{"version":3,"file":"useChartValueFormatter.cjs","names":["_react","require","_i18n","_formatChartValue","useChartValueFormatter","i18n","useTranslation","languageCode","language","useCallback","format","value","formatChartValue","exports"],"sources":["../../../../src/charts/utils/useChartValueFormatter.ts"],"sourcesContent":["/*!\n * Copyright (c) 2026-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { useCallback } from \"react\";\n\nimport { useTranslation } from \"../../i18n.generated/i18n.js\";\nimport {\n  formatChartValue,\n  type FormatChartValueProps,\n} from \"./formatChartValue.js\";\n\n/**\n * The formatter functions from {@link useChartValueFormatter} accept these props. The props match {@link FormatChartValueProps}, but without `languageCode`. The hook binds the `languageCode` field from context.\n */\nexport type ChartValueFormatterProps = Omit<\n  FormatChartValueProps,\n  \"languageCode\"\n>;\n\n/**\n * Formats a chart value with the active locale.\n */\nexport type ChartValueFormatter = (props: ChartValueFormatterProps) => string;\n\n/**\n * The hook reads the active language code from the Odyssey translation context. The hook returns a version of {@link formatChartValue} that uses that locale. A consumer only needs to supply `value` and an optional `format`.\n *\n * The returned function stays referentially stable while the active language stays the same. This makes it safe to add as a dependency of a consumer's `useMemo`.\n */\nexport const useChartValueFormatter = (): ChartValueFormatter => {\n  const { i18n } = useTranslation();\n  const languageCode = i18n.language;\n\n  return useCallback<ChartValueFormatter>(\n    ({ format, value }) => formatChartValue({ format, languageCode, value }),\n    [languageCode],\n  );\n};\n"],"mappings":";;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GA4BO,MAAMG,sBAAsB,GAAGA,CAAA,KAA2B;EAC/D,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,oBAAc,EAAC,CAAC;EACjC,MAAMC,YAAY,GAAGF,IAAI,CAACG,QAAQ;EAElC,OAAO,IAAAC,kBAAW,EAChB,CAAC;IAAEC,MAAM;IAAEC;EAAM,CAAC,KAAK,IAAAC,kCAAgB,EAAC;IAAEF,MAAM;IAAEH,YAAY;IAAEI;EAAM,CAAC,CAAC,EACxE,CAACJ,YAAY,CACf,CAAC;AACH,CAAC;AAACM,OAAA,CAAAT,sBAAA,GAAAA,sBAAA","ignoreList":[]}