@formatjs/intl-pluralrules 6.3.13 → 6.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +9 -8
- package/index.js +519 -154
- package/index.js.map +1 -1
- package/locale-data/ca.js +2 -2
- package/locale-data/es.js +2 -2
- package/locale-data/fr.js +2 -2
- package/locale-data/it.js +2 -2
- package/locale-data/lld.js +2 -2
- package/locale-data/pt-PT.js +2 -2
- package/locale-data/pt.js +2 -2
- package/locale-data/scn.js +2 -2
- package/locale-data/vec.js +2 -2
- package/package.json +2 -2
- package/polyfill-force.d.ts +1 -1
- package/polyfill-force.js +519 -156
- package/polyfill-force.js.map +1 -1
- package/polyfill.d.ts +1 -1
- package/polyfill.iife.js +1018 -179
- package/polyfill.js +519 -154
- package/polyfill.js.map +1 -1
- package/should-polyfill.d.ts +1 -2
package/polyfill.iife.js
CHANGED
|
@@ -1,4 +1,391 @@
|
|
|
1
|
-
|
|
1
|
+
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-locales@0.0.0/node_modules/@formatjs_generated/cldr.supported-locales/default-content.js
|
|
2
|
+
const defaultContent = {
|
|
3
|
+
"aa": ["aa-ET"],
|
|
4
|
+
"ab": ["ab-GE"],
|
|
5
|
+
"af": ["af-ZA"],
|
|
6
|
+
"agq": ["agq-CM"],
|
|
7
|
+
"ak": ["ak-GH"],
|
|
8
|
+
"am": ["am-ET"],
|
|
9
|
+
"an": ["an-ES"],
|
|
10
|
+
"ann": ["ann-NG"],
|
|
11
|
+
"apc": ["apc-SY"],
|
|
12
|
+
"ar": ["ar-001"],
|
|
13
|
+
"arn": ["arn-CL"],
|
|
14
|
+
"as": ["as-IN"],
|
|
15
|
+
"asa": ["asa-TZ"],
|
|
16
|
+
"ast": ["ast-ES"],
|
|
17
|
+
"az-Arab": ["az-Arab-IR"],
|
|
18
|
+
"az-Cyrl": ["az-Cyrl-AZ"],
|
|
19
|
+
"az-Latn": ["az-Latn-AZ"],
|
|
20
|
+
"ba": ["ba-RU"],
|
|
21
|
+
"bal-Arab": ["bal-Arab-PK"],
|
|
22
|
+
"bal-Latn": ["bal-Latn-PK"],
|
|
23
|
+
"bas": ["bas-CM"],
|
|
24
|
+
"be": ["be-BY"],
|
|
25
|
+
"bem": ["bem-ZM"],
|
|
26
|
+
"bew": ["bew-ID"],
|
|
27
|
+
"bez": ["bez-TZ"],
|
|
28
|
+
"bg": ["bg-BG"],
|
|
29
|
+
"bgc": ["bgc-IN"],
|
|
30
|
+
"bgn": ["bgn-PK"],
|
|
31
|
+
"bho": ["bho-IN"],
|
|
32
|
+
"blo": ["blo-BJ"],
|
|
33
|
+
"blt": ["blt-VN"],
|
|
34
|
+
"bm": ["bm-ML"],
|
|
35
|
+
"bm-Nkoo": ["bm-Nkoo-ML"],
|
|
36
|
+
"bn": ["bn-BD"],
|
|
37
|
+
"bo": ["bo-CN"],
|
|
38
|
+
"bqi": ["bqi-IR"],
|
|
39
|
+
"br": ["br-FR"],
|
|
40
|
+
"brx": ["brx-IN"],
|
|
41
|
+
"bs-Cyrl": ["bs-Cyrl-BA"],
|
|
42
|
+
"bs-Latn": ["bs-Latn-BA"],
|
|
43
|
+
"bss": ["bss-CM"],
|
|
44
|
+
"bua": ["bua-RU"],
|
|
45
|
+
"byn": ["byn-ER"],
|
|
46
|
+
"ca": ["ca-ES"],
|
|
47
|
+
"cad": ["cad-US"],
|
|
48
|
+
"cch": ["cch-NG"],
|
|
49
|
+
"ccp": ["ccp-BD"],
|
|
50
|
+
"ce": ["ce-RU"],
|
|
51
|
+
"ceb": ["ceb-PH"],
|
|
52
|
+
"cgg": ["cgg-UG"],
|
|
53
|
+
"cho": ["cho-US"],
|
|
54
|
+
"chr": ["chr-US"],
|
|
55
|
+
"cic": ["cic-US"],
|
|
56
|
+
"ckb": ["ckb-IQ"],
|
|
57
|
+
"co": ["co-FR"],
|
|
58
|
+
"cop": ["cop-EG"],
|
|
59
|
+
"cs": ["cs-CZ"],
|
|
60
|
+
"csw": ["csw-CA"],
|
|
61
|
+
"cu": ["cu-RU"],
|
|
62
|
+
"cv": ["cv-RU"],
|
|
63
|
+
"cy": ["cy-GB"],
|
|
64
|
+
"da": ["da-DK"],
|
|
65
|
+
"dav": ["dav-KE"],
|
|
66
|
+
"de": ["de-DE"],
|
|
67
|
+
"dje": ["dje-NE"],
|
|
68
|
+
"doi": ["doi-IN"],
|
|
69
|
+
"dsb": ["dsb-DE"],
|
|
70
|
+
"dua": ["dua-CM"],
|
|
71
|
+
"dv": ["dv-MV"],
|
|
72
|
+
"dyo": ["dyo-SN"],
|
|
73
|
+
"dz": ["dz-BT"],
|
|
74
|
+
"ebu": ["ebu-KE"],
|
|
75
|
+
"ee": ["ee-GH"],
|
|
76
|
+
"el": ["el-GR"],
|
|
77
|
+
"en-Dsrt": ["en-Dsrt-US"],
|
|
78
|
+
"en-Shaw": ["en-Shaw-GB"],
|
|
79
|
+
"en": ["en-US"],
|
|
80
|
+
"eo": ["eo-001"],
|
|
81
|
+
"es": ["es-ES"],
|
|
82
|
+
"et": ["et-EE"],
|
|
83
|
+
"eu": ["eu-ES"],
|
|
84
|
+
"ewo": ["ewo-CM"],
|
|
85
|
+
"fa": ["fa-IR"],
|
|
86
|
+
"ff-Adlm": ["ff-Adlm-GN"],
|
|
87
|
+
"ff-Latn": ["ff-Latn-SN"],
|
|
88
|
+
"fi": ["fi-FI"],
|
|
89
|
+
"fil": ["fil-PH"],
|
|
90
|
+
"fo": ["fo-FO"],
|
|
91
|
+
"fr": ["fr-FR"],
|
|
92
|
+
"frr": ["frr-DE"],
|
|
93
|
+
"fur": ["fur-IT"],
|
|
94
|
+
"fy": ["fy-NL"],
|
|
95
|
+
"ga": ["ga-IE"],
|
|
96
|
+
"gaa": ["gaa-GH"],
|
|
97
|
+
"gd": ["gd-GB"],
|
|
98
|
+
"gez": ["gez-ET"],
|
|
99
|
+
"gl": ["gl-ES"],
|
|
100
|
+
"gn": ["gn-PY"],
|
|
101
|
+
"gsw": ["gsw-CH"],
|
|
102
|
+
"gu": ["gu-IN"],
|
|
103
|
+
"guz": ["guz-KE"],
|
|
104
|
+
"gv": ["gv-IM"],
|
|
105
|
+
"ha-Arab": ["ha-Arab-NG"],
|
|
106
|
+
"ha": ["ha-NG"],
|
|
107
|
+
"haw": ["haw-US"],
|
|
108
|
+
"he": ["he-IL"],
|
|
109
|
+
"hi": ["hi-IN"],
|
|
110
|
+
"hi-Latn": ["hi-Latn-IN"],
|
|
111
|
+
"hnj-Hmnp": ["hnj-Hmnp-US"],
|
|
112
|
+
"hr": ["hr-HR"],
|
|
113
|
+
"hsb": ["hsb-DE"],
|
|
114
|
+
"ht": ["ht-HT"],
|
|
115
|
+
"hu": ["hu-HU"],
|
|
116
|
+
"hy": ["hy-AM"],
|
|
117
|
+
"ia": ["ia-001"],
|
|
118
|
+
"id": ["id-ID"],
|
|
119
|
+
"ie": ["ie-EE"],
|
|
120
|
+
"ig": ["ig-NG"],
|
|
121
|
+
"ii": ["ii-CN"],
|
|
122
|
+
"io": ["io-001"],
|
|
123
|
+
"is": ["is-IS"],
|
|
124
|
+
"it": ["it-IT"],
|
|
125
|
+
"iu": ["iu-CA"],
|
|
126
|
+
"iu-Latn": ["iu-Latn-CA"],
|
|
127
|
+
"ja": ["ja-JP"],
|
|
128
|
+
"jbo": ["jbo-001"],
|
|
129
|
+
"jgo": ["jgo-CM"],
|
|
130
|
+
"jmc": ["jmc-TZ"],
|
|
131
|
+
"jv": ["jv-ID"],
|
|
132
|
+
"ka": ["ka-GE"],
|
|
133
|
+
"kaa-Cyrl": ["kaa-Cyrl-UZ"],
|
|
134
|
+
"kaa-Latn": ["kaa-Latn-UZ"],
|
|
135
|
+
"kab": ["kab-DZ"],
|
|
136
|
+
"kaj": ["kaj-NG"],
|
|
137
|
+
"kam": ["kam-KE"],
|
|
138
|
+
"kcg": ["kcg-NG"],
|
|
139
|
+
"kde": ["kde-TZ"],
|
|
140
|
+
"kea": ["kea-CV"],
|
|
141
|
+
"kek": ["kek-GT"],
|
|
142
|
+
"ken": ["ken-CM"],
|
|
143
|
+
"kgp": ["kgp-BR"],
|
|
144
|
+
"khq": ["khq-ML"],
|
|
145
|
+
"ki": ["ki-KE"],
|
|
146
|
+
"kk-Arab": ["kk-Arab-CN"],
|
|
147
|
+
"kk-Cyrl": ["kk-Cyrl-KZ"],
|
|
148
|
+
"kkj": ["kkj-CM"],
|
|
149
|
+
"kl": ["kl-GL"],
|
|
150
|
+
"kln": ["kln-KE"],
|
|
151
|
+
"km": ["km-KH"],
|
|
152
|
+
"kn": ["kn-IN"],
|
|
153
|
+
"ko": ["ko-KR"],
|
|
154
|
+
"kok-Deva": ["kok-Deva-IN"],
|
|
155
|
+
"kok-Latn": ["kok-Latn-IN"],
|
|
156
|
+
"kpe": ["kpe-LR"],
|
|
157
|
+
"ks-Arab": ["ks-Arab-IN"],
|
|
158
|
+
"ks-Deva": ["ks-Deva-IN"],
|
|
159
|
+
"ksb": ["ksb-TZ"],
|
|
160
|
+
"ksf": ["ksf-CM"],
|
|
161
|
+
"ksh": ["ksh-DE"],
|
|
162
|
+
"ku-Arab": ["ku-Arab-IQ"],
|
|
163
|
+
"ku-Latn": ["ku-Latn-TR"],
|
|
164
|
+
"kw": ["kw-GB"],
|
|
165
|
+
"kxv-Deva": ["kxv-Deva-IN"],
|
|
166
|
+
"kxv-Latn": ["kxv-Latn-IN"],
|
|
167
|
+
"kxv-Orya": ["kxv-Orya-IN"],
|
|
168
|
+
"kxv-Telu": ["kxv-Telu-IN"],
|
|
169
|
+
"ky": ["ky-KG"],
|
|
170
|
+
"la": ["la-VA"],
|
|
171
|
+
"lag": ["lag-TZ"],
|
|
172
|
+
"lb": ["lb-LU"],
|
|
173
|
+
"lg": ["lg-UG"],
|
|
174
|
+
"lij": ["lij-IT"],
|
|
175
|
+
"lkt": ["lkt-US"],
|
|
176
|
+
"lld": ["lld-IT"],
|
|
177
|
+
"lmo": ["lmo-IT"],
|
|
178
|
+
"ln": ["ln-CD"],
|
|
179
|
+
"lo": ["lo-LA"],
|
|
180
|
+
"lrc": ["lrc-IR"],
|
|
181
|
+
"lt": ["lt-LT"],
|
|
182
|
+
"ltg": ["ltg-LV"],
|
|
183
|
+
"lu": ["lu-CD"],
|
|
184
|
+
"luo": ["luo-KE"],
|
|
185
|
+
"luy": ["luy-KE"],
|
|
186
|
+
"lv": ["lv-LV"],
|
|
187
|
+
"lzz": ["lzz-TR"],
|
|
188
|
+
"mai": ["mai-IN"],
|
|
189
|
+
"mas": ["mas-KE"],
|
|
190
|
+
"mdf": ["mdf-RU"],
|
|
191
|
+
"mer": ["mer-KE"],
|
|
192
|
+
"mfe": ["mfe-MU"],
|
|
193
|
+
"mg": ["mg-MG"],
|
|
194
|
+
"mgh": ["mgh-MZ"],
|
|
195
|
+
"mgo": ["mgo-CM"],
|
|
196
|
+
"mhn": ["mhn-IT"],
|
|
197
|
+
"mi": ["mi-NZ"],
|
|
198
|
+
"mic": ["mic-CA"],
|
|
199
|
+
"mk": ["mk-MK"],
|
|
200
|
+
"ml": ["ml-IN"],
|
|
201
|
+
"mn": ["mn-MN"],
|
|
202
|
+
"mn-Mong": ["mn-Mong-CN"],
|
|
203
|
+
"mni-Beng": ["mni-Beng-IN"],
|
|
204
|
+
"mni-Mtei": ["mni-Mtei-IN"],
|
|
205
|
+
"moh": ["moh-CA"],
|
|
206
|
+
"mr": ["mr-IN"],
|
|
207
|
+
"ms-Arab": ["ms-Arab-MY"],
|
|
208
|
+
"ms": ["ms-MY"],
|
|
209
|
+
"mt": ["mt-MT"],
|
|
210
|
+
"mua": ["mua-CM"],
|
|
211
|
+
"mus": ["mus-US"],
|
|
212
|
+
"mww-Hmnp": ["mww-Hmnp-US"],
|
|
213
|
+
"my": ["my-MM"],
|
|
214
|
+
"myv": ["myv-RU"],
|
|
215
|
+
"mzn": ["mzn-IR"],
|
|
216
|
+
"naq": ["naq-NA"],
|
|
217
|
+
"nb": ["nb-NO"],
|
|
218
|
+
"nd": ["nd-ZW"],
|
|
219
|
+
"nds": ["nds-DE"],
|
|
220
|
+
"ne": ["ne-NP"],
|
|
221
|
+
"nl": ["nl-NL"],
|
|
222
|
+
"nmg": ["nmg-CM"],
|
|
223
|
+
"nn": ["nn-NO"],
|
|
224
|
+
"nnh": ["nnh-CM"],
|
|
225
|
+
"nqo": ["nqo-GN"],
|
|
226
|
+
"nr": ["nr-ZA"],
|
|
227
|
+
"nso": ["nso-ZA"],
|
|
228
|
+
"nus": ["nus-SS"],
|
|
229
|
+
"nv": ["nv-US"],
|
|
230
|
+
"ny": ["ny-MW"],
|
|
231
|
+
"nyn": ["nyn-UG"],
|
|
232
|
+
"oc": ["oc-FR"],
|
|
233
|
+
"oka": ["oka-CA"],
|
|
234
|
+
"om": ["om-ET"],
|
|
235
|
+
"or": ["or-IN"],
|
|
236
|
+
"os": ["os-GE"],
|
|
237
|
+
"osa": ["osa-US"],
|
|
238
|
+
"pa-Arab": ["pa-Arab-PK"],
|
|
239
|
+
"pa-Guru": ["pa-Guru-IN"],
|
|
240
|
+
"pap": ["pap-CW"],
|
|
241
|
+
"pcm": ["pcm-NG"],
|
|
242
|
+
"pi-Latn": ["pi-Latn-GB"],
|
|
243
|
+
"pis": ["pis-SB"],
|
|
244
|
+
"pl": ["pl-PL"],
|
|
245
|
+
"pms": ["pms-IT"],
|
|
246
|
+
"prg": ["prg-PL"],
|
|
247
|
+
"ps": ["ps-AF"],
|
|
248
|
+
"pt": ["pt-BR"],
|
|
249
|
+
"qu": ["qu-PE"],
|
|
250
|
+
"quc": ["quc-GT"],
|
|
251
|
+
"raj": ["raj-IN"],
|
|
252
|
+
"rhg-Rohg": ["rhg-Rohg-MM"],
|
|
253
|
+
"rif": ["rif-MA"],
|
|
254
|
+
"rm": ["rm-CH"],
|
|
255
|
+
"rn": ["rn-BI"],
|
|
256
|
+
"ro": ["ro-RO"],
|
|
257
|
+
"rof": ["rof-TZ"],
|
|
258
|
+
"ru": ["ru-RU"],
|
|
259
|
+
"rw": ["rw-RW"],
|
|
260
|
+
"rwk": ["rwk-TZ"],
|
|
261
|
+
"sa": ["sa-IN"],
|
|
262
|
+
"sah": ["sah-RU"],
|
|
263
|
+
"saq": ["saq-KE"],
|
|
264
|
+
"sat-Deva": ["sat-Deva-IN"],
|
|
265
|
+
"sat-Olck": ["sat-Olck-IN"],
|
|
266
|
+
"sbp": ["sbp-TZ"],
|
|
267
|
+
"sc": ["sc-IT"],
|
|
268
|
+
"scn": ["scn-IT"],
|
|
269
|
+
"sd-Arab": ["sd-Arab-PK"],
|
|
270
|
+
"sd-Deva": ["sd-Deva-IN"],
|
|
271
|
+
"sdh": ["sdh-IR"],
|
|
272
|
+
"se": ["se-NO"],
|
|
273
|
+
"seh": ["seh-MZ"],
|
|
274
|
+
"ses": ["ses-ML"],
|
|
275
|
+
"sg": ["sg-CF"],
|
|
276
|
+
"sgs": ["sgs-LT"],
|
|
277
|
+
"shi-Latn": ["shi-Latn-MA"],
|
|
278
|
+
"shi-Tfng": ["shi-Tfng-MA"],
|
|
279
|
+
"shn": ["shn-MM"],
|
|
280
|
+
"si": ["si-LK"],
|
|
281
|
+
"sid": ["sid-ET"],
|
|
282
|
+
"sk": ["sk-SK"],
|
|
283
|
+
"skr": ["skr-PK"],
|
|
284
|
+
"sl": ["sl-SI"],
|
|
285
|
+
"sma": ["sma-SE"],
|
|
286
|
+
"smj": ["smj-SE"],
|
|
287
|
+
"smn": ["smn-FI"],
|
|
288
|
+
"sms": ["sms-FI"],
|
|
289
|
+
"sn": ["sn-ZW"],
|
|
290
|
+
"so": ["so-SO"],
|
|
291
|
+
"sq": ["sq-AL"],
|
|
292
|
+
"sr-Cyrl": ["sr-Cyrl-RS"],
|
|
293
|
+
"sr-Latn": ["sr-Latn-RS"],
|
|
294
|
+
"ss": ["ss-ZA"],
|
|
295
|
+
"ssy": ["ssy-ER"],
|
|
296
|
+
"st": ["st-ZA"],
|
|
297
|
+
"su-Latn": ["su-Latn-ID"],
|
|
298
|
+
"suz-Deva": ["suz-Deva-NP"],
|
|
299
|
+
"suz-Sunu": ["suz-Sunu-NP"],
|
|
300
|
+
"sv": ["sv-SE"],
|
|
301
|
+
"sw": ["sw-TZ"],
|
|
302
|
+
"syr": ["syr-IQ"],
|
|
303
|
+
"szl": ["szl-PL"],
|
|
304
|
+
"ta": ["ta-IN"],
|
|
305
|
+
"te": ["te-IN"],
|
|
306
|
+
"teo": ["teo-UG"],
|
|
307
|
+
"tg": ["tg-TJ"],
|
|
308
|
+
"th": ["th-TH"],
|
|
309
|
+
"ti": ["ti-ET"],
|
|
310
|
+
"tig": ["tig-ER"],
|
|
311
|
+
"tk": ["tk-TM"],
|
|
312
|
+
"tn": ["tn-ZA"],
|
|
313
|
+
"to": ["to-TO"],
|
|
314
|
+
"tok": ["tok-001"],
|
|
315
|
+
"tpi": ["tpi-PG"],
|
|
316
|
+
"tr": ["tr-TR"],
|
|
317
|
+
"trv": ["trv-TW"],
|
|
318
|
+
"trw": ["trw-PK"],
|
|
319
|
+
"ts": ["ts-ZA"],
|
|
320
|
+
"tt": ["tt-RU"],
|
|
321
|
+
"twq": ["twq-NE"],
|
|
322
|
+
"tyv": ["tyv-RU"],
|
|
323
|
+
"tzm": ["tzm-MA"],
|
|
324
|
+
"ug": ["ug-CN"],
|
|
325
|
+
"uk": ["uk-UA"],
|
|
326
|
+
"ur": ["ur-PK"],
|
|
327
|
+
"uz-Arab": ["uz-Arab-AF"],
|
|
328
|
+
"uz-Cyrl": ["uz-Cyrl-UZ"],
|
|
329
|
+
"uz-Latn": ["uz-Latn-UZ"],
|
|
330
|
+
"vai-Latn": ["vai-Latn-LR"],
|
|
331
|
+
"vai-Vaii": ["vai-Vaii-LR"],
|
|
332
|
+
"ve": ["ve-ZA"],
|
|
333
|
+
"vec": ["vec-IT"],
|
|
334
|
+
"vi": ["vi-VN"],
|
|
335
|
+
"vmw": ["vmw-MZ"],
|
|
336
|
+
"vo": ["vo-001"],
|
|
337
|
+
"vun": ["vun-TZ"],
|
|
338
|
+
"wa": ["wa-BE"],
|
|
339
|
+
"wae": ["wae-CH"],
|
|
340
|
+
"wal": ["wal-ET"],
|
|
341
|
+
"wbp": ["wbp-AU"],
|
|
342
|
+
"wo": ["wo-SN"],
|
|
343
|
+
"xh": ["xh-ZA"],
|
|
344
|
+
"xnr": ["xnr-IN"],
|
|
345
|
+
"xog": ["xog-UG"],
|
|
346
|
+
"yav": ["yav-CM"],
|
|
347
|
+
"yi": ["yi-UA"],
|
|
348
|
+
"yo": ["yo-NG"],
|
|
349
|
+
"yrl": ["yrl-BR"],
|
|
350
|
+
"yue-Hans": ["yue-Hans-CN"],
|
|
351
|
+
"yue-Hant": ["yue-Hant-HK"],
|
|
352
|
+
"za": ["za-CN"],
|
|
353
|
+
"zgh": ["zgh-MA"],
|
|
354
|
+
"zh-Hans": ["zh-Hans-CN"],
|
|
355
|
+
"zh-Hant": ["zh-Hant-TW"],
|
|
356
|
+
"zh-Latn": ["zh-Latn-CN"],
|
|
357
|
+
"zu": ["zu-ZA"]
|
|
358
|
+
};
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region packages/ecma402-abstract/registerLocaleData.js
|
|
361
|
+
const explicitLocales = /* @__PURE__ */ new WeakMap();
|
|
362
|
+
function registerLocaleData(locale, data, localeData, availableLocales) {
|
|
363
|
+
let loaded = explicitLocales.get(localeData);
|
|
364
|
+
if (!loaded) {
|
|
365
|
+
loaded = /* @__PURE__ */ new Set();
|
|
366
|
+
explicitLocales.set(localeData, loaded);
|
|
367
|
+
}
|
|
368
|
+
loaded.add(locale);
|
|
369
|
+
const locales = [locale, ...defaultContent[locale] || []];
|
|
370
|
+
for (const tag of locales) {
|
|
371
|
+
if (tag === locale || !loaded.has(tag) || localeData[tag] === void 0) localeData[tag] = data;
|
|
372
|
+
availableLocales.add(tag);
|
|
373
|
+
}
|
|
374
|
+
for (const tag of locales) {
|
|
375
|
+
const parts = tag.split("-");
|
|
376
|
+
const fallbacks = [];
|
|
377
|
+
while (parts.length > 1) {
|
|
378
|
+
if (parts.length > 2 && parts[1].length === 4) fallbacks.push([parts[0], ...parts.slice(2)].join("-"));
|
|
379
|
+
parts.pop();
|
|
380
|
+
fallbacks.push(parts.join("-"));
|
|
381
|
+
}
|
|
382
|
+
for (const fallback of fallbacks) {
|
|
383
|
+
if (localeData[fallback] === void 0) localeData[fallback] = localeData[tag];
|
|
384
|
+
availableLocales.add(fallback);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
2
389
|
//#region packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
3
390
|
/**
|
|
4
391
|
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
@@ -3261,7 +3648,20 @@ const regions = {
|
|
|
3261
3648
|
"ZW"
|
|
3262
3649
|
]
|
|
3263
3650
|
};
|
|
3264
|
-
|
|
3651
|
+
function splitUnicodeExtension(locale) {
|
|
3652
|
+
const subtags = locale.split("-");
|
|
3653
|
+
for (let i = 1; i < subtags.length; i++) {
|
|
3654
|
+
if (subtags[i] === "x") break;
|
|
3655
|
+
if (subtags[i] !== "u") continue;
|
|
3656
|
+
let end = i + 1;
|
|
3657
|
+
while (end < subtags.length && subtags[end].length > 1) end++;
|
|
3658
|
+
return {
|
|
3659
|
+
locale: [...subtags.slice(0, i), ...subtags.slice(end)].join("-"),
|
|
3660
|
+
extension: "-" + subtags.slice(i, end).join("-")
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
return { locale };
|
|
3664
|
+
}
|
|
3265
3665
|
/**
|
|
3266
3666
|
* Asserts that a condition is true, throwing an error if it is not.
|
|
3267
3667
|
* Used for runtime validation and type narrowing.
|
|
@@ -3277,7 +3677,7 @@ const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
|
3277
3677
|
* // locale is now narrowed to non-undefined type
|
|
3278
3678
|
* ```
|
|
3279
3679
|
*/
|
|
3280
|
-
function invariant$
|
|
3680
|
+
function invariant$2(condition, message, Err = Error) {
|
|
3281
3681
|
if (!condition) throw new Err(message);
|
|
3282
3682
|
}
|
|
3283
3683
|
const DEFAULT_MATCHING_THRESHOLD = 838;
|
|
@@ -3561,7 +3961,7 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
|
3561
3961
|
let extension;
|
|
3562
3962
|
const noExtensionLocales = [];
|
|
3563
3963
|
const noExtensionLocaleMap = requestedLocales.reduce((all, l) => {
|
|
3564
|
-
const noExtensionLocale = l
|
|
3964
|
+
const { locale: noExtensionLocale } = splitUnicodeExtension(l);
|
|
3565
3965
|
noExtensionLocales.push(noExtensionLocale);
|
|
3566
3966
|
all[noExtensionLocale] = l;
|
|
3567
3967
|
return all;
|
|
@@ -3569,7 +3969,7 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
|
3569
3969
|
const result = findBestMatch(noExtensionLocales, availableLocales);
|
|
3570
3970
|
if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
|
|
3571
3971
|
foundLocale = result.matchedSupportedLocale;
|
|
3572
|
-
extension = noExtensionLocaleMap[result.matchedDesiredLocale].
|
|
3972
|
+
extension = splitUnicodeExtension(noExtensionLocaleMap[result.matchedDesiredLocale]).extension;
|
|
3573
3973
|
}
|
|
3574
3974
|
if (!foundLocale) return { locale: getDefaultLocale() };
|
|
3575
3975
|
return {
|
|
@@ -3577,16 +3977,251 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
|
3577
3977
|
extension
|
|
3578
3978
|
};
|
|
3579
3979
|
}
|
|
3980
|
+
const subdivisionAlias = {
|
|
3981
|
+
"cn11": "cnbj",
|
|
3982
|
+
"cn12": "cntj",
|
|
3983
|
+
"cn13": "cnhe",
|
|
3984
|
+
"cn14": "cnsx",
|
|
3985
|
+
"cn15": "cnmn",
|
|
3986
|
+
"cn21": "cnln",
|
|
3987
|
+
"cn22": "cnjl",
|
|
3988
|
+
"cn23": "cnhl",
|
|
3989
|
+
"cn31": "cnsh",
|
|
3990
|
+
"cn32": "cnjs",
|
|
3991
|
+
"cn33": "cnzj",
|
|
3992
|
+
"cn34": "cnah",
|
|
3993
|
+
"cn35": "cnfj",
|
|
3994
|
+
"cn36": "cnjx",
|
|
3995
|
+
"cn37": "cnsd",
|
|
3996
|
+
"cn41": "cnha",
|
|
3997
|
+
"cn42": "cnhb",
|
|
3998
|
+
"cn43": "cnhn",
|
|
3999
|
+
"cn44": "cngd",
|
|
4000
|
+
"cn45": "cngx",
|
|
4001
|
+
"cn46": "cnhi",
|
|
4002
|
+
"cn50": "cncq",
|
|
4003
|
+
"cn51": "cnsc",
|
|
4004
|
+
"cn52": "cngz",
|
|
4005
|
+
"cn53": "cnyn",
|
|
4006
|
+
"cn54": "cnxz",
|
|
4007
|
+
"cn61": "cnsn",
|
|
4008
|
+
"cn62": "cngs",
|
|
4009
|
+
"cn63": "cnqh",
|
|
4010
|
+
"cn64": "cnnx",
|
|
4011
|
+
"cn65": "cnxj",
|
|
4012
|
+
"cn71": "twzzzz",
|
|
4013
|
+
"cn91": "hkzzzz",
|
|
4014
|
+
"cn92": "mozzzz",
|
|
4015
|
+
"cz10a": "cz110",
|
|
4016
|
+
"cz10b": "cz111",
|
|
4017
|
+
"cz10c": "cz112",
|
|
4018
|
+
"cz10d": "cz113",
|
|
4019
|
+
"cz10e": "cz114",
|
|
4020
|
+
"cz10f": "cz115",
|
|
4021
|
+
"cz611": "cz663",
|
|
4022
|
+
"cz612": "cz632",
|
|
4023
|
+
"cz613": "cz633",
|
|
4024
|
+
"cz614": "cz634",
|
|
4025
|
+
"cz615": "cz635",
|
|
4026
|
+
"cz621": "cz641",
|
|
4027
|
+
"cz622": "cz642",
|
|
4028
|
+
"cz623": "cz643",
|
|
4029
|
+
"cz624": "cz644",
|
|
4030
|
+
"cz626": "cz646",
|
|
4031
|
+
"cz627": "cz647",
|
|
4032
|
+
"czjc": "cz31",
|
|
4033
|
+
"czjm": "cz64",
|
|
4034
|
+
"czka": "cz41",
|
|
4035
|
+
"czkr": "cz52",
|
|
4036
|
+
"czli": "cz51",
|
|
4037
|
+
"czmo": "cz80",
|
|
4038
|
+
"czol": "cz71",
|
|
4039
|
+
"czpa": "cz53",
|
|
4040
|
+
"czpl": "cz32",
|
|
4041
|
+
"czpr": "cz10",
|
|
4042
|
+
"czst": "cz20",
|
|
4043
|
+
"czus": "cz42",
|
|
4044
|
+
"czvy": "cz63",
|
|
4045
|
+
"czzl": "cz72",
|
|
4046
|
+
"fi01": "axzzzz",
|
|
4047
|
+
"fra": "frges",
|
|
4048
|
+
"frb": "frnaq",
|
|
4049
|
+
"frbl": "blzzzz",
|
|
4050
|
+
"frc": "frara",
|
|
4051
|
+
"frcp": "cpzzzz",
|
|
4052
|
+
"frd": "frbfc",
|
|
4053
|
+
"fre": "frbre",
|
|
4054
|
+
"frf": "frcvl",
|
|
4055
|
+
"frg": "frges",
|
|
4056
|
+
"frgf": "gfzzzz",
|
|
4057
|
+
"frgp": "gpzzzz",
|
|
4058
|
+
"frgua": "gpzzzz",
|
|
4059
|
+
"frh": "frcor",
|
|
4060
|
+
"fri": "frbfc",
|
|
4061
|
+
"frj": "fridf",
|
|
4062
|
+
"frk": "frocc",
|
|
4063
|
+
"frl": "frnaq",
|
|
4064
|
+
"frlre": "rezzzz",
|
|
4065
|
+
"frm": "frges",
|
|
4066
|
+
"frmay": "ytzzzz",
|
|
4067
|
+
"frmf": "mfzzzz",
|
|
4068
|
+
"frmq": "mqzzzz",
|
|
4069
|
+
"frn": "frocc",
|
|
4070
|
+
"frnc": "nczzzz",
|
|
4071
|
+
"fro": "frhdf",
|
|
4072
|
+
"frp": "frnor",
|
|
4073
|
+
"frpf": "pfzzzz",
|
|
4074
|
+
"frpm": "pmzzzz",
|
|
4075
|
+
"frq": "frnor",
|
|
4076
|
+
"frr": "frpdl",
|
|
4077
|
+
"frre": "rezzzz",
|
|
4078
|
+
"frs": "frhdf",
|
|
4079
|
+
"frt": "frnaq",
|
|
4080
|
+
"frtf": "tfzzzz",
|
|
4081
|
+
"fru": "frpac",
|
|
4082
|
+
"frv": "frara",
|
|
4083
|
+
"frwf": "wfzzzz",
|
|
4084
|
+
"fryt": "ytzzzz",
|
|
4085
|
+
"laxn": "laxs",
|
|
4086
|
+
"lud": "lucl",
|
|
4087
|
+
"lug": "luec",
|
|
4088
|
+
"lul": "luca",
|
|
4089
|
+
"mrnkc": "mr13",
|
|
4090
|
+
"nlaw": "awzzzz",
|
|
4091
|
+
"nlcw": "cwzzzz",
|
|
4092
|
+
"nlsx": "sxzzzz",
|
|
4093
|
+
"no23": "no50",
|
|
4094
|
+
"nzn": "nzauk",
|
|
4095
|
+
"nzs": "nzcan",
|
|
4096
|
+
"omba": "ombj",
|
|
4097
|
+
"omsh": "omsj",
|
|
4098
|
+
"plds": "pl02",
|
|
4099
|
+
"plkp": "pl04",
|
|
4100
|
+
"pllb": "pl08",
|
|
4101
|
+
"plld": "pl10",
|
|
4102
|
+
"pllu": "pl06",
|
|
4103
|
+
"plma": "pl12",
|
|
4104
|
+
"plmz": "pl14",
|
|
4105
|
+
"plop": "pl16",
|
|
4106
|
+
"plpd": "pl20",
|
|
4107
|
+
"plpk": "pl18",
|
|
4108
|
+
"plpm": "pl22",
|
|
4109
|
+
"plsk": "pl26",
|
|
4110
|
+
"plsl": "pl24",
|
|
4111
|
+
"plwn": "pl28",
|
|
4112
|
+
"plwp": "pl30",
|
|
4113
|
+
"plzp": "pl32",
|
|
4114
|
+
"shta": "tazzzz",
|
|
4115
|
+
"tteto": "tttob",
|
|
4116
|
+
"ttrcm": "ttmrc",
|
|
4117
|
+
"ttwto": "tttob",
|
|
4118
|
+
"twkhq": "twkhh",
|
|
4119
|
+
"twtnq": "twtnn",
|
|
4120
|
+
"twtpq": "twnwt",
|
|
4121
|
+
"twtxq": "twtxg",
|
|
4122
|
+
"usas": "aszzzz",
|
|
4123
|
+
"usgu": "guzzzz",
|
|
4124
|
+
"usmp": "mpzzzz",
|
|
4125
|
+
"uspr": "przzzz",
|
|
4126
|
+
"usum": "umzzzz",
|
|
4127
|
+
"usvi": "vizzzz"
|
|
4128
|
+
};
|
|
4129
|
+
const extensionAlias = {
|
|
4130
|
+
"t": {
|
|
4131
|
+
"d0": { "name": "charname" },
|
|
4132
|
+
"m0": {
|
|
4133
|
+
"beta-metsehaf": "betamets",
|
|
4134
|
+
"ies-jes": "iesjes",
|
|
4135
|
+
"names": "prprname",
|
|
4136
|
+
"tekie-alibekit": "tekieali"
|
|
4137
|
+
}
|
|
4138
|
+
},
|
|
4139
|
+
"u": {
|
|
4140
|
+
"ca": {
|
|
4141
|
+
"ethiopic-amete-alem": "ethioaa",
|
|
4142
|
+
"islamicc": "islamic-civil"
|
|
4143
|
+
},
|
|
4144
|
+
"kb": { "yes": "true" },
|
|
4145
|
+
"kc": { "yes": "true" },
|
|
4146
|
+
"kh": { "yes": "true" },
|
|
4147
|
+
"kk": { "yes": "true" },
|
|
4148
|
+
"kn": { "yes": "true" },
|
|
4149
|
+
"ks": {
|
|
4150
|
+
"primary": "level1",
|
|
4151
|
+
"tertiary": "level3"
|
|
4152
|
+
},
|
|
4153
|
+
"ms": { "imperial": "uksystem" },
|
|
4154
|
+
"tz": {
|
|
4155
|
+
"aqams": "aqmcm",
|
|
4156
|
+
"aukns": "auhba",
|
|
4157
|
+
"caffs": "cawnp",
|
|
4158
|
+
"camtr": "cator",
|
|
4159
|
+
"canpg": "cator",
|
|
4160
|
+
"capnt": "caiql",
|
|
4161
|
+
"cathu": "cator",
|
|
4162
|
+
"cayzf": "caedm",
|
|
4163
|
+
"cet": "bebru",
|
|
4164
|
+
"cnckg": "cnsha",
|
|
4165
|
+
"cnhrb": "cnsha",
|
|
4166
|
+
"cnkhg": "cnurc",
|
|
4167
|
+
"cst6cdt": "uschi",
|
|
4168
|
+
"cuba": "cuhav",
|
|
4169
|
+
"eet": "grath",
|
|
4170
|
+
"egypt": "egcai",
|
|
4171
|
+
"eire": "iedub",
|
|
4172
|
+
"est": "papty",
|
|
4173
|
+
"est5edt": "usnyc",
|
|
4174
|
+
"factory": "unk",
|
|
4175
|
+
"gaza": "gazastrp",
|
|
4176
|
+
"gmt0": "gmt",
|
|
4177
|
+
"hongkong": "hkhkg",
|
|
4178
|
+
"hst": "ushnl",
|
|
4179
|
+
"iceland": "isrey",
|
|
4180
|
+
"iran": "irthr",
|
|
4181
|
+
"israel": "jeruslm",
|
|
4182
|
+
"jamaica": "jmkin",
|
|
4183
|
+
"japan": "jptyo",
|
|
4184
|
+
"libya": "lytip",
|
|
4185
|
+
"met": "bebru",
|
|
4186
|
+
"mncoq": "mnuln",
|
|
4187
|
+
"mst": "usphx",
|
|
4188
|
+
"mst7mdt": "usden",
|
|
4189
|
+
"mxstis": "mxtij",
|
|
4190
|
+
"navajo": "usden",
|
|
4191
|
+
"poland": "plwaw",
|
|
4192
|
+
"portugal": "ptlis",
|
|
4193
|
+
"prc": "cnsha",
|
|
4194
|
+
"pst8pdt": "uslax",
|
|
4195
|
+
"roc": "twtpe",
|
|
4196
|
+
"rok": "krsel",
|
|
4197
|
+
"turkey": "trist",
|
|
4198
|
+
"uaozh": "uaiev",
|
|
4199
|
+
"uauzh": "uaiev",
|
|
4200
|
+
"uct": "utc",
|
|
4201
|
+
"umjon": "ushnl",
|
|
4202
|
+
"usnavajo": "usden",
|
|
4203
|
+
"wet": "ptlis",
|
|
4204
|
+
"zulu": "utc"
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
};
|
|
3580
4208
|
function CanonicalizeUValue(ukey, uvalue) {
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
4209
|
+
invariant$2(ukey !== void 0, `ukey must be defined`);
|
|
4210
|
+
let canonicalized = "";
|
|
4211
|
+
for (let i = 0; i < uvalue.length; i++) {
|
|
4212
|
+
const code = uvalue.charCodeAt(i);
|
|
4213
|
+
canonicalized += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : uvalue[i];
|
|
4214
|
+
}
|
|
4215
|
+
const aliases = Object.prototype.hasOwnProperty.call(extensionAlias.u, ukey) ? extensionAlias.u[ukey] : void 0;
|
|
4216
|
+
if (aliases && Object.prototype.hasOwnProperty.call(aliases, canonicalized)) canonicalized = aliases[canonicalized];
|
|
4217
|
+
if ((ukey === "rg" || ukey === "sd") && Object.prototype.hasOwnProperty.call(subdivisionAlias, canonicalized)) canonicalized = subdivisionAlias[canonicalized];
|
|
4218
|
+
return canonicalized === "true" ? "" : canonicalized;
|
|
3584
4219
|
}
|
|
3585
4220
|
function CanonicalizeUnicodeLocaleId(locale) {
|
|
3586
4221
|
return Intl.getCanonicalLocales(locale)[0];
|
|
3587
4222
|
}
|
|
3588
4223
|
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
3589
|
-
invariant$
|
|
4224
|
+
invariant$2(splitUnicodeExtension(locale).extension === void 0, "Expected locale to not have a Unicode locale extension");
|
|
3590
4225
|
let extension = "-u";
|
|
3591
4226
|
for (const attr of attributes) extension += `-${attr}`;
|
|
3592
4227
|
for (const kw of keywords) {
|
|
@@ -3635,11 +4270,11 @@ function BestAvailableLocale(availableLocales, locale) {
|
|
|
3635
4270
|
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
3636
4271
|
const result = { locale: "" };
|
|
3637
4272
|
for (const locale of requestedLocales) {
|
|
3638
|
-
const noExtensionLocale = locale
|
|
4273
|
+
const { locale: noExtensionLocale, extension } = splitUnicodeExtension(locale);
|
|
3639
4274
|
const availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
3640
4275
|
if (availableLocale) {
|
|
3641
4276
|
result.locale = availableLocale;
|
|
3642
|
-
if (
|
|
4277
|
+
if (extension) result.extension = extension;
|
|
3643
4278
|
return result;
|
|
3644
4279
|
}
|
|
3645
4280
|
}
|
|
@@ -3647,8 +4282,8 @@ function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
|
3647
4282
|
return result;
|
|
3648
4283
|
}
|
|
3649
4284
|
function UnicodeExtensionComponents(extension) {
|
|
3650
|
-
invariant$
|
|
3651
|
-
invariant$
|
|
4285
|
+
invariant$2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
|
|
4286
|
+
invariant$2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
|
|
3652
4287
|
const attributes = [];
|
|
3653
4288
|
const keywords = [];
|
|
3654
4289
|
let keyword;
|
|
@@ -3660,7 +4295,7 @@ function UnicodeExtensionComponents(extension) {
|
|
|
3660
4295
|
if (e === -1) len = size - k;
|
|
3661
4296
|
else len = e - k;
|
|
3662
4297
|
let subtag = extension.slice(k, k + len);
|
|
3663
|
-
invariant$
|
|
4298
|
+
invariant$2(len >= 2, "Expected a subtag to have at least 2 characters");
|
|
3664
4299
|
if (keyword === void 0 && len != 2) {
|
|
3665
4300
|
if (attributes.indexOf(subtag) === -1) attributes.push(subtag);
|
|
3666
4301
|
} else if (len === 2) {
|
|
@@ -3671,7 +4306,7 @@ function UnicodeExtensionComponents(extension) {
|
|
|
3671
4306
|
if (keywords.find((k) => k.key === keyword?.key) === void 0) keywords.push(keyword);
|
|
3672
4307
|
} else if (keyword?.value === "") keyword.value = subtag;
|
|
3673
4308
|
else {
|
|
3674
|
-
invariant$
|
|
4309
|
+
invariant$2(keyword !== void 0, "Expected keyword to be defined");
|
|
3675
4310
|
keyword.value += "-" + subtag;
|
|
3676
4311
|
}
|
|
3677
4312
|
k += len + 1;
|
|
@@ -3695,10 +4330,9 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
|
|
|
3695
4330
|
};
|
|
3696
4331
|
let foundLocale = r.locale;
|
|
3697
4332
|
let foundLocaleData = localeData[foundLocale];
|
|
3698
|
-
const result =
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
};
|
|
4333
|
+
const result = Object.create(null);
|
|
4334
|
+
result.locale = "en";
|
|
4335
|
+
result.dataLocale = foundLocale;
|
|
3702
4336
|
let components;
|
|
3703
4337
|
let keywords;
|
|
3704
4338
|
if (r.extension) {
|
|
@@ -3708,9 +4342,9 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
|
|
|
3708
4342
|
let supportedKeywords = [];
|
|
3709
4343
|
for (const key of relevantExtensionKeys) {
|
|
3710
4344
|
let keyLocaleData = foundLocaleData?.[key] ?? [];
|
|
3711
|
-
invariant$
|
|
4345
|
+
invariant$2(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
|
|
3712
4346
|
let value = keyLocaleData[0];
|
|
3713
|
-
invariant$
|
|
4347
|
+
invariant$2(value == null || typeof value === "string", `value must be a string, null, or undefined`);
|
|
3714
4348
|
let supportedKeyword;
|
|
3715
4349
|
let entry = keywords.find((k) => k.key === key);
|
|
3716
4350
|
if (entry) {
|
|
@@ -3732,12 +4366,12 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
|
|
|
3732
4366
|
}
|
|
3733
4367
|
}
|
|
3734
4368
|
let optionsValue = options[key];
|
|
3735
|
-
invariant$
|
|
4369
|
+
invariant$2(optionsValue == null || typeof optionsValue === "string", `optionsValue must be a string or undefined`);
|
|
3736
4370
|
if (typeof optionsValue === "string") {
|
|
3737
4371
|
optionsValue = CanonicalizeUValue(key.toLowerCase(), optionsValue);
|
|
3738
4372
|
if (optionsValue === "") optionsValue = "true";
|
|
3739
4373
|
}
|
|
3740
|
-
if (optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
|
|
4374
|
+
if (optionsValue !== void 0 && optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
|
|
3741
4375
|
value = optionsValue;
|
|
3742
4376
|
supportedKeyword = void 0;
|
|
3743
4377
|
}
|
|
@@ -3760,8 +4394,8 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
|
|
|
3760
4394
|
function LookupSupportedLocales(availableLocales, requestedLocales) {
|
|
3761
4395
|
const subset = [];
|
|
3762
4396
|
for (const locale of requestedLocales) {
|
|
3763
|
-
const
|
|
3764
|
-
if (
|
|
4397
|
+
const { locale: noExtensionLocale } = splitUnicodeExtension(locale);
|
|
4398
|
+
if (BestAvailableLocale(availableLocales, noExtensionLocale)) subset.push(locale);
|
|
3765
4399
|
}
|
|
3766
4400
|
return subset;
|
|
3767
4401
|
}
|
|
@@ -3797,7 +4431,7 @@ function ToString(o) {
|
|
|
3797
4431
|
* @param fallback
|
|
3798
4432
|
*/
|
|
3799
4433
|
function GetOption(opts, prop, type, values, fallback) {
|
|
3800
|
-
if (typeof opts !== "object") throw new TypeError("Options must be an object");
|
|
4434
|
+
if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
|
|
3801
4435
|
let value = opts[prop];
|
|
3802
4436
|
if (value !== void 0) {
|
|
3803
4437
|
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
|
|
@@ -4286,7 +4920,7 @@ var BigDecimal = class BigDecimal {
|
|
|
4286
4920
|
};
|
|
4287
4921
|
//#endregion
|
|
4288
4922
|
//#region packages/ecma262-abstract/ToPrimitive.js
|
|
4289
|
-
function invariant$
|
|
4923
|
+
function invariant$1(condition, message, Err = Error) {
|
|
4290
4924
|
if (!condition) throw new Err(message);
|
|
4291
4925
|
}
|
|
4292
4926
|
function IsCallable(fn) {
|
|
@@ -4316,7 +4950,7 @@ function ToPrimitive(input, preferredType) {
|
|
|
4316
4950
|
if (preferredType === void 0) hint = "default";
|
|
4317
4951
|
else if (preferredType === "string") hint = "string";
|
|
4318
4952
|
else {
|
|
4319
|
-
invariant$
|
|
4953
|
+
invariant$1(preferredType === "number", "preferredType must be \"string\" or \"number\"");
|
|
4320
4954
|
hint = "number";
|
|
4321
4955
|
}
|
|
4322
4956
|
let result = exoticToPrim.call(input, hint);
|
|
@@ -4337,6 +4971,7 @@ function ToPrimitive(input, preferredType) {
|
|
|
4337
4971
|
function ToIntlMathematicalValue(input) {
|
|
4338
4972
|
if (typeof input === "bigint") return new BigDecimal(input.toString());
|
|
4339
4973
|
let primValue = ToPrimitive(input, "number");
|
|
4974
|
+
if (typeof primValue === "symbol") throw new TypeError("Cannot convert a Symbol value to a number");
|
|
4340
4975
|
if (primValue === void 0) return new BigDecimal(NaN);
|
|
4341
4976
|
if (primValue === true) return new BigDecimal(1);
|
|
4342
4977
|
if (primValue === false) return new BigDecimal(0);
|
|
@@ -4361,7 +4996,9 @@ function CoerceOptionsToObject(options) {
|
|
|
4361
4996
|
//#endregion
|
|
4362
4997
|
//#region packages/ecma402-abstract/DefaultNumberOption.js
|
|
4363
4998
|
/**
|
|
4999
|
+
* ECMA-402 §9.2.13 DefaultNumberOption, step 2.
|
|
4364
5000
|
* https://tc39.es/ecma402/#sec-defaultnumberoption
|
|
5001
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
|
|
4365
5002
|
* @param val
|
|
4366
5003
|
* @param min
|
|
4367
5004
|
* @param max
|
|
@@ -4369,7 +5006,7 @@ function CoerceOptionsToObject(options) {
|
|
|
4369
5006
|
*/
|
|
4370
5007
|
function DefaultNumberOption(inputVal, min, max, fallback) {
|
|
4371
5008
|
if (inputVal === void 0) return fallback;
|
|
4372
|
-
const val =
|
|
5009
|
+
const val = +inputVal;
|
|
4373
5010
|
if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
|
|
4374
5011
|
return Math.floor(val);
|
|
4375
5012
|
}
|
|
@@ -4412,7 +5049,7 @@ function ensureIntl() {
|
|
|
4412
5049
|
});
|
|
4413
5050
|
return Intl;
|
|
4414
5051
|
}
|
|
4415
|
-
function invariant
|
|
5052
|
+
function invariant(condition, message, Err = Error) {
|
|
4416
5053
|
if (!condition) throw new Err(message);
|
|
4417
5054
|
}
|
|
4418
5055
|
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
@@ -4448,8 +5085,8 @@ function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefau
|
|
|
4448
5085
|
let mxsd = opts.maximumSignificantDigits;
|
|
4449
5086
|
internalSlots.minimumIntegerDigits = mnid;
|
|
4450
5087
|
const roundingIncrement = GetNumberOption(opts, "roundingIncrement", 1, 5e3, 1);
|
|
4451
|
-
invariant
|
|
4452
|
-
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}
|
|
5088
|
+
invariant(VALID_ROUNDING_INCREMENTS.has(roundingIncrement), `Invalid rounding increment value: ${roundingIncrement}.
|
|
5089
|
+
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`, RangeError);
|
|
4453
5090
|
const roundingMode = GetOption(opts, "roundingMode", "string", [
|
|
4454
5091
|
"ceil",
|
|
4455
5092
|
"floor",
|
|
@@ -4479,26 +5116,30 @@ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
|
|
|
4479
5116
|
needSd = hasSd;
|
|
4480
5117
|
if (hasSd || !hasFd && notation === "compact") needFd = false;
|
|
4481
5118
|
}
|
|
4482
|
-
if (needSd)
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
5119
|
+
if (needSd) {
|
|
5120
|
+
if (hasSd) {
|
|
5121
|
+
internalSlots.minimumSignificantDigits = DefaultNumberOption(mnsd, 1, 21, 1);
|
|
5122
|
+
internalSlots.maximumSignificantDigits = DefaultNumberOption(mxsd, internalSlots.minimumSignificantDigits, 21, 21);
|
|
5123
|
+
} else {
|
|
5124
|
+
internalSlots.minimumSignificantDigits = 1;
|
|
5125
|
+
internalSlots.maximumSignificantDigits = 21;
|
|
5126
|
+
}
|
|
4488
5127
|
}
|
|
4489
|
-
if (needFd)
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
5128
|
+
if (needFd) {
|
|
5129
|
+
if (hasFd) {
|
|
5130
|
+
mnfd = DefaultNumberOption(mnfd, 0, 100, void 0);
|
|
5131
|
+
mxfd = DefaultNumberOption(mxfd, 0, 100, void 0);
|
|
5132
|
+
if (mnfd === void 0) {
|
|
5133
|
+
invariant(mxfd !== void 0, "maximumFractionDigits must be defined");
|
|
5134
|
+
mnfd = Math.min(mnfdDefault, mxfd);
|
|
5135
|
+
} else if (mxfd === void 0) mxfd = Math.max(mxfdDefault, mnfd);
|
|
5136
|
+
else if (mnfd > mxfd) throw new RangeError(`Invalid range, ${mnfd} > ${mxfd}`);
|
|
5137
|
+
internalSlots.minimumFractionDigits = mnfd;
|
|
5138
|
+
internalSlots.maximumFractionDigits = mxfd;
|
|
5139
|
+
} else {
|
|
5140
|
+
internalSlots.minimumFractionDigits = mnfdDefault;
|
|
5141
|
+
internalSlots.maximumFractionDigits = mxfdDefault;
|
|
5142
|
+
}
|
|
4502
5143
|
}
|
|
4503
5144
|
if (!needSd && !needFd) {
|
|
4504
5145
|
internalSlots.minimumFractionDigits = 0;
|
|
@@ -4521,8 +5162,8 @@ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
|
|
|
4521
5162
|
internalSlots.roundingPriority = "auto";
|
|
4522
5163
|
}
|
|
4523
5164
|
if (roundingIncrement !== 1) {
|
|
4524
|
-
invariant
|
|
4525
|
-
invariant
|
|
5165
|
+
invariant(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeError);
|
|
5166
|
+
invariant(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeError);
|
|
4526
5167
|
}
|
|
4527
5168
|
}
|
|
4528
5169
|
//#endregion
|
|
@@ -4537,13 +5178,19 @@ function InitializePluralRules(pl, locales, options, { availableLocales, relevan
|
|
|
4537
5178
|
const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
4538
5179
|
internalSlots.locale = r.locale;
|
|
4539
5180
|
internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal");
|
|
4540
|
-
const notation = GetOption(opts, "notation", "string", [
|
|
5181
|
+
const notation = GetOption(opts, "notation", "string", [
|
|
5182
|
+
"standard",
|
|
5183
|
+
"scientific",
|
|
5184
|
+
"engineering",
|
|
5185
|
+
"compact"
|
|
5186
|
+
], "standard");
|
|
4541
5187
|
internalSlots.notation = notation;
|
|
5188
|
+
const compactDisplay = GetOption(opts, "compactDisplay", "string", ["short", "long"], "short");
|
|
4542
5189
|
if (notation === "compact") {
|
|
4543
|
-
internalSlots.compactDisplay =
|
|
4544
|
-
|
|
5190
|
+
internalSlots.compactDisplay = compactDisplay;
|
|
5191
|
+
internalSlots.compactExponents = localeData[r.dataLocale]?.compactExponents;
|
|
4545
5192
|
}
|
|
4546
|
-
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3,
|
|
5193
|
+
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, notation);
|
|
4547
5194
|
return pl;
|
|
4548
5195
|
}
|
|
4549
5196
|
//#endregion
|
|
@@ -4562,62 +5209,8 @@ function Type(x) {
|
|
|
4562
5209
|
if (typeof x === "bigint") return "BigInt";
|
|
4563
5210
|
}
|
|
4564
5211
|
//#endregion
|
|
4565
|
-
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
4566
|
-
/**
|
|
4567
|
-
* Cached function to compute powers of 10 for Decimal.js operations.
|
|
4568
|
-
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
|
|
4569
|
-
* by memoizing expensive Decimal.pow(10, n) calculations.
|
|
4570
|
-
*
|
|
4571
|
-
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
|
|
4572
|
-
* so caching provides substantial performance benefits.
|
|
4573
|
-
*
|
|
4574
|
-
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
|
|
4575
|
-
*/
|
|
4576
|
-
const getPowerOf10 = memoize((exponent) => {
|
|
4577
|
-
return BigDecimal.pow(10, exponent);
|
|
4578
|
-
});
|
|
4579
|
-
//#endregion
|
|
4580
|
-
//#region packages/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
4581
|
-
/**
|
|
4582
|
-
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
|
|
4583
|
-
* number of the given magnitude (power of ten of the most significant digit) according to the
|
|
4584
|
-
* locale and the desired notation (scientific, engineering, or compact).
|
|
4585
|
-
*/
|
|
4586
|
-
function ComputeExponentForMagnitude(internalSlots, magnitude) {
|
|
4587
|
-
const { notation, dataLocaleData, numberingSystem } = internalSlots;
|
|
4588
|
-
switch (notation) {
|
|
4589
|
-
case "standard": return 0;
|
|
4590
|
-
case "scientific": return magnitude.toNumber();
|
|
4591
|
-
case "engineering": return magnitude.div(3).floor().times(3).toNumber();
|
|
4592
|
-
default: {
|
|
4593
|
-
invariant$1(notation === "compact", "Invalid notation");
|
|
4594
|
-
const { compactDisplay, style, currencyDisplay } = internalSlots;
|
|
4595
|
-
let thresholdMap;
|
|
4596
|
-
if (style === "currency" && currencyDisplay !== "name") thresholdMap = (dataLocaleData.numbers.currency[numberingSystem] || dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]]).short;
|
|
4597
|
-
else {
|
|
4598
|
-
const decimal = dataLocaleData.numbers.decimal[numberingSystem] || dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
|
|
4599
|
-
thresholdMap = compactDisplay === "long" ? decimal.long : decimal.short;
|
|
4600
|
-
}
|
|
4601
|
-
if (!thresholdMap) return 0;
|
|
4602
|
-
const num = getPowerOf10(magnitude).toString();
|
|
4603
|
-
const thresholds = Object.keys(thresholdMap);
|
|
4604
|
-
if (num < thresholds[0]) return 0;
|
|
4605
|
-
if (num > thresholds[thresholds.length - 1]) {
|
|
4606
|
-
const magnitudeKey = thresholds[thresholds.length - 1];
|
|
4607
|
-
if (thresholdMap[magnitudeKey].other === "0") return 0;
|
|
4608
|
-
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
|
|
4609
|
-
}
|
|
4610
|
-
const i = thresholds.indexOf(num);
|
|
4611
|
-
if (i === -1) return 0;
|
|
4612
|
-
const magnitudeKey = thresholds[i];
|
|
4613
|
-
if (thresholdMap[magnitudeKey].other === "0") return 0;
|
|
4614
|
-
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
|
|
4615
|
-
}
|
|
4616
|
-
}
|
|
4617
|
-
}
|
|
4618
|
-
//#endregion
|
|
4619
5212
|
//#region packages/ecma402-abstract/constants.js
|
|
4620
|
-
const ZERO
|
|
5213
|
+
const ZERO = new BigDecimal(0);
|
|
4621
5214
|
const NEGATIVE_ZERO = new BigDecimal(-0);
|
|
4622
5215
|
//#endregion
|
|
4623
5216
|
//#region packages/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js
|
|
@@ -4652,21 +5245,36 @@ function GetUnsignedRoundingMode(roundingMode, isNegative) {
|
|
|
4652
5245
|
function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
|
|
4653
5246
|
if (x.eq(r1) || r1.eq(r2)) return r1;
|
|
4654
5247
|
if (x.eq(r2)) return r2;
|
|
4655
|
-
invariant
|
|
5248
|
+
invariant(r1.lessThan(x) && x.lessThan(r2), `x should be between r1 and r2 but x=${x}, r1=${r1}, r2=${r2}`);
|
|
4656
5249
|
if (unsignedRoundingMode === "zero") return r1;
|
|
4657
5250
|
if (unsignedRoundingMode === "infinity") return r2;
|
|
4658
5251
|
const d1 = x.minus(r1);
|
|
4659
5252
|
const d2 = r2.minus(x);
|
|
4660
5253
|
if (d1.lessThan(d2)) return r1;
|
|
4661
5254
|
if (d2.lessThan(d1)) return r2;
|
|
4662
|
-
invariant
|
|
5255
|
+
invariant(d1.eq(d2), "d1 should be equal to d2");
|
|
4663
5256
|
if (unsignedRoundingMode === "half-zero") return r1;
|
|
4664
5257
|
if (unsignedRoundingMode === "half-infinity") return r2;
|
|
4665
|
-
invariant
|
|
5258
|
+
invariant(unsignedRoundingMode === "half-even", "unsignedRoundingMode should be half-even");
|
|
4666
5259
|
if (r1.div(r2.minus(r1)).mod(2).isZero()) return r1;
|
|
4667
5260
|
return r2;
|
|
4668
5261
|
}
|
|
4669
5262
|
//#endregion
|
|
5263
|
+
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
5264
|
+
/**
|
|
5265
|
+
* Cached function to compute powers of 10 for Decimal.js operations.
|
|
5266
|
+
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
|
|
5267
|
+
* by memoizing expensive Decimal.pow(10, n) calculations.
|
|
5268
|
+
*
|
|
5269
|
+
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
|
|
5270
|
+
* so caching provides substantial performance benefits.
|
|
5271
|
+
*
|
|
5272
|
+
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
|
|
5273
|
+
*/
|
|
5274
|
+
const getPowerOf10 = memoize((exponent) => {
|
|
5275
|
+
return BigDecimal.pow(10, exponent);
|
|
5276
|
+
});
|
|
5277
|
+
//#endregion
|
|
4670
5278
|
//#region packages/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
4671
5279
|
function ToRawFixedFn(n, f) {
|
|
4672
5280
|
return n.times(getPowerOf10(-f));
|
|
@@ -4824,7 +5432,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
4824
5432
|
if (x.isZero()) {
|
|
4825
5433
|
m = repeat("0", p);
|
|
4826
5434
|
e = 0;
|
|
4827
|
-
xFinal = ZERO
|
|
5435
|
+
xFinal = ZERO;
|
|
4828
5436
|
} else {
|
|
4829
5437
|
const { n1, e1, r1 } = findN1E1R1(x, p);
|
|
4830
5438
|
const { n2, e2, r2 } = findN2E2R2(x, p);
|
|
@@ -4849,7 +5457,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
4849
5457
|
m = m.slice(0, e + 1) + "." + m.slice(m.length - (p - (e + 1)));
|
|
4850
5458
|
int = e + 1;
|
|
4851
5459
|
} else {
|
|
4852
|
-
invariant
|
|
5460
|
+
invariant(e < 0, "e should be less than 0");
|
|
4853
5461
|
m = "0." + repeat("0", -e - 1) + m;
|
|
4854
5462
|
int = 1;
|
|
4855
5463
|
}
|
|
@@ -4865,7 +5473,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
4865
5473
|
formattedString: m,
|
|
4866
5474
|
roundedNumber: xFinal,
|
|
4867
5475
|
integerDigitsCount: int,
|
|
4868
|
-
roundingMagnitude: e
|
|
5476
|
+
roundingMagnitude: e - p + 1
|
|
4869
5477
|
};
|
|
4870
5478
|
}
|
|
4871
5479
|
//#endregion
|
|
@@ -4878,9 +5486,9 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
4878
5486
|
let sign;
|
|
4879
5487
|
if (x.isZero() && x.isNegative()) {
|
|
4880
5488
|
sign = "negative";
|
|
4881
|
-
x = ZERO
|
|
5489
|
+
x = ZERO;
|
|
4882
5490
|
} else {
|
|
4883
|
-
invariant
|
|
5491
|
+
invariant(x.isFinite(), "NumberFormatDigitInternalSlots value is not finite");
|
|
4884
5492
|
if (x.lessThan(0)) sign = "negative";
|
|
4885
5493
|
else sign = "positive";
|
|
4886
5494
|
if (sign === "negative") x = x.negated();
|
|
@@ -4898,14 +5506,14 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
4898
5506
|
default:
|
|
4899
5507
|
let sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
|
|
4900
5508
|
let fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
|
|
4901
|
-
if (intlObject.roundingType === "morePrecision")
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
5509
|
+
if (intlObject.roundingType === "morePrecision") {
|
|
5510
|
+
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = sResult;
|
|
5511
|
+
else result = fResult;
|
|
5512
|
+
} else {
|
|
5513
|
+
invariant(intlObject.roundingType === "lessPrecision", "Invalid roundingType");
|
|
4905
5514
|
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = fResult;
|
|
4906
5515
|
else result = sResult;
|
|
4907
5516
|
}
|
|
4908
|
-
break;
|
|
4909
5517
|
}
|
|
4910
5518
|
x = result.roundedNumber;
|
|
4911
5519
|
let string = result.formattedString;
|
|
@@ -4916,44 +5524,22 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
4916
5524
|
const int = result.integerDigitsCount;
|
|
4917
5525
|
const minInteger = intlObject.minimumIntegerDigits;
|
|
4918
5526
|
if (int < minInteger) string = repeat("0", minInteger - int) + string;
|
|
4919
|
-
if (sign === "negative")
|
|
4920
|
-
|
|
5527
|
+
if (sign === "negative") {
|
|
5528
|
+
if (x.isZero()) x = NEGATIVE_ZERO;
|
|
5529
|
+
else x = x.negated();
|
|
5530
|
+
}
|
|
4921
5531
|
return {
|
|
4922
5532
|
roundedNumber: x,
|
|
4923
5533
|
formattedString: string
|
|
4924
5534
|
};
|
|
4925
5535
|
}
|
|
4926
5536
|
//#endregion
|
|
4927
|
-
//#region packages/ecma262-abstract/ToNumber.js
|
|
4928
|
-
const ZERO = new BigDecimal(0);
|
|
4929
|
-
function invariant(condition, message, Err = Error) {
|
|
4930
|
-
if (!condition) throw new Err(message);
|
|
4931
|
-
}
|
|
4932
|
-
/**
|
|
4933
|
-
* https://tc39.es/ecma262/#sec-tonumber
|
|
4934
|
-
*/
|
|
4935
|
-
function ToNumber(arg) {
|
|
4936
|
-
if (typeof arg === "number") return new BigDecimal(arg);
|
|
4937
|
-
if (typeof arg === "bigint") return new BigDecimal(arg.toString());
|
|
4938
|
-
invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
|
|
4939
|
-
if (arg === void 0) return new BigDecimal(NaN);
|
|
4940
|
-
if (arg === null || arg === 0) return ZERO;
|
|
4941
|
-
if (arg === true) return new BigDecimal(1);
|
|
4942
|
-
if (typeof arg === "string") try {
|
|
4943
|
-
return new BigDecimal(arg);
|
|
4944
|
-
} catch {
|
|
4945
|
-
return new BigDecimal(NaN);
|
|
4946
|
-
}
|
|
4947
|
-
invariant(typeof arg === "object", "object expected", TypeError);
|
|
4948
|
-
let primValue = ToPrimitive(arg, "number");
|
|
4949
|
-
invariant(typeof primValue !== "object", "object expected", TypeError);
|
|
4950
|
-
return ToNumber(primValue);
|
|
4951
|
-
}
|
|
4952
|
-
//#endregion
|
|
4953
5537
|
//#region packages/ecma402-abstract/PluralRules/GetOperands.js
|
|
4954
5538
|
/**
|
|
4955
|
-
*
|
|
4956
|
-
*
|
|
5539
|
+
* CLDR operands for the implementation-defined PluralRuleSelect
|
|
5540
|
+
* ECMA-402 §17.5.1 PluralRuleSelect, decimalString parameter and return definition.
|
|
5541
|
+
* https://tc39.es/ecma402/#sec-pluralruleselect
|
|
5542
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/pluralrules.html#L285-L290
|
|
4957
5543
|
*
|
|
4958
5544
|
* Implementation: Extended to support compact exponent (c/e operands)
|
|
4959
5545
|
*
|
|
@@ -4961,34 +5547,34 @@ function ToNumber(arg) {
|
|
|
4961
5547
|
* @param exponent Compact decimal exponent (c/e operand), defaults to 0
|
|
4962
5548
|
*/
|
|
4963
5549
|
function GetOperands(s, exponent = 0) {
|
|
4964
|
-
invariant
|
|
4965
|
-
const n =
|
|
4966
|
-
invariant
|
|
5550
|
+
invariant(typeof s === "string", `GetOperands should have been called with a string`);
|
|
5551
|
+
const n = new BigDecimal(s);
|
|
5552
|
+
invariant(n.isFinite(), "n should be finite");
|
|
4967
5553
|
let dp = s.indexOf(".");
|
|
4968
5554
|
let iv;
|
|
4969
5555
|
let f;
|
|
4970
5556
|
let v;
|
|
4971
5557
|
let fv = "";
|
|
4972
5558
|
if (dp === -1) {
|
|
4973
|
-
iv =
|
|
4974
|
-
f = ZERO
|
|
5559
|
+
iv = s;
|
|
5560
|
+
f = ZERO;
|
|
4975
5561
|
v = 0;
|
|
4976
5562
|
} else {
|
|
4977
5563
|
iv = s.slice(0, dp);
|
|
4978
5564
|
fv = s.slice(dp, s.length);
|
|
4979
|
-
f =
|
|
5565
|
+
f = new BigDecimal(fv);
|
|
4980
5566
|
v = fv.length;
|
|
4981
5567
|
}
|
|
4982
|
-
const i =
|
|
5568
|
+
const i = new BigDecimal(iv).abs();
|
|
4983
5569
|
let w;
|
|
4984
5570
|
let t;
|
|
4985
5571
|
if (!f.isZero()) {
|
|
4986
5572
|
const ft = fv.replace(/0+$/, "");
|
|
4987
5573
|
w = ft.length;
|
|
4988
|
-
t =
|
|
5574
|
+
t = new BigDecimal(ft);
|
|
4989
5575
|
} else {
|
|
4990
5576
|
w = 0;
|
|
4991
|
-
t = ZERO
|
|
5577
|
+
t = ZERO;
|
|
4992
5578
|
}
|
|
4993
5579
|
return {
|
|
4994
5580
|
Number: n,
|
|
@@ -5019,8 +5605,8 @@ function GetOperands(s, exponent = 0) {
|
|
|
5019
5605
|
*/
|
|
5020
5606
|
function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
5021
5607
|
const internalSlots = getInternalSlots(pl);
|
|
5022
|
-
invariant
|
|
5023
|
-
invariant
|
|
5608
|
+
invariant(Type(internalSlots) === "Object", "pl has to be an object");
|
|
5609
|
+
invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
5024
5610
|
if (!n.isFinite()) return {
|
|
5025
5611
|
formattedString: String(n),
|
|
5026
5612
|
pluralCategory: "other"
|
|
@@ -5028,11 +5614,19 @@ function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
5028
5614
|
const { locale, type, notation } = internalSlots;
|
|
5029
5615
|
const s = FormatNumericToString(internalSlots, n).formattedString;
|
|
5030
5616
|
let exponent = 0;
|
|
5031
|
-
if (notation === "compact"
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5617
|
+
if (notation === "compact") {
|
|
5618
|
+
const patterns = internalSlots.compactExponents?.[internalSlots.compactDisplay || "short"];
|
|
5619
|
+
const integer = (s[0] === "-" ? s.slice(1) : s).split(".")[0];
|
|
5620
|
+
let first = 0;
|
|
5621
|
+
while (first < integer.length && integer[first] === "0") first++;
|
|
5622
|
+
const magnitude = integer.length - first - 1;
|
|
5623
|
+
let selectedMagnitude = -1;
|
|
5624
|
+
if (patterns) for (const key in patterns) {
|
|
5625
|
+
const threshold = Number(key);
|
|
5626
|
+
if (threshold <= magnitude && threshold > selectedMagnitude) {
|
|
5627
|
+
selectedMagnitude = threshold;
|
|
5628
|
+
exponent = patterns[threshold];
|
|
5629
|
+
}
|
|
5036
5630
|
}
|
|
5037
5631
|
}
|
|
5038
5632
|
return {
|
|
@@ -5062,7 +5656,9 @@ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
5062
5656
|
* It resolves the appropriate plural form for a range by determining the plural forms of both the
|
|
5063
5657
|
* start and end values, then consulting locale-specific range data.
|
|
5064
5658
|
*
|
|
5659
|
+
* ECMA-402 §17.5.4 ResolvePluralRange, steps 1–3.
|
|
5065
5660
|
* Specification: https://tc39.es/ecma402/#sec-resolvepluralrange
|
|
5661
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/pluralrules.html#L356-L358
|
|
5066
5662
|
*
|
|
5067
5663
|
* @param pluralRules - An initialized PluralRules object
|
|
5068
5664
|
* @param x - Mathematical value for the range start
|
|
@@ -5070,10 +5666,10 @@ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
5070
5666
|
* @returns The plural category for the range (zero, one, two, few, many, or other)
|
|
5071
5667
|
*/
|
|
5072
5668
|
function ResolvePluralRange(pluralRules, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }) {
|
|
5073
|
-
if (
|
|
5669
|
+
if (x.isNaN() || y.isNaN()) throw new RangeError("selectRange requires start and end values not to be NaN");
|
|
5074
5670
|
const internalSlots = getInternalSlots(pluralRules);
|
|
5075
|
-
invariant
|
|
5076
|
-
invariant
|
|
5671
|
+
invariant(Type(internalSlots) === "Object", "pluralRules has to be an object");
|
|
5672
|
+
invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
5077
5673
|
const xp = ResolvePluralInternal(pluralRules, x, {
|
|
5078
5674
|
getInternalSlots,
|
|
5079
5675
|
PluralRuleSelect
|
|
@@ -5152,11 +5748,13 @@ var PluralRules = class PluralRules {
|
|
|
5152
5748
|
}
|
|
5153
5749
|
resolvedOptions() {
|
|
5154
5750
|
validateInstance(this, "resolvedOptions");
|
|
5155
|
-
const opts =
|
|
5751
|
+
const opts = {};
|
|
5156
5752
|
const internalSlots = getInternalSlots(this);
|
|
5157
5753
|
opts.locale = internalSlots.locale;
|
|
5158
5754
|
opts.type = internalSlots.type;
|
|
5159
5755
|
[
|
|
5756
|
+
"notation",
|
|
5757
|
+
"compactDisplay",
|
|
5160
5758
|
"minimumIntegerDigits",
|
|
5161
5759
|
"minimumFractionDigits",
|
|
5162
5760
|
"maximumFractionDigits",
|
|
@@ -5166,7 +5764,21 @@ var PluralRules = class PluralRules {
|
|
|
5166
5764
|
const val = internalSlots[field];
|
|
5167
5765
|
if (val !== void 0) opts[field] = val;
|
|
5168
5766
|
});
|
|
5169
|
-
|
|
5767
|
+
const categories = PluralRules.localeData[internalSlots.locale].categories[internalSlots.type];
|
|
5768
|
+
opts.pluralCategories = [
|
|
5769
|
+
"zero",
|
|
5770
|
+
"one",
|
|
5771
|
+
"two",
|
|
5772
|
+
"few",
|
|
5773
|
+
"many",
|
|
5774
|
+
"other"
|
|
5775
|
+
].filter((category) => categories.includes(category));
|
|
5776
|
+
for (const field of [
|
|
5777
|
+
"roundingIncrement",
|
|
5778
|
+
"roundingMode",
|
|
5779
|
+
"roundingPriority",
|
|
5780
|
+
"trailingZeroDisplay"
|
|
5781
|
+
]) opts[field] = internalSlots[field];
|
|
5170
5782
|
return opts;
|
|
5171
5783
|
}
|
|
5172
5784
|
select(val) {
|
|
@@ -5205,7 +5817,7 @@ var PluralRules = class PluralRules {
|
|
|
5205
5817
|
* pr.selectRange(BigInt(1), BigInt(2)); // "other"
|
|
5206
5818
|
*
|
|
5207
5819
|
* @throws {TypeError} If start or end is undefined
|
|
5208
|
-
* @throws {RangeError} If start or end
|
|
5820
|
+
* @throws {RangeError} If start or end converts to NaN
|
|
5209
5821
|
*
|
|
5210
5822
|
* @note Chrome's native implementation (as of early 2025) has a bug where it throws
|
|
5211
5823
|
* "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
|
|
@@ -5230,8 +5842,7 @@ var PluralRules = class PluralRules {
|
|
|
5230
5842
|
}
|
|
5231
5843
|
static __addLocaleData(...data) {
|
|
5232
5844
|
for (const { data: d, locale } of data) {
|
|
5233
|
-
PluralRules.localeData
|
|
5234
|
-
PluralRules.availableLocales.add(locale);
|
|
5845
|
+
registerLocaleData(locale, d, PluralRules.localeData, PluralRules.availableLocales);
|
|
5235
5846
|
if (!PluralRules.__defaultLocale) PluralRules.__defaultLocale = locale;
|
|
5236
5847
|
}
|
|
5237
5848
|
}
|
|
@@ -5289,6 +5900,234 @@ try {
|
|
|
5289
5900
|
});
|
|
5290
5901
|
} catch {}
|
|
5291
5902
|
//#endregion
|
|
5903
|
+
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-locales@0.0.0/node_modules/@formatjs_generated/cldr.supported-locales/intl-pluralrules.js
|
|
5904
|
+
const supportedLocales = [
|
|
5905
|
+
"af",
|
|
5906
|
+
"ak",
|
|
5907
|
+
"am",
|
|
5908
|
+
"an",
|
|
5909
|
+
"ar",
|
|
5910
|
+
"ars",
|
|
5911
|
+
"as",
|
|
5912
|
+
"asa",
|
|
5913
|
+
"ast",
|
|
5914
|
+
"az",
|
|
5915
|
+
"bal",
|
|
5916
|
+
"be",
|
|
5917
|
+
"bem",
|
|
5918
|
+
"bez",
|
|
5919
|
+
"bg",
|
|
5920
|
+
"bho",
|
|
5921
|
+
"blo",
|
|
5922
|
+
"bm",
|
|
5923
|
+
"bn",
|
|
5924
|
+
"bo",
|
|
5925
|
+
"br",
|
|
5926
|
+
"brx",
|
|
5927
|
+
"bs",
|
|
5928
|
+
"ca",
|
|
5929
|
+
"ce",
|
|
5930
|
+
"ceb",
|
|
5931
|
+
"cgg",
|
|
5932
|
+
"chr",
|
|
5933
|
+
"ckb",
|
|
5934
|
+
"cs",
|
|
5935
|
+
"csw",
|
|
5936
|
+
"cv",
|
|
5937
|
+
"cy",
|
|
5938
|
+
"da",
|
|
5939
|
+
"de",
|
|
5940
|
+
"doi",
|
|
5941
|
+
"dsb",
|
|
5942
|
+
"dv",
|
|
5943
|
+
"dz",
|
|
5944
|
+
"ee",
|
|
5945
|
+
"el",
|
|
5946
|
+
"en",
|
|
5947
|
+
"eo",
|
|
5948
|
+
"es",
|
|
5949
|
+
"et",
|
|
5950
|
+
"eu",
|
|
5951
|
+
"fa",
|
|
5952
|
+
"ff",
|
|
5953
|
+
"fi",
|
|
5954
|
+
"fil",
|
|
5955
|
+
"fo",
|
|
5956
|
+
"fr",
|
|
5957
|
+
"fur",
|
|
5958
|
+
"fy",
|
|
5959
|
+
"ga",
|
|
5960
|
+
"gd",
|
|
5961
|
+
"gl",
|
|
5962
|
+
"gsw",
|
|
5963
|
+
"gu",
|
|
5964
|
+
"guw",
|
|
5965
|
+
"gv",
|
|
5966
|
+
"ha",
|
|
5967
|
+
"haw",
|
|
5968
|
+
"he",
|
|
5969
|
+
"hi",
|
|
5970
|
+
"hnj",
|
|
5971
|
+
"hr",
|
|
5972
|
+
"hsb",
|
|
5973
|
+
"hu",
|
|
5974
|
+
"hy",
|
|
5975
|
+
"ia",
|
|
5976
|
+
"id",
|
|
5977
|
+
"ie",
|
|
5978
|
+
"ig",
|
|
5979
|
+
"ii",
|
|
5980
|
+
"io",
|
|
5981
|
+
"is",
|
|
5982
|
+
"it",
|
|
5983
|
+
"iu",
|
|
5984
|
+
"ja",
|
|
5985
|
+
"jbo",
|
|
5986
|
+
"jgo",
|
|
5987
|
+
"jmc",
|
|
5988
|
+
"jv",
|
|
5989
|
+
"jw",
|
|
5990
|
+
"ka",
|
|
5991
|
+
"kab",
|
|
5992
|
+
"kaj",
|
|
5993
|
+
"kcg",
|
|
5994
|
+
"kde",
|
|
5995
|
+
"kea",
|
|
5996
|
+
"kk",
|
|
5997
|
+
"kkj",
|
|
5998
|
+
"kl",
|
|
5999
|
+
"km",
|
|
6000
|
+
"kn",
|
|
6001
|
+
"ko",
|
|
6002
|
+
"kok",
|
|
6003
|
+
"kok-Latn",
|
|
6004
|
+
"ks",
|
|
6005
|
+
"ksb",
|
|
6006
|
+
"ksh",
|
|
6007
|
+
"ku",
|
|
6008
|
+
"kw",
|
|
6009
|
+
"ky",
|
|
6010
|
+
"lag",
|
|
6011
|
+
"lb",
|
|
6012
|
+
"lg",
|
|
6013
|
+
"lij",
|
|
6014
|
+
"lkt",
|
|
6015
|
+
"lld",
|
|
6016
|
+
"ln",
|
|
6017
|
+
"lo",
|
|
6018
|
+
"lt",
|
|
6019
|
+
"lv",
|
|
6020
|
+
"mas",
|
|
6021
|
+
"mg",
|
|
6022
|
+
"mgo",
|
|
6023
|
+
"mk",
|
|
6024
|
+
"ml",
|
|
6025
|
+
"mn",
|
|
6026
|
+
"mo",
|
|
6027
|
+
"mr",
|
|
6028
|
+
"ms",
|
|
6029
|
+
"mt",
|
|
6030
|
+
"my",
|
|
6031
|
+
"nah",
|
|
6032
|
+
"naq",
|
|
6033
|
+
"nb",
|
|
6034
|
+
"nd",
|
|
6035
|
+
"ne",
|
|
6036
|
+
"nl",
|
|
6037
|
+
"nn",
|
|
6038
|
+
"nnh",
|
|
6039
|
+
"no",
|
|
6040
|
+
"nqo",
|
|
6041
|
+
"nr",
|
|
6042
|
+
"nso",
|
|
6043
|
+
"ny",
|
|
6044
|
+
"nyn",
|
|
6045
|
+
"om",
|
|
6046
|
+
"or",
|
|
6047
|
+
"os",
|
|
6048
|
+
"osa",
|
|
6049
|
+
"pa",
|
|
6050
|
+
"pap",
|
|
6051
|
+
"pcm",
|
|
6052
|
+
"pl",
|
|
6053
|
+
"prg",
|
|
6054
|
+
"ps",
|
|
6055
|
+
"pt",
|
|
6056
|
+
"pt-PT",
|
|
6057
|
+
"rm",
|
|
6058
|
+
"ro",
|
|
6059
|
+
"rof",
|
|
6060
|
+
"ru",
|
|
6061
|
+
"rwk",
|
|
6062
|
+
"sah",
|
|
6063
|
+
"saq",
|
|
6064
|
+
"sat",
|
|
6065
|
+
"sc",
|
|
6066
|
+
"scn",
|
|
6067
|
+
"sd",
|
|
6068
|
+
"sdh",
|
|
6069
|
+
"se",
|
|
6070
|
+
"seh",
|
|
6071
|
+
"ses",
|
|
6072
|
+
"sg",
|
|
6073
|
+
"sgs",
|
|
6074
|
+
"sh",
|
|
6075
|
+
"shi",
|
|
6076
|
+
"si",
|
|
6077
|
+
"sk",
|
|
6078
|
+
"sl",
|
|
6079
|
+
"sma",
|
|
6080
|
+
"smi",
|
|
6081
|
+
"smj",
|
|
6082
|
+
"smn",
|
|
6083
|
+
"sms",
|
|
6084
|
+
"sn",
|
|
6085
|
+
"so",
|
|
6086
|
+
"sq",
|
|
6087
|
+
"sr",
|
|
6088
|
+
"ss",
|
|
6089
|
+
"ssy",
|
|
6090
|
+
"st",
|
|
6091
|
+
"su",
|
|
6092
|
+
"sv",
|
|
6093
|
+
"sw",
|
|
6094
|
+
"syr",
|
|
6095
|
+
"ta",
|
|
6096
|
+
"te",
|
|
6097
|
+
"teo",
|
|
6098
|
+
"th",
|
|
6099
|
+
"ti",
|
|
6100
|
+
"tig",
|
|
6101
|
+
"tk",
|
|
6102
|
+
"tl",
|
|
6103
|
+
"tn",
|
|
6104
|
+
"to",
|
|
6105
|
+
"tpi",
|
|
6106
|
+
"tr",
|
|
6107
|
+
"ts",
|
|
6108
|
+
"tzm",
|
|
6109
|
+
"ug",
|
|
6110
|
+
"uk",
|
|
6111
|
+
"und",
|
|
6112
|
+
"ur",
|
|
6113
|
+
"uz",
|
|
6114
|
+
"ve",
|
|
6115
|
+
"vec",
|
|
6116
|
+
"vi",
|
|
6117
|
+
"vo",
|
|
6118
|
+
"vun",
|
|
6119
|
+
"wa",
|
|
6120
|
+
"wae",
|
|
6121
|
+
"wo",
|
|
6122
|
+
"xh",
|
|
6123
|
+
"xog",
|
|
6124
|
+
"yi",
|
|
6125
|
+
"yo",
|
|
6126
|
+
"yue",
|
|
6127
|
+
"zh",
|
|
6128
|
+
"zu"
|
|
6129
|
+
];
|
|
6130
|
+
//#endregion
|
|
5292
6131
|
//#region packages/intl-pluralrules/should-polyfill.ts
|
|
5293
6132
|
function supportedLocalesOf(locale) {
|
|
5294
6133
|
if (!locale) return true;
|