@formatjs/intl-durationformat 0.10.17 → 0.11.0

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/index.js CHANGED
@@ -1,14 +1,121 @@
1
1
  import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
2
2
  import { BigDecimal, Decimal } from "@formatjs/bigdecimal";
3
+ //#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
4
+ const numberingSystemNames = [
5
+ "adlm",
6
+ "ahom",
7
+ "arab",
8
+ "arabext",
9
+ "armn",
10
+ "armnlow",
11
+ "bali",
12
+ "beng",
13
+ "bhks",
14
+ "brah",
15
+ "cakm",
16
+ "cham",
17
+ "cyrl",
18
+ "deva",
19
+ "diak",
20
+ "ethi",
21
+ "fullwide",
22
+ "gara",
23
+ "geor",
24
+ "gong",
25
+ "gonm",
26
+ "grek",
27
+ "greklow",
28
+ "gujr",
29
+ "gukh",
30
+ "guru",
31
+ "hanidays",
32
+ "hanidec",
33
+ "hans",
34
+ "hansfin",
35
+ "hant",
36
+ "hantfin",
37
+ "hebr",
38
+ "hmng",
39
+ "hmnp",
40
+ "java",
41
+ "jpan",
42
+ "jpanfin",
43
+ "jpanyear",
44
+ "kali",
45
+ "kawi",
46
+ "khmr",
47
+ "knda",
48
+ "krai",
49
+ "lana",
50
+ "lanatham",
51
+ "laoo",
52
+ "latn",
53
+ "lepc",
54
+ "limb",
55
+ "mathbold",
56
+ "mathdbl",
57
+ "mathmono",
58
+ "mathsanb",
59
+ "mathsans",
60
+ "mlym",
61
+ "modi",
62
+ "mong",
63
+ "mroo",
64
+ "mtei",
65
+ "mymr",
66
+ "mymrepka",
67
+ "mymrpao",
68
+ "mymrshan",
69
+ "mymrtlng",
70
+ "nagm",
71
+ "newa",
72
+ "nkoo",
73
+ "olck",
74
+ "onao",
75
+ "orya",
76
+ "osma",
77
+ "outlined",
78
+ "rohg",
79
+ "roman",
80
+ "romanlow",
81
+ "saur",
82
+ "segment",
83
+ "shrd",
84
+ "sind",
85
+ "sinh",
86
+ "sora",
87
+ "sund",
88
+ "sunu",
89
+ "takr",
90
+ "talu",
91
+ "taml",
92
+ "tamldec",
93
+ "telu",
94
+ "thai",
95
+ "tibt",
96
+ "tirh",
97
+ "tnsa",
98
+ "tols",
99
+ "vaii",
100
+ "wara",
101
+ "wcho"
102
+ ];
103
+ //#endregion
104
+ //#region packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
105
+ /** Tests the Unicode locale identifier `type` grammar, not locale support. */
106
+ function IsUnicodeLocaleIdentifierType(value) {
107
+ return /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i.test(value);
108
+ }
109
+ //#endregion
3
110
  //#region packages/ecma262-abstract/OrdinaryHasInstance.js
