{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n *   currency: \"JPY\",\n *   fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n  const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n  return (...args: Parameters<typeof currency>) =>\n    currency(args[0], {\n      ...args[1],\n      locale: args[1]?.locale ?? locale,\n    });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}