@formatjs/intl-relativetimeformat 10.0.0 → 10.0.1

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/polyfill.iife.js +235 -364
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-relativetimeformat",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
4
4
  "description": "Formats JavaScript dates to relative time strings.",
5
5
  "keywords": [
6
6
  "intl",
@@ -20,8 +20,8 @@
20
20
  "url": "git@github.com:formatjs/formatjs.git"
21
21
  },
22
22
  "dependencies": {
23
- "@formatjs/ecma402-abstract": "1.11.3",
24
- "@formatjs/intl-localematcher": "0.2.24",
23
+ "@formatjs/ecma402-abstract": "1.11.4",
24
+ "@formatjs/intl-localematcher": "0.2.25",
25
25
  "tslib": "^2.1.0"
26
26
  },
27
27
  "main": "index.js",
package/polyfill.iife.js CHANGED
@@ -1,359 +1,4 @@
1
1
  (function() {
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __markAsModule = function(target) {
9
- return __defProp(target, "__esModule", { value: true });
10
- };
11
- var __commonJS = function(cb, mod) {
12
- return function __require() {
13
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
- };
15
- };
16
- var __reExport = function(target, module, copyDefault, desc) {
17
- if (module && typeof module === "object" || typeof module === "function")
18
- for (var keys = __getOwnPropNames(module), i = 0, n = keys.length, key; i < n; i++) {
19
- key = keys[i];
20
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
21
- __defProp(target, key, { get: function(k) {
22
- return module[k];
23
- }.bind(null, key), enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
24
- }
25
- return target;
26
- };
27
- var __toESM = function(module, isNodeMode) {
28
- return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: function() {
29
- return module.default;
30
- }, enumerable: true } : { value: module, enumerable: true })), module);
31
- };
32
-
33
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/CanonicalizeLocaleList.js
34
- var require_CanonicalizeLocaleList = __commonJS({
35
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/CanonicalizeLocaleList.js": function(exports) {
36
- "use strict";
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.CanonicalizeLocaleList = void 0;
39
- function CanonicalizeLocaleList2(locales) {
40
- return Intl.getCanonicalLocales(locales);
41
- }
42
- exports.CanonicalizeLocaleList = CanonicalizeLocaleList2;
43
- }
44
- });
45
-
46
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js
47
- var require_utils = __commonJS({
48
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
49
- "use strict";
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = void 0;
52
- exports.UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
53
- function invariant2(condition, message, Err) {
54
- if (Err === void 0) {
55
- Err = Error;
56
- }
57
- if (!condition) {
58
- throw new Err(message);
59
- }
60
- }
61
- exports.invariant = invariant2;
62
- }
63
- });
64
-
65
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js
66
- var require_BestAvailableLocale = __commonJS({
67
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js": function(exports) {
68
- "use strict";
69
- Object.defineProperty(exports, "__esModule", { value: true });
70
- exports.BestAvailableLocale = void 0;
71
- function BestAvailableLocale(availableLocales, locale) {
72
- var candidate = locale;
73
- while (true) {
74
- if (availableLocales.has(candidate)) {
75
- return candidate;
76
- }
77
- var pos = candidate.lastIndexOf("-");
78
- if (!~pos) {
79
- return void 0;
80
- }
81
- if (pos >= 2 && candidate[pos - 2] === "-") {
82
- pos -= 2;
83
- }
84
- candidate = candidate.slice(0, pos);
85
- }
86
- }
87
- exports.BestAvailableLocale = BestAvailableLocale;
88
- }
89
- });
90
-
91
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js
92
- var require_LookupMatcher = __commonJS({
93
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js": function(exports) {
94
- "use strict";
95
- Object.defineProperty(exports, "__esModule", { value: true });
96
- exports.LookupMatcher = void 0;
97
- var utils_1 = require_utils();
98
- var BestAvailableLocale_1 = require_BestAvailableLocale();
99
- function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
100
- var result = { locale: "" };
101
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
102
- var locale = requestedLocales_1[_i];
103
- var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
104
- var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
105
- if (availableLocale) {
106
- result.locale = availableLocale;
107
- if (locale !== noExtensionLocale) {
108
- result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
109
- }
110
- return result;
111
- }
112
- }
113
- result.locale = getDefaultLocale();
114
- return result;
115
- }
116
- exports.LookupMatcher = LookupMatcher;
117
- }
118
- });
119
-
120
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js
121
- var require_BestFitMatcher = __commonJS({
122
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js": function(exports) {
123
- "use strict";
124
- Object.defineProperty(exports, "__esModule", { value: true });
125
- exports.BestFitMatcher = void 0;
126
- var BestAvailableLocale_1 = require_BestAvailableLocale();
127
- var utils_1 = require_utils();
128
- function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
129
- var minimizedAvailableLocaleMap = {};
130
- var availableLocaleMap = {};
131
- var canonicalizedLocaleMap = {};
132
- var minimizedAvailableLocales = /* @__PURE__ */ new Set();
133
- availableLocales.forEach(function(locale2) {
134
- var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
135
- var canonicalizedLocale = Intl.getCanonicalLocales(locale2)[0] || locale2;
136
- minimizedAvailableLocaleMap[minimizedLocale] = locale2;
137
- availableLocaleMap[locale2] = locale2;
138
- canonicalizedLocaleMap[canonicalizedLocale] = locale2;
139
- minimizedAvailableLocales.add(minimizedLocale);
140
- minimizedAvailableLocales.add(locale2);
141
- minimizedAvailableLocales.add(canonicalizedLocale);
142
- });
143
- var foundLocale;
144
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
145
- var l = requestedLocales_1[_i];
146
- if (foundLocale) {
147
- break;
148
- }
149
- var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
150
- if (availableLocales.has(noExtensionLocale)) {
151
- foundLocale = noExtensionLocale;
152
- break;
153
- }
154
- if (minimizedAvailableLocales.has(noExtensionLocale)) {
155
- foundLocale = noExtensionLocale;
156
- break;
157
- }
158
- var locale = new Intl.Locale(noExtensionLocale);
159
- var maximizedRequestedLocale = locale.maximize().toString();
160
- var minimizedRequestedLocale = locale.minimize().toString();
161
- if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
162
- foundLocale = minimizedRequestedLocale;
163
- break;
164
- }
165
- foundLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(minimizedAvailableLocales, maximizedRequestedLocale);
166
- }
167
- if (!foundLocale) {
168
- return { locale: getDefaultLocale() };
169
- }
170
- return {
171
- locale: availableLocaleMap[foundLocale] || canonicalizedLocaleMap[foundLocale] || minimizedAvailableLocaleMap[foundLocale] || foundLocale
172
- };
173
- }
174
- exports.BestFitMatcher = BestFitMatcher;
175
- }
176
- });
177
-
178
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js
179
- var require_UnicodeExtensionValue = __commonJS({
180
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js": function(exports) {
181
- "use strict";
182
- Object.defineProperty(exports, "__esModule", { value: true });
183
- exports.UnicodeExtensionValue = void 0;
184
- var utils_1 = require_utils();
185
- function UnicodeExtensionValue(extension, key) {
186
- (0, utils_1.invariant)(key.length === 2, "key must have 2 elements");
187
- var size = extension.length;
188
- var searchValue = "-".concat(key, "-");
189
- var pos = extension.indexOf(searchValue);
190
- if (pos !== -1) {
191
- var start = pos + 4;
192
- var end = start;
193
- var k = start;
194
- var done = false;
195
- while (!done) {
196
- var e = extension.indexOf("-", k);
197
- var len = void 0;
198
- if (e === -1) {
199
- len = size - k;
200
- } else {
201
- len = e - k;
202
- }
203
- if (len === 2) {
204
- done = true;
205
- } else if (e === -1) {
206
- end = size;
207
- done = true;
208
- } else {
209
- end = e;
210
- k = e + 1;
211
- }
212
- }
213
- return extension.slice(start, end);
214
- }
215
- searchValue = "-".concat(key);
216
- pos = extension.indexOf(searchValue);
217
- if (pos !== -1 && pos + 3 === size) {
218
- return "";
219
- }
220
- return void 0;
221
- }
222
- exports.UnicodeExtensionValue = UnicodeExtensionValue;
223
- }
224
- });
225
-
226
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js
227
- var require_ResolveLocale = __commonJS({
228
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js": function(exports) {
229
- "use strict";
230
- Object.defineProperty(exports, "__esModule", { value: true });
231
- exports.ResolveLocale = void 0;
232
- var LookupMatcher_1 = require_LookupMatcher();
233
- var BestFitMatcher_1 = require_BestFitMatcher();
234
- var utils_1 = require_utils();
235
- var UnicodeExtensionValue_1 = require_UnicodeExtensionValue();
236
- function ResolveLocale2(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
237
- var matcher = options.localeMatcher;
238
- var r;
239
- if (matcher === "lookup") {
240
- r = (0, LookupMatcher_1.LookupMatcher)(availableLocales, requestedLocales, getDefaultLocale);
241
- } else {
242
- r = (0, BestFitMatcher_1.BestFitMatcher)(availableLocales, requestedLocales, getDefaultLocale);
243
- }
244
- var foundLocale = r.locale;
245
- var result = { locale: "", dataLocale: foundLocale };
246
- var supportedExtension = "-u";
247
- for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
248
- var key = relevantExtensionKeys_1[_i];
249
- (0, utils_1.invariant)(foundLocale in localeData, "Missing locale data for ".concat(foundLocale));
250
- var foundLocaleData = localeData[foundLocale];
251
- (0, utils_1.invariant)(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data ".concat(key, " must be an object"));
252
- var keyLocaleData = foundLocaleData[key];
253
- (0, utils_1.invariant)(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key, " must be an array"));
254
- var value = keyLocaleData[0];
255
- (0, utils_1.invariant)(typeof value === "string" || value === null, "value must be string or null but got ".concat(typeof value, " in key ").concat(key));
256
- var supportedExtensionAddition = "";
257
- if (r.extension) {
258
- var requestedValue = (0, UnicodeExtensionValue_1.UnicodeExtensionValue)(r.extension, key);
259
- if (requestedValue !== void 0) {
260
- if (requestedValue !== "") {
261
- if (~keyLocaleData.indexOf(requestedValue)) {
262
- value = requestedValue;
263
- supportedExtensionAddition = "-".concat(key, "-").concat(value);
264
- }
265
- } else if (~requestedValue.indexOf("true")) {
266
- value = "true";
267
- supportedExtensionAddition = "-".concat(key);
268
- }
269
- }
270
- }
271
- if (key in options) {
272
- var optionsValue = options[key];
273
- (0, utils_1.invariant)(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
274
- if (~keyLocaleData.indexOf(optionsValue)) {
275
- if (optionsValue !== value) {
276
- value = optionsValue;
277
- supportedExtensionAddition = "";
278
- }
279
- }
280
- }
281
- result[key] = value;
282
- supportedExtension += supportedExtensionAddition;
283
- }
284
- if (supportedExtension.length > 2) {
285
- var privateIndex = foundLocale.indexOf("-x-");
286
- if (privateIndex === -1) {
287
- foundLocale = foundLocale + supportedExtension;
288
- } else {
289
- var preExtension = foundLocale.slice(0, privateIndex);
290
- var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
291
- foundLocale = preExtension + supportedExtension + postExtension;
292
- }
293
- foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
294
- }
295
- result.locale = foundLocale;
296
- return result;
297
- }
298
- exports.ResolveLocale = ResolveLocale2;
299
- }
300
- });
301
-
302
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js
303
- var require_LookupSupportedLocales = __commonJS({
304
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js": function(exports) {
305
- "use strict";
306
- Object.defineProperty(exports, "__esModule", { value: true });
307
- exports.LookupSupportedLocales = void 0;
308
- var utils_1 = require_utils();
309
- var BestAvailableLocale_1 = require_BestAvailableLocale();
310
- function LookupSupportedLocales2(availableLocales, requestedLocales) {
311
- var subset = [];
312
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
313
- var locale = requestedLocales_1[_i];
314
- var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
315
- var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
316
- if (availableLocale) {
317
- subset.push(availableLocale);
318
- }
319
- }
320
- return subset;
321
- }
322
- exports.LookupSupportedLocales = LookupSupportedLocales2;
323
- }
324
- });
325
-
326
- // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js
327
- var require_intl_localematcher = __commonJS({
328
- "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js": function(exports) {
329
- "use strict";
330
- Object.defineProperty(exports, "__esModule", { value: true });
331
- exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
332
- var CanonicalizeLocaleList_1 = require_CanonicalizeLocaleList();
333
- var ResolveLocale_1 = require_ResolveLocale();
334
- function match2(requestedLocales, availableLocales, defaultLocale, opts) {
335
- var locales = availableLocales.reduce(function(all, l) {
336
- all.add(l);
337
- return all;
338
- }, /* @__PURE__ */ new Set());
339
- return (0, ResolveLocale_1.ResolveLocale)(locales, (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(requestedLocales), {
340
- localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
341
- }, [], {}, function() {
342
- return defaultLocale;
343
- }).locale;
344
- }
345
- exports.match = match2;
346
- var LookupSupportedLocales_1 = require_LookupSupportedLocales();
347
- Object.defineProperty(exports, "LookupSupportedLocales", { enumerable: true, get: function() {
348
- return LookupSupportedLocales_1.LookupSupportedLocales;
349
- } });
350
- var ResolveLocale_2 = require_ResolveLocale();
351
- Object.defineProperty(exports, "ResolveLocale", { enumerable: true, get: function() {
352
- return ResolveLocale_2.ResolveLocale;
353
- } });
354
- }
355
- });
356
-
357
2
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/CanonicalizeLocaleList.js
358
3
  function CanonicalizeLocaleList(locales) {
359
4
  return Intl.getCanonicalLocales(locales);
@@ -457,6 +102,237 @@
457
102
  }
458
103
  }
