{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAWD,MAAM,8BAAQ,IAAI;AAClB,SAAS,0CACP,OAA+B;IAE/B,IAAI,aAAa,4BAAM,GAAG,CAAC;IAC3B,IAAI,CAAC,YAAY;QACf,aAAa,IAAI,CAAA,GAAA,wDAAwB,EAAE;QAC3C,4BAAM,GAAG,CAAC,SAAS;IACrB;IAEA,OAAO;AACT;AAKO,SAAS,0CAGd,OAA+B,EAAE,WAAoB;IACrD,OACE,AAAC,eAAe,CAAA,GAAA,wDAAwB,EAAE,6BAA6B,CAAC,gBACxE,0CAAoB;AAExB;AASO,SAAS,0CAGd,OAA+B,EAAE,WAAoB;IACrD,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,mCAAQ;IACvB,IAAI,aAAa,0CAA6B,SAAS;IACvD,OAAO,CAAA,GAAA,oBAAM,EAAE,IAAM,IAAI,CAAA,GAAA,uDAAuB,EAAE,QAAQ,aAAa;QAAC;QAAQ;KAAW;AAC7F","sources":["packages/react-aria/src/i18n/useLocalizedStringFormatter.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n  LocalizedString,\n  LocalizedStringDictionary,\n  LocalizedStringFormatter,\n  LocalizedStrings\n} from '@internationalized/string';\nimport {useLocale} from './I18nProvider';\nimport {useMemo} from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(\n  strings: LocalizedStrings<K, T>\n): LocalizedStringDictionary<K, T> {\n  let dictionary = cache.get(strings);\n  if (!dictionary) {\n    dictionary = new LocalizedStringDictionary(strings);\n    cache.set(strings, dictionary);\n  }\n\n  return dictionary;\n}\n\n/**\n * Returns a cached LocalizedStringDictionary for the given strings.\n */\nexport function useLocalizedStringDictionary<\n  K extends string = string,\n  T extends LocalizedString = string\n>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringDictionary<K, T> {\n  return (\n    (packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName)) ||\n    getCachedDictionary(strings)\n  );\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the\n * locale changes.\n *\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<\n  K extends string = string,\n  T extends LocalizedString = string\n>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringFormatter<K, T> {\n  let {locale} = useLocale();\n  let dictionary = useLocalizedStringDictionary(strings, packageName);\n  return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n"],"names":[],"version":3,"file":"useLocalizedStringFormatter.cjs.map"}