@poe-platform/safe-js 0.1.468 → 0.1.470

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.
@@ -1,7 +1,3 @@
1
- import {
2
- __export
3
- } from "./chunk-4YIDX44G.js";
4
-
5
1
  // packages/safe-js/src/interp/internal-symbols.ts
6
2
  var internalSymbols = /* @__PURE__ */ new Set();
7
3
 
@@ -11230,14 +11226,6 @@ function decodeBase64(text, alphabet, mode, budget, maxLength = Number.MAX_SAFE_
11230
11226
  }
11231
11227
  }
11232
11228
 
11233
- // packages/safe-js/src/interp/numberformat-portable.ts
11234
- var numberformat_portable_exports = {};
11235
- __export(numberformat_portable_exports, {
11236
- createPortableNumberFormatter: () => createPortableNumberFormatter,
11237
- numberFormatterOptions: () => numberFormatterOptions,
11238
- numberFormatterResult: () => numberFormatterResult
11239
- });
11240
-
11241
11229
  // packages/safe-js/src/intl-data/dist/pluralrules-engine.js
11242
11230
  import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
11243
11231
  import Decimal$1, { Decimal } from "@formatjs/bigdecimal";
@@ -18284,7 +18272,6 @@ var localeData = Object.freeze({
18284
18272
 
18285
18273
  // packages/safe-js/src/interp/numberformat-numbering.ts
18286
18274
  var NativeNumberFormat = Intl.NumberFormat;
18287
- var nativeUnits = new Set(Intl.supportedValuesOf("unit"));
18288
18275
  function localizeNumberParts(parts, locale, options) {
18289
18276
  parts = parts.flatMap((part) => {
18290
18277
  if (part.type !== "minusSign" && part.type !== "plusSign") return [part];
@@ -18298,16 +18285,12 @@ function localizeNumberParts(parts, locale, options) {
18298
18285
  return separated;
18299
18286
  });
18300
18287
  const numberingSystem = options.numberingSystem;
18301
- const pluralType = options.style === "unit" ? "unit" : options.style === "currency" && options.currencyDisplay === "name" ? "currency" : void 0;
18302
- const nativePlural = pluralType !== "unit" || typeof options.unit === "string" && options.unit.split("-per-").every((unit) => nativeUnits.has(unit));
18303
- const integralPlural = pluralType !== void 0 && nativePlural && options.notation === "standard" && !parts.some((part) => part.type === "fraction");
18304
- if (numberingSystem === "latn" && !integralPlural) return parts;
18288
+ if (numberingSystem === "latn") return parts;
18305
18289
  const digitFormatter = new NativeNumberFormat(locale, { numberingSystem, useGrouping: false });
18306
18290
  const digits = Array.from({ length: 10 }, (_, digit) => digitFormatter.formatToParts(digit).find((part) => part.type === "integer").value);
18307
18291
  const sourceFormatter = new NumberFormat(locale, { numberingSystem, useGrouping: false });
18308
18292
  const sourceDigits = Array.from({ length: 10 }, (_, digit) => sourceFormatter.formatToParts(digit).find((part) => part.type === "integer").value);
18309
18293
  const result = [];
18310
- let roundedInteger;
18311
18294
  for (let index = 0; index < parts.length; index++) {
18312
18295
  const part = parts[index];
18313
18296
  if (part.type === "exponentMinusSign") {
@@ -18340,7 +18323,6 @@ function localizeNumberParts(parts, locale, options) {
18340
18323
  const digit = sourceDigits.indexOf(char);
18341
18324
  return digit < 0 ? char : String(digit);
18342
18325
  }).join("");
18343
- roundedInteger = ascii;
18344
18326
  const grouping = options.useGrouping;
18345
18327
  const formatter = new NativeNumberFormat(locale, {
18346
18328
  numberingSystem,
@@ -18366,21 +18348,6 @@ function localizeNumberParts(parts, locale, options) {
18366
18348
  }
18367
18349
  for (const value of grouped) result.push({ ...part, type: value.type, value: value.value });
18368
18350
  }
18369
- if (integralPlural && roundedInteger !== void 0) {
18370
- const native = new NativeNumberFormat(locale, {
18371
- style: options.style,
18372
- unit: options.unit,
18373
- unitDisplay: options.unitDisplay,
18374
- currency: options.currency,
18375
- currencyDisplay: "name",
18376
- maximumFractionDigits: 0,
18377
- minimumFractionDigits: 0
18378
- });
18379
- const word = native.formatToParts(BigInt(roundedInteger)).find((part) => part.type === pluralType)?.value;
18380
- if (word !== void 0) {
18381
- for (const part of result) if (part.type === pluralType) part.value = word;
18382
- }
18383
- }
18384
18351
  return result;
18385
18352
  }
18386
18353
  function addNumberingSystem(data, locale, numberingSystem) {
@@ -18505,15 +18472,19 @@ function numberFormatterResult(formatter, method, values) {
18505
18472
  // packages/safe-js/src/interp/numberformat-backend.ts
18506
18473
  var NativeNumberFormat3 = Intl.NumberFormat;
18507
18474
  var modernNative = new NativeNumberFormat3("en", { maximumFractionDigits: 0, ...{ roundingMode: "floor" } }).format(1.9) === "1" && typeof Object.getOwnPropertyDescriptor(NativeNumberFormat3.prototype, "formatRange")?.value === "function";
18508
- var portable = modernNative ? void 0 : numberformat_portable_exports;
18475
+ var portableFormatters = /* @__PURE__ */ new WeakSet();
18509
18476
  function createNumberFormatter(locales2, options) {
18510
- return portable === void 0 ? new NativeNumberFormat3(locales2, options) : portable.createPortableNumberFormatter(locales2, options);
18477
+ if (modernNative && options.style !== "unit" && !(options.style === "currency" && options.currencyDisplay === "name"))
18478
+ return new NativeNumberFormat3(locales2, options);
18479
+ const formatter = createPortableNumberFormatter(locales2, options);
18480
+ portableFormatters.add(formatter);
18481
+ return formatter;
18511
18482
  }
18512
18483
  function numberFormatterOptions2(formatter) {
18513
- return portable === void 0 ? { ...formatter.resolvedOptions() } : portable.numberFormatterOptions(formatter);
18484
+ return portableFormatters.has(formatter) ? numberFormatterOptions(formatter) : { ...formatter.resolvedOptions() };
18514
18485
  }
18515
18486
  function numberFormatterResult2(formatter, method, values) {
18516
- return portable === void 0 ? Reflect.apply(Reflect.get(formatter, method), formatter, values) : portable.numberFormatterResult(formatter, method, values);
18487
+ return portableFormatters.has(formatter) ? numberFormatterResult(formatter, method, values) : Reflect.apply(Reflect.get(formatter, method), formatter, values);
18517
18488
  }
18518
18489
 
18519
18490
  // packages/safe-js/src/interp/intl-digit-options.ts
@@ -28785,20 +28756,41 @@ function selectPlural2(value, inputs) {
28785
28756
  return Reflect.apply(inputs.length === 1 ? select : selectRange, pluralRulesState(value).native, inputs);
28786
28757
  }
28787
28758
 
28788
- // packages/safe-js/src/interp/intl-numberformat.ts
28759
+ // packages/safe-js/src/interp/intl-durationformat.ts
28789
28760
  var states10 = /* @__PURE__ */ new WeakMap();
28761
+ function createSandboxDurationFormat(settings) {
28762
+ const value = /* @__PURE__ */ Object.create(null);
28763
+ const options = { locale: settings.locale, numberingSystem: settings.numberingSystem, style: settings.style };
28764
+ for (const [unit, { style, display }] of Object.entries(settings.units)) {
28765
+ options[unit] = style === "fractional" ? "numeric" : style;
28766
+ options[`${unit}Display`] = display;
28767
+ }
28768
+ options.fractionalDigits = settings.fractionalDigits;
28769
+ states10.set(value, { settings, options });
28770
+ return value;
28771
+ }
28772
+ function isSandboxDurationFormat(value) {
28773
+ return typeof value === "object" && value !== null && states10.has(value);
28774
+ }
28775
+ function durationFormatState(value) {
28776
+ if (!isSandboxDurationFormat(value)) throw new TypeError("Intl.DurationFormat requires a DurationFormat receiver.");
28777
+ return states10.get(value);
28778
+ }
28779
+
28780
+ // packages/safe-js/src/interp/intl-numberformat.ts
28781
+ var states11 = /* @__PURE__ */ new WeakMap();
28790
28782
  function createSandboxNumberFormat(locales2, options) {
28791
28783
  const native = createNumberFormatter(locales2, options);
28792
28784
  const value = /* @__PURE__ */ Object.create(null);
28793
- states10.set(value, { native, options: numberFormatterOptions2(native) });
28785
+ states11.set(value, { native, options: numberFormatterOptions2(native) });
28794
28786
  return value;
28795
28787
  }
28796
28788
  function isSandboxNumberFormat(value) {
28797
- return typeof value === "object" && value !== null && states10.has(value);
28789
+ return typeof value === "object" && value !== null && states11.has(value);
28798
28790
  }
28799
28791
  function numberFormatState(value) {
28800
28792
  if (!isSandboxNumberFormat(value)) throw new TypeError("Intl.NumberFormat requires a NumberFormat receiver.");
28801
- return states10.get(value);
28793
+ return states11.get(value);
28802
28794
  }
28803
28795
  async function numberFormatValue(value, budget, context) {
28804
28796
  const primitive = typeof value === "object" && value !== null ? await objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number") : value;
@@ -28822,21 +28814,21 @@ var methods = {
28822
28814
  formatRange: NativeDateTimeFormat.prototype.formatRange,
28823
28815
  formatRangeToParts: NativeDateTimeFormat.prototype.formatRangeToParts
28824
28816
  };
28825
- var states11 = /* @__PURE__ */ new WeakMap();
28817
+ var states12 = /* @__PURE__ */ new WeakMap();
28826
28818
  function createSandboxDateTimeFormat(locales2, options, restoring = false) {
28827
28819
  const input = { ...options };
28828
28820
  if (restoring) delete input.hour12;
28829
28821
  const native = new NativeDateTimeFormat(locales2, input);
28830
28822
  const value = /* @__PURE__ */ Object.create(null);
28831
- states11.set(value, { native, options: { ...Reflect.apply(resolvedOptions6, native, []) } });
28823
+ states12.set(value, { native, options: { ...Reflect.apply(resolvedOptions6, native, []) } });
28832
28824
  return value;
28833
28825
  }
28834
28826
  function isSandboxDateTimeFormat(value) {
28835
- return typeof value === "object" && value !== null && states11.has(value);
28827
+ return typeof value === "object" && value !== null && states12.has(value);
28836
28828
  }
28837
28829
  function dateTimeFormatState(value) {
28838
28830
  if (!isSandboxDateTimeFormat(value)) throw new TypeError("Intl.DateTimeFormat requires a DateTimeFormat receiver.");
28839
- return states11.get(value);
28831
+ return states12.get(value);
28840
28832
  }
28841
28833
  function formatDateTimeValue(receiver, method, values) {
28842
28834
  const { native } = dateTimeFormatState(receiver);
@@ -29200,6 +29192,14 @@ function captureGuestHeapNode(value, encode) {
29200
29192
  const options = pluralRulesState(value).options;
29201
29193
  return { kind: "guest-pluralrules", options: { ...options, pluralCategories: [...options.pluralCategories] }, state: captureObjectState(value, encode) };
29202
29194
  }
29195
+ if (isSandboxDurationFormat(value)) {
29196
+ const { fractionalDigits, ...settings } = durationFormatState(value).settings;
29197
+ return { kind: "guest-durationformat", settings: {
29198
+ ...settings,
29199
+ ...fractionalDigits === void 0 ? {} : { fractionalDigits },
29200
+ units: Object.fromEntries(Object.entries(settings.units).map(([unit, options]) => [unit, { ...options }]))
29201
+ }, state: captureObjectState(value, encode) };
29202
+ }
29203
29203
  if (isSandboxDateTimeFormat(value)) {
29204
29204
  const { options, format: format4 } = dateTimeFormatState(value);
29205
29205
  return { kind: "guest-datetimeformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
@@ -30169,6 +30169,27 @@ function getEnumerableDataValues(value) {
30169
30169
  return getEnumerableDataEntries(value).map(([, entry]) => entry);
30170
30170
  }
30171
30171
 
30172
+ // packages/safe-js/src/interp/intl-duration-locale.ts
30173
+ import { DurationFormat } from "@formatjs/intl-durationformat";
30174
+ var NativeNumberFormat4 = Intl.NumberFormat;
30175
+ var NativeLocale2 = Intl.Locale;
30176
+ var patterns = new Map(Object.entries(DurationFormat.localeData).map(([locale, data]) => {
30177
+ if (data === void 0) throw new TypeError(`Missing duration data for ${locale}.`);
30178
+ return [locale, Object.freeze({ ...data.digitalFormat })];
30179
+ }));
30180
+ function resolveDurationLocale(locales2, options) {
30181
+ const { locale, numberingSystem } = new NativeNumberFormat4(locales2, options).resolvedOptions();
30182
+ const tag = new NativeLocale2(locale);
30183
+ let selected = tag.baseName;
30184
+ if (!patterns.has(selected)) selected = tag.minimize().baseName;
30185
+ while (!patterns.has(selected) && selected.includes("-")) selected = selected.slice(0, selected.lastIndexOf("-"));
30186
+ const pattern = patterns.get(selected);
30187
+ if (pattern === void 0) throw new RangeError(`Missing DurationFormat locale data for ${locale}.`);
30188
+ const separator = pattern[numberingSystem] ?? pattern.default;
30189
+ if (separator === void 0) throw new TypeError("Missing duration separator.");
30190
+ return { locale, numberingSystem, separator };
30191
+ }
30192
+
30172
30193
  // packages/safe-js/src/interp/globals/json-parse.ts
30173
30194
  async function parseJsonWithReviver(text, reviver, budget, context) {
30174
30195
  budget.visitNode(text.length);
@@ -32033,7 +32054,7 @@ function createMiscGlobals(options) {
32033
32054
  }
32034
32055
 
32035
32056
  // packages/safe-js/src/interp/globals/uri.ts
32036
- var conversions = { encodeURI, encodeURIComponent, decodeURI, decodeURIComponent };
32057
+ var conversions = { encodeURI, encodeURIComponent, decodeURI, decodeURIComponent, escape, unescape };
32037
32058
  function createUriGlobals(budget) {
32038
32059
  return Object.fromEntries(Object.entries(conversions).map(([name, conversion]) => {
32039
32060
  const closure = createSandboxClosure({
@@ -34405,6 +34426,262 @@ function createSegmenterConstructor(budget) {
34405
34426
  return constructor;
34406
34427
  }
34407
34428
 
34429
+ // packages/safe-js/src/interp/intl-duration-options.ts
34430
+ async function readDurationOptions(value, locales2, budget, context) {
34431
+ if (value !== void 0 && (value === null || typeof value !== "object")) throw new TypeError("DurationFormat options must be an object.");
34432
+ const input = intlOptionsObject(value, budget);
34433
+ const converted = {};
34434
+ const units = {};
34435
+ let raw;
34436
+ const release = retainValues(budget, () => [input, locales2, converted, units, raw]);
34437
+ try {
34438
+ for (const [key, type] of [["localeMatcher", ["lookup", "best fit"]], ["numberingSystem", "unicodeType"]]) {
34439
+ raw = await readIntlProperty(input, key, budget, context);
34440
+ if (raw !== void 0) converted[key] = await convertIntlOption(raw, key, type, budget, context);
34441
+ }
34442
+ const locale = resolveDurationLocale(locales2, { localeMatcher: converted.localeMatcher, numberingSystem: converted.numberingSystem });
34443
+ raw = await readIntlProperty(input, "style", budget, context);
34444
+ const style = raw === void 0 ? "short" : await convertIntlOption(raw, "style", ["long", "short", "narrow", "digital"], budget, context);
34445
+ let previous = "";
34446
+ for (const unit of ["years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"]) {
34447
+ units[unit] = await readDurationUnitOptions(input, unit, style, previous, budget, context);
34448
+ if (["hours", "minutes", "seconds", "milliseconds", "microseconds"].includes(unit)) previous = units[unit].style;
34449
+ }
34450
+ raw = await readIntlProperty(input, "fractionalDigits", budget, context);
34451
+ let fractionalDigits;
34452
+ if (raw !== void 0) {
34453
+ const number = await sandboxNumber(raw, budget, context);
34454
+ if (Number.isNaN(number) || number < 0 || number > 9) throw new RangeError("Invalid duration fractionalDigits.");
34455
+ fractionalDigits = Math.floor(number);
34456
+ }
34457
+ return { ...locale, style, units, fractionalDigits };
34458
+ } finally {
34459
+ release();
34460
+ }
34461
+ }
34462
+ async function readDurationUnitOptions(input, unit, base, previous, budget, context) {
34463
+ const subsecond = ["milliseconds", "microseconds", "nanoseconds"].includes(unit);
34464
+ const clock = ["hours", "minutes", "seconds"].includes(unit);
34465
+ const styles = ["long", "short", "narrow", ...clock || subsecond ? ["numeric"] : [], ...clock ? ["2-digit"] : []];
34466
+ let raw;
34467
+ let style;
34468
+ const release = retainValues(budget, () => [input, raw, style]);
34469
+ try {
34470
+ raw = await readIntlProperty(input, unit, budget, context);
34471
+ style = raw === void 0 ? void 0 : await convertIntlOption(raw, unit, styles, budget, context);
34472
+ let defaultDisplay = "always";
34473
+ if (style === void 0) {
34474
+ if (base === "digital") {
34475
+ style = clock || subsecond ? "numeric" : "short";
34476
+ if (!clock) defaultDisplay = "auto";
34477
+ } else if (["numeric", "2-digit", "fractional"].includes(previous)) {
34478
+ style = "numeric";
34479
+ if (unit !== "minutes" && unit !== "seconds") defaultDisplay = "auto";
34480
+ } else {
34481
+ style = base;
34482
+ defaultDisplay = "auto";
34483
+ }
34484
+ }
34485
+ if (style === "numeric" && subsecond) {
34486
+ style = "fractional";
34487
+ defaultDisplay = "auto";
34488
+ }
34489
+ raw = await readIntlProperty(input, `${unit}Display`, budget, context);
34490
+ const display = raw === void 0 ? defaultDisplay : await convertIntlOption(raw, `${unit}Display`, ["always", "auto"], budget, context);
34491
+ if (display === "always" && style === "fractional" || previous === "fractional" && style !== "fractional" || ["numeric", "2-digit"].includes(previous) && !["numeric", "2-digit", "fractional"].includes(style))
34492
+ throw new RangeError("Incompatible duration unit style or display.");
34493
+ if (["minutes", "seconds"].includes(unit) && ["numeric", "2-digit"].includes(previous)) style = "2-digit";
34494
+ return { style, display };
34495
+ } finally {
34496
+ release();
34497
+ }
34498
+ }
34499
+
34500
+ // packages/safe-js/src/interp/intl-duration-record.ts
34501
+ async function readDurationRecord(input, budget, context) {
34502
+ if (typeof input === "string") throw new RangeError("Duration strings are not supported.");
34503
+ if (typeof input !== "object" || input === null) throw new TypeError("Expected a duration object.");
34504
+ const record4 = { years: 0, months: 0, weeks: 0, days: 0, hours: 0, minutes: 0, seconds: 0, milliseconds: 0, microseconds: 0, nanoseconds: 0 };
34505
+ let raw;
34506
+ let present = false;
34507
+ const release = retainValues(budget, () => [input, record4, raw]);
34508
+ try {
34509
+ for (const key of ["days", "hours", "microseconds", "milliseconds", "minutes", "months", "nanoseconds", "seconds", "weeks", "years"]) {
34510
+ raw = await readIntlProperty(input, key, budget, context);
34511
+ if (raw === void 0) continue;
34512
+ present = true;
34513
+ const value = await sandboxNumber(raw, budget, context);
34514
+ if (!Number.isInteger(value)) throw new RangeError("Duration fields must be finite integers.");
34515
+ record4[key] = value === 0 ? 0 : value;
34516
+ }
34517
+ if (!present) throw new TypeError("Expected at least one duration field.");
34518
+ let sign = 0;
34519
+ for (const value of Object.values(record4)) {
34520
+ const current = Math.sign(value);
34521
+ if (current !== 0) {
34522
+ if (sign !== 0 && sign !== current) throw new RangeError("Duration fields must have the same sign.");
34523
+ sign = current;
34524
+ }
34525
+ }
34526
+ if ([record4.years, record4.months, record4.weeks].some((value) => Math.abs(value) >= 2 ** 32))
34527
+ throw new RangeError("Duration calendar fields exceed their limit.");
34528
+ const nanoseconds = BigInt(record4.days) * 86400000000000n + BigInt(record4.hours) * 3600000000000n + BigInt(record4.minutes) * 60000000000n + BigInt(record4.seconds) * 1000000000n + BigInt(record4.milliseconds) * 1000000n + BigInt(record4.microseconds) * 1000n + BigInt(record4.nanoseconds);
34529
+ const limit = 2n ** 53n * 1000000000n;
34530
+ if (nanoseconds <= -limit || nanoseconds >= limit) throw new RangeError("Duration time fields exceed their limit.");
34531
+ return record4;
34532
+ } finally {
34533
+ release();
34534
+ }
34535
+ }
34536
+
34537
+ // packages/safe-js/src/interp/intl-duration-parts.ts
34538
+ import { BigDecimal as BigDecimal2 } from "@formatjs/bigdecimal";
34539
+ var NativeListFormat2 = Intl.ListFormat;
34540
+ function formatDurationParts(settings, duration, separator) {
34541
+ const units = Object.keys(duration);
34542
+ const lists = [];
34543
+ const negative = Object.values(duration).some((value) => value < 0);
34544
+ let first = true;
34545
+ const amount = (index2) => {
34546
+ let value = new BigDecimal2(BigInt(duration[units[index2]]).toString());
34547
+ for (let next = index2 + 1; next < units.length && settings.units[units[next]].style === "fractional"; next++)
34548
+ value = value.plus(new BigDecimal2(BigInt(duration[units[next]]).toString()).div(new BigDecimal2(1e3).pow(next - index2)));
34549
+ return value;
34550
+ };
34551
+ const numberParts = (index2, value, numeric) => {
34552
+ const unit = units[index2];
34553
+ const style = settings.units[unit].style;
34554
+ const options = { numberingSystem: settings.numberingSystem, signDisplay: first ? "auto" : "never" };
34555
+ if (numeric) {
34556
+ options.useGrouping = false;
34557
+ if (style === "2-digit") options.minimumIntegerDigits = 2;
34558
+ } else {
34559
+ options.style = "unit";
34560
+ options.unit = unit.slice(0, -1);
34561
+ options.unitDisplay = style;
34562
+ }
34563
+ if (settings.units[units[index2 + 1] ?? ""]?.style === "fractional") {
34564
+ options.minimumFractionDigits = settings.fractionalDigits ?? 0;
34565
+ options.maximumFractionDigits = settings.fractionalDigits ?? 9;
34566
+ options.roundingMode = "trunc";
34567
+ }
34568
+ const input = first && negative && value.isZero() ? -0 : value.toString();
34569
+ first = false;
34570
+ const formatter = createPortableNumberFormatter(settings.locale, options);
34571
+ const parts = numberFormatterResult(formatter, "formatToParts", [input]);
34572
+ return parts.map((part) => ({ ...part, unit: unit.slice(0, -1) }));
34573
+ };
34574
+ for (let index2 = 0; index2 < units.length; index2++) {
34575
+ const unit = units[index2];
34576
+ const option = settings.units[unit];
34577
+ if (option.style === "fractional") break;
34578
+ if (["numeric", "2-digit"].includes(option.style)) {
34579
+ const hours = index2 <= 4 && (duration.hours !== 0 || settings.units.hours.display === "always");
34580
+ const secondsValue = amount(6);
34581
+ const seconds = !secondsValue.isZero() || settings.units.seconds.display === "always";
34582
+ const minutes = index2 <= 5 && (duration.minutes !== 0 || settings.units.minutes.display === "always" || hours && seconds);
34583
+ const parts = [];
34584
+ for (const [clockIndex, displayed] of [[4, hours], [5, minutes], [6, seconds]]) {
34585
+ if (!displayed) continue;
34586
+ if (parts.length) parts.push({ type: "literal", value: separator });
34587
+ parts.push(...numberParts(clockIndex, clockIndex === 6 ? secondsValue : amount(clockIndex), true));
34588
+ }
34589
+ if (parts.length) lists.push(parts);
34590
+ break;
34591
+ }
34592
+ const value = amount(index2);
34593
+ if (!value.isZero() || option.display === "always") lists.push(numberParts(index2, value, false));
34594
+ if (settings.units[units[index2 + 1] ?? ""]?.style === "fractional") break;
34595
+ }
34596
+ const list2 = new NativeListFormat2(settings.locale, { type: "unit", style: settings.style === "digital" ? "short" : settings.style });
34597
+ let index = 0;
34598
+ return list2.formatToParts(lists.map((parts) => parts.map((part) => part.value).join(""))).flatMap((part) => part.type === "element" ? lists[index++] : [{ type: "literal", value: part.value }]);
34599
+ }
34600
+
34601
+ // packages/safe-js/src/interp/globals/intl-durationformat.ts
34602
+ var supportedLocalesOf10 = Intl.NumberFormat.supportedLocalesOf;
34603
+ function createDurationFormatConstructor(budget) {
34604
+ const prototype = createIntrinsicObject();
34605
+ const constructor = createSandboxClosure({
34606
+ guest: true,
34607
+ sandbox: true,
34608
+ name: "DurationFormat",
34609
+ length: 0,
34610
+ call: () => {
34611
+ throw new TypeError("Constructor DurationFormat requires 'new'.");
34612
+ },
34613
+ construct: async ([input, options], context) => {
34614
+ const target = context?.newTarget;
34615
+ const selected = target === void 0 || target === constructor ? prototype : context?.getProperty !== void 0 ? await context.getProperty(target, "prototype") : await readPropertyDescriptor(getSandboxPropertyDescriptor(target, "prototype", budget) ?? { value: void 0 }, target, context);
34616
+ let locales2 = [];
34617
+ let settings;
34618
+ const release = retainValues(budget, () => [selected, locales2, settings]);
34619
+ try {
34620
+ locales2 = await canonicalizeGuestLocales(input, budget, context);
34621
+ settings = await readDurationOptions(options, locales2, budget, context);
34622
+ const value = createSandboxDurationFormat(settings);
34623
+ setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
34624
+ return allocateProducedSandboxValue(value, budget);
34625
+ } finally {
34626
+ release();
34627
+ }
34628
+ }
34629
+ });
34630
+ const properties = materializeFunctionProperties(constructor);
34631
+ Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
34632
+ Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
34633
+ guest: true,
34634
+ sandbox: true,
34635
+ name: "supportedLocalesOf",
34636
+ length: 1,
34637
+ call: async ([input, options], context) => {
34638
+ const locales2 = await canonicalizeGuestLocales(input, budget, context);
34639
+ const release = retainValues(budget, () => [locales2]);
34640
+ try {
34641
+ const source = intlOptionsObject(options, budget);
34642
+ const raw = await readIntlProperty(source, "localeMatcher", budget, context);
34643
+ const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
34644
+ return allocateProducedSandboxValue(supportedLocalesOf10(locales2, { localeMatcher: matcher }), budget);
34645
+ } finally {
34646
+ release();
34647
+ }
34648
+ }
34649
+ }), writable: true, configurable: true });
34650
+ Object.defineProperties(prototype, {
34651
+ constructor: { value: constructor, writable: true, configurable: true },
34652
+ [Symbol.toStringTag]: { value: "Intl.DurationFormat", configurable: true },
34653
+ resolvedOptions: { value: createSandboxClosure({
34654
+ guest: true,
34655
+ sandbox: true,
34656
+ name: "resolvedOptions",
34657
+ length: 0,
34658
+ call: (_args, context) => allocateProducedSandboxValue({ ...durationFormatState(context?.thisValue).options }, budget)
34659
+ }), writable: true, configurable: true }
34660
+ });
34661
+ for (const method of ["format", "formatToParts"]) {
34662
+ Object.defineProperty(prototype, method, { value: createSandboxClosure({
34663
+ guest: true,
34664
+ sandbox: true,
34665
+ name: method,
34666
+ length: 1,
34667
+ call: async ([input], context) => {
34668
+ const receiver = context?.thisValue;
34669
+ const { settings } = durationFormatState(receiver);
34670
+ const release = retainValues(budget, () => [receiver, input]);
34671
+ try {
34672
+ const record4 = await readDurationRecord(input, budget, context);
34673
+ budget.visitNode(100);
34674
+ const parts = formatDurationParts(settings, record4, settings.separator);
34675
+ return allocateProducedSandboxValue(method === "format" ? parts.map((part) => part.value).join("") : parts, budget);
34676
+ } finally {
34677
+ release();
34678
+ }
34679
+ }
34680
+ }), writable: true, configurable: true });
34681
+ }
34682
+ return constructor;
34683
+ }
34684
+
34408
34685
  // packages/safe-js/src/interp/globals/intl.ts
34409
34686
  var supportedValuesOf = Intl.supportedValuesOf;
34410
34687
  function createIntlGlobal(budget, now) {
@@ -34427,6 +34704,7 @@ function createIntlGlobal(budget, now) {
34427
34704
  const dateTimeFormat = createDateTimeFormatConstructor(budget, now);
34428
34705
  const pluralRules = createPluralRulesConstructor(budget);
34429
34706
  const segmenter = createSegmenterConstructor(budget);
34707
+ const durationFormat = createDurationFormatConstructor(budget);
34430
34708
  Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
34431
34709
  Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
34432
34710
  Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
@@ -34436,13 +34714,14 @@ function createIntlGlobal(budget, now) {
34436
34714
  Object.defineProperty(intl, "DateTimeFormat", { value: dateTimeFormat, writable: true, configurable: true });
34437
34715
  Object.defineProperty(intl, "PluralRules", { value: pluralRules, writable: true, configurable: true });
34438
34716
  Object.defineProperty(intl, "Segmenter", { value: segmenter, writable: true, configurable: true });
34717
+ Object.defineProperty(intl, "DurationFormat", { value: durationFormat, writable: true, configurable: true });
34439
34718
  for (const [name, call] of Object.entries(methods3)) {
34440
34719
  const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
34441
34720
  Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
34442
34721
  }
34443
34722
  Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
34444
34723
  registerBuiltinIdentities(budget, { Intl: intl });
34445
- for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat, pluralRules, segmenter]) {
34724
+ for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat, pluralRules, segmenter, durationFormat]) {
34446
34725
  const prototype = constructor.properties.prototype;
34447
34726
  for (const owner of [prototype, constructor.properties])
34448
34727
  for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
@@ -34560,7 +34839,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34560
34839
  createRawJson(node.text);
34561
34840
  return true;
34562
34841
  }
34563
- if (!["guest-segmenter", "guest-segments", "module-function", "async-generator-driver", "async-generator-handler", "async-function-driver", "async-function-handler", "thenable-state", "thenable-resolver", "construction-environment", "capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-locale", "guest-listformat", "guest-pluralrules", "guest-displaynames", "guest-relativetimeformat", "guest-datetimeformat", "guest-numberformat", "guest-collator", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "async-disposable-stack", "async-cleanup", "async-cleanup-handler", "disposable-stack", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
34842
+ if (!["guest-durationformat", "guest-segmenter", "guest-segments", "module-function", "async-generator-driver", "async-generator-handler", "async-function-driver", "async-function-handler", "thenable-state", "thenable-resolver", "construction-environment", "capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-locale", "guest-listformat", "guest-pluralrules", "guest-displaynames", "guest-relativetimeformat", "guest-datetimeformat", "guest-numberformat", "guest-collator", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "async-disposable-stack", "async-cleanup", "async-cleanup-handler", "disposable-stack", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
34564
34843
  const reference = (value, kinds) => {
34565
34844
  const ref = record2(value);
34566
34845
  fields(ref, ["kind", "id"]);
@@ -34890,6 +35169,30 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34890
35169
  throw new TypeError("Invalid segment iterator boundary.");
34891
35170
  }
34892
35171
  state(node.state);
35172
+ } else if (node.kind === "guest-durationformat") {
35173
+ fields(node, ["kind", "settings", "state"]);
35174
+ const settings = record2(node.settings);
35175
+ fields(settings, ["locale", "numberingSystem", "separator", "style", "units"], ["fractionalDigits"]);
35176
+ if (typeof settings.locale !== "string" || typeof settings.numberingSystem !== "string" || !["long", "short", "narrow", "digital"].includes(settings.style) || settings.fractionalDigits !== void 0 && (!Number.isInteger(settings.fractionalDigits) || settings.fractionalDigits < 0 || settings.fractionalDigits > 9))
35177
+ throw new TypeError("Invalid duration settings.");
35178
+ const locale = resolveDurationLocale([settings.locale], { numberingSystem: settings.numberingSystem });
35179
+ if (locale.locale !== settings.locale || locale.numberingSystem !== settings.numberingSystem || locale.separator !== settings.separator)
35180
+ throw new TypeError("Invalid resolved duration locale.");
35181
+ const units = record2(settings.units);
35182
+ const names = ["years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"];
35183
+ fields(units, names);
35184
+ let previous = "";
35185
+ for (const name of names) {
35186
+ const unit = record2(units[name]);
35187
+ fields(unit, ["style", "display"]);
35188
+ const clock = ["hours", "minutes", "seconds"].includes(name);
35189
+ const subsecond = ["milliseconds", "microseconds", "nanoseconds"].includes(name);
35190
+ const allowed = ["long", "short", "narrow", ...clock ? ["numeric", "2-digit"] : [], ...subsecond ? ["fractional"] : []];
35191
+ if (typeof unit.style !== "string" || !allowed.includes(unit.style) || !["always", "auto"].includes(unit.display) || unit.style === "fractional" && unit.display !== "auto" || previous === "fractional" && unit.style !== "fractional" || ["numeric", "2-digit"].includes(previous) && !["numeric", "2-digit", "fractional"].includes(unit.style) || ["minutes", "seconds"].includes(name) && ["numeric", "2-digit"].includes(previous) && unit.style !== "2-digit")
35192
+ throw new TypeError("Invalid duration unit options.");
35193
+ if (clock || name === "milliseconds" || name === "microseconds") previous = unit.style;
35194
+ }
35195
+ state(node.state);
34893
35196
  } else if (node.kind === "guest-pluralrules") {
34894
35197
  fields(node, ["kind", "options", "state"]);
34895
35198
  const options = record2(node.options);
@@ -38475,7 +38778,7 @@ var structuredCloneErrorNames = ["Error", "EvalError", "RangeError", "ReferenceE
38475
38778
  function* cloneStructuredGraph(value, state, budget, depth = 0) {
38476
38779
  assertSandboxDataDepth(depth);
38477
38780
  budget.visitNode();
38478
- if (typeof value === "symbol" || isSandboxModuleNamespace(value) || isSandboxClosure(value) || isSandboxPromise(value) || isSandboxGenerator(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxArrayIterator(value) || isSandboxStringIterator(value) || isSandboxArguments(value) || isSandboxSegmenter(value) || isSandboxSegments(value) || isSandboxLocale(value) || isSandboxCollator(value) || isSandboxDateTimeFormat(value) || isSandboxDisplayNames(value) || isSandboxListFormat(value) || isSandboxNumberFormat(value) || isSandboxPluralRules(value) || isSandboxRelativeTimeFormat(value))
38781
+ if (typeof value === "symbol" || isSandboxModuleNamespace(value) || isSandboxClosure(value) || isSandboxPromise(value) || isSandboxGenerator(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxArrayIterator(value) || isSandboxStringIterator(value) || isSandboxArguments(value) || isSandboxSegmenter(value) || isSandboxSegments(value) || isSandboxLocale(value) || isSandboxCollator(value) || isSandboxDateTimeFormat(value) || isSandboxDisplayNames(value) || isSandboxDurationFormat(value) || isSandboxListFormat(value) || isSandboxNumberFormat(value) || isSandboxPluralRules(value) || isSandboxRelativeTimeFormat(value))
38479
38782
  throw new DOMException("Value cannot be structured cloned.", "DataCloneError");
38480
38783
  if (typeof value !== "object" || value === null) return allocateProducedSandboxValue(value, budget);
38481
38784
  if (iteratorHelperStates.has(value) || iteratorWrapperStates.has(value))
@@ -38683,6 +38986,11 @@ function measureSandboxData(values, options = {}) {
38683
38986
  if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
38684
38987
  if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
38685
38988
  if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
38989
+ if (isSandboxDurationFormat(value)) {
38990
+ const state = durationFormatState(value);
38991
+ visit(state.settings, depth + 1);
38992
+ visit(state.options, depth + 1);
38993
+ }
38686
38994
  if (isSandboxNumberFormat(value)) {
38687
38995
  const state = numberFormatState(value);
38688
38996
  visit(state.options, depth + 1);
@@ -56735,4 +57043,4 @@ authorization of the copyright holder.
56735
57043
  SPDX-License-Identifier: Unicode-3.0
56736
57044
 
56737
57045
  */
56738
- //# sourceMappingURL=chunk-BNHG2QJQ.js.map
57046
+ //# sourceMappingURL=chunk-4LQGK4QH.js.map