@formatjs/intl-pluralrules 6.3.1 → 6.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/polyfill-force.js CHANGED
@@ -1,13 +1,1136 @@
1
- import { PluralRules } from "./index.js";
1
+ import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
2
+ import Decimal, { Decimal as Decimal$1 } from "@formatjs/bigdecimal";
3
+ //#region packages/ecma402-abstract/CanonicalizeLocaleList.js
4
+ /**
5
+ * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
6
+ * @param locales
7
+ */
8
+ function CanonicalizeLocaleList(locales) {
9
+ return Intl.getCanonicalLocales(locales);
10
+ }
11
+ //#endregion
12
+ //#region packages/ecma262-abstract/ToObject.js
13
+ /**
14
+ * https://tc39.es/ecma262/#sec-toobject
15
+ */
16
+ function ToObject(arg) {
17
+ if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
18
+ return Object(arg);
19
+ }
20
+ //#endregion
21
+ //#region packages/ecma262-abstract/ToString.js
22
+ /**
23
+ * https://tc39.es/ecma262/#sec-tostring
24
+ */
25
+ function ToString(o) {
26
+ if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
27
+ return String(o);
28
+ }
29
+ //#endregion
30
+ //#region packages/ecma402-abstract/GetOption.js
31
+ /**
32
+ * https://tc39.es/ecma402/#sec-getoption
33
+ * @param opts
34
+ * @param prop
35
+ * @param type
36
+ * @param values
37
+ * @param fallback
38
+ */
39
+ function GetOption(opts, prop, type, values, fallback) {
40
+ if (typeof opts !== "object") throw new TypeError("Options must be an object");
41
+ let value = opts[prop];
42
+ if (value !== void 0) {
43
+ if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
44
+ if (type === "boolean") value = Boolean(value);
45
+ if (type === "string") value = ToString(value);
46
+ if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
47
+ return value;
48
+ }
49
+ return fallback;
50
+ }
51
+ //#endregion
52
+ //#region packages/ecma402-abstract/SupportedLocales.js
53
+ /**
54
+ * https://tc39.es/ecma402/#sec-supportedlocales
55
+ * @param availableLocales
56
+ * @param requestedLocales
57
+ * @param options
58
+ */
59
+ function SupportedLocales(availableLocales, requestedLocales, options) {
60
+ let matcher = "best fit";
61
+ if (options !== void 0) {
62
+ options = ToObject(options);
63
+ matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
64
+ }
65
+ if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
66
+ return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
67
+ }
68
+ //#endregion
69
+ //#region packages/ecma262-abstract/ToPrimitive.js
70
+ function invariant$2(condition, message, Err = Error) {
71
+ if (!condition) throw new Err(message);
72
+ }
73
+ function IsCallable(fn) {
74
+ return typeof fn === "function";
75
+ }
76
+ function OrdinaryToPrimitive(O, hint) {
77
+ let methodNames;
78
+ if (hint === "string") methodNames = ["toString", "valueOf"];
79
+ else methodNames = ["valueOf", "toString"];
80
+ for (const name of methodNames) {
81
+ const method = O[name];
82
+ if (IsCallable(method)) {
83
+ let result = method.call(O);
84
+ if (typeof result !== "object") return result;
85
+ }
86
+ }
87
+ throw new TypeError("Cannot convert object to primitive value");
88
+ }
89
+ /**
90
+ * https://tc39.es/ecma262/#sec-toprimitive
91
+ */
92
+ function ToPrimitive(input, preferredType) {
93
+ if (typeof input === "object" && input != null) {
94
+ const exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : void 0;
95
+ let hint;
96
+ if (exoticToPrim !== void 0) {
97
+ if (preferredType === void 0) hint = "default";
98
+ else if (preferredType === "string") hint = "string";
99
+ else {
100
+ invariant$2(preferredType === "number", "preferredType must be \"string\" or \"number\"");
101
+ hint = "number";
102
+ }
103
+ let result = exoticToPrim.call(input, hint);
104
+ if (typeof result !== "object") return result;
105
+ throw new TypeError("Cannot convert exotic object to primitive.");
106
+ }
107
+ if (preferredType === void 0) preferredType = "number";
108
+ return OrdinaryToPrimitive(input, preferredType);
109
+ }
110
+ return input;
111
+ }
112
+ //#endregion
113
+ //#region packages/ecma402-abstract/ToIntlMathematicalValue.js
114
+ /**
115
+ * https://tc39.es/ecma402/#sec-tointlmathematicalvalue
116
+ * Converts input to a mathematical value, supporting BigInt
117
+ */
118
+ function ToIntlMathematicalValue(input) {
119
+ if (typeof input === "bigint") return new Decimal$1(input.toString());
120
+ let primValue = ToPrimitive(input, "number");
121
+ if (primValue === void 0) return new Decimal$1(NaN);
122
+ if (primValue === true) return new Decimal$1(1);
123
+ if (primValue === false) return new Decimal$1(0);
124
+ if (primValue === null) return new Decimal$1(0);
125
+ try {
126
+ return new Decimal$1(primValue);
127
+ } catch {
128
+ return new Decimal$1(NaN);
129
+ }
130
+ }
131
+ //#endregion
132
+ //#region packages/ecma402-abstract/CoerceOptionsToObject.js
133
+ /**
134
+ * https://tc39.es/ecma402/#sec-coerceoptionstoobject
135
+ * @param options
136
+ * @returns
137
+ */
138
+ function CoerceOptionsToObject(options) {
139
+ if (typeof options === "undefined") return Object.create(null);
140
+ return ToObject(options);
141
+ }
142
+ //#endregion
143
+ //#region packages/ecma402-abstract/DefaultNumberOption.js
144
+ /**
145
+ * https://tc39.es/ecma402/#sec-defaultnumberoption
146
+ * @param val
147
+ * @param min
148
+ * @param max
149
+ * @param fallback
150
+ */
151
+ function DefaultNumberOption(inputVal, min, max, fallback) {
152
+ if (inputVal === void 0) return fallback;
153
+ const val = Number(inputVal);
154
+ if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
155
+ return Math.floor(val);
156
+ }
157
+ //#endregion
158
+ //#region packages/ecma402-abstract/GetNumberOption.js
159
+ /**
160
+ * https://tc39.es/ecma402/#sec-getnumberoption
161
+ * @param options
162
+ * @param property
163
+ * @param min
164
+ * @param max
165
+ * @param fallback
166
+ */
167
+ function GetNumberOption(options, property, minimum, maximum, fallback) {
168
+ const val = options[property];
169
+ return DefaultNumberOption(val, minimum, maximum, fallback);
170
+ }
171
+ //#endregion
172
+ //#region node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
173
+ function memoize(fn, options) {
174
+ const cache = options && options.cache ? options.cache : cacheDefault;
175
+ const serializer = options && options.serializer ? options.serializer : serializerDefault;
176
+ return (options && options.strategy ? options.strategy : strategyDefault)(fn, {
177
+ cache,
178
+ serializer
179
+ });
180
+ }
181
+ function isPrimitive(value) {
182
+ return value == null || typeof value === "number" || typeof value === "boolean";
183
+ }
184
+ function monadic(fn, cache, serializer, arg) {
185
+ const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
186
+ let computedValue = cache.get(cacheKey);
187
+ if (typeof computedValue === "undefined") {
188
+ computedValue = fn.call(this, arg);
189
+ cache.set(cacheKey, computedValue);
190
+ }
191
+ return computedValue;
192
+ }
193
+ function variadic(fn, cache, serializer) {
194
+ const args = Array.prototype.slice.call(arguments, 3);
195
+ const cacheKey = serializer(args);
196
+ let computedValue = cache.get(cacheKey);
197
+ if (typeof computedValue === "undefined") {
198
+ computedValue = fn.apply(this, args);
199
+ cache.set(cacheKey, computedValue);
200
+ }
201
+ return computedValue;
202
+ }
203
+ function assemble(fn, context, strategy, cache, serialize) {
204
+ return strategy.bind(context, fn, cache, serialize);
205
+ }
206
+ function strategyDefault(fn, options) {
207
+ const strategy = fn.length === 1 ? monadic : variadic;
208
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
209
+ }
210
+ function strategyVariadic(fn, options) {
211
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
212
+ }
213
+ function strategyMonadic(fn, options) {
214
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
215
+ }
216
+ const serializerDefault = function() {
217
+ return JSON.stringify(arguments);
218
+ };
219
+ var ObjectWithoutPrototypeCache = class {
220
+ constructor() {
221
+ this.cache = Object.create(null);
222
+ }
223
+ get(key) {
224
+ return this.cache[key];
225
+ }
226
+ set(key, value) {
227
+ this.cache[key] = value;
228
+ }
229
+ };
230
+ const cacheDefault = { create: function create() {
231
+ return new ObjectWithoutPrototypeCache();
232
+ } };
233
+ const strategies = {
234
+ variadic: strategyVariadic,
235
+ monadic: strategyMonadic
236
+ };
237
+ //#endregion
238
+ //#region packages/ecma402-abstract/utils.js
239
+ function repeat(s, times) {
240
+ if (typeof s.repeat === "function") return s.repeat(times);
241
+ const arr = Array.from({ length: times });
242
+ for (let i = 0; i < arr.length; i++) arr[i] = s;
243
+ return arr.join("");
244
+ }
245
+ function invariant$1(condition, message, Err = Error) {
246
+ if (!condition) throw new Err(message);
247
+ }
248
+ memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
249
+ memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
250
+ memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });
251
+ memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
252
+ //#endregion
253
+ //#region packages/ecma402-abstract/NumberFormat/SetNumberFormatDigitOptions.js
254
+ const VALID_ROUNDING_INCREMENTS = new Set([
255
+ 1,
256
+ 2,
257
+ 5,
258
+ 10,
259
+ 20,
260
+ 25,
261
+ 50,
262
+ 100,
263
+ 200,
264
+ 250,
265
+ 500,
266
+ 1e3,
267
+ 2e3,
268
+ 2500,
269
+ 5e3
270
+ ]);
271
+ /**
272
+ * https://tc39.es/ecma402/#sec-setnfdigitoptions
273
+ */
274
+ function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
275
+ const mnid = GetNumberOption(opts, "minimumIntegerDigits", 1, 21, 1);
276
+ let mnfd = opts.minimumFractionDigits;
277
+ let mxfd = opts.maximumFractionDigits;
278
+ let mnsd = opts.minimumSignificantDigits;
279
+ let mxsd = opts.maximumSignificantDigits;
280
+ internalSlots.minimumIntegerDigits = mnid;
281
+ const roundingIncrement = GetNumberOption(opts, "roundingIncrement", 1, 5e3, 1);
282
+ invariant$1(VALID_ROUNDING_INCREMENTS.has(roundingIncrement), `Invalid rounding increment value: ${roundingIncrement}.
283
+ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
284
+ const roundingMode = GetOption(opts, "roundingMode", "string", [
285
+ "ceil",
286
+ "floor",
287
+ "expand",
288
+ "trunc",
289
+ "halfCeil",
290
+ "halfFloor",
291
+ "halfExpand",
292
+ "halfTrunc",
293
+ "halfEven"
294
+ ], "halfExpand");
295
+ const roundingPriority = GetOption(opts, "roundingPriority", "string", [
296
+ "auto",
297
+ "morePrecision",
298
+ "lessPrecision"
299
+ ], "auto");
300
+ const trailingZeroDisplay = GetOption(opts, "trailingZeroDisplay", "string", ["auto", "stripIfInteger"], "auto");
301
+ if (roundingIncrement !== 1) mxfdDefault = mnfdDefault;
302
+ internalSlots.roundingIncrement = roundingIncrement;
303
+ internalSlots.roundingMode = roundingMode;
304
+ internalSlots.trailingZeroDisplay = trailingZeroDisplay;
305
+ const hasSd = mnsd !== void 0 || mxsd !== void 0;
306
+ const hasFd = mnfd !== void 0 || mxfd !== void 0;
307
+ let needSd = true;
308
+ let needFd = true;
309
+ if (roundingPriority === "auto") {
310
+ needSd = hasSd;
311
+ if (hasSd || !hasFd && notation === "compact") needFd = false;
312
+ }
313
+ if (needSd) if (hasSd) {
314
+ internalSlots.minimumSignificantDigits = DefaultNumberOption(mnsd, 1, 21, 1);
315
+ internalSlots.maximumSignificantDigits = DefaultNumberOption(mxsd, internalSlots.minimumSignificantDigits, 21, 21);
316
+ } else {
317
+ internalSlots.minimumSignificantDigits = 1;
318
+ internalSlots.maximumSignificantDigits = 21;
319
+ }
320
+ if (needFd) if (hasFd) {
321
+ mnfd = DefaultNumberOption(mnfd, 0, 100, void 0);
322
+ mxfd = DefaultNumberOption(mxfd, 0, 100, void 0);
323
+ if (mnfd === void 0) {
324
+ invariant$1(mxfd !== void 0, "maximumFractionDigits must be defined");
325
+ mnfd = Math.min(mnfdDefault, mxfd);
326
+ } else if (mxfd === void 0) mxfd = Math.max(mxfdDefault, mnfd);
327
+ else if (mnfd > mxfd) throw new RangeError(`Invalid range, ${mnfd} > ${mxfd}`);
328
+ internalSlots.minimumFractionDigits = mnfd;
329
+ internalSlots.maximumFractionDigits = mxfd;
330
+ } else {
331
+ internalSlots.minimumFractionDigits = mnfdDefault;
332
+ internalSlots.maximumFractionDigits = mxfdDefault;
333
+ }
334
+ if (!needSd && !needFd) {
335
+ internalSlots.minimumFractionDigits = 0;
336
+ internalSlots.maximumFractionDigits = 0;
337
+ internalSlots.minimumSignificantDigits = 1;
338
+ internalSlots.maximumSignificantDigits = 2;
339
+ internalSlots.roundingType = "morePrecision";
340
+ internalSlots.roundingPriority = "morePrecision";
341
+ } else if (roundingPriority === "morePrecision") {
342
+ internalSlots.roundingType = "morePrecision";
343
+ internalSlots.roundingPriority = "morePrecision";
344
+ } else if (roundingPriority === "lessPrecision") {
345
+ internalSlots.roundingType = "lessPrecision";
346
+ internalSlots.roundingPriority = "lessPrecision";
347
+ } else if (hasSd) {
348
+ internalSlots.roundingType = "significantDigits";
349
+ internalSlots.roundingPriority = "auto";
350
+ } else {
351
+ internalSlots.roundingType = "fractionDigits";
352
+ internalSlots.roundingPriority = "auto";
353
+ }
354
+ if (roundingIncrement !== 1) {
355
+ invariant$1(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeError);
356
+ invariant$1(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeError);
357
+ }
358
+ }
359
+ //#endregion
360
+ //#region packages/ecma402-abstract/PluralRules/InitializePluralRules.js
361
+ function InitializePluralRules(pl, locales, options, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots }) {
362
+ const requestedLocales = CanonicalizeLocaleList(locales);
363
+ const opt = Object.create(null);
364
+ const opts = CoerceOptionsToObject(options);
365
+ const internalSlots = getInternalSlots(pl);
366
+ internalSlots.initializedPluralRules = true;
367
+ opt.localeMatcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
368
+ const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
369
+ internalSlots.locale = r.locale;
370
+ internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal");
371
+ const notation = GetOption(opts, "notation", "string", ["standard", "compact"], "standard");
372
+ internalSlots.notation = notation;
373
+ if (notation === "compact") {
374
+ internalSlots.compactDisplay = GetOption(opts, "compactDisplay", "string", ["short", "long"], "short");
375
+ if (typeof Intl !== "undefined" && Intl.NumberFormat && Intl.NumberFormat.localeData) internalSlots.dataLocaleData = Intl.NumberFormat.localeData[r.locale];
376
+ }
377
+ SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, "standard");
378
+ return pl;
379
+ }
380
+ //#endregion
381
+ //#region packages/ecma262-abstract/Type.js
382
+ /**
383
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
384
+ */
385
+ function Type(x) {
386
+ if (x === null) return "Null";
387
+ if (typeof x === "undefined") return "Undefined";
388
+ if (typeof x === "function" || typeof x === "object") return "Object";
389
+ if (typeof x === "number") return "Number";
390
+ if (typeof x === "boolean") return "Boolean";
391
+ if (typeof x === "string") return "String";
392
+ if (typeof x === "symbol") return "Symbol";
393
+ if (typeof x === "bigint") return "BigInt";
394
+ }
395
+ //#endregion
396
+ //#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
397
+ /**
398
+ * Cached function to compute powers of 10 for Decimal.js operations.
399
+ * This cache significantly reduces overhead in ComputeExponent and ToRawFixed
400
+ * by memoizing expensive Decimal.pow(10, n) calculations.
401
+ *
402
+ * Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
403
+ * so caching provides substantial performance benefits.
404
+ *
405
+ * @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
406
+ */
407
+ const getPowerOf10 = memoize((exponent) => {
408
+ return Decimal$1.pow(10, exponent);
409
+ });
410
+ //#endregion
411
+ //#region packages/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
412
+ /**
413
+ * The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
414
+ * number of the given magnitude (power of ten of the most significant digit) according to the
415
+ * locale and the desired notation (scientific, engineering, or compact).
416
+ */
417
+ function ComputeExponentForMagnitude(internalSlots, magnitude) {
418
+ const { notation, dataLocaleData, numberingSystem } = internalSlots;
419
+ switch (notation) {
420
+ case "standard": return 0;
421
+ case "scientific": return magnitude.toNumber();
422
+ case "engineering": return magnitude.div(3).floor().times(3).toNumber();
423
+ default: {
424
+ invariant$1(notation === "compact", "Invalid notation");
425
+ const { compactDisplay, style, currencyDisplay } = internalSlots;
426
+ let thresholdMap;
427
+ if (style === "currency" && currencyDisplay !== "name") thresholdMap = (dataLocaleData.numbers.currency[numberingSystem] || dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]]).short;
428
+ else {
429
+ const decimal = dataLocaleData.numbers.decimal[numberingSystem] || dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
430
+ thresholdMap = compactDisplay === "long" ? decimal.long : decimal.short;
431
+ }
432
+ if (!thresholdMap) return 0;
433
+ const num = getPowerOf10(magnitude).toString();
434
+ const thresholds = Object.keys(thresholdMap);
435
+ if (num < thresholds[0]) return 0;
436
+ if (num > thresholds[thresholds.length - 1]) {
437
+ const magnitudeKey = thresholds[thresholds.length - 1];
438
+ if (thresholdMap[magnitudeKey].other === "0") return 0;
439
+ return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
440
+ }
441
+ const i = thresholds.indexOf(num);
442
+ if (i === -1) return 0;
443
+ const magnitudeKey = thresholds[i];
444
+ if (thresholdMap[magnitudeKey].other === "0") return 0;
445
+ return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
446
+ }
447
+ }
448
+ }
449
+ new Decimal$1(10);
450
+ const ZERO$1 = new Decimal$1(0);
451
+ const NEGATIVE_ZERO = new Decimal$1(-0);
452
+ //#endregion
453
+ //#region packages/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js
454
+ const negativeMapping = {
455
+ ceil: "zero",
456
+ floor: "infinity",
457
+ expand: "infinity",
458
+ trunc: "zero",
459
+ halfCeil: "half-zero",
460
+ halfFloor: "half-infinity",
461
+ halfExpand: "half-infinity",
462
+ halfTrunc: "half-zero",
463
+ halfEven: "half-even"
464
+ };
465
+ const positiveMapping = {
466
+ ceil: "infinity",
467
+ floor: "zero",
468
+ expand: "infinity",
469
+ trunc: "zero",
470
+ halfCeil: "half-infinity",
471
+ halfFloor: "half-zero",
472
+ halfExpand: "half-infinity",
473
+ halfTrunc: "half-zero",
474
+ halfEven: "half-even"
475
+ };
476
+ function GetUnsignedRoundingMode(roundingMode, isNegative) {
477
+ if (isNegative) return negativeMapping[roundingMode];
478
+ return positiveMapping[roundingMode];
479
+ }
480
+ //#endregion
481
+ //#region packages/ecma402-abstract/NumberFormat/ApplyUnsignedRoundingMode.js
482
+ function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
483
+ if (x.eq(r1) || r1.eq(r2)) return r1;
484
+ if (x.eq(r2)) return r2;
485
+ invariant$1(r1.lessThan(x) && x.lessThan(r2), `x should be between r1 and r2 but x=${x}, r1=${r1}, r2=${r2}`);
486
+ if (unsignedRoundingMode === "zero") return r1;
487
+ if (unsignedRoundingMode === "infinity") return r2;
488
+ const d1 = x.minus(r1);
489
+ const d2 = r2.minus(x);
490
+ if (d1.lessThan(d2)) return r1;
491
+ if (d2.lessThan(d1)) return r2;
492
+ invariant$1(d1.eq(d2), "d1 should be equal to d2");
493
+ if (unsignedRoundingMode === "half-zero") return r1;
494
+ if (unsignedRoundingMode === "half-infinity") return r2;
495
+ invariant$1(unsignedRoundingMode === "half-even", "unsignedRoundingMode should be half-even");
496
+ if (r1.div(r2.minus(r1)).mod(2).isZero()) return r1;
497
+ return r2;
498
+ }
499
+ //#endregion
500
+ //#region packages/ecma402-abstract/NumberFormat/ToRawFixed.js
501
+ function ToRawFixedFn(n, f) {
502
+ return n.times(getPowerOf10(-f));
503
+ }
504
+ function findN1R1(x, f, roundingIncrement) {
505
+ const n1 = x.times(getPowerOf10(f)).floor().div(roundingIncrement).floor().times(roundingIncrement);
506
+ return {
507
+ n1,
508
+ r1: ToRawFixedFn(n1, f)
509
+ };
510
+ }
511
+ function findN2R2(x, f, roundingIncrement) {
512
+ const n2 = x.times(getPowerOf10(f)).ceil().div(roundingIncrement).ceil().times(roundingIncrement);
513
+ return {
514
+ n2,
515
+ r2: ToRawFixedFn(n2, f)
516
+ };
517
+ }
518
+ /**
519
+ * https://tc39.es/ecma402/#sec-torawfixed
520
+ * @param x a finite non-negative Number or BigInt
521
+ * @param minFraction an integer between 0 and 20
522
+ * @param maxFraction an integer between 0 and 20
523
+ */
524
+ function ToRawFixed(x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode) {
525
+ const f = maxFraction;
526
+ const { n1, r1 } = findN1R1(x, f, roundingIncrement);
527
+ const { n2, r2 } = findN2R2(x, f, roundingIncrement);
528
+ const r = ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode);
529
+ let n, xFinal;
530
+ let m;
531
+ if (r.eq(r1)) {
532
+ n = n1;
533
+ xFinal = r1;
534
+ } else {
535
+ n = n2;
536
+ xFinal = r2;
537
+ }
538
+ if (n.isZero()) m = "0";
539
+ else m = n.toString();
540
+ let int;
541
+ if (f !== 0) {
542
+ let k = m.length;
543
+ if (k <= f) {
544
+ m = repeat("0", f - k + 1) + m;
545
+ k = f + 1;
546
+ }
547
+ const a = m.slice(0, k - f);
548
+ const b = m.slice(m.length - f);
549
+ m = a + "." + b;
550
+ int = a.length;
551
+ } else int = m.length;
552
+ let cut = maxFraction - minFraction;
553
+ while (cut > 0 && m[m.length - 1] === "0") {
554
+ m = m.slice(0, m.length - 1);
555
+ cut--;
556
+ }
557
+ if (m[m.length - 1] === ".") m = m.slice(0, m.length - 1);
558
+ return {
559
+ formattedString: m,
560
+ roundedNumber: xFinal,
561
+ integerDigitsCount: int,
562
+ roundingMagnitude: -f
563
+ };
564
+ }
565
+ //#endregion
566
+ //#region packages/ecma402-abstract/NumberFormat/ToRawPrecision.js
567
+ function findN1E1R1(x, p) {
568
+ const maxN1 = getPowerOf10(p);
569
+ const minN1 = getPowerOf10(p - 1);
570
+ let e1 = x.log(10).floor();
571
+ const divisor = getPowerOf10(e1.minus(p).plus(1));
572
+ let n1 = x.div(divisor).floor();
573
+ let r1 = n1.times(divisor);
574
+ if (n1.greaterThanOrEqualTo(maxN1)) {
575
+ e1 = e1.plus(1);
576
+ const newDivisor = getPowerOf10(e1.minus(p).plus(1));
577
+ n1 = x.div(newDivisor).floor();
578
+ r1 = n1.times(newDivisor);
579
+ } else if (n1.lessThan(minN1)) {
580
+ e1 = e1.minus(1);
581
+ const newDivisor = getPowerOf10(e1.minus(p).plus(1));
582
+ n1 = x.div(newDivisor).floor();
583
+ r1 = n1.times(newDivisor);
584
+ }
585
+ if (r1.lessThanOrEqualTo(x) && n1.lessThan(maxN1) && n1.greaterThanOrEqualTo(minN1)) return {
586
+ n1,
587
+ e1,
588
+ r1
589
+ };
590
+ let currentE1 = x.div(minN1).log(10).plus(p).minus(1).ceil();
591
+ while (true) {
592
+ const currentDivisor = getPowerOf10(currentE1.minus(p).plus(1));
593
+ let currentN1 = x.div(currentDivisor).floor();
594
+ if (currentN1.lessThan(maxN1) && currentN1.greaterThanOrEqualTo(minN1)) {
595
+ const currentR1 = currentN1.times(currentDivisor);
596
+ if (currentR1.lessThanOrEqualTo(x)) return {
597
+ n1: currentN1,
598
+ e1: currentE1,
599
+ r1: currentR1
600
+ };
601
+ }
602
+ currentE1 = currentE1.minus(1);
603
+ }
604
+ }
605
+ function findN2E2R2(x, p) {
606
+ const maxN2 = getPowerOf10(p);
607
+ const minN2 = getPowerOf10(p - 1);
608
+ let e2 = x.log(10).floor();
609
+ const divisor = getPowerOf10(e2.minus(p).plus(1));
610
+ let n2 = x.div(divisor).ceil();
611
+ let r2 = n2.times(divisor);
612
+ if (n2.greaterThanOrEqualTo(maxN2)) {
613
+ e2 = e2.plus(1);
614
+ const newDivisor = getPowerOf10(e2.minus(p).plus(1));
615
+ n2 = x.div(newDivisor).ceil();
616
+ r2 = n2.times(newDivisor);
617
+ } else if (n2.lessThan(minN2)) {
618
+ e2 = e2.minus(1);
619
+ const newDivisor = getPowerOf10(e2.minus(p).plus(1));
620
+ n2 = x.div(newDivisor).ceil();
621
+ r2 = n2.times(newDivisor);
622
+ }
623
+ if (r2.greaterThanOrEqualTo(x) && n2.lessThan(maxN2) && n2.greaterThanOrEqualTo(minN2)) return {
624
+ n2,
625
+ e2,
626
+ r2
627
+ };
628
+ let currentE2 = x.div(maxN2).log(10).plus(p).minus(1).floor();
629
+ while (true) {
630
+ const currentDivisor = getPowerOf10(currentE2.minus(p).plus(1));
631
+ let currentN2 = x.div(currentDivisor).ceil();
632
+ if (currentN2.lessThan(maxN2) && currentN2.greaterThanOrEqualTo(minN2)) {
633
+ const currentR2 = currentN2.times(currentDivisor);
634
+ if (currentR2.greaterThanOrEqualTo(x)) return {
635
+ n2: currentN2,
636
+ e2: currentE2,
637
+ r2: currentR2
638
+ };
639
+ }
640
+ currentE2 = currentE2.plus(1);
641
+ }
642
+ }
643
+ /**
644
+ * https://tc39.es/ecma402/#sec-torawprecision
645
+ * @param x a finite non-negative Number or BigInt
646
+ * @param minPrecision an integer between 1 and 21
647
+ * @param maxPrecision an integer between 1 and 21
648
+ */
649
+ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
650
+ const p = maxPrecision;
651
+ let m;
652
+ let e;
653
+ let xFinal;
654
+ if (x.isZero()) {
655
+ m = repeat("0", p);
656
+ e = 0;
657
+ xFinal = ZERO$1;
658
+ } else {
659
+ const { n1, e1, r1 } = findN1E1R1(x, p);
660
+ const { n2, e2, r2 } = findN2E2R2(x, p);
661
+ let r = ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode);
662
+ let n;
663
+ if (r.eq(r1)) {
664
+ n = n1;
665
+ e = e1.toNumber();
666
+ xFinal = r1;
667
+ } else {
668
+ n = n2;
669
+ e = e2.toNumber();
670
+ xFinal = r2;
671
+ }
672
+ m = n.toString();
673
+ }
674
+ let int;
675
+ if (e >= p - 1) {
676
+ m = m + repeat("0", e - p + 1);
677
+ int = e + 1;
678
+ } else if (e >= 0) {
679
+ m = m.slice(0, e + 1) + "." + m.slice(m.length - (p - (e + 1)));
680
+ int = e + 1;
681
+ } else {
682
+ invariant$1(e < 0, "e should be less than 0");
683
+ m = "0." + repeat("0", -e - 1) + m;
684
+ int = 1;
685
+ }
686
+ if (m.includes(".") && maxPrecision > minPrecision) {
687
+ let cut = maxPrecision - minPrecision;
688
+ while (cut > 0 && m[m.length - 1] === "0") {
689
+ m = m.slice(0, m.length - 1);
690
+ cut--;
691
+ }
692
+ if (m[m.length - 1] === ".") m = m.slice(0, m.length - 1);
693
+ }
694
+ return {
695
+ formattedString: m,
696
+ roundedNumber: xFinal,
697
+ integerDigitsCount: int,
698
+ roundingMagnitude: e
699
+ };
700
+ }
701
+ //#endregion
702
+ //#region packages/ecma402-abstract/NumberFormat/FormatNumericToString.js
703
+ /**
704
+ * https://tc39.es/ecma402/#sec-formatnumberstring
705
+ */
706
+ function FormatNumericToString(intlObject, _x) {
707
+ let x = _x;
708
+ let sign;
709
+ if (x.isZero() && x.isNegative()) {
710
+ sign = "negative";
711
+ x = ZERO$1;
712
+ } else {
713
+ invariant$1(x.isFinite(), "NumberFormatDigitInternalSlots value is not finite");
714
+ if (x.lessThan(0)) sign = "negative";
715
+ else sign = "positive";
716
+ if (sign === "negative") x = x.negated();
717
+ }
718
+ let result;
719
+ const roundingType = intlObject.roundingType;
720
+ const unsignedRoundingMode = GetUnsignedRoundingMode(intlObject.roundingMode, sign === "negative");
721
+ switch (roundingType) {
722
+ case "significantDigits":
723
+ result = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
724
+ break;
725
+ case "fractionDigits":
726
+ result = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
727
+ break;
728
+ default:
729
+ let sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
730
+ let fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
731
+ if (intlObject.roundingType === "morePrecision") if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = sResult;
732
+ else result = fResult;
733
+ else {
734
+ invariant$1(intlObject.roundingType === "lessPrecision", "Invalid roundingType");
735
+ if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = fResult;
736
+ else result = sResult;
737
+ }
738
+ break;
739
+ }
740
+ x = result.roundedNumber;
741
+ let string = result.formattedString;
742
+ if (intlObject.trailingZeroDisplay === "stripIfInteger" && x.isInteger()) {
743
+ let i = string.indexOf(".");
744
+ if (i > -1) string = string.slice(0, i);
745
+ }
746
+ const int = result.integerDigitsCount;
747
+ const minInteger = intlObject.minimumIntegerDigits;
748
+ if (int < minInteger) string = repeat("0", minInteger - int) + string;
749
+ if (sign === "negative") if (x.isZero()) x = NEGATIVE_ZERO;
750
+ else x = x.negated();
751
+ return {
752
+ roundedNumber: x,
753
+ formattedString: string
754
+ };
755
+ }
756
+ //#endregion
757
+ //#region packages/ecma262-abstract/ToNumber.js
758
+ const ZERO = new Decimal$1(0);
759
+ function invariant(condition, message, Err = Error) {
760
+ if (!condition) throw new Err(message);
761
+ }
762
+ /**
763
+ * https://tc39.es/ecma262/#sec-tonumber
764
+ */
765
+ function ToNumber(arg) {
766
+ if (typeof arg === "number") return new Decimal$1(arg);
767
+ if (typeof arg === "bigint") return new Decimal$1(arg.toString());
768
+ invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
769
+ if (arg === void 0) return new Decimal$1(NaN);
770
+ if (arg === null || arg === 0) return ZERO;
771
+ if (arg === true) return new Decimal$1(1);
772
+ if (typeof arg === "string") try {
773
+ return new Decimal$1(arg);
774
+ } catch {
775
+ return new Decimal$1(NaN);
776
+ }
777
+ invariant(typeof arg === "object", "object expected", TypeError);
778
+ let primValue = ToPrimitive(arg, "number");
779
+ invariant(typeof primValue !== "object", "object expected", TypeError);
780
+ return ToNumber(primValue);
781
+ }
782
+ //#endregion
783
+ //#region packages/ecma402-abstract/PluralRules/GetOperands.js
784
+ /**
785
+ * ECMA-402 Spec: GetOperands abstract operation
786
+ * https://tc39.es/ecma402/#sec-getoperands
787
+ *
788
+ * Implementation: Extended to support compact exponent (c/e operands)
789
+ *
790
+ * @param s Formatted number string
791
+ * @param exponent Compact decimal exponent (c/e operand), defaults to 0
792
+ */
793
+ function GetOperands(s, exponent = 0) {
794
+ invariant$1(typeof s === "string", `GetOperands should have been called with a string`);
795
+ const n = ToNumber(s);
796
+ invariant$1(n.isFinite(), "n should be finite");
797
+ let dp = s.indexOf(".");
798
+ let iv;
799
+ let f;
800
+ let v;
801
+ let fv = "";
802
+ if (dp === -1) {
803
+ iv = n;
804
+ f = ZERO$1;
805
+ v = 0;
806
+ } else {
807
+ iv = s.slice(0, dp);
808
+ fv = s.slice(dp, s.length);
809
+ f = ToNumber(fv);
810
+ v = fv.length;
811
+ }
812
+ const i = ToNumber(iv).abs();
813
+ let w;
814
+ let t;
815
+ if (!f.isZero()) {
816
+ const ft = fv.replace(/0+$/, "");
817
+ w = ft.length;
818
+ t = ToNumber(ft);
819
+ } else {
820
+ w = 0;
821
+ t = ZERO$1;
822
+ }
823
+ return {
824
+ Number: n,
825
+ IntegerDigits: i.lessThanOrEqualTo(Number.MAX_SAFE_INTEGER) && i.greaterThanOrEqualTo(-Number.MAX_SAFE_INTEGER) ? i.toNumber() : i.toString(),
826
+ NumberOfFractionDigits: v,
827
+ NumberOfFractionDigitsWithoutTrailing: w,
828
+ FractionDigits: f.toNumber(),
829
+ FractionDigitsWithoutTrailing: t.toNumber(),
830
+ CompactExponent: exponent
831
+ };
832
+ }
833
+ //#endregion
834
+ //#region packages/ecma402-abstract/PluralRules/ResolvePlural.js
835
+ /**
836
+ * ResolvePluralInternal ( pluralRules, n )
837
+ *
838
+ * Internal version of ResolvePlural that returns both the formatted string and plural category.
839
+ * This is needed for selectRange, which must compare formatted strings to determine if the
840
+ * start and end values are identical.
841
+ *
842
+ * The formatted string is obtained by applying the number formatting options (digit options)
843
+ * from the PluralRules object to the input number. This ensures that formatting-sensitive
844
+ * plural rules work correctly (e.g., rules that depend on visible fraction digits).
845
+ *
846
+ * @param pl - An initialized PluralRules object
847
+ * @param n - Mathematical value to resolve
848
+ * @returns Record containing the formatted string and plural category
849
+ */
850
+ function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
851
+ const internalSlots = getInternalSlots(pl);
852
+ invariant$1(Type(internalSlots) === "Object", "pl has to be an object");
853
+ invariant$1("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
854
+ if (!n.isFinite()) return {
855
+ formattedString: String(n),
856
+ pluralCategory: "other"
857
+ };
858
+ const { locale, type, notation } = internalSlots;
859
+ const s = FormatNumericToString(internalSlots, n).formattedString;
860
+ let exponent = 0;
861
+ if (notation === "compact" && !n.isZero()) {
862
+ if (internalSlots.dataLocaleData?.numbers) try {
863
+ exponent = ComputeExponentForMagnitude(internalSlots, new Decimal(Math.floor(Math.log10(Math.abs(n.toNumber())))));
864
+ } catch {
865
+ exponent = 0;
866
+ }
867
+ }
868
+ return {
869
+ formattedString: s,
870
+ pluralCategory: PluralRuleSelect(locale, type, n, GetOperands(s, exponent))
871
+ };
872
+ }
873
+ /**
874
+ * http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
875
+ * @param pl
876
+ * @param n
877
+ * @param PluralRuleSelect Has to pass in bc it's implementation-specific
878
+ */
879
+ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
880
+ return ResolvePluralInternal(pl, n, {
881
+ getInternalSlots,
882
+ PluralRuleSelect
883
+ }).pluralCategory;
884
+ }
885
+ //#endregion
886
+ //#region packages/ecma402-abstract/PluralRules/ResolvePluralRange.js
887
+ /**
888
+ * ResolvePluralRange ( pluralRules, x, y )
889
+ *
890
+ * The ResolvePluralRange abstract operation is called with arguments pluralRules (which must be
891
+ * an object initialized as a PluralRules), x (a mathematical value), and y (a mathematical value).
892
+ * It resolves the appropriate plural form for a range by determining the plural forms of both the
893
+ * start and end values, then consulting locale-specific range data.
894
+ *
895
+ * Specification: https://tc39.es/ecma402/#sec-resolvepluralrange
896
+ *
897
+ * @param pluralRules - An initialized PluralRules object
898
+ * @param x - Mathematical value for the range start
899
+ * @param y - Mathematical value for the range end
900
+ * @returns The plural category for the range (zero, one, two, few, many, or other)
901
+ */
902
+ function ResolvePluralRange(pluralRules, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }) {
903
+ if (!x.isFinite() || !y.isFinite()) throw new RangeError("selectRange requires start and end values to be finite numbers");
904
+ const internalSlots = getInternalSlots(pluralRules);
905
+ invariant$1(Type(internalSlots) === "Object", "pluralRules has to be an object");
906
+ invariant$1("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
907
+ const xp = ResolvePluralInternal(pluralRules, x, {
908
+ getInternalSlots,
909
+ PluralRuleSelect
910
+ });
911
+ const yp = ResolvePluralInternal(pluralRules, y, {
912
+ getInternalSlots,
913
+ PluralRuleSelect
914
+ });
915
+ if (xp.formattedString === yp.formattedString) return xp.pluralCategory;
916
+ const { locale, type } = internalSlots;
917
+ return PluralRuleSelectRange(locale, type, xp.pluralCategory, yp.pluralCategory);
918
+ }
919
+ //#endregion
920
+ //#region packages/intl-pluralrules/get_internal_slots.ts
921
+ const internalSlotMap = /* @__PURE__ */ new WeakMap();
922
+ function getInternalSlots(x) {
923
+ let internalSlots = internalSlotMap.get(x);
924
+ if (!internalSlots) {
925
+ internalSlots = Object.create(null);
926
+ internalSlotMap.set(x, internalSlots);
927
+ }
928
+ return internalSlots;
929
+ }
930
+ //#endregion
931
+ //#region packages/intl-pluralrules/index.ts
932
+ function validateInstance(instance, method) {
933
+ if (!(instance instanceof PluralRules)) throw new TypeError(`Method Intl.PluralRules.prototype.${method} called on incompatible receiver ${String(instance)}`);
934
+ }
935
+ /**
936
+ * http://ecma-international.org/ecma-402/7.0/index.html#sec-pluralruleselect
937
+ * @param locale
938
+ * @param type
939
+ * @param _n
940
+ * @param param3
941
+ */
942
+ function PluralRuleSelect(locale, type, _n, { IntegerDigits, NumberOfFractionDigits, FractionDigits, CompactExponent }) {
943
+ return PluralRules.localeData[locale].fn(NumberOfFractionDigits ? `${IntegerDigits}.${FractionDigits}` : String(IntegerDigits), type === "ordinal", CompactExponent);
944
+ }
945
+ /**
946
+ * PluralRuleSelectRange ( locale, type, notation, compactDisplay, start, end )
947
+ *
948
+ * Implementation-defined abstract operation that determines the plural category for a range
949
+ * by consulting CLDR plural range data. Each locale defines how different combinations of
950
+ * start and end plural categories map to a range plural category.
951
+ *
952
+ * Examples from CLDR:
953
+ * - English: "one" + "other" → "other" (e.g., "1-2 items")
954
+ * - French: "one" + "one" → "one" (e.g., "0-1 vue")
955
+ * - Arabic: "few" + "many" → "many" (e.g., complex range rules)
956
+ *
957
+ * The spec allows this to be implementation-defined, and we use CLDR supplemental data
958
+ * from pluralRanges.json which provides explicit mappings for each locale.
959
+ *
960
+ * @param locale - BCP 47 locale identifier
961
+ * @param type - "cardinal" or "ordinal"
962
+ * @param xp - Start plural category
963
+ * @param yp - End plural category
964
+ * @returns The plural category for the range
965
+ */
966
+ function PluralRuleSelectRange(locale, type, xp, yp) {
967
+ const localeData = PluralRules.localeData[locale];
968
+ if (!localeData || !localeData.pluralRanges) return yp;
969
+ const key = `${xp}_${yp}`;
970
+ return (type === "ordinal" ? localeData.pluralRanges.ordinal : localeData.pluralRanges.cardinal)?.[key] ?? yp;
971
+ }
972
+ var PluralRules = class PluralRules {
973
+ constructor(locales, options) {
974
+ if (!(this && this instanceof PluralRules ? this.constructor : void 0)) throw new TypeError("Intl.PluralRules must be called with 'new'");
975
+ return InitializePluralRules(this, locales, options, {
976
+ availableLocales: PluralRules.availableLocales,
977
+ relevantExtensionKeys: PluralRules.relevantExtensionKeys,
978
+ localeData: PluralRules.localeData,
979
+ getDefaultLocale: PluralRules.getDefaultLocale,
980
+ getInternalSlots
981
+ });
982
+ }
983
+ resolvedOptions() {
984
+ validateInstance(this, "resolvedOptions");
985
+ const opts = Object.create(null);
986
+ const internalSlots = getInternalSlots(this);
987
+ opts.locale = internalSlots.locale;
988
+ opts.type = internalSlots.type;
989
+ [
990
+ "minimumIntegerDigits",
991
+ "minimumFractionDigits",
992
+ "maximumFractionDigits",
993
+ "minimumSignificantDigits",
994
+ "maximumSignificantDigits"
995
+ ].forEach((field) => {
996
+ const val = internalSlots[field];
997
+ if (val !== void 0) opts[field] = val;
998
+ });
999
+ opts.pluralCategories = [...PluralRules.localeData[opts.locale].categories[opts.type]];
1000
+ return opts;
1001
+ }
1002
+ select(val) {
1003
+ validateInstance(this, "select");
1004
+ const n = ToIntlMathematicalValue(val);
1005
+ return ResolvePlural(this, n, {
1006
+ getInternalSlots,
1007
+ PluralRuleSelect
1008
+ });
1009
+ }
1010
+ /**
1011
+ * Intl.PluralRules.prototype.selectRange ( start, end )
1012
+ *
1013
+ * Returns a string indicating which plural rule applies to a range of numbers.
1014
+ * This is useful for formatting ranges like "1-2 items" vs "2-3 items" where
1015
+ * different languages have different plural rules for ranges.
1016
+ *
1017
+ * Specification: https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange
1018
+ *
1019
+ * @param start - The start value of the range (number or bigint)
1020
+ * @param end - The end value of the range (number or bigint)
1021
+ * @returns The plural category for the range (zero, one, two, few, many, or other)
1022
+ *
1023
+ * @example
1024
+ * const pr = new Intl.PluralRules('en');
1025
+ * pr.selectRange(1, 2); // "other" (English: "1-2 items")
1026
+ * pr.selectRange(1, 1); // "one" (same value: "1 item")
1027
+ *
1028
+ * @example
1029
+ * const prFr = new Intl.PluralRules('fr');
1030
+ * prFr.selectRange(0, 1); // "one" (French: "0-1 vue")
1031
+ * prFr.selectRange(1, 2); // "other" (French: "1-2 vues")
1032
+ *
1033
+ * @example
1034
+ * // BigInt support (spec-compliant, but Chrome has a bug as of early 2025)
1035
+ * pr.selectRange(BigInt(1), BigInt(2)); // "other"
1036
+ *
1037
+ * @throws {TypeError} If start or end is undefined
1038
+ * @throws {RangeError} If start or end is not a finite number (Infinity, NaN)
1039
+ *
1040
+ * @note Chrome's native implementation (as of early 2025) has a bug where it throws
1041
+ * "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
1042
+ * a browser bug - the spec requires BigInt support. This polyfill handles BigInt correctly.
1043
+ */
1044
+ selectRange(start, end) {
1045
+ validateInstance(this, "selectRange");
1046
+ if (start === void 0 || end === void 0) throw new TypeError("selectRange requires both start and end arguments");
1047
+ const x = ToIntlMathematicalValue(start);
1048
+ const y = ToIntlMathematicalValue(end);
1049
+ return ResolvePluralRange(this, x, y, {
1050
+ getInternalSlots,
1051
+ PluralRuleSelect,
1052
+ PluralRuleSelectRange
1053
+ });
1054
+ }
1055
+ toString() {
1056
+ return "[object Intl.PluralRules]";
1057
+ }
1058
+ static supportedLocalesOf(locales, options) {
1059
+ return SupportedLocales(PluralRules.availableLocales, CanonicalizeLocaleList(locales), options);
1060
+ }
1061
+ static __addLocaleData(...data) {
1062
+ for (const { data: d, locale } of data) {
1063
+ PluralRules.localeData[locale] = d;
1064
+ PluralRules.availableLocales.add(locale);
1065
+ if (!PluralRules.__defaultLocale) PluralRules.__defaultLocale = locale;
1066
+ }
1067
+ }
1068
+ static {
1069
+ this.localeData = {};
1070
+ }
1071
+ static {
1072
+ this.availableLocales = /* @__PURE__ */ new Set();
1073
+ }
1074
+ static {
1075
+ this.__defaultLocale = "";
1076
+ }
1077
+ static getDefaultLocale() {
1078
+ return PluralRules.__defaultLocale;
1079
+ }
1080
+ static {
1081
+ this.relevantExtensionKeys = [];
1082
+ }
1083
+ static {
1084
+ this.polyfilled = true;
1085
+ }
1086
+ };
1087
+ try {
1088
+ if (typeof Symbol !== "undefined") Object.defineProperty(PluralRules.prototype, Symbol.toStringTag, {
1089
+ value: "Intl.PluralRules",
1090
+ writable: false,
1091
+ enumerable: false,
1092
+ configurable: true
1093
+ });
1094
+ try {
1095
+ Object.defineProperty(PluralRules, "length", {
1096
+ value: 0,
1097
+ writable: false,
1098
+ enumerable: false,
1099
+ configurable: true
1100
+ });
1101
+ } catch {}
1102
+ Object.defineProperty(PluralRules.prototype.constructor, "length", {
1103
+ value: 0,
1104
+ writable: false,
1105
+ enumerable: false,
1106
+ configurable: true
1107
+ });
1108
+ Object.defineProperty(PluralRules.supportedLocalesOf, "length", {
1109
+ value: 1,
1110
+ writable: false,
1111
+ enumerable: false,
1112
+ configurable: true
1113
+ });
1114
+ Object.defineProperty(PluralRules, "name", {
1115
+ value: "PluralRules",
1116
+ writable: false,
1117
+ enumerable: false,
1118
+ configurable: true
1119
+ });
1120
+ } catch {}
1121
+ //#endregion
1122
+ //#region packages/intl-pluralrules/polyfill-force.ts
2
1123
  Object.defineProperty(Intl, "PluralRules", {
3
1124
  value: PluralRules,
4
1125
  writable: true,
5
1126
  enumerable: false,
6
1127
  configurable: true
7
1128
  });
8
- // Drain any locale data that was buffered before polyfill loaded
9
1129
  const buf = globalThis.__FORMATJS_PLURALRULES_DATA__;
10
1130
  if (buf) {
11
1131
  for (const d of buf) PluralRules.__addLocaleData(d);
12
1132
  delete globalThis.__FORMATJS_PLURALRULES_DATA__;
13
1133
  }
1134
+ //#endregion
1135
+
1136
+ //# sourceMappingURL=polyfill-force.js.map