{"version":3,"file":"getPlural.cjs","names":["getCachedIntl"],"sources":["../../../src/interpreter/getPlural.ts"],"sourcesContent":["import type { DeclaredLocales } from '@intlayer/types';\nimport type { LocalesValues } from 'intlayer';\nimport { getCachedIntl } from '../formatters';\nimport type {\n  PluralCategory,\n  PluralContentState,\n} from '../transpiler/plural/plural';\n\n/**\n * Picks content from a plural map based on a count and locale, using CLDR\n * pluralization rules (`Intl.PluralRules`).\n *\n * Falls back to the `other` category when no specific category matches.\n *\n * @example\n * ```ts\n * getPlural({\n *   one: 'one item',\n *   other: '{{count}} items',\n * }, 5, 'en');\n * // '{{count}} items'\n * ```\n */\nexport const getPlural = <const L extends LocalesValues = DeclaredLocales>(\n  pluralContent: PluralContentState<string>,\n  count: number,\n  locale: L\n): string => {\n  const category = getCachedIntl(Intl.PluralRules, locale).select(\n    count\n  ) as PluralCategory;\n\n  return pluralContent[category] ?? pluralContent.other;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAa,aACX,eACA,OACA,WACW;AAKX,QAAO,cAJUA,iCAAc,KAAK,aAAa,OAAO,CAAC,OACvD,MAG2B,KAAK,cAAc"}