unicode-input-toolconverter 0.2.0 → 0.2.3

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 (143) hide show
  1. package/.nyc_output/out.json +8980 -1849
  2. package/CHANGES.md +15 -1
  3. package/README.md +6 -11
  4. package/_locales/en-US/messages.json +153 -6
  5. package/_locales/hu-HU/messages.json +153 -6
  6. package/_locales/pt-BR/messages.json +153 -6
  7. package/_locales/sv-SE/messages.json +153 -6
  8. package/babel.config.json +0 -1
  9. package/browser_action/characterSelection.js +18 -11
  10. package/browser_action/charrefConverters.js +286 -79
  11. package/browser_action/chartBuild.js +97 -27
  12. package/browser_action/encodingBehaviors.js +10 -7
  13. package/browser_action/entityBehaviors.js +42 -16
  14. package/browser_action/index-es.html +13 -1
  15. package/browser_action/index-instrumented.html +13 -1
  16. package/browser_action/index-pages.html +13 -1
  17. package/browser_action/index.html +13 -1
  18. package/browser_action/index.iife.min.js +9 -1
  19. package/browser_action/index.iife.min.js.map +1 -1
  20. package/browser_action/index.instrumented.iife.min.js +1 -1
  21. package/browser_action/index.instrumented.iife.min.js.map +1 -1
  22. package/browser_action/index.js +5 -5
  23. package/browser_action/preferences/prefDefaults.js +12 -3
  24. package/browser_action/service-worker/sw-activateCallback.js +1 -2
  25. package/browser_action/service-worker/sw-resources.json +6 -4
  26. package/browser_action/templateUtils/elements.js +12 -1
  27. package/browser_action/templateUtils/fill.js +6 -0
  28. package/browser_action/templateUtils/validation.js +4 -1
  29. package/browser_action/templates/chartBuild.js +167 -102
  30. package/browser_action/templates/index.js +227 -53
  31. package/browser_action/templatesElementCustomization/widgets.js +40 -15
  32. package/browser_action/unicode/UnicodeConverter.js +99 -73
  33. package/browser_action/unicode/charrefunicodeDb.js +100 -50
  34. package/browser_action/unicode/getScriptInfoForCodePoint.js +13 -4
  35. package/browser_action/unicode/hangul.js +27 -20
  36. package/browser_action/unicode/lastScriptNames.json +1 -1
  37. package/browser_action/unicode/parseUnihanFromTextFileStrings.js +44 -25
  38. package/browser_action/unicode/unicodeFieldInfo.js +112 -90
  39. package/browser_action/unicode/unicodeScripts.js +409 -35
  40. package/browser_action/unicode/unihan.js +4 -3
  41. package/browser_action/unicode/unihanDbPopulate.js +7 -2
  42. package/browser_action/unicode/unihanFields.js +34 -0
  43. package/browser_action/unicodecharref.js +353 -190
  44. package/browser_action/utils/DOMUtils.js +95 -34
  45. package/browser_action/utils/FetchUtils.js +7 -6
  46. package/browser_action/utils/TextUtils.js +4 -4
  47. package/browser_action/utils/TypedArrayUtils.js +9 -5
  48. package/browser_action/utils/semicolonSeparatedToArray.js +3 -3
  49. package/browser_action/utils/setupServiceWorker.js +2 -2
  50. package/eslint.config.js +11 -0
  51. package/icons/openWindow16.png +0 -0
  52. package/icons/openWindow24.png +0 -0
  53. package/lib/background.html +7 -0
  54. package/lib/background.js +2 -2
  55. package/package.json +80 -70
  56. package/pnpm-workspace.yaml +8 -0
  57. package/server.js +66 -51
  58. package/sw.js +97 -56
  59. package/tools/entities-import.js +4 -1
  60. package/tools/findEsResources.js +33 -10
  61. package/tools/fix-sw-resources-vendor-paths.js +60 -0
  62. package/tools/list-locales.js +2 -2
  63. package/tools/parseUnicodeCharts.js +126 -60
  64. package/tools/ucd-import.js +1 -10
  65. package/tools/unicode-charts.html +49 -20
  66. package/tools/unihan-import.js +45 -15
  67. package/tools/write-sw-version.js +16 -0
  68. package/tsconfig.json +23 -0
  69. package/typings/__coverage__.d.ts +5 -0
  70. package/typings/apple-system-profiler.d.ts +17 -0
  71. package/typings/commands.d.ts +19 -0
  72. package/typings/json-6.d.ts +4 -0
  73. package/typings/rollup-plugin-istanbul.d.ts +3 -0
  74. package/vendor/camelcase/index.d.ts +154 -0
  75. package/vendor/camelcase/index.js +137 -23
  76. package/vendor/fflate/esm/browser.d.ts +1539 -0
  77. package/vendor/fflate/esm/browser.js +82 -55
  78. package/vendor/intl-dom/dist/Formatter.d.ts +120 -0
  79. package/vendor/intl-dom/dist/Formatter.d.ts.map +1 -0
  80. package/vendor/intl-dom/dist/collation.d.ts +42 -0
  81. package/vendor/intl-dom/dist/collation.d.ts.map +1 -0
  82. package/vendor/intl-dom/dist/defaultAllSubstitutions.d.ts +52 -0
  83. package/vendor/intl-dom/dist/defaultAllSubstitutions.d.ts.map +1 -0
  84. package/vendor/intl-dom/dist/defaultInsertNodes.d.ts +96 -0
  85. package/vendor/intl-dom/dist/defaultInsertNodes.d.ts.map +1 -0
  86. package/vendor/intl-dom/dist/defaultKeyCheckerConverter.d.ts +17 -0
  87. package/vendor/intl-dom/dist/defaultKeyCheckerConverter.d.ts.map +1 -0
  88. package/vendor/intl-dom/dist/defaultLocaleResolver.d.ts +285 -0
  89. package/vendor/intl-dom/dist/defaultLocaleResolver.d.ts.map +1 -0
  90. package/vendor/intl-dom/dist/findLocaleStrings.d.ts +88 -0
  91. package/vendor/intl-dom/dist/findLocaleStrings.d.ts.map +1 -0
  92. package/vendor/intl-dom/dist/getDOMForLocaleString.d.ts +67 -0
  93. package/vendor/intl-dom/dist/getDOMForLocaleString.d.ts.map +1 -0
  94. package/vendor/intl-dom/dist/getMessageForKeyByStyle.d.ts +73 -0
  95. package/vendor/intl-dom/dist/getMessageForKeyByStyle.d.ts.map +1 -0
  96. package/vendor/intl-dom/dist/getStringFromMessageAndDefaults.d.ts +26 -0
  97. package/vendor/intl-dom/dist/getStringFromMessageAndDefaults.d.ts.map +1 -0
  98. package/vendor/intl-dom/dist/i18n.d.ts +113 -0
  99. package/vendor/intl-dom/dist/i18n.d.ts.map +1 -0
  100. package/vendor/intl-dom/dist/index.d.ts +92 -0
  101. package/vendor/intl-dom/dist/index.d.ts.map +1 -0
  102. package/vendor/intl-dom/dist/index.esm.d.ts +34 -0
  103. package/vendor/intl-dom/dist/index.esm.js +854 -896
  104. package/vendor/intl-dom/dist/index.esm.min.js +4 -0
  105. package/vendor/intl-dom/dist/index.esm.min.js.map +1 -0
  106. package/vendor/intl-dom/dist/index.umd.js +2953 -0
  107. package/vendor/intl-dom/dist/index.umd.min.js +4 -0
  108. package/vendor/intl-dom/dist/index.umd.min.js.map +1 -0
  109. package/vendor/intl-dom/dist/promiseChainForValues.d.ts +34 -0
  110. package/vendor/intl-dom/dist/promiseChainForValues.d.ts.map +1 -0
  111. package/vendor/intl-dom/dist/shared.d.ts +20 -0
  112. package/vendor/intl-dom/dist/shared.d.ts.map +1 -0
  113. package/vendor/intl-dom/dist/utils.d.ts +53 -0
  114. package/vendor/intl-dom/dist/utils.d.ts.map +1 -0
  115. package/vendor/jamilih/dist/jml.d.mts +468 -0
  116. package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +1489 -343
  117. package/vendor/jquery/dist/jquery.js +1677 -2713
  118. package/vendor/json-6/dist/index.mjs +2 -0
  119. package/vendor/miller-columns/CHANGES.md +185 -0
  120. package/vendor/miller-columns/LICENSE-MIT.txt +21 -0
  121. package/vendor/miller-columns/README.md +249 -0
  122. package/vendor/miller-columns/demos/index.html +69 -0
  123. package/vendor/miller-columns/demos/index.js +72 -0
  124. package/vendor/miller-columns/dist/index-es.js +748 -0
  125. package/vendor/miller-columns/dist/index-es.min.d.ts +25 -0
  126. package/vendor/miller-columns/dist/index-es.min.js +7 -1
  127. package/vendor/miller-columns/dist/index-umd.js +757 -0
  128. package/vendor/miller-columns/dist/index-umd.min.js +7 -0
  129. package/vendor/miller-columns/dist/index.d.ts +25 -0
  130. package/vendor/miller-columns/dist/millerColumns.d.ts +10 -0
  131. package/vendor/miller-columns/eslint.config.js +46 -0
  132. package/vendor/miller-columns/fix-declarations.js +18 -0
  133. package/vendor/miller-columns/miller-columns.css +24 -1
  134. package/vendor/miller-columns/package.json +73 -0
  135. package/vendor/miller-columns/pnpm-workspace.yaml +2 -0
  136. package/vendor/miller-columns/src/index.js +642 -0
  137. package/vendor/miller-columns/src/millerColumns.ts +12 -0
  138. package/vendor/miller-columns/tsconfig-prod.json +23 -0
  139. package/vendor/miller-columns/tsconfig.json +21 -0
  140. package/vendor/simple-prefs/dist/index.esm.d.ts +1 -0
  141. package/vendor/simple-prefs/dist/index.esm.js +164 -216
  142. package/vendor/simple-prefs/dist/simple-prefs.d.ts +117 -0
  143. package/lgtm.yml +0 -5
@@ -1,269 +1,376 @@
1
- function _iterableToArrayLimit(arr, i) {
2
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
3
- if (null != _i) {
4
- var _s,
5
- _e,
6
- _x,
7
- _r,
8
- _arr = [],
9
- _n = !0,
10
- _d = !1;
11
- try {
12
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
13
- if (Object(_i) !== _i) return;
14
- _n = !1;
15
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
16
- } catch (err) {
17
- _d = !0, _e = err;
18
- } finally {
19
- try {
20
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
21
- } finally {
22
- if (_d) throw _e;
23
- }
24
- }
25
- return _arr;
26
- }
1
+ function _arrayLikeToArray(r, a) {
2
+ (null == a || a > r.length) && (a = r.length);
3
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4
+ return n;
27
5
  }
28
- function ownKeys(object, enumerableOnly) {
29
- var keys = Object.keys(object);
30
- if (Object.getOwnPropertySymbols) {
31
- var symbols = Object.getOwnPropertySymbols(object);
32
- enumerableOnly && (symbols = symbols.filter(function (sym) {
33
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
34
- })), keys.push.apply(keys, symbols);
35
- }
36
- return keys;
6
+ function _arrayWithHoles(r) {
7
+ if (Array.isArray(r)) return r;
37
8
  }
38
- function _objectSpread2(target) {
39
- for (var i = 1; i < arguments.length; i++) {
40
- var source = null != arguments[i] ? arguments[i] : {};
41
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
42
- _defineProperty(target, key, source[key]);
43
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
44
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
45
- });
46
- }
47
- return target;
9
+ function _arrayWithoutHoles(r) {
10
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
48
11
  }
49
- function _typeof(obj) {
50
- "@babel/helpers - typeof";
51
-
52
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
53
- return typeof obj;
54
- } : function (obj) {
55
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
56
- }, _typeof(obj);
12
+ function _assertThisInitialized(e) {
13
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
14
+ return e;
57
15
  }
58
- function _wrapRegExp() {
59
- _wrapRegExp = function (re, groups) {
60
- return new BabelRegExp(re, void 0, groups);
61
- };
62
- var _super = RegExp.prototype,
63
- _groups = new WeakMap();
64
- function BabelRegExp(re, flags, groups) {
65
- var _this = new RegExp(re, flags);
66
- return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype);
16
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
17
+ try {
18
+ var i = n[a](c),
19
+ u = i.value;
20
+ } catch (n) {
21
+ return void e(n);
67
22
  }
68
- function buildGroups(result, re) {
69
- var g = _groups.get(re);
70
- return Object.keys(g).reduce(function (groups, name) {
71
- var i = g[name];
72
- if ("number" == typeof i) groups[name] = result[i];else {
73
- for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++;
74
- groups[name] = result[i[k]];
23
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
24
+ }
25
+ function _asyncToGenerator(n) {
26
+ return function () {
27
+ var t = this,
28
+ e = arguments;
29
+ return new Promise(function (r, o) {
30
+ var a = n.apply(t, e);
31
+ function _next(n) {
32
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
75
33
  }
76
- return groups;
77
- }, Object.create(null));
78
- }
79
- return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
80
- var result = _super.exec.call(this, str);
81
- if (result) {
82
- result.groups = buildGroups(result, this);
83
- var indices = result.indices;
84
- indices && (indices.groups = buildGroups(indices, this));
85
- }
86
- return result;
87
- }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
88
- if ("string" == typeof substitution) {
89
- var groups = _groups.get(this);
90
- return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
91
- var group = groups[name];
92
- return "$" + (Array.isArray(group) ? group.join("$") : group);
93
- }));
94
- }
95
- if ("function" == typeof substitution) {
96
- var _this = this;
97
- return _super[Symbol.replace].call(this, str, function () {
98
- var args = arguments;
99
- return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
100
- });
101
- }
102
- return _super[Symbol.replace].call(this, str, substitution);
103
- }, _wrapRegExp.apply(this, arguments);
34
+ function _throw(n) {
35
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
36
+ }
37
+ _next(void 0);
38
+ });
39
+ };
104
40
  }