459
104
 
105
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/CanonicalizeLocaleList.js
106
+ function CanonicalizeLocaleList2(locales) {
107
+ return Intl.getCanonicalLocales(locales);
108
+ }
109
+
110
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/utils.js
111
+ var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
112
+ function invariant2(condition, message, Err) {
113
+ if (Err === void 0) {
114
+ Err = Error;
115
+ }
116
+ if (!condition) {
117
+ throw new Err(message);
118
+ }
119
+ }
120
+
121
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/BestAvailableLocale.js
122
+ function BestAvailableLocale(availableLocales, locale) {
123
+ var candidate = locale;
124
+ while (true) {
125
+ if (availableLocales.has(candidate)) {
126
+ return candidate;
127
+ }
128
+ var pos = candidate.lastIndexOf("-");
129
+ if (!~pos) {
130
+ return void 0;
131
+ }
132
+ if (pos >= 2 && candidate[pos - 2] === "-") {
133
+ pos -= 2;
134
+ }
135
+ candidate = candidate.slice(0, pos);
136
+ }
137
+ }
138
+
139
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/LookupMatcher.js
140
+ function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
141
+ var result = { locale: "" };
142
+ for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
143
+ var locale = requestedLocales_1[_i];
144
+ var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
145
+ var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
146
+ if (availableLocale) {
147
+ result.locale = availableLocale;
148
+ if (locale !== noExtensionLocale) {
149
+ result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
150
+ }
151
+ return result;
152
+ }
153
+ }
154
+ result.locale = getDefaultLocale();
155
+ return result;
156
+ }
157
+
158
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/BestFitMatcher.js
159
+ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
160
+ var minimizedAvailableLocaleMap = {};
161
+ var availableLocaleMap = {};
162
+ var canonicalizedLocaleMap = {};
163
+ var minimizedAvailableLocales = /* @__PURE__ */ new Set();
164
+ availableLocales.forEach(function(locale2) {
165
+ var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
166
+ var canonicalizedLocale = Intl.getCanonicalLocales(locale2)[0] || locale2;
167
+ minimizedAvailableLocaleMap[minimizedLocale] = locale2;
168
+ availableLocaleMap[locale2] = locale2;
169
+ canonicalizedLocaleMap[canonicalizedLocale] = locale2;
170
+ minimizedAvailableLocales.add(minimizedLocale);
171
+ minimizedAvailableLocales.add(locale2);
172
+ minimizedAvailableLocales.add(canonicalizedLocale);
173
+ });
174
+ var foundLocale;
175
+ for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
176
+ var l = requestedLocales_1[_i];
177
+ if (foundLocale) {
178
+ break;
179
+ }
180
+ var noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
181
+ if (availableLocales.has(noExtensionLocale)) {
182
+ foundLocale = noExtensionLocale;
183
+ break;
184
+ }
185
+ if (minimizedAvailableLocales.has(noExtensionLocale)) {
186
+ foundLocale = noExtensionLocale;
187
+ break;
188
+ }
189
+ var locale = new Intl.Locale(noExtensionLocale);
190
+ var maximizedRequestedLocale = locale.maximize().toString();
191
+ var minimizedRequestedLocale = locale.minimize().toString();
192
+ if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
193
+ foundLocale = minimizedRequestedLocale;
194
+ break;
195
+ }
196
+ foundLocale = BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
197
+ }
198
+ if (!foundLocale) {
199
+ return { locale: getDefaultLocale() };
200
+ }
201
+ return {
202
+ locale: availableLocaleMap[foundLocale] || canonicalizedLocaleMap[foundLocale] || minimizedAvailableLocaleMap[foundLocale] || foundLocale
203
+ };
204
+ }
205
+
206
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/UnicodeExtensionValue.js
207
+ function UnicodeExtensionValue(extension, key) {
208
+ invariant2(key.length === 2, "key must have 2 elements");
209
+ var size = extension.length;
210
+ var searchValue = "-".concat(key, "-");
211
+ var pos = extension.indexOf(searchValue);
212
+ if (pos !== -1) {
213
+ var start = pos + 4;
214
+ var end = start;
215
+ var k = start;
216
+ var done = false;
217
+ while (!done) {
218
+ var e = extension.indexOf("-", k);
219
+ var len = void 0;
220
+ if (e === -1) {
221
+ len = size - k;
222
+ } else {
223
+ len = e - k;
224
+ }
225
+ if (len === 2) {
226
+ done = true;
227
+ } else if (e === -1) {
228
+ end = size;
229
+ done = true;
230
+ } else {
231
+ end = e;
232
+ k = e + 1;
233
+ }
234
+ }
235
+ return extension.slice(start, end);
236
+ }
237
+ searchValue = "-".concat(key);
238
+ pos = extension.indexOf(searchValue);
239
+ if (pos !== -1 && pos + 3 === size) {
240
+ return "";
241
+ }
242
+ return void 0;
243
+ }
244
+
245
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/ResolveLocale.js
246
+ function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
247
+ var matcher = options.localeMatcher;
248
+ var r;
249
+ if (matcher === "lookup") {
250
+ r = LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
251
+ } else {
252
+ r = BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
253
+ }
254
+ var foundLocale = r.locale;
255
+ var result = { locale: "", dataLocale: foundLocale };
256
+ var supportedExtension = "-u";
257
+ for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
258
+ var key = relevantExtensionKeys_1[_i];
259
+ invariant2(foundLocale in localeData, "Missing locale data for ".concat(foundLocale));
260
+ var foundLocaleData = localeData[foundLocale];
261
+ invariant2(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data ".concat(key, " must be an object"));
262
+ var keyLocaleData = foundLocaleData[key];
263
+ invariant2(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key, " must be an array"));
264
+ var value = keyLocaleData[0];
265
+ invariant2(typeof value === "string" || value === null, "value must be string or null but got ".concat(typeof value, " in key ").concat(key));
266
+ var supportedExtensionAddition = "";
267
+ if (r.extension) {
268
+ var requestedValue = UnicodeExtensionValue(r.extension, key);
269
+ if (requestedValue !== void 0) {
270
+ if (requestedValue !== "") {
271
+ if (~keyLocaleData.indexOf(requestedValue)) {
272
+ value = requestedValue;
273
+ supportedExtensionAddition = "-".concat(key, "-").concat(value);
274
+ }
275
+ } else if (~requestedValue.indexOf("true")) {
276
+ value = "true";
277
+ supportedExtensionAddition = "-".concat(key);
278
+ }
279
+ }
280
+ }
281
+ if (key in options) {
282
+ var optionsValue = options[key];
283
+ invariant2(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
284
+ if (~keyLocaleData.indexOf(optionsValue)) {
285
+ if (optionsValue !== value) {
286
+ value = optionsValue;
287
+ supportedExtensionAddition = "";
288
+ }
289
+ }
290
+ }
291
+ result[key] = value;
292
+ supportedExtension += supportedExtensionAddition;
293
+ }
294
+ if (supportedExtension.length > 2) {
295
+ var privateIndex = foundLocale.indexOf("-x-");
296
+ if (privateIndex === -1) {
297
+ foundLocale = foundLocale + supportedExtension;
298
+ } else {
299
+ var preExtension = foundLocale.slice(0, privateIndex);
300
+ var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
301
+ foundLocale = preExtension + supportedExtension + postExtension;
302
+ }
303
+ foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
304
+ }
305
+ result.locale = foundLocale;
306
+ return result;
307
+ }
308
+
309
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/abstract/LookupSupportedLocales.js
310
+ function LookupSupportedLocales(availableLocales, requestedLocales) {
311
+ var subset = [];
312
+ for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
313
+ var locale = requestedLocales_1[_i];
314
+ var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
315
+ var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
316
+ if (availableLocale) {
317
+ subset.push(availableLocale);
318
+ }
319
+ }
320
+ return subset;
321
+ }
322
+
323
+ // bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/lib/index.js
324
+ function match(requestedLocales, availableLocales, defaultLocale, opts) {
325
+ var locales = availableLocales.reduce(function(all, l) {
326
+ all.add(l);
327
+ return all;
328
+ }, /* @__PURE__ */ new Set());
329
+ return ResolveLocale(locales, CanonicalizeLocaleList2(requestedLocales), {
330
+ localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
331
+ }, [], {}, function() {
332
+ return defaultLocale;
333
+ }).locale;
334
+ }
335
+
460
336
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/PartitionPattern.js
461
337
  function PartitionPattern(pattern) {
462
338
  var result = [];
@@ -490,7 +366,6 @@
490
366
  }
