{"version":3,"names":["FORMATTER_CACHE","Map","getFormatter","locale","options","key","JSON","stringify","cached","get","formatter","Intl","NumberFormat","set","formatNumberValue","value","format","style"],"sources":["format-number.ts"],"sourcesContent":["/**\n * Shared number-formatting helper used by `<Progress.Root>` and\n * `<Meter.Root>`. Both components format a numeric value for display using\n * the same algorithm: if an explicit `format` is provided, pass the value\n * through `Intl.NumberFormat` verbatim; otherwise use a percent formatter\n * applied to `value / 100`.\n *\n * A module-scope cache keyed by `(locale, options)` keeps repeated formats\n * O(1). Construction of `Intl.NumberFormat` is the expensive step; the\n * formatters themselves are cheap to re-use.\n */\n\nconst FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\n\nfunction getFormatter(\n\tlocale: Intl.LocalesArgument | undefined,\n\toptions: Intl.NumberFormatOptions | undefined,\n): Intl.NumberFormat {\n\tconst key = JSON.stringify({ locale, options });\n\tconst cached = FORMATTER_CACHE.get(key);\n\tif (cached) return cached;\n\tconst formatter = new Intl.NumberFormat(locale, options);\n\tFORMATTER_CACHE.set(key, formatter);\n\treturn formatter;\n}\n\n/**\n * Formats a numeric value for display. Returns `\"\"` if `value` is `null`\n * (matches progress's indeterminate state). If `format` is undefined, the\n * default is a percentage applied to `value / 100` — so a raw value of `42`\n * yields `\"42%\"` under an `en-US` locale.\n */\nexport function formatNumberValue(\n\tvalue: number | null,\n\tlocale: Intl.LocalesArgument | undefined,\n\tformat: Intl.NumberFormatOptions | undefined,\n): string {\n\tif (value == null) return \"\";\n\tif (!format) {\n\t\treturn getFormatter(locale, { style: \"percent\" }).format(value / 100);\n\t}\n\treturn getFormatter(locale, format).format(value);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,eAAe,GAAG,IAAIC,GAAG,CAA4B,CAAC;AAE5D,SAASC,YAAYA,CACpBC,MAAwC,EACxCC,OAA6C,EACzB;EACpB,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAAC;IAAEJ,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAC/C,MAAMI,MAAM,GAAGR,eAAe,CAACS,GAAG,CAACJ,GAAG,CAAC;EACvC,IAAIG,MAAM,EAAE,OAAOA,MAAM;EACzB,MAAME,SAAS,GAAG,IAAIC,IAAI,CAACC,YAAY,CAACT,MAAM,EAAEC,OAAO,CAAC;EACxDJ,eAAe,CAACa,GAAG,CAACR,GAAG,EAAEK,SAAS,CAAC;EACnC,OAAOA,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,iBAAiBA,CAChCC,KAAoB,EACpBZ,MAAwC,EACxCa,MAA4C,EACnC;EACT,IAAID,KAAK,IAAI,IAAI,EAAE,OAAO,EAAE;EAC5B,IAAI,CAACC,MAAM,EAAE;IACZ,OAAOd,YAAY,CAACC,MAAM,EAAE;MAAEc,KAAK,EAAE;IAAU,CAAC,CAAC,CAACD,MAAM,CAACD,KAAK,GAAG,GAAG,CAAC;EACtE;EACA,OAAOb,YAAY,CAACC,MAAM,EAAEa,MAAM,CAAC,CAACA,MAAM,CAACD,KAAK,CAAC;AAClD","ignoreList":[]}