UNPKG

@formatjs/intl-relativetimeformat

Version:

Formats JavaScript dates to relative time strings.

1,860 lines (1,845 loc) 121 kB
(() => { var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.js function CanonicalizeLocaleList(locales) { return Intl.getCanonicalLocales(locales); } // node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js var DIV_PRECISION = 40; var SpecialValue = function(SpecialValue2) { SpecialValue2[SpecialValue2["NONE"] = 0] = "NONE"; SpecialValue2[SpecialValue2["NAN"] = 1] = "NAN"; SpecialValue2[SpecialValue2["POSITIVE_INFINITY"] = 2] = "POSITIVE_INFINITY"; SpecialValue2[SpecialValue2["NEGATIVE_INFINITY"] = 3] = "NEGATIVE_INFINITY"; return SpecialValue2; }(SpecialValue || {}); function removeTrailingZeros(mantissa, exponent) { if (mantissa === 0n) return [0n, 0]; while (mantissa % 10n === 0n) { mantissa /= 10n; exponent++; } return [mantissa, exponent]; } function bigintAbs(n) { return n < 0n ? -n : n; } function digitCount(n) { if (n === 0n) return 1; if (n < 0n) n = -n; let count = 0; const big15 = 1000000000000000n; while (n >= big15) { n /= big15; count += 15; } let r = Number(n); while (r >= 1) { r /= 10; count++; } return count; } var TEN_BIGINT = 10n; function bigintPow10(n) { if (n <= 0) return 1n; let result = 1n; let base = TEN_BIGINT; let exp = n; while (exp > 0) { if (exp & 1) result *= base; base *= base; exp >>= 1; } return result; } function parseDecimalString(s) { s = s.trim(); if (s === "NaN") { return { mantissa: 0n, exponent: 0, special: SpecialValue.NAN, negativeZero: false }; } if (s === "Infinity" || s === "+Infinity") { return { mantissa: 0n, exponent: 0, special: SpecialValue.POSITIVE_INFINITY, negativeZero: false }; } if (s === "-Infinity") { return { mantissa: 0n, exponent: 0, special: SpecialValue.NEGATIVE_INFINITY, negativeZero: false }; } let negative = false; let idx = 0; if (s[idx] === "-") { negative = true; idx++; } else if (s[idx] === "+") { idx++; } let eIdx = s.indexOf("e", idx); if (eIdx === -1) eIdx = s.indexOf("E", idx); let sciExp = 0; let numPart; if (eIdx !== -1) { sciExp = parseInt(s.substring(eIdx + 1), 10); numPart = s.substring(idx, eIdx); } else { numPart = s.substring(idx); } const dotIdx = numPart.indexOf("."); let intPart; let fracPart; if (dotIdx !== -1) { intPart = numPart.substring(0, dotIdx); fracPart = numPart.substring(dotIdx + 1); } else { intPart = numPart; fracPart = ""; } const combined = intPart + fracPart; const exponent = sciExp - fracPart.length; if (combined === "" || combined === "0" || /^0+$/.test(combined)) { return { mantissa: 0n, exponent: 0, special: SpecialValue.NONE, negativeZero: negative }; } let mantissa = BigInt(combined); if (negative) mantissa = -mantissa; const [normMantissa, normExponent] = removeTrailingZeros(mantissa, exponent); return { mantissa: normMantissa, exponent: normExponent, special: SpecialValue.NONE, negativeZero: false }; } var BigDecimal = class _BigDecimal { constructor(value) { __publicField(this, "_mantissa"); __publicField(this, "_exponent"); __publicField(this, "_special"); __publicField(this, "_negativeZero"); if (typeof value === "bigint") { const [m, e] = removeTrailingZeros(value, 0); this._mantissa = m; this._exponent = e; this._special = SpecialValue.NONE; this._negativeZero = false; return; } if (typeof value === "number") { if (Number.isNaN(value)) { this._mantissa = 0n; this._exponent = 0; this._special = SpecialValue.NAN; this._negativeZero = false; return; } if (value === Infinity) { this._mantissa = 0n; this._exponent = 0; this._special = SpecialValue.POSITIVE_INFINITY; this._negativeZero = false; return; } if (value === -Infinity) { this._mantissa = 0n; this._exponent = 0; this._special = SpecialValue.NEGATIVE_INFINITY; this._negativeZero = false; return; } if (value === 0) { this._mantissa = 0n; this._exponent = 0; this._special = SpecialValue.NONE; this._negativeZero = Object.is(value, -0); return; } value = String(value); } const parsed = parseDecimalString(value); this._mantissa = parsed.mantissa; this._exponent = parsed.exponent; this._special = parsed.special; this._negativeZero = parsed.negativeZero; } // Private constructor for internal use static _create(mantissa, exponent, special, negativeZero) { const bd = Object.create(_BigDecimal.prototype); bd._mantissa = mantissa; bd._exponent = exponent; bd._special = special; bd._negativeZero = negativeZero; return bd; } // Auto-coerce to BigDecimal for decimal.js compat static _coerce(v) { return v instanceof _BigDecimal ? v : new _BigDecimal(v); } // --- Arithmetic --- times(y) { const other = _BigDecimal._coerce(y); if (this._special || other._special) { return this._specialArith(other, "times"); } if (this._mantissa === 0n || other._mantissa === 0n) { const negZero = this._isSignNegative() ? !other._isSignNegative() : other._isSignNegative(); return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero); } const m = this._mantissa * other._mantissa; const e = this._exponent + other._exponent; const [nm, ne] = removeTrailingZeros(m, e); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } div(y) { const other = _BigDecimal._coerce(y); if (this._special || other._special) { return this._specialArith(other, "div"); } if (other._mantissa === 0n) { if (this._mantissa === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } const neg = this._isSignNegative() !== other._isSignNegative(); return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false); } if (this._mantissa === 0n) { const negZero = this._isSignNegative() !== other._isSignNegative(); return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero); } const scaledNumerator = this._mantissa * bigintPow10(DIV_PRECISION); const quotient = scaledNumerator / other._mantissa; const newExponent = this._exponent - other._exponent - DIV_PRECISION; const [nm, ne] = removeTrailingZeros(quotient, newExponent); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } plus(y) { const other = _BigDecimal._coerce(y); if (this._special || other._special) { return this._specialArith(other, "plus"); } if (this._mantissa === 0n && other._mantissa === 0n) { const negZero = this._negativeZero && other._negativeZero; return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero); } if (this._mantissa === 0n) return other; if (other._mantissa === 0n) return this; let m1 = this._mantissa; let m2 = other._mantissa; const e1 = this._exponent; const e2 = other._exponent; const minE = Math.min(e1, e2); if (e1 > minE) m1 *= bigintPow10(e1 - minE); if (e2 > minE) m2 *= bigintPow10(e2 - minE); const sum = m1 + m2; if (sum === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NONE, false); } const [nm, ne] = removeTrailingZeros(sum, minE); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } minus(y) { return this.plus(_BigDecimal._coerce(y).negated()); } mod(y) { const other = _BigDecimal._coerce(y); if (this._special || other._special) { if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } if (this._special === SpecialValue.POSITIVE_INFINITY || this._special === SpecialValue.NEGATIVE_INFINITY) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } if (other._special === SpecialValue.POSITIVE_INFINITY || other._special === SpecialValue.NEGATIVE_INFINITY) { return this; } } if (other._mantissa === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } if (this._mantissa === 0n) { return this; } let m1 = this._mantissa; let m2 = other._mantissa; const e1 = this._exponent; const e2 = other._exponent; const minE = Math.min(e1, e2); if (e1 > minE) m1 *= bigintPow10(e1 - minE); if (e2 > minE) m2 *= bigintPow10(e2 - minE); const remainder = m1 % m2; if (remainder === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NONE, false); } const [nm, ne] = removeTrailingZeros(remainder, minE); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } abs() { if (this._special === SpecialValue.NAN) return this; if (this._special === SpecialValue.NEGATIVE_INFINITY) { return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false); } return _BigDecimal._create(bigintAbs(this._mantissa), this._exponent, this._special, false); } negated() { if (this._special === SpecialValue.NAN) return this; if (this._special === SpecialValue.POSITIVE_INFINITY) { return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false); } if (this._special === SpecialValue.NEGATIVE_INFINITY) { return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false); } if (this._mantissa === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NONE, !this._negativeZero); } return _BigDecimal._create(-this._mantissa, this._exponent, SpecialValue.NONE, false); } pow(n) { if (this._special === SpecialValue.NAN) return this; if (n === 0) return new _BigDecimal(1); if (n < 0) { return new _BigDecimal(1).div(this.pow(-n)); } if (this._special === SpecialValue.POSITIVE_INFINITY) return this; if (this._special === SpecialValue.NEGATIVE_INFINITY) { return n % 2 === 0 ? _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false) : this; } if (this._mantissa === 0n) return new _BigDecimal(0); const m = this._mantissa ** BigInt(n); const e = this._exponent * n; const [nm, ne] = removeTrailingZeros(m, e); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } floor() { if (this._special !== SpecialValue.NONE) return this; if (this._mantissa === 0n) return this; if (this._exponent >= 0) return this; const divisor = bigintPow10(-this._exponent); const m = this._mantissa; let q = m / divisor; if (m < 0n && m % divisor !== 0n) { q -= 1n; } if (q === 0n) { const negZero = this._mantissa < 0n; return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero); } const [nm, ne] = removeTrailingZeros(q, 0); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } ceil() { if (this._special !== SpecialValue.NONE) return this; if (this._mantissa === 0n) return this; if (this._exponent >= 0) return this; const divisor = bigintPow10(-this._exponent); const m = this._mantissa; let q = m / divisor; if (m > 0n && m % divisor !== 0n) { q += 1n; } if (q === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NONE, false); } const [nm, ne] = removeTrailingZeros(q, 0); return _BigDecimal._create(nm, ne, SpecialValue.NONE, false); } log(base) { if (this._special === SpecialValue.NAN) return this; if (this._special === SpecialValue.NEGATIVE_INFINITY) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } if (this._special === SpecialValue.POSITIVE_INFINITY) { return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false); } if (this._mantissa < 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } if (this._mantissa === 0n) { return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false); } if (base === 10) { return this._log10(); } const log10x = this._log10(); const log10b = new _BigDecimal(Math.log10(base)); return log10x.div(log10b); } _log10() { const absMantissa = bigintAbs(this._mantissa); const digits = digitCount(absMantissa); let log10Mantissa; if (digits <= 15) { log10Mantissa = Math.log10(Number(absMantissa)); } else { const shift = digits - 17; const leading = absMantissa / bigintPow10(shift); log10Mantissa = Math.log10(Number(leading)) + shift; } const totalLog10 = log10Mantissa + this._exponent; return new _BigDecimal(totalLog10); } // --- Comparison --- eq(y) { const other = _BigDecimal._coerce(y); if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) return false; if (this._special !== other._special) return false; if (this._special !== SpecialValue.NONE) return true; if (this._mantissa === 0n && other._mantissa === 0n) return true; return this._mantissa === other._mantissa && this._exponent === other._exponent; } _compareTo(other) { if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) { return NaN; } if (this._special === SpecialValue.POSITIVE_INFINITY) { return other._special === SpecialValue.POSITIVE_INFINITY ? 0 : 1; } if (this._special === SpecialValue.NEGATIVE_INFINITY) { return other._special === SpecialValue.NEGATIVE_INFINITY ? 0 : -1; } if (other._special === SpecialValue.POSITIVE_INFINITY) return -1; if (other._special === SpecialValue.NEGATIVE_INFINITY) return 1; const thisZero = this._mantissa === 0n; const otherZero = other._mantissa === 0n; if (thisZero && otherZero) return 0; if (thisZero) return other._mantissa > 0n ? -1 : 1; if (otherZero) return this._mantissa > 0n ? 1 : -1; const thisNeg = this._mantissa < 0n; const otherNeg = other._mantissa < 0n; if (thisNeg !== otherNeg) return thisNeg ? -1 : 1; let m1 = this._mantissa; let m2 = other._mantissa; const e1 = this._exponent; const e2 = other._exponent; const minE = Math.min(e1, e2); if (e1 > minE) m1 *= bigintPow10(e1 - minE); if (e2 > minE) m2 *= bigintPow10(e2 - minE); if (m1 < m2) return -1; if (m1 > m2) return 1; return 0; } lessThan(y) { const c = this._compareTo(_BigDecimal._coerce(y)); return c === -1; } greaterThan(y) { const c = this._compareTo(_BigDecimal._coerce(y)); return c === 1; } lessThanOrEqualTo(y) { const c = this._compareTo(_BigDecimal._coerce(y)); return c === 0 || c === -1; } greaterThanOrEqualTo(y) { const c = this._compareTo(_BigDecimal._coerce(y)); return c === 0 || c === 1; } // --- Queries --- isZero() { return this._special === SpecialValue.NONE && this._mantissa === 0n; } isNaN() { return this._special === SpecialValue.NAN; } isFinite() { return this._special === SpecialValue.NONE; } isNegative() { if (this._special === SpecialValue.NAN) return false; if (this._special === SpecialValue.NEGATIVE_INFINITY) return true; if (this._special === SpecialValue.POSITIVE_INFINITY) return false; if (this._mantissa === 0n) return this._negativeZero; return this._mantissa < 0n; } isPositive() { if (this._special === SpecialValue.NAN) return false; if (this._special === SpecialValue.POSITIVE_INFINITY) return true; if (this._special === SpecialValue.NEGATIVE_INFINITY) return false; if (this._mantissa === 0n) return !this._negativeZero; return this._mantissa > 0n; } isInteger() { if (this._special !== SpecialValue.NONE) return false; if (this._mantissa === 0n) return true; return this._exponent >= 0; } // --- Conversion --- toJSON() { return this.toString(); } toNumber() { if (this._special === SpecialValue.NAN) return NaN; if (this._special === SpecialValue.POSITIVE_INFINITY) return Infinity; if (this._special === SpecialValue.NEGATIVE_INFINITY) return -Infinity; if (this._mantissa === 0n) return this._negativeZero ? -0 : 0; return Number(this.toString()); } toString() { if (this._special === SpecialValue.NAN) return "NaN"; if (this._special === SpecialValue.POSITIVE_INFINITY) return "Infinity"; if (this._special === SpecialValue.NEGATIVE_INFINITY) return "-Infinity"; if (this._mantissa === 0n) return "0"; const negative = this._mantissa < 0n; const absStr = bigintAbs(this._mantissa).toString(); const prefix = negative ? "-" : ""; if (this._exponent === 0) { return prefix + absStr; } if (this._exponent > 0) { return prefix + absStr + "0".repeat(this._exponent); } const decimalPlaces = -this._exponent; if (decimalPlaces < absStr.length) { const intPart = absStr.slice(0, absStr.length - decimalPlaces); const fracPart = absStr.slice(absStr.length - decimalPlaces); return prefix + intPart + "." + fracPart; } else { const leadingZeros = decimalPlaces - absStr.length; return prefix + "0." + "0".repeat(leadingZeros) + absStr; } } // --- Static --- static pow(base, exp) { const n = typeof exp === "number" ? exp : exp.toNumber(); if (typeof base === "number" && base === 10) { return _BigDecimal._create(1n, n, SpecialValue.NONE, false); } const bd = base instanceof _BigDecimal ? base : new _BigDecimal(base); return bd.pow(n); } static set(_config) { } // --- Internal helpers --- _isSignNegative() { if (this._special === SpecialValue.NEGATIVE_INFINITY) return true; if (this._mantissa < 0n) return true; if (this._mantissa === 0n) return this._negativeZero; return false; } _specialArith(other, op) { const a = this._special; const b = other._special; if (a === SpecialValue.NAN || b === SpecialValue.NAN) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } const aNeg = this._isSignNegative(); const bNeg = other._isSignNegative(); const aInf = a === SpecialValue.POSITIVE_INFINITY || a === SpecialValue.NEGATIVE_INFINITY; const bInf = b === SpecialValue.POSITIVE_INFINITY || b === SpecialValue.NEGATIVE_INFINITY; if (op === "times") { if (aInf || bInf) { if (aInf && other._mantissa === 0n && !bInf || bInf && this._mantissa === 0n && !aInf) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } const neg = aNeg !== bNeg; return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false); } } if (op === "div") { if (aInf && bInf) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } if (aInf) { const neg = aNeg !== bNeg; return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false); } if (bInf) { const negZero = aNeg !== bNeg; return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero); } } if (op === "plus") { if (aInf && bInf) { if (aNeg !== bNeg) { return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } return this; } if (aInf) return this; if (bInf) return other; } return _BigDecimal._create(0n, 0, SpecialValue.NAN, false); } }; // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js var TEN = new BigDecimal(10); var ZERO = new BigDecimal(0); var NEGATIVE_ZERO = new BigDecimal(-0); // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js function memoize(fn, options) { const cache = options && options.cache ? options.cache : cacheDefault; const serializer = options && options.serializer ? options.serializer : serializerDefault; const strategy = options && options.strategy ? options.strategy : strategyDefault; return strategy(fn, { cache, serializer }); } function isPrimitive(value) { return value == null || typeof value === "number" || typeof value === "boolean"; } function monadic(fn, cache, serializer, arg) { const cacheKey = isPrimitive(arg) ? arg : serializer(arg); let computedValue = cache.get(cacheKey); if (typeof computedValue === "undefined") { computedValue = fn.call(this, arg); cache.set(cacheKey, computedValue); } return computedValue; } function variadic(fn, cache, serializer) { const args = Array.prototype.slice.call(arguments, 3); const cacheKey = serializer(args); let computedValue = cache.get(cacheKey); if (typeof computedValue === "undefined") { computedValue = fn.apply(this, args); cache.set(cacheKey, computedValue); } return computedValue; } function assemble(fn, context, strategy, cache, serialize) { return strategy.bind(context, fn, cache, serialize); } function strategyDefault(fn, options) { const strategy = fn.length === 1 ? monadic : variadic; return assemble(fn, this, strategy, options.cache.create(), options.serializer); } function strategyVariadic(fn, options) { return assemble(fn, this, variadic, options.cache.create(), options.serializer); } function strategyMonadic(fn, options) { return assemble(fn, this, monadic, options.cache.create(), options.serializer); } var serializerDefault = function() { return JSON.stringify(arguments); }; var ObjectWithoutPrototypeCache = class { constructor() { __publicField(this, "cache"); this.cache = /* @__PURE__ */ Object.create(null); } get(key) { return this.cache[key]; } set(key, value) { this.cache[key] = value; } }; var cacheDefault = { create: function create() { return new ObjectWithoutPrototypeCache(); } }; var strategies = { variadic: strategyVariadic, monadic: strategyMonadic }; // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/utils.js function invariant(condition, message, Err = Error) { if (!condition) { throw new Err(message); } } var createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic }); var createMemoizedPluralRules = memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic }); var createMemoizedLocale = memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic }); var createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic }); // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/262.js function ToString(o) { if (typeof o === "symbol") { throw TypeError("Cannot convert a Symbol value to a string"); } return String(o); } function ToObject(arg) { if (arg == null) { throw new TypeError("undefined/null cannot be converted to object"); } return Object(arg); } function SameValue(x, y) { if (Object.is) { return Object.is(x, y); } if (x === y) { return x !== 0 || 1 / x === 1 / y; } return x !== x && y !== y; } function Type(x) { if (x === null) { return "Null"; } if (typeof x === "undefined") { return "Undefined"; } if (typeof x === "function" || typeof x === "object") { return "Object"; } if (typeof x === "number") { return "Number"; } if (typeof x === "boolean") { return "Boolean"; } if (typeof x === "string") { return "String"; } if (typeof x === "symbol") { return "Symbol"; } if (typeof x === "bigint") { return "BigInt"; } } var MINUTES_PER_HOUR = 60; var SECONDS_PER_MINUTE = 60; var MS_PER_SECOND = 1e3; var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE; var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR; // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CoerceOptionsToObject.js function CoerceOptionsToObject(options) { if (typeof options === "undefined") { return /* @__PURE__ */ Object.create(null); } return ToObject(options); } // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOption.js function GetOption(opts, prop, type, values, fallback) { if (typeof opts !== "object") { throw new TypeError("Options must be an object"); } let value = opts[prop]; if (value !== void 0) { if (type !== "boolean" && type !== "string") { throw new TypeError("invalid type"); } if (type === "boolean") { value = Boolean(value); } if (type === "string") { value = ToString(value); } if (values !== void 0 && !values.filter((val) => val == value).length) { throw new RangeError(`${value} is not within ${values.join(", ")}`); } return value; } return fallback; } // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsSanctionedSimpleUnitIdentifier.js var SANCTIONED_UNITS = [ "angle-degree", "area-acre", "area-hectare", "concentr-percent", "digital-bit", "digital-byte", "digital-gigabit", "digital-gigabyte", "digital-kilobit", "digital-kilobyte", "digital-megabit", "digital-megabyte", "digital-petabyte", "digital-terabit", "digital-terabyte", "duration-day", "duration-hour", "duration-millisecond", "duration-minute", "duration-month", "duration-second", "duration-week", "duration-year", "length-centimeter", "length-foot", "length-inch", "length-kilometer", "length-meter", "length-mile-scandinavian", "length-mile", "length-millimeter", "length-yard", "mass-gram", "mass-kilogram", "mass-ounce", "mass-pound", "mass-stone", "temperature-celsius", "temperature-fahrenheit", "volume-fluid-ounce", "volume-gallon", "volume-liter", "volume-milliliter" ]; function removeUnitNamespace(unit) { return unit.slice(unit.indexOf("-") + 1); } var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace); // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/decimal-cache.js var getPowerOf10 = memoize((exponent) => { return BigDecimal.pow(10, exponent); }); // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/; // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/format_to_parts.js var CARET_S_UNICODE_REGEX = new RegExp(`^${S_UNICODE_REGEX.source}`); var S_DOLLAR_UNICODE_REGEX = new RegExp(`${S_UNICODE_REGEX.source}$`); // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeLocaleList.js function CanonicalizeLocaleList2(locales) { return Intl.getCanonicalLocales(locales); } // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/languageMatching.js var data = { supplemental: { languageMatching: { "written-new": [ { paradigmLocales: { _locales: "en en_GB es es_419 pt_BR pt_PT" } }, { $enUS: { _value: "AS+CA+GU+MH+MP+PH+PR+UM+US+VI" } }, { $cnsar: { _value: "HK+MO" } }, { $americas: { _value: "019" } }, { $maghreb: { _value: "MA+DZ+TN+LY+MR+EH" } }, { no: { _desired: "nb", _distance: "1" } }, { bs: { _desired: "hr", _distance: "4" } }, { bs: { _desired: "sh", _distance: "4" } }, { hr: { _desired: "sh", _distance: "4" } }, { sr: { _desired: "sh", _distance: "4" } }, { aa: { _desired: "ssy", _distance: "4" } }, { de: { _desired: "gsw", _distance: "4", _oneway: "true" } }, { de: { _desired: "lb", _distance: "4", _oneway: "true" } }, { no: { _desired: "da", _distance: "8" } }, { nb: { _desired: "da", _distance: "8" } }, { ru: { _desired: "ab", _distance: "30", _oneway: "true" } }, { en: { _desired: "ach", _distance: "30", _oneway: "true" } }, { nl: { _desired: "af", _distance: "20", _oneway: "true" } }, { en: { _desired: "ak", _distance: "30", _oneway: "true" } }, { en: { _desired: "am", _distance: "30", _oneway: "true" } }, { es: { _desired: "ay", _distance: "20", _oneway: "true" } }, { ru: { _desired: "az", _distance: "30", _oneway: "true" } }, { ur: { _desired: "bal", _distance: "20", _oneway: "true" } }, { ru: { _desired: "be", _distance: "20", _oneway: "true" } }, { en: { _desired: "bem", _distance: "30", _oneway: "true" } }, { hi: { _desired: "bh", _distance: "30", _oneway: "true" } }, { en: { _desired: "bn", _distance: "30", _oneway: "true" } }, { zh: { _desired: "bo", _distance: "20", _oneway: "true" } }, { fr: { _desired: "br", _distance: "20", _oneway: "true" } }, { es: { _desired: "ca", _distance: "20", _oneway: "true" } }, { fil: { _desired: "ceb", _distance: "30", _oneway: "true" } }, { en: { _desired: "chr", _distance: "20", _oneway: "true" } }, { ar: { _desired: "ckb", _distance: "30", _oneway: "true" } }, { fr: { _desired: "co", _distance: "20", _oneway: "true" } }, { fr: { _desired: "crs", _distance: "20", _oneway: "true" } }, { sk: { _desired: "cs", _distance: "20" } }, { en: { _desired: "cy", _distance: "20", _oneway: "true" } }, { en: { _desired: "ee", _distance: "30", _oneway: "true" } }, { en: { _desired: "eo", _distance: "30", _oneway: "true" } }, { es: { _desired: "eu", _distance: "20", _oneway: "true" } }, { da: { _desired: "fo", _distance: "20", _oneway: "true" } }, { nl: { _desired: "fy", _distance: "20", _oneway: "true" } }, { en: { _desired: "ga", _distance: "20", _oneway: "true" } }, { en: { _desired: "gaa", _distance: "30", _oneway: "true" } }, { en: { _desired: "gd", _distance: "20", _oneway: "true" } }, { es: { _desired: "gl", _distance: "20", _oneway: "true" } }, { es: { _desired: "gn", _distance: "20", _oneway: "true" } }, { hi: { _desired: "gu", _distance: "30", _oneway: "true" } }, { en: { _desired: "ha", _distance: "30", _oneway: "true" } }, { en: { _desired: "haw", _distance: "20", _oneway: "true" } }, { fr: { _desired: "ht", _distance: "20", _oneway: "true" } }, { ru: { _desired: "hy", _distance: "30", _oneway: "true" } }, { en: { _desired: "ia", _distance: "30", _oneway: "true" } }, { en: { _desired: "ig", _distance: "30", _oneway: "true" } }, { en: { _desired: "is", _distance: "20", _oneway: "true" } }, { id: { _desired: "jv", _distance: "20", _oneway: "true" } }, { en: { _desired: "ka", _distance: "30", _oneway: "true" } }, { fr: { _desired: "kg", _distance: "30", _oneway: "true" } }, { ru: { _desired: "kk", _distance: "30", _oneway: "true" } }, { en: { _desired: "km", _distance: "30", _oneway: "true" } }, { en: { _desired: "kn", _distance: "30", _oneway: "true" } }, { en: { _desired: "kri", _distance: "30", _oneway: "true" } }, { tr: { _desired: "ku", _distance: "30", _oneway: "true" } }, { ru: { _desired: "ky", _distance: "30", _oneway: "true" } }, { it: { _desired: "la", _distance: "20", _oneway: "true" } }, { en: { _desired: "lg", _distance: "30", _oneway: "true" } }, { fr: { _desired: "ln", _distance: "30", _oneway: "true" } }, { en: { _desired: "lo", _distance: "30", _oneway: "true" } }, { en: { _desired: "loz", _distance: "30", _oneway: "true" } }, { fr: { _desired: "lua", _distance: "30", _oneway: "true" } }, { hi: { _desired: "mai", _distance: "20", _oneway: "true" } }, { en: { _desired: "mfe", _distance: "30", _oneway: "true" } }, { fr: { _desired: "mg", _distance: "30", _oneway: "true" } }, { en: { _desired: "mi", _distance: "20", _oneway: "true" } }, { en: { _desired: "ml", _distance: "30", _oneway: "true" } }, { ru: { _desired: "mn", _distance: "30", _oneway: "true" } }, { hi: { _desired: "mr", _distance: "30", _oneway: "true" } }, { id: { _desired: "ms", _distance: "30", _oneway: "true" } }, { en: { _desired: "mt", _distance: "30", _oneway: "true" } }, { en: { _desired: "my", _distance: "30", _oneway: "true" } }, { en: { _desired: "ne", _distance: "30", _oneway: "true" } }, { nb: { _desired: "nn", _distance: "20" } }, { no: { _desired: "nn", _distance: "20" } }, { en: { _desired: "nso", _distance: "30", _oneway: "true" } }, { en: { _desired: "ny", _distance: "30", _oneway: "true" } }, { en: { _desired: "nyn", _distance: "30", _oneway: "true" } }, { fr: { _desired: "oc", _distance: "20", _oneway: "true" } }, { en: { _desired: "om", _distance: "30", _oneway: "true" } }, { en: { _desired: "or", _distance: "30", _oneway: "true" } }, { en: { _desired: "pa", _distance: "30", _oneway: "true" } }, { en: { _desired: "pcm", _distance: "20", _oneway: "true" } }, { en: { _desired: "ps", _distance: "30", _oneway: "true" } }, { es: { _desired: "qu", _distance: "30", _oneway: "true" } }, { de: { _desired: "rm", _distance: "20", _oneway: "true" } }, { en: { _desired: "rn", _distance: "30", _oneway: "true" } }, { fr: { _desired: "rw", _distance: "30", _oneway: "true" } }, { hi: { _desired: "sa", _distance: "30", _oneway: "true" } }, { en: { _desired: "sd", _distance: "30", _oneway: "true" } }, { en: { _desired: "si", _distance: "30", _oneway: "true" } }, { en: { _desired: "sn", _distance: "30", _oneway: "true" } }, { en: { _desired: "so", _distance: "30", _oneway: "true" } }, { en: { _desired: "sq", _distance: "30", _oneway: "true" } }, { en: { _desired: "st", _distance: "30", _oneway: "true" } }, { id: { _desired: "su", _distance: "20", _oneway: "true" } }, { en: { _desired: "sw", _distance: "30", _oneway: "true" } }, { en: { _desired: "ta", _distance: "30", _oneway: "true" } }, { en: { _desired: "te", _distance: "30", _oneway: "true" } }, { ru: { _desired: "tg", _distance: "30", _oneway: "true" } }, { en: { _desired: "ti", _distance: "30", _oneway: "true" } }, { ru: { _desired: "tk", _distance: "30", _oneway: "true" } }, { en: { _desired: "tlh", _distance: "30", _oneway: "true" } }, { en: { _desired: "tn", _distance: "30", _oneway: "true" } }, { en: { _desired: "to", _distance: "30", _oneway: "true" } }, { ru: { _desired: "tt", _distance: "30", _oneway: "true" } }, { en: { _desired: "tum", _distance: "30", _oneway: "true" } }, { zh: { _desired: "ug", _distance: "20", _oneway: "true" } }, { ru: { _desired: "uk", _distance: "20", _oneway: "true" } }, { en: { _desired: "ur", _distance: "30", _oneway: "true" } }, { ru: { _desired: "uz", _distance: "30", _oneway: "true" } }, { fr: { _desired: "wo", _distance: "30", _oneway: "true" } }, { en: { _desired: "xh", _distance: "30", _oneway: "true" } }, { en: { _desired: "yi", _distance: "30", _oneway: "true" } }, { en: { _desired: "yo", _distance: "30", _oneway: "true" } }, { zh: { _desired: "za", _distance: "20", _oneway: "true" } }, { en: { _desired: "zu", _distance: "30", _oneway: "true" } }, { ar: { _desired: "aao", _distance: "10", _oneway: "true" } }, { ar: { _desired: "abh", _distance: "10", _oneway: "true" } }, { ar: { _desired: "abv", _distance: "10", _oneway: "true" } }, { ar: { _desired: "acm", _distance: "10", _oneway: "true" } }, { ar: { _desired: "acq", _distance: "10", _oneway: "true" } }, { ar: { _desired: "acw", _distance: "10", _oneway: "true" } }, { ar: { _desired: "acx", _distance: "10", _oneway: "true" } }, { ar: { _desired: "acy", _distance: "10", _oneway: "true" } }, { ar: { _desired: "adf", _distance: "10", _oneway: "true" } }, { ar: { _desired: "aeb", _distance: "10", _oneway: "true" } }, { ar: { _desired: "aec", _distance: "10", _oneway: "true" } }, { ar: { _desired: "afb", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ajp", _distance: "10", _oneway: "true" } }, { ar: { _desired: "apc", _distance: "10", _oneway: "true" } }, { ar: { _desired: "apd", _distance: "10", _oneway: "true" } }, { ar: { _desired: "arq", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ars", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ary", _distance: "10", _oneway: "true" } }, { ar: { _desired: "arz", _distance: "10", _oneway: "true" } }, { ar: { _desired: "auz", _distance: "10", _oneway: "true" } }, { ar: { _desired: "avl", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ayh", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ayl", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ayn", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ayp", _distance: "10", _oneway: "true" } }, { ar: { _desired: "bbz", _distance: "10", _oneway: "true" } }, { ar: { _desired: "pga", _distance: "10", _oneway: "true" } }, { ar: { _desired: "shu", _distance: "10", _oneway: "true" } }, { ar: { _desired: "ssh", _distance: "10", _oneway: "true" } }, { az: { _desired: "azb", _distance: "10", _oneway: "true" } }, { et: { _desired: "vro", _distance: "10", _oneway: "true" } }, { ff: { _desired: "ffm", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fub", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fue", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fuf", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fuh", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fui", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fuq", _distance: "10", _oneway: "true" } }, { ff: { _desired: "fuv", _distance: "10", _oneway: "true" } }, { gn: { _desired: "gnw", _distance: "10", _oneway: "true" } }, { gn: { _desired: "gui", _distance: "10", _oneway: "true" } }, { gn: { _desired: "gun", _distance: "10", _oneway: "true" } }, { gn: { _desired: "nhd", _distance: "10", _oneway: "true" } }, { iu: { _desired: "ikt", _distance: "10", _oneway: "true" } }, { kln: { _desired: "enb", _distance: "10", _oneway: "true" } }, { kln: { _desired: "eyo", _distance: "10", _oneway: "true" } }, { kln: { _desired: "niq", _distance: "10", _oneway: "true" } }, { kln: { _desired: "oki", _distance: "10", _oneway: "true" } }, { kln: { _desired: "pko", _distance: "10", _oneway: "true" } }, { kln: { _desired: "sgc", _distance: "10", _oneway: "true" } }, { kln: { _desired: "tec", _distance: "10", _oneway: "true" } }, { kln: { _desired: "tuy", _distance: "10", _oneway: "true" } }, { kok: { _desired: "gom", _distance: "10", _oneway: "true" } }, { kpe: { _desired: "gkp", _distance: "10", _oneway: "true" } }, { luy: { _desired: "ida", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lkb", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lko", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lks", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lri", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lrm", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lsm", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lto", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lts", _distance: "10", _oneway: "true" } }, { luy: { _desired: "lwg", _distance: "10", _oneway: "true" } }, { luy: { _desired: "nle", _distance: "10", _oneway: "true" } }, { luy: { _desired: "nyd", _distance: "10", _oneway: "true" } }, { luy: { _desired: "rag", _distance: "10", _oneway: "true" } }, { lv: { _desired: "ltg", _distance: "10", _oneway: "true" } }, { mg: { _desired: "bhr", _distance: "10", _oneway: "true" } }, { mg: { _desired: "bjq", _distance: "10", _oneway: "true" } }, { mg: { _desired: "bmm", _distance: "10", _oneway: "true" } }, { mg: { _desired: "bzc", _distance: "10", _oneway: "true" } }, { mg: { _desired: "msh", _distance: "10", _oneway: "true" } }, { mg: { _desired: "skg", _distance: "10", _oneway: "true" } }, { mg: { _desired: "tdx", _distance: "10", _oneway: "true" } }, { mg: {