491
367
 
492
368
  // bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/SupportedLocales.js
493
- var import_intl_localematcher = __toESM(require_intl_localematcher());
494
369
  function SupportedLocales(availableLocales, requestedLocales, options) {
495
370
  var matcher = "best fit";
496
371
  if (options !== void 0) {
@@ -498,13 +373,12 @@
498
373
  matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
499
374
  }
500
375
  if (matcher === "best fit") {
501
- return (0, import_intl_localematcher.LookupSupportedLocales)(availableLocales, requestedLocales);
376
+ return LookupSupportedLocales(availableLocales, requestedLocales);
502
377
  }
503
- return (0, import_intl_localematcher.LookupSupportedLocales)(availableLocales, requestedLocales);
378
+ return LookupSupportedLocales(availableLocales, requestedLocales);
504
379
  }
505
380
 
506
381
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/abstract/InitializeRelativeTimeFormat.js
507
- var import_intl_localematcher2 = __toESM(require_intl_localematcher());
508
382
  var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
509
383
  function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
510
384
  var getInternalSlots2 = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
@@ -522,7 +396,7 @@
522
396
  }
523
397
  }
524
398
  opt.nu = numberingSystem;
525
- var r = (0, import_intl_localematcher2.ResolveLocale)(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
399
+ var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
526
400
  var locale = r.locale, nu = r.nu;
527
401
  internalSlots.locale = locale;
528
402
  internalSlots.style = GetOption(opts, "style", "string", ["long", "narrow", "short"], "long");
@@ -753,9 +627,6 @@
753
627
  } catch (e) {
754
628
  }
