{"version":3,"file":"list.mjs","names":[],"sources":["../../../src/formatters/list.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getCachedIntl } from '../utils/intl';\n\n/** Locally defined subset of Intl.ListFormatOptions so consumers don't need ES2021.Intl in their lib. */\ntype ListFormatOptions = {\n  localeMatcher?: 'lookup' | 'best fit';\n  type?: 'conjunction' | 'disjunction' | 'unit';\n  style?: 'long' | 'short' | 'narrow';\n};\n\n/**\n * Formats an array of values into a localized list string using the Intl API.\n *\n * @example\n * list(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * @example\n * list(['red', 'green', 'blue'], { locale: Locales.FRENCH, type: 'disjunction' });\n * // \"rouge, vert ou bleu\"\n *\n * @example\n * list([1, 2, 3], { type: 'unit' });\n * // \"1, 2, 3\"\n */\nexport const list = (\n  values: (string | number)[],\n  options?: ListFormatOptions & { locale?: LocalesValues }\n): string =>\n  getCachedIntl(\n    (Intl as any).ListFormat,\n    options?.locale ?? internationalization?.defaultLocale,\n\n    {\n      type: options?.type ?? 'conjunction',\n      style: options?.style ?? 'long',\n      ...options,\n    }\n  ).format(values.map(String));\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,MAAa,QACX,QACA,YAEA,cACG,KAAa,YACd,SAAS,UAAU,sBAAsB,eAEzC;CACE,MAAM,SAAS,QAAQ;CACvB,OAAO,SAAS,SAAS;CACzB,GAAG;CACJ,CACF,CAAC,OAAO,OAAO,IAAI,OAAO,CAAC"}