105
- function _classCallCheck(instance, Constructor) {
106
- if (!(instance instanceof Constructor)) {
107
- throw new TypeError("Cannot call a class as a function");
108
- }
41
+ function _callSuper(t, o, e) {
42
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
109
43
  }
110
- function _defineProperties(target, props) {
111
- for (var i = 0; i < props.length; i++) {
112
- var descriptor = props[i];
113
- descriptor.enumerable = descriptor.enumerable || false;
114
- descriptor.configurable = true;
115
- if ("value" in descriptor) descriptor.writable = true;
116
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
44
+ function _classCallCheck(a, n) {
45
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
46
+ }
47
+ function _defineProperties(e, r) {
48
+ for (var t = 0; t < r.length; t++) {
49
+ var o = r[t];
50
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
117
51
  }
118
52
  }
119
- function _createClass(Constructor, protoProps, staticProps) {
120
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
121
- if (staticProps) _defineProperties(Constructor, staticProps);
122
- Object.defineProperty(Constructor, "prototype", {
53
+ function _createClass(e, r, t) {
54
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
123
55
  writable: false
124
- });
125
- return Constructor;
56
+ }), e;
126
57
  }
127
- function _defineProperty(obj, key, value) {
128
- key = _toPropertyKey(key);
129
- if (key in obj) {
130
- Object.defineProperty(obj, key, {
131
- value: value,
132
- enumerable: true,
133
- configurable: true,
134
- writable: true
135
- });
136
- } else {
137
- obj[key] = value;
138
- }
139
- return obj;
58
+ function _defineProperty(e, r, t) {
59
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
60
+ value: t,
61
+ enumerable: true,
62
+ configurable: true,
63
+ writable: true
64
+ }) : e[r] = t, e;
140
65
  }
141
- function _inherits(subClass, superClass) {
142
- if (typeof superClass !== "function" && superClass !== null) {
143
- throw new TypeError("Super expression must either be null or a function");
144
- }
145
- subClass.prototype = Object.create(superClass && superClass.prototype, {
66
+ function _getPrototypeOf(t) {
67
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
68
+ return t.__proto__ || Object.getPrototypeOf(t);
69
+ }, _getPrototypeOf(t);
70
+ }
71
+ function _inherits(t, e) {
72
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
73
+ t.prototype = Object.create(e && e.prototype, {
146
74
  constructor: {
147
- value: subClass,
75
+ value: t,
148
76
  writable: true,
149
77
  configurable: true
150
78
  }
151
- });
152
- Object.defineProperty(subClass, "prototype", {
79
+ }), Object.defineProperty(t, "prototype", {
153
80
  writable: false
154
- });
155
- if (superClass) _setPrototypeOf(subClass, superClass);
156
- }
157
- function _getPrototypeOf(o) {
158
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
159
- return o.__proto__ || Object.getPrototypeOf(o);
160
- };
161
- return _getPrototypeOf(o);
162
- }
163
- function _setPrototypeOf(o, p) {
164
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
165
- o.__proto__ = p;
166
- return o;
167
- };
168
- return _setPrototypeOf(o, p);
81
+ }), e && _setPrototypeOf(t, e);
169
82
  }
170
83
  function _isNativeReflectConstruct() {
171
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
172
- if (Reflect.construct.sham) return false;
173
- if (typeof Proxy === "function") return true;
174
84
  try {
175
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
176
- return true;
177
- } catch (e) {
178
- return false;
85
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
86
+ } catch (t) {}
87
+ return (_isNativeReflectConstruct = function () {
88
+ return !!t;
89
+ })();
90
+ }
91
+ function _iterableToArray(r) {
92
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
93
+ }
94
+ function _iterableToArrayLimit(r, l) {
95
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
96
+ if (null != t) {
97
+ var e,
98
+ n,
99
+ i,
100
+ u,
101
+ a = [],
102
+ f = true,
103
+ o = false;
104
+ try {
105
+ if (i = (t = t.call(r)).next, 0 === l) {
106
+ if (Object(t) !== t) return;
107
+ f = !1;
108
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
109
+ } catch (r) {
110
+ o = true, n = r;
111
+ } finally {
112
+ try {
113
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
114
+ } finally {
115
+ if (o) throw n;
116
+ }
117
+ }
118
+ return a;
179
119
  }
180
120
  }
181
- function _assertThisInitialized(self) {
182
- if (self === void 0) {
183
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
121
+ function _nonIterableRest() {
122
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
123
+ }
124
+ function _nonIterableSpread() {
125
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
126
+ }
127
+ function ownKeys(e, r) {
128
+ var t = Object.keys(e);
129
+ if (Object.getOwnPropertySymbols) {
130
+ var o = Object.getOwnPropertySymbols(e);
131
+ r && (o = o.filter(function (r) {
132
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
133
+ })), t.push.apply(t, o);
184
134
  }
185
- return self;
135
+ return t;
186
136
  }
187
- function _possibleConstructorReturn(self, call) {
188
- if (call && (typeof call === "object" || typeof call === "function")) {
189
- return call;
190
- } else if (call !== void 0) {
191
- throw new TypeError("Derived constructors may only return object or undefined");
137
+ function _objectSpread2(e) {
138
+ for (var r = 1; r < arguments.length; r++) {
139
+ var t = null != arguments[r] ? arguments[r] : {};
140
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
141
+ _defineProperty(e, r, t[r]);
142
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
143
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
144
+ });
192
145
  }
193
- return _assertThisInitialized(self);
146
+ return e;
194
147
  }
195
- function _createSuper(Derived) {
196
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
197
- return function _createSuperInternal() {
198
- var Super = _getPrototypeOf(Derived),
199
- result;
200
- if (hasNativeReflectConstruct) {
201
- var NewTarget = _getPrototypeOf(this).constructor;
202
- result = Reflect.construct(Super, arguments, NewTarget);
203
- } else {
204
- result = Super.apply(this, arguments);
205
- }
206
- return _possibleConstructorReturn(this, result);
207
- };
148
+ function _possibleConstructorReturn(t, e) {
149
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
150
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
151
+ return _assertThisInitialized(t);
208
152
  }
209
- function _slicedToArray(arr, i) {
210
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
153
+ function _regenerator() {
154
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
155
+ var e,
156
+ t,
157
+ r = "function" == typeof Symbol ? Symbol : {},
158
+ n = r.iterator || "@@iterator",
159
+ o = r.toStringTag || "@@toStringTag";
160
+ function i(r, n, o, i) {
161
+ var c = n && n.prototype instanceof Generator ? n : Generator,
162
+ u = Object.create(c.prototype);
163
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
164
+ var i,
165
+ c,
166
+ u,
167
+ f = 0,
168
+ p = o || [],
169
+ y = false,
170
+ G = {
171
+ p: 0,
172
+ n: 0,
173
+ v: e,
174
+ a: d,
175
+ f: d.bind(e, 4),
176
+ d: function (t, r) {
177
+ return i = t, c = 0, u = e, G.n = r, a;
178
+ }
179
+ };
180
+ function d(r, n) {
181
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
182
+ var o,
183
+ i = p[t],
184
+ d = G.p,
185
+ l = i[2];
186
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
187
+ }
188
+ if (o || r > 1) return a;
189
+ throw y = true, n;
190
+ }
191
+ return function (o, p, l) {
192
+ if (f > 1) throw TypeError("Generator is already running");
193
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
194
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
195
+ try {
196
+ if (f = 2, i) {
197
+ if (c || (o = "next"), t = i[o]) {
198
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
199
+ if (!t.done) return t;
200
+ u = t.value, c < 2 && (c = 0);
201
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
202
+ i = e;
203
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
204
+ } catch (t) {
205
+ i = e, c = 1, u = t;
206
+ } finally {
207
+ f = 1;
208
+ }
209
+ }
210
+ return {
211
+ value: t,
212
+ done: y
213
+ };
214
+ };
215
+ }(r, o, i), true), u;
216
+ }
217
+ var a = {};
218
+ function Generator() {}
219
+ function GeneratorFunction() {}
220
+ function GeneratorFunctionPrototype() {}
221
+ t = Object.getPrototypeOf;
222
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
223
+ return this;
224
+ }), t),
225
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
226
+ function f(e) {
227
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
228
+ }
229
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
230
+ return this;
231
+ }), _regeneratorDefine(u, "toString", function () {
232
+ return "[object Generator]";
233
+ }), (_regenerator = function () {
234
+ return {
235
+ w: i,
236
+ m: f
237
+ };
238
+ })();
211
239
  }
