{
  "version": 3,
  "sources": ["../../src/utils/transactions/getDecodedDataField/getDecodedDataField.ts"],
  "sourcesContent": ["import { MAX_DECODE_TX_DATA_LENGTH } from 'constants/transactions.constants';\nimport {\n  DecodeMethodEnum,\n  DecodedDisplayType\n} from 'types/serverTransactions.types';\nimport { decodeByMethod } from './helpers/decodeByMethod';\nimport { decodeHighlight } from './helpers/decodeHighlight';\nimport { getDecodedParts } from './helpers/getDecodedParts';\nimport { getDisplayValueAndValidationWarnings } from './helpers/getDisplayValueAndValidationWarnings';\n\ninterface IDecodedDataField {\n  data: string;\n  decodeMethod: DecodeMethodEnum;\n  identifier?: string;\n  highlight?: string | null;\n}\n\nexport const getDecodedDataField = ({\n  data,\n  decodeMethod,\n  identifier,\n  highlight = null\n}: IDecodedDataField): DecodedDisplayType => {\n  const decodedData: DecodedDisplayType = {\n    displayValue: '',\n    validationWarnings: [],\n    highlight\n  };\n\n  if (\n    data.length > MAX_DECODE_TX_DATA_LENGTH &&\n    [DecodeMethodEnum.decimal, DecodeMethodEnum.smart].includes(decodeMethod)\n  ) {\n    return {\n      ...decodedData,\n      displayValue: data\n    };\n  }\n\n  const hasAt = data.includes('@');\n  const hasNewLine = data.includes('\\n');\n\n  if (!hasAt && !hasNewLine) {\n    return {\n      ...decodedData,\n      displayValue: decodeByMethod({ data, decodeMethod }),\n      highlight: highlight\n        ? decodeByMethod({ data: highlight, decodeMethod })\n        : highlight\n    };\n  }\n\n  if (hasAt) {\n    const parts = data.split('@');\n    const decodedParts = getDisplayValueAndValidationWarnings({\n      parts,\n      decodeMethod,\n      identifier,\n      decodedData\n    });\n\n    const decodedHighlight = highlight\n      ? decodeHighlight({\n          data: highlight,\n          identifier,\n          decodeMethod,\n          delimiter: '@'\n        })\n      : null;\n\n    return {\n      ...decodedData,\n      displayValue: decodedParts.join('@'),\n      highlight: decodedHighlight\n    };\n  }\n\n  if (hasNewLine) {\n    const parts = data.split('\\n');\n\n    const initialDecodedParts = parts.map((part) => {\n      if (decodeMethod === DecodeMethodEnum.raw) {\n        return part;\n      }\n\n      return decodeByMethod({\n        data: Buffer.from(part, 'base64').toString('hex'),\n        decodeMethod\n      });\n    });\n\n    const decodedParts = getDecodedParts({\n      parts,\n      initialDecodedParts,\n      identifier,\n      decodeMethod\n    });\n\n    const decodedHighlight = highlight\n      ? decodeHighlight({\n          data: highlight,\n          identifier,\n          decodeMethod,\n          delimiter: '\\n'\n        })\n      : null;\n\n    return {\n      ...decodedData,\n      displayValue: decodedParts.join('\\n'),\n      highlight: decodedHighlight\n    };\n  }\n\n  return decodedData;\n};\n"],
  "mappings": "6MAiBO,IAAMA,EAAsB,CAAC,CAClC,KAAAC,EACA,aAAAC,EACA,WAAAC,EACA,UAAAC,EAAY,IACd,IAA6C,CAC3C,IAAMC,EAAkC,CACtC,aAAc,GACd,mBAAoB,CAAC,EACrB,UAAAD,CACF,EAEA,GACEH,EAAK,OAAS,MACd,kBAAiD,EAAE,SAASC,CAAY,EAExE,MAAO,CACL,GAAGG,EACH,aAAcJ,CAChB,EAGF,IAAMK,EAAQL,EAAK,SAAS,GAAG,EACzBM,EAAaN,EAAK,SAAS;AAAA,CAAI,EAErC,GAAI,CAACK,GAAS,CAACC,EACb,MAAO,CACL,GAAGF,EACH,aAAcG,EAAe,CAAE,KAAAP,EAAM,aAAAC,CAAa,CAAC,EACnD,UAAWE,GACPI,EAAe,CAAE,KAAMJ,EAAW,aAAAF,CAAa,CAAC,CAEtD,EAGF,GAAII,EAAO,CACT,IAAMG,EAAQR,EAAK,MAAM,GAAG,EACtBS,EAAeC,EAAqC,CACxD,MAAAF,EACA,aAAAP,EACA,WAAAC,EACA,YAAAE,CACF,CAAC,EAEKO,EAAmBR,EACrBS,EAAgB,CACd,KAAMT,EACN,WAAAD,EACA,aAAAD,EACA,UAAW,GACb,CAAC,EACD,KAEJ,MAAO,CACL,GAAGG,EACH,aAAcK,EAAa,KAAK,GAAG,EACnC,UAAWE,CACb,CACF,CAEA,GAAIL,EAAY,CACd,IAAME,EAAQR,EAAK,MAAM;AAAA,CAAI,EAEvBa,EAAsBL,EAAM,IAAKM,GACjCb,UACKa,EAGFP,EAAe,CACpB,KAAM,OAAO,KAAKO,EAAM,QAAQ,EAAE,SAAS,KAAK,EAChD,aAAAb,CACF,CAAC,CACF,EAEKQ,EAAeM,EAAgB,CACnC,MAAAP,EACA,oBAAAK,EACA,WAAAX,EACA,aAAAD,CACF,CAAC,EAEKU,EAAmBR,EACrBS,EAAgB,CACd,KAAMT,EACN,WAAAD,EACA,aAAAD,EACA,UAAW;AAAA,CACb,CAAC,EACD,KAEJ,MAAO,CACL,GAAGG,EACH,aAAcK,EAAa,KAAK;AAAA,CAAI,EACpC,UAAWE,CACb,CACF,CAEA,OAAOP,CACT",
  "names": ["getDecodedDataField", "data", "decodeMethod", "identifier", "highlight", "decodedData", "hasAt", "hasNewLine", "decodeByMethod", "parts", "decodedParts", "getDisplayValueAndValidationWarnings", "decodedHighlight", "decodeHighlight", "initialDecodedParts", "part", "getDecodedParts"]
}
