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gB,EAAUhB,QAAQ,KAC1CgB,EAAUpB,QAAQ,wBAAyB,KAC3CoB,EACGJ,MAAM,KAAK,GACXhB,QAAQ,wBAAyB,KACjCsB,OAAO,IAAKF,EAAUJ,MAAM,KAAK,GAAGhB,QAAQ,IAAK,KACtDJ,CAAK,EAGE2B,EAAe3B,GACtBA,EACKA,EAAMI,QAAQ,IAAK,IAGrBJ,EAOI4B,EAA0BA,CACrCC,EACAC,KAEA,IAAIC,GAAiB,EAUrB,OARAC,OAAOC,QAAQJ,GAAUK,SAAQC,IAAyB,IAAvBC,EAAKpC,GAAMmC,EAC5C,MAAME,EAAeP,EAAYM,GAE7BE,OAAOD,KAAkBC,OAAOtC,KAClC+B,GAAiB,EACnB,IAGKA,CAAc,EAGVQ,EACXvB,IAEA,MAAMC,EAASD,EAAMC,OAErBA,EAAOjB,MAAQiB,EAAOjB,MAAMI,QADd,UAC6B,GAAG,C","sources":["utils/constants/betslip/index.ts","utils/helpers/validators.ts"],"sourcesContent":["import SpringConfigs from '../swarm/spring-configs';\n\nexport const BETSLIP_STAKE_LIMIT = 9;\nexport const BETSLIP_STAKE_LIMIT_WITH_COMMA = BETSLIP_STAKE_LIMIT + 2;\nexport const SEPARATOR = SpringConfigs.PRICE_SEPARATOR === ',';\n","import { FormEventHandler } from 'react';\nimport { SEPARATOR } from 'utils/constants/betslip';\n\nexport const getIsPositiveNumber = (value: string): boolean =>\n  /^[+]?((?!00\\d*$)[0-9]+(?:[.][0-9]*)?|\\.[0-9]+)$/.test(value);\n\nexport const getValidPositiveNumber = (\n  value?: string,\n  separator?: boolean\n): string | undefined => {\n  if (!value) {\n    return;\n  }\n\n  if (value.includes(',') && !separator) {\n    value = value.replace(',', '.');\n  }\n\n  value = value.replace(/[^\\d.]/g, '');\n  let formattedValue = String(value?.replace(',', '.'));\n\n  if (formattedValue.includes('.')) {\n    const indexOfFirst = formattedValue.indexOf('.');\n    const indexOfSecond = formattedValue.indexOf('.', indexOfFirst + 1);\n\n    if (indexOfSecond !== -1) {\n      formattedValue = formattedValue.substring(0, indexOfSecond);\n    }\n  }\n\n  let updatedValue = null;\n\n  if (\n    formattedValue.length === 2 &&\n    +formattedValue[0] === 0 &&\n    formattedValue[1] !== '.'\n  ) {\n    updatedValue = `0.${formattedValue[1]}`;\n  }\n\n  if (getIsPositiveNumber(formattedValue) || !value || updatedValue) {\n    return updatedValue || formattedValue;\n  }\n};\n\nexport const getValidDecimalInput: FormEventHandler<HTMLInputElement> = (\n  event\n): void => {\n  const target = event.target as HTMLInputElement;\n  const regex = /[^0-9.]/g;\n\n  if (`${target.value || ''}`.charAt(0) === '.') {\n    target.value = `0${target.value}`;\n  } else {\n    if (target.value.split('.').length > 2) {\n      target.value = target.value.slice(0, target.value.lastIndexOf('.'));\n    } else {\n      target.value = target.value.replace(regex, '');\n    }\n  }\n};\n\nexport const thousandSeparator = (value: string | number): string | number => {\n  const valString = value?.toString() || '';\n\n  return SEPARATOR && value\n    ? valString.indexOf('.') <= valString.indexOf(',')\n      ? valString.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n      : valString\n          .split('.')[0]\n          .replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n          .concat('.', valString.split('.')[1].replace(',', ''))\n    : value;\n};\n\nexport const removeComma = (value: string): string => {\n  if (value) {\n    return value.replace(',', '');\n  }\n\n  return value;\n};\n\ntype TCheckInitialLimitValues = {\n  [key: string]: string | number | undefined;\n};\n\nexport const checkInitialLimitValues = (\n  formData: TCheckInitialLimitValues,\n  initialData: TCheckInitialLimitValues\n): boolean => {\n  let isFieldTouched = false;\n\n  Object.entries(formData).forEach(([key, value]): void => {\n    const initialValue = initialData[key as keyof typeof initialData];\n\n    if (Number(initialValue) !== Number(value)) {\n      isFieldTouched = true;\n    }\n  });\n\n  return isFieldTouched;\n};\n\nexport const getValidDecimalInputNoDot: FormEventHandler<HTMLInputElement> = (\n  event\n): void => {\n  const target = event.target as HTMLInputElement;\n  const regex = /[^0-9]/g;\n  target.value = target.value.replace(regex, '');\n};\n"],"names":["BETSLIP_STAKE_LIMIT","BETSLIP_STAKE_LIMIT_WITH_COMMA","SEPARATOR","SpringConfigs","PRICE_SEPARATOR","getValidPositiveNumber","value","separator","_value","includes","replace","formattedValue","String","indexOfFirst","indexOf","indexOfSecond","substring","updatedValue","length","test","getIsPositiveNumber","getValidDecimalInput","event","target","regex","charAt","split","slice","lastIndexOf","thousandSeparator","valString","toString","concat","removeComma","checkInitialLimitValues","formData","initialData","isFieldTouched","Object","entries","forEach","_ref","key","initialValue","Number","getValidDecimalInputNoDot"],"sourceRoot":""}