@formatjs/intl-pluralrules
Version:
Polyfill for Intl.PluralRules
5,314 lines • 112 kB
JavaScript
import { supportedLocales } from "@formatjs_generated/cldr.supported-locales/intl-pluralrules.js";
//#region packages/ecma402-abstract/CanonicalizeLocaleList.js
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
* @param locales
*/
function CanonicalizeLocaleList$1(locales) {
return Intl.getCanonicalLocales(locales);
}
//#endregion
//#region 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;
return (options && options.strategy ? options.strategy : strategyDefault)(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);
}
const serializerDefault = function() {
return JSON.stringify(arguments);
};
var ObjectWithoutPrototypeCache = class {
constructor() {
this.cache = Object.create(null);
}
get(key) {
return this.cache[key];
}
set(key, value) {
this.cache[key] = value;
}
};
const cacheDefault = { create: function create() {
return new ObjectWithoutPrototypeCache();
} };
const strategies = {
variadic: strategyVariadic,
monadic: strategyMonadic
};
//#endregion
//#region node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
* @param locales
*/
function CanonicalizeLocaleList(locales) {
return Intl.getCanonicalLocales(locales);
}
const 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: {
_desired: "tkg",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "txy",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "xmv",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "xmw",
_distance: "10",
_oneway: "true"
} },
{ mn: {
_desired: "mvf",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "bjn",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "btj",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "bve",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "bvu",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "coa",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "dup",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "hji",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "id",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "jak",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "jax",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "kvb",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "kvr",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "kxd",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "lce",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "lcf",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "liw",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "max",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "meo",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mfa",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mfb",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "min",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mqg",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "msi",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mui",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "orn",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "ors",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "pel",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "pse",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "tmw",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "urk",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "vkk",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "vkt",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "xmm",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "zlm",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "zmi",
_distance: "10",
_oneway: "true"
} },
{ ne: {
_desired: "dty",
_distance: "10",
_oneway: "true"
} },
{ om: {
_desired: "gax",
_distance: "10",
_oneway: "true"
} },
{ om: {
_desired: "hae",
_distance: "10",
_oneway: "true"
} },
{ om: {
_desired: "orc",
_distance: "10",
_oneway: "true"
} },
{ or: {
_desired: "spv",
_distance: "10",
_oneway: "true"
} },
{ ps: {
_desired: "pbt",
_distance: "10",
_oneway: "true"
} },
{ ps: {
_desired: "pst",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qub",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qud",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quf",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qug",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quk",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qul",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qup",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qur",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qus",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quw",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qux",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quy",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qva",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvc",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qve",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvi",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvj",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvl",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvm",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvn",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvo",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvp",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvs",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvw",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvz",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qwa",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qwc",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qwh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qws",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxa",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxc",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxl",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxn",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxo",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxp",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxr",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxt",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxu",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxw",
_distance: "10",
_oneway: "true"
} },
{ sc: {
_desired: "sdc",
_distance: "10",
_oneway: "true"
} },
{ sc: {
_desired: "sdn",
_distance: "10",
_oneway: "true"
} },
{ sc: {
_desired: "sro",
_distance: "10",
_oneway: "true"
} },
{ sq: {
_desired: "aae",
_distance: "10",
_oneway: "true"
} },
{ sq: {
_desired: "aat",
_distance: "10",
_oneway: "true"
} },
{ sq: {
_desired: "aln",
_distance: "10",
_oneway: "true"
} },
{ syr: {
_desired: "aii",
_distance: "10",
_oneway: "true"
} },
{ uz: {
_desired: "uzs",
_distance: "10",
_oneway: "true"
} },
{ yi: {
_desired: "yih",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "cdo",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "cjy",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "cpx",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "czh",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "czo",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "gan",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "hak",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "hsn",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "lzh",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "mnp",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "nan",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "wuu",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "yue",
_distance: "10",
_oneway: "true"
} },
{ "*": {
_desired: "*",
_distance: "80"
} },
{ "en-Latn": {
_desired: "am-Ethi",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "az-Latn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "bn-Beng",
_distance: "10",
_oneway: "true"
} },
{ "zh-Hans": {
_desired: "bo-Tibt",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "hy-Armn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ka-Geor",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "km-Khmr",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "kn-Knda",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "lo-Laoo",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ml-Mlym",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "my-Mymr",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ne-Deva",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "or-Orya",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "pa-Guru",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ps-Arab",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "sd-Arab",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "si-Sinh",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ta-Taml",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "te-Telu",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ti-Ethi",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "tk-Latn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ur-Arab",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "uz-Latn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "yi-Hebr",
_distance: "10",
_oneway: "true"
} },
{ "sr-Cyrl": {
_desired: "sr-Latn",
_distance: "5"
} },
{ "zh-Hans": {
_desired: "za-Latn",
_distance: "10",
_oneway: "true"
} },
{ "zh-Hans": {
_desired: "zh-Hani",
_distance: "20",
_oneway: "true"
} },
{ "zh-Hant": {
_desired: "zh-Hani",
_distance: "20",
_oneway: "true"
} },
{ "ar-Arab": {
_desired: "ar-Latn",
_distance: "20",
_oneway: "true"
} },
{ "bn-Beng": {
_desired: "bn-Latn",
_distance: "20",
_oneway: "true"
} },
{ "gu-Gujr": {
_desired: "gu-Latn",
_distance: "20",
_oneway: "true"
} },
{ "hi-Deva": {
_desired: "hi-Latn",
_distance: "20",
_oneway: "true"
} },
{ "kn-Knda": {
_desired: "kn-Latn",
_distance: "20",
_oneway: "true"
} },
{ "ml-Mlym": {
_desired: "ml-Latn",
_distance: "20",
_oneway: "true"
} },
{ "mr-Deva": {
_desired: "mr-Latn",
_distance: "20",
_oneway: "true"
} },
{ "ta-Taml": {
_desired: "ta-Latn",
_distance: "20",
_oneway: "true"
} },
{ "te-Telu": {
_desired: "te-Latn",
_distance: "20",
_oneway: "true"
} },
{ "zh-Hans": {
_desired: "zh-Latn",
_distance: "20",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Latn",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Hani",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Hira",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Kana",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Hrkt",
_distance: "5",
_oneway: "true"
} },
{ "ja-Hrkt": {
_desired: "ja-Hira",
_distance: "5",
_oneway: "true"
} },
{ "ja-Hrkt": {
_desired: "ja-Kana",
_distance: "5",
_oneway: "true"
} },
{ "ko-Kore": {
_desired: "ko-Hani",
_distance: "5",
_oneway: "true"
} },
{ "ko-Kore": {
_desired: "ko-Hang",
_distance: "5",
_oneway: "true"
} },
{ "ko-Kore": {
_desired: "ko-Jamo",
_distance: "5",
_oneway: "true"
} },
{ "ko-Hang": {
_desired: "ko-Jamo",
_distance: "5",
_oneway: "true"
} },
{ "*-*": {
_desired: "*-*",
_distance: "50"
} },
{ "ar-*-$maghreb": {
_desired: "ar-*-$maghreb",
_distance: "4"
} },
{ "ar-*-$!maghreb": {
_desired: "ar-*-$!maghreb",
_distance: "4"
} },
{ "ar-*-*": {
_desired: "ar-*-*",
_distance: "5"
} },
{ "en-*-$enUS": {
_desired: "en-*-$enUS",
_distance: "4"
} },
{ "en-*-GB": {
_desired: "en-*-$!enUS",
_distance: "3"
} },
{ "en-*-$!enUS": {
_desired: "en-*-$!enUS",
_distance: "4"
} },
{ "en-*-*": {
_desired: "en-*-*",
_distance: "5"
} },
{ "es-*-$americas": {
_desired: "es-*-$americas",
_distance: "4"
} },
{ "es-*-$!americas": {
_desired: "es-*-$!americas",
_distance: "4"
} },
{ "es-*-*": {
_desired: "es-*-*",
_distance: "5"
} },
{ "pt-*-$americas": {
_desired: "pt-*-$americas",
_distance: "4"
} },
{ "pt-*-$!americas": {
_desired: "pt-*-$!americas",
_distance: "4"
} },
{ "pt-*-*": {
_desired: "pt-*-*",
_distance: "5"
} },
{ "zh-Hant-$cnsar": {
_desired: "zh-Hant-$cnsar",
_distance: "4"
} },
{ "zh-Hant-$!cnsar": {
_desired: "zh-Hant-$!cnsar",
_distance: "4"
} },
{ "zh-Hant-*": {
_desired: "zh-Hant-*",
_distance: "5"
} },
{ "*-*-*": {
_desired: "*-*-*",
_distance: "4"
} }
] } } };
const regions = {
"001": [
"001",
"001-status-grouping",
"002",
"005",
"009",
"011",
"013",
"014",
"015",
"017",
"018",
"019",
"021",
"029",
"030",
"034",
"035",
"039",
"053",
"054",
"057",
"061",
"142",
"143",
"145",
"150",
"151",
"154",
"155",
"AC",
"AD",
"AE",
"AF",
"AG",
"AI",
"AL",
"AM",
"AO",
"AQ",
"AR",
"AS",
"AT",
"AU",
"AW",
"AX",
"AZ",
"BA",
"BB",
"BD",
"BE",
"BF",
"BG",
"BH",
"BI",
"BJ",
"BL",
"BM",
"BN",
"BO",
"BQ",
"BR",
"BS",
"BT",
"BV",
"BW",
"BY",
"BZ",
"CA",
"CC",
"CD",
"CF",
"CG",
"CH",
"CI",
"CK",
"CL",
"CM",
"CN",
"CO",
"CP",
"CQ",
"CR",
"CU",
"CV",
"CW",
"CX",
"CY",
"CZ",
"DE",
"DG",
"DJ",
"DK",
"DM",
"DO",
"DZ",
"EA",
"EC",
"EE",
"EG",
"EH",
"ER",
"ES",
"ET",
"EU",
"EZ",
"FI",
"FJ",
"FK",
"FM",
"FO",
"FR",
"GA",
"GB",
"GD",
"GE",
"GF",
"GG",
"GH",
"GI",
"GL",
"GM",
"GN",
"GP",
"GQ",
"GR",
"GS",
"GT",
"GU",
"GW",
"GY",
"HK",
"HM",
"HN",
"HR",
"HT",
"HU",
"IC",
"ID",
"IE",
"IL",
"IM",
"IN",
"IO",
"IQ",
"IR",
"IS",
"IT",
"JE",
"JM",
"JO",
"JP",
"KE",
"KG",
"KH",
"KI",
"KM",
"KN",
"KP",
"KR",
"KW",
"KY",
"KZ",
"LA",
"LB",
"LC",
"LI",
"LK",
"LR",
"LS",
"LT",
"LU",
"LV",
"LY",
"MA",
"MC",
"MD",
"ME",
"MF",
"MG",
"MH",
"MK",
"ML",
"MM",
"MN",
"MO",
"MP",
"MQ",
"MR",
"MS",
"MT",
"MU",
"MV",
"MW",
"MX",
"MY",
"MZ",
"NA",
"NC",
"NE",
"NF",
"NG",
"NI",
"NL",
"NO",
"NP",
"NR",
"NU",
"NZ",
"OM",
"PA",
"PE",
"PF",
"PG",
"PH",
"PK",
"PL",
"PM",
"PN",
"PR",
"PS",
"PT",
"PW",
"PY",
"QA",
"QO",
"RE",
"RO",
"RS",
"RU",
"RW",
"SA",
"SB",
"SC",
"SD",
"SE",
"SG",
"SH",
"SI",
"SJ",
"SK",
"SL",
"SM",
"SN",
"SO",
"SR",
"SS",
"ST",
"SV",
"SX",
"SY",
"SZ",
"TA",
"TC",
"TD",
"TF",
"TG",
"TH",
"TJ",
"TK",
"TL",
"TM",
"TN",
"TO",
"TR",
"TT",
"TV",
"TW",
"TZ",
"UA",
"UG",
"UM",
"UN",
"US",
"UY",
"UZ",
"VA",
"VC",
"VE",
"VG",
"VI",
"VN",
"VU",
"WF",
"WS",
"XK",
"YE",
"YT",
"ZA",
"ZM",
"ZW"
],
"002": [
"002",
"002-status-grouping",
"011",
"014",
"015",
"017",
"018",
"202",
"AO",
"BF",
"BI",
"BJ",
"BW",
"CD",
"CF",
"CG",
"CI",
"CM",
"CV",
"DJ",
"DZ",
"EA",
"EG",
"EH",
"ER",
"ET",
"GA",
"GH",
"GM",
"GN",
"GQ",
"GW",
"IC",
"IO",
"KE",
"KM",
"LR",
"LS",
"LY",
"MA",
"MG",
"ML",
"MR",
"MU",
"MW",
"MZ",
"NA",
"NE",
"NG",
"RE",
"RW",
"SC",
"SD",
"SH",
"SL",
"SN",
"SO",
"SS",
"ST",
"SZ",
"TD",
"TF",
"TG",
"TN",
"TZ",
"UG",
"YT",
"ZA",
"ZM",
"ZW"
],
"003": [
"003",
"013",
"021",
"029",
"AG",
"AI",
"AW",
"BB",
"BL",
"BM",
"BQ",
"BS",
"BZ",
"CA",
"CR",
"CU",
"CW",
"DM",
"DO",
"GD",
"GL",
"GP",
"GT",
"HN",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"MX",
"NI",
"PA",
"PM",
"PR",
"SV",
"SX",
"TC",
"TT",
"US",
"VC",
"VG",
"VI"
],
"005": [
"005",
"AR",
"BO",
"BR",
"BV",
"CL",
"CO",
"EC",
"FK",
"GF",
"GS",
"GY",
"PE",
"PY",
"SR",
"UY",
"VE"
],
"009": [
"009",
"053",
"054",
"057",
"061",
"AC",
"AQ",
"AS",
"AU",
"CC",
"CK",
"CP",
"CX",
"DG",
"FJ",
"FM",
"GU",
"HM",
"KI",
"MH",
"MP",
"NC",
"NF",
"NR",
"NU",
"NZ",
"PF",
"PG",
"PN",
"PW",
"QO",
"SB",
"TA",
"TK",
"TO",
"TV",
"UM",
"VU",
"WF",
"WS"
],
"011": [
"011",
"BF",
"BJ",
"CI",
"CV",
"GH",
"GM",
"GN",
"GW",
"LR",
"ML",
"MR",
"NE",
"NG",
"SH",
"SL",
"SN",
"TG"
],
"013": [
"013",
"BZ",
"CR",
"GT",
"HN",
"MX",
"NI",
"PA",
"SV"
],
"014": [
"014",
"BI",
"DJ",
"ER",
"ET",
"IO",
"KE",
"KM",
"MG",
"MU",
"MW",
"MZ",
"RE",
"RW",
"SC",
"SO",
"SS",
"TF",
"TZ",
"UG",
"YT",
"ZM",
"ZW"
],
"015": [
"015",
"DZ",
"EA",
"EG",
"EH",
"IC",
"LY",
"MA",
"SD",
"TN"
],
"017": [
"017",
"AO",
"CD",
"CF",
"CG",
"CM",
"GA",
"GQ",
"ST",
"TD"
],
"018": [
"018",
"BW",
"LS",
"NA",
"SZ",
"ZA"
],
"019": [
"003",
"005",
"013",
"019",
"019-status-grouping",
"021",
"029",
"419",
"AG",
"AI",
"AR",
"AW",
"BB",
"BL",
"BM",
"BO",
"BQ",
"BR",
"BS",
"BV",
"BZ",
"CA",
"CL",
"CO",
"CR",
"CU",
"CW",
"DM",
"DO",
"EC",
"FK",
"GD",
"GF",
"GL",
"GP",
"GS",
"GT",
"GY",
"HN",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"MX",
"NI",
"PA",
"PE",
"PM",
"PR",
"PY",
"SR",
"SV",
"SX",
"TC",
"TT",
"US",
"UY",
"VC",
"VE",
"VG",
"VI"
],
"021": [
"021",
"BM",
"CA",
"GL",
"PM",
"US"
],
"029": [
"029",
"AG",
"AI",
"AW",
"BB",
"BL",
"BQ",
"BS",
"CU",
"CW",
"DM",
"DO",
"GD",
"GP",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"PR",
"SX",
"TC",
"TT",
"VC",
"VG",
"VI"
],
"030": [
"030",
"CN",
"HK",
"JP",
"KP",
"KR",
"MN",
"MO",
"TW"
],
"034": [
"034",
"AF",
"BD",
"BT",
"IN",
"IR",
"LK",
"MV",
"NP",
"PK"
],
"035": [
"035",
"BN",
"ID",
"KH",
"LA",
"MM",
"MY",
"PH",
"SG",
"TH",
"TL",
"VN"
],
"039": [
"039",
"AD",
"AL",
"BA",
"ES",
"GI",
"GR",
"HR",
"IT",
"ME",
"MK",
"MT",
"PT",
"RS",
"SI",
"SM",
"VA",
"XK"
],
"053": [
"053",
"AU",
"CC",
"CX",
"HM",
"NF",
"NZ"
],
"054": [
"054",
"FJ",
"NC",
"PG",
"SB",
"VU"
],
"057": [
"057",
"FM",
"GU",
"KI",
"MH",
"MP",
"NR",
"PW",
"UM"
],
"061": [
"061",
"AS",
"CK",
"NU",
"PF",
"PN",
"TK",
"TO",
"TV",
"WF",
"WS"
],
"142": [
"030",
"034",
"035",
"142",
"143",
"145",
"AE",
"AF",
"AM",
"AZ",
"BD",
"BH",
"BN",
"BT",
"CN",
"CY",
"GE",
"HK",
"ID",
"IL",
"IN",
"IQ",
"IR",
"JO",
"JP",
"KG",
"KH",
"KP",
"KR",
"KW",
"KZ",
"LA",
"LB",
"LK",
"MM",
"MN",
"MO",
"MV",
"MY",
"NP",
"OM",
"PH",
"PK",
"PS",
"QA",
"SA",
"SG",
"SY",
"TH",
"TJ",
"TL",
"TM",
"TR",
"TW",
"UZ",
"VN",
"YE"
],
"143": [
"143",
"KG",
"KZ",
"TJ",
"TM",
"UZ"
],
"145": [
"145",
"AE",
"AM",
"AZ",
"BH",
"CY",
"GE",
"IL",
"IQ",
"JO",
"KW",
"LB",
"OM",
"PS",
"QA",
"SA",
"SY",
"TR",
"YE"
],
"150": [
"039",
"150",
"151",
"154",
"155",
"AD",
"AL",
"AT",
"AX",
"BA",
"BE",
"BG",
"BY",
"CH",
"CQ",
"CZ",
"DE",
"DK",
"EE",
"ES",
"FI",
"FO",
"FR",
"GB",
"GG",
"GI",
"GR",
"HR",
"HU",
"IE",
"IM",
"IS",
"IT",
"JE",
"LI",
"LT",
"LU",
"LV",
"MC",
"MD",
"ME",
"MK",
"MT",
"NL",
"NO",
"PL",
"PT",
"RO",
"RS",
"RU",
"SE",
"SI",
"SJ",
"SK",
"SM",
"UA",
"VA",
"XK"
],
"151": [
"151",
"BG",
"BY",
"CZ",
"HU",
"MD",
"PL",
"RO",
"RU",
"SK",
"UA"
],
"154": [
"154",
"AX",
"CQ",
"DK",
"EE",
"FI",
"FO",
"GB",
"GG",
"IE",
"IM",
"IS",
"JE",
"LT",
"LV",
"NO",
"SE",
"SJ"
],
"155": [
"155",
"AT",
"BE",
"CH",
"DE",
"FR",
"LI",
"LU",
"MC",
"NL"
],
"202": [
"011",
"014",
"017",
"018",
"202",
"AO",
"BF",
"BI",
"BJ",
"BW",
"CD",
"CF",
"CG",
"CI",
"CM",
"CV",
"DJ",
"ER",
"ET",
"GA",
"GH",
"GM",
"GN",
"GQ",
"GW",
"IO",
"KE",
"KM",
"LR",
"LS",
"MG",
"ML",
"MR",
"MU",
"MW",
"MZ",
"NA",
"NE",
"NG",
"RE",
"RW",
"SC",
"SH",
"SL",
"SN",
"SO",
"SS",
"ST",
"SZ",
"TD",
"TF",
"TG",
"TZ",
"UG",
"YT",
"ZA",
"ZM",
"ZW"
],
"419": [
"005",
"013",
"029",
"419",
"AG",
"AI",
"AR",
"AW",
"BB",
"BL",
"BO",
"BQ",
"BR",
"BS",
"BV",
"BZ",
"CL",
"CO",
"CR",
"CU",
"CW",
"DM",
"DO",
"EC",
"FK",
"GD",
"GF",
"GP",
"GS",
"GT",
"GY",
"HN",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"MX",
"NI",
"PA",
"PE",
"PR",
"PY",
"SR",
"SV",
"SX",
"TC",
"TT",
"UY",
"VC",
"VE",
"VG",
"VI"
],
"EU": [
"AT",
"BE",
"BG",
"CY",
"CZ",
"DE",
"DK",
"EE",
"ES",
"EU",
"FI",
"FR",
"GR",
"HR",
"HU",
"IE",
"IT",
"LT",
"LU",
"LV",
"MT",
"NL",
"PL",
"PT",
"RO",
"SE",
"SI",
"SK"
],
"EZ": [
"AT",
"BE",
"CY",
"DE",
"EE",
"ES",
"EZ",
"FI",
"FR",
"GR",
"IE",
"IT",
"LT",
"LU",
"LV",
"MT",
"NL",
"PT",
"SI",
"SK"
],
"QO": [
"AC",
"AQ",
"CP",
"DG",
"QO",
"TA"
],
"UN": [
"AD",
"AE",
"AF",
"AG",
"AL",
"AM",
"AO",
"AR",
"AT",
"AU",
"AZ",
"BA",
"BB",
"BD",
"BE",
"BF",
"BG",
"BH",
"BI",
"BJ",
"BN",
"BO",
"BR",
"BS",
"BT",
"BW",
"BY",
"BZ",
"CA",
"CD",
"CF",
"CG",
"CH",
"CI",
"CL",
"CM",
"CN",
"CO",
"CR",
"CU",
"CV",
"CY",
"CZ",
"DE",
"DJ",
"DK",
"DM",
"DO",
"DZ",
"EC",
"EE",
"EG",
"ER",
"ES",
"ET",
"FI",
"FJ",
"FM",
"FR",
"GA",
"GB",
"GD",
"GE",
"GH",
"GM",
"GN",
"GQ",
"GR",
"GT",
"GW",
"GY",
"HN",
"HR",
"HT",
"HU",
"ID",
"IE",
"IL",
"IN",
"IQ",
"IR",
"IS",
"IT",
"JM",
"JO",
"JP",
"KE",
"KG",
"KH",
"KI",
"KM",
"KN",
"KP",
"KR",
"KW",
"KZ",
"LA",
"LB",
"LC",
"LI",
"LK",
"LR",
"LS",
"LT",
"LU",
"LV",
"LY",
"MA",
"MC",
"MD",
"ME",
"MG",
"MH",
"MK",
"ML",
"MM",
"MN",
"MR",
"MT",
"MU",
"MV",
"MW",
"MX",
"MY",
"MZ",
"NA",
"NE",
"NG",
"NI",
"NL",
"NO",
"NP",
"NR",
"NZ",
"OM",
"PA",
"PE",
"PG",
"PH",
"PK",
"PL",
"PT",
"PW",
"PY",
"QA",
"RO",
"RS",
"RU",
"RW",
"SA",
"SB",
"SC",
"SD",
"SE",
"SG",
"SI",
"SK",
"SL",
"SM",
"SN",
"SO",
"SR",
"SS",
"ST",
"SV",
"SY",
"SZ",
"TD",
"TG",
"TH",
"TJ",
"TL",
"TM",
"TN",
"TO",
"TR",
"TT",
"TV",
"TZ",
"UA",
"UG",
"UN",
"US",
"UY",
"UZ",
"VC",
"VE",
"VN",
"VU",
"WS",
"YE",
"ZA",
"ZM",
"ZW"
]
};
const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
/**
* Asserts that a condition is true, throwing an error if it is not.
* Used for runtime validation and type narrowing.
*
* @param condition - The condition to check
* @param message - Error message if condition is false
* @param Err - Error constructor to use (defaults to Error)
* @throws {Error} When condition is false
*
* @example
* ```ts
* invariant(locale !== undefined, 'Locale must be defined')
* // locale is now narrowed to non-undefined type
* ```
*/
function invariant$3(condition, message, Err = Error) {
if (!condition) throw new Err(message);
}
const DEFAULT_MATCHING_THRESHOLD = 838;
let PROCESSED_DATA;
function processData() {
if (!PROCESSED_DATA) {
const paradigmLocales = data.supplemental.languageMatching["written-new"][0]?.paradigmLocales?._locales.split(" ");
const matchVariables = data.supplemental.languageMatching["written-new"].slice(1, 5);
PROCESSED_DATA = {
matches: data.supplemental.languageMatching["written-new"].slice(5).map((d) => {
const key = Object.keys(d)[0];
const value = d[key];
return {
supported: key,
desired: value._desired,
distance: +value._distance,
oneway: value.oneway === "true" ? true : false
};
}, {}),
matchVariables: matchVariables.reduce((all, d) => {
const key = Object.keys(d)[0];
const value = d[key];
all[key.slice(1)] = value._value.split("+");
return all;
}, {}),
paradigmLocales: [...paradigmLocales, ...paradigmLocales.map((l) => new Intl.Locale(l.replace(/_/g, "-")).maximize().toString())]
};
}
return PROCESSED_DATA;
}
function isMatched(locale, languageMatchInfoLocale, matchVariables) {
const [language, script, region] = languageMatchInfoLocale.split("-");
let matches = true;
if (region && region[0] === "$") {
const shouldInclude = region[1] !== "!";
const expandedMatchedRegions = (shouldInclude ? matchVariables[region.slice(1)] : matchVariables[region.slice(2)]).map((r) => regions[r] || [r]).reduce((all, list) => [...all, ...list], []);
matches &&= !(expandedMatchedRegions.indexOf(locale.region || "") > -1 != shouldInclude);
} else matches &&= locale.region ? region === "*" || region === locale.region : true;
matches &&= locale.script ? script === "*" || script === locale.script : true;
matches &&= locale.language ? language === "*" || language === locale.language : true;
return matches;
}
function serializeLSR(lsr) {
return [
lsr.language,
lsr.script,
lsr.region
].filter(Boolean).join("-");
}
function findMatchingDistanceForLSR(desired, supported, data) {
for (const d of data.matches) {
let matches = isMatched(desired, d.desired, data.matchVariables) && isMatched(supported, d.supported, data.matchVariables);
if (!d.oneway && !matches) matches = isMatched(desired, d.supported, data.matchVariables) && isMatched(supported, d.desired, data.matchVariables);
if (matches) {
const distance = d.distance * 10;
if (data.paradigmLocales.indexOf(serializeLSR(desired)) > -1 != data.paradigmLocales.indexOf(serializeLSR(supported)) > -1) return distance - 1;
return distance;
}
}
throw new Error("No matching distance found");
}
function findMatchingDistanceImpl(desired, supported) {
const desiredLocale = new Intl.Locale(desired).maximize();
const supportedLocale = new Intl.Locale(supported).maximize();
const desiredLSR = {
language: desiredLocale.language,
script: desiredLocale.script || "",
region: desiredLocale.region || ""
};
const supportedLSR = {
language: supportedLocale.language,
script: supportedLocale.script || "",
region: supportedLocale.region || ""
};
let matchingDistance = 0;
const data = processData();
if (desiredLSR.language !== supportedLSR.language) matchingDistance += findMatchingDistanceForLSR({
language: desiredLocale.language,
script: "",
region: ""
}, {
language: supportedLocale.language,
script: "",
region: ""
}, data);
if (desiredLSR.script !== supportedLSR.script) matchingDistance += findMatchingDistanceForLSR({
language: desiredLocale.language,
script: desiredLSR.script,
region: ""
}, {
language: supportedLocale.language,
script: supportedLSR.script,
region: ""
}, data);
if (desiredLSR.region !== supportedLSR.region) matchingDistance += findMatchingDistanceForLSR(desiredLSR, supportedLSR, data);
return matchingDistance;
}
/**
* Calculates the matching distance between two locales using the CLDR Enhanced Language Matching algorithm.
* This function is memoized for performance, as distance calculations are expensive.
*
* The distance represents how "far apart" two locales are, with 0 being identical (after maximization).
* Distances are calculated based on Language-Script-Region (LSR) differences using CLDR data.
*
* @param desired - The desired locale (e.g., "en-US")
* @param supported - The supported locale to compare against (e.g., "en-GB")
* @returns The calculated distance between the locales
*
* @example
* ```ts
* findMatchingDistance('en-US', 'en-US') // 0 - identical
* findMatchingDistance('en-US', 'en-GB') // 40 - same language/script, different region
* findMatchingDistance('es-CO', 'es-419') // 39 - regional variant
* findMatchingDistance('en', 'fr') // 840 - completely different languages
* ```
*
* @see https://unicode.org/reports/tr35/#EnhancedLanguageMatching
*/
const findMatchingDistance = memoize(findMatchingDistanceImpl, { serializer: (args) => `${args[0]}|${args[1]}` });
/**
* Generates fallback candidates by progressively removing subtags
* e.g., "en-US" -> ["en-US", "en"]
* "zh-Hans-CN" -> ["zh-Hans-CN", "zh-Hans", "zh"]
*/
function getFallbackCandidates(locale) {
const candidates = [];
let current = locale;
while (current) {
candidates.push(current);
const lastDash = current.lastIndexOf("-");
if (lastDash === -1) break;
current = current.substring(0, lastDash);
}
return candidates;
}
/**
* Finds the best locale match using a three-tier optimization hierarchy.
*
* ## Three-Tier Matching Algorithm:
*
* **Tier 1 - Fast Path** (O(n)): Exact string matching via Set lookup
* - Example: 'en' matches 'en' exactly → distance 0
* - Solves #4936: 48x faster than baseline (12ms vs 610ms with 700+ locales)
*
* **Tier 2 - Fallback Path** (O(k×n)): Maximization + progressive subtag removal
* - Maximizes requested locale, then removes subtags right-to-left
* - Example: "zh-TW" → "zh-Hant-TW" → ["zh-Hant-TW", "zh-Hant", "zh"]
* - Distance: 0 for maximized match, 10 per removed subtag + position penalty
* - 40-50x faster than full UTS #35, handles 99% of real-world cases correctly
*
* **Tier 3 - Slow Path** (O(n×m), memoized): Full UTS #35 CLDR matching
* - Calculates Language-Script-Region distances using CLDR data
* - Handles complex cases like cross-script matching (sr-Cyrl ↔ sr-Latn)
* - Only used when Tiers 1 & 2 find no match
* - Still 6x faster than baseline due to memoization
*
* ## Performance Impact of Maximization:
*
* While Tier 2 now calls `Intl.Locale().maximize()` once per requested locale,
* this is still much faster than Tier 3's full distance calculation:
* - Tier 1: ~12ms (exact match, no maximization)
* - Tier 2: ~13-15ms (maximization + fallback)
* - Tier 3: ~100ms+ (full UTS #35 with all supported locales)
*
* @param requestedLocales - Locale identifiers in preference order
* @param supportedLocales - Available locale identifiers
* @param threshold - Maximum distance (default: 838, from CLDR)
* @returns Matching result with distances
*
* @example
* ```ts
* // Tier 1: Exact match
* findBestMatch(['en'], ['en', 'fr'])
* // → { matchedSupportedLocale: 'en', distances: { en: { en: 0 } } }
*
* // Tier 2: Fallback with maximization
* findBestMatch(['zh-TW'], ['zh-Hant'])
* // → zh-TW maximizes to zh-Hant-TW, falls back to zh-Hant (distance 0)
*
* findBestMatch(['en-US'], ['en'])
* // → en-US maximizes to en-Latn-US, falls back to en (distance 10)
*
* // Tier 3: Full calculation
* findBestMatch(['en-XZ'], ['ja', 'ko'])
* // → No fallback match, uses UTS #35 to find closest match
* ```
*
* @see https://unicode.org/reports/tr35/#EnhancedLanguageMatching
* @see https://github.com/formatjs/formatjs/issues/4936
*/
const canonicalizedSupportedCache = /* @__PURE__ */ new WeakMap();
function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_MATCHING_THRESHOLD) {
let lowestDistance = Infinity;
let result = {
matchedDesiredLocale: "",
distances: {}
};
let canonicalizedSupportedLocales = canonicalizedSupportedCache.get(supportedLocales);
if (!canonicalizedSupportedLocales) {
canonicalizedSupportedLocales = supportedLocales.map((locale) => {
try {
return Intl.getCanonicalLocales([locale])[0] || locale;
} catch {
return locale;
}
});
canonicalizedSupportedCache.set(supportedLocales, canonicalizedSupportedLocales);
}
const supportedSet = new Set(canonicalizedSupportedLocales);
for (let i = 0; i < requestedLocales.length; i++) {
const desired = requestedLocales[i];
if (supportedSet.has(desired)) {
const distance = 0 + i * 40;
result.distances[desired] = { [desired]: distance };
if (distance < lowestDistance) {
lowestDistance = distance;
result.matchedDesiredLocale = desired;
result.matchedSupportedLocale = desired;
}
if (i === 0) return result;
}
}
for (let i = 0; i < requestedLocales.length; i++) {
const desired = requestedLocales[i];
try {
const maximized = new Intl.Locale(desired).maximize().toString();
if (maximized !== desired) {
const maximizedCandidates = getFallbackCandidates(maximized);
for (let j = 0; j < maximizedCandidates.length; j++) {
const candidate = maximizedCandidates[j];
if (candidate === desired) continue;
if (supportedSet.has(candidate)) {
let distance;
try {
distance = new Intl.Locale(candidate).maximize().toString() === maximized ? 0 + i * 40 : j * 10 + i * 40;
} catch {
distance = j * 10 + i * 40;
}
if (!result.distances[desired]) result.distances[desired] = {};
result.distances[desired][candidate] = distance;
if (distance < lowestDistance) {
lowestDistance = distance;
result.matchedDesiredLocale = desired;
result.matchedSupportedLocale = candidate;
}
break;
}
}
}
} catch {}
}
if (result.matchedSupportedLocale && lowestDistance === 0) return result;
lowestDistance = Infinity;
requestedLocales.forEach((desired, i) => {
if (!result.distances[desired]) result.distances[desired] = {};
canonicalizedSupportedLocales.forEach((canonicalLocale, supportedIndex) => {
const originalSupported = supportedLocales[supportedIndex];
const finalDistance = findMatchingDistance(desired, canonicalLocale) + 0 + i * 40;
result.distances[desired][originalSupported] = finalDistance;
if (finalDistance < lowestDistance) {
lowestDistance = finalDistance;
result.matchedDesiredLocale = desired;
result.matchedSupportedLocale = originalSupported;
}
});
});
if (lowestDistance >= threshold) {
result.matchedDesiredLocale = void 0;
result.matchedSupportedLocale = void 0;
}
return result;
}
/**
* https://tc39.es/ecma402/#sec-bestfitmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
let foundLocale;
let extension;
const noExtensionLocales = [];
const noExtensionLocaleMap = requestedLocales.reduce((all, l) => {
const noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
noExtensionLocales.push(noExtensionLocale);
all[noExtensionLocale] = l;
return all;
}, {});
const result = findBestMatch(noExtensionLocales, availableLocales);
if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
foundLocale = result.matchedSupportedLocale;
extension = noExtensionLocaleMap[result.matchedDesiredLocale].slice(result.matchedDesiredLocale.length) || void 0;
}
if (!foundLocale) return { locale: getDefaultLocale() };
return {
locale: foundLocale,
extension
};
}
function CanonicalizeUValue(ukey, uvalue) {
let lowerValue = uvalue.toLowerCase();
invariant$3(ukey !== void 0, `ukey must be defined`);
return lowerValue;
}
function CanonicalizeUnicodeLocaleId(locale) {
return Intl.getCanonicalLocales(locale)[0];
}
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
invariant$3(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
let extension = "-u";
for (const attr of attributes) extension += `-${attr}`;
for (const kw of keywords) {
const { key, value } = kw;
extension += `-${key}`;
if (value !== "") extension += `-${value}`;
}
if (extension === "-u") return CanonicalizeUnicodeLocaleId(locale);
let privateIndex = locale.indexOf("-x-");
let newLocale;
if (privateIndex === -1) newLocale = locale + extension;
else {
let preExtension = locale.slice(0, privateIndex);
let postExtension = locale.slice(privateIndex);
newLocale = preExtension + extension + postExtension;
}
return CanonicalizeUnicodeLocaleId(newLocale);
}
const availableLocalesSetCache = /* @__PURE__ */ new WeakMap();
/**
* https://tc39.es/ecma402/#sec-bestavailablelocale
* @param availableLocales
* @param locale
*/
function BestAvailableLocale(availableLocales, locale) {
let availableSet = availableLocalesSetCache.get(availableLocales);
if (!availableSet) {
availableSet = new Set(availableLocales);
availableLocalesSetCache.set(availableLocales, availableSet);
}
let candidate = locale;
while (true) {
if (availableSet.has(candidate)) return candidate;
let pos = candidate.lastIndexOf("-");
if (!~pos) return;
if (pos >= 2 && candidate[pos - 2] === "-") pos -= 2;
candidate = candidate.slice(0, pos);
}
}
/**
* https://tc39.es/ecma402/#sec-lookupmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
const result = { locale: "" };
for (const locale of requestedLocales) {
const noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
const availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
result.locale = availableLocale;
if (locale !== noExtensionLocale) result.extension = locale.slice(noExtensionLocale.length, locale.length);
return result;
}
}
result.locale = getDefaultLocale();
return result;
}
function UnicodeExtensionComponents(extension) {
invariant$3(extension === extension.toLowerCase(), "Expected extension to be lowercase");
invariant$3(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
const attributes = [];
const keywords = [];
let keyword;
let size = extension.length;
let k = 3;
while (k < size) {
let e = extension.indexOf("-", k);
let len;
if (e === -1) len = size - k;
else len = e - k;
let subtag = extension.slice(k, k + len);
invariant$3(len >= 2, "Expected a subtag to have at least 2 characters");
if (keyword === void 0 && len != 2) {
if (attributes.indexOf(subtag) === -1) attributes.push(subtag);
} else if (len === 2) {
keyword = {
key: subtag,
value: ""
};
if (keywords.find((k) => k.key === keyword?.key) === void 0) keywords.push(keyword);
} else if (keyword?.value === "") keyword.value = subtag;
else {
invariant$3(keyword !== void 0, "Expected keyword to be defined");
keyword.value += "-" + subtag;
}
k += len + 1;
}
return {
attributes,
keywords
};
}
/**
* https://tc39.es/ecma402/#sec-resolvelocale
*/
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
const matcher = options.localeMatcher;
let r;
if (matcher === "lookup") r = LookupMatcher(Array.from(availableLocales), requestedLocales, getDefaultLocale);
else r = BestFitMatcher(Array.from(availableLocales), requestedLocales, getDefaultLocale);
if (r == null) r = {
locale: getDefaultLocale(),
extension: ""
};
let foundLocale = r.locale;
let foundLocaleData = localeData[foundLocale];
const result = {
locale: "en",
dataLocale: foundLocale
};
let components;
let keywords;
if (r.extension) {
components = UnicodeExtensionComponents(r.extension);
keywords = components.keywords;
} else keywords = [];
let supportedKeywords = [];
for (const key of relevantExtensionKeys) {
let keyLocaleData = foundLocaleData?.[key] ?? [];
invariant$3(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
let value = keyLocaleData[0];
invariant$3(value === void 0 || typeof value === "string", `value must be a string or undefined`);
let supportedKeyword;
let entry = keywords.find((k) => k.key === key);
if (entry) {
let requestedValue = entry.value;
if (requestedValue !== "") {
if (keyLocaleData.indexOf(requestedValue) > -1) {
value = requestedValue;
supportedKeyword = {
key,
value
};
}
} else if (keyLocaleData.indexOf("true") > -1) {
value = "true";
supportedKeyword = {
key,
value
};
}
}
let optionsValue = options[key];
invariant$3(optionsValue == null || typeof optionsValue === "string", `optionsValue must be a string or undefined`);
if (typeof optionsValue === "string") {
optionsValue = CanonicalizeUValue(key.toLowerCase(), optionsValue);
if (optionsValue === "") optionsValue = "true";
}
if (optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
value = optionsValue;
supportedKeyword = void 0;
}
if (supportedKeyword) supportedKeywords.push(supportedKeyword);
result[key] = value;
}
let supportedAttributes = [];
if (supportedKeywords.length > 0) {
supportedAttributes = [];
foundLocale = InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords);
}
result.locale = foundLocale;
return result;
}
/**
* https://tc39.es/ecma402/#sec-lookupsupportedlocales
* @param availableLocales
* @param requestedLocales
*/
function LookupSupportedLocales(availableLocales, requestedLocales) {
const subset = [];
for (const locale of requestedLocales) {
const availableLocale = BestAvailableLocale(availableLocales, locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, ""));
if (availableLocale) subset.push(availableLocale);
}
return subset;
}
function match(requestedLocales, availableLocales, defaultLocale, opts) {
return ResolveLocale(availableLocales, CanonicalizeLocaleList(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
}
//#endregion
//#region packages/ecma262-abstract/ToObject.js
/**
* https://tc39.es/ecma262/#sec-toobject
*/
function ToObject(arg) {
if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
return Object(arg);
}
//#endregion
//#region packages/ecma262-abstract/ToString.js
/**
* https://tc39.es/ecma262/#sec-tostring
*/
function ToString(o) {
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
return String(o);
}
//#endregion
//#region packages/ecma402-abstract/GetOption.js
/**
* https://tc39.es/ecma402/#sec-getoption
* @param opts
* @param prop
* @param type
* @param values
* @param fallback
*/
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;
}
//#endregion
//#region packages/ecma402-abstract/SupportedLocales.js
/**
* https://tc39.es/ecma402/#sec-supportedlocales
* @param availableLocales
* @param requestedLocales
* @param options
*/
function SupportedLocales(availableLocales, requestedLocales, options) {
let matcher = "best fit";
if (options !== void 0) {
options = ToObject(options);
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
}
if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
}
//#endregion
//#region node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js
const DIV_PRECISION = 40;
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;
}
const 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: 1,
negativeZero: false
};
if (s === "Infinity" || s === "+Infinity") return {
mantissa: 0n,
exponent: 0,
special: 2,
negativeZero: false
};
if (s === "-Infinity") return {
mantissa: 0n,
exponent: 0,
special: 3,
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: 0,
negativeZero: negative
};
let mantissa = BigInt(combined);
if (negative) mantissa = -mantissa;
const [normMantissa, normExponent] = removeTrailingZeros(mantissa, exponent);
return {
mantissa: normMantissa,
exponent: normExponent,
special: 0,
negativeZero: false
};
}
var BigDecimal = class BigDecimal {
constructor(value) {
if (typeof value === "bigint") {
const [m, e] = removeTrailingZeros(value, 0);
this._mantissa = m;
this._exponent = e;
this._special = 0;
this._negativeZero = false;
return;
}
if (typeof value === "number") {
if (Number.isNaN(value)) {
this._mantissa = 0n;
this._exponent = 0;
this._special = 1;
this._negativeZero = false;
return;
}
if (value === Infinity) {
this._mantissa = 0n;
this._exponent = 0;
this._special = 2;
this._negativeZero = false;
return;
}
if (value === -Infinity) {
this._mantissa = 0n;
this._exponent = 0;
this._special = 3;
this._negativeZero = false;
return;
}
if (value === 0) {
this._mantissa = 0n;
this._exponent = 0;
this._special = 0;
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;
}
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;
}
static _coerce(v) {
return v instanceof BigDecimal ? v : new BigDecimal(v);
}
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, 0, negZero);
}
const [nm, ne] = removeTrailingZeros(this._mantissa * other._mantissa, this._exponent + other._exponent);
return BigDecimal._create(nm, ne, 0, 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, 1, false);
const neg = this._isSignNegative() !== other._isSignNegative();
return BigDecimal._create(0n, 0, neg ? 3 : 2, false);
}
if (this._mantissa === 0n) {
const negZero = this._isSignNegative() !== other._isSignNegative();
return BigDecimal._create(0n, 0, 0, negZero);
}
const [nm, ne] = removeTrailingZeros(this._mantissa * bigintPow10(DIV_PRECISION) / other._mantissa, this._exponent - other._exponent - DIV_PRECISION);
return BigDecimal._create(nm, ne, 0, 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, 0, 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, 0, false);
const [nm, ne] = removeTrailingZeros(sum, minE);
return BigDecimal._create(nm, ne, 0, 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 === 1 || other._special === 1) return BigDecimal._create(0n, 0, 1, false);
if (this._special === 2 || this._special === 3) return BigDecimal._create(0n, 0, 1, false);
if (other._special === 2 || other._special === 3) return this;
}
if (other._mantissa === 0n) return BigDecimal._create(0n, 0, 1, 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, 0, false);
const [nm, ne] = removeTrailingZeros(remainder, minE);
return BigDecimal._create(nm, ne, 0, false);
}
abs() {
if (this._special === 1) return this;
if (this._special === 3) return BigDecimal._create(0n, 0, 2, false);
return BigDecimal._create(bigintAbs(this._mantissa), this._exponent, this._special, false);
}
negated() {
if (this._special === 1) return this;
if (this._special === 2) return BigDecimal._create(0n, 0, 3, false);
if (this._special === 3) return BigDecimal._create(0n, 0, 2, false);
if (this._mantissa === 0n) return BigDecimal._create(0n, 0, 0, !this._negativeZero);
return BigDecimal._create(-this._mantissa, this._exponent, 0, false);
}
pow(n) {
if (this._special === 1) return this;
if (n === 0) return new BigDecimal(1);
if (n < 0) return new BigDecimal(1).div(this.pow(-n));
if (this._special === 2) return this;
if (this._special === 3) return n % 2 === 0 ? BigDecimal._create(0n, 0, 2, false) : this;
if (this._mantissa === 0n) return new BigDecimal(0);
const [nm, ne] = removeTrailingZeros(this._mantissa ** BigInt(n), this._exponent * n);
return BigDecimal._create(nm, ne, 0, false);
}
floor() {
if (this._special !== 0) 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, 0, negZero);
}
const [nm, ne] = removeTrailingZeros(q, 0);
return BigDecimal._create(nm, ne, 0, false);
}
ceil() {
if (this._special !== 0) 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, 0, false);
const [nm, ne] = removeTrailingZeros(q, 0);
return BigDecimal._create(nm, ne, 0, false);
}
log(base) {
if (this._special === 1) return this;
if (this._special === 3) return BigDecimal._create(0n, 0, 1, false);
if (this._special === 2) return BigDecimal._create(0n, 0, 2, false);
if (this._mantissa < 0n) return BigDecimal._create(0n, 0, 1, false);
if (this._mantissa === 0n) return BigDecimal._create(0n, 0, 3, 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);
}
eq(y) {
const other = BigDecimal._coerce(y);
if (this._special === 1 || other._special === 1) return false;
if (this._special !== other._special) return false;
if (this._special !== 0) 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 === 1 || other._special === 1) return NaN;
if (this._special === 2) return other._special === 2 ? 0 : 1;
if (this._special === 3) return other._special === 3 ? 0 : -1;
if (other._special === 2) return -1;
if (other._special === 3) 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;
if (thisNeg !== other._mantissa < 0n) 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) {
return this._compareTo(BigDecimal._coerce(y)) === -1;
}
greaterThan(y) {
return this._compareTo(BigDecimal._coerce(y)) === 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;
}
isZero() {
return this._special === 0 && this._mantissa === 0n;
}
isNaN() {
return this._special === 1;
}
isFinite() {
return this._special === 0;
}
isNegative() {
if (this._special === 1) return false;
if (this._special === 3) return true;
if (this._special === 2) return false;
if (this._mantissa === 0n) return this._negativeZero;
return this._mantissa < 0n;
}
isPositive() {
if (this._special === 1) return false;
if (this._special === 2) return true;
if (this._special === 3) return false;
if (this._mantissa === 0n) return !this._negativeZero;
return this._mantissa > 0n;
}
isInteger() {
if (this._special !== 0) return false;
if (this._mantissa === 0n) return true;
return this._exponent >= 0;
}
toJSON() {
return this.toString();
}
toNumber() {
if (this._special === 1) return NaN;
if (this._special === 2) return Infinity;
if (this._special === 3) return -Infinity;
if (this._mantissa === 0n) return this._negativeZero ? -0 : 0;
return Number(this.toString());
}
toString() {
if (this._special === 1) return "NaN";
if (this._special === 2) return "Infinity";
if (this._special === 3) 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 pow(base, exp) {
const n = typeof exp === "number" ? exp : exp.toNumber();
if (typeof base === "number" && base === 10) return BigDecimal._create(1n, n, 0, false);
return (base instanceof BigDecimal ? base : new BigDecimal(base)).pow(n);
}
static set(_config) {}
_isSignNegative() {
if (this._special === 3) 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 === 1 || b === 1) return BigDecimal._create(0n, 0, 1, false);
const aNeg = this._isSignNegative();
const bNeg = other._isSignNegative();
const aInf = a === 2 || a === 3;
const bInf = b === 2 || b === 3;
if (op === "times") {
if (aInf || bInf) {
if (aInf && other._mantissa === 0n && !bInf || bInf && this._mantissa === 0n && !aInf) return BigDecimal._create(0n, 0, 1, false);
const neg = aNeg !== bNeg;
return BigDecimal._create(0n, 0, neg ? 3 : 2, false);
}
}
if (op === "div") {
if (aInf && bInf) return BigDecimal._create(0n, 0, 1, false);
if (aInf) {
const neg = aNeg !== bNeg;
return BigDecimal._create(0n, 0, neg ? 3 : 2, false);
}
if (bInf) {
const negZero = aNeg !== bNeg;
return BigDecimal._create(0n, 0, 0, negZero);
}
}
if (op === "plus") {
if (aInf && bInf) {
if (aNeg !== bNeg) return BigDecimal._create(0n, 0, 1, false);
return this;
}
if (aInf) return this;
if (bInf) return other;
}
return BigDecimal._create(0n, 0, 1, false);
}
};
//#endregion
//#region packages/ecma262-abstract/ToPrimitive.js
function invariant$2(condition, message, Err = Error) {
if (!condition) throw new Err(message);
}
function IsCallable(fn) {
return typeof fn === "function";
}
function OrdinaryToPrimitive(O, hint) {
let methodNames;
if (hint === "string") methodNames = ["toString", "valueOf"];
else methodNames = ["valueOf", "toString"];
for (const name of methodNames) {
const method = O[name];
if (IsCallable(method)) {
let result = method.call(O);
if (typeof result !== "object") return result;
}
}
throw new TypeError("Cannot convert object to primitive value");
}
/**
* https://tc39.es/ecma262/#sec-toprimitive
*/
function ToPrimitive(input, preferredType) {
if (typeof input === "object" && input != null) {
const exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : void 0;
let hint;
if (exoticToPrim !== void 0) {
if (preferredType === void 0) hint = "default";
else if (preferredType === "string") hint = "string";
else {
invariant$2(preferredType === "number", "preferredType must be \"string\" or \"number\"");
hint = "number";
}
let result = exoticToPrim.call(input, hint);
if (typeof result !== "object") return result;
throw new TypeError("Cannot convert exotic object to primitive.");
}
if (preferredType === void 0) preferredType = "number";
return OrdinaryToPrimitive(input, preferredType);
}
return input;
}
//#endregion
//#region packages/ecma402-abstract/ToIntlMathematicalValue.js
/**
* https://tc39.es/ecma402/#sec-tointlmathematicalvalue
* Converts input to a mathematical value, supporting BigInt
*/
function ToIntlMathematicalValue(input) {
if (typeof input === "bigint") return new BigDecimal(input.toString());
let primValue = ToPrimitive(input, "number");
if (primValue === void 0) return new BigDecimal(NaN);
if (primValue === true) return new BigDecimal(1);
if (primValue === false) return new BigDecimal(0);
if (primValue === null) return new BigDecimal(0);
try {
return new BigDecimal(primValue);
} catch {
return new BigDecimal(NaN);
}
}
//#endregion
//#region packages/ecma402-abstract/CoerceOptionsToObject.js
/**
* https://tc39.es/ecma402/#sec-coerceoptionstoobject
* @param options
* @returns
*/
function CoerceOptionsToObject(options) {
if (typeof options === "undefined") return Object.create(null);
return ToObject(options);
}
//#endregion
//#region packages/ecma402-abstract/DefaultNumberOption.js
/**
* https://tc39.es/ecma402/#sec-defaultnumberoption
* @param val
* @param min
* @param max
* @param fallback
*/
function DefaultNumberOption(inputVal, min, max, fallback) {
if (inputVal === void 0) return fallback;
const val = Number(inputVal);
if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
return Math.floor(val);
}
//#endregion
//#region packages/ecma402-abstract/GetNumberOption.js
/**
* https://tc39.es/ecma402/#sec-getnumberoption
* @param options
* @param property
* @param min
* @param max
* @param fallback
*/
function GetNumberOption(options, property, minimum, maximum, fallback) {
const val = options[property];
return DefaultNumberOption(val, minimum, maximum, fallback);
}
//#endregion
//#region packages/ecma402-abstract/utils.js
function repeat(s, times) {
if (typeof s.repeat === "function") return s.repeat(times);
const arr = Array.from({ length: times });
for (let i = 0; i < arr.length; i++) arr[i] = s;
return arr.join("");
}
function defineProperty(target, name, { value }) {
Object.defineProperty(target, name, {
configurable: true,
enumerable: false,
writable: true,
value
});
}
function ensureIntl() {
if (typeof Intl === "undefined") Object.defineProperty(globalThis, "Intl", {
configurable: true,
enumerable: false,
writable: true,
value: {}
});
return Intl;
}
function invariant$1(condition, message, Err = Error) {
if (!condition) throw new Err(message);
}
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
//#endregion
//#region packages/ecma402-abstract/NumberFormat/SetNumberFormatDigitOptions.js
const VALID_ROUNDING_INCREMENTS = /* @__PURE__ */ new Set([
1,
2,
5,
10,
20,
25,
50,
100,
200,
250,
500,
1e3,
2e3,
2500,
5e3
]);
/**
* https://tc39.es/ecma402/#sec-setnfdigitoptions
*/
function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
const mnid = GetNumberOption(opts, "minimumIntegerDigits", 1, 21, 1);
let mnfd = opts.minimumFractionDigits;
let mxfd = opts.maximumFractionDigits;
let mnsd = opts.minimumSignificantDigits;
let mxsd = opts.maximumSignificantDigits;
internalSlots.minimumIntegerDigits = mnid;
const roundingIncrement = GetNumberOption(opts, "roundingIncrement", 1, 5e3, 1);
invariant$1(VALID_ROUNDING_INCREMENTS.has(roundingIncrement), `Invalid rounding increment value: ${roundingIncrement}.
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
const roundingMode = GetOption(opts, "roundingMode", "string", [
"ceil",
"floor",
"expand",
"trunc",
"halfCeil",
"halfFloor",
"halfExpand",
"halfTrunc",
"halfEven"
], "halfExpand");
const roundingPriority = GetOption(opts, "roundingPriority", "string", [
"auto",
"morePrecision",
"lessPrecision"
], "auto");
const trailingZeroDisplay = GetOption(opts, "trailingZeroDisplay", "string", ["auto", "stripIfInteger"], "auto");
if (roundingIncrement !== 1) mxfdDefault = mnfdDefault;
internalSlots.roundingIncrement = roundingIncrement;
internalSlots.roundingMode = roundingMode;
internalSlots.trailingZeroDisplay = trailingZeroDisplay;
const hasSd = mnsd !== void 0 || mxsd !== void 0;
const hasFd = mnfd !== void 0 || mxfd !== void 0;
let needSd = true;
let needFd = true;
if (roundingPriority === "auto") {
needSd = hasSd;
if (hasSd || !hasFd && notation === "compact") needFd = false;
}
if (needSd) if (hasSd) {
internalSlots.minimumSignificantDigits = DefaultNumberOption(mnsd, 1, 21, 1);
internalSlots.maximumSignificantDigits = DefaultNumberOption(mxsd, internalSlots.minimumSignificantDigits, 21, 21);
} else {
internalSlots.minimumSignificantDigits = 1;
internalSlots.maximumSignificantDigits = 21;
}
if (needFd) if (hasFd) {
mnfd = DefaultNumberOption(mnfd, 0, 100, void 0);
mxfd = DefaultNumberOption(mxfd, 0, 100, void 0);
if (mnfd === void 0) {
invariant$1(mxfd !== void 0, "maximumFractionDigits must be defined");
mnfd = Math.min(mnfdDefault, mxfd);
} else if (mxfd === void 0) mxfd = Math.max(mxfdDefault, mnfd);
else if (mnfd > mxfd) throw new RangeError(`Invalid range, ${mnfd} > ${mxfd}`);
internalSlots.minimumFractionDigits = mnfd;
internalSlots.maximumFractionDigits = mxfd;
} else {
internalSlots.minimumFractionDigits = mnfdDefault;
internalSlots.maximumFractionDigits = mxfdDefault;
}
if (!needSd && !needFd) {
internalSlots.minimumFractionDigits = 0;
internalSlots.maximumFractionDigits = 0;
internalSlots.minimumSignificantDigits = 1;
internalSlots.maximumSignificantDigits = 2;
internalSlots.roundingType = "morePrecision";
internalSlots.roundingPriority = "morePrecision";
} else if (roundingPriority === "morePrecision") {
internalSlots.roundingType = "morePrecision";
internalSlots.roundingPriority = "morePrecision";
} else if (roundingPriority === "lessPrecision") {
internalSlots.roundingType = "lessPrecision";
internalSlots.roundingPriority = "lessPrecision";
} else if (hasSd) {
internalSlots.roundingType = "significantDigits";
internalSlots.roundingPriority = "auto";
} else {
internalSlots.roundingType = "fractionDigits";
internalSlots.roundingPriority = "auto";
}
if (roundingIncrement !== 1) {
invariant$1(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeError);
invariant$1(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeError);
}
}
//#endregion
//#region packages/ecma402-abstract/PluralRules/InitializePluralRules.js
function InitializePluralRules(pl, locales, options, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots }) {
const requestedLocales = CanonicalizeLocaleList$1(locales);
const opt = Object.create(null);
const opts = CoerceOptionsToObject(options);
const internalSlots = getInternalSlots(pl);
internalSlots.initializedPluralRules = true;
opt.localeMatcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
internalSlots.locale = r.locale;
internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal");
const notation = GetOption(opts, "notation", "string", ["standard", "compact"], "standard");
internalSlots.notation = notation;
if (notation === "compact") {
internalSlots.compactDisplay = GetOption(opts, "compactDisplay", "string", ["short", "long"], "short");
if (typeof Intl !== "undefined" && Intl.NumberFormat && Intl.NumberFormat.localeData) internalSlots.dataLocaleData = Intl.NumberFormat.localeData[r.locale];
}
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, "standard");
return pl;
}
//#endregion
//#region packages/ecma262-abstract/Type.js
/**
* https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
*/
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";
}
//#endregion
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
/**
* Cached function to compute powers of 10 for Decimal.js operations.
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
* by memoizing expensive Decimal.pow(10, n) calculations.
*
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
* so caching provides substantial performance benefits.
*
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
*/
const getPowerOf10 = memoize((exponent) => {
return BigDecimal.pow(10, exponent);
});
//#endregion
//#region packages/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
/**
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
* number of the given magnitude (power of ten of the most significant digit) according to the
* locale and the desired notation (scientific, engineering, or compact).
*/
function ComputeExponentForMagnitude(internalSlots, magnitude) {
const { notation, dataLocaleData, numberingSystem } = internalSlots;
switch (notation) {
case "standard": return 0;
case "scientific": return magnitude.toNumber();
case "engineering": return magnitude.div(3).floor().times(3).toNumber();
default: {
invariant$1(notation === "compact", "Invalid notation");
const { compactDisplay, style, currencyDisplay } = internalSlots;
let thresholdMap;
if (style === "currency" && currencyDisplay !== "name") thresholdMap = (dataLocaleData.numbers.currency[numberingSystem] || dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]]).short;
else {
const decimal = dataLocaleData.numbers.decimal[numberingSystem] || dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
thresholdMap = compactDisplay === "long" ? decimal.long : decimal.short;
}
if (!thresholdMap) return 0;
const num = getPowerOf10(magnitude).toString();
const thresholds = Object.keys(thresholdMap);
if (num < thresholds[0]) return 0;
if (num > thresholds[thresholds.length - 1]) {
const magnitudeKey = thresholds[thresholds.length - 1];
if (thresholdMap[magnitudeKey].other === "0") return 0;
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
}
const i = thresholds.indexOf(num);
if (i === -1) return 0;
const magnitudeKey = thresholds[i];
if (thresholdMap[magnitudeKey].other === "0") return 0;
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
}
}
}
//#endregion
//#region packages/ecma402-abstract/constants.js
const ZERO$1 = new BigDecimal(0);
const NEGATIVE_ZERO = new BigDecimal(-0);
//#endregion
//#region packages/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js
const negativeMapping = {
ceil: "zero",
floor: "infinity",
expand: "infinity",
trunc: "zero",
halfCeil: "half-zero",
halfFloor: "half-infinity",
halfExpand: "half-infinity",
halfTrunc: "half-zero",
halfEven: "half-even"
};
const positiveMapping = {
ceil: "infinity",
floor: "zero",
expand: "infinity",
trunc: "zero",
halfCeil: "half-infinity",
halfFloor: "half-zero",
halfExpand: "half-infinity",
halfTrunc: "half-zero",
halfEven: "half-even"
};
function GetUnsignedRoundingMode(roundingMode, isNegative) {
if (isNegative) return negativeMapping[roundingMode];
return positiveMapping[roundingMode];
}
//#endregion
//#region packages/ecma402-abstract/NumberFormat/ApplyUnsignedRoundingMode.js
function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
if (x.eq(r1) || r1.eq(r2)) return r1;
if (x.eq(r2)) return r2;
invariant$1(r1.lessThan(x) && x.lessThan(r2), `x should be between r1 and r2 but x=${x}, r1=${r1}, r2=${r2}`);
if (unsignedRoundingMode === "zero") return r1;
if (unsignedRoundingMode === "infinity") return r2;
const d1 = x.minus(r1);
const d2 = r2.minus(x);
if (d1.lessThan(d2)) return r1;
if (d2.lessThan(d1)) return r2;
invariant$1(d1.eq(d2), "d1 should be equal to d2");
if (unsignedRoundingMode === "half-zero") return r1;
if (unsignedRoundingMode === "half-infinity") return r2;
invariant$1(unsignedRoundingMode === "half-even", "unsignedRoundingMode should be half-even");
if (r1.div(r2.minus(r1)).mod(2).isZero()) return r1;
return r2;
}
//#endregion
//#region packages/ecma402-abstract/NumberFormat/ToRawFixed.js
function ToRawFixedFn(n, f) {
return n.times(getPowerOf10(-f));
}
function findN1R1(x, f, roundingIncrement) {
const n1 = x.times(getPowerOf10(f)).floor().div(roundingIncrement).floor().times(roundingIncrement);
return {
n1,
r1: ToRawFixedFn(n1, f)
};
}
function findN2R2(x, f, roundingIncrement) {
const n2 = x.times(getPowerOf10(f)).ceil().div(roundingIncrement).ceil().times(roundingIncrement);
return {
n2,
r2: ToRawFixedFn(n2, f)
};
}
/**
* https://tc39.es/ecma402/#sec-torawfixed
* @param x a finite non-negative Number or BigInt
* @param minFraction an integer between 0 and 20
* @param maxFraction an integer between 0 and 20
*/
function ToRawFixed(x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode) {
const f = maxFraction;
const { n1, r1 } = findN1R1(x, f, roundingIncrement);
const { n2, r2 } = findN2R2(x, f, roundingIncrement);
const r = ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode);
let n, xFinal;
let m;
if (r.eq(r1)) {
n = n1;
xFinal = r1;
} else {
n = n2;
xFinal = r2;
}
if (n.isZero()) m = "0";
else m = n.toString();
let int;
if (f !== 0) {
let k = m.length;
if (k <= f) {
m = repeat("0", f - k + 1) + m;
k = f + 1;
}
const a = m.slice(0, k - f);
const b = m.slice(m.length - f);
m = a + "." + b;
int = a.length;
} else int = m.length;
let cut = maxFraction - minFraction;
while (cut > 0 && m[m.length - 1] === "0") {
m = m.slice(0, m.length - 1);
cut--;
}
if (m[m.length - 1] === ".") m = m.slice(0, m.length - 1);
return {
formattedString: m,
roundedNumber: xFinal,
integerDigitsCount: int,
roundingMagnitude: -f
};
}
//#endregion
//#region packages/ecma402-abstract/NumberFormat/ToRawPrecision.js
function findN1E1R1(x, p) {
const maxN1 = getPowerOf10(p);
const minN1 = getPowerOf10(p - 1);
let e1 = x.log(10).floor();
const divisor = getPowerOf10(e1.minus(p).plus(1));
let n1 = x.div(divisor).floor();
let r1 = n1.times(divisor);
if (n1.greaterThanOrEqualTo(maxN1)) {
e1 = e1.plus(1);
const newDivisor = getPowerOf10(e1.minus(p).plus(1));
n1 = x.div(newDivisor).floor();
r1 = n1.times(newDivisor);
} else if (n1.lessThan(minN1)) {
e1 = e1.minus(1);
const newDivisor = getPowerOf10(e1.minus(p).plus(1));
n1 = x.div(newDivisor).floor();
r1 = n1.times(newDivisor);
}
if (r1.lessThanOrEqualTo(x) && n1.lessThan(maxN1) && n1.greaterThanOrEqualTo(minN1)) return {
n1,
e1,
r1
};
let currentE1 = x.div(minN1).log(10).plus(p).minus(1).ceil();
while (true) {
const currentDivisor = getPowerOf10(currentE1.minus(p).plus(1));
let currentN1 = x.div(currentDivisor).floor();
if (currentN1.lessThan(maxN1) && currentN1.greaterThanOrEqualTo(minN1)) {
const currentR1 = currentN1.times(currentDivisor);
if (currentR1.lessThanOrEqualTo(x)) return {
n1: currentN1,
e1: currentE1,
r1: currentR1
};
}
currentE1 = currentE1.minus(1);
}
}
function findN2E2R2(x, p) {
const maxN2 = getPowerOf10(p);
const minN2 = getPowerOf10(p - 1);
let e2 = x.log(10).floor();
const divisor = getPowerOf10(e2.minus(p).plus(1));
let n2 = x.div(divisor).ceil();
let r2 = n2.times(divisor);
if (n2.greaterThanOrEqualTo(maxN2)) {
e2 = e2.plus(1);
const newDivisor = getPowerOf10(e2.minus(p).plus(1));
n2 = x.div(newDivisor).ceil();
r2 = n2.times(newDivisor);
} else if (n2.lessThan(minN2)) {
e2 = e2.minus(1);
const newDivisor = getPowerOf10(e2.minus(p).plus(1));
n2 = x.div(newDivisor).ceil();
r2 = n2.times(newDivisor);
}
if (r2.greaterThanOrEqualTo(x) && n2.lessThan(maxN2) && n2.greaterThanOrEqualTo(minN2)) return {
n2,
e2,
r2
};
let currentE2 = x.div(maxN2).log(10).plus(p).minus(1).floor();
while (true) {
const currentDivisor = getPowerOf10(currentE2.minus(p).plus(1));
let currentN2 = x.div(currentDivisor).ceil();
if (currentN2.lessThan(maxN2) && currentN2.greaterThanOrEqualTo(minN2)) {
const currentR2 = currentN2.times(currentDivisor);
if (currentR2.greaterThanOrEqualTo(x)) return {
n2: currentN2,
e2: currentE2,
r2: currentR2
};
}
currentE2 = currentE2.plus(1);
}
}
/**
* https://tc39.es/ecma402/#sec-torawprecision
* @param x a finite non-negative Number or BigInt
* @param minPrecision an integer between 1 and 21
* @param maxPrecision an integer between 1 and 21
*/
function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
const p = maxPrecision;
let m;
let e;
let xFinal;
if (x.isZero()) {
m = repeat("0", p);
e = 0;
xFinal = ZERO$1;
} else {
const { n1, e1, r1 } = findN1E1R1(x, p);
const { n2, e2, r2 } = findN2E2R2(x, p);
let r = ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode);
let n;
if (r.eq(r1)) {
n = n1;
e = e1.toNumber();
xFinal = r1;
} else {
n = n2;
e = e2.toNumber();
xFinal = r2;
}
m = n.toString();
}
let int;
if (e >= p - 1) {
m = m + repeat("0", e - p + 1);
int = e + 1;
} else if (e >= 0) {
m = m.slice(0, e + 1) + "." + m.slice(m.length - (p - (e + 1)));
int = e + 1;
} else {
invariant$1(e < 0, "e should be less than 0");
m = "0." + repeat("0", -e - 1) + m;
int = 1;
}
if (m.includes(".") && maxPrecision > minPrecision) {
let cut = maxPrecision - minPrecision;
while (cut > 0 && m[m.length - 1] === "0") {
m = m.slice(0, m.length - 1);
cut--;
}
if (m[m.length - 1] === ".") m = m.slice(0, m.length - 1);
}
return {
formattedString: m,
roundedNumber: xFinal,
integerDigitsCount: int,
roundingMagnitude: e
};
}
//#endregion
//#region packages/ecma402-abstract/NumberFormat/FormatNumericToString.js
/**
* https://tc39.es/ecma402/#sec-formatnumberstring
*/
function FormatNumericToString(intlObject, _x) {
let x = _x;
let sign;
if (x.isZero() && x.isNegative()) {
sign = "negative";
x = ZERO$1;
} else {
invariant$1(x.isFinite(), "NumberFormatDigitInternalSlots value is not finite");
if (x.lessThan(0)) sign = "negative";
else sign = "positive";
if (sign === "negative") x = x.negated();
}
let result;
const roundingType = intlObject.roundingType;
const unsignedRoundingMode = GetUnsignedRoundingMode(intlObject.roundingMode, sign === "negative");
switch (roundingType) {
case "significantDigits":
result = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
break;
case "fractionDigits":
result = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
break;
default:
let sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
let fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
if (intlObject.roundingType === "morePrecision") if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = sResult;
else result = fResult;
else {
invariant$1(intlObject.roundingType === "lessPrecision", "Invalid roundingType");
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = fResult;
else result = sResult;
}
break;
}
x = result.roundedNumber;
let string = result.formattedString;
if (intlObject.trailingZeroDisplay === "stripIfInteger" && x.isInteger()) {
let i = string.indexOf(".");
if (i > -1) string = string.slice(0, i);
}
const int = result.integerDigitsCount;
const minInteger = intlObject.minimumIntegerDigits;
if (int < minInteger) string = repeat("0", minInteger - int) + string;
if (sign === "negative") if (x.isZero()) x = NEGATIVE_ZERO;
else x = x.negated();
return {
roundedNumber: x,
formattedString: string
};
}
//#endregion
//#region packages/ecma262-abstract/ToNumber.js
const ZERO = new BigDecimal(0);
function invariant(condition, message, Err = Error) {
if (!condition) throw new Err(message);
}
/**
* https://tc39.es/ecma262/#sec-tonumber
*/
function ToNumber(arg) {
if (typeof arg === "number") return new BigDecimal(arg);
if (typeof arg === "bigint") return new BigDecimal(arg.toString());
invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
if (arg === void 0) return new BigDecimal(NaN);
if (arg === null || arg === 0) return ZERO;
if (arg === true) return new BigDecimal(1);
if (typeof arg === "string") try {
return new BigDecimal(arg);
} catch {
return new BigDecimal(NaN);
}
invariant(typeof arg === "object", "object expected", TypeError);
let primValue = ToPrimitive(arg, "number");
invariant(typeof primValue !== "object", "object expected", TypeError);
return ToNumber(primValue);
}
//#endregion
//#region packages/ecma402-abstract/PluralRules/GetOperands.js
/**
* ECMA-402 Spec: GetOperands abstract operation
* https://tc39.es/ecma402/#sec-getoperands
*
* Implementation: Extended to support compact exponent (c/e operands)
*
* @param s Formatted number string
* @param exponent Compact decimal exponent (c/e operand), defaults to 0
*/
function GetOperands(s, exponent = 0) {
invariant$1(typeof s === "string", `GetOperands should have been called with a string`);
const n = ToNumber(s);
invariant$1(n.isFinite(), "n should be finite");
let dp = s.indexOf(".");
let iv;
let f;
let v;
let fv = "";
if (dp === -1) {
iv = n;
f = ZERO$1;
v = 0;
} else {
iv = s.slice(0, dp);
fv = s.slice(dp, s.length);
f = ToNumber(fv);
v = fv.length;
}
const i = ToNumber(iv).abs();
let w;
let t;
if (!f.isZero()) {
const ft = fv.replace(/0+$/, "");
w = ft.length;
t = ToNumber(ft);
} else {
w = 0;
t = ZERO$1;
}
return {
Number: n,
IntegerDigits: i.lessThanOrEqualTo(Number.MAX_SAFE_INTEGER) && i.greaterThanOrEqualTo(-Number.MAX_SAFE_INTEGER) ? i.toNumber() : i.toString(),
NumberOfFractionDigits: v,
NumberOfFractionDigitsWithoutTrailing: w,
FractionDigits: f.toNumber(),
FractionDigitsWithoutTrailing: t.toNumber(),
CompactExponent: exponent
};
}
//#endregion
//#region packages/ecma402-abstract/PluralRules/ResolvePlural.js
/**
* ResolvePluralInternal ( pluralRules, n )
*
* Internal version of ResolvePlural that returns both the formatted string and plural category.
* This is needed for selectRange, which must compare formatted strings to determine if the
* start and end values are identical.
*
* The formatted string is obtained by applying the number formatting options (digit options)
* from the PluralRules object to the input number. This ensures that formatting-sensitive
* plural rules work correctly (e.g., rules that depend on visible fraction digits).
*
* @param pl - An initialized PluralRules object
* @param n - Mathematical value to resolve
* @returns Record containing the formatted string and plural category
*/
function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
const internalSlots = getInternalSlots(pl);
invariant$1(Type(internalSlots) === "Object", "pl has to be an object");
invariant$1("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
if (!n.isFinite()) return {
formattedString: String(n),
pluralCategory: "other"
};
const { locale, type, notation } = internalSlots;
const s = FormatNumericToString(internalSlots, n).formattedString;
let exponent = 0;
if (notation === "compact" && !n.isZero()) {
if (internalSlots.dataLocaleData?.numbers) try {
exponent = ComputeExponentForMagnitude(internalSlots, new BigDecimal(Math.floor(Math.log10(Math.abs(n.toNumber())))));
} catch {
exponent = 0;
}
}
return {
formattedString: s,
pluralCategory: PluralRuleSelect(locale, type, n, GetOperands(s, exponent))
};
}
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
* @param pl
* @param n
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
*/
function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
return ResolvePluralInternal(pl, n, {
getInternalSlots,
PluralRuleSelect
}).pluralCategory;
}
//#endregion
//#region packages/ecma402-abstract/PluralRules/ResolvePluralRange.js
/**
* ResolvePluralRange ( pluralRules, x, y )
*
* The ResolvePluralRange abstract operation is called with arguments pluralRules (which must be
* an object initialized as a PluralRules), x (a mathematical value), and y (a mathematical value).
* It resolves the appropriate plural form for a range by determining the plural forms of both the
* start and end values, then consulting locale-specific range data.
*
* Specification: https://tc39.es/ecma402/#sec-resolvepluralrange
*
* @param pluralRules - An initialized PluralRules object
* @param x - Mathematical value for the range start
* @param y - Mathematical value for the range end
* @returns The plural category for the range (zero, one, two, few, many, or other)
*/
function ResolvePluralRange(pluralRules, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }) {
if (!x.isFinite() || !y.isFinite()) throw new RangeError("selectRange requires start and end values to be finite numbers");
const internalSlots = getInternalSlots(pluralRules);
invariant$1(Type(internalSlots) === "Object", "pluralRules has to be an object");
invariant$1("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
const xp = ResolvePluralInternal(pluralRules, x, {
getInternalSlots,
PluralRuleSelect
});
const yp = ResolvePluralInternal(pluralRules, y, {
getInternalSlots,
PluralRuleSelect
});
if (xp.formattedString === yp.formattedString) return xp.pluralCategory;
const { locale, type } = internalSlots;
return PluralRuleSelectRange(locale, type, xp.pluralCategory, yp.pluralCategory);
}
//#endregion
//#region packages/intl-pluralrules/get_internal_slots.ts
const internalSlotMap = /* @__PURE__ */ new WeakMap();
function getInternalSlots(x) {
let internalSlots = internalSlotMap.get(x);
if (!internalSlots) {
internalSlots = Object.create(null);
internalSlotMap.set(x, internalSlots);
}
return internalSlots;
}
//#endregion
//#region packages/intl-pluralrules/index.ts
function validateInstance(instance, method) {
if (!(instance instanceof PluralRules)) throw new TypeError(`Method Intl.PluralRules.prototype.${method} called on incompatible receiver ${String(instance)}`);
}
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-pluralruleselect
* @param locale
* @param type
* @param _n
* @param param3
*/
function PluralRuleSelect(locale, type, _n, { IntegerDigits, NumberOfFractionDigits, FractionDigits, CompactExponent }) {
return PluralRules.localeData[locale].fn(NumberOfFractionDigits ? `${IntegerDigits}.${FractionDigits}` : String(IntegerDigits), type === "ordinal", CompactExponent);
}
/**
* PluralRuleSelectRange ( locale, type, notation, compactDisplay, start, end )
*
* Implementation-defined abstract operation that determines the plural category for a range
* by consulting CLDR plural range data. Each locale defines how different combinations of
* start and end plural categories map to a range plural category.
*
* Examples from CLDR:
* - English: "one" + "other" → "other" (e.g., "1-2 items")
* - French: "one" + "one" → "one" (e.g., "0-1 vue")
* - Arabic: "few" + "many" → "many" (e.g., complex range rules)
*
* The spec allows this to be implementation-defined, and we use CLDR supplemental data
* from pluralRanges.json which provides explicit mappings for each locale.
*
* @param locale - BCP 47 locale identifier
* @param type - "cardinal" or "ordinal"
* @param xp - Start plural category
* @param yp - End plural category
* @returns The plural category for the range
*/
function PluralRuleSelectRange(locale, type, xp, yp) {
const localeData = PluralRules.localeData[locale];
if (!localeData || !localeData.pluralRanges) return yp;
const key = `${xp}_${yp}`;
return (type === "ordinal" ? localeData.pluralRanges.ordinal : localeData.pluralRanges.cardinal)?.[key] ?? yp;
}
var PluralRules = class PluralRules {
constructor(locales, options) {
if (!(this && this instanceof PluralRules ? this.constructor : void 0)) throw new TypeError("Intl.PluralRules must be called with 'new'");
return InitializePluralRules(this, locales, options, {
availableLocales: PluralRules.availableLocales,
relevantExtensionKeys: PluralRules.relevantExtensionKeys,
localeData: PluralRules.localeData,
getDefaultLocale: PluralRules.getDefaultLocale,
getInternalSlots
});
}
resolvedOptions() {
validateInstance(this, "resolvedOptions");
const opts = Object.create(null);
const internalSlots = getInternalSlots(this);
opts.locale = internalSlots.locale;
opts.type = internalSlots.type;
[
"minimumIntegerDigits",
"minimumFractionDigits",
"maximumFractionDigits",
"minimumSignificantDigits",
"maximumSignificantDigits"
].forEach((field) => {
const val = internalSlots[field];
if (val !== void 0) opts[field] = val;
});
opts.pluralCategories = [...PluralRules.localeData[opts.locale].categories[opts.type]];
return opts;
}
select(val) {
validateInstance(this, "select");
const n = ToIntlMathematicalValue(val);
return ResolvePlural(this, n, {
getInternalSlots,
PluralRuleSelect
});
}
/**
* Intl.PluralRules.prototype.selectRange ( start, end )
*
* Returns a string indicating which plural rule applies to a range of numbers.
* This is useful for formatting ranges like "1-2 items" vs "2-3 items" where
* different languages have different plural rules for ranges.
*
* Specification: https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange
*
* @param start - The start value of the range (number or bigint)
* @param end - The end value of the range (number or bigint)
* @returns The plural category for the range (zero, one, two, few, many, or other)
*
* @example
* const pr = new Intl.PluralRules('en');
* pr.selectRange(1, 2); // "other" (English: "1-2 items")
* pr.selectRange(1, 1); // "one" (same value: "1 item")
*
* @example
* const prFr = new Intl.PluralRules('fr');
* prFr.selectRange(0, 1); // "one" (French: "0-1 vue")
* prFr.selectRange(1, 2); // "other" (French: "1-2 vues")
*
* @example
* // BigInt support (spec-compliant, but Chrome has a bug as of early 2025)
* pr.selectRange(BigInt(1), BigInt(2)); // "other"
*
* @throws {TypeError} If start or end is undefined
* @throws {RangeError} If start or end is not a finite number (Infinity, NaN)
*
* @note Chrome's native implementation (as of early 2025) has a bug where it throws
* "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
* a browser bug - the spec requires BigInt support. This polyfill handles BigInt correctly.
*/
selectRange(start, end) {
validateInstance(this, "selectRange");
if (start === void 0 || end === void 0) throw new TypeError("selectRange requires both start and end arguments");
const x = ToIntlMathematicalValue(start);
const y = ToIntlMathematicalValue(end);
return ResolvePluralRange(this, x, y, {
getInternalSlots,
PluralRuleSelect,
PluralRuleSelectRange
});
}
toString() {
return "[object Intl.PluralRules]";
}
static supportedLocalesOf(locales, options) {
return SupportedLocales(PluralRules.availableLocales, CanonicalizeLocaleList$1(locales), options);
}
static __addLocaleData(...data) {
for (const { data: d, locale } of data) {
PluralRules.localeData[locale] = d;
PluralRules.availableLocales.add(locale);
if (!PluralRules.__defaultLocale) PluralRules.__defaultLocale = locale;
}
}
static {
this.localeData = {};
}
static {
this.availableLocales = /* @__PURE__ */ new Set();
}
static {
this.__defaultLocale = "";
}
static getDefaultLocale() {
return PluralRules.__defaultLocale;
}
static {
this.relevantExtensionKeys = [];
}
static {
this.polyfilled = true;
}
};
try {
if (typeof Symbol !== "undefined") Object.defineProperty(PluralRules.prototype, Symbol.toStringTag, {
value: "Intl.PluralRules",
writable: false,
enumerable: false,
configurable: true
});
try {
Object.defineProperty(PluralRules, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true
});
} catch {}
Object.defineProperty(PluralRules.prototype.constructor, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true
});
Object.defineProperty(PluralRules.supportedLocalesOf, "length", {
value: 1,
writable: false,
enumerable: false,
configurable: true
});
Object.defineProperty(PluralRules, "name", {
value: "PluralRules",
writable: false,
enumerable: false,
configurable: true
});
} catch {}
//#endregion
//#region packages/intl-pluralrules/should-polyfill.ts
function supportedLocalesOf(locale) {
if (!locale) return true;
const locales = Array.isArray(locale) ? locale : [locale];
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length;
}
function shouldPolyfill(locale = "en") {
if (typeof Intl === "undefined" || !("PluralRules" in Intl) || new Intl.PluralRules("en", { minimumFractionDigits: 2 }).select(1) === "one" || !supportedLocalesOf(locale)) return locale ? match([locale], supportedLocales, "en") : void 0;
}
//#endregion
//#region packages/intl-pluralrules/polyfill.ts
const intl = ensureIntl();
if (shouldPolyfill()) {
defineProperty(intl, "PluralRules", { value: PluralRules });
const buf = globalThis.__FORMATJS_PLURALRULES_DATA__;
if (buf) {
for (const d of buf) PluralRules.__addLocaleData(d);
delete globalThis.__FORMATJS_PLURALRULES_DATA__;
}
}
//#endregion
//# sourceMappingURL=polyfill.iife.js.map