{
  "version": 3,
  "sources": ["../../src/controllers/FormatAmountController/FormatAmountController.ts"],
  "sourcesContent": ["import { stringIsInteger, stringIsFloat, formatAmount } from 'lib/sdkDappUtils';\nimport { FormatAmountControllerPropsType, FormatedAmountType } from './types';\n\nexport class FormatAmountController {\n  public static getData(\n    props: FormatAmountControllerPropsType\n  ): FormatedAmountType {\n    const { input } = props;\n\n    if (!input || !stringIsInteger(input)) {\n      return {\n        isValid: false,\n        label: this.getLabel(props),\n        valueInteger: '0',\n        valueDecimal: this.formatDecimalPart('0', props.digits)\n      };\n    }\n\n    const formattedAmount = formatAmount(props);\n    const isValid = stringIsFloat(formattedAmount.replaceAll(',', ''));\n    const [valueInteger, valueDecimal] = formattedAmount.split('.');\n\n    return {\n      isValid,\n      label: this.getLabel(props),\n      valueInteger: valueInteger || '0',\n      valueDecimal: this.formatDecimalPart(valueDecimal, props.digits)\n    };\n  }\n\n  private static getLabel(props: FormatAmountControllerPropsType): string {\n    return ` ${props.token ?? props.egldLabel ?? ''}`.trimEnd();\n  }\n\n  private static formatDecimalPart(decimalPart = '', digits = 2): string {\n    const padded = decimalPart.padEnd(digits, '0').slice(0, digits);\n    return `.${padded || '0'.repeat(digits)}`;\n  }\n}\n"],
  "mappings": "uDAGO,IAAMA,EAAN,KAA6B,CAClC,OAAc,QACZC,EACoB,CACpB,GAAM,CAAE,MAAAC,CAAM,EAAID,EAElB,GAAI,CAACC,GAAS,CAACC,EAAgBD,CAAK,EAClC,MAAO,CACL,QAAS,GACT,MAAO,KAAK,SAASD,CAAK,EAC1B,aAAc,IACd,aAAc,KAAK,kBAAkB,IAAKA,EAAM,MAAM,CACxD,EAGF,IAAMG,EAAkBC,EAAaJ,CAAK,EACpCK,EAAUC,EAAcH,EAAgB,WAAW,IAAK,EAAE,CAAC,EAC3D,CAACI,EAAcC,CAAY,EAAIL,EAAgB,MAAM,GAAG,EAE9D,MAAO,CACL,QAAAE,EACA,MAAO,KAAK,SAASL,CAAK,EAC1B,aAAcO,GAAgB,IAC9B,aAAc,KAAK,kBAAkBC,EAAcR,EAAM,MAAM,CACjE,CACF,CAEA,OAAe,SAASA,EAAgD,CACtE,MAAO,IAAIA,EAAM,OAASA,EAAM,WAAa,EAAE,GAAG,QAAQ,CAC5D,CAEA,OAAe,kBAAkBS,EAAc,GAAIC,EAAS,EAAW,CAErE,MAAO,IADQD,EAAY,OAAOC,EAAQ,GAAG,EAAE,MAAM,EAAGA,CAAM,GACzC,IAAI,OAAOA,CAAM,CAAC,EACzC,CACF",
  "names": ["FormatAmountController", "props", "input", "stringIsInteger", "formattedAmount", "formatAmount", "isValid", "stringIsFloat", "valueInteger", "valueDecimal", "decimalPart", "digits"]
}
