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KC,qBACxCjB,GAAWgB,EAAKC,mBAIhBD,EAAKG,gBACLD,OAAOF,EAAKG,kBACX1B,EAAAA,GAAc2B,oCAEfpB,GAAWgB,EAAKG,gBAGdH,EAAKK,eAAiBH,OAAOF,EAAKK,iBACpCrB,GAAWgB,EAAKK,eAGXpC,EAAiB,CACtBe,UACAG,SAAS,EACTC,cAAeY,EAAKM,gBACpB,C","sources":["utils/account/calculate-balance.ts"],"sourcesContent":["import SpringConfigs from 'utils/constants/swarm/spring-configs';\n\ninterface Params {\n  balance?: number;\n  isBonus?: boolean;\n  casinoBalance?: number;\n}\n\nexport const calculateBalance = (\n  params: Params,\n  frozenBalance = 0,\n  rounding = SpringConfigs.PRICE_ROUNDING,\n  separator = SpringConfigs.PRICE_SEPARATOR,\n  hideTrailingZeros = SpringConfigs.HIDE_TRAILING_ZEROES\n): string => {\n  let calculatedBalance = ((params.balance ?? 0) - frozenBalance).toFixed(\n    rounding\n  );\n\n  if (\n    SpringConfigs.CASINO_BALANCE_IN_USER_BALANCE &&\n    !params.isBonus &&\n    params.casinoBalance\n  ) {\n    switch (SpringConfigs.CASINO_SPORTSBOOK_SWITCHER) {\n      case 0:\n        calculatedBalance = (\n          parseFloat(calculatedBalance) + params.casinoBalance\n        ).toFixed(rounding);\n\n        break;\n      case 2:\n        calculatedBalance = (params.casinoBalance - frozenBalance).toFixed(\n          rounding\n        );\n\n        break;\n    }\n  }\n\n  const filteredBalance = +calculatedBalance - parseInt(calculatedBalance);\n\n  if (separator) {\n    const parts = calculatedBalance.toString().split('.');\n    parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, separator);\n    calculatedBalance = parts.join('.');\n  }\n\n  if (hideTrailingZeros && filteredBalance === 0) {\n    return calculatedBalance.toString().split('.')[0];\n  }\n\n  return calculatedBalance;\n};\n\nexport const calculateCasinoBalance = (\n  balance: number,\n  rounding = SpringConfigs.PRICE_ROUNDING\n): string => {\n  return (balance ?? 0).toFixed(rounding);\n};\n\nexport const calculateBonus = (user: Record<string, any>): string => {\n  let balance = 0;\n\n  if (user.bonus_win_balance && Number(user.bonus_win_balance)) {\n    balance += user.bonus_win_balance;\n  }\n\n  if (\n    user.frozen_balance &&\n    Number(user.frozen_balance) &&\n    !SpringConfigs.SHOULD_IGNORE_USER_FROZEN_BALANCE\n  ) {\n    balance += user.frozen_balance;\n  }\n\n  if (user.bonus_balance && Number(user.bonus_balance)) {\n    balance += user.bonus_balance;\n  }\n\n  return calculateBalance({\n    balance,\n    isBonus: true,\n    casinoBalance: user.casino_balance\n  });\n};\n"],"names":["calculateBalance","params","_params$balance","frozenBalance","arguments","length","undefined","rounding","SpringConfigs","PRICE_ROUNDING","separator","PRICE_SEPARATOR","hideTrailingZeros","HIDE_TRAILING_ZEROES","calculatedBalance","balance","toFixed","CASINO_BALANCE_IN_USER_BALANCE","isBonus","casinoBalance","CASINO_SPORTSBOOK_SWITCHER","parseFloat","filteredBalance","parseInt","parts","toString","split","replace","join","calculateCasinoBalance","calculateBonus","user","bonus_win_balance","Number","frozen_balance","SHOULD_IGNORE_USER_FROZEN_BALANCE","bonus_balance","casino_balance"],"sourceRoot":""}