@formatjs/intl-durationformat 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -1
- package/index.js +493 -198
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/polyfill-force.js +509 -204
- package/polyfill-force.js.map +1 -1
- package/polyfill.js +510 -205
- package/polyfill.js.map +1 -1
- package/should-polyfill.js +1 -1
- package/should-polyfill.js.map +1 -1
package/polyfill-force.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BigDecimal
|
|
1
|
+
import { FilterLocales, ResolveLocale } from "@formatjs/intl-localematcher";
|
|
2
|
+
import { BigDecimal } from "@formatjs/bigdecimal";
|
|
3
3
|
// node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
|
|
4
4
|
const numberingSystemNames = [
|
|
5
5
|
"adlm",
|
|
@@ -101,79 +101,111 @@ const numberingSystemNames = [
|
|
|
101
101
|
"wcho"
|
|
102
102
|
];
|
|
103
103
|
// packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
|
|
104
|
+
const typeApply = Reflect.apply;
|
|
105
|
+
const charCodeAt = String.prototype.charCodeAt;
|
|
104
106
|
/** Tests the Unicode locale identifier `type` grammar, not locale support. */
|
|
105
107
|
function IsUnicodeLocaleIdentifierType(value) {
|
|
106
|
-
|
|
108
|
+
let length = 0;
|
|
109
|
+
for (let index = 0; index < value.length; index++) {
|
|
110
|
+
const code = typeApply(charCodeAt, value, [index]);
|
|
111
|
+
if (code === 45) {
|
|
112
|
+
if (length < 3) return false;
|
|
113
|
+
length = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const letter = code | 32;
|
|
117
|
+
if (!(letter >= 97 && letter <= 122) && !(code >= 48 && code <= 57)) return false;
|
|
118
|
+
if (++length > 8) return false;
|
|
119
|
+
}
|
|
120
|
+
return length >= 3;
|
|
107
121
|
}
|
|
108
|
-
// packages/ecma262-abstract/
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
// packages/ecma262-abstract/intrinsics.js
|
|
123
|
+
const floor = Math.floor;
|
|
124
|
+
const numberFrom = Number;
|
|
125
|
+
const bigIntFrom = BigInt;
|
|
126
|
+
const objectFrom = Object;
|
|
127
|
+
const objectCreate = Object.create;
|
|
128
|
+
function createFromConstructor(newTarget, defaultPrototype) {
|
|
129
|
+
const prototype = newTarget.prototype;
|
|
130
|
+
return objectCreate(objectFrom(prototype) === prototype ? prototype : defaultPrototype);
|
|
111
131
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
const mathAbs = Math.abs;
|
|
133
|
+
const numberIsInteger = Number.isInteger;
|
|
134
|
+
const numberIsFinite = Number.isFinite;
|
|
135
|
+
Number.isSafeInteger;
|
|
136
|
+
const ErrorConstructor = Error;
|
|
137
|
+
const TypeErrorConstructor$1 = TypeError;
|
|
138
|
+
const RangeErrorConstructor = RangeError;
|
|
139
|
+
const arrayApply = Reflect.apply;
|
|
140
|
+
Array.prototype.every;
|
|
141
|
+
const some = Array.prototype.some;
|
|
142
|
+
function arraySome(values, predicate) {
|
|
143
|
+
return arrayApply(some, values, [predicate]);
|
|
122
144
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
Array.prototype.includes;
|
|
146
|
+
Array.prototype.indexOf;
|
|
147
|
+
const defineProperty$2 = Object.defineProperty;
|
|
148
|
+
function setDataProperty(target, key, value) {
|
|
149
|
+
defineProperty$2(target, key, {
|
|
150
|
+
__proto__: null,
|
|
151
|
+
value,
|
|
152
|
+
writable: true,
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true
|
|
155
|
+
});
|
|
130
156
|
}
|
|
131
157
|
// packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
158
|
+
let canonicalIntl = globalThis.Intl;
|
|
159
|
+
const canonicalDescriptor = Object.getOwnPropertyDescriptor;
|
|
160
|
+
const canonicalApply = Reflect.apply;
|
|
161
|
+
const providerKey = Symbol.for("@formatjs/intlCanonicalizeLocaleList");
|
|
162
|
+
function ownCanonicalProvider() {
|
|
163
|
+
const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales");
|
|
164
|
+
return (descriptor && canonicalDescriptor(descriptor, "value"))?.value;
|
|
165
|
+
}
|
|
166
|
+
let canonicalProvider = ownCanonicalProvider();
|
|
167
|
+
function registeredCanonicalProvider() {
|
|
168
|
+
try {
|
|
169
|
+
const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, providerKey);
|
|
170
|
+
return descriptor && canonicalDescriptor(descriptor, "value")?.value;
|
|
171
|
+
} catch {}
|
|
172
|
+
}
|
|
136
173
|
function CanonicalizeLocaleList(locales) {
|
|
137
|
-
|
|
174
|
+
if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl;
|
|
175
|
+
const registered = registeredCanonicalProvider();
|
|
176
|
+
if (typeof registered === "function") return canonicalApply(registered, canonicalIntl, [locales]);
|
|
177
|
+
if (typeof canonicalProvider !== "function") canonicalProvider = ownCanonicalProvider();
|
|
178
|
+
return canonicalApply(canonicalProvider, canonicalIntl, [locales]);
|
|
138
179
|
}
|
|
139
180
|
// packages/ecma402-abstract/DefaultNumberOption.js
|
|
140
|
-
/**
|
|
141
|
-
* ECMA-402 §9.2.13 DefaultNumberOption, step 2.
|
|
142
|
-
* https://tc39.es/ecma402/#sec-defaultnumberoption
|
|
143
|
-
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
|
|
144
|
-
* @param val
|
|
145
|
-
* @param min
|
|
146
|
-
* @param max
|
|
147
|
-
* @param fallback
|
|
148
|
-
*/
|
|
149
181
|
function DefaultNumberOption(inputVal, min, max, fallback) {
|
|
150
182
|
if (inputVal === void 0) return fallback;
|
|
151
183
|
const val = +inputVal;
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
184
|
+
if (!numberIsFinite(val) || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`);
|
|
185
|
+
return val === 0 ? 0 : floor(val);
|
|
154
186
|
}
|
|
155
187
|
// packages/ecma402-abstract/GetNumberOption.js
|
|
156
|
-
/**
|
|
157
|
-
* https://tc39.es/ecma402/#sec-getnumberoption
|
|
158
|
-
* @param options
|
|
159
|
-
* @param property
|
|
160
|
-
* @param min
|
|
161
|
-
* @param max
|
|
162
|
-
* @param fallback
|
|
163
|
-
*/
|
|
164
188
|
function GetNumberOption(options, property, minimum, maximum, fallback) {
|
|
165
189
|
const val = options[property];
|
|
166
190
|
return DefaultNumberOption(val, minimum, maximum, fallback);
|
|
167
191
|
}
|
|
192
|
+
// packages/ecma262-abstract/IsObject.js
|
|
193
|
+
function IsObject(value) {
|
|
194
|
+
return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
|
|
195
|
+
}
|
|
168
196
|
// packages/ecma262-abstract/ToString.js
|
|
197
|
+
const StringConstructor = String;
|
|
198
|
+
const TypeErrorConstructor = TypeError;
|
|
169
199
|
/**
|
|
170
200
|
* https://tc39.es/ecma262/#sec-tostring
|
|
171
201
|
*/
|
|
172
202
|
function ToString(o) {
|
|
173
|
-
if (typeof o === "symbol") throw
|
|
174
|
-
return
|
|
203
|
+
if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
|
|
204
|
+
return StringConstructor(o);
|
|
175
205
|
}
|
|
176
206
|
// packages/ecma402-abstract/GetOption.js
|
|
207
|
+
const optionApply = Reflect.apply;
|
|
208
|
+
const optionJoin = Array.prototype.join;
|
|
177
209
|
/**
|
|
178
210
|
* https://tc39.es/ecma402/#sec-getoption
|
|
179
211
|
* @param opts
|
|
@@ -183,34 +215,62 @@ function ToString(o) {
|
|
|
183
215
|
* @param fallback
|
|
184
216
|
*/
|
|
185
217
|
function GetOption(opts, prop, type, values, fallback) {
|
|
186
|
-
if (opts
|
|
218
|
+
if (!IsObject(opts)) throw new TypeErrorConstructor$1("Options must be an object");
|
|
187
219
|
let value = opts[prop];
|
|
188
220
|
if (value !== void 0) {
|
|
189
|
-
if (type !== "boolean" && type !== "string") throw new
|
|
190
|
-
if (type === "boolean") value =
|
|
221
|
+
if (type !== "boolean" && type !== "string") throw new TypeErrorConstructor$1("invalid type");
|
|
222
|
+
if (type === "boolean") value = !!value;
|
|
191
223
|
if (type === "string") value = ToString(value);
|
|
192
|
-
if (values
|
|
224
|
+
if (values?.length && !arraySome(values, (val) => val === value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`);
|
|
193
225
|
return value;
|
|
194
226
|
}
|
|
195
227
|
return fallback;
|
|
196
228
|
}
|
|
197
|
-
// packages/ecma402-abstract/
|
|
229
|
+
// packages/ecma402-abstract/GetOptionsObject.js
|
|
230
|
+
const createObject$2 = Object.create;
|
|
198
231
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* @param requestedLocales
|
|
232
|
+
* ECMA-262 §7.3.36 GetOptionsObject, steps 1–3.
|
|
233
|
+
* https://tc39.es/ecma262/#sec-getoptionsobject
|
|
202
234
|
* @param options
|
|
235
|
+
* @returns
|
|
203
236
|
*/
|
|
237
|
+
function GetOptionsObject(options) {
|
|
238
|
+
if (options === void 0) return createObject$2(null);
|
|
239
|
+
if (IsObject(options)) return options;
|
|
240
|
+
throw new TypeErrorConstructor$1("Options must be an object");
|
|
241
|
+
}
|
|
242
|
+
// packages/ecma262-abstract/ToObject.js
|
|
243
|
+
/**
|
|
244
|
+
* https://tc39.es/ecma262/#sec-toobject
|
|
245
|
+
*/
|
|
246
|
+
function ToObject(arg) {
|
|
247
|
+
if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
|
|
248
|
+
return objectFrom(arg);
|
|
249
|
+
}
|
|
250
|
+
// packages/ecma402-abstract/CoerceOptionsToObject.js
|
|
251
|
+
const createObject$1 = Object.create;
|
|
252
|
+
/**
|
|
253
|
+
* https://tc39.es/ecma402/#sec-coerceoptionstoobject
|
|
254
|
+
* @param options
|
|
255
|
+
* @returns
|
|
256
|
+
*/
|
|
257
|
+
function CoerceOptionsToObject(options) {
|
|
258
|
+
if (options === void 0) return createObject$1(null);
|
|
259
|
+
return ToObject(options);
|
|
260
|
+
}
|
|
261
|
+
// packages/ecma402-abstract/SupportedLocales.js
|
|
204
262
|
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
options = ToObject(options);
|
|
208
|
-
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
209
|
-
}
|
|
210
|
-
if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
211
|
-
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
263
|
+
const matcher = GetOption(CoerceOptionsToObject(options), "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
264
|
+
return FilterLocales(availableLocales, requestedLocales, matcher, true);
|
|
212
265
|
}
|
|
213
266
|
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
267
|
+
const apply$2 = Reflect.apply;
|
|
268
|
+
const bind = Function.prototype.bind;
|
|
269
|
+
const slice = Array.prototype.slice;
|
|
270
|
+
const stringify = JSON.stringify;
|
|
271
|
+
const create = Object.create;
|
|
272
|
+
const defineProperty$1 = Object.defineProperty;
|
|
273
|
+
const setPrototypeOf = Object.setPrototypeOf;
|
|
214
274
|
function memoize(fn, options) {
|
|
215
275
|
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
216
276
|
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -226,23 +286,29 @@ function monadic(fn, cache, serializer, arg) {
|
|
|
226
286
|
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
|
227
287
|
let computedValue = cache.get(cacheKey);
|
|
228
288
|
if (typeof computedValue === "undefined") {
|
|
229
|
-
computedValue = fn
|
|
289
|
+
computedValue = apply$2(fn, this, [arg]);
|
|
230
290
|
cache.set(cacheKey, computedValue);
|
|
231
291
|
}
|
|
232
292
|
return computedValue;
|
|
233
293
|
}
|
|
234
294
|
function variadic(fn, cache, serializer) {
|
|
235
|
-
const args =
|
|
295
|
+
const args = apply$2(slice, arguments, [3]);
|
|
296
|
+
if (serializer === serializerDefault) setPrototypeOf(args, null);
|
|
236
297
|
const cacheKey = serializer(args);
|
|
237
298
|
let computedValue = cache.get(cacheKey);
|
|
238
299
|
if (typeof computedValue === "undefined") {
|
|
239
|
-
computedValue =
|
|
300
|
+
computedValue = apply$2(fn, this, args);
|
|
240
301
|
cache.set(cacheKey, computedValue);
|
|
241
302
|
}
|
|
242
303
|
return computedValue;
|
|
243
304
|
}
|
|
244
305
|
function assemble(fn, context, strategy, cache, serialize) {
|
|
245
|
-
return
|
|
306
|
+
return apply$2(bind, strategy, [
|
|
307
|
+
context,
|
|
308
|
+
fn,
|
|
309
|
+
cache,
|
|
310
|
+
serialize
|
|
311
|
+
]);
|
|
246
312
|
}
|
|
247
313
|
function strategyDefault(fn, options) {
|
|
248
314
|
const strategy = fn.length === 1 ? monadic : variadic;
|
|
@@ -255,11 +321,18 @@ function strategyMonadic(fn, options) {
|
|
|
255
321
|
return assemble(fn, this, monadic, options.cache.create(), options.serializer);
|
|
256
322
|
}
|
|
257
323
|
const serializerDefault = function() {
|
|
258
|
-
|
|
324
|
+
setPrototypeOf(arguments, null);
|
|
325
|
+
return stringify(arguments);
|
|
259
326
|
};
|
|
260
327
|
var ObjectWithoutPrototypeCache = class {
|
|
261
328
|
constructor() {
|
|
262
|
-
this
|
|
329
|
+
defineProperty$1(this, "cache", {
|
|
330
|
+
__proto__: null,
|
|
331
|
+
value: create(null),
|
|
332
|
+
writable: true,
|
|
333
|
+
enumerable: true,
|
|
334
|
+
configurable: true
|
|
335
|
+
});
|
|
263
336
|
}
|
|
264
337
|
get(key) {
|
|
265
338
|
return this.cache[key];
|
|
@@ -275,7 +348,9 @@ const strategies = {
|
|
|
275
348
|
variadic: strategyVariadic,
|
|
276
349
|
monadic: strategyMonadic
|
|
277
350
|
};
|
|
278
|
-
|
|
351
|
+
String.prototype.repeat;
|
|
352
|
+
Array.from;
|
|
353
|
+
Array.prototype.join;
|
|
279
354
|
function defineProperty(target, name, { value }) {
|
|
280
355
|
Object.defineProperty(target, name, {
|
|
281
356
|
configurable: true,
|
|
@@ -285,23 +360,130 @@ function defineProperty(target, name, { value }) {
|
|
|
285
360
|
});
|
|
286
361
|
}
|
|
287
362
|
function ensureIntl() {
|
|
288
|
-
if (typeof Intl === "undefined")
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
363
|
+
if (typeof Intl === "undefined") {
|
|
364
|
+
const intl = {};
|
|
365
|
+
if (typeof Symbol !== "undefined") Object.defineProperty(intl, Symbol.toStringTag, {
|
|
366
|
+
value: "Intl",
|
|
367
|
+
writable: false,
|
|
368
|
+
enumerable: false,
|
|
369
|
+
configurable: true
|
|
370
|
+
});
|
|
371
|
+
Object.defineProperty(globalThis, "Intl", {
|
|
372
|
+
configurable: true,
|
|
373
|
+
enumerable: false,
|
|
374
|
+
writable: true,
|
|
375
|
+
value: intl
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
if (providerIntl === void 0) providerIntl = Intl;
|
|
294
379
|
return Intl;
|
|
295
380
|
}
|
|
296
|
-
function invariant(condition, message, Err =
|
|
381
|
+
function invariant(condition, message, Err = ErrorConstructor) {
|
|
297
382
|
if (!condition) throw new Err(message);
|
|
298
383
|
}
|
|
299
|
-
|
|
300
|
-
memoize((...args) => new Intl.
|
|
301
|
-
const
|
|
384
|
+
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
385
|
+
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
386
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
387
|
+
const formatterMemoizeOptions = {
|
|
388
|
+
__proto__: null,
|
|
389
|
+
strategy: strategies.variadic
|
|
390
|
+
};
|
|
391
|
+
let providerIntl = globalThis.Intl;
|
|
392
|
+
function ownIntlProvider(name) {
|
|
393
|
+
const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
|
|
394
|
+
return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
|
|
395
|
+
}
|
|
396
|
+
let numberFormatIntrinsic = ownIntlProvider("NumberFormat");
|
|
397
|
+
let listFormatIntrinsic = ownIntlProvider("ListFormat");
|
|
398
|
+
let pluralRulesProvider = ownIntlProvider("PluralRules");
|
|
399
|
+
const formatterIntrinsicKeys = {
|
|
400
|
+
NumberFormat: Symbol.for("@formatjs/intlNumberFormat"),
|
|
401
|
+
ListFormat: Symbol.for("@formatjs/intlListFormat"),
|
|
402
|
+
PluralRules: Symbol.for("@formatjs/intlPluralRules")
|
|
403
|
+
};
|
|
404
|
+
function getNumberFormatIntrinsic() {
|
|
405
|
+
if (providerIntl === void 0) providerIntl = globalThis.Intl;
|
|
406
|
+
const registered = ownIntlProvider(formatterIntrinsicKeys.NumberFormat);
|
|
407
|
+
if (typeof registered === "function") return registered;
|
|
408
|
+
if (typeof numberFormatIntrinsic !== "function") numberFormatIntrinsic = ownIntlProvider("NumberFormat");
|
|
409
|
+
return numberFormatIntrinsic;
|
|
410
|
+
}
|
|
411
|
+
function getListFormatIntrinsic() {
|
|
412
|
+
if (providerIntl === void 0) providerIntl = globalThis.Intl;
|
|
413
|
+
const registered = ownIntlProvider(formatterIntrinsicKeys.ListFormat);
|
|
414
|
+
if (typeof registered === "function") return registered;
|
|
415
|
+
if (typeof listFormatIntrinsic !== "function") listFormatIntrinsic = ownIntlProvider("ListFormat");
|
|
416
|
+
return listFormatIntrinsic;
|
|
417
|
+
}
|
|
418
|
+
const getFormatterPrototype = Object.getPrototypeOf;
|
|
419
|
+
function formatterMethodLookup(name) {
|
|
420
|
+
const methods = /* @__PURE__ */ new WeakMap();
|
|
421
|
+
const owners = /* @__PURE__ */ new WeakMap();
|
|
422
|
+
const getMethod = methods.get.bind(methods);
|
|
423
|
+
const setMethod = methods.set.bind(methods);
|
|
424
|
+
const getOwner = owners.get.bind(owners);
|
|
425
|
+
const setOwner = owners.set.bind(owners);
|
|
426
|
+
return (Constructor) => {
|
|
427
|
+
const cached = getMethod(Constructor);
|
|
428
|
+
if (cached) return cached;
|
|
429
|
+
let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
|
|
430
|
+
while (prototype != null) {
|
|
431
|
+
const inherited = getOwner(prototype);
|
|
432
|
+
if (inherited) {
|
|
433
|
+
setMethod(Constructor, inherited);
|
|
434
|
+
return inherited;
|
|
435
|
+
}
|
|
436
|
+
const descriptor = getOwnPropertyDescriptor(prototype, name);
|
|
437
|
+
const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
|
|
438
|
+
if (value && typeof value.value === "function") {
|
|
439
|
+
const method = value.value;
|
|
440
|
+
setMethod(Constructor, method);
|
|
441
|
+
setOwner(prototype, method);
|
|
442
|
+
return method;
|
|
443
|
+
}
|
|
444
|
+
prototype = getFormatterPrototype(prototype);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const findFormatterPartsMethod = formatterMethodLookup("formatToParts");
|
|
449
|
+
const findPluralRulesSelectMethod = formatterMethodLookup("select");
|
|
450
|
+
function getFormatterPartsMethod(Constructor) {
|
|
451
|
+
const method = findFormatterPartsMethod(Constructor);
|
|
452
|
+
if (!method) throw new TypeErrorConstructor$1("Missing supplied formatter parts method");
|
|
453
|
+
return method;
|
|
454
|
+
}
|
|
455
|
+
if (typeof numberFormatIntrinsic === "function") findFormatterPartsMethod(numberFormatIntrinsic);
|
|
456
|
+
if (typeof listFormatIntrinsic === "function") findFormatterPartsMethod(listFormatIntrinsic);
|
|
457
|
+
if (typeof pluralRulesProvider === "function") findPluralRulesSelectMethod(pluralRulesProvider);
|
|
458
|
+
const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
459
|
+
const getNumberFormatMemoizer = numberFormatMemoizers.get.bind(numberFormatMemoizers);
|
|
460
|
+
const setNumberFormatMemoizer = numberFormatMemoizers.set.bind(numberFormatMemoizers);
|
|
461
|
+
const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
462
|
+
const getListFormatMemoizer = listFormatMemoizers.get.bind(listFormatMemoizers);
|
|
463
|
+
const setListFormatMemoizer = listFormatMemoizers.set.bind(listFormatMemoizers);
|
|
464
|
+
const pluralRulesMemoizers = /* @__PURE__ */ new WeakMap();
|
|
465
|
+
pluralRulesMemoizers.get.bind(pluralRulesMemoizers);
|
|
466
|
+
pluralRulesMemoizers.set.bind(pluralRulesMemoizers);
|
|
467
|
+
function createMemoizedNumberFormatForConstructor(Constructor) {
|
|
468
|
+
let factory = getNumberFormatMemoizer(Constructor);
|
|
469
|
+
if (!factory) {
|
|
470
|
+
factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
|
|
471
|
+
setNumberFormatMemoizer(Constructor, factory);
|
|
472
|
+
}
|
|
473
|
+
return factory;
|
|
474
|
+
}
|
|
475
|
+
function createMemoizedListFormatForConstructor(Constructor) {
|
|
476
|
+
let factory = getListFormatMemoizer(Constructor);
|
|
477
|
+
if (!factory) {
|
|
478
|
+
factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
|
|
479
|
+
setListFormatMemoizer(Constructor, factory);
|
|
480
|
+
}
|
|
481
|
+
return factory;
|
|
482
|
+
}
|
|
302
483
|
// packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
|
|
303
484
|
function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
|
|
304
|
-
|
|
485
|
+
const unitOptions = options;
|
|
486
|
+
let style = GetOption(unitOptions, unit, "string", stylesList, void 0);
|
|
305
487
|
let displayDefault = "always";
|
|
306
488
|
if (style === void 0) {
|
|
307
489
|
if (baseStyle === "digital") {
|
|
@@ -319,10 +501,10 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
|
|
|
319
501
|
style = "fractional";
|
|
320
502
|
displayDefault = "auto";
|
|
321
503
|
}
|
|
322
|
-
const display = GetOption(
|
|
323
|
-
if (display === "always" && style === "fractional") throw new
|
|
324
|
-
if (prevStyle === "fractional" && style !== "fractional") throw new
|
|
325
|
-
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new
|
|
504
|
+
const display = GetOption(unitOptions, `${unit}Display`, "string", ["always", "auto"], displayDefault);
|
|
505
|
+
if (display === "always" && style === "fractional") throw new RangeErrorConstructor("Fractional units cannot use always display");
|
|
506
|
+
if (prevStyle === "fractional" && style !== "fractional") throw new RangeErrorConstructor("Fractional units must be followed by fractional units");
|
|
507
|
+
if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeErrorConstructor("Can't mix numeric and non-numeric styles");
|
|
326
508
|
if (twoDigitHours && unit === "hours") style = "2-digit";
|
|
327
509
|
if ((unit === "minutes" || unit === "seconds") && (prevStyle === "numeric" || prevStyle === "2-digit")) style = "2-digit";
|
|
328
510
|
return {
|
|
@@ -405,43 +587,63 @@ const TABLE_2 = [
|
|
|
405
587
|
];
|
|
406
588
|
// packages/intl-durationformat/get_internal_slots.ts
|
|
407
589
|
const internalSlotMap = /* @__PURE__ */ new WeakMap();
|
|
590
|
+
const getSlots = internalSlotMap.get.bind(internalSlotMap);
|
|
591
|
+
const setSlots = internalSlotMap.set.bind(internalSlotMap);
|
|
592
|
+
const createSlots = Object.create;
|
|
593
|
+
function requireInternalSlots(x) {
|
|
594
|
+
const slots = getSlots(x);
|
|
595
|
+
if (!slots?.initializedDurationFormat) throw new TypeErrorConstructor$1("Incompatible Intl.DurationFormat receiver");
|
|
596
|
+
return slots;
|
|
597
|
+
}
|
|
408
598
|
function getInternalSlots(x) {
|
|
409
|
-
let internalSlots =
|
|
599
|
+
let internalSlots = getSlots(x);
|
|
410
600
|
if (!internalSlots) {
|
|
411
|
-
internalSlots =
|
|
412
|
-
|
|
601
|
+
internalSlots = createSlots(null);
|
|
602
|
+
setSlots(x, internalSlots);
|
|
413
603
|
}
|
|
414
604
|
return internalSlots;
|
|
415
605
|
}
|
|
416
606
|
// packages/intl-durationformat/abstract/PartitionDurationFormatPattern.ts
|
|
607
|
+
const apply$1 = Reflect.apply;
|
|
608
|
+
const stringListIterator = Array.prototype[Symbol.iterator];
|
|
609
|
+
const stringListIteratorNext = Object.getPrototypeOf(apply$1(stringListIterator, [], [])).next;
|
|
610
|
+
const formatterProviders = /* @__PURE__ */ new WeakMap();
|
|
611
|
+
const getFormatterProviders = formatterProviders.get.bind(formatterProviders);
|
|
612
|
+
const setFormatterProviders = formatterProviders.set.bind(formatterProviders);
|
|
613
|
+
function initializeDurationFormatProviders(df) {
|
|
614
|
+
const NumberFormat = getNumberFormatIntrinsic();
|
|
615
|
+
const ListFormat = getListFormatIntrinsic();
|
|
616
|
+
setFormatterProviders(df, {
|
|
617
|
+
numberFormat: createMemoizedNumberFormatForConstructor(NumberFormat),
|
|
618
|
+
listFormat: createMemoizedListFormatForConstructor(ListFormat),
|
|
619
|
+
numberFormatToParts: getFormatterPartsMethod(NumberFormat),
|
|
620
|
+
listFormatToParts: getFormatterPartsMethod(ListFormat)
|
|
621
|
+
});
|
|
622
|
+
}
|
|
417
623
|
function PartitionDurationFormatPattern(df, duration) {
|
|
418
624
|
const result = [];
|
|
419
625
|
let done = false;
|
|
420
626
|
let separated = false;
|
|
421
627
|
let signDisplayed = true;
|
|
422
|
-
const negative = TABLE_2
|
|
628
|
+
const negative = arraySome(TABLE_2, (row) => duration[row.valueField] < 0);
|
|
423
629
|
const internalSlots = getInternalSlots(df);
|
|
424
|
-
|
|
425
|
-
const dataLocaleData = DurationFormat.localeData[dataLocale];
|
|
426
|
-
if (!dataLocaleData) throw new TypeError("Invalid locale");
|
|
427
|
-
const numberingSystem = internalSlots.numberingSystem;
|
|
428
|
-
const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
|
|
630
|
+
const providers = getFormatterProviders(df);
|
|
429
631
|
for (let i = 0; i < TABLE_2.length && !done; i++) {
|
|
430
632
|
const row = TABLE_2[i];
|
|
431
|
-
let value = new BigDecimal(
|
|
633
|
+
let value = new BigDecimal(bigIntFrom(duration[row.valueField]));
|
|
432
634
|
const style = internalSlots[row.styleSlot];
|
|
433
635
|
const display = internalSlots[row.displaySlot];
|
|
434
636
|
const { unit, numberFormatUnit } = row;
|
|
435
|
-
const nfOpts =
|
|
637
|
+
const nfOpts = { __proto__: null };
|
|
436
638
|
if (unit === "seconds" || unit === "milliseconds" || unit === "microseconds") {
|
|
437
639
|
let nextStyle;
|
|
438
640
|
if (unit === "seconds") nextStyle = internalSlots.milliseconds;
|
|
439
641
|
else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
|
|
440
642
|
else nextStyle = internalSlots.nanoseconds;
|
|
441
|
-
if (nextStyle === "
|
|
442
|
-
if (unit === "seconds") value = value.plus(new BigDecimal(
|
|
443
|
-
else if (unit === "milliseconds") value = value.plus(new BigDecimal(
|
|
444
|
-
else value = value.plus(new BigDecimal(
|
|
643
|
+
if (nextStyle === "fractional") {
|
|
644
|
+
if (unit === "seconds") value = value.plus(new BigDecimal(bigIntFrom(duration.milliseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e6))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e9)));
|
|
645
|
+
else if (unit === "milliseconds") value = value.plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e6)));
|
|
646
|
+
else value = value.plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e3)));
|
|
445
647
|
if (internalSlots.fractionalDigits === void 0) {
|
|
446
648
|
nfOpts.maximumFractionDigits = 9;
|
|
447
649
|
nfOpts.minimumFractionDigits = 0;
|
|
@@ -467,56 +669,73 @@ function PartitionDurationFormatPattern(df, duration) {
|
|
|
467
669
|
nfOpts.unit = numberFormatUnit;
|
|
468
670
|
nfOpts.unitDisplay = style;
|
|
469
671
|
}
|
|
470
|
-
const nf =
|
|
672
|
+
const nf = providers.numberFormat(internalSlots.locale, nfOpts);
|
|
471
673
|
let list;
|
|
472
674
|
if (!separated) list = [];
|
|
473
675
|
else {
|
|
474
676
|
list = result[result.length - 1];
|
|
475
|
-
list.
|
|
677
|
+
setDataProperty(list, `${list.length}`, {
|
|
476
678
|
type: "literal",
|
|
477
|
-
value:
|
|
679
|
+
value: unit === "minutes" ? internalSlots.hourMinuteSeparator : internalSlots.minuteSecondSeparator,
|
|
680
|
+
unit: void 0
|
|
478
681
|
});
|
|
479
682
|
}
|
|
480
|
-
nf
|
|
481
|
-
|
|
683
|
+
let parts = apply$1(providers.numberFormatToParts, nf, [value.isZero() && value.isNegative() ? -0 : value]);
|
|
684
|
+
for (let index = 0; index < parts.length; index++) {
|
|
685
|
+
const { type, value } = parts[index];
|
|
686
|
+
setDataProperty(list, `${list.length}`, {
|
|
482
687
|
type,
|
|
483
688
|
value,
|
|
484
689
|
unit: numberFormatUnit
|
|
485
690
|
});
|
|
486
|
-
}
|
|
691
|
+
}
|
|
487
692
|
if (!separated) {
|
|
488
693
|
if (style === "2-digit" || style === "numeric") separated = true;
|
|
489
|
-
result.
|
|
694
|
+
setDataProperty(result, `${result.length}`, list);
|
|
490
695
|
}
|
|
491
696
|
} else separated = false;
|
|
492
697
|
}
|
|
493
|
-
const lfOpts =
|
|
698
|
+
const lfOpts = { __proto__: null };
|
|
494
699
|
lfOpts.type = "unit";
|
|
495
700
|
let listStyle = internalSlots.style;
|
|
496
701
|
if (listStyle === "digital") listStyle = "short";
|
|
497
702
|
lfOpts.style = listStyle;
|
|
498
|
-
const lf =
|
|
703
|
+
const lf = providers.listFormat(internalSlots.locale, lfOpts);
|
|
499
704
|
const strings = [];
|
|
500
|
-
for (
|
|
705
|
+
for (let index = 0; index < result.length; index++) {
|
|
706
|
+
const parts = result[index];
|
|
501
707
|
let string = "";
|
|
502
|
-
for (
|
|
503
|
-
strings.
|
|
708
|
+
for (let partIndex = 0; partIndex < parts.length; partIndex++) string += parts[partIndex].value;
|
|
709
|
+
setDataProperty(strings, `${strings.length}`, string);
|
|
504
710
|
}
|
|
505
|
-
|
|
711
|
+
setDataProperty(strings, Symbol.iterator, () => {
|
|
712
|
+
const iterator = apply$1(stringListIterator, strings, []);
|
|
713
|
+
return {
|
|
714
|
+
__proto__: null,
|
|
715
|
+
next() {
|
|
716
|
+
return apply$1(stringListIteratorNext, iterator, []);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
});
|
|
720
|
+
let formatted = apply$1(providers.listFormatToParts, lf, [strings]);
|
|
506
721
|
let resultIndex = 0;
|
|
507
722
|
let resultLength = result.length;
|
|
508
|
-
|
|
509
|
-
for (
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
type
|
|
518
|
-
|
|
519
|
-
|
|
723
|
+
const flattened = [];
|
|
724
|
+
for (let index = 0; index < formatted.length; index++) {
|
|
725
|
+
const { type, value } = formatted[index];
|
|
726
|
+
if (type === "element") {
|
|
727
|
+
invariant(resultIndex < resultLength, "Index out of bounds");
|
|
728
|
+
let parts = result[resultIndex];
|
|
729
|
+
for (let index = 0; index < parts.length; index++) setDataProperty(flattened, `${flattened.length}`, parts[index]);
|
|
730
|
+
resultIndex++;
|
|
731
|
+
} else {
|
|
732
|
+
invariant(type === "literal", "Type must be literal");
|
|
733
|
+
setDataProperty(flattened, `${flattened.length}`, {
|
|
734
|
+
type: "literal",
|
|
735
|
+
value,
|
|
736
|
+
unit: void 0
|
|
737
|
+
});
|
|
738
|
+
}
|
|
520
739
|
}
|
|
521
740
|
return flattened;
|
|
522
741
|
}
|
|
@@ -535,7 +754,8 @@ const TABLE_1 = [
|
|
|
535
754
|
];
|
|
536
755
|
// packages/ecma402-abstract/DurationFormat/DurationRecordSign.js
|
|
537
756
|
function DurationRecordSign(record) {
|
|
538
|
-
for (
|
|
757
|
+
for (let index = 0; index < TABLE_1.length; index++) {
|
|
758
|
+
const key = TABLE_1[index];
|
|
539
759
|
if (record[key] < 0) return -1;
|
|
540
760
|
if (record[key] > 0) return 1;
|
|
541
761
|
}
|
|
@@ -544,42 +764,49 @@ function DurationRecordSign(record) {
|
|
|
544
764
|
// packages/ecma402-abstract/DurationFormat/IsValidDurationRecord.js
|
|
545
765
|
function IsValidDurationRecord(record) {
|
|
546
766
|
const sign = DurationRecordSign(record);
|
|
547
|
-
for (
|
|
548
|
-
const v = record[
|
|
549
|
-
if (!
|
|
767
|
+
for (let index = 0; index < TABLE_1.length; index++) {
|
|
768
|
+
const v = record[TABLE_1[index]];
|
|
769
|
+
if (!numberIsFinite(v)) return false;
|
|
550
770
|
if (v < 0 && sign > 0) return false;
|
|
551
771
|
if (v > 0 && sign < 0) return false;
|
|
552
772
|
}
|
|
553
|
-
if ([
|
|
773
|
+
if (arraySome([
|
|
554
774
|
"years",
|
|
555
775
|
"months",
|
|
556
776
|
"weeks"
|
|
557
|
-
]
|
|
558
|
-
const billion =
|
|
559
|
-
const normalizedNanoseconds =
|
|
560
|
-
const limit =
|
|
777
|
+
], (unit) => mathAbs(record[unit]) >= 2 ** 32)) return false;
|
|
778
|
+
const billion = bigIntFrom(1e9);
|
|
779
|
+
const normalizedNanoseconds = bigIntFrom(record.days) * bigIntFrom(86400) * billion + bigIntFrom(record.hours) * bigIntFrom(3600) * billion + bigIntFrom(record.minutes) * bigIntFrom(60) * billion + bigIntFrom(record.seconds) * billion + bigIntFrom(record.milliseconds) * bigIntFrom(1e6) + bigIntFrom(record.microseconds) * bigIntFrom(1e3) + bigIntFrom(record.nanoseconds);
|
|
780
|
+
const limit = bigIntFrom(2 ** 53) * billion;
|
|
561
781
|
return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
|
|
562
782
|
}
|
|
563
783
|
// packages/ecma262-abstract/ToNumber.js
|
|
564
|
-
/**
|
|
565
|
-
* ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
|
|
566
|
-
* https://tc39.es/ecma262/#sec-tonumber
|
|
567
|
-
* https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L5183-L5191
|
|
568
|
-
*/
|
|
569
784
|
function ToNumber(arg) {
|
|
570
|
-
return
|
|
785
|
+
return +arg;
|
|
571
786
|
}
|
|
572
787
|
// packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
|
|
573
788
|
function ToIntegerIfIntegral(arg) {
|
|
574
789
|
const number = ToNumber(arg);
|
|
575
|
-
|
|
576
|
-
return number
|
|
790
|
+
if (!numberIsInteger(number)) throw new RangeErrorConstructor("Duration field is not an integer");
|
|
791
|
+
return number === 0 ? 0 : number;
|
|
577
792
|
}
|
|
578
793
|
// packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
|
|
794
|
+
const durationPropertyNames = [
|
|
795
|
+
"days",
|
|
796
|
+
"hours",
|
|
797
|
+
"microseconds",
|
|
798
|
+
"milliseconds",
|
|
799
|
+
"minutes",
|
|
800
|
+
"months",
|
|
801
|
+
"nanoseconds",
|
|
802
|
+
"seconds",
|
|
803
|
+
"weeks",
|
|
804
|
+
"years"
|
|
805
|
+
];
|
|
579
806
|
function ToDurationRecord(input) {
|
|
580
|
-
if ((
|
|
581
|
-
if (typeof input === "string") throw new
|
|
582
|
-
throw new
|
|
807
|
+
if (!IsObject(input)) {
|
|
808
|
+
if (typeof input === "string") throw new RangeErrorConstructor("Invalid duration format");
|
|
809
|
+
throw new TypeErrorConstructor$1("Invalid duration");
|
|
583
810
|
}
|
|
584
811
|
const result = {
|
|
585
812
|
years: 0,
|
|
@@ -594,26 +821,16 @@ function ToDurationRecord(input) {
|
|
|
594
821
|
nanoseconds: 0
|
|
595
822
|
};
|
|
596
823
|
let anyDefined = false;
|
|
597
|
-
for (
|
|
598
|
-
|
|
599
|
-
"hours",
|
|
600
|
-
"microseconds",
|
|
601
|
-
"milliseconds",
|
|
602
|
-
"minutes",
|
|
603
|
-
"months",
|
|
604
|
-
"nanoseconds",
|
|
605
|
-
"seconds",
|
|
606
|
-
"weeks",
|
|
607
|
-
"years"
|
|
608
|
-
]) {
|
|
824
|
+
for (let index = 0; index < durationPropertyNames.length; index++) {
|
|
825
|
+
const field = durationPropertyNames[index];
|
|
609
826
|
const value = input[field];
|
|
610
827
|
if (value !== void 0) {
|
|
611
828
|
anyDefined = true;
|
|
612
829
|
result[field] = ToIntegerIfIntegral(value);
|
|
613
830
|
}
|
|
614
831
|
}
|
|
615
|
-
if (!anyDefined) throw new
|
|
616
|
-
if (!IsValidDurationRecord(result)) throw new
|
|
832
|
+
if (!anyDefined) throw new TypeErrorConstructor$1("Invalid duration format");
|
|
833
|
+
if (!IsValidDurationRecord(result)) throw new RangeErrorConstructor("Invalid duration format");
|
|
617
834
|
return result;
|
|
618
835
|
}
|
|
619
836
|
// packages/ecma402-abstract/DurationFormat/ToTemporalDurationRecord.js
|
|
@@ -633,11 +850,11 @@ const apply = Reflect.apply;
|
|
|
633
850
|
const readers = [];
|
|
634
851
|
function registerTemporalDurationNamespace(namespace) {
|
|
635
852
|
const constructor = namespace?.Duration;
|
|
636
|
-
if (!constructor || readers
|
|
853
|
+
if (!constructor || arraySome(readers, (reader) => reader.constructor === constructor)) return;
|
|
637
854
|
const from = constructor.from, prototype = constructor.prototype;
|
|
638
855
|
if (typeof from !== "function" || prototype === null || typeof prototype !== "object" && typeof prototype !== "function") return;
|
|
639
856
|
const getters = fields.map((field) => Object.getOwnPropertyDescriptor(prototype, field)?.get);
|
|
640
|
-
if (getters
|
|
857
|
+
if (arraySome(getters, (getter) => typeof getter !== "function")) return;
|
|
641
858
|
readers.push({
|
|
642
859
|
constructor,
|
|
643
860
|
from,
|
|
@@ -651,14 +868,15 @@ function ToTemporalDurationRecord(input) {
|
|
|
651
868
|
const reader = readers[readers.length - 1];
|
|
652
869
|
input = apply(reader.from, reader.constructor, [input]);
|
|
653
870
|
}
|
|
654
|
-
if (input !== null && (typeof input === "object" || typeof input === "function")) for (
|
|
871
|
+
if (input !== null && (typeof input === "object" || typeof input === "function")) for (let index = 0; index < readers.length; index++) {
|
|
872
|
+
const reader = readers[index];
|
|
655
873
|
let years;
|
|
656
874
|
try {
|
|
657
875
|
years = apply(reader.getters[0], input, []);
|
|
658
876
|
} catch {
|
|
659
877
|
continue;
|
|
660
878
|
}
|
|
661
|
-
const record =
|
|
879
|
+
const record = { __proto__: null };
|
|
662
880
|
record.years = years;
|
|
663
881
|
for (let index = 1; index < fields.length; index++) record[fields[index]] = apply(reader.getters[index], input, []);
|
|
664
882
|
return record;
|
|
@@ -712,6 +930,7 @@ const TIME_SEPARATORS = {
|
|
|
712
930
|
"az-Cyrl": { "nu": ["latn"] },
|
|
713
931
|
"az-Latn": { "nu": ["latn"] },
|
|
714
932
|
"ba": { "nu": ["latn"] },
|
|
933
|
+
"bal": { "nu": ["latn"] },
|
|
715
934
|
"bal-Latn": { "nu": ["latn"] },
|
|
716
935
|
"bas": { "nu": ["latn"] },
|
|
717
936
|
"be": { "nu": ["latn"] },
|
|
@@ -735,6 +954,7 @@ const TIME_SEPARATORS = {
|
|
|
735
954
|
"bua": { "nu": ["latn"] },
|
|
736
955
|
"ca": { "nu": ["latn"] },
|
|
737
956
|
"ca-AD": { "nu": ["latn"] },
|
|
957
|
+
"ca-ES": { "nu": ["latn"] },
|
|
738
958
|
"ca-ES-valencia": { "nu": ["latn"] },
|
|
739
959
|
"ca-FR": { "nu": ["latn"] },
|
|
740
960
|
"ca-IT": { "nu": ["latn"] },
|
|
@@ -956,6 +1176,13 @@ const TIME_SEPARATORS = {
|
|
|
956
1176
|
"ff-Adlm-NG": { "nu": ["adlm"] },
|
|
957
1177
|
"ff-Adlm-SL": { "nu": ["adlm"] },
|
|
958
1178
|
"ff-Adlm-SN": { "nu": ["adlm"] },
|
|
1179
|
+
"ff-BF": { "nu": ["latn"] },
|
|
1180
|
+
"ff-CM": { "nu": ["latn"] },
|
|
1181
|
+
"ff-GH": { "nu": ["latn"] },
|
|
1182
|
+
"ff-GM": { "nu": ["latn"] },
|
|
1183
|
+
"ff-GN": { "nu": ["latn"] },
|
|
1184
|
+
"ff-GW": { "nu": ["latn"] },
|
|
1185
|
+
"ff-LR": { "nu": ["latn"] },
|
|
959
1186
|
"ff-Latn": { "nu": ["latn"] },
|
|
960
1187
|
"ff-Latn-BF": { "nu": ["latn"] },
|
|
961
1188
|
"ff-Latn-CM": { "nu": ["latn"] },
|
|
@@ -968,6 +1195,11 @@ const TIME_SEPARATORS = {
|
|
|
968
1195
|
"ff-Latn-NE": { "nu": ["latn"] },
|
|
969
1196
|
"ff-Latn-NG": { "nu": ["latn"] },
|
|
970
1197
|
"ff-Latn-SL": { "nu": ["latn"] },
|
|
1198
|
+
"ff-MR": { "nu": ["latn"] },
|
|
1199
|
+
"ff-NE": { "nu": ["latn"] },
|
|
1200
|
+
"ff-NG": { "nu": ["latn"] },
|
|
1201
|
+
"ff-SL": { "nu": ["latn"] },
|
|
1202
|
+
"ff-SN": { "nu": ["adlm"] },
|
|
971
1203
|
"fi": {
|
|
972
1204
|
"nu": ["latn"],
|
|
973
1205
|
"separator": { "latn": "." }
|
|
@@ -1096,9 +1328,11 @@ const TIME_SEPARATORS = {
|
|
|
1096
1328
|
"ksf": { "nu": ["latn"] },
|
|
1097
1329
|
"ksh": { "nu": ["latn"] },
|
|
1098
1330
|
"ku": { "nu": ["latn"] },
|
|
1331
|
+
"ku-IQ": { "nu": ["latn"] },
|
|
1099
1332
|
"ku-Latn": { "nu": ["latn"] },
|
|
1100
1333
|
"ku-Latn-IQ": { "nu": ["latn"] },
|
|
1101
1334
|
"ku-Latn-SY": { "nu": ["latn"] },
|
|
1335
|
+
"ku-SY": { "nu": ["latn"] },
|
|
1102
1336
|
"ku-TR": { "nu": ["latn"] },
|
|
1103
1337
|
"kw": { "nu": ["latn"] },
|
|
1104
1338
|
"kxv": { "nu": ["latn"] },
|
|
@@ -1259,6 +1493,7 @@ const TIME_SEPARATORS = {
|
|
|
1259
1493
|
"sq-MK": { "nu": ["latn"] },
|
|
1260
1494
|
"sq-XK": { "nu": ["latn"] },
|
|
1261
1495
|
"sr": { "nu": ["latn"] },
|
|
1496
|
+
"sr-BA": { "nu": ["latn"] },
|
|
1262
1497
|
"sr-Cyrl": { "nu": ["latn"] },
|
|
1263
1498
|
"sr-Cyrl-BA": { "nu": ["latn"] },
|
|
1264
1499
|
"sr-Cyrl-ME": { "nu": ["latn"] },
|
|
@@ -1267,6 +1502,8 @@ const TIME_SEPARATORS = {
|
|
|
1267
1502
|
"sr-Latn-BA": { "nu": ["latn"] },
|
|
1268
1503
|
"sr-Latn-ME": { "nu": ["latn"] },
|
|
1269
1504
|
"sr-Latn-XK": { "nu": ["latn"] },
|
|
1505
|
+
"sr-ME": { "nu": ["latn"] },
|
|
1506
|
+
"sr-XK": { "nu": ["latn"] },
|
|
1270
1507
|
"st": { "nu": ["latn"] },
|
|
1271
1508
|
"st-LS": { "nu": ["latn"] },
|
|
1272
1509
|
"su": {
|
|
@@ -1277,6 +1514,7 @@ const TIME_SEPARATORS = {
|
|
|
1277
1514
|
"nu": ["latn"],
|
|
1278
1515
|
"separator": { "latn": "." }
|
|
1279
1516
|
},
|
|
1517
|
+
"suz": { "nu": ["latn"] },
|
|
1280
1518
|
"suz-Sunu": { "nu": ["latn"] },
|
|
1281
1519
|
"sv": { "nu": ["latn"] },
|
|
1282
1520
|
"sv-AX": { "nu": ["latn"] },
|
|
@@ -1351,13 +1589,16 @@ const TIME_SEPARATORS = {
|
|
|
1351
1589
|
"yrl-CO": { "nu": ["latn"] },
|
|
1352
1590
|
"yrl-VE": { "nu": ["latn"] },
|
|
1353
1591
|
"yue": { "nu": ["latn"] },
|
|
1592
|
+
"yue-CN": { "nu": ["latn"] },
|
|
1354
1593
|
"yue-Hans": { "nu": ["latn"] },
|
|
1355
1594
|
"yue-Hant": { "nu": ["latn"] },
|
|
1356
1595
|
"yue-Hant-CN": { "nu": ["latn"] },
|
|
1357
1596
|
"yue-Hant-MO": { "nu": ["latn"] },
|
|
1597
|
+
"yue-MO": { "nu": ["latn"] },
|
|
1358
1598
|
"za": { "nu": ["latn"] },
|
|
1359
1599
|
"zgh": { "nu": ["latn"] },
|
|
1360
1600
|
"zh": { "nu": ["latn"] },
|
|
1601
|
+
"zh-HK": { "nu": ["latn"] },
|
|
1361
1602
|
"zh-Hans": { "nu": ["latn"] },
|
|
1362
1603
|
"zh-Hans-HK": { "nu": ["latn"] },
|
|
1363
1604
|
"zh-Hans-MO": { "nu": ["latn"] },
|
|
@@ -1367,25 +1608,76 @@ const TIME_SEPARATORS = {
|
|
|
1367
1608
|
"zh-Hant-HK": { "nu": ["latn"] },
|
|
1368
1609
|
"zh-Hant-MO": { "nu": ["latn"] },
|
|
1369
1610
|
"zh-Hant-MY": { "nu": ["latn"] },
|
|
1611
|
+
"zh-MO": { "nu": ["latn"] },
|
|
1612
|
+
"zh-MY": { "nu": ["latn"] },
|
|
1613
|
+
"zh-SG": { "nu": ["latn"] },
|
|
1370
1614
|
"zu": { "nu": ["latn"] }
|
|
1371
1615
|
}
|
|
1372
1616
|
};
|
|
1373
1617
|
// packages/intl-durationformat/core.ts
|
|
1618
|
+
let defaultLocale = "en";
|
|
1619
|
+
function getDefaultLocale() {
|
|
1620
|
+
return defaultLocale;
|
|
1621
|
+
}
|
|
1374
1622
|
const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
|
|
1623
|
+
const getNumberingSystems = numberingSystemsByConstructor.get.bind(numberingSystemsByConstructor);
|
|
1624
|
+
const setNumberingSystems = numberingSystemsByConstructor.set.bind(numberingSystemsByConstructor);
|
|
1625
|
+
const createObject = Object.create;
|
|
1626
|
+
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
|
1627
|
+
const providerApply = Reflect.apply;
|
|
1628
|
+
const providerDescriptor = Object.getOwnPropertyDescriptor;
|
|
1629
|
+
const providerPrototype = Object.getPrototypeOf;
|
|
1630
|
+
const resolvedMethods = /* @__PURE__ */ new WeakMap();
|
|
1631
|
+
const getResolvedMethod = resolvedMethods.get.bind(resolvedMethods);
|
|
1632
|
+
const setResolvedMethod = resolvedMethods.set.bind(resolvedMethods);
|
|
1633
|
+
function numberFormatResolvedOptions(Constructor) {
|
|
1634
|
+
let prototype = Constructor.prototype;
|
|
1635
|
+
while (prototype !== null) {
|
|
1636
|
+
const cached = getResolvedMethod(prototype);
|
|
1637
|
+
if (cached) return cached;
|
|
1638
|
+
const descriptor = providerDescriptor(prototype, "resolvedOptions");
|
|
1639
|
+
const value = descriptor && providerDescriptor(descriptor, "value");
|
|
1640
|
+
if (typeof value?.value === "function") {
|
|
1641
|
+
const method = value.value;
|
|
1642
|
+
setResolvedMethod(prototype, method);
|
|
1643
|
+
return method;
|
|
1644
|
+
}
|
|
1645
|
+
prototype = providerPrototype(prototype);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
const initialNumberFormat = getNumberFormatIntrinsic();
|
|
1649
|
+
if (typeof initialNumberFormat === "function") numberFormatResolvedOptions(initialNumberFormat);
|
|
1650
|
+
const NumberingSet = Set;
|
|
1651
|
+
const numberingAdd = Set.prototype.add;
|
|
1652
|
+
const numberingValues = Set.prototype.values;
|
|
1653
|
+
const numberingNext = providerPrototype(new NumberingSet().values()).next;
|
|
1654
|
+
function numberingUnion(first, second) {
|
|
1655
|
+
const unique = new NumberingSet();
|
|
1656
|
+
for (let index = 0; index < first.length; index++) providerApply(numberingAdd, unique, [first[index]]);
|
|
1657
|
+
for (let index = 0; index < second.length; index++) providerApply(numberingAdd, unique, [second[index]]);
|
|
1658
|
+
const iterator = providerApply(numberingValues, unique, []);
|
|
1659
|
+
const result = [];
|
|
1660
|
+
for (;;) {
|
|
1661
|
+
const next = providerApply(numberingNext, iterator, []);
|
|
1662
|
+
if (next.done) return result;
|
|
1663
|
+
setDataProperty(result, `${result.length}`, next.value);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1375
1666
|
function supportedNumberingSystems() {
|
|
1376
|
-
const NumberFormat =
|
|
1377
|
-
let systems =
|
|
1667
|
+
const NumberFormat = getNumberFormatIntrinsic();
|
|
1668
|
+
let systems = getNumberingSystems(NumberFormat);
|
|
1378
1669
|
if (!systems) {
|
|
1379
|
-
systems =
|
|
1380
|
-
|
|
1670
|
+
systems = [];
|
|
1671
|
+
const resolvedOptions = numberFormatResolvedOptions(NumberFormat);
|
|
1672
|
+
for (let index = 0; index < numberingSystemNames.length; index++) {
|
|
1673
|
+
const numberingSystem = numberingSystemNames[index];
|
|
1674
|
+
const options = createObject(null);
|
|
1381
1675
|
options.numberingSystem = numberingSystem;
|
|
1382
1676
|
try {
|
|
1383
|
-
|
|
1384
|
-
} catch {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
});
|
|
1388
|
-
if (systems.length) numberingSystemsByConstructor.set(NumberFormat, systems);
|
|
1677
|
+
if (resolvedOptions && providerApply(resolvedOptions, new NumberFormat("en", options), []).numberingSystem === numberingSystem) setDataProperty(systems, `${systems.length}`, numberingSystem);
|
|
1678
|
+
} catch {}
|
|
1679
|
+
}
|
|
1680
|
+
if (systems.length) setNumberingSystems(NumberFormat, systems);
|
|
1389
1681
|
}
|
|
1390
1682
|
return systems;
|
|
1391
1683
|
}
|
|
@@ -1540,27 +1832,33 @@ const TABLE_3 = [
|
|
|
1540
1832
|
* DurationFormat provides locale-sensitive duration formatting
|
|
1541
1833
|
* Implements the Intl.DurationFormat API from the TC39 proposal
|
|
1542
1834
|
*/
|
|
1543
|
-
var DurationFormat = class DurationFormat {
|
|
1835
|
+
var DurationFormat = class DurationFormat extends null {
|
|
1544
1836
|
static __addTemporalNamespace(namespace) {
|
|
1545
1837
|
registerTemporalDurationNamespace(namespace);
|
|
1546
1838
|
}
|
|
1547
1839
|
constructor(locales, options) {
|
|
1548
|
-
|
|
1840
|
+
const receiver = createFromConstructor(new.target, DurationFormat.prototype);
|
|
1549
1841
|
const requestedLocales = CanonicalizeLocaleList(locales);
|
|
1550
|
-
const opt =
|
|
1551
|
-
const opts =
|
|
1842
|
+
const opt = createObject(null);
|
|
1843
|
+
const opts = GetOptionsObject(options);
|
|
1552
1844
|
const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
1553
1845
|
const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
|
|
1554
|
-
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw
|
|
1846
|
+
if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeErrorConstructor(`Invalid numberingSystems: ${numberingSystem}`);
|
|
1555
1847
|
opt.nu = numberingSystem;
|
|
1556
1848
|
opt.localeMatcher = matcher;
|
|
1557
1849
|
const { localeData, availableLocales } = DurationFormat;
|
|
1558
|
-
const r = ResolveLocale(availableLocales, requestedLocales, opt, ["nu"], localeData,
|
|
1850
|
+
const r = ResolveLocale(availableLocales, requestedLocales, opt, ["nu"], localeData, getDefaultLocale, "hostDefaultWithLocaleData");
|
|
1559
1851
|
const locale = r.locale;
|
|
1560
|
-
const internalSlots = getInternalSlots(
|
|
1852
|
+
const internalSlots = getInternalSlots(receiver);
|
|
1561
1853
|
internalSlots.initializedDurationFormat = true;
|
|
1562
1854
|
internalSlots.locale = locale;
|
|
1563
1855
|
internalSlots.numberingSystem = r.nu;
|
|
1856
|
+
internalSlots.dataLocale = r.dataLocale;
|
|
1857
|
+
const digitalFormat = r.localeData?.digitalFormat;
|
|
1858
|
+
invariant(!!digitalFormat, `Invalid locale ${r.dataLocale}`);
|
|
1859
|
+
const separator = hasOwn(digitalFormat, r.nu) ? digitalFormat[r.nu] : digitalFormat.default;
|
|
1860
|
+
internalSlots.hourMinuteSeparator = separator;
|
|
1861
|
+
internalSlots.minuteSecondSeparator = separator;
|
|
1564
1862
|
const style = GetOption(opts, "style", "string", [
|
|
1565
1863
|
"long",
|
|
1566
1864
|
"short",
|
|
@@ -1568,61 +1866,61 @@ var DurationFormat = class DurationFormat {
|
|
|
1568
1866
|
"digital"
|
|
1569
1867
|
], "short");
|
|
1570
1868
|
internalSlots.style = style;
|
|
1571
|
-
internalSlots.dataLocale = r.dataLocale;
|
|
1572
1869
|
let prevStyle = "";
|
|
1573
|
-
|
|
1574
|
-
|
|
1870
|
+
const unitStyles = internalSlots;
|
|
1871
|
+
for (let index = 0; index < TABLE_3.length; index++) {
|
|
1872
|
+
const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = TABLE_3[index];
|
|
1575
1873
|
const unitOptions = GetDurationUnitOptions(unit, opts, style, valueList, digitalBase, prevStyle);
|
|
1576
|
-
|
|
1874
|
+
unitStyles[styleSlot] = unitOptions.style;
|
|
1577
1875
|
internalSlots[displaySlot] = unitOptions.display;
|
|
1578
1876
|
if (unit === "hours" || unit === "minutes" || unit === "seconds" || unit === "milliseconds" || unit === "microseconds") prevStyle = unitOptions.style;
|
|
1579
|
-
}
|
|
1877
|
+
}
|
|
1580
1878
|
internalSlots.fractionalDigits = GetNumberOption(opts, "fractionalDigits", 0, 9, void 0);
|
|
1879
|
+
initializeDurationFormatProviders(receiver);
|
|
1880
|
+
return receiver;
|
|
1581
1881
|
}
|
|
1582
1882
|
resolvedOptions() {
|
|
1583
|
-
|
|
1584
|
-
const internalSlots = getInternalSlots(this);
|
|
1883
|
+
const internalSlots = requireInternalSlots(this);
|
|
1585
1884
|
const ro = {};
|
|
1586
|
-
for (
|
|
1885
|
+
for (let index = 0; index < RESOLVED_OPTIONS_KEYS.length; index++) {
|
|
1886
|
+
const key = RESOLVED_OPTIONS_KEYS[index];
|
|
1587
1887
|
let v = internalSlots[key];
|
|
1588
1888
|
if (key === "fractionalDigits") {
|
|
1589
1889
|
if (v === void 0) continue;
|
|
1590
|
-
v =
|
|
1890
|
+
v = numberFrom(v);
|
|
1591
1891
|
} else if (v === "fractional") v = "numeric";
|
|
1592
1892
|
else invariant(v !== void 0, `Missing internal slot ${key}`);
|
|
1593
|
-
ro
|
|
1893
|
+
setDataProperty(ro, key, v);
|
|
1594
1894
|
}
|
|
1595
1895
|
return ro;
|
|
1596
1896
|
}
|
|
1597
1897
|
formatToParts(duration) {
|
|
1598
|
-
|
|
1898
|
+
requireInternalSlots(this);
|
|
1599
1899
|
const record = ToTemporalDurationRecord(duration);
|
|
1600
1900
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1601
1901
|
const result = [];
|
|
1602
|
-
for (
|
|
1902
|
+
for (let index = 0; index < parts.length; index++) {
|
|
1903
|
+
const { type, unit, value } = parts[index];
|
|
1603
1904
|
const obj = {
|
|
1604
1905
|
type,
|
|
1605
1906
|
value
|
|
1606
1907
|
};
|
|
1607
|
-
if (unit) obj
|
|
1608
|
-
result.
|
|
1908
|
+
if (unit) setDataProperty(obj, "unit", unit);
|
|
1909
|
+
setDataProperty(result, `${result.length}`, obj);
|
|
1609
1910
|
}
|
|
1610
1911
|
return result;
|
|
1611
1912
|
}
|
|
1612
1913
|
format(duration) {
|
|
1613
|
-
|
|
1914
|
+
requireInternalSlots(this);
|
|
1614
1915
|
const record = ToTemporalDurationRecord(duration);
|
|
1615
1916
|
const parts = PartitionDurationFormatPattern(this, record);
|
|
1616
1917
|
let result = "";
|
|
1617
|
-
for (
|
|
1918
|
+
for (let index = 0; index < parts.length; index++) result += parts[index].value;
|
|
1618
1919
|
return result;
|
|
1619
1920
|
}
|
|
1620
1921
|
static supportedLocalesOf(locales, options) {
|
|
1621
1922
|
return SupportedLocales(DurationFormat.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
1622
1923
|
}
|
|
1623
|
-
static {
|
|
1624
|
-
this.__defaultLocale = "en";
|
|
1625
|
-
}
|
|
1626
1924
|
static {
|
|
1627
1925
|
this.availableLocales = /* @__PURE__ */ new Set();
|
|
1628
1926
|
}
|
|
@@ -1632,7 +1930,7 @@ var DurationFormat = class DurationFormat {
|
|
|
1632
1930
|
all[locale] = {
|
|
1633
1931
|
get nu() {
|
|
1634
1932
|
const defaults = TIME_SEPARATORS.localeData[locale].nu;
|
|
1635
|
-
return
|
|
1933
|
+
return numberingUnion(defaults, supportedNumberingSystems());
|
|
1636
1934
|
},
|
|
1637
1935
|
digitalFormat: {
|
|
1638
1936
|
default: TIME_SEPARATORS.default,
|
|
@@ -1643,14 +1941,20 @@ var DurationFormat = class DurationFormat {
|
|
|
1643
1941
|
}, {});
|
|
1644
1942
|
}
|
|
1645
1943
|
static {
|
|
1646
|
-
this.getDefaultLocale =
|
|
1647
|
-
return DurationFormat.__defaultLocale;
|
|
1648
|
-
};
|
|
1944
|
+
this.getDefaultLocale = getDefaultLocale;
|
|
1649
1945
|
}
|
|
1650
1946
|
static {
|
|
1651
1947
|
this.polyfilled = true;
|
|
1652
1948
|
}
|
|
1653
1949
|
};
|
|
1950
|
+
Object.defineProperty(DurationFormat, "__defaultLocale", {
|
|
1951
|
+
configurable: true,
|
|
1952
|
+
enumerable: true,
|
|
1953
|
+
get: getDefaultLocale,
|
|
1954
|
+
set(locale) {
|
|
1955
|
+
defaultLocale = locale;
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1654
1958
|
Object.defineProperty(DurationFormat, "length", {
|
|
1655
1959
|
value: 0,
|
|
1656
1960
|
configurable: true
|
|
@@ -1659,6 +1963,7 @@ Object.defineProperty(DurationFormat.supportedLocalesOf, "length", {
|
|
|
1659
1963
|
value: 1,
|
|
1660
1964
|
configurable: true
|
|
1661
1965
|
});
|
|
1966
|
+
Object.setPrototypeOf(DurationFormat.prototype, Object.prototype);
|
|
1662
1967
|
Object.defineProperty(DurationFormat.prototype, Symbol.toStringTag, {
|
|
1663
1968
|
value: "Intl.DurationFormat",
|
|
1664
1969
|
configurable: true
|