212
- function _toConsumableArray(arr) {
213
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
240
+ function _regeneratorDefine(e, r, n, t) {
241
+ var i = Object.defineProperty;
242
+ try {
243
+ i({}, "", {});
244
+ } catch (e) {
245
+ i = 0;
246
+ }
247
+ _regeneratorDefine = function (e, r, n, t) {
248
+ function o(r, n) {
249
+ _regeneratorDefine(e, r, function (e) {
250
+ return this._invoke(r, n, e);
251
+ });
252
+ }
253
+ r ? i ? i(e, r, {
254
+ value: n,
255
+ enumerable: !t,
256
+ configurable: !t,
257
+ writable: !t
258
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
259
+ }, _regeneratorDefine(e, r, n, t);
214
260
  }
215
- function _arrayWithoutHoles(arr) {
216
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
261
+ function _setPrototypeOf(t, e) {
262
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
263
+ return t.__proto__ = e, t;
264
+ }, _setPrototypeOf(t, e);
217
265
  }
218
- function _arrayWithHoles(arr) {
219
- if (Array.isArray(arr)) return arr;
266
+ function _slicedToArray(r, e) {
267
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
220
268
  }
221
- function _iterableToArray(iter) {
222
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
269
+ function _taggedTemplateLiteral(e, t) {
270
+ return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
271
+ raw: {
272
+ value: Object.freeze(t)
273
+ }
274
+ }));
223
275
  }
224
- function _unsupportedIterableToArray(o, minLen) {
225
- if (!o) return;
226
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
227
- var n = Object.prototype.toString.call(o).slice(8, -1);
228
- if (n === "Object" && o.constructor) n = o.constructor.name;
229
- if (n === "Map" || n === "Set") return Array.from(o);
230
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
276
+ function _toConsumableArray(r) {
277
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
231
278
  }
232
- function _arrayLikeToArray(arr, len) {
233
- if (len == null || len > arr.length) len = arr.length;
234
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
235
- return arr2;
279
+ function _toPrimitive(t, r) {
280
+ if ("object" != typeof t || !t) return t;
281
+ var e = t[Symbol.toPrimitive];
282
+ if (void 0 !== e) {
283
+ var i = e.call(t, r);
284
+ if ("object" != typeof i) return i;
285
+ throw new TypeError("@@toPrimitive must return a primitive value.");
286
+ }
287
+ return ("string" === r ? String : Number)(t);
236
288
  }
237
- function _nonIterableSpread() {
238
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
289
+ function _toPropertyKey(t) {
290
+ var i = _toPrimitive(t, "string");
291
+ return "symbol" == typeof i ? i : i + "";
239
292
  }
240
- function _nonIterableRest() {
241
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
293
+ function _typeof(o) {
294
+ "@babel/helpers - typeof";
295
+
296
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
297
+ return typeof o;
298
+ } : function (o) {
299
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
300
+ }, _typeof(o);
242
301
  }
243
- function _toPrimitive(input, hint) {
244
- if (typeof input !== "object" || input === null) return input;
245
- var prim = input[Symbol.toPrimitive];
246
- if (prim !== undefined) {
247
- var res = prim.call(input, hint || "default");
248
- if (typeof res !== "object") return res;
249
- throw new TypeError("@@toPrimitive must return a primitive value.");
302
+ function _unsupportedIterableToArray(r, a) {
303
+ if (r) {
304
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
305
+ var t = {}.toString.call(r).slice(8, -1);
306
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
250
307
  }
251
- return (hint === "string" ? String : Number)(input);
252
308
  }
253
- function _toPropertyKey(arg) {
254
- var key = _toPrimitive(arg, "string");
255
- return typeof key === "symbol" ? key : String(key);
309
+ function _wrapRegExp() {
310
+ _wrapRegExp = function (e, r) {
311
+ return new BabelRegExp(e, void 0, r);
312
+ };
313
+ var e = RegExp.prototype,
314
+ r = new WeakMap();
315
+ function BabelRegExp(e, t, p) {
316
+ var o = RegExp(e, t);
317
+ return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype);
318
+ }
319
+ function buildGroups(e, t) {
320
+ var p = r.get(t);
321
+ return Object.keys(p).reduce(function (r, t) {
322
+ var o = p[t];
323
+ if ("number" == typeof o) r[t] = e[o];else {
324
+ for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++;
325
+ r[t] = e[o[i]];
326
+ }
327
+ return r;
328
+ }, Object.create(null));
329
+ }
330
+ return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) {
331
+ var t = e.exec.call(this, r);
332
+ if (t) {
333
+ t.groups = buildGroups(t, this);
334
+ var p = t.indices;
335
+ p && (p.groups = buildGroups(p, this));
336
+ }
337
+ return t;
338
+ }, BabelRegExp.prototype[Symbol.replace] = function (t, p) {
339
+ if ("string" == typeof p) {
340
+ var o = r.get(this);
341
+ return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) {
342
+ if ("" === t) return e;
343
+ var p = o[r];
344
+ return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : "";
345
+ }));
346
+ }
347
+ if ("function" == typeof p) {
348
+ var i = this;
349
+ return e[Symbol.replace].call(this, t, function () {
350
+ var e = arguments;
351
+ return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e);
352
+ });
353
+ }
354
+ return e[Symbol.replace].call(this, t, p);
355
+ }, _wrapRegExp.apply(this, arguments);
256
356
  }
257
357
 
358
+ /* eslint-disable unicorn/no-top-level-assignment-in-function -- Temporary */
258
359
  // We want it to work in the browser, so commenting out
259
360
  // import jsonExtra from 'json5';
260
361
  // import jsonExtra from 'json-6';
261
362
 
363
+ /* eslint-disable jsdoc/reject-any-type -- Ok */
262
364
  /**
263
365
  * @typedef {any} JSON6
264
366
  */
367
+ /**
368
+ * @typedef {any} AnyValue
369
+ */
370
+ /* eslint-enable jsdoc/reject-any-type -- Ok */
265
371
 
266
- // @ts-expect-error Need typing for JSON6
372
+ // Don't use ts-expect-error here, as result differs by tsconfig
373
+ // @ts-ignore Need typing for JSON6
267
374
  var _jsonExtra = globalThis.jsonExtra;
268
375
 
269
376
  /**
@@ -278,15 +385,11 @@ var setJSONExtra = function setJSONExtra(__jsonExtra) {
278
385
  * @returns {string}
279
386
  */
280
387
  var unescapeBackslashes = function unescapeBackslashes(str) {
281
- return str.replace(/\\+/g, function (esc) {
388
+ return str.replaceAll(/\\+/g, function (esc) {
282
389
  return esc.slice(0, esc.length / 2);
283
390
  });
284
391
  };
285
392
 
286
- /**
287
- * @typedef {any} AnyValue
288
- */
289
-
290
393
  /**
291
394
  * @param {string} args
292
395
  * @returns {AnyValue}
@@ -335,8 +438,6 @@ var processRegex = function processRegex(regex, str, _ref) {
335
438
  betweenMatches = _ref.betweenMatches,
336
439
  afterMatch = _ref.afterMatch,
337
440
  escapeAtOne = _ref.escapeAtOne;
338
- var match;
339
- var previousIndex = 0;
340
441
  if (extra) {
341
442
  betweenMatches = extra;
342
443
  afterMatch = extra;
@@ -345,6 +446,8 @@ var processRegex = function processRegex(regex, str, _ref) {
345
446
  if (!betweenMatches || !afterMatch) {
346
447
  throw new Error('You must have `extra` or `betweenMatches` and `afterMatch` arguments.');
347
448
  }
449
+ var match;
450
+ var previousIndex = 0;
348
451
  while ((match = regex.exec(str)) !== null) {
349
452
  var _match = match,
350
453
  _match2 = _slicedToArray(_match, 2),
@@ -369,8 +472,8 @@ var processRegex = function processRegex(regex, str, _ref) {
369
472
  }
370
473
  };
371
474
 
372
- /* globals fetch, document */
373
-
475
+ /* globals document -- Polyglot variable */
476
+ /* eslint-disable unicorn/no-top-level-assignment-in-function -- Necessary */
374
477
  /**
375
478
  * @typedef {(
376
479
  * input: RequestInfo|URL, init?: RequestInit
@@ -380,7 +483,7 @@ var processRegex = function processRegex(regex, str, _ref) {
380
483
  * @type {null|Fetch}
381
484
  */
382
485
  var _fetch = typeof fetch !== 'undefined' ? fetch
383
- /* c8 ignore next */ : null;
486
+ /* c8 ignore next -- Available in Node now too */ : null;
384
487
 
385
488
  /**
386
489
  * @param {Fetch} f
@@ -399,7 +502,7 @@ var getFetch = function getFetch() {
399
502
 
400
503
  /** @type {Document|null} */
401
504
  var _doc = typeof document !== 'undefined'
402
- /* c8 ignore next */ ? document : null;
505
+ /* c8 ignore next -- Not available by default in Node */ ? document : null;
403
506
 
404
507
  /**
405
508
  * @param {Document} doc
@@ -416,24 +519,25 @@ var getDocument = function getDocument() {
416
519
  return _doc;
417
520
  };
418
521
 
522
+ var _templateObject$2;
523
+
419
524
  /**
420
525
  *
421
526
  * @returns {string}
422
527
  */
423
528
  function generateUUID() {
424
- // Adapted from original: public domain/MIT: http://stackoverflow.com/a/8809472/271577
529
+ // Adapted from original: public domain/MIT: https://stackoverflow.com/a/8809472/271577
425
530
  var d = Date.now();
426
- /* c8 ignore next 5 */
531
+ /* c8 ignore next 5 -- Available in Node */
427
532
  if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
428
533
  d += performance.now(); // use high-precision timer if available
429
534
  }
430
-
431
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
432
- /* eslint-disable no-bitwise */
535
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/g, function (c) {
536
+ /* eslint-disable no-bitwise, sonarjs/pseudo-random -- Convenient */
433
537
  var r = Math.trunc((d + Math.random() * 16) % 16);
434
538
  d = Math.floor(d / 16);
435
539
  return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
436
- /* eslint-enable no-bitwise */
540
+ /* eslint-enable no-bitwise, sonarjs/pseudo-random -- Convenient */
437
541
  });
438
542
  }
439
543
 
@@ -445,6 +549,7 @@ function generateUUID() {
445
549
  * @returns {string[]}
446
550
  */
447
551
  var sort = function sort(locale, arrayOfItems, options) {
552
+ // eslint-disable-next-line unicorn/no-array-sort -- Modifies
448
553
  return arrayOfItems.sort(new Intl.Collator(locale, options).compare);
449
554
  };
450
555
 
@@ -480,7 +585,7 @@ var sortListSimple = function sortListSimple(locale, arrayOfItems, listOptions,
480
585
  *
481
586
  * @param {string} locale
482
587
  * @param {string[]} arrayOfItems
483
- * @param {((str: string, idx: Integer) => any)|
588
+ * @param {import('./index.js').SortListMapper|
484
589
  * Intl.ListFormatOptions|undefined} map
485
590
  * @param {Intl.ListFormatOptions|undefined} [listOptions]
486
591
  * @param {Intl.CollatorOptions|undefined} [collationOptions]
@@ -508,7 +613,7 @@ var sortList = function sortList(locale, arrayOfItems, map, listOptions, collati
508
613
  };
509
614
  processRegex(
510
615
  // // eslint-disable-next-line prefer-named-capture-group
511
- new RegExp("<<".concat(randomId, "(\\d)>>"), 'gu'), list(locale, placeholderArray, listOptions), {
616
+ new RegExp(String.raw(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["<<", "(d)>>"], ["<<", "(\\d)>>"])), randomId), 'gv'), list(locale, placeholderArray, listOptions), {
512
617
  betweenMatches: push,
513
618
  afterMatch: push,
514
619
  onMatch: function onMatch(_, idx) {
@@ -590,16 +695,15 @@ var getFormatterInfo = function getFormatterInfo(_ref) {
590
695
  * key?: string,
591
696
  * locale?: string
592
697
  * }) => string|Node} AllSubstitutionCallback
593
- */
698
+ */
594
699
 
595
700
  /**
596
701
  * @type {AllSubstitutionCallback}
597
702
  */
598
703
  var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
599
704
  var value = _ref2.value,
600
- arg = _ref2.arg;
601
- _ref2.key;
602
- var locale = _ref2.locale;
705
+ arg = _ref2.arg,
706
+ locale = _ref2.locale;
603
707
  // Strings or DOM Nodes
604
708
  if (typeof value === 'string' || value && _typeof(value) === 'object' && 'nodeType' in value) {
605
709
  return value;
@@ -619,12 +723,13 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
619
723
  var applyArgs = function applyArgs(_ref3) {
620
724
  var type = _ref3.type,
621
725
  _ref3$options = _ref3.options,
622
- options = _ref3$options === void 0 ? /** @type {object|undefined} */
623
- opts : _ref3$options,
726
+ options = _ref3$options === void 0 ? (/** @type {object|undefined} */
727
+ opts) : _ref3$options,
624
728
  _ref3$checkArgOptions = _ref3.checkArgOptions,
625
729
  checkArgOptions = _ref3$checkArgOptions === void 0 ? false : _ref3$checkArgOptions;
626
730
  if (typeof arg === 'string') {
627
- var _arg$split = arg.split('|'),
731
+ // eslint-disable-next-line prefer-const -- Convenient
732
+ var _arg$split = arg.split('|', 3),
628
733
  _arg$split2 = _slicedToArray(_arg$split, 3),
629
734
  userType = _arg$split2[0],
630
735
  extraArgs = _arg$split2[1],
@@ -647,23 +752,22 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
647
752
  var expectsDatetime = false;
648
753
  if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
649
754
  var singleKey = Object.keys(value)[0];
755
+ /**
756
+ * @typedef {"number"|"date"|"datetime"|"dateRange"|
757
+ * "datetimeRange"|"relative"|"region"|"language"|
758
+ * "script"|"currency"|"list"|"plural"} SpecialFormat
759
+ */
650
760
  if (['number', 'date', 'datetime', 'dateRange', 'datetimeRange', 'relative', 'region', 'language', 'script', 'currency', 'list', 'plural'].includes(singleKey)) {
651
761
  var extraOpts, callback;
652
- /**
653
- * @typedef {any} AnyValue
654
- */
655
-
656
762
  var obj = /** @type {unknown} */
657
- /** @type {AnyValue} */
658
- value[
763
+ /** @type {Record<string, keyof SpecialFormat>} */
764
+ value[(
659
765
  /**
660
- * @type {"number"|"date"|"datetime"|"dateRange"|
661
- * "datetimeRange"|"relative"|"region"|"language"|
662
- * "script"|"currency"|"list"|"plural"}
663
- */
664
- singleKey];
766
+ * @type {SpecialFormat}
767
+ */
768
+ singleKey)];
665
769
  var _getFormatterInfo = getFormatterInfo({
666
- object:
770
+ object: (
667
771
  /**
668
772
  * @type {import('./defaultLocaleResolver.js').DateRangeValueArray|
669
773
  * import('./defaultLocaleResolver.js').ListValueArray|
@@ -671,7 +775,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
671
775
  * import('./defaultLocaleResolver.js').ValueArray
672
776
  * }
673
777
  */
674
- obj
778
+ obj)
675
779
  });
676
780
  value = _getFormatterInfo.value;
677
781
  opts = _getFormatterInfo.options;
@@ -689,10 +793,10 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
689
793
  type: 'DATERANGE',
690
794
  options: extraOpts
691
795
  }));
692
- return dtf.formatRange.apply(dtf, _toConsumableArray( /** @type {[Date, Date]} */
693
- [/** @type {number|Date} */
694
- value, /** @type {Date} */
695
- opts].map(function (val) {
796
+ return dtf.formatRange.apply(dtf, _toConsumableArray(/** @type {[Date, Date]} */
797
+ [(/** @type {number|Date} */
798
+ value), (/** @type {Date} */
799
+ opts)].map(function (val) {
696
800
  return typeof val === 'number' ? new Date(val) : val;
697
801
  })));
698
802
  }
@@ -700,27 +804,26 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
700
804
  case 'language':
701
805
  case 'script':
702
806
  case 'currency':
703
- return (/** @type {string} */new Intl.DisplayNames(locale, _objectSpread2(_objectSpread2({}, applyArgs({
704
- type: singleKey.toUpperCase()
705
- })), {}, {
706
- type: singleKey
707
- })).of( /** @type {string} */value)
708
- );
807
+ return /** @type {string} */new Intl.DisplayNames(locale, _objectSpread2(_objectSpread2({}, applyArgs({
808
+ type: singleKey.toUpperCase()
809
+ })), {}, {
810
+ type: singleKey
811
+ })).of(/** @type {string} */value);
709
812
  case 'relative':
710
813
  // The second argument actually contains the primary options, so swap
711
- // eslint-disable-next-line max-len -- Long
814
+ // eslint-disable-next-line @stylistic/max-len -- Long
712
815
  var _ref4 = /** @type {[Intl.RelativeTimeFormatUnit, object?]} */
713
816
  [opts, extraOpts];
714
817
  extraOpts = _ref4[0];
715
818
  opts = _ref4[1];
716
819
  return new Intl.RelativeTimeFormat(locale, applyArgs({
717
820
  type: 'RELATIVE'
718
- })).format( /** @type {number} */value, extraOpts);
821
+ })).format(/** @type {number} */value, extraOpts);
719
822
 
720
823
  // ListFormat (with Collator)
721
824
  case 'list':
722
825
  if (callback) {
723
- return sortList( /** @type {string} */locale, /** @type {string[]} */
826
+ return sortList(/** @type {string} */locale, /** @type {string[]} */
724
827
  value, callback, applyArgs({
725
828
  type: 'LIST'
726
829
  }), applyArgs({
@@ -729,7 +832,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
729
832
  checkArgOptions: true
730
833
  }));
731
834
  }
732
- return sortList( /** @type {string} */locale, /** @type {string[]} */
835
+ return sortList(/** @type {string} */locale, /** @type {string[]} */
733
836
  value, applyArgs({
734
837
  type: 'LIST'
735
838
  }), applyArgs({
@@ -743,7 +846,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
743
846
 
744
847
  // Dates
745
848
  if (value) {
746
- if (typeof value === 'number' && (expectsDatetime || /^DATE(?:TIME)(?:\||$)/.test( /** @type {string} */arg))) {
849
+ if (typeof value === 'number' && (expectsDatetime || /^DATE(?:TIME)(?:\||$)/.test(/** @type {string} */arg))) {
747
850
  value = new Date(value);
748
851
  }
749
852
  if (_typeof(value) === 'object' && 'getTime' in value && typeof value.getTime === 'function') {
@@ -761,7 +864,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
761
864
  return (_Intl$DateTimeFormat = new Intl.DateTimeFormat(locale, applyArgs({
762
865
  type: 'DATERANGE',
763
866
  options: _extraOpts2
764
- }))).formatRange.apply(_Intl$DateTimeFormat, _toConsumableArray( /** @type {[Date, Date]} */
867
+ }))).formatRange.apply(_Intl$DateTimeFormat, _toConsumableArray(/** @type {[Date, Date]} */
765
868
  value.slice(0, 2).map(function (val) {
766
869
  return typeof val === 'number' ? new Date(val) : val;
767
870
  })));
@@ -778,6 +881,8 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
778
881
  throw new TypeError('Unknown formatter');
779
882
  };
780
883
 
884
+ var _templateObject$1, _templateObject2$1;
885
+
781
886
  /**
782
887
  * Base class for formatting.
783
888
  */
@@ -792,7 +897,7 @@ var Formatter = /*#__PURE__*/_createClass(function Formatter() {
792
897
  * @param {string} cfg.type
793
898
  * @param {"richNested"|"rich"|"plain"|
794
899
  * "plainNested"|import('./getMessageForKeyByStyle.js').
795
- * MessageStyleCallback} [cfg.messageStyle="richNested"]
900
+ * MessageStyleCallback} [cfg.messageStyle]
796
901
  * @returns {string}
797
902
  */
798
903
  var _getSubstitution = function getSubstitution(_ref) {
@@ -819,15 +924,13 @@ var _getSubstitution = function getSubstitution(_ref) {
819
924
  * Formatter for local variables.
820
925
  */
821
926
  var LocalFormatter = /*#__PURE__*/function (_Formatter) {
822
- _inherits(LocalFormatter, _Formatter);
823
- var _super = _createSuper(LocalFormatter);
824
927
  /**
825
928
  * @param {import('./getMessageForKeyByStyle.js').LocalObject} locals
826
929
  */
827
930
  function LocalFormatter(locals) {
828
931
  var _this;
829
932
  _classCallCheck(this, LocalFormatter);
830
- _this = _super.call(this);
933
+ _this = _callSuper(this, LocalFormatter);
831
934
  _this.locals = locals;
832
935
  return _this;
833
936
  }
@@ -835,7 +938,8 @@ var LocalFormatter = /*#__PURE__*/function (_Formatter) {
835
938
  * @param {string} key
836
939
  * @returns {string|Element}
837
940
  */
838
- _createClass(LocalFormatter, [{
941
+ _inherits(LocalFormatter, _Formatter);
942
+ return _createClass(LocalFormatter, [{
839
943
  key: "getSubstitution",
840
944
  value: function getSubstitution(key) {
841
945
  return _getSubstitution({
@@ -854,48 +958,45 @@ var LocalFormatter = /*#__PURE__*/function (_Formatter) {
854
958
  var components = key.slice(1).split('.');
855
959
  /** @type {import('./getMessageForKeyByStyle.js').LocaleBody} */
856
960
  var parent = this.locals;
857
- return (/** @type {typeof LocalFormatter} */this.constructor.isMatchingKey(key) && components.every(function (cmpt) {
858
- var result = (cmpt in parent);
859
- parent =
860
- /**
861
- * @type {import('./defaultLocaleResolver.js').
862
- * RichNestedLocaleStringBodyObject|
863
- * import('./defaultLocaleResolver.js').
864
- * PlainNestedLocaleStringBodyObject|
865
- * import('./defaultLocaleResolver.js').RichLocaleStringSubObject
866
- * }
867
- */
868
- /**
869
- * @type {import('./defaultLocaleResolver.js').
870
- * RichNestedLocaleStringBodyObject|
871
- * import('./defaultLocaleResolver.js').
872
- * PlainNestedLocaleStringBodyObject
873
- * }
874
- */
875
- parent[cmpt];
876
- return result;
877
- })
878
- );
961
+ return /** @type {typeof LocalFormatter} */this.constructor.isMatchingKey(key) && components.every(function (cmpt) {
962
+ var result = Object.hasOwn(parent, cmpt);
963
+ parent =
964
+ /**
965
+ * @type {import('./defaultLocaleResolver.js').
966
+ * RichNestedLocaleStringBodyObject|
967
+ * import('./defaultLocaleResolver.js').
968
+ * PlainNestedLocaleStringBodyObject|
969
+ * import('./defaultLocaleResolver.js').RichLocaleStringSubObject
970
+ * }
971
+ */
972
+ /**
973
+ * @type {import('./defaultLocaleResolver.js').
974
+ * RichNestedLocaleStringBodyObject|
975
+ * import('./defaultLocaleResolver.js').
976
+ * PlainNestedLocaleStringBodyObject
977
+ * }
978
+ */
979
+ parent[cmpt];
980
+ return result;
981
+ });
879
982
  }
983
+ }], [{
984
+ key: "isMatchingKey",
985
+ value:
880
986
  /**
881
987
  * @param {string} key
882
988
  * @returns {boolean}
883
989
  */
884
- }], [{
885
- key: "isMatchingKey",
886
- value: function isMatchingKey(key) {
990
+ function isMatchingKey(key) {
887
991
  return key.startsWith('-');
888
992
  }
889
993
  }]);
890
- return LocalFormatter;
891
994
  }(Formatter);
892
995
 
893
996
  /**
894
997
  * Formatter for regular variables.
895
998
  */
896
999
  var RegularFormatter = /*#__PURE__*/function (_Formatter2) {
897
- _inherits(RegularFormatter, _Formatter2);
898
- var _super2 = _createSuper(RegularFormatter);
899
1000
  /**
900
1001
  * @param {import('./defaultLocaleResolver.js').SubstitutionObject
901
1002
  * } substitutions
@@ -903,7 +1004,7 @@ var RegularFormatter = /*#__PURE__*/function (_Formatter2) {
903
1004
  function RegularFormatter(substitutions) {
904
1005
  var _this2;
905
1006
  _classCallCheck(this, RegularFormatter);
906
- _this2 = _super2.call(this);
1007
+ _this2 = _callSuper(this, RegularFormatter);
907
1008
  _this2.substitutions = substitutions;
908
1009
  return _this2;
909
1010
  }
@@ -911,31 +1012,29 @@ var RegularFormatter = /*#__PURE__*/function (_Formatter2) {
911
1012
  * @param {string} key
912
1013
  * @returns {boolean}
913
1014
  */
914
- _createClass(RegularFormatter, [{
1015
+ _inherits(RegularFormatter, _Formatter2);
1016
+ return _createClass(RegularFormatter, [{
915
1017
  key: "isMatch",
916
1018
  value: function isMatch(key) {
917
- return (/** @type {typeof RegularFormatter} */this.constructor.isMatchingKey(key) && key in this.substitutions
918
- );
1019
+ return /** @type {typeof RegularFormatter} */this.constructor.isMatchingKey(key) && Object.hasOwn(this.substitutions, key);
919
1020
  }
1021
+ }], [{
1022
+ key: "isMatchingKey",
1023
+ value:
920
1024
  /**
921
1025
  * @param {string} key
922
1026
  * @returns {boolean}
923
1027
  */
924
- }], [{
925
- key: "isMatchingKey",
926
- value: function isMatchingKey(key) {
1028
+ function isMatchingKey(key) {
927
1029
  return /^[0-9A-Z_a-z]/.test(key);
928
1030
  }
929
1031
  }]);
930
- return RegularFormatter;
931
1032
  }(Formatter);
932
1033
 
933
1034
  /**
934
1035
  * Formatter for switch variables.
935
1036
  */
936
1037
  var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
937
- _inherits(SwitchFormatter, _Formatter3);
938
- var _super3 = _createSuper(SwitchFormatter);
939
1038
  /**
940
1039
  * @param {import('./defaultLocaleResolver.js').Switches} switches
941
1040
  * @param {object} cfg
@@ -946,7 +1045,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
946
1045
  var _this3;
947
1046
  var substitutions = _ref2.substitutions;
948
1047
  _classCallCheck(this, SwitchFormatter);
949
- _this3 = _super3.call(this);
1048
+ _this3 = _callSuper(this, SwitchFormatter);
950
1049
  _this3.switches = switches;
951
1050
  _this3.substitutions = substitutions;
952
1051
  return _this3;
@@ -962,7 +1061,8 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
962
1061
  * MissingSuppliedFormattersCallback} cfg.missingSuppliedFormatters
963
1062
  * @returns {string}
964
1063
  */
965
- _createClass(SwitchFormatter, [{
1064
+ _inherits(SwitchFormatter, _Formatter3);
1065
+ return _createClass(SwitchFormatter, [{
966
1066
  key: "getSubstitution",
967
1067
  value: function getSubstitution(key, _ref3) {
968
1068
  var locale = _ref3.locale,
@@ -983,7 +1083,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
983
1083
  /** @type {string} */
984
1084
  var opts;
985
1085
  if (objKey && objKey.includes('|')) {
986
- var _objKey$split = objKey.split('|');
1086
+ var _objKey$split = objKey.split('|', 3);
987
1087
  var _objKey$split2 = _slicedToArray(_objKey$split, 3);
988
1088
  type = _objKey$split2[1];
989
1089
  opts = _objKey$split2[2];
@@ -993,7 +1093,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
993
1093
  key: key,
994
1094
  formatter: this
995
1095
  });
996
- return '\\{' + key + '}';
1096
+ return String.raw(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["{"], ["\\{"]))) + key + '}';
997
1097
  }
998
1098
 
999
1099
  /*
@@ -1021,7 +1121,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1021
1121
  var pluralOpts = parseJSONExtra(opts);
1022
1122
  return new Intl.PluralRules(locale, _objectSpread2(_objectSpread2({}, defaultOptions), pluralOpts)).select(value);
1023
1123
  };
1024
- var formatterValue = this.substitutions[/** @type {string} */keySegment];
1124
+ var formatterValue = this.substitutions[(/** @type {string} */keySegment)];
1025
1125
  var match = formatterValue;
1026
1126
  if (typeof formatterValue === 'number') {
1027
1127
  switch (type) {
@@ -1045,7 +1145,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1045
1145
  * import('./defaultLocaleResolver.js').PluralInfo}
1046
1146
  */
1047
1147
  // @ts-expect-error Ok
1048
- formatterValue[/** @type {"number"|"plural"} */singleKey]
1148
+ formatterValue[(/** @type {"number"|"plural"} */singleKey)]
1049
1149
  }),
1050
1150
  value = _getFormatterInfo.value,
1051
1151
  options = _getFormatterInfo.options;
@@ -1056,14 +1156,14 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1056
1156
  if (!typeMatches) {
1057
1157
  throw new TypeError("Expecting type \"".concat(type.toLowerCase(), "\"; instead found \"").concat(singleKey, "\"."));
1058
1158
  }
1059
- // eslint-disable-next-line default-case
1159
+ // eslint-disable-next-line default-case -- Just two cases
1060
1160
  switch (type) {
1061
1161
  case 'NUMBER':
1062
- match = getNumberFormat( /** @type {number} */value, /** @type {Intl.NumberFormatOptions} */
1162
+ match = getNumberFormat(/** @type {number} */value, /** @type {Intl.NumberFormatOptions} */
1063
1163
  options);
1064
1164
  break;
1065
1165
  case 'PLURAL':
1066
- match = getPluralFormat( /** @type {number} */value, /** @type {Intl.PluralRulesOptions} */
1166
+ match = getPluralFormat(/** @type {number} */value, /** @type {Intl.PluralRulesOptions} */
1067
1167
  options);
1068
1168
  break;
1069
1169
  }
@@ -1079,12 +1179,12 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1079
1179
  * @returns {string}
1080
1180
  */
1081
1181
  var preventNesting = function preventNesting(s) {
1082
- return s.replace(/\\/g, '\\\\').replace(/\./g, '\\.');
1182
+ return s.replaceAll('\\', '\\\\').replaceAll('.', String.raw(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["."], ["\\."]))));
1083
1183
  };
1084
1184
  try {
1085
1185
  return _getSubstitution({
1086
1186
  messageStyle: messageStyle,
1087
- key: match ? preventNesting( /** @type {string} */match) : arg,
1187
+ key: match ? preventNesting(/** @type {string} */match) : arg,
1088
1188
  body: body,
1089
1189
  type: 'switch'
1090
1190
  });
@@ -1092,7 +1192,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1092
1192
  try {
1093
1193
  return _getSubstitution({
1094
1194
  messageStyle: messageStyle,
1095
- key: '*' + preventNesting( /** @type {string} */match),
1195
+ key: '*' + preventNesting(/** @type {string} */match),
1096
1196
  body: body,
1097
1197
  type: 'switch'
1098
1198
  });
@@ -1101,7 +1201,9 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1101
1201
  return switchKey.startsWith('*');
1102
1202
  });
1103
1203
  if (!k) {
1104
- throw new Error("No defaults found for switch ".concat(ky));
1204
+ throw new Error("No defaults found for switch ".concat(ky), {
1205
+ cause: error
1206
+ });
1105
1207
  }
1106
1208
  return _getSubstitution({
1107
1209
  messageStyle: messageStyle,
@@ -1124,12 +1226,12 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1124
1226
  }
1125
1227
 
1126
1228
  /**
1127
- * @typedef {[
1128
- * objKey?: string,
1129
- * body?: import('./getMessageForKeyByStyle.js').LocaleBody,
1130
- * keySegment?: string
1131
- * ]} SwitchMatch
1132
- */
1229
+ * @typedef {[
1230
+ * objKey?: string,
1231
+ * body?: import('./getMessageForKeyByStyle.js').LocaleBody,
1232
+ * keySegment?: string
1233
+ * ]} SwitchMatch
1234
+ */
1133
1235
 
1134
1236
  /**
1135
1237
  * @typedef {number} Integer
@@ -1147,18 +1249,22 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1147
1249
  var returnValue = /** @type {unknown} */ks.reduce(
1148
1250
  /**
1149
1251
  * @param {import('./defaultLocaleResolver.js').SwitchArrays|
1150
- * import('./defaultLocaleResolver.js').SwitchArray} obj
1252
+ * import('./defaultLocaleResolver.js').SwitchArray|
1253
+ * import('./defaultLocaleResolver.js').SwitchCaseArray|SwitchMatch} obj
1151
1254
  * @param {string} k
1152
1255
  * @param {Integer} i
1153
1256
  * @throws {Error}
1154
- * @returns {SwitchMatch|
1257
+ * @returns {import('./defaultLocaleResolver.js').SwitchArrays|
1258
+ * import('./defaultLocaleResolver.js').SwitchArray|
1155
1259
  * import('./defaultLocaleResolver.js').SwitchCaseArray|
1156
- * import('./defaultLocaleResolver.js').SwitchArray}
1260
+ * SwitchMatch}
1157
1261
  */
1158
- // @ts-expect-error It works
1159
1262
  function (obj, k, i) {
1263
+ if (Array.isArray(obj)) {
1264
+ return obj;
1265
+ }
1160
1266
  if (i < ks.length - 1) {
1161
- if (!(k in obj)) {
1267
+ if (!Object.hasOwn(obj, k)) {
1162
1268
  throw new Error("Switch key \"".concat(k, "\" not found (from \"~").concat(ky, "\")"));
1163
1269
  }
1164
1270
  return obj[k];
@@ -1171,18 +1277,23 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1171
1277
  return k === /** @type {typeof SwitchFormatter} */_this4.constructor.getKey(switchKey);
1172
1278
  });
1173
1279
  return ret ? [].concat(_toConsumableArray(ret), [k]) : [];
1174
- }, this.switches);
1175
- return (/** @type {SwitchMatch} */returnValue
1176
- );
1280
+ },
1281
+ /**
1282
+ * @type {import('./defaultLocaleResolver.js').SwitchArrays|
1283
+ * import('./defaultLocaleResolver.js').SwitchArray|
1284
+ * import('./defaultLocaleResolver.js').SwitchCaseArray|SwitchMatch}
1285
+ */ /** @type {unknown} */
1286
+ this.switches);
1287
+ return /** @type {SwitchMatch} */returnValue;
1177
1288
  }
1178
-
1289
+ }], [{
1290
+ key: "isMatchingKey",
1291
+ value:
1179
1292
  /**
1180
1293
  * @param {string} key
1181
1294
  * @returns {boolean}
1182
1295
  */
1183
- }], [{
1184
- key: "isMatchingKey",
1185
- value: function isMatchingKey(key) {
1296
+ function isMatchingKey(key) {
1186
1297
  return key.startsWith('~');
1187
1298
  }
1188
1299
  /**
@@ -1193,13 +1304,12 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1193
1304
  key: "getKey",
1194
1305
  value: function getKey(key) {
1195
1306
  var match = key.match(/^(?:[\0-\{\}-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*/);
1196
- return (/** @type {string} */match && match[0]
1197
- );
1307
+ return /** @type {string} */match && match[0];
1198
1308
  }
1199
1309
  }]);
1200
- return SwitchFormatter;
1201
1310
  }(Formatter);
1202
1311
 
1312
+ /* eslint-disable jsdoc/reject-any-type -- Generic API */
1203
1313
  /**
1204
1314
  * @typedef {(value: any) => Promise<any>|any} PromiseChainErrback
1205
1315
  */
@@ -1217,7 +1327,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
1217
1327
  * @param {Array<any>} values Array of values
1218
1328
  * @param {PromiseChainErrback} errBack Accepts an item of the array as its
1219
1329
  * single argument
1220
- * @param {string} [errorMessage="Reached end of values array."]
1330
+ * @param {string} [errorMessage]
1221
1331
  * @returns {Promise<any>} Either resolves to a value derived from an item in
1222
1332
  * the array or rejects if all items reject
1223
1333
  * @example
@@ -1232,191 +1342,6 @@ promiseChainForValues(['a', 'b', 'c'], (val) => {
1232
1342
  });
1233
1343
  });
1234
1344
  */
1235
-
1236
- function _await$2(value, then, direct) {
1237
- if (direct) {
1238
- return then ? then(value) : value;
1239
- }
1240
- if (!value || !value.then) {
1241
- value = Promise.resolve(value);
1242
- }
1243
- return then ? value.then(then) : value;
1244
- }
1245
- function _catch$1(body, recover) {
1246
- try {
1247
- var result = body();
1248
- } catch (e) {
1249
- return recover(e);
1250
- }
1251
- if (result && result.then) {
1252
- return result.then(void 0, recover);
1253
- }
1254
- return result;
1255
- }
1256
- function _settle(pact, state, value) {
1257
- if (!pact.s) {
1258
- if (value instanceof _Pact) {
1259
- if (value.s) {
1260
- if (state & 1) {
1261
- state = value.s;
1262
- }
1263
- value = value.v;
1264
- } else {
1265
- value.o = _settle.bind(null, pact, state);
1266
- return;
1267
- }
1268
- }
1269
- if (value && value.then) {
1270
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
1271
- return;
1272
- }
1273
- pact.s = state;
1274
- pact.v = value;
1275
- var observer = pact.o;
1276
- if (observer) {
1277
- observer(pact);
1278
- }
1279
- }
1280
- }
1281
- var _Pact = /*#__PURE__*/function () {
1282
- function _Pact() {}
1283
- _Pact.prototype.then = function (onFulfilled, onRejected) {
1284
- var result = new _Pact();
1285
- var state = this.s;
1286
- if (state) {
1287
- var callback = state & 1 ? onFulfilled : onRejected;
1288
- if (callback) {
1289
- try {
1290
- _settle(result, 1, callback(this.v));
1291
- } catch (e) {
1292
- _settle(result, 2, e);
1293
- }
1294
- return result;
1295
- } else {
1296
- return this;
1297
- }
1298
- }
1299
- this.o = function (_this) {
1300
- try {
1301
- var value = _this.v;
1302
- if (_this.s & 1) {
1303
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
1304
- } else if (onRejected) {
1305
- _settle(result, 1, onRejected(value));
1306
- } else {
1307
- _settle(result, 2, value);
1308
- }
1309
- } catch (e) {
1310
- _settle(result, 2, e);
1311
- }
1312
- };
1313
- return result;
1314
- };
1315
- return _Pact;
1316
- }();
1317
- function _isSettledPact(thenable) {
1318
- return thenable instanceof _Pact && thenable.s & 1;
1319
- }
1320
- function _for(test, update, body) {
1321
- var stage;
1322
- for (;;) {
1323
- var shouldContinue = test();
1324
- if (_isSettledPact(shouldContinue)) {
1325
- shouldContinue = shouldContinue.v;
1326
- }
1327
- if (!shouldContinue) {
1328
- return result;
1329
- }
1330
- if (shouldContinue.then) {
1331
- stage = 0;
1332
- break;
1333
- }
1334
- var result = body();
1335
- if (result && result.then) {
1336
- if (_isSettledPact(result)) {
1337
- result = result.s;
1338
- } else {
1339
- stage = 1;
1340
- break;
1341
- }
1342
- }
1343
- if (update) {
1344
- var updateValue = update();
1345
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
1346
- stage = 2;
1347
- break;
1348
- }
1349
- }
1350
- }
1351
- var pact = new _Pact();
1352
- var reject = _settle.bind(null, pact, 2);
1353
- (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
1354
- return pact;
1355
- function _resumeAfterBody(value) {
1356
- result = value;
1357
- do {
1358
- if (update) {
1359
- updateValue = update();
1360
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
1361
- updateValue.then(_resumeAfterUpdate).then(void 0, reject);
1362
- return;
1363
- }
1364
- }
1365
- shouldContinue = test();
1366
- if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
1367
- _settle(pact, 1, result);
1368
- return;
1369
- }
1370
- if (shouldContinue.then) {
1371
- shouldContinue.then(_resumeAfterTest).then(void 0, reject);
1372
- return;
1373
- }
1374
- result = body();
1375
- if (_isSettledPact(result)) {
1376
- result = result.v;
1377
- }
1378
- } while (!result || !result.then);
1379
- result.then(_resumeAfterBody).then(void 0, reject);
1380
- }
1381
- function _resumeAfterTest(shouldContinue) {
1382
- if (shouldContinue) {
1383
- result = body();
1384
- if (result && result.then) {
1385
- result.then(_resumeAfterBody).then(void 0, reject);
1386
- } else {
1387
- _resumeAfterBody(result);
1388
- }
1389
- } else {
1390
- _settle(pact, 1, result);
1391
- }
1392
- }
1393
- function _resumeAfterUpdate() {
1394
- if (shouldContinue = test()) {
1395
- if (shouldContinue.then) {
1396
- shouldContinue.then(_resumeAfterTest).then(void 0, reject);
1397
- } else {
1398
- _resumeAfterTest(shouldContinue);
1399
- }
1400
- } else {
1401
- _settle(pact, 1, result);
1402
- }
1403
- }
1404
- }
1405
- function _continue(value, then) {
1406
- return value && value.then ? value.then(then) : then(value);
1407
- }
1408
- function _async$1(f) {
1409
- return function () {
1410
- for (var args = [], i = 0; i < arguments.length; i++) {
1411
- args[i] = arguments[i];
1412
- }
1413
- try {
1414
- return Promise.resolve(f.apply(this, args));
1415
- } catch (e) {
1416
- return Promise.reject(e);
1417
- }
1418
- };
1419
- }
1420
1345
  var promiseChainForValues = function promiseChainForValues(values, errBack) {
1421
1346
  var errorMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Reached end of values array.';
1422
1347
  if (!Array.isArray(values)) {
@@ -1425,51 +1350,59 @@ var promiseChainForValues = function promiseChainForValues(values, errBack) {
1425
1350
  if (typeof errBack !== 'function') {
1426
1351
  throw new TypeError('The `errBack` argument to `promiseChainForValues` must be a function.');
1427
1352
  }
1428
- return _async$1(function () {
1429
- var _exit = false,
1430
- _interrupt = false;
1431
- var ret;
1432
- var p = Promise.reject(new Error('Intentionally reject so as to begin checking chain'));
1433
- var breaking;
1434
- return _continue(_for(function () {
1435
- return !(_interrupt || _exit);
1436
- }, void 0, function () {
1437
- var value = values.shift();
1438
- return _catch$1(function () {
1439
- // eslint-disable-next-line no-await-in-loop
1440
- return _await$2(p, function (_p) {
1441
- ret = _p;
1442
- _interrupt = true;
1443
- });
1444
- }, function () {
1445
- if (breaking) {
1446
- throw new Error(errorMessage);
1447
- }
1448
- // We allow one more try
1449
- if (!values.length) {
1450
- breaking = true;
1451
- }
1452
- // // eslint-disable-next-line no-await-in-loop
1453
- p = errBack(value);
1454
- });
1455
- }), function (_result2) {
1456
- return ret;
1457
- });
1458
- })();
1353
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1354
+ var ret, p, breaking, value, _t;
1355
+ return _regenerator().w(function (_context) {
1356
+ while (1) switch (_context.p = _context.n) {
1357
+ case 0:
1358
+ p = Promise.reject(new Error('Intentionally reject so as to begin checking chain'));
1359
+ case 1:
1360
+ value = values.shift();
1361
+ _context.p = 2;
1362
+ _context.n = 3;
1363
+ return p;
1364
+ case 3:
1365
+ ret = _context.v;
1366
+ return _context.a(3, 7);
1367
+ case 4:
1368
+ _context.p = 4;
1369
+ _t = _context.v;
1370
+ if (!breaking) {
1371
+ _context.n = 5;
1372
+ break;
1373
+ }
1374
+ throw new Error(errorMessage, {
1375
+ cause: _t
1376
+ });
1377
+ case 5:
1378
+ // We allow one more try
1379
+ if (!values.length) {
1380
+ breaking = true;
1381
+ }
1382
+ // // eslint-disable-next-line no-await-in-loop
1383
+ p = errBack(value);
1384
+ case 6:
1385
+ _context.n = 1;
1386
+ break;
1387
+ case 7:
1388
+ return _context.a(2, ret);
1389
+ }
1390
+ }, _callee, null, [[2, 4]]);
1391
+ }))();
1459
1392
  };
1460
1393
 
1461
1394
  /**
1462
- * `arg` - By default, accepts the third portion of the
1463
- * `formattingRegex` within `insertNodes`, i.e., to allow the locale to
1464
- * supply arguments back to the calling script.
1465
- * `key` - The substitution key.
1466
- * @callback SubstitutionCallback
1467
- * @param {{
1468
- * arg: string,
1469
- * key: string
1470
- * }} cfg
1471
- * @returns {string|Element} The replacement text or element
1472
- */
1395
+ * `arg` - By default, accepts the third portion of the
1396
+ * `formattingRegex` within `insertNodes`, i.e., to allow the locale to
1397
+ * supply arguments back to the calling script.
1398
+ * `key` - The substitution key.
1399
+ * @callback SubstitutionCallback
1400
+ * @param {{
1401
+ * arg: string,
1402
+ * key: string
1403
+ * }} cfg
1404
+ * @returns {string|Element} The replacement text or element
1405
+ */
1473
1406
 
1474
1407
  /**
1475
1408
  * May have additional properties if supplying options to an underlying
@@ -1584,11 +1517,11 @@ var promiseChainForValues = function promiseChainForValues(values, errBack) {
1584
1517
  */
1585
1518
 
1586
1519
  /**
1587
- * @typedef {Object<string, SwitchCaseArray>} SwitchArray
1520
+ * @typedef {Record<string, SwitchCaseArray>} SwitchArray
1588
1521
  */
1589
1522
 
1590
1523
  /**
1591
- * @typedef {Object<string, SwitchArray>} SwitchArrays
1524
+ * @typedef {Record<string, SwitchArray>} SwitchArrays
1592
1525
  */
1593
1526
 
1594
1527
  /**
@@ -1599,11 +1532,15 @@ var promiseChainForValues = function promiseChainForValues(values, errBack) {
1599
1532
  */
1600
1533
 
1601
1534
  /**
1602
- * @typedef {Object<string, SwitchCase>} Switch
1535
+ * @typedef {Record<string, SwitchCase>} SwitchGroup
1536
+ */
1537
+
1538
+ /**
1539
+ * @typedef {Record<string, SwitchCase|SwitchGroup>} Switch
1603
1540
  */
1604
1541
 
1605
1542
  /**
1606
- * @typedef {Object<string, Switch>} Switches
1543
+ * @typedef {Record<string, Switch>} Switches
1607
1544
  */
1608
1545
 
1609
1546
  /**
@@ -1772,15 +1709,14 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1772
1709
  });
1773
1710
  };
1774
1711
  addFunctionKeys();
1775
- var localFormatter = new LocalFormatter( /** @type {import('./getMessageForKeyByStyle.js').LocalObject} */locals);
1712
+ var localFormatter = new LocalFormatter(/** @type {import('./getMessageForKeyByStyle.js').LocalObject} */locals);
1776
1713
  var regularFormatter = new RegularFormatter(substitutions);
1777
- var switchFormatter = new SwitchFormatter( /** @type {import('./defaultLocaleResolver.js').Switches} */
1714
+ var switchFormatter = new SwitchFormatter(/** @type {import('./defaultLocaleResolver.js').Switches} */
1778
1715
  switches, {
1779
1716
  substitutions: substitutions
1780
1717
  });
1781
1718
 
1782
- // eslint-disable-next-line max-len
1783
- // eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex
1719
+ // eslint-disable-next-line prefer-named-capture-group -- Convenient for now
1784
1720
  var formattingRegex = /(\\*)\{((?:(?:[\0-\|~-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])|\\\})*?)(?:(\|)((?:[\0-\|~-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*))?\}/g;
1785
1721
  if (allSubstitutions) {
1786
1722
  allSubstitutions = Array.isArray(allSubstitutions) ? allSubstitutions : [allSubstitutions];
@@ -1813,8 +1749,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1813
1749
  */
1814
1750
  switchFormatter.constructor.isMatchingKey(key)) {
1815
1751
  substitution = switchFormatter.getSubstitution(key, {
1816
- // eslint-disable-next-line object-shorthand -- TS casting
1817
- locale: /** @type {string} */locale,
1752
+ locale: (/** @type {string} */locale),
1818
1753
  usedKeys: usedKeys,
1819
1754
  arg: arg,
1820
1755
  missingSuppliedFormatters: missingSuppliedFormatters
@@ -1858,14 +1793,12 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1858
1793
  substitution = defaultAllSubstitutions({
1859
1794
  value: substitution,
1860
1795
  arg: arg,
1861
- key: key,
1862
1796
  locale: locale
1863
1797
  });
1864
1798
  }
1865
1799
 
1866
1800
  // Change this and return type if other substitutions possible
1867
- return (/** @type {string|Node} */substitution
1868
- );
1801
+ return /** @type {string|Node} */substitution;
1869
1802
  };
1870
1803
  var recursiveLocalCount = 1;
1871
1804
  /**
@@ -1888,7 +1821,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1888
1821
  if (recursiveLocalCount++ > maximumLocalNestingDepth) {
1889
1822
  throw new TypeError('Too much recursion in local variables.');
1890
1823
  }
1891
- if ( /** @type {typeof import('./Formatter.js').LocalFormatter} */localFormatter.constructor.isMatchingKey(ky)) {
1824
+ if (/** @type {typeof import('./Formatter.js').LocalFormatter} */localFormatter.constructor.isMatchingKey(ky)) {
1892
1825
  var extraSubsts = substitutions;
1893
1826
  var localFormatters;
1894
1827
  if (arg) {
@@ -1905,7 +1838,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1905
1838
  substitutions: localFormatters
1906
1839
  });
1907
1840
  }
1908
- } else if ( /** @type {typeof import('./Formatter.js').SwitchFormatter} */
1841
+ } else if (/** @type {typeof import('./Formatter.js').SwitchFormatter} */
1909
1842
  switchFormatter.constructor.isMatchingKey(ky)) {
1910
1843
  subst = processSubsts({
1911
1844
  str: substitution
@@ -1921,13 +1854,13 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1921
1854
  var returnsDOM = false;
1922
1855
 
1923
1856
  /** @type {Replace} */
1924
- var replace = function replace(_ref6) {
1857
+ var _replace = function replace(_ref6) {
1925
1858
  var str = _ref6.str,
1926
1859
  _ref6$substs = _ref6.substs,
1927
1860
  substs = _ref6$substs === void 0 ? substitutions : _ref6$substs,
1928
1861
  _ref6$formatter = _ref6.formatter,
1929
1862
  formatter = _ref6$formatter === void 0 ? regularFormatter : _ref6$formatter;
1930
- return str.replace(formattingRegex,
1863
+ return str.replaceAll(formattingRegex,
1931
1864
  /**
1932
1865
  * @param {string} _
1933
1866
  * @param {string} esc
@@ -1956,14 +1889,14 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1956
1889
  substitution: substitution,
1957
1890
  ky: ky,
1958
1891
  arg: arg,
1959
- processSubsts: replace
1892
+ processSubsts: _replace
1960
1893
  });
1961
- returnsDOM = returnsDOM || substitution !== null && _typeof(substitution) === 'object' && 'nodeType' in substitution;
1894
+ returnsDOM || (returnsDOM = substitution !== null && _typeof(substitution) === 'object' && 'nodeType' in substitution);
1962
1895
  usedKeys.push(ky);
1963
1896
  return esc + substitution;
1964
1897
  });
1965
1898
  };
1966
- var ret = replace({
1899
+ var ret = _replace({
1967
1900
  str: string
1968
1901
  });
1969
1902
  if (!returnsDOM) {
@@ -1980,7 +1913,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1980
1913
  recursiveLocalCount = 1;
1981
1914
 
1982
1915
  /** @type {ProcessSubstitutions} */
1983
- var processSubstitutions = function processSubstitutions(_ref7) {
1916
+ var _processSubstitutions = function processSubstitutions(_ref7) {
1984
1917
  var str = _ref7.str,
1985
1918
  _ref7$substs = _ref7.substs,
1986
1919
  substs = _ref7$substs === void 0 ? substitutions : _ref7$substs,
@@ -1992,7 +1925,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
1992
1925
  // Copy to ensure we are resetting index on each instance (manually
1993
1926
  // resetting on `formattingRegex` is problematic with recursion that
1994
1927
  // uses the same regex copy)
1995
- var regex = new RegExp(formattingRegex, 'gu');
1928
+ var regex = new RegExp(formattingRegex, 'gv');
1996
1929
 
1997
1930
  /**
1998
1931
  * @param {...(string|Node)} args
@@ -2023,7 +1956,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
2023
1956
  substitution: substitution,
2024
1957
  ky: ky,
2025
1958
  arg: arg,
2026
- processSubsts: processSubstitutions
1959
+ processSubsts: _processSubstitutions
2027
1960
  });
2028
1961
  if (Array.isArray(substitution)) {
2029
1962
  push.apply(void 0, _toConsumableArray(substitution));
@@ -2034,7 +1967,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
2034
1967
  push(substitution.cloneNode(true));
2035
1968
  } else {
2036
1969
  // Why no number here?
2037
- push( /** @type {string} */substitution);
1970
+ push(/** @type {string} */substitution);
2038
1971
  }
2039
1972
  }
2040
1973
  usedKeys.push(ky);
@@ -2042,7 +1975,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
2042
1975
  });
2043
1976
  return nodes;
2044
1977
  };
2045
- var nodes = processSubstitutions({
1978
+ var nodes = _processSubstitutions({
2046
1979
  str: string
2047
1980
  });
2048
1981
  checkExtraSuppliedFormatters({
@@ -2057,6 +1990,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
2057
1990
  });
2058
1991
  };
2059
1992
 
1993
+ var _templateObject, _templateObject2;
2060
1994
  /**
2061
1995
  * @callback KeyCheckerConverterCallback
2062
1996
  * @param {string|string[]} key By default may be an array (if the type ends
@@ -2072,25 +2006,25 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
2072
2006
  /**
2073
2007
  * @type {KeyCheckerConverterCallback}
2074
2008
  */
2075
- function defaultKeyCheckerConverter(key, messageStyle) {
2076
- if (Array.isArray(key) && key.every(function (k) {
2009
+ var defaultKeyCheckerConverter = function defaultKeyCheckerConverter(key, messageStyle) {
2010
+ if (typeof messageStyle === 'string' && Array.isArray(key) && key.every(function (k) {
2077
2011
  return typeof k === 'string';
2078
- }) && typeof messageStyle === 'string' && messageStyle.endsWith('Nested')) {
2012
+ }) && messageStyle.endsWith('Nested')) {
2079
2013
  return key.map(function (k) {
2080
- return k.replace( /*#__PURE__*/_wrapRegExp(/(\\+)/g, {
2014
+ return k.replaceAll(/*#__PURE__*/_wrapRegExp(/(\\+)/g, {
2081
2015
  backslashes: 1
2082
- }), '\\$<backslashes>').replace(/\./g, '\\.');
2016
+ }), String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["$<backslashes>"], ["\\$<backslashes>"])))).replaceAll('.', String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["."], ["\\."]))));
2083
2017
  }).join('.');
2084
2018
  }
2085
2019
  if (typeof key !== 'string') {
2086
2020
  throw new TypeError('`key` is expected to be a string (or array of strings for nested style)');
2087
2021
  }
2088
2022
  return key;
2089
- }
2023
+ };
2090
2024
 
2091
2025
  /**
2092
- * @typedef {LocaleBody} LocalObject
2093
- */
2026
+ * @typedef {LocaleBody} LocalObject
2027
+ */
2094
2028
 
2095
2029
  /**
2096
2030
  * May also contain language code and direction, translator name and
@@ -2098,7 +2032,7 @@ function defaultKeyCheckerConverter(key, messageStyle) {
2098
2032
  * @typedef {object} LocaleHead
2099
2033
  * @property {LocalObject} [locals]
2100
2034
  * @property {import('./defaultLocaleResolver.js').Switches} [switches]
2101
- */
2035
+ */
2102
2036
 
2103
2037
  /**
2104
2038
  * @typedef {import('./defaultLocaleResolver.js').
@@ -2111,33 +2045,34 @@ function defaultKeyCheckerConverter(key, messageStyle) {
2111
2045
  */
2112
2046
 
2113
2047
  /**
2114
- * @typedef {object} LocaleObject
2115
- * @property {LocaleHead} [head]
2116
- * @property {LocaleBody} body
2117
- */
2048
+ * @typedef {object} LocaleObject
2049
+ * @property {LocaleHead} [head]
2050
+ * @property {LocaleBody} body
2051
+ */
2118
2052
 
2119
2053
  /**
2120
- * @typedef {object} MessageStyleCallbackResult
2121
- * @property {string} value Regardless of message style, will contain
2122
- * the string result
2123
- * @property {import(
2124
- * './defaultLocaleResolver.js'
2125
- * ).RichLocaleStringSubObject} [info] Full info on the localized item
2126
- * (for rich message styles only)
2127
- */
2054
+ * @typedef {object} MessageStyleCallbackResult
2055
+ * @property {string} value Regardless of message style, will contain
2056
+ * the string result
2057
+ * @property {import(
2058
+ * './defaultLocaleResolver.js'
2059
+ * ).RichLocaleStringSubObject} [info] Full info on the localized item
2060
+ * (for rich message styles only)
2061
+ */
2128
2062
 
2129
2063
  /**
2130
- * @callback MessageStyleCallback
2131
- * @param {LocaleObject} obj The exact
2132
- * format depends on the `cfg.defaults` of `i18n`
2133
- * @param {string} key
2134
- * @returns {false|MessageStyleCallbackResult} If `false`, will resort to default
2135
- */
2064
+ * @callback MessageStyleCallback
2065
+ * @param {LocaleObject} obj The exact
2066
+ * format depends on the `cfg.defaults` of `i18n`
2067
+ * @param {string} key
2068
+ * @returns {false|MessageStyleCallbackResult} If `false`, will resort to
2069
+ * default
2070
+ */
2136
2071
 
2137
- /* eslint-disable max-len */
2072
+ /* eslint-disable @stylistic/max-len -- Long */
2138
2073
  /**
2139
2074
  * @param {object} [cfg]
2140
- * @param {"richNested"|"rich"|"plain"|"plainNested"|MessageStyleCallback} [cfg.messageStyle="richNested"]
2075
+ * @param {"richNested"|"rich"|"plain"|"plainNested"|MessageStyleCallback} [cfg.messageStyle]
2141
2076
  * @returns {MessageStyleCallback}
2142
2077
  */
2143
2078
  var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
@@ -2157,7 +2092,8 @@ var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
2157
2092
  * @type {string[]}
2158
2093
  */
2159
2094
  var keys = [];
2160
- // eslint-disable-next-line prefer-named-capture-group
2095
+ // eslint-disable-next-line @stylistic/max-len -- Long
2096
+ // eslint-disable-next-line prefer-named-capture-group -- Convenient for now
2161
2097
  var possiblyEscapedCharPattern = /(\\*)\./g;
2162
2098
 
2163
2099
  /**
@@ -2195,23 +2131,26 @@ var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
2195
2131
  */
2196
2132
  var ret = false;
2197
2133
  var currObj = obj;
2134
+
2135
+ // eslint-disable-next-line @stylistic/max-len -- Long
2136
+ // eslint-disable-next-line unicorn/no-unused-array-method-return -- Shortcircuiting
2198
2137
  keysUnescaped.some(function (ky, i, kys) {
2199
2138
  if (!currObj || _typeof(currObj) !== 'object') {
2200
2139
  return true;
2201
2140
  }
2202
2141
  if (
2203
2142
  // If specified key is too deep, we should fail
2204
- i === kys.length - 1 && ky in currObj && currObj[ky] && _typeof(currObj[ky]) === 'object' && 'message' in currObj[ky] &&
2143
+ i === kys.length - 1 && Object.hasOwn(currObj, ky) && currObj[ky] !== null && _typeof(currObj[ky]) === 'object' && 'message' in currObj[ky] &&
2205
2144
  // NECESSARY FOR SECURITY ON UNTRUSTED LOCALES
2206
2145
  typeof currObj[ky].message === 'string') {
2207
2146
  ret = {
2208
- value: /** @type {string} */currObj[ky].message,
2209
- info:
2147
+ value: (/** @type {string} */currObj[ky].message),
2148
+ info: (
2210
2149
  /**
2211
2150
  * @type {import('./defaultLocaleResolver.js').
2212
2151
  * RichLocaleStringSubObject}
2213
2152
  */
2214
- currObj[ky]
2153
+ currObj[ky])
2215
2154
  };
2216
2155
  }
2217
2156
  currObj =
@@ -2232,7 +2171,7 @@ var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
2232
2171
  * }
2233
2172
  */
2234
2173
  mainObj && _typeof(mainObj) === 'object' && mainObj.body;
2235
- if (obj && _typeof(obj) === 'object' && key in obj && obj[key] && _typeof(obj[key]) === 'object' && 'message' in obj[key] &&
2174
+ if (obj && _typeof(obj) === 'object' && Object.hasOwn(obj, key) && obj[key] !== null && _typeof(obj[key]) === 'object' && 'message' in obj[key] &&
2236
2175
  // NECESSARY FOR SECURITY ON UNTRUSTED LOCALES
2237
2176
  typeof obj[key].message === 'string') {
2238
2177
  return {
@@ -2249,7 +2188,7 @@ var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
2249
2188
  * }
2250
2189
  */
2251
2190
  mainObj && _typeof(mainObj) === 'object' && mainObj.body;
2252
- if (obj && _typeof(obj) === 'object' && key in obj && obj[key] && typeof obj[key] === 'string') {
2191
+ if (obj && _typeof(obj) === 'object' && Object.hasOwn(obj, key) && obj[key] !== null && typeof obj[key] === 'string') {
2253
2192
  return {
2254
2193
  value: obj[key]
2255
2194
  };
@@ -2276,6 +2215,8 @@ var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
2276
2215
  * PlainNestedLocaleStringBodyObject}
2277
2216
  */
2278
2217
  function (o, k) {
2218
+ // eslint-disable-next-line @stylistic/max-len -- Long
2219
+ // eslint-disable-next-line unicorn/no-computed-property-existence-check -- Ok
2279
2220
  if (o && _typeof(o) === 'object' && o[k]) {
2280
2221
  return o[k];
2281
2222
  }
@@ -2302,7 +2243,7 @@ var getMessageForKeyByStyle = function getMessageForKeyByStyle() {
2302
2243
  * } [cfg.defaults]
2303
2244
  * @param {"richNested"|"rich"|"plain"|"plainNested"|
2304
2245
  * import('./getMessageForKeyByStyle.js').MessageStyleCallback
2305
- * } [cfg.messageStyle="richNested"]
2246
+ * } [cfg.messageStyle]
2306
2247
  * @param {import('./getMessageForKeyByStyle.js').
2307
2248
  * MessageStyleCallback
2308
2249
  * } [cfg.messageForKey] Defaults to getting `MessageStyleCallback` based
@@ -2325,7 +2266,10 @@ var getStringFromMessageAndDefaults = function getStringFromMessageAndDefaults(_
2325
2266
  var str;
2326
2267
  if (typeof message === 'string') {
2327
2268
  str = message;
2328
- } else if (defaults === false || defaults === undefined || defaults === null) {
2269
+ } else if (
2270
+ // eslint-disable-next-line @stylistic/max-len -- Long
2271
+ // eslint-disable-next-line unicorn/prefer-includes-over-repeated-comparisons -- TS
2272
+ defaults === false || defaults === undefined || defaults === null) {
2329
2273
  str = false;
2330
2274
  } else if (defaults && _typeof(defaults) === 'object') {
2331
2275
  var msg = messageForKey(defaults, key);
@@ -2371,18 +2315,18 @@ var getStringFromMessageAndDefaults = function getStringFromMessageAndDefaults(_
2371
2315
  * for use by configuring formatters
2372
2316
  * @param {import('./getMessageForKeyByStyle.js').LocalObject} [cfg.locals]
2373
2317
  * @param {import('./defaultLocaleResolver.js').Switches} [cfg.switches]
2374
- * @param {Integer} [cfg.maximumLocalNestingDepth=3]
2318
+ * @param {Integer} [cfg.maximumLocalNestingDepth]
2375
2319
  * @param {?(import('./defaultAllSubstitutions.js').AllSubstitutionCallback|
2376
2320
  * import('./defaultAllSubstitutions.js').AllSubstitutionCallback[])
2377
- * } [cfg.allSubstitutions=[defaultAllSubstitutions]]
2321
+ * } [cfg.allSubstitutions]
2378
2322
  * @param {import('./defaultInsertNodes.js').InsertNodesCallback
2379
- * } [cfg.insertNodes=defaultInsertNodes]
2323
+ * } [cfg.insertNodes]
2380
2324
  * @param {false|import('./defaultLocaleResolver.js').SubstitutionObject
2381
- * } [cfg.substitutions=false]
2382
- * @param {boolean} [cfg.dom=false]
2383
- * @param {boolean} [cfg.forceNodeReturn=false]
2384
- * @param {boolean} [cfg.throwOnMissingSuppliedFormatters=true]
2385
- * @param {boolean} [cfg.throwOnExtraSuppliedFormatters=true]
2325
+ * } [cfg.substitutions]
2326
+ * @param {boolean} [cfg.dom]
2327
+ * @param {boolean} [cfg.forceNodeReturn]
2328
+ * @param {boolean} [cfg.throwOnMissingSuppliedFormatters]
2329
+ * @param {boolean} [cfg.throwOnExtraSuppliedFormatters]
2386
2330
  * @returns {string|Text|DocumentFragment}
2387
2331
  */
2388
2332
  var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
@@ -2417,6 +2361,12 @@ var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
2417
2361
  var _doc = getDocument();
2418
2362
  return forceNodeReturn ? /** @type {Document} */_doc.createTextNode(str) : str;
2419
2363
  };
2364
+ if (!substitutions && !allSubstitutions && !throwOnMissingSuppliedFormatters) {
2365
+ return stringOrTextNode(string);
2366
+ }
2367
+ if (!substitutions) {
2368
+ substitutions = {};
2369
+ }
2420
2370
 
2421
2371
  /** @type {string[]} */
2422
2372
  var usedKeys = [];
@@ -2442,13 +2392,13 @@ var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
2442
2392
  var key = _ref3.key,
2443
2393
  formatter = _ref3.formatter;
2444
2394
  var matching = formatter.isMatch(key);
2445
- if (
2395
+ if (!matching &&
2446
2396
  /**
2447
2397
  * @type {typeof import('./Formatter.js').LocalFormatter|
2448
2398
  * typeof import('./Formatter.js').RegularFormatter|
2449
2399
  * typeof import('./Formatter.js').SwitchFormatter}
2450
2400
  */
2451
- formatter.constructor.isMatchingKey(key) && !matching) {
2401
+ formatter.constructor.isMatchingKey(key)) {
2452
2402
  if (throwOnMissingSuppliedFormatters) {
2453
2403
  throw new Error("Missing formatting key: ".concat(key));
2454
2404
  }
@@ -2456,12 +2406,6 @@ var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
2456
2406
  }
2457
2407
  return false;
2458
2408
  };
2459
- if (!substitutions && !allSubstitutions && !throwOnMissingSuppliedFormatters) {
2460
- return stringOrTextNode(string);
2461
- }
2462
- if (!substitutions) {
2463
- substitutions = {};
2464
- }
2465
2409
  var nodes = insertNodes({
2466
2410
  string: string,
2467
2411
  dom: dom,
@@ -2483,49 +2427,17 @@ var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
2483
2427
  return container;
2484
2428
  };
2485
2429
 
2486
- function _await$1(value, then, direct) {
2487
- if (direct) {
2488
- return then ? then(value) : value;
2489
- }
2490
- if (!value || !value.then) {
2491
- value = Promise.resolve(value);
2492
- }
2493
- return then ? value.then(then) : value;
2494
- } /**
2495
- * Takes a locale and returns a new locale to check.
2496
- * @callback LocaleMatcher
2497
- * @param {string} locale The failed locale
2498
- * @throws {Error} If there are no further hyphens left to check
2499
- * @returns {string|Promise<string>} The new locale to check
2500
- */
2430
+ /**
2431
+ * Takes a locale and returns a new locale to check.
2432
+ * @callback LocaleMatcher
2433
+ * @param {string} locale The failed locale
2434
+ * @throws {Error} If there are no further hyphens left to check
2435
+ * @returns {string|Promise<string>} The new locale to check
2436
+ */
2501
2437
 
2502
2438
  /**
2503
2439
  * @type {LocaleMatcher}
2504
2440
  */
2505
-
2506
- function _async(f) {
2507
- return function () {
2508
- for (var args = [], i = 0; i < arguments.length; i++) {
2509
- args[i] = arguments[i];
2510
- }
2511
- try {
2512
- return Promise.resolve(f.apply(this, args));
2513
- } catch (e) {
2514
- return Promise.reject(e);
2515
- }
2516
- };
2517
- }
2518
- function _catch(body, recover) {
2519
- try {
2520
- var result = body();
2521
- } catch (e) {
2522
- return recover(e);
2523
- }
2524
- if (result && result.then) {
2525
- return result.then(void 0, recover);
2526
- }
2527
- return result;
2528
- }
2529
2441
  var defaultLocaleMatcher = function defaultLocaleMatcher(locale) {
2530
2442
  if (!locale.includes('-')) {
2531
2443
  throw new Error('Locale not available');
@@ -2533,14 +2445,14 @@ var defaultLocaleMatcher = function defaultLocaleMatcher(locale) {
2533
2445
  // Try without hyphen, i.e., the "lookup" algorithm:
2534
2446
  // See https://tools.ietf.org/html/rfc4647#section-3.4 and
2535
2447
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
2536
- return locale.replace(/\x2D(?:[\0-,\.-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*$/, '');
2448
+ return locale.replace(/-(?:[\0-,\.-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*$/, '');
2537
2449
  };
2538
2450
 
2539
2451
  /**
2540
2452
  * @param {object} cfg
2541
2453
  * @param {string} cfg.locale
2542
2454
  * @param {string[]} cfg.locales
2543
- * @param {LocaleMatcher} [cfg.localeMatcher=defaultLocaleMatcher]
2455
+ * @param {LocaleMatcher} [cfg.localeMatcher]
2544
2456
  * @returns {string|false}
2545
2457
  */
2546
2458
  var getMatchingLocale = function getMatchingLocale(_ref) {
@@ -2597,14 +2509,13 @@ var findLocaleStrings = function findLocaleStrings() {
2597
2509
  localeResolver = _ref2.localeResolver,
2598
2510
  localesBasePath = _ref2.localesBasePath,
2599
2511
  localeMatcher = _ref2.localeMatcher;
2600
- return (/** @type {Promise<LocaleObjectInfo>} */_findLocale({
2601
- locales: locales,
2602
- defaultLocales: defaultLocales,
2603
- localeResolver: localeResolver,
2604
- localesBasePath: localesBasePath,
2605
- localeMatcher: localeMatcher
2606
- })
2607
- );
2512
+ return /** @type {Promise<LocaleObjectInfo>} */_findLocale({
2513
+ locales: locales,
2514
+ defaultLocales: defaultLocales,
2515
+ localeResolver: localeResolver,
2516
+ localesBasePath: localesBasePath,
2517
+ localeMatcher: localeMatcher
2518
+ });
2608
2519
  };
2609
2520
 
2610
2521
  /**
@@ -2628,15 +2539,14 @@ var findLocale = function findLocale() {
2628
2539
  localeResolver = _ref3.localeResolver,
2629
2540
  localesBasePath = _ref3.localesBasePath,
2630
2541
  localeMatcher = _ref3.localeMatcher;
2631
- return (/** @type {Promise<string>} */_findLocale({
2632
- locales: locales,
2633
- defaultLocales: defaultLocales,
2634
- localeResolver: localeResolver,
2635
- localesBasePath: localesBasePath,
2636
- localeMatcher: localeMatcher,
2637
- headOnly: true
2638
- })
2639
- );
2542
+ return /** @type {Promise<string>} */_findLocale({
2543
+ locales: locales,
2544
+ defaultLocales: defaultLocales,
2545
+ localeResolver: localeResolver,
2546
+ localesBasePath: localesBasePath,
2547
+ localeMatcher: localeMatcher,
2548
+ headOnly: true
2549
+ });
2640
2550
  };
2641
2551
 
2642
2552
  /**
@@ -2648,65 +2558,114 @@ var findLocale = function findLocale() {
2648
2558
  * property to determine whether to make a simple HEAD and resolve to
2649
2559
  * the locale rather than locale and contents
2650
2560
  */
2651
- var _findLocale = _async(function (_ref4) {
2652
- /**
2653
- * @callback getLocale
2654
- * @throws {SyntaxError|TypeError|Error}
2655
- * @param {string} locale
2656
- * @returns {Promise<LocaleObjectInfo|string>}
2657
- */
2658
- var getLocale = _async(function (locale) {
2659
- if (typeof locale !== 'string') {
2660
- throw new TypeError('Non-string locale type');
2661
- }
2662
- var url = localeResolver(localesBasePath, locale);
2663
- if (typeof url !== 'string') {
2664
- throw new TypeError('`localeResolver` expected to resolve to (URL) string.');
2665
- }
2666
- return _catch(function () {
2667
- var _fetch = /** @type {import('./shared.js').Fetch} */getFetch();
2668
- return _await$1(headOnly ? _fetch(url, {
2669
- method: 'HEAD'
2670
- }) : _fetch(url), function (resp) {
2671
- if (resp.status === 404) {
2672
- // Don't allow browser (tested in Firefox) to continue
2673
- // and give `SyntaxError` with missing file or we won't be
2674
- // able to try without the hyphen
2675
- throw new Error('Trying again');
2676
- }
2677
- return headOnly ? locale : _await$1(resp.json(), function (strings) {
2678
- return {
2679
- locale: locale,
2680
- strings: strings
2561
+ var _findLocale = /*#__PURE__*/function () {
2562
+ var _findLocale2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref4) {
2563
+ var _ref4$locales, locales, _ref4$defaultLocales, defaultLocales, _ref4$localeResolver, localeResolver, _ref4$localesBasePath, localesBasePath, _ref4$localeMatcher, localeMatcher, _ref4$headOnly, headOnly, getLocale, _getLocale;
2564
+ return _regenerator().w(function (_context2) {
2565
+ while (1) switch (_context2.n) {
2566
+ case 0:
2567
+ _getLocale = function _getLocale3() {
2568
+ _getLocale = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(locale) {
2569
+ var url, _fetch, resp, strings, newLocale, _t;
2570
+ return _regenerator().w(function (_context) {
2571
+ while (1) switch (_context.p = _context.n) {
2572
+ case 0:
2573
+ if (!(typeof locale !== 'string')) {
2574
+ _context.n = 1;
2575
+ break;
2576
+ }
2577
+ throw new TypeError('Non-string locale type');
2578
+ case 1:
2579
+ url = localeResolver(localesBasePath, locale);
2580
+ if (!(typeof url !== 'string')) {
2581
+ _context.n = 2;
2582
+ break;
2583
+ }
2584
+ throw new TypeError('`localeResolver` expected to resolve to (URL) string.');
2585
+ case 2:
2586
+ _context.p = 2;
2587
+ _fetch = /** @type {import('./shared.js').Fetch} */getFetch();
2588
+ _context.n = 3;
2589
+ return headOnly ? _fetch(url, {
2590
+ method: 'HEAD'
2591
+ }) : _fetch(url);
2592
+ case 3:
2593
+ resp = _context.v;
2594
+ if (!(resp.status === 404)) {
2595
+ _context.n = 4;
2596
+ break;
2597
+ }
2598
+ throw new Error('Trying again');
2599
+ case 4:
2600
+ if (!headOnly) {
2601
+ _context.n = 5;
2602
+ break;
2603
+ }
2604
+ return _context.a(2, locale);
2605
+ case 5:
2606
+ _context.n = 6;
2607
+ return resp.json();
2608
+ case 6:
2609
+ strings = _context.v;
2610
+ return _context.a(2, {
2611
+ locale: locale,
2612
+ strings: strings
2613
+ });
2614
+ case 7:
2615
+ _context.p = 7;
2616
+ _t = _context.v;
2617
+ if (!(/** @type {Error} */_t.name === 'SyntaxError')) {
2618
+ _context.n = 8;
2619
+ break;
2620
+ }
2621
+ throw _t;
2622
+ case 8:
2623
+ _context.n = 9;
2624
+ return /** @type {LocaleMatcher} */localeMatcher(locale);
2625
+ case 9:
2626
+ newLocale = _context.v;
2627
+ return _context.a(2, getLocale(newLocale));
2628
+ }
2629
+ }, _callee, null, [[2, 7]]);
2630
+ }));
2631
+ return _getLocale.apply(this, arguments);
2681
2632
  };
2682
- });
2683
- });
2684
- }, function (err) {
2685
- if ( /** @type {Error} */err.name === 'SyntaxError') {
2686
- throw err;
2633
+ getLocale = function _getLocale2(_x2) {
2634
+ return _getLocale.apply(this, arguments);
2635
+ };
2636
+ _ref4$locales = _ref4.locales, locales = _ref4$locales === void 0 ? typeof intlDomLocale !== 'undefined' ? [intlDomLocale] : typeof navigator === 'undefined' ? [] : navigator.languages : _ref4$locales, _ref4$defaultLocales = _ref4.defaultLocales, defaultLocales = _ref4$defaultLocales === void 0 ? ['en-US'] : _ref4$defaultLocales, _ref4$localeResolver = _ref4.localeResolver, localeResolver = _ref4$localeResolver === void 0 ? defaultLocaleResolver : _ref4$localeResolver, _ref4$localesBasePath = _ref4.localesBasePath, localesBasePath = _ref4$localesBasePath === void 0 ? '.' : _ref4$localesBasePath, _ref4$localeMatcher = _ref4.localeMatcher, localeMatcher = _ref4$localeMatcher === void 0 ? 'lookup' : _ref4$localeMatcher, _ref4$headOnly = _ref4.headOnly, headOnly = _ref4$headOnly === void 0 ? false : _ref4$headOnly;
2637
+ /**
2638
+ * @callback getLocale
2639
+ * @throws {SyntaxError|TypeError|Error}
2640
+ * @param {string} locale
2641
+ * @returns {Promise<LocaleObjectInfo|string>}
2642
+ */
2643
+ if (!(localeMatcher === 'lookup')) {
2644
+ _context2.n = 1;
2645
+ break;
2646
+ }
2647
+ localeMatcher = defaultLocaleMatcher;
2648
+ _context2.n = 2;
2649
+ break;
2650
+ case 1:
2651
+ if (!(typeof localeMatcher !== 'function')) {
2652
+ _context2.n = 2;
2653
+ break;
2654
+ }
2655
+ throw new TypeError('`localeMatcher` must be "lookup" or a function!');
2656
+ case 2:
2657
+ _context2.n = 3;
2658
+ return promiseChainForValues([].concat(_toConsumableArray(locales), _toConsumableArray(defaultLocales)), getLocale, 'No matching locale found for ' + [].concat(_toConsumableArray(locales), _toConsumableArray(defaultLocales)).join(', '));
2659
+ case 3:
2660
+ return _context2.a(2, _context2.v);
2687
2661
  }
2688
- return _await$1( /** @type {LocaleMatcher} */localeMatcher(locale), getLocale);
2689
- });
2690
- });
2691
- var _ref4$locales = _ref4.locales,
2692
- locales = _ref4$locales === void 0 ? typeof intlDomLocale !== 'undefined' ? [intlDomLocale] : typeof navigator === 'undefined' ? [] : navigator.languages : _ref4$locales,
2693
- _ref4$defaultLocales = _ref4.defaultLocales,
2694
- defaultLocales = _ref4$defaultLocales === void 0 ? ['en-US'] : _ref4$defaultLocales,
2695
- _ref4$localeResolver = _ref4.localeResolver,
2696
- localeResolver = _ref4$localeResolver === void 0 ? defaultLocaleResolver : _ref4$localeResolver,
2697
- _ref4$localesBasePath = _ref4.localesBasePath,
2698
- localesBasePath = _ref4$localesBasePath === void 0 ? '.' : _ref4$localesBasePath,
2699
- _ref4$localeMatcher = _ref4.localeMatcher,
2700
- localeMatcher = _ref4$localeMatcher === void 0 ? 'lookup' : _ref4$localeMatcher,
2701
- _ref4$headOnly = _ref4.headOnly,
2702
- headOnly = _ref4$headOnly === void 0 ? false : _ref4$headOnly;
2703
- if (localeMatcher === 'lookup') {
2704
- localeMatcher = defaultLocaleMatcher;
2705
- } else if (typeof localeMatcher !== 'function') {
2706
- throw new TypeError('`localeMatcher` must be "lookup" or a function!');
2662
+ }, _callee2);
2663
+ }));
2664
+ function _findLocale(_x) {
2665
+ return _findLocale2.apply(this, arguments);
2707
2666
  }
2708
- return promiseChainForValues([].concat(_toConsumableArray(locales), _toConsumableArray(defaultLocales)), getLocale, 'No matching locale found for ' + [].concat(_toConsumableArray(locales), _toConsumableArray(defaultLocales)).join(', '));
2709
- });
2667
+ return _findLocale;
2668
+ }();
2710
2669
 
2711
2670
  /**
2712
2671
  * @typedef {import('./index.js').Sort} Sort
@@ -2728,81 +2687,25 @@ var _findLocale = _async(function (_ref4) {
2728
2687
  * @param {string} cfg.resolvedLocale
2729
2688
  * @param {"richNested"|"rich"|"plain"|"plainNested"|
2730
2689
  * import('./getMessageForKeyByStyle.js').
2731
- * MessageStyleCallback} [cfg.messageStyle="richNested"]
2690
+ * MessageStyleCallback} [cfg.messageStyle]
2732
2691
  * @param {?import('./defaultAllSubstitutions.js').AllSubstitutionCallback|
2733
2692
  * import('./defaultAllSubstitutions.js').
2734
2693
  * AllSubstitutionCallback[]} [cfg.allSubstitutions]
2735
2694
  * @param {import('./defaultInsertNodes.js').
2736
- * InsertNodesCallback} [cfg.insertNodes=defaultInsertNodes]
2695
+ * InsertNodesCallback} [cfg.insertNodes]
2737
2696
  * @param {import('./defaultKeyCheckerConverter.js').
2738
2697
  * KeyCheckerConverterCallback} [cfg.keyCheckerConverter]
2739
2698
  * @param {false|null|undefined|
2740
2699
  * import('./getMessageForKeyByStyle.js').LocaleObject} [cfg.defaults]
2741
2700
  * @param {false|import('./defaultLocaleResolver.js').
2742
- * SubstitutionObject} [cfg.substitutions={}]
2743
- * @param {Integer} [cfg.maximumLocalNestingDepth=3]
2744
- * @param {boolean} [cfg.dom=false]
2745
- * @param {boolean} [cfg.forceNodeReturn=false]
2746
- * @param {boolean} [cfg.throwOnMissingSuppliedFormatters=true]
2747
- * @param {boolean} [cfg.throwOnExtraSuppliedFormatters=true]
2701
+ * SubstitutionObject} [cfg.substitutions]
2702
+ * @param {Integer} [cfg.maximumLocalNestingDepth]
2703
+ * @param {boolean} [cfg.dom]
2704
+ * @param {boolean} [cfg.forceNodeReturn]
2705
+ * @param {boolean} [cfg.throwOnMissingSuppliedFormatters]
2706
+ * @param {boolean} [cfg.throwOnExtraSuppliedFormatters]
2748
2707
  * @returns {I18NCallback} Rejects if no suitable locale is found.
2749
2708
  */
2750
-
2751
- function _await(value, then, direct) {
2752
- if (direct) {
2753
- return then ? then(value) : value;
2754
- }
2755
- if (!value || !value.then) {
2756
- value = Promise.resolve(value);
2757
- }
2758
- return then ? value.then(then) : value;
2759
- }
2760
-
2761
- /**
2762
- * @typedef {number} Integer
2763
- */
2764
-
2765
- /**
2766
- * @param {object} [cfg={}]
2767
- * @param {string[]} [cfg.locales=navigator.languages] BCP-47 language strings
2768
- * @param {string[]} [cfg.defaultLocales=["en-US"]]
2769
- * @param {import('./findLocaleStrings.js').
2770
- * LocaleStringFinder} [cfg.localeStringFinder=findLocaleStrings]
2771
- * @param {string} [cfg.localesBasePath="."]
2772
- * @param {import('./defaultLocaleResolver.js').
2773
- * LocaleResolver} [cfg.localeResolver=defaultLocaleResolver]
2774
- * @param {"lookup"|import('./findLocaleStrings.js').
2775
- * LocaleMatcher} [cfg.localeMatcher="lookup"]
2776
- * @param {"richNested"|"rich"|"plain"|"plainNested"|
2777
- * import('./getMessageForKeyByStyle.js').
2778
- * MessageStyleCallback} [cfg.messageStyle="richNested"]
2779
- * @param {?(import('./defaultAllSubstitutions.js').AllSubstitutionCallback|
2780
- * import('./defaultAllSubstitutions.js').
2781
- * AllSubstitutionCallback[])} [cfg.allSubstitutions]
2782
- * @param {import('./defaultInsertNodes.js').
2783
- * InsertNodesCallback} [cfg.insertNodes=defaultInsertNodes]
2784
- * @param {import('./defaultKeyCheckerConverter.js').
2785
- * KeyCheckerConverterCallback} [cfg.keyCheckerConverter]
2786
- * @param {false|null|undefined|
2787
- * import('./getMessageForKeyByStyle.js').LocaleObject} [cfg.defaults]
2788
- * @param {false|
2789
- * import('./defaultLocaleResolver.js').
2790
- * SubstitutionObject} [cfg.substitutions={}]
2791
- * @param {Integer} [cfg.maximumLocalNestingDepth=3]
2792
- * @param {boolean} [cfg.dom=false]
2793
- * @param {boolean} [cfg.forceNodeReturn=false]
2794
- * @param {boolean} [cfg.throwOnMissingSuppliedFormatters=true]
2795
- * @param {boolean} [cfg.throwOnExtraSuppliedFormatters=true]
2796
- * @returns {Promise<I18NCallback>} Rejects if no suitable locale is found.
2797
- */
2798
-
2799
- function _invoke(body, then) {
2800
- var result = body();
2801
- if (result && result.then) {
2802
- return result.then(then);
2803
- }
2804
- return then(result);
2805
- }
2806
2709
  var i18nServer = function i18nServer(_ref) {
2807
2710
  var strings = _ref.strings,
2808
2711
  resolvedLocale = _ref.resolvedLocale,
@@ -2889,74 +2792,129 @@ var i18nServer = function i18nServer(_ref) {
2889
2792
  };
2890
2793
  return formatter;
2891
2794
  };
2892
- var i18n = function i18n() {
2893
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2894
- locales = _ref3.locales,
2895
- defaultLocales = _ref3.defaultLocales,
2896
- _ref3$localeStringFin = _ref3.localeStringFinder,
2897
- localeStringFinder = _ref3$localeStringFin === void 0 ? findLocaleStrings : _ref3$localeStringFin,
2898
- localesBasePath = _ref3.localesBasePath,
2899
- localeResolver = _ref3.localeResolver,
2900
- localeMatcher = _ref3.localeMatcher,
2901
- messageStyle = _ref3.messageStyle,
2902
- allSubstitutions = _ref3.allSubstitutions,
2903
- insertNodes = _ref3.insertNodes,
2904
- keyCheckerConverter = _ref3.keyCheckerConverter,
2905
- defaults = _ref3.defaults,
2906
- substitutions = _ref3.substitutions,
2907
- maximumLocalNestingDepth = _ref3.maximumLocalNestingDepth,
2908
- dom = _ref3.dom,
2909
- forceNodeReturn = _ref3.forceNodeReturn,
2910
- throwOnMissingSuppliedFormatters = _ref3.throwOnMissingSuppliedFormatters,
2911
- throwOnExtraSuppliedFormatters = _ref3.throwOnExtraSuppliedFormatters;
2912
- try {
2913
- return _await(localeStringFinder({
2914
- locales: locales,
2915
- defaultLocales: defaultLocales,
2916
- localeResolver: localeResolver,
2917
- localesBasePath: localesBasePath,
2918
- localeMatcher: localeMatcher
2919
- }), function (_ref4) {
2920
- var strings = _ref4.strings,
2921
- resolvedLocale = _ref4.locale;
2922
- return _invoke(function () {
2923
- if (!defaults && defaultLocales) {
2924
- var defaultLocale;
2925
- return _await(localeStringFinder({
2795
+
2796
+ /**
2797
+ * @typedef {number} Integer
2798
+ */
2799
+
2800
+ /**
2801
+ * @param {object} [cfg]
2802
+ * @param {string[]} [cfg.locales] BCP-47 language strings
2803
+ * @param {string[]} [cfg.defaultLocales]
2804
+ * @param {import('./findLocaleStrings.js').
2805
+ * LocaleStringFinder} [cfg.localeStringFinder]
2806
+ * @param {string} [cfg.localesBasePath]
2807
+ * @param {import('./defaultLocaleResolver.js').
2808
+ * LocaleResolver} [cfg.localeResolver]
2809
+ * @param {"lookup"|import('./findLocaleStrings.js').
2810
+ * LocaleMatcher} [cfg.localeMatcher]
2811
+ * @param {"richNested"|"rich"|"plain"|"plainNested"|
2812
+ * import('./getMessageForKeyByStyle.js').
2813
+ * MessageStyleCallback} [cfg.messageStyle]
2814
+ * @param {?(import('./defaultAllSubstitutions.js').AllSubstitutionCallback|
2815
+ * import('./defaultAllSubstitutions.js').
2816
+ * AllSubstitutionCallback[])} [cfg.allSubstitutions]
2817
+ * @param {import('./defaultInsertNodes.js').
2818
+ * InsertNodesCallback} [cfg.insertNodes]
2819
+ * @param {import('./defaultKeyCheckerConverter.js').
2820
+ * KeyCheckerConverterCallback} [cfg.keyCheckerConverter]
2821
+ * @param {false|null|undefined|
2822
+ * import('./getMessageForKeyByStyle.js').LocaleObject} [cfg.defaults]
2823
+ * @param {false|
2824
+ * import('./defaultLocaleResolver.js').
2825
+ * SubstitutionObject} [cfg.substitutions]
2826
+ * @param {Integer} [cfg.maximumLocalNestingDepth]
2827
+ * @param {boolean} [cfg.dom]
2828
+ * @param {boolean} [cfg.forceNodeReturn]
2829
+ * @param {boolean} [cfg.throwOnMissingSuppliedFormatters]
2830
+ * @param {boolean} [cfg.throwOnExtraSuppliedFormatters]
2831
+ * @returns {Promise<I18NCallback>} Rejects if no suitable locale is found.
2832
+ */
2833
+ var i18n = /*#__PURE__*/function () {
2834
+ var _i18n = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2835
+ var _ref3,
2836
+ locales,
2837
+ defaultLocales,
2838
+ _ref3$localeStringFin,
2839
+ localeStringFinder,
2840
+ localesBasePath,
2841
+ localeResolver,
2842
+ localeMatcher,
2843
+ messageStyle,
2844
+ allSubstitutions,
2845
+ insertNodes,
2846
+ keyCheckerConverter,
2847
+ defaults,
2848
+ substitutions,
2849
+ maximumLocalNestingDepth,
2850
+ dom,
2851
+ forceNodeReturn,
2852
+ throwOnMissingSuppliedFormatters,
2853
+ throwOnExtraSuppliedFormatters,
2854
+ _yield$localeStringFi,
2855
+ strings,
2856
+ resolvedLocale,
2857
+ defaultLocale,
2858
+ _yield$localeStringFi2,
2859
+ _args = arguments;
2860
+ return _regenerator().w(function (_context) {
2861
+ while (1) switch (_context.n) {
2862
+ case 0:
2863
+ _ref3 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, locales = _ref3.locales, defaultLocales = _ref3.defaultLocales, _ref3$localeStringFin = _ref3.localeStringFinder, localeStringFinder = _ref3$localeStringFin === void 0 ? findLocaleStrings : _ref3$localeStringFin, localesBasePath = _ref3.localesBasePath, localeResolver = _ref3.localeResolver, localeMatcher = _ref3.localeMatcher, messageStyle = _ref3.messageStyle, allSubstitutions = _ref3.allSubstitutions, insertNodes = _ref3.insertNodes, keyCheckerConverter = _ref3.keyCheckerConverter, defaults = _ref3.defaults, substitutions = _ref3.substitutions, maximumLocalNestingDepth = _ref3.maximumLocalNestingDepth, dom = _ref3.dom, forceNodeReturn = _ref3.forceNodeReturn, throwOnMissingSuppliedFormatters = _ref3.throwOnMissingSuppliedFormatters, throwOnExtraSuppliedFormatters = _ref3.throwOnExtraSuppliedFormatters;
2864
+ _context.n = 1;
2865
+ return localeStringFinder({
2866
+ locales: locales,
2867
+ defaultLocales: defaultLocales,
2868
+ localeResolver: localeResolver,
2869
+ localesBasePath: localesBasePath,
2870
+ localeMatcher: localeMatcher
2871
+ });
2872
+ case 1:
2873
+ _yield$localeStringFi = _context.v;
2874
+ strings = _yield$localeStringFi.strings;
2875
+ resolvedLocale = _yield$localeStringFi.locale;
2876
+ if (!(!defaults && defaultLocales)) {
2877
+ _context.n = 3;
2878
+ break;
2879
+ }
2880
+ _context.n = 2;
2881
+ return localeStringFinder({
2926
2882
  locales: defaultLocales,
2927
2883
  defaultLocales: [],
2928
2884
  localeResolver: localeResolver,
2929
2885
  localesBasePath: localesBasePath,
2930
2886
  localeMatcher: localeMatcher
2931
- }), function (_localeStringFinder) {
2932
- defaults = _localeStringFinder.strings;
2933
- defaultLocale = _localeStringFinder.locale;
2934
- if (defaultLocale === resolvedLocale) {
2935
- defaults = null; // No need to fall back
2936
- }
2937
2887
  });
2938
- }
2939
- }, function () {
2940
- return i18nServer({
2941
- strings: strings,
2942
- resolvedLocale: resolvedLocale,
2943
- messageStyle: messageStyle,
2944
- allSubstitutions: allSubstitutions,
2945
- insertNodes: insertNodes,
2946
- keyCheckerConverter: keyCheckerConverter,
2947
- defaults: defaults,
2948
- substitutions: substitutions,
2949
- maximumLocalNestingDepth: maximumLocalNestingDepth,
2950
- dom: dom,
2951
- forceNodeReturn: forceNodeReturn,
2952
- throwOnMissingSuppliedFormatters: throwOnMissingSuppliedFormatters,
2953
- throwOnExtraSuppliedFormatters: throwOnExtraSuppliedFormatters
2954
- });
2955
- });
2956
- });
2957
- } catch (e) {
2958
- return Promise.reject(e);
2888
+ case 2:
2889
+ _yield$localeStringFi2 = _context.v;
2890
+ defaults = _yield$localeStringFi2.strings;
2891
+ defaultLocale = _yield$localeStringFi2.locale;
2892
+ if (defaultLocale === resolvedLocale) {
2893
+ defaults = null; // No need to fall back
2894
+ }
2895
+ case 3:
2896
+ return _context.a(2, i18nServer({
2897
+ strings: strings,
2898
+ resolvedLocale: resolvedLocale,
2899
+ messageStyle: messageStyle,
2900
+ allSubstitutions: allSubstitutions,
2901
+ insertNodes: insertNodes,
2902
+ keyCheckerConverter: keyCheckerConverter,
2903
+ defaults: defaults,
2904
+ substitutions: substitutions,
2905
+ maximumLocalNestingDepth: maximumLocalNestingDepth,
2906
+ dom: dom,
2907
+ forceNodeReturn: forceNodeReturn,
2908
+ throwOnMissingSuppliedFormatters: throwOnMissingSuppliedFormatters,
2909
+ throwOnExtraSuppliedFormatters: throwOnExtraSuppliedFormatters
2910
+ }));
2911
+ }
2912
+ }, _callee);
2913
+ }));
2914
+ function i18n() {
2915
+ return _i18n.apply(this, arguments);
2959
2916
  }
2960
- };
2917
+ return i18n;
2918
+ }();
2961
2919
 
2962
2920
  export { Formatter, LocalFormatter, RegularFormatter, SwitchFormatter, defaultAllSubstitutions, defaultInsertNodes, defaultKeyCheckerConverter, defaultLocaleMatcher, defaultLocaleResolver, findLocale, findLocaleStrings, getDOMForLocaleString, getDocument, getFetch, getMatchingLocale, getMessageForKeyByStyle, getStringFromMessageAndDefaults, i18n, i18nServer, parseJSONExtra, processRegex, promiseChainForValues, setDocument, setFetch, setJSONExtra, unescapeBackslashes };