@poe-platform/safe-js 0.1.462 → 0.1.464

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.
@@ -6288,11 +6288,11 @@ function assertBareImportSpecifier(specifier) {
6288
6288
  }
6289
6289
  }
6290
6290
  function hasInvalidImportPathDots(value) {
6291
- const segments = value.split(".");
6292
- if (segments.some((segment) => segment.length === 0)) {
6291
+ const segments2 = value.split(".");
6292
+ if (segments2.some((segment) => segment.length === 0)) {
6293
6293
  return true;
6294
6294
  }
6295
- return segments.length > 1 && ["js", "mjs", "cjs", "ts", "mts", "cts", "json"].includes(segments.at(-1) ?? "");
6295
+ return segments2.length > 1 && ["js", "mjs", "cjs", "ts", "mts", "cts", "json"].includes(segments2.at(-1) ?? "");
6296
6296
  }
6297
6297
  function hasProtocolPrefix(value) {
6298
6298
  const colonIndex = value.indexOf(":");
@@ -9036,6 +9036,48 @@ function nextStringIterator(value, budget) {
9036
9036
  return { value: entry, done: false };
9037
9037
  }
9038
9038
 
9039
+ // packages/safe-js/src/interp/intl-segmenter.ts
9040
+ var NativeSegmenter = Intl.Segmenter;
9041
+ var nativeSegment = NativeSegmenter.prototype.segment;
9042
+ var nativeResolvedOptions = NativeSegmenter.prototype.resolvedOptions;
9043
+ var nativeContaining = Object.getPrototypeOf(new NativeSegmenter("en").segment("")).containing;
9044
+ var segmenters = /* @__PURE__ */ new WeakMap();
9045
+ var segments = /* @__PURE__ */ new WeakMap();
9046
+ function createSandboxSegmenter(locales2, options) {
9047
+ const native = new NativeSegmenter(locales2, options);
9048
+ const value = /* @__PURE__ */ Object.create(null);
9049
+ segmenters.set(value, { native, options: Reflect.apply(nativeResolvedOptions, native, []) });
9050
+ return value;
9051
+ }
9052
+ function isSandboxSegmenter(value) {
9053
+ return typeof value === "object" && value !== null && segmenters.has(value);
9054
+ }
9055
+ function segmenterState(value) {
9056
+ if (!isSandboxSegmenter(value)) throw new TypeError("Intl.Segmenter requires a Segmenter receiver.");
9057
+ return segmenters.get(value);
9058
+ }
9059
+ function createSandboxSegments(state) {
9060
+ const native = Reflect.apply(nativeSegment, segmenterState(state.segmenter).native, [state.input]);
9061
+ const value = /* @__PURE__ */ Object.create(null);
9062
+ segments.set(value, { ...state, native });
9063
+ return value;
9064
+ }
9065
+ function isSandboxSegments(value) {
9066
+ return typeof value === "object" && value !== null && segments.has(value);
9067
+ }
9068
+ function segmentState(value, iterator) {
9069
+ if (!isSandboxSegments(value) || iterator !== void 0 && segments.get(value).index !== void 0 !== iterator)
9070
+ throw new TypeError(iterator ? "Segment iterator requires a segment iterator receiver." : "Segments method requires a Segments receiver.");
9071
+ return segments.get(value);
9072
+ }
9073
+ function containingSegment(value, index, iterator, budget) {
9074
+ const state = segmentState(value, iterator);
9075
+ budget.visitNode(state.input.length + 1);
9076
+ const result = Reflect.apply(nativeContaining, state.native, [index]);
9077
+ if (iterator && result !== void 0) state.index = result.index + result.segment.length;
9078
+ return result === void 0 ? void 0 : { ...result };
9079
+ }
9080
+
9039
9081
  // packages/safe-js/src/interp/iterator-wrapper.ts
9040
9082
  var iteratorWrapperStates = /* @__PURE__ */ new WeakMap();
9041
9083
 
@@ -18508,14 +18550,16 @@ function numberFormatterResult2(formatter, method, values) {
18508
18550
  return portable === void 0 ? Reflect.apply(Reflect.get(formatter, method), formatter, values) : portable.numberFormatterResult(formatter, method, values);
18509
18551
  }
18510
18552
 
18511
- // packages/safe-js/src/interp/number-locale.ts
18553
+ // packages/safe-js/src/interp/intl-digit-options.ts
18512
18554
  var roundingIncrements = [1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3, 2e3, 2500, 5e3];
18513
- async function readNumberFormatOptions(inputValue, locales2, budget, context) {
18555
+ async function readIntlDigitOptions(input, defaults, budget, context) {
18514
18556
  const options = /* @__PURE__ */ Object.create(null);
18515
18557
  const digits = /* @__PURE__ */ Object.create(null);
18516
- const release = retainValues(budget, () => [inputValue, locales2, options, digits]);
18558
+ const minimumDefault = defaults.minimum;
18559
+ let maximumDefault = defaults.maximum;
18560
+ const notation = defaults.notation;
18561
+ const release = retainValues(budget, () => [input, options, digits]);
18517
18562
  try {
18518
- const input = intlOptionsObject(inputValue, budget);
18519
18563
  const readString = async (key, type) => {
18520
18564
  const raw = await readIntlProperty(input, key, budget, context);
18521
18565
  if (raw === void 0) return void 0;
@@ -18531,29 +18575,6 @@ async function readNumberFormatOptions(inputValue, locales2, budget, context) {
18531
18575
  throw new RangeError(`Invalid ${key} option.`);
18532
18576
  return Math.floor(number);
18533
18577
  };
18534
- await readString("localeMatcher", ["lookup", "best fit"]);
18535
- await readString("numberingSystem", "unicodeType");
18536
- const style = await readString("style", ["decimal", "percent", "currency", "unit"]) ?? "decimal";
18537
- const currency = await readString("currency");
18538
- if (currency === void 0) {
18539
- if (style === "currency") throw new TypeError("Currency formatting requires a currency.");
18540
- } else if (currency.length !== 3 || ![...currency].every((char) => char >= "A" && char <= "Z" || char >= "a" && char <= "z"))
18541
- throw new RangeError("Invalid currency code.");
18542
- await readString("currencyDisplay", ["code", "symbol", "narrowSymbol", "name"]);
18543
- await readString("currencySign", ["standard", "accounting"]);
18544
- const unit = await readString("unit");
18545
- if (unit === void 0) {
18546
- if (style === "unit") throw new TypeError("Unit formatting requires a unit.");
18547
- } else createNumberFormatter("en", { style: "unit", unit });
18548
- await readString("unitDisplay", ["short", "narrow", "long"]);
18549
- const notation = await readString("notation", ["standard", "scientific", "engineering", "compact"]) ?? "standard";
18550
- let minimumDefault = 0;
18551
- let maximumDefault = style === "percent" ? 0 : 3;
18552
- if (style === "currency" && notation === "standard") {
18553
- const currencyDefaults = numberFormatterOptions2(createNumberFormatter("en", { style: "currency", currency }));
18554
- minimumDefault = currencyDefaults.minimumFractionDigits;
18555
- maximumDefault = currencyDefaults.maximumFractionDigits;
18556
- }
18557
18578
  options.minimumIntegerDigits = await numberOption(await readIntlProperty(input, "minimumIntegerDigits", budget, context), "minimumIntegerDigits", 1, 21, 1);
18558
18579
  for (const key of ["minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"])
18559
18580
  digits[key] = await readIntlProperty(input, key, budget, context);
@@ -18585,6 +18606,50 @@ async function readNumberFormatOptions(inputValue, locales2, budget, context) {
18585
18606
  options.minimumFractionDigits = minimum;
18586
18607
  options.maximumFractionDigits = maximum;
18587
18608
  }
18609
+ return options;
18610
+ } finally {
18611
+ release();
18612
+ }
18613
+ }
18614
+
18615
+ // packages/safe-js/src/interp/number-locale.ts
18616
+ async function readNumberFormatOptions(inputValue, locales2, budget, context) {
18617
+ const options = /* @__PURE__ */ Object.create(null);
18618
+ const release = retainValues(budget, () => [inputValue, locales2, options]);
18619
+ try {
18620
+ const input = intlOptionsObject(inputValue, budget);
18621
+ const readString = async (key, type) => {
18622
+ const raw = await readIntlProperty(input, key, budget, context);
18623
+ if (raw === void 0) return void 0;
18624
+ const text = type === void 0 ? await sandboxString(raw, budget, context) : await convertIntlOption(raw, key, type, budget, context);
18625
+ if (type === void 0) budget.visitNode(text.length);
18626
+ options[key] = text;
18627
+ return text;
18628
+ };
18629
+ await readString("localeMatcher", ["lookup", "best fit"]);
18630
+ await readString("numberingSystem", "unicodeType");
18631
+ const style = await readString("style", ["decimal", "percent", "currency", "unit"]) ?? "decimal";
18632
+ const currency = await readString("currency");
18633
+ if (currency === void 0) {
18634
+ if (style === "currency") throw new TypeError("Currency formatting requires a currency.");
18635
+ } else if (currency.length !== 3 || ![...currency].every((char) => char >= "A" && char <= "Z" || char >= "a" && char <= "z"))
18636
+ throw new RangeError("Invalid currency code.");
18637
+ await readString("currencyDisplay", ["code", "symbol", "narrowSymbol", "name"]);
18638
+ await readString("currencySign", ["standard", "accounting"]);
18639
+ const unit = await readString("unit");
18640
+ if (unit === void 0) {
18641
+ if (style === "unit") throw new TypeError("Unit formatting requires a unit.");
18642
+ } else createNumberFormatter("en", { style: "unit", unit });
18643
+ await readString("unitDisplay", ["short", "narrow", "long"]);
18644
+ const notation = await readString("notation", ["standard", "scientific", "engineering", "compact"]) ?? "standard";
18645
+ let minimumDefault = 0;
18646
+ let maximumDefault = style === "percent" ? 0 : 3;
18647
+ if (style === "currency" && notation === "standard") {
18648
+ const currencyDefaults = numberFormatterOptions2(createNumberFormatter("en", { style: "currency", currency }));
18649
+ minimumDefault = currencyDefaults.minimumFractionDigits;
18650
+ maximumDefault = currencyDefaults.maximumFractionDigits;
18651
+ }
18652
+ Object.assign(options, await readIntlDigitOptions(input, { minimum: minimumDefault, maximum: maximumDefault, notation }, budget, context));
18588
18653
  createNumberFormatter(locales2, options);
18589
18654
  await readString("compactDisplay", ["short", "long"]);
18590
18655
  const grouping = await readIntlProperty(input, "useGrouping", budget, context);
@@ -19785,7 +19850,7 @@ import { types as types7 } from "node:util";
19785
19850
 
19786
19851
  // packages/safe-js/src/interp/intl-collator.ts
19787
19852
  var NativeCollator = Intl.Collator;
19788
- var nativeResolvedOptions = NativeCollator.prototype.resolvedOptions;
19853
+ var nativeResolvedOptions2 = NativeCollator.prototype.resolvedOptions;
19789
19854
  var nativeCompare = Object.getOwnPropertyDescriptor(NativeCollator.prototype, "compare").get;
19790
19855
  var states5 = /* @__PURE__ */ new WeakMap();
19791
19856
  var optionTypes = [
@@ -19824,7 +19889,7 @@ async function readCollatorOptions(input, budget, context, invalid) {
19824
19889
  function createSandboxCollator(locales2, options) {
19825
19890
  const native = new NativeCollator(locales2, options);
19826
19891
  const value = /* @__PURE__ */ Object.create(null);
19827
- states5.set(value, { native, options: Reflect.apply(nativeResolvedOptions, native, []) });
19892
+ states5.set(value, { native, options: Reflect.apply(nativeResolvedOptions2, native, []) });
19828
19893
  return value;
19829
19894
  }
19830
19895
  function isSandboxCollator(value) {
@@ -28629,7 +28694,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28629
28694
  }
28630
28695
  const updated = Object.values(base).filter((value) => value !== void 0).join("-") + canonical.slice(native.baseName.length);
28631
28696
  const extension = unicodeKeywords(updated);
28632
- const optionTypes5 = [
28697
+ const optionTypes7 = [
28633
28698
  ["calendar", "ca", "unicodeType"],
28634
28699
  ["collation", "co", "unicodeType"],
28635
28700
  ["firstDayOfWeek", "fw", "unicodeType"],
@@ -28638,7 +28703,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
28638
28703
  ["numeric", "kn", "boolean"],
28639
28704
  ["numberingSystem", "nu", "unicodeType"]
28640
28705
  ];
28641
- for (const [key, extensionKey, type] of optionTypes5) {
28706
+ for (const [key, extensionKey, type] of optionTypes7) {
28642
28707
  let value = await readIntlProperty(options, key, budget, context);
28643
28708
  if (value === void 0) continue;
28644
28709
  if (key === "firstDayOfWeek") {
@@ -28726,20 +28791,48 @@ function displayName(value, code) {
28726
28791
  return Reflect.apply(of, displayNamesState(value).native, [code]);
28727
28792
  }
28728
28793
 
28729
- // packages/safe-js/src/interp/intl-numberformat.ts
28794
+ // packages/safe-js/src/interp/intl-pluralrules.ts
28795
+ var PortablePluralRules = numberFormatIntl.PluralRules;
28796
+ var select = PortablePluralRules.prototype.select;
28797
+ var selectRange = PortablePluralRules.prototype.selectRange;
28798
+ var resolvedOptions5 = PortablePluralRules.prototype.resolvedOptions;
28730
28799
  var states9 = /* @__PURE__ */ new WeakMap();
28800
+ function createSandboxPluralRules(locales2, options) {
28801
+ const native = new PortablePluralRules(locales2, options);
28802
+ const value = /* @__PURE__ */ Object.create(null);
28803
+ states9.set(value, { native, options: { ...Reflect.apply(resolvedOptions5, native, []) } });
28804
+ return value;
28805
+ }
28806
+ function isSandboxPluralRules(value) {
28807
+ return typeof value === "object" && value !== null && states9.has(value);
28808
+ }
28809
+ function pluralRulesState(value) {
28810
+ if (!isSandboxPluralRules(value)) throw new TypeError("Intl.PluralRules requires a PluralRules receiver.");
28811
+ return states9.get(value);
28812
+ }
28813
+ function selectPlural2(value, inputs) {
28814
+ inputs = inputs.map((input) => {
28815
+ if (typeof input !== "string") return input;
28816
+ const number = Number(input);
28817
+ return !Number.isFinite(number) || number === 0 ? number : input.trim();
28818
+ });
28819
+ return Reflect.apply(inputs.length === 1 ? select : selectRange, pluralRulesState(value).native, inputs);
28820
+ }
28821
+
28822
+ // packages/safe-js/src/interp/intl-numberformat.ts
28823
+ var states10 = /* @__PURE__ */ new WeakMap();
28731
28824
  function createSandboxNumberFormat(locales2, options) {
28732
28825
  const native = createNumberFormatter(locales2, options);
28733
28826
  const value = /* @__PURE__ */ Object.create(null);
28734
- states9.set(value, { native, options: numberFormatterOptions2(native) });
28827
+ states10.set(value, { native, options: numberFormatterOptions2(native) });
28735
28828
  return value;
28736
28829
  }
28737
28830
  function isSandboxNumberFormat(value) {
28738
- return typeof value === "object" && value !== null && states9.has(value);
28831
+ return typeof value === "object" && value !== null && states10.has(value);
28739
28832
  }
28740
28833
  function numberFormatState(value) {
28741
28834
  if (!isSandboxNumberFormat(value)) throw new TypeError("Intl.NumberFormat requires a NumberFormat receiver.");
28742
- return states9.get(value);
28835
+ return states10.get(value);
28743
28836
  }
28744
28837
  async function numberFormatValue(value, budget, context) {
28745
28838
  const primitive = typeof value === "object" && value !== null ? await objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number") : value;
@@ -28756,28 +28849,28 @@ function formatNumberValue(receiver, method, values) {
28756
28849
 
28757
28850
  // packages/safe-js/src/interp/intl-datetimeformat.ts
28758
28851
  var NativeDateTimeFormat = Intl.DateTimeFormat;
28759
- var resolvedOptions5 = NativeDateTimeFormat.prototype.resolvedOptions;
28852
+ var resolvedOptions6 = NativeDateTimeFormat.prototype.resolvedOptions;
28760
28853
  var format3 = Object.getOwnPropertyDescriptor(NativeDateTimeFormat.prototype, "format").get;
28761
28854
  var methods = {
28762
28855
  formatToParts: NativeDateTimeFormat.prototype.formatToParts,
28763
28856
  formatRange: NativeDateTimeFormat.prototype.formatRange,
28764
28857
  formatRangeToParts: NativeDateTimeFormat.prototype.formatRangeToParts
28765
28858
  };
28766
- var states10 = /* @__PURE__ */ new WeakMap();
28859
+ var states11 = /* @__PURE__ */ new WeakMap();
28767
28860
  function createSandboxDateTimeFormat(locales2, options, restoring = false) {
28768
28861
  const input = { ...options };
28769
28862
  if (restoring) delete input.hour12;
28770
28863
  const native = new NativeDateTimeFormat(locales2, input);
28771
28864
  const value = /* @__PURE__ */ Object.create(null);
28772
- states10.set(value, { native, options: { ...Reflect.apply(resolvedOptions5, native, []) } });
28865
+ states11.set(value, { native, options: { ...Reflect.apply(resolvedOptions6, native, []) } });
28773
28866
  return value;
28774
28867
  }
28775
28868
  function isSandboxDateTimeFormat(value) {
28776
- return typeof value === "object" && value !== null && states10.has(value);
28869
+ return typeof value === "object" && value !== null && states11.has(value);
28777
28870
  }
28778
28871
  function dateTimeFormatState(value) {
28779
28872
  if (!isSandboxDateTimeFormat(value)) throw new TypeError("Intl.DateTimeFormat requires a DateTimeFormat receiver.");
28780
- return states10.get(value);
28873
+ return states11.get(value);
28781
28874
  }
28782
28875
  function formatDateTimeValue(receiver, method, values) {
28783
28876
  const { native } = dateTimeFormatState(receiver);
@@ -29124,8 +29217,23 @@ function captureGuestHeapNode(value, encode) {
29124
29217
  }
29125
29218
  if (isSandboxLocale(value)) return { kind: "guest-locale", tag: localeTag(value), state: captureObjectState(value, encode) };
29126
29219
  if (isSandboxListFormat(value)) return { kind: "guest-listformat", options: { ...listFormatState(value).options }, state: captureObjectState(value, encode) };
29220
+ if (isSandboxSegmenter(value)) return { kind: "guest-segmenter", options: { ...segmenterState(value).options }, state: captureObjectState(value, encode) };
29221
+ if (isSandboxSegments(value)) {
29222
+ const state2 = segmentState(value);
29223
+ return {
29224
+ kind: "guest-segments",
29225
+ segmenter: encode(state2.segmenter),
29226
+ input: state2.input,
29227
+ ...state2.index === void 0 ? {} : { index: state2.index },
29228
+ state: captureObjectState(value, encode)
29229
+ };
29230
+ }
29127
29231
  if (isSandboxRelativeTimeFormat(value)) return { kind: "guest-relativetimeformat", options: { ...relativeTimeFormatState(value).options }, state: captureObjectState(value, encode) };
29128
29232
  if (isSandboxDisplayNames(value)) return { kind: "guest-displaynames", options: { ...displayNamesState(value).options }, state: captureObjectState(value, encode) };
29233
+ if (isSandboxPluralRules(value)) {
29234
+ const options = pluralRulesState(value).options;
29235
+ return { kind: "guest-pluralrules", options: { ...options, pluralCategories: [...options.pluralCategories] }, state: captureObjectState(value, encode) };
29236
+ }
29129
29237
  if (isSandboxDateTimeFormat(value)) {
29130
29238
  const { options, format: format4 } = dateTimeFormatState(value);
29131
29239
  return { kind: "guest-datetimeformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
@@ -34085,6 +34193,252 @@ function createDateTimeFormatConstructor(budget, now) {
34085
34193
  return constructor;
34086
34194
  }
34087
34195
 
34196
+ // packages/safe-js/src/interp/globals/intl-pluralrules.ts
34197
+ var supportedLocalesOf8 = Intl.PluralRules.supportedLocalesOf;
34198
+ var optionTypes5 = [
34199
+ ["localeMatcher", ["lookup", "best fit"]],
34200
+ ["type", ["cardinal", "ordinal"]]
34201
+ ];
34202
+ function createPluralRulesConstructor(budget) {
34203
+ const prototype = createIntrinsicObject();
34204
+ const constructor = createSandboxClosure({
34205
+ guest: true,
34206
+ sandbox: true,
34207
+ name: "PluralRules",
34208
+ length: 0,
34209
+ call: () => {
34210
+ throw new TypeError("Constructor PluralRules requires 'new'.");
34211
+ },
34212
+ construct: async ([input, options], context) => {
34213
+ const target = context?.newTarget;
34214
+ 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);
34215
+ let locales2 = [];
34216
+ const converted = /* @__PURE__ */ Object.create(null);
34217
+ const release = retainValues(budget, () => [selected, locales2, converted]);
34218
+ try {
34219
+ locales2 = await canonicalizeGuestLocales(input, budget, context);
34220
+ const source = intlOptionsObject(options, budget);
34221
+ for (const [key, type] of optionTypes5) {
34222
+ const raw = await readIntlProperty(source, key, budget, context);
34223
+ if (raw !== void 0) converted[key] = await convertIntlOption(raw, key, type, budget, context);
34224
+ }
34225
+ Object.assign(converted, await readIntlDigitOptions(source, { minimum: 0, maximum: 3, notation: "standard" }, budget, context));
34226
+ const value = createSandboxPluralRules(locales2, converted);
34227
+ setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
34228
+ return allocateProducedSandboxValue(value, budget);
34229
+ } finally {
34230
+ release();
34231
+ }
34232
+ }
34233
+ });
34234
+ const properties = materializeFunctionProperties(constructor);
34235
+ Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
34236
+ Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
34237
+ guest: true,
34238
+ sandbox: true,
34239
+ name: "supportedLocalesOf",
34240
+ length: 1,
34241
+ call: async ([input, options], context) => {
34242
+ const locales2 = await canonicalizeGuestLocales(input, budget, context);
34243
+ const release = retainValues(budget, () => [locales2]);
34244
+ try {
34245
+ const source = intlOptionsObject(options, budget);
34246
+ const raw = await readIntlProperty(source, "localeMatcher", budget, context);
34247
+ const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
34248
+ return allocateProducedSandboxValue(supportedLocalesOf8(locales2, { localeMatcher: matcher }), budget);
34249
+ } finally {
34250
+ release();
34251
+ }
34252
+ }
34253
+ }), writable: true, configurable: true });
34254
+ Object.defineProperties(prototype, {
34255
+ constructor: { value: constructor, writable: true, configurable: true },
34256
+ [Symbol.toStringTag]: { value: "Intl.PluralRules", configurable: true },
34257
+ resolvedOptions: { value: createSandboxClosure({
34258
+ guest: true,
34259
+ sandbox: true,
34260
+ name: "resolvedOptions",
34261
+ length: 0,
34262
+ call: (_args, context) => {
34263
+ const options = pluralRulesState(context?.thisValue).options;
34264
+ return allocateProducedSandboxValue({ ...options, pluralCategories: [...options.pluralCategories] }, budget);
34265
+ }
34266
+ }), writable: true, configurable: true }
34267
+ });
34268
+ for (const method of ["select", "selectRange"]) {
34269
+ const range = method === "selectRange";
34270
+ Object.defineProperty(prototype, method, { value: createSandboxClosure({
34271
+ guest: true,
34272
+ sandbox: true,
34273
+ name: method,
34274
+ length: range ? 2 : 1,
34275
+ call: async ([first, second], context) => {
34276
+ const receiver = context?.thisValue;
34277
+ pluralRulesState(receiver);
34278
+ if (range && (first === void 0 || second === void 0)) throw new TypeError("PluralRules range requires both values.");
34279
+ const inputs = [];
34280
+ const release = retainValues(budget, () => [receiver, first, second, inputs]);
34281
+ try {
34282
+ inputs.push(await numberFormatValue(first, budget, context));
34283
+ if (range) inputs.push(await numberFormatValue(second, budget, context));
34284
+ return allocateProducedSandboxValue(selectPlural2(receiver, inputs), budget);
34285
+ } finally {
34286
+ release();
34287
+ }
34288
+ }
34289
+ }), writable: true, configurable: true });
34290
+ }
34291
+ return constructor;
34292
+ }
34293
+
34294
+ // packages/safe-js/src/interp/globals/intl-segmenter.ts
34295
+ var supportedLocalesOf9 = Intl.Segmenter.supportedLocalesOf;
34296
+ var optionTypes6 = [
34297
+ ["localeMatcher", ["lookup", "best fit"]],
34298
+ ["granularity", ["grapheme", "word", "sentence"]]
34299
+ ];
34300
+ function createSegmenterConstructor(budget) {
34301
+ const prototype = createIntrinsicObject();
34302
+ const segmentsPrototype = createIntrinsicObject();
34303
+ const iteratorPrototype = createIntrinsicObject();
34304
+ setSandboxPrototype(iteratorPrototype, resolveIntrinsicIdentity(budget, '["%IteratorPrototype%"]'));
34305
+ const constructor = createSandboxClosure({
34306
+ guest: true,
34307
+ sandbox: true,
34308
+ name: "Segmenter",
34309
+ length: 0,
34310
+ call: () => {
34311
+ throw new TypeError("Constructor Segmenter requires 'new'.");
34312
+ },
34313
+ construct: async ([input, options], context) => {
34314
+ const target = context?.newTarget;
34315
+ 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);
34316
+ let locales2 = [];
34317
+ const converted = /* @__PURE__ */ Object.create(null);
34318
+ const release = retainValues(budget, () => [selected, locales2, converted]);
34319
+ try {
34320
+ locales2 = await canonicalizeGuestLocales(input, budget, context);
34321
+ const source = intlOptionsObject(options, budget);
34322
+ for (const [key, type] of optionTypes6) {
34323
+ const raw = await readIntlProperty(source, key, budget, context);
34324
+ if (raw !== void 0) converted[key] = await convertIntlOption(raw, key, type, budget, context);
34325
+ }
34326
+ const value = createSandboxSegmenter(locales2, converted);
34327
+ setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
34328
+ return allocateProducedSandboxValue(value, budget);
34329
+ } finally {
34330
+ release();
34331
+ }
34332
+ }
34333
+ });
34334
+ const properties = materializeFunctionProperties(constructor);
34335
+ Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
34336
+ Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
34337
+ guest: true,
34338
+ sandbox: true,
34339
+ name: "supportedLocalesOf",
34340
+ length: 1,
34341
+ call: async ([input, options], context) => {
34342
+ const locales2 = await canonicalizeGuestLocales(input, budget, context);
34343
+ const release = retainValues(budget, () => [locales2]);
34344
+ try {
34345
+ const source = intlOptionsObject(options, budget);
34346
+ const raw = await readIntlProperty(source, "localeMatcher", budget, context);
34347
+ const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
34348
+ return allocateProducedSandboxValue(supportedLocalesOf9(locales2, { localeMatcher: matcher }), budget);
34349
+ } finally {
34350
+ release();
34351
+ }
34352
+ }
34353
+ }), writable: true, configurable: true });
34354
+ Object.defineProperties(prototype, {
34355
+ constructor: { value: constructor, writable: true, configurable: true },
34356
+ [Symbol.toStringTag]: { value: "Intl.Segmenter", configurable: true },
34357
+ resolvedOptions: { value: createSandboxClosure({
34358
+ guest: true,
34359
+ sandbox: true,
34360
+ name: "resolvedOptions",
34361
+ length: 0,
34362
+ call: (_args, context) => allocateProducedSandboxValue({ ...segmenterState(context?.thisValue).options }, budget)
34363
+ }), writable: true, configurable: true },
34364
+ segment: { value: createSandboxClosure({
34365
+ guest: true,
34366
+ sandbox: true,
34367
+ name: "segment",
34368
+ length: 1,
34369
+ call: async ([input], context) => {
34370
+ const receiver = context?.thisValue;
34371
+ segmenterState(receiver);
34372
+ const release = retainValues(budget, () => [receiver, input]);
34373
+ try {
34374
+ const text = await sandboxString(input, budget, context);
34375
+ budget.visitNode(text.length);
34376
+ const value = createSandboxSegments({ segmenter: receiver, input: text });
34377
+ setSandboxPrototype(value, segmentsPrototype, budget);
34378
+ return allocateProducedSandboxValue(value, budget);
34379
+ } finally {
34380
+ release();
34381
+ }
34382
+ }
34383
+ }), writable: true, configurable: true }
34384
+ });
34385
+ const containing = createSandboxClosure({
34386
+ guest: true,
34387
+ sandbox: true,
34388
+ name: "containing",
34389
+ length: 1,
34390
+ call: async ([input], context) => {
34391
+ const receiver = context?.thisValue;
34392
+ segmentState(receiver, false);
34393
+ const release = retainValues(budget, () => [receiver, input]);
34394
+ try {
34395
+ const number = await sandboxNumber(input, budget, context);
34396
+ const index = Number.isNaN(number) ? 0 : Math.trunc(number);
34397
+ return allocateProducedSandboxValue(containingSegment(receiver, index, false, budget), budget);
34398
+ } finally {
34399
+ release();
34400
+ }
34401
+ }
34402
+ });
34403
+ const iterate = createSandboxClosure({
34404
+ guest: true,
34405
+ sandbox: true,
34406
+ name: "[Symbol.iterator]",
34407
+ length: 0,
34408
+ call: (_args, context) => {
34409
+ const state = segmentState(context?.thisValue, false);
34410
+ budget.visitNode(state.input.length);
34411
+ const value = createSandboxSegments({ segmenter: state.segmenter, input: state.input, index: 0 });
34412
+ setSandboxPrototype(value, iteratorPrototype, budget);
34413
+ return allocateProducedSandboxValue(value, budget);
34414
+ }
34415
+ });
34416
+ const next = createSandboxClosure({
34417
+ guest: true,
34418
+ sandbox: true,
34419
+ name: "next",
34420
+ length: 0,
34421
+ call: (_args, context) => {
34422
+ const receiver = context?.thisValue;
34423
+ const state = segmentState(receiver, true);
34424
+ const value = containingSegment(receiver, state.index, true, budget);
34425
+ return allocateProducedSandboxValue({ value, done: value === void 0 }, budget);
34426
+ }
34427
+ });
34428
+ Object.defineProperties(segmentsPrototype, {
34429
+ containing: { value: containing, writable: true, configurable: true },
34430
+ [Symbol.iterator]: { value: iterate, writable: true, configurable: true }
34431
+ });
34432
+ Object.defineProperties(iteratorPrototype, {
34433
+ next: { value: next, writable: true, configurable: true },
34434
+ [Symbol.toStringTag]: { value: "Segmenter String Iterator", configurable: true }
34435
+ });
34436
+ registerBuiltinIdentities(budget, { "%IntlSegmentsPrototype%": segmentsPrototype, "%IntlSegmentIteratorPrototype%": iteratorPrototype });
34437
+ for (const closure of [containing, iterate, next]) registerIntrinsicFunction(budget, closure);
34438
+ for (const value of [segmentsPrototype, iteratorPrototype]) registerIntrinsicObject(budget, value);
34439
+ return constructor;
34440
+ }
34441
+
34088
34442
  // packages/safe-js/src/interp/globals/intl.ts
34089
34443
  var supportedValuesOf = Intl.supportedValuesOf;
34090
34444
  function createIntlGlobal(budget, now) {
@@ -34104,6 +34458,8 @@ function createIntlGlobal(budget, now) {
34104
34458
  const relativeTimeFormat = createRelativeTimeFormatConstructor(budget);
34105
34459
  const displayNames = createDisplayNamesConstructor(budget);
34106
34460
  const dateTimeFormat = createDateTimeFormatConstructor(budget, now);
34461
+ const pluralRules = createPluralRulesConstructor(budget);
34462
+ const segmenter = createSegmenterConstructor(budget);
34107
34463
  Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
34108
34464
  Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
34109
34465
  Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
@@ -34111,13 +34467,15 @@ function createIntlGlobal(budget, now) {
34111
34467
  Object.defineProperty(intl, "RelativeTimeFormat", { value: relativeTimeFormat, writable: true, configurable: true });
34112
34468
  Object.defineProperty(intl, "DisplayNames", { value: displayNames, writable: true, configurable: true });
34113
34469
  Object.defineProperty(intl, "DateTimeFormat", { value: dateTimeFormat, writable: true, configurable: true });
34470
+ Object.defineProperty(intl, "PluralRules", { value: pluralRules, writable: true, configurable: true });
34471
+ Object.defineProperty(intl, "Segmenter", { value: segmenter, writable: true, configurable: true });
34114
34472
  for (const [name, call] of Object.entries(methods3)) {
34115
34473
  const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
34116
34474
  Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
34117
34475
  }
34118
34476
  Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
34119
34477
  registerBuiltinIdentities(budget, { Intl: intl });
34120
- for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat]) {
34478
+ for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat, pluralRules, segmenter]) {
34121
34479
  const prototype = constructor.properties.prototype;
34122
34480
  for (const owner of [prototype, constructor.properties])
34123
34481
  for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
@@ -34235,7 +34593,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34235
34593
  createRawJson(node.text);
34236
34594
  return true;
34237
34595
  }
34238
- if (!["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-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;
34596
+ 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;
34239
34597
  const reference = (value, kinds) => {
34240
34598
  const ref = record2(value);
34241
34599
  fields(ref, ["kind", "id"]);
@@ -34543,6 +34901,44 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
34543
34901
  const restored = listFormatState(createSandboxListFormat(options.locale, options)).options;
34544
34902
  if (names.some((key) => options[key] !== restored[key])) throw new TypeError("Invalid resolved ListFormat options.");
34545
34903
  state(node.state);
34904
+ } else if (node.kind === "guest-segmenter") {
34905
+ fields(node, ["kind", "options", "state"]);
34906
+ const options = record2(node.options);
34907
+ fields(options, ["locale", "granularity"]);
34908
+ if (typeof options.locale !== "string" || typeof options.granularity !== "string") throw new TypeError("Invalid Segmenter options.");
34909
+ const restored = segmenterState(createSandboxSegmenter(options.locale, options)).options;
34910
+ if (options.locale !== restored.locale || options.granularity !== restored.granularity) throw new TypeError("Invalid resolved Segmenter options.");
34911
+ state(node.state);
34912
+ } else if (node.kind === "guest-segments") {
34913
+ fields(node, ["kind", "segmenter", "input", "state"], ["index"]);
34914
+ const segmenter = reference(node.segmenter, ["guest-segmenter"]);
34915
+ if (typeof node.input !== "string") throw new TypeError("Invalid segments input.");
34916
+ if (node.index !== void 0) {
34917
+ if (!Number.isSafeInteger(node.index) || node.index < 0 || node.index > node.input.length)
34918
+ throw new TypeError("Invalid segment iterator index.");
34919
+ const options = record2(segmenter.options);
34920
+ const owner = createSandboxSegmenter(options.locale, options);
34921
+ const value = createSandboxSegments({ segmenter: owner, input: node.input });
34922
+ if (node.index < node.input.length && segmentState(value).native.containing(node.index)?.index !== node.index)
34923
+ throw new TypeError("Invalid segment iterator boundary.");
34924
+ }
34925
+ state(node.state);
34926
+ } else if (node.kind === "guest-pluralrules") {
34927
+ fields(node, ["kind", "options", "state"]);
34928
+ const options = record2(node.options);
34929
+ fields(
34930
+ options,
34931
+ ["locale", "type", "minimumIntegerDigits", "pluralCategories", "roundingIncrement", "roundingMode", "roundingPriority", "trailingZeroDisplay"],
34932
+ ["minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"]
34933
+ );
34934
+ if (typeof options.locale !== "string" || !Array.isArray(options.pluralCategories) || options.pluralCategories.some((value) => typeof value !== "string") || Object.entries(options).some(([key, value]) => key !== "pluralCategories" && typeof value !== "string" && typeof value !== "number"))
34935
+ throw new TypeError("Invalid PluralRules option type.");
34936
+ const restored = pluralRulesState(createSandboxPluralRules(options.locale, options)).options;
34937
+ if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => {
34938
+ const value = restored[key];
34939
+ return Array.isArray(value) ? options[key].length !== value.length || value.some((item, index) => options[key][index] !== item) : options[key] !== value;
34940
+ })) throw new TypeError("Invalid resolved PluralRules options.");
34941
+ state(node.state);
34546
34942
  } else if (node.kind === "guest-displaynames") {
34547
34943
  fields(node, ["kind", "options", "state"]);
34548
34944
  const options = record2(node.options);
@@ -38112,7 +38508,7 @@ var structuredCloneErrorNames = ["Error", "EvalError", "RangeError", "ReferenceE
38112
38508
  function* cloneStructuredGraph(value, state, budget, depth = 0) {
38113
38509
  assertSandboxDataDepth(depth);
38114
38510
  budget.visitNode();
38115
- if (typeof value === "symbol" || isSandboxModuleNamespace(value) || isSandboxClosure(value) || isSandboxPromise(value) || isSandboxGenerator(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxArrayIterator(value) || isSandboxStringIterator(value) || isSandboxArguments(value))
38511
+ 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))
38116
38512
  throw new DOMException("Value cannot be structured cloned.", "DataCloneError");
38117
38513
  if (typeof value !== "object" || value === null) return allocateProducedSandboxValue(value, budget);
38118
38514
  if (iteratorHelperStates.has(value) || iteratorWrapperStates.has(value))
@@ -38319,6 +38715,7 @@ function measureSandboxData(values, options = {}) {
38319
38715
  if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
38320
38716
  if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
38321
38717
  if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
38718
+ if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
38322
38719
  if (isSandboxNumberFormat(value)) {
38323
38720
  const state = numberFormatState(value);
38324
38721
  visit(state.options, depth + 1);
@@ -38386,6 +38783,12 @@ function measureSandboxData(values, options = {}) {
38386
38783
  }
38387
38784
  if (isSandboxArrayIterator(value)) visit(arrayIteratorState(value).source, depth + 1);
38388
38785
  if (isSandboxStringIterator(value)) visit(stringIteratorState(value).input, depth + 1);
38786
+ if (isSandboxSegmenter(value)) visit(segmenterState(value).options, depth + 1);
38787
+ if (isSandboxSegments(value)) {
38788
+ const state = segmentState(value);
38789
+ visit(state.segmenter, depth + 1);
38790
+ visit(state.input, depth + 1);
38791
+ }
38389
38792
  if (isSandboxRegExpIterator(value)) {
38390
38793
  const state = regexpIteratorState(value);
38391
38794
  visit(state.matcher, depth + 1);
@@ -56309,4 +56712,4 @@ The above copyright notice and this permission notice shall be included in all c
56309
56712
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56310
56713
 
56311
56714
  */
56312
- //# sourceMappingURL=chunk-2PVMLKJL.js.map
56715
+ //# sourceMappingURL=chunk-N45AVH5W.js.map