{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nimport $4oXB5$react, { useContext as $4oXB5$useContext, useState as $4oXB5$useState, useEffect as $4oXB5$useEffect, useMemo as $4oXB5$useMemo, useCallback as $4oXB5$useCallback, useRef as $4oXB5$useRef } from \"react\";\nimport { useIsSSR as $4oXB5$useIsSSR } from \"@react-aria/ssr\";\nimport { MessageDictionary as $4oXB5$MessageDictionary, MessageFormatter as $4oXB5$MessageFormatter } from \"@internationalized/message\";\nimport { DateFormatter as $4oXB5$DateFormatter } from \"@internationalized/date\";\nimport { NumberFormatter as $4oXB5$NumberFormatter } from \"@internationalized/number\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $1bbc62ad423ac4ed$exports = {};\n$parcel$export($1bbc62ad423ac4ed$exports, \"I18nProvider\", function () {\n  return $1bbc62ad423ac4ed$export$a54013f0d02a8f82;\n});\n$parcel$export($1bbc62ad423ac4ed$exports, \"useLocale\", function () {\n  return $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7;\n});\nvar $1ad791d3e8a33aa4$var$RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nvar $1ad791d3e8a33aa4$var$RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\nfunction $1ad791d3e8a33aa4$export$702d680b21cbd764(locale) {\n  if (Intl.Locale) {\n    var script = new Intl.Locale(locale).maximize().script;\n    return $1ad791d3e8a33aa4$var$RTL_SCRIPTS.has(script);\n  }\n\n  var lang = locale.split('-')[0];\n  return $1ad791d3e8a33aa4$var$RTL_LANGS.has(lang);\n}\n\nfunction $9a70206312150f3d$export$f09106e7c6677ec5() {\n  var locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';\n  return {\n    locale: locale,\n    direction: $1ad791d3e8a33aa4$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'\n  };\n}\n\nvar $9a70206312150f3d$var$currentLocale = $9a70206312150f3d$export$f09106e7c6677ec5();\nvar $9a70206312150f3d$var$listeners = new Set();\n\nfunction $9a70206312150f3d$var$updateLocale() {\n  $9a70206312150f3d$var$currentLocale = $9a70206312150f3d$export$f09106e7c6677ec5();\n\n  for (var _iterator = _createForOfIteratorHelperLoose($9a70206312150f3d$var$listeners), _step; !(_step = _iterator()).done;) {\n    var listener = _step.value;\n    listener($9a70206312150f3d$var$currentLocale);\n  }\n}\n\nfunction $9a70206312150f3d$export$188ec29ebc2bdc3a() {\n  var isSSR = $4oXB5$useIsSSR();\n\n  var _$4oXB5$useState = $4oXB5$useState($9a70206312150f3d$var$currentLocale),\n      _$4oXB5$useState2 = _slicedToArray(_$4oXB5$useState, 2),\n      defaultLocale = _$4oXB5$useState2[0],\n      setDefaultLocale = _$4oXB5$useState2[1];\n\n  $4oXB5$useEffect(function () {\n    if ($9a70206312150f3d$var$listeners.size === 0) window.addEventListener('languagechange', $9a70206312150f3d$var$updateLocale);\n    $9a70206312150f3d$var$listeners.add(setDefaultLocale);\n    return function () {\n      $9a70206312150f3d$var$listeners.delete(setDefaultLocale);\n      if ($9a70206312150f3d$var$listeners.size === 0) window.removeEventListener('languagechange', $9a70206312150f3d$var$updateLocale);\n    };\n  }, []);\n  if (isSSR) return {\n    locale: 'en-US',\n    direction: 'ltr'\n  };\n  return defaultLocale;\n}\n\nvar $1bbc62ad423ac4ed$var$I18nContext = $4oXB5$react.createContext(null);\n\nfunction $1bbc62ad423ac4ed$export$a54013f0d02a8f82(props) {\n  var locale = props.locale,\n      children = props.children;\n  var defaultLocale = $9a70206312150f3d$export$188ec29ebc2bdc3a();\n  var value = locale ? {\n    locale: locale,\n    direction: $1ad791d3e8a33aa4$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'\n  } : defaultLocale;\n  return $4oXB5$react.createElement($1bbc62ad423ac4ed$var$I18nContext.Provider, {\n    value: value\n  }, children);\n}\n\nfunction $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7() {\n  var defaultLocale = $9a70206312150f3d$export$188ec29ebc2bdc3a();\n  var context = $4oXB5$useContext($1bbc62ad423ac4ed$var$I18nContext);\n  return context || defaultLocale;\n}\n\nvar $9aec7593eb71f732$exports = {};\n$parcel$export($9aec7593eb71f732$exports, \"useMessageFormatter\", function () {\n  return $9aec7593eb71f732$export$ec23bf898b1eed85;\n});\nvar $9aec7593eb71f732$var$cache = new WeakMap();\n\nfunction $9aec7593eb71f732$var$getCachedDictionary(strings) {\n  var dictionary = $9aec7593eb71f732$var$cache.get(strings);\n\n  if (!dictionary) {\n    dictionary = new $4oXB5$MessageDictionary(strings);\n    $9aec7593eb71f732$var$cache.set(strings, dictionary);\n  }\n\n  return dictionary;\n}\n\nfunction $9aec7593eb71f732$export$ec23bf898b1eed85(strings) {\n  var _$1bbc62ad423ac4ed$ex = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7(),\n      locale = _$1bbc62ad423ac4ed$ex.locale;\n\n  var dictionary = $4oXB5$useMemo(function () {\n    return $9aec7593eb71f732$var$getCachedDictionary(strings);\n  }, [strings]);\n  var formatter = $4oXB5$useMemo(function () {\n    return new $4oXB5$MessageFormatter(locale, dictionary);\n  }, [locale, dictionary]);\n  return $4oXB5$useCallback(function (key, variables) {\n    return formatter.format(key, variables);\n  }, [formatter]);\n}\n\nvar $6489b9f106b69c05$exports = {};\n$parcel$export($6489b9f106b69c05$exports, \"useDateFormatter\", function () {\n  return $6489b9f106b69c05$export$85fd5fdf27bacc79;\n});\n\nfunction $6489b9f106b69c05$export$85fd5fdf27bacc79(options) {\n  var lastOptions = $4oXB5$useRef(null);\n  if (options && lastOptions.current && $6489b9f106b69c05$var$isEqual(options, lastOptions.current)) options = lastOptions.current;\n  lastOptions.current = options;\n\n  var _$1bbc62ad423ac4ed$ex2 = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7(),\n      locale = _$1bbc62ad423ac4ed$ex2.locale;\n\n  return $4oXB5$useMemo(function () {\n    return new $4oXB5$DateFormatter(locale, options);\n  }, [locale, options]);\n}\n\nfunction $6489b9f106b69c05$var$isEqual(a, b) {\n  if (a === b) return true;\n  var aKeys = Object.keys(a);\n  var bKeys = Object.keys(b);\n  if (aKeys.length !== bKeys.length) return false;\n\n  for (var _i = 0, _aKeys = aKeys; _i < _aKeys.length; _i++) {\n    var key = _aKeys[_i];\n    if (b[key] !== a[key]) return false;\n  }\n\n  return true;\n}\n\nvar $259f0789267e35cd$exports = {};\n$parcel$export($259f0789267e35cd$exports, \"useNumberFormatter\", function () {\n  return $259f0789267e35cd$export$b7a616150fdb9f44;\n});\n\nfunction $259f0789267e35cd$export$b7a616150fdb9f44() {\n  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n  var _$1bbc62ad423ac4ed$ex3 = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7(),\n      locale = _$1bbc62ad423ac4ed$ex3.locale;\n\n  return $4oXB5$useMemo(function () {\n    return new $4oXB5$NumberFormatter(locale, options);\n  }, [locale, options]);\n}\n\nvar $2032e35a005f8123$exports = {};\n$parcel$export($2032e35a005f8123$exports, \"useCollator\", function () {\n  return $2032e35a005f8123$export$a16aca283550c30d;\n});\nvar $2032e35a005f8123$var$cache = new Map();\n\nfunction $2032e35a005f8123$export$a16aca283550c30d(options) {\n  var _$1bbc62ad423ac4ed$ex4 = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7(),\n      locale = _$1bbc62ad423ac4ed$ex4.locale;\n\n  var cacheKey = locale + (options ? Object.entries(options).sort(function (a, b) {\n    return a[0] < b[0] ? -1 : 1;\n  }).join() : '');\n  if ($2032e35a005f8123$var$cache.has(cacheKey)) return $2032e35a005f8123$var$cache.get(cacheKey);\n  var formatter = new Intl.Collator(locale, options);\n  $2032e35a005f8123$var$cache.set(cacheKey, formatter);\n  return formatter;\n}\n\nvar $eb14a2d22a778b07$exports = {};\n$parcel$export($eb14a2d22a778b07$exports, \"useFilter\", function () {\n  return $eb14a2d22a778b07$export$3274cf84b703fff;\n});\n\nfunction $eb14a2d22a778b07$export$3274cf84b703fff(options) {\n  var collator = $2032e35a005f8123$export$a16aca283550c30d(_objectSpread({\n    usage: 'search'\n  }, options));\n  return {\n    startsWith: function startsWith(string, substring) {\n      if (substring.length === 0) return true;\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(0, substring.length), substring) === 0;\n    },\n    endsWith: function endsWith(string, substring) {\n      if (substring.length === 0) return true;\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(-substring.length), substring) === 0;\n    },\n    contains: function contains(string, substring) {\n      if (substring.length === 0) return true;\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      var scan = 0;\n      var sliceLen = substring.length;\n\n      for (; scan + sliceLen <= string.length; scan++) {\n        var slice = string.slice(scan, scan + sliceLen);\n        if (collator.compare(substring, slice) === 0) return true;\n      }\n\n      return false;\n    }\n  };\n}\n\nexport { $1bbc62ad423ac4ed$export$a54013f0d02a8f82 as I18nProvider, $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7 as useLocale, $9aec7593eb71f732$export$ec23bf898b1eed85 as useMessageFormatter, $6489b9f106b69c05$export$85fd5fdf27bacc79 as useDateFormatter, $259f0789267e35cd$export$b7a616150fdb9f44 as useNumberFormatter, $2032e35a005f8123$export$a16aca283550c30d as useCollator, $eb14a2d22a778b07$export$3274cf84b703fff as useFilter };","map":{"version":3,"sources":["packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","packages/@react-aria/i18n/src/useMessageFormatter.ts","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react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AAQ,CAAC,OAAT,CAAiB,MAAM,CAAC,KAAP,CAAY,CAAE,SAAS,CAAC,MAAxB,CAAjB,EAAkD,SAAlD,MAAiE,CAAxE;AACD,KApBI;AAqBL,IAAA,QArBK,oBAqBI,MArBJ,EAqBY,SArBZ,EAqBuB;AAC1B,UAAI,SAAS,CAAC,MAAV,KAAqB,CAAzB,EACE,OAAO,IAAP;AAGF,MAAA,MAAM,GAAG,MAAM,CAAC,SAAP,CAAiB,KAAjB,CAAT;AACA,MAAA,SAAS,GAAG,SAAS,CAAC,SAAV,CAAoB,KAApB,CAAZ;AAEA,UAAI,IAAI,GAAG,CAAX;AACA,UAAI,QAAQ,GAAG,SAAS,CAAC,MAAzB;;AACA,aAAO,IAAI,GAAG,QAAP,IAAmB,MAAM,CAAC,MAAjC,EAAyC,IAAI,EAA7C,EAAiD;AAC/C,YAAI,KAAK,GAAG,MAAM,CAAC,KAAP,CAAa,IAAb,EAAmB,IAAI,GAAG,QAA1B,CAAZ;AACA,YAAI,QAAQ,CAAC,OAAT,CAAiB,SAAjB,EAA4B,KAA5B,MAAuC,CAA3C,EACE,OAAO,IAAP;AAEH;;AAED,aAAO,KAAP;AACD;AAvCI,GAAP;AAyCD","sourcesContent":["/*\n * Copyright 2020 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 {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\ninterface ProviderProps {\n  /** Contents that should have the locale applied. */\n  children: ReactNode,\n  /** The locale to apply to the children. */\n  locale?: string\n}\n\nconst I18nContext = React.createContext<Locale>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: ProviderProps) {\n  let {locale, children} = props;\n  let defaultLocale = useDefaultLocale();\n\n  let value: Locale = locale ? {\n    locale,\n    direction: isRTL(locale) ? 'rtl' : 'ltr'\n  } : defaultLocale;\n\n  return (\n    <I18nContext.Provider value={value}>\n      {children}\n    </I18nContext.Provider>\n  );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n  let defaultLocale = useDefaultLocale();\n  let context = useContext(I18nContext);\n  return context || defaultLocale;\n}\n","/*\n * Copyright 2020 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\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(locale: string) {\n  // If the Intl.Locale API is available, use it to get the script for the locale.\n  // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n  // @ts-ignore\n  if (Intl.Locale) {\n    // @ts-ignore\n    let script = new Intl.Locale(locale).maximize().script;\n    return RTL_SCRIPTS.has(script);\n  }\n\n  // If not, just guess by the language (first part of the locale)\n  let lang = locale.split('-')[0];\n  return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 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 {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n  /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n  locale: string,\n  /** The writing direction for the locale. */\n  direction: Direction\n}\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n  // @ts-ignore\n  let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n  return {\n    locale,\n    direction: isRTL(locale) ? 'rtl' : 'ltr'\n  };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n  currentLocale = getDefaultLocale();\n  for (let listener of listeners) {\n    listener(currentLocale);\n  }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n  let isSSR = useIsSSR();\n  let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n  useEffect(() => {\n    if (listeners.size === 0) {\n      window.addEventListener('languagechange', updateLocale);\n    }\n\n    listeners.add(setDefaultLocale);\n\n    return () => {\n      listeners.delete(setDefaultLocale);\n      if (listeners.size === 0) {\n        window.removeEventListener('languagechange', updateLocale);\n      }\n    };\n  }, []);\n\n  // We cannot determine the browser's language on the server, so default to\n  // en-US. This will be updated after hydration on the client to the correct value.\n  if (isSSR) {\n    return {\n      locale: 'en-US',\n      direction: 'ltr'\n    };\n  }\n\n  return defaultLocale;\n}\n","/*\n * Copyright 2020 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 {LocalizedStrings, MessageDictionary, MessageFormatter} from '@internationalized/message';\nimport {useCallback, useMemo} from 'react';\nimport {useLocale} from './context';\n\ntype FormatMessage = (key: string, variables?: {[key: string]: any}) => string;\n\nconst cache = new WeakMap();\nfunction getCachedDictionary(strings: LocalizedStrings) {\n  let dictionary = cache.get(strings);\n  if (!dictionary) {\n    dictionary = new MessageDictionary(strings);\n    cache.set(strings, dictionary);\n  }\n\n  return dictionary;\n}\n\n/**\n * Handles formatting ICU Message strings to create localized strings for the current locale.\n * Automatically updates when the locale changes, and handles caching of messages for performance.\n * @param strings - A mapping of languages to strings by key.\n */\nexport function useMessageFormatter(strings: LocalizedStrings): FormatMessage {\n  let {locale} = useLocale();\n  let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n  let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);\n  return useCallback((key, variables) => formatter.format(key, variables), [formatter]);\n}\n","/*\n * Copyright 2020 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 {DateFormatter} from '@internationalized/date';\nimport {useLocale} from './context';\nimport {useMemo, useRef} from 'react';\n\ninterface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n  calendar?: string\n}\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): DateFormatter {\n  // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.\n  let lastOptions = useRef(null);\n  if (options && lastOptions.current && isEqual(options, lastOptions.current)) {\n    options = lastOptions.current;\n  }\n\n  lastOptions.current = options;\n\n  let {locale} = useLocale();\n  return useMemo(() => new DateFormatter(locale, options), [locale, options]);\n}\n\nfunction isEqual(a: DateFormatterOptions, b: DateFormatterOptions) {\n  if (a === b) {\n    return true;\n  }\n\n  let aKeys = Object.keys(a);\n  let bKeys = Object.keys(b);\n  if (aKeys.length !== bKeys.length) {\n    return false;\n  }\n\n  for (let key of aKeys) {\n    if (b[key] !== a[key]) {\n      return false;\n    }\n  }\n\n  return true;\n}\n","/*\n * Copyright 2020 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 {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n  let {locale} = useLocale();\n  return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 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 {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n  let {locale} = useLocale();\n\n  let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n  if (cache.has(cacheKey)) {\n    return cache.get(cacheKey);\n  }\n\n  let formatter = new Intl.Collator(locale, options);\n  cache.set(cacheKey, formatter);\n  return formatter;\n}\n","/*\n * Copyright 2020 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 {useCollator} from './useCollator';\n\ninterface Filter {\n  /** Returns whether a string starts with a given substring. */\n  startsWith(string: string, substring: string): boolean,\n  /** Returns whether a string ends with a given substring. */\n  endsWith(string: string, substring: string): boolean,\n  /** Returns whether a string contains a given substring. */\n  contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n  let collator = useCollator({\n    usage: 'search',\n    ...options\n  });\n\n  // TODO(later): these methods don't currently support the ignorePunctuation option.\n\n  return {\n    startsWith(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      // Normalize both strings so we can slice safely\n      // TODO: take into account the ignorePunctuation option as well...\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(0, substring.length), substring) === 0;\n    },\n    endsWith(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n      return collator.compare(string.slice(-substring.length), substring) === 0;\n    },\n    contains(string, substring) {\n      if (substring.length === 0) {\n        return true;\n      }\n\n      string = string.normalize('NFC');\n      substring = substring.normalize('NFC');\n\n      let scan = 0;\n      let sliceLen = substring.length;\n      for (; scan + sliceLen <= string.length; scan++) {\n        let slice = string.slice(scan, scan + sliceLen);\n        if (collator.compare(substring, slice) === 0) {\n          return true;\n        }\n      }\n\n      return false;\n    }\n  };\n}\n"]},"metadata":{},"sourceType":"module"}