755
629
 
756
- // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/should-polyfill.js
757
- var import_intl_localematcher3 = __toESM(require_intl_localematcher());
758
-
759
630
  // bazel-out/darwin-fastbuild/bin/packages/intl-relativetimeformat/lib/supported-locales.js
760
631
  var supportedLocales = ["af-NA", "af", "agq", "ak", "am", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "ar", "as", "asa", "ast", "az-Cyrl", "az-Latn", "az", "bas", "be-tarask", "be", "bem", "bez", "bg", "bm", "bn-IN", "bn", "bo-IN", "bo", "br", "brx", "bs-Cyrl", "bs-Latn", "bs", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ca", "ccp-IN", "ccp", "ce", "ceb", "cgg", "chr", "ckb-IR", "ckb", "cs", "cy", "da-GL", "da", "dav", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "de", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee-TG", "ee", "el-CY", "el", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "en", "eo", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "es", "et", "eu", "ewo", "fa-AF", "fa", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Adlm", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "ff-Latn", "ff", "fi", "fil", "fo-DK", "fo", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fr", "fur", "fy", "ga-GB", "ga", "gd", "gl", "gsw-FR", "gsw-LI", "gsw", "gu", "guz", "gv", "ha-GH", "ha-NE", "ha", "haw", "he", "hi", "hr-BA", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it-CH", "it-SM", "it-VA", "it", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko-KP", "ko", "kok", "ks-Arab", "ks", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln-AO", "ln-CF", "ln-CG", "ln", "lo", "lrc-IQ", "lrc", "lt", "lu", "luo", "luy", "lv", "mai", "mas-TZ", "mas", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni-Beng", "mni", "mr", "ms-BN", "ms-ID", "ms-SG", "ms", "mt", "mua", "my", "mzn", "naq", "nb-SJ", "nb", "nd", "nds-NL", "nds", "ne-IN", "ne", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nl", "nmg", "nn", "nnh", "no", "nus", "nyn", "om-KE", "om", "or", "os-RU", "os", "pa-Arab", "pa-Guru", "pa", "pcm", "pl", "ps-PK", "ps", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "pt", "qu-BO", "qu-EC", "qu", "rm", "rn", "ro-MD", "ro", "rof", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "ru", "rw", "rwk", "sa", "sah", "saq", "sat-Olck", "sat", "sbp", "sc", "sd-Arab", "sd-Deva", "sd", "se-FI", "se-SE", "se", "seh", "ses", "sg", "shi-Latn", "shi-Tfng", "shi", "si", "sk", "sl", "smn", "sn", "so-DJ", "so-ET", "so-KE", "so", "sq-MK", "sq-XK", "sq", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Cyrl", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "sr-Latn", "sr", "su-Latn", "su", "sv-AX", "sv-FI", "sv", "sw-CD", "sw-KE", "sw-UG", "sw", "ta-LK", "ta-MY", "ta-SG", "ta", "te", "teo-KE", "teo", "tg", "th", "ti-ER", "ti", "tk", "to", "tr-CY", "tr", "tt", "twq", "tzm", "ug", "uk", "und", "ur-IN", "ur", "uz-Arab", "uz-Cyrl", "uz-Latn", "uz", "vai-Latn", "vai-Vaii", "vai", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo-BJ", "yo", "yrl-CO", "yrl-VE", "yrl", "yue-Hans", "yue-Hant", "yue", "zgh", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hans", "zh-Hant-HK", "zh-Hant-MO", "zh-Hant", "zh", "zu"];
761
632
 
@@ -781,7 +652,7 @@
781
652
  locale = "en";
782
653
  }
783
654
  if (!("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale) || !hasResolvedOptionsNumberingSystem(locale)) {
784
- return (0, import_intl_localematcher3.match)([locale], supportedLocales, "en");
655
+ return match([locale], supportedLocales, "en");
785
656
  }
786
657
  }
787
658