4
- function IsCallable$1(fn) {
111
+ function IsCallable(fn) {
5
112
  return typeof fn === "function";
6
113
  }
7
114
  /**
8
115
  * https://tc39.es/ecma262/#sec-ordinaryhasinstance
9
116
  */
10
117
  function OrdinaryHasInstance(C, O, internalSlots) {
11
- if (!IsCallable$1(C)) return false;
118
+ if (!IsCallable(C)) return false;
12
119
  if (internalSlots?.boundTargetFunction) return O instanceof internalSlots?.boundTargetFunction;
13
120
  if (typeof O !== "object") return false;
14
121
  let P = C.prototype;
@@ -36,7 +143,9 @@ function CanonicalizeLocaleList(locales) {
36
143
  //#endregion
37
144
  //#region packages/ecma402-abstract/DefaultNumberOption.js
38
145
  /**
146
+ * ECMA-402 §9.2.13 DefaultNumberOption, step 2.
39
147
  * https://tc39.es/ecma402/#sec-defaultnumberoption
148
+ * https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
40
149
  * @param val
41
150
  * @param min
42
151
  * @param max
@@ -44,7 +153,7 @@ function CanonicalizeLocaleList(locales) {
44
153
  */
45
154
  function DefaultNumberOption(inputVal, min, max, fallback) {
46
155
  if (inputVal === void 0) return fallback;
47
- const val = Number(inputVal);
156
+ const val = +inputVal;
48
157
  if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
49
158
  return Math.floor(val);
50
159
  }
@@ -82,7 +191,7 @@ function ToString(o) {
82
191
  * @param fallback
83
192
  */
84
193
  function GetOption(opts, prop, type, values, fallback) {
85
- if (typeof opts !== "object") throw new TypeError("Options must be an object");
194
+ if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
86
195
  let value = opts[prop];
87
196
  if (value !== void 0) {
88
197
  if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
@@ -178,7 +287,7 @@ const strategies = {
178
287
  };
179
288
  //#endregion
180
289
  //#region packages/ecma402-abstract/utils.js
181
- function invariant$2(condition, message, Err = Error) {
290
+ function invariant(condition, message, Err = Error) {
182
291
  if (!condition) throw new Err(message);
183
292
  }
184
293
  const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
@@ -189,24 +298,28 @@ const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...arg
189
298
  function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
190
299
  let style = GetOption(options, unit, "string", stylesList, void 0);
191
300
  let displayDefault = "always";
192
- if (style === void 0) if (baseStyle === "digital") {
193
- if (unit !== "hours" && unit !== "minutes" && unit !== "seconds") displayDefault = "auto";
194
- style = digitalBase;
195
- } else {
196
- displayDefault = "auto";
197
- if (prevStyle === "numeric" || prevStyle === "2-digit") style = "numeric";
198
- else style = baseStyle;
199
- }
200
- let display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
201
- if (twoDigitHours && unit === "hours" && style === "numeric") style = "2-digit";
202
- if (prevStyle === "numeric" || prevStyle === "2-digit") {
203
- if (style !== "numeric" && style !== "2-digit") throw new RangeError("Can't mix numeric and non-numeric styles");
204
- else if (unit === "minutes" || unit === "seconds") style = "2-digit";
205
- if (style === "numeric" && (unit === "milliseconds" || unit === "microseconds" || unit === "nanoseconds")) {
206
- if (display === "always") throw new RangeError("Can't display milliseconds, microseconds, or nanoseconds in numeric format");
207
- style = "fractional";
301
+ if (style === void 0) {
302
+ if (baseStyle === "digital") {
303
+ style = digitalBase;
304
+ if (unit !== "hours" && unit !== "minutes" && unit !== "seconds") displayDefault = "auto";
305
+ } else if (prevStyle === "fractional" || prevStyle === "numeric" || prevStyle === "2-digit") {
306
+ style = "numeric";
307
+ if (unit !== "minutes" && unit !== "seconds") displayDefault = "auto";
308
+ } else {
309
+ style = baseStyle;
310
+ displayDefault = "auto";
208
311
  }
209
312
  }
313
+ if (style === "numeric" && (unit === "milliseconds" || unit === "microseconds" || unit === "nanoseconds")) {
314
+ style = "fractional";
315
+ displayDefault = "auto";
316
+ }
317
+ const display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
318
+ if (display === "always" && style === "fractional") throw new RangeError("Fractional units cannot use always display");
319
+ if (prevStyle === "fractional" && style !== "fractional") throw new RangeError("Fractional units must be followed by fractional units");
320
+ if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeError("Can't mix numeric and non-numeric styles");
321
+ if (twoDigitHours && unit === "hours") style = "2-digit";
322
+ if ((unit === "minutes" || unit === "seconds") && (prevStyle === "numeric" || prevStyle === "2-digit")) style = "2-digit";
210
323
  return {
211
324
  style,
212
325
  display
@@ -303,6 +416,8 @@ function PartitionDurationFormatPattern(df, duration) {
303
416
  const result = [];
304
417
  let done = false;
305
418
  let separated = false;
419
+ let signDisplayed = true;
420
+ const negative = TABLE_2.some((row) => duration[row.valueField] < 0);
306
421
  const internalSlots = getInternalSlots(df);
307
422
  let dataLocale = internalSlots.dataLocale;
308
423
  const dataLocaleData = DurationFormat.localeData[dataLocale];
@@ -311,7 +426,7 @@ function PartitionDurationFormatPattern(df, duration) {
311
426
  const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
312
427
  for (let i = 0; i < TABLE_2.length && !done; i++) {
313
428
  const row = TABLE_2[i];
314
- let value = new BigDecimal(duration[row.valueField]);
429
+ let value = new BigDecimal(BigInt(duration[row.valueField]));
315
430
  const style = internalSlots[row.styleSlot];
316
431
  const display = internalSlots[row.displaySlot];
317
432
  const { unit, numberFormatUnit } = row;
@@ -322,9 +437,9 @@ function PartitionDurationFormatPattern(df, duration) {
322
437
  else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
323
438
  else nextStyle = internalSlots.nanoseconds;
324
439
  if (nextStyle === "numeric" || nextStyle === "fractional") {
325
- if (unit === "seconds") value = value.plus(new BigDecimal(duration.milliseconds).div(1e3)).plus(new BigDecimal(duration.microseconds).div(1e6)).plus(new BigDecimal(duration.nanoseconds).div(1e9));
326
- else if (unit === "milliseconds") value = value.plus(new BigDecimal(duration.microseconds).div(1e3)).plus(new BigDecimal(duration.nanoseconds).div(1e6));
327
- else value = value.plus(new BigDecimal(duration.nanoseconds).div(1e3));
440
+ if (unit === "seconds") value = value.plus(new BigDecimal(BigInt(duration.milliseconds)).div(1e3)).plus(new BigDecimal(BigInt(duration.microseconds)).div(1e6)).plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e9));
441
+ else if (unit === "milliseconds") value = value.plus(new BigDecimal(BigInt(duration.microseconds)).div(1e3)).plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e6));
442
+ else value = value.plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e3));
328
443
  if (internalSlots.fractionalDigits === void 0) {
329
444
  nfOpts.maximumFractionDigits = 9;
330
445
  nfOpts.minimumFractionDigits = 0;
@@ -336,8 +451,14 @@ function PartitionDurationFormatPattern(df, duration) {
336
451
  done = true;
337
452
  }
338
453
  }
339
- if (!value.isZero() || display !== "auto") {
454
+ const minutesBetweenHoursAndSeconds = unit === "minutes" && separated && (internalSlots.secondsDisplay === "always" || duration.seconds !== 0 || duration.milliseconds !== 0 || duration.microseconds !== 0 || duration.nanoseconds !== 0);
455
+ if (!value.isZero() || display !== "auto" || minutesBetweenHoursAndSeconds) {
456
+ if (signDisplayed) {
457
+ if (value.isZero() && negative) value = new BigDecimal("-0");
458
+ signDisplayed = false;
459
+ } else nfOpts.signDisplay = "never";
340
460
  nfOpts.numberingSystem = internalSlots.numberingSystem;
461
+ if (style === "numeric" || style === "2-digit") nfOpts.useGrouping = false;
341
462
  if (style === "2-digit") nfOpts.minimumIntegerDigits = 2;
342
463
  if (style !== "2-digit" && style !== "numeric" && style !== "fractional") {
343
464
  nfOpts.style = "unit";
@@ -354,7 +475,7 @@ function PartitionDurationFormatPattern(df, duration) {
354
475
  value: separator
355
476
  });
356
477
  }
357
- nf.formatToParts(value).forEach(({ type, value }) => {
478
+ nf.formatToParts(value.isZero() && value.isNegative() ? -0 : value).forEach(({ type, value }) => {
358
479
  list.push({
359
480
  type,
360
481
  value,
@@ -384,12 +505,12 @@ function PartitionDurationFormatPattern(df, duration) {
384
505
  let resultLength = result.length;
385
506
  let flattened = [];
386
507
  for (const { type, value } of formatted) if (type === "element") {
387
- invariant$2(resultIndex < resultLength, "Index out of bounds");
508
+ invariant(resultIndex < resultLength, "Index out of bounds");
388
509
  let parts = result[resultIndex];
389
510
  for (const part of parts) flattened.push(part);
390
511
  resultIndex++;
391
512
  } else {
392
- invariant$2(type === "literal", "Type must be literal");
513
+ invariant(type === "literal", "Type must be literal");
393
514
  flattened.push({
394
515
  type: "literal",
395
516
  value
@@ -426,93 +547,41 @@ function IsValidDurationRecord(record) {
426
547
  const sign = DurationRecordSign(record);
427
548
  for (const key of TABLE_1) {
428
549
  const v = record[key];
429
- invariant$2(isFinite(Number(v)), `${key} is not finite`);
550
+ if (!Number.isFinite(v)) return false;
430
551
  if (v < 0 && sign > 0) return false;
431
552
  if (v > 0 && sign < 0) return false;
432
553
  }
433
- return true;
434
- }
435
- //#endregion
436
- //#region packages/ecma262-abstract/ToPrimitive.js
437
- function invariant$1(condition, message, Err = Error) {
438
- if (!condition) throw new Err(message);
439
- }
440
- function IsCallable(fn) {
441
- return typeof fn === "function";
442
- }
443
- function OrdinaryToPrimitive(O, hint) {
444
- let methodNames;
445
- if (hint === "string") methodNames = ["toString", "valueOf"];
446
- else methodNames = ["valueOf", "toString"];
447
- for (const name of methodNames) {
448
- const method = O[name];
449
- if (IsCallable(method)) {
450
- let result = method.call(O);
451
- if (typeof result !== "object") return result;
452
- }
453
- }
454
- throw new TypeError("Cannot convert object to primitive value");
455
- }
456
- /**
457
- * https://tc39.es/ecma262/#sec-toprimitive
458
- */
459
- function ToPrimitive(input, preferredType) {
460
- if (typeof input === "object" && input != null) {
461
- const exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : void 0;
462
- let hint;
463
- if (exoticToPrim !== void 0) {
464
- if (preferredType === void 0) hint = "default";
465
- else if (preferredType === "string") hint = "string";
466
- else {
467
- invariant$1(preferredType === "number", "preferredType must be \"string\" or \"number\"");
468
- hint = "number";
469
- }
470
- let result = exoticToPrim.call(input, hint);
471
- if (typeof result !== "object") return result;
472
- throw new TypeError("Cannot convert exotic object to primitive.");
473
- }
474
- if (preferredType === void 0) preferredType = "number";
475
- return OrdinaryToPrimitive(input, preferredType);
476
- }
477
- return input;
554
+ if ([
555
+ "years",
556
+ "months",
557
+ "weeks"
558
+ ].some((unit) => Math.abs(record[unit]) >= 2 ** 32)) return false;
559
+ const billion = BigInt(1e9);
560
+ const normalizedNanoseconds = BigInt(record.days) * BigInt(86400) * billion + BigInt(record.hours) * BigInt(3600) * billion + BigInt(record.minutes) * BigInt(60) * billion + BigInt(record.seconds) * billion + BigInt(record.milliseconds) * BigInt(1e6) + BigInt(record.microseconds) * BigInt(1e3) + BigInt(record.nanoseconds);
561
+ const limit = BigInt(2 ** 53) * billion;
562
+ return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
478
563
  }
479
564
  //#endregion
480
565
  //#region packages/ecma262-abstract/ToNumber.js
481
- const ZERO = new Decimal(0);
482
- function invariant(condition, message, Err = Error) {
483
- if (!condition) throw new Err(message);
484
- }
485
566
  /**
567
+ * ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
486
568
  * https://tc39.es/ecma262/#sec-tonumber
569
+ * https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L5183-L5191
487
570
  */
488
571
  function ToNumber(arg) {
489
- if (typeof arg === "number") return new Decimal(arg);
490
- if (typeof arg === "bigint") return new Decimal(arg.toString());
491
- invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
492
- if (arg === void 0) return new Decimal(NaN);
493
- if (arg === null || arg === 0) return ZERO;
494
- if (arg === true) return new Decimal(1);
495
- if (typeof arg === "string") try {
496
- return new Decimal(arg);
497
- } catch {
498
- return new Decimal(NaN);
499
- }
500
- invariant(typeof arg === "object", "object expected", TypeError);
501
- let primValue = ToPrimitive(arg, "number");
502
- invariant(typeof primValue !== "object", "object expected", TypeError);
503
- return ToNumber(primValue);
572
+ return new Decimal(+arg);
504
573
  }
505
574
  //#endregion
506
575
  //#region packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
507
576
  function ToIntegerIfIntegral(arg) {
508
577
  const number = ToNumber(arg);
509
- invariant$2(number.isInteger(), `${arg} is not an integer`);
510
- return number.toNumber();
578
+ invariant(number.isInteger(), "Duration field is not an integer", RangeError);
579
+ return number.isZero() ? 0 : number.toNumber();
511
580
  }
512
581
  //#endregion
513
582
  //#region packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
514
583
  function ToDurationRecord(input) {
515
- if (typeof input !== "object") {
584
+ if ((typeof input !== "object" || input === null) && typeof input !== "function") {
516
585
  if (typeof input === "string") throw new RangeError("Invalid duration format");
517
586
  throw new TypeError("Invalid duration");
518
587
  }
@@ -528,121 +597,62 @@ function ToDurationRecord(input) {
528
597
  microseconds: 0,
529
598
  nanoseconds: 0
530
599
  };
531
- if (input.days !== void 0) result.days = ToIntegerIfIntegral(input.days);
532
- if (input.hours !== void 0) result.hours = ToIntegerIfIntegral(input.hours);
533
- if (input.microseconds !== void 0) result.microseconds = ToIntegerIfIntegral(input.microseconds);
534
- if (input.milliseconds !== void 0) result.milliseconds = ToIntegerIfIntegral(input.milliseconds);
535
- if (input.minutes !== void 0) result.minutes = ToIntegerIfIntegral(input.minutes);
536
- if (input.months !== void 0) result.months = ToIntegerIfIntegral(input.months);
537
- if (input.nanoseconds !== void 0) result.nanoseconds = ToIntegerIfIntegral(input.nanoseconds);
538
- if (input.seconds !== void 0) result.seconds = ToIntegerIfIntegral(input.seconds);
539
- if (input.weeks !== void 0) result.weeks = ToIntegerIfIntegral(input.weeks);
540
- if (input.years !== void 0) result.years = ToIntegerIfIntegral(input.years);
541
- if (input.years === void 0 && input.months === void 0 && input.weeks === void 0 && input.days === void 0 && input.hours === void 0 && input.minutes === void 0 && input.seconds === void 0 && input.milliseconds === void 0 && input.microseconds === void 0 && input.nanoseconds === void 0) throw new TypeError("Invalid duration format");
600
+ let anyDefined = false;
601
+ for (const field of [
602
+ "days",
603
+ "hours",
604
+ "microseconds",
605
+ "milliseconds",
606
+ "minutes",
607
+ "months",
608
+ "nanoseconds",
609
+ "seconds",
610
+ "weeks",
611
+ "years"
612
+ ]) {
613
+ const value = input[field];
614
+ if (value !== void 0) {
615
+ anyDefined = true;
616
+ result[field] = ToIntegerIfIntegral(value);
617
+ }
618
+ }
619
+ if (!anyDefined) throw new TypeError("Invalid duration format");
542
620
  if (!IsValidDurationRecord(result)) throw new RangeError("Invalid duration format");
543
621
  return result;
544
622
  }
545
623
  //#endregion
546
- //#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
547
- const numberingSystemNames = [
548
- "adlm",
549
- "ahom",
550
- "arab",
551
- "arabext",
552
- "armn",
553
- "armnlow",
554
- "bali",
555
- "beng",
556
- "bhks",
557
- "brah",
558
- "cakm",
559
- "cham",
560
- "cyrl",
561
- "deva",
562
- "diak",
563
- "ethi",
564
- "fullwide",
565
- "gara",
566
- "geor",
567
- "gong",
568
- "gonm",
569
- "grek",
570
- "greklow",
571
- "gujr",
572
- "gukh",
573
- "guru",
574
- "hanidays",
575
- "hanidec",
576
- "hans",
577
- "hansfin",
578
- "hant",
579
- "hantfin",
580
- "hebr",
581
- "hmng",
582
- "hmnp",
583
- "java",
584
- "jpan",
585
- "jpanfin",
586
- "jpanyear",
587
- "kali",
588
- "kawi",
589
- "khmr",
590
- "knda",
591
- "krai",
592
- "lana",
593
- "lanatham",
594
- "laoo",
595
- "latn",
596
- "lepc",
597
- "limb",
598
- "mathbold",
599
- "mathdbl",
600
- "mathmono",
601
- "mathsanb",
602
- "mathsans",
603
- "mlym",
604
- "modi",
605
- "mong",
606
- "mroo",
607
- "mtei",
608
- "mymr",
609
- "mymrepka",
610
- "mymrpao",
611
- "mymrshan",
612
- "mymrtlng",
613
- "nagm",
614
- "newa",
615
- "nkoo",
616
- "olck",
617
- "onao",
618
- "orya",
619
- "osma",
620
- "outlined",
621
- "rohg",
622
- "roman",
623
- "romanlow",
624
- "saur",
625
- "segment",
626
- "shrd",
627
- "sind",
628
- "sinh",
629
- "sora",
630
- "sund",
631
- "sunu",
632
- "takr",
633
- "talu",
634
- "taml",
635
- "tamldec",
636
- "telu",
637
- "thai",
638
- "tibt",
639
- "tirh",
640
- "tnsa",
641
- "tols",
642
- "vaii",
643
- "wara",
644
- "wcho"
624
+ //#region packages/intl-durationformat/abstract/ToTemporalDurationRecord.ts
625
+ const temporalDuration = globalThis.Temporal?.Duration;
626
+ const durationFrom = temporalDuration?.from;
627
+ const fields = [
628
+ "years",
629
+ "months",
630
+ "weeks",
631
+ "days",
632
+ "hours",
633
+ "minutes",
634
+ "seconds",
635
+ "milliseconds",
636
+ "microseconds",
637
+ "nanoseconds"
645
638
  ];
639
+ const getters = temporalDuration && fields.map((field) => Object.getOwnPropertyDescriptor(temporalDuration.prototype, field).get);
640
+ function ToTemporalDurationRecord(input) {
641
+ if (typeof input === "string" && durationFrom) input = durationFrom.call(temporalDuration, input);
642
+ if (getters && input !== null && (typeof input === "object" || typeof input === "function")) {
643
+ let years;
644
+ try {
645
+ years = getters[0].call(input);
646
+ } catch {
647
+ return ToDurationRecord(input);
648
+ }
649
+ const record = Object.create(null);
650
+ record.years = years;
651
+ for (let i = 1; i < fields.length; i++) record[fields[i]] = getters[i].call(input);
652
+ return record;
653
+ }
654
+ return ToDurationRecord(input);
655
+ }
646
656
  //#endregion
647
657
  //#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/time-separators.js
648
658
  const TIME_SEPARATORS = {
@@ -1398,10 +1408,16 @@ const TIME_SEPARATORS = {
1398
1408
  "twq": { "nu": ["latn"] },
1399
1409
  "tyv": { "nu": ["latn"] },
1400
1410
  "tzm": { "nu": ["latn"] },
1401
- "ug": { "nu": ["latn"] },
1411
+ "ug": {
1412
+ "nu": ["latn"],
1413
+ "separator": { "arabext": "٫" }
1414
+ },
1402
1415
  "uk": { "nu": ["latn"] },
1403
1416
  "und": { "nu": ["latn"] },
1404
- "ur": { "nu": ["latn"] },
1417
+ "ur": {
1418
+ "nu": ["latn"],
1419
+ "separator": { "arabext": "٫" }
1420
+ },
1405
1421
  "ur-IN": {
1406
1422
  "nu": ["arabext"],
1407
1423
  "separator": { "arabext": "٫" }
@@ -1457,8 +1473,27 @@ const TIME_SEPARATORS = {
1457
1473
  };
1458
1474
  //#endregion
1459
1475
  //#region packages/intl-durationformat/core.ts
1476
+ const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
1477
+ function supportedNumberingSystems() {
1478
+ const NumberFormat = Intl.NumberFormat;
1479
+ let systems = numberingSystemsByConstructor.get(NumberFormat);
1480
+ if (!systems) {
1481
+ systems = numberingSystemNames.filter((numberingSystem) => {
1482
+ const options = Object.create(null);
1483
+ options.numberingSystem = numberingSystem;
1484
+ try {
1485
+ return new NumberFormat("en", options).resolvedOptions().numberingSystem === numberingSystem;
1486
+ } catch {
1487
+ return false;
1488
+ }
1489
+ });
1490
+ if (systems.length) numberingSystemsByConstructor.set(NumberFormat, systems);
1491
+ }
1492
+ return systems;
1493
+ }
1460
1494
  const RESOLVED_OPTIONS_KEYS = [
1461
1495
  "locale",
1496
+ "numberingSystem",
1462
1497
  "style",
1463
1498
  "years",
1464
1499
  "yearsDisplay",
@@ -1480,7 +1515,6 @@ const RESOLVED_OPTIONS_KEYS = [
1480
1515
  "microsecondsDisplay",
1481
1516
  "nanoseconds",
1482
1517
  "nanosecondsDisplay",
1483
- "numberingSystem",
1484
1518
  "fractionalDigits"
1485
1519
  ];
1486
1520
  const TABLE_3 = [
@@ -1616,7 +1650,7 @@ var DurationFormat = class DurationFormat {
1616
1650
  const opts = options === void 0 ? Object.create(null) : ToObject(options);
1617
1651
  const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
1618
1652
  const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
1619
- if (numberingSystem !== void 0 && numberingSystemNames.indexOf(numberingSystem) < 0) throw RangeError(`Invalid numberingSystems: ${numberingSystem}`);
1653
+ if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeError(`Invalid numberingSystems: ${numberingSystem}`);
1620
1654
  opt.nu = numberingSystem;
1621
1655
  opt.localeMatcher = matcher;
1622
1656
  const { localeData, availableLocales } = DurationFormat;
@@ -1651,16 +1685,17 @@ var DurationFormat = class DurationFormat {
1651
1685
  for (const key of RESOLVED_OPTIONS_KEYS) {
1652
1686
  let v = internalSlots[key];
1653
1687
  if (key === "fractionalDigits") {
1654
- if (v !== void 0) v = Number(v);
1688
+ if (v === void 0) continue;
1689
+ v = Number(v);
1655
1690
  } else if (v === "fractional") v = "numeric";
1656
- else invariant$2(v !== void 0, `Missing internal slot ${key}`);
1691
+ else invariant(v !== void 0, `Missing internal slot ${key}`);
1657
1692
  ro[key] = v;
1658
1693
  }
1659
1694
  return ro;
1660
1695
  }
1661
1696
  formatToParts(duration) {
1662
1697
  if (getInternalSlots(this).initializedDurationFormat === void 0) throw new TypeError("Error uninitialized locale");
1663
- const record = ToDurationRecord(duration);
1698
+ const record = ToTemporalDurationRecord(duration);
1664
1699
  const parts = PartitionDurationFormatPattern(this, record);
1665
1700
  const result = [];
1666
1701
  for (const { type, unit, value } of parts) {
@@ -1675,7 +1710,7 @@ var DurationFormat = class DurationFormat {
1675
1710
  }
1676
1711
  format(duration) {
1677
1712
  if (getInternalSlots(this).initializedDurationFormat === void 0) throw new TypeError("Error uninitialized locale");
1678
- const record = ToDurationRecord(duration);
1713
+ const record = ToTemporalDurationRecord(duration);
1679
1714
  const parts = PartitionDurationFormatPattern(this, record);
1680
1715
  let result = "";
1681
1716
  for (const { value } of parts) result += value;
@@ -1693,10 +1728,11 @@ var DurationFormat = class DurationFormat {
1693
1728
  static {
1694
1729
  this.localeData = Object.keys(TIME_SEPARATORS.localeData).reduce((all, locale) => {
1695
1730
  DurationFormat.availableLocales.add(locale);
1696
- const nu = [...TIME_SEPARATORS.localeData[locale].nu];
1697
- if (!nu.includes("latn")) nu.push("latn");
1698
1731
  all[locale] = {
1699
- nu,
1732
+ get nu() {
1733
+ const defaults = TIME_SEPARATORS.localeData[locale].nu;
1734
+ return [.../* @__PURE__ */ new Set([...defaults, ...supportedNumberingSystems()])];
1735
+ },
1700
1736
  digitalFormat: {
1701
1737
  default: TIME_SEPARATORS.default,
1702
1738
  ...TIME_SEPARATORS.localeData[locale].separator
@@ -1714,6 +1750,18 @@ var DurationFormat = class DurationFormat {
1714
1750
  this.polyfilled = true;
1715
1751
  }
1716
1752
  };
1753
+ Object.defineProperty(DurationFormat, "length", {
1754
+ value: 0,
1755
+ configurable: true
1756
+ });
1757
+ Object.defineProperty(DurationFormat.supportedLocalesOf, "length", {
1758
+ value: 1,
1759
+ configurable: true
1760
+ });
1761
+ Object.defineProperty(DurationFormat.prototype, Symbol.toStringTag, {
1762
+ value: "Intl.DurationFormat",
1763
+ configurable: true
1764
+ });
1717
1765
  //#endregion
1718
1766
  export { DurationFormat };
1719
1767