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,kDCJzB,MA4PaG,EAA4Ce,IAKlD,IALmD,OACxDnB,EAAM,OACNC,EAAM,KACN6B,EAAI,SACJzB,GACDc,EACC,OAAO,IAAIL,SAAwBiB,KACjCC,EAAAA,EAAAA,IACE,CACEC,OAAQjC,EACRkC,OAAQjC,EACRkC,KAAML,IAERxB,IACE,IAAKA,EAAK8B,QAAU9B,EAAK+B,QAAQC,OAAS,EAAG,CAC3C,MAAMC,EAAuBjC,EAAK+B,QAAQzC,QACxC,CAAC4C,EAAKC,IACJA,EAAKC,OACD,IACKF,EACH,CACEG,MAAOF,EAAKC,OACZE,MAAOH,EAAKI,GACZC,WAAYL,EAAKM,sBAGrBP,GACN,IAGFT,EAAQQ,GAEA,OAARlC,QAAQ,IAARA,GAAAA,EAAWC,EAAK+B,QAClB,CAEAN,EAAQ,GAAG,IAEb,KACEA,EAAQ,GAAG,GAEd,GACD,C","sources":["newelements/_Betslip/managers/FreeBetManager/utils/fetchFreeBetAmounts/single.ts","newelements/_Betslip/managers/FreeBetManager/BetTypeBaseSlice/single.tsx","newelements/_Betslip/managers/FreeBetManager/utils/build-free-bet-args-from-bets.ts","newelements/_Betslip/managers/FreeBetManager/utils/fetchFreeBetAmounts/index.ts"],"sourcesContent":["import { FreeBetData, TAdvancedFreebet } from 'interfaces/bet-data';\nimport { buildFreeBetArgsFromBets } from 'newelements/_Betslip/managers/FreeBetManager/utils/build-free-bet-args-from-bets';\nimport { fetchFreeBetAmounts } from 'newelements/_Betslip/managers/FreeBetManager/utils/fetchFreeBetAmounts/index';\nimport { fireCheckProfitBoost } from 'newelements/_Betslip/managers/ProfitBoostManager/actions';\nimport store from 'store';\nimport { setFreeBetField, updateSingleEvents } from 'store/actions';\nimport { IBetslipRootStateInitialData } from 'store/reducers/betslip';\n\nexport const getSingleEventsFreeBets = () => {\n  const betslipStore: IBetslipRootStateInitialData = store.getState()?.betSlip;\n\n  const allBets = betslipStore.allLsBets;\n  const freeBetStore = betslipStore.freeBets;\n\n  const singleEventFreeBets: FreeBetData = {};\n\n  const getFreeBetPromises = allBets.reduce<\n    ReturnType<typeof fetchFreeBetAmounts>[]\n  >((promises, bet) => {\n    if (freeBetStore.singleEventFreeBets[bet.eventId]) {\n      return promises;\n    }\n\n    const [events, isLive] = buildFreeBetArgsFromBets([bet]);\n\n    const callback = (data: TAdvancedFreebet[]) =>\n      fireCheckProfitBoost(data, bet.eventId);\n\n    const amountsPromise = fetchFreeBetAmounts({\n      events,\n      isLive,\n      callback\n    });\n\n    amountsPromise.then(amounts => {\n      singleEventFreeBets[bet.eventId] = amounts;\n    });\n\n    return [...promises, amountsPromise];\n  }, []);\n\n  if (\n    freeBetStore.selectedFreeBetEventId &&\n    !allBets.find(bet => bet.eventId === freeBetStore.selectedFreeBetEventId)\n  ) {\n    store.dispatch(\n      setFreeBetField({\n        selectedFreeBetEventId: null\n      })\n    );\n  }\n\n  Promise.all(getFreeBetPromises).finally(() => {\n    store.dispatch(updateSingleEvents(singleEventFreeBets));\n  });\n};\n","import { FC, useLayoutEffect } from 'react';\nimport { EFreeBetsActions } from 'newelements/_Betslip/managers/FreeBetManager/actions';\nimport { TFreeBetManagerSlicesProps } from 'newelements/_Betslip/managers/FreeBetManager/types';\nimport { getSingleEventsFreeBets } from 'newelements/_Betslip/managers/FreeBetManager/utils/fetchFreeBetAmounts/single';\nimport { useEventbus } from 'newhooks/generic/useEventbus';\n\n// in this slice wrote freeBet data fetching for single bets and switching freeBet selector logic\nexport const FreeBetManagerSliceSingle: FC<TFreeBetManagerSlicesProps> = ({\n  getOnMount = false\n}) => {\n  useLayoutEffect(() => {\n    if (getOnMount) {\n      getSingleEventsFreeBets();\n    }\n  }, []);\n\n  useEventbus({\n    [EFreeBetsActions.GET_FREE_BETS]: getSingleEventsFreeBets\n  });\n\n  return null;\n};\n","import { BetSlipEventObj, TGetFreeBetAmountEvent } from 'interfaces/bet-data';\n\ntype TBuildFreeBetArgsFromBets = (\n  allBets: BetSlipEventObj[]\n) => [events: TGetFreeBetAmountEvent[], isLive: boolean];\n\nexport const buildFreeBetArgsFromBets: TBuildFreeBetArgsFromBets = allBets => {\n  let isLive = false;\n  const events: TGetFreeBetAmountEvent[] = allBets.map(bet => {\n    if (!isLive && bet.isLive) {\n      isLive = bet.isLive;\n    }\n\n    return {\n      Coeficient: Number(bet.coeficient),\n      SelectionId: bet.eventId\n    };\n  });\n\n  return [events, isLive];\n};\n","import {\n  FreeBetAmounts,\n  TAdvancedFreebet,\n  TGetFreeBetAmountEvent\n} from 'interfaces/bet-data';\nimport { getV3Freebet } from 'services/bet-slip';\n\ntype TFetchFreeBetAmounts = (params: {\n  events: TGetFreeBetAmountEvent[];\n  isLive: boolean;\n  type?: number;\n  callback?: (data: TAdvancedFreebet[]) => void;\n}) => Promise<FreeBetAmounts>;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst mockedFreeBetsResponse = {\n  result: 0,\n  result_text: null,\n  details: [\n    {\n      id: 712612332,\n      amount: 5,\n      expiration_date: 1714641075,\n      bet_types: [2, 1]\n    },\n    {\n      id: 712782254,\n      amount: 4,\n      expiration_date: 1714652711,\n      bet_types: [2, 1]\n    },\n    {\n      id: 712782453,\n      amount: 3,\n      expiration_date: 1714652719,\n      bet_types: [2, 1]\n    },\n    {\n      id: 712782681,\n      amount: 5,\n      expiration_date: 1714652728,\n      bet_types: [2, 1]\n    },\n    {\n      id: 718389058,\n      amount_percent: 8,\n      bet_type: 0,\n      expiration_date: 1714466644,\n      boost_max_bet_amounts: [\n        {\n          Currency: 'EUR',\n          MaxBetAmount: 75\n        },\n        {\n          Currency: 'USD',\n          MaxBetAmount: 75\n        },\n        {\n          Currency: 'GHS',\n          MaxBetAmount: 600\n        },\n        {\n          Currency: 'IDR',\n          MaxBetAmount: 1000\n        },\n        {\n          Currency: 'KZT',\n          MaxBetAmount: 40000\n        },\n        {\n          Currency: 'KES',\n          MaxBetAmount: 9000\n        },\n        {\n          Currency: 'MYR',\n          MaxBetAmount: 350\n        },\n        {\n          Currency: 'RUB',\n          MaxBetAmount: 5500\n        },\n        {\n          Currency: 'THB',\n          MaxBetAmount: 2700\n        },\n        {\n          Currency: 'VND',\n          MaxBetAmount: 1800\n        },\n        {\n          Currency: 'CAD',\n          MaxBetAmount: 100\n        },\n        {\n          Currency: 'AMD',\n          MaxBetAmount: 35000\n        },\n        {\n          Currency: 'KRW',\n          MaxBetAmount: 100000\n        },\n        {\n          Currency: 'BDT',\n          MaxBetAmount: 8500\n        },\n        {\n          Currency: 'FTN',\n          MaxBetAmount: 100\n        },\n        {\n          Currency: 'UAH',\n          MaxBetAmount: 3000\n        }\n      ]\n    },\n    {\n      id: 718389064,\n      amount_percent: 10,\n      bet_type: 0,\n      expiration_date: 1714466645,\n      boost_max_bet_amounts: [\n        {\n          Currency: 'EUR',\n          MaxBetAmount: 50\n        },\n        {\n          Currency: 'USD',\n          MaxBetAmount: 50\n        },\n        {\n          Currency: 'GHS',\n          MaxBetAmount: 400\n        },\n        {\n          Currency: 'IDR',\n          MaxBetAmount: 750\n        },\n        {\n          Currency: 'KZT',\n          MaxBetAmount: 25000\n        },\n        {\n          Currency: 'KES',\n          MaxBetAmount: 6000\n        },\n        {\n          Currency: 'MYR',\n          MaxBetAmount: 200\n        },\n        {\n          Currency: 'RUB',\n          MaxBetAmount: 3500\n        },\n        {\n          Currency: 'THB',\n          MaxBetAmount: 1800\n        },\n        {\n          Currency: 'VND',\n          MaxBetAmount: 1200\n        },\n        {\n          Currency: 'CAD',\n          MaxBetAmount: 75\n        },\n        {\n          Currency: 'AMD',\n          MaxBetAmount: 25000\n        },\n        {\n          Currency: 'KRW',\n          MaxBetAmount: 67000\n        },\n        {\n          Currency: 'BDT',\n          MaxBetAmount: 5600\n        },\n        {\n          Currency: 'FTN',\n          MaxBetAmount: 75\n        },\n        {\n          Currency: 'UAH',\n          MaxBetAmount: 2000\n        }\n      ]\n    },\n    {\n      id: 718389068,\n      amount_percent: 5,\n      bet_type: 0,\n      expiration_date: 1714466645,\n      boost_max_bet_amounts: [\n        {\n          Currency: 'EUR',\n          MaxBetAmount: 100\n        },\n        {\n          Currency: 'USD',\n          MaxBetAmount: 100\n        },\n        {\n          Currency: 'GHS',\n          MaxBetAmount: 75\n        },\n        {\n          Currency: 'IDR',\n          MaxBetAmount: 1500\n        },\n        {\n          Currency: 'KZT',\n          MaxBetAmount: 50000\n        },\n        {\n          Currency: 'KES',\n          MaxBetAmount: 12000\n        },\n        {\n          Currency: 'MYR',\n          MaxBetAmount: 450\n        },\n        {\n          Currency: 'RUB',\n          MaxBetAmount: 7000\n        },\n        {\n          Currency: 'THB',\n          MaxBetAmount: 3500\n        },\n        {\n          Currency: 'VND',\n          MaxBetAmount: 2500\n        },\n        {\n          Currency: 'CAD',\n          MaxBetAmount: 150\n        },\n        {\n          Currency: 'AMD',\n          MaxBetAmount: 50000\n        },\n        {\n          Currency: 'KRW',\n          MaxBetAmount: 135000\n        },\n        {\n          Currency: 'BDT',\n          MaxBetAmount: 11300\n        },\n        {\n          Currency: 'UZS',\n          MaxBetAmount: 1250000\n        },\n        {\n          Currency: 'FTN',\n          MaxBetAmount: 120\n        },\n        {\n          Currency: 'UAH',\n          MaxBetAmount: 4000\n        }\n      ]\n    }\n  ]\n};\n\n// @Todo need to create some type for freeBet call and do Bet call (based on bet type) betslip-type\nexport const fetchFreeBetAmounts: TFetchFreeBetAmounts = ({\n  events,\n  isLive,\n  type,\n  callback\n}) => {\n  return new Promise<FreeBetAmounts>(resolve => {\n    getV3Freebet(\n      {\n        Events: events,\n        IsLive: isLive,\n        Type: type\n      },\n      data => {\n        if (!data.result && data.details.length > 0) {\n          const advancedFreeBetsData = data.details.reduce<FreeBetAmounts>(\n            (acc, item) =>\n              item.amount\n                ? [\n                    ...acc,\n                    {\n                      label: item.amount,\n                      value: item.id,\n                      maxPayouts: item.freebet_max_payouts\n                    }\n                  ]\n                : acc,\n            []\n          );\n\n          resolve(advancedFreeBetsData);\n\n          callback?.(data.details);\n        }\n\n        resolve([]);\n      },\n      () => {\n        resolve([]);\n      }\n    );\n  });\n};\n"],"names":["getSingleEventsFreeBets","_store$getState","betslipStore","store","getState","betSlip","allBets","allLsBets","freeBetStore","freeBets","singleEventFreeBets","getFreeBetPromises","reduce","promises","bet","eventId","events","isLive","buildFreeBetArgsFromBets","amountsPromise","fetchFreeBetAmounts","callback","data","fireCheckProfitBoost","then","amounts","selectedFreeBetEventId","find","dispatch","setFreeBetField","Promise","all","finally","updateSingleEvents","FreeBetManagerSliceSingle","_ref","getOnMount","useLayoutEffect","useEventbus","EFreeBetsActions","GET_FREE_BETS","map","Coeficient","Number","coeficient","SelectionId","type","resolve","getV3Freebet","Events","IsLive","Type","result","details","length","advancedFreeBetsData","acc","item","amount","label","value","id","maxPayouts","freebet_max_payouts"],"sourceRoot":""}