@hortiview/default-components 1.4.4 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +51 -0
  2. package/dist/components/DefaultAllowedComponent/DefaultAllowedComponent.d.ts +11 -0
  3. package/dist/components/DefaultAllowedComponent/DefaultAllowedComponent.js +11 -0
  4. package/dist/components/DefaultFormNumber/DefaultFormNumber.js +12 -1496
  5. package/dist/components/DefaultFormSelect/DefaultFormSelect.js +9 -178
  6. package/dist/components/DefaultLoadingSpinner/DefaultLoadingSpinner.js +6 -6
  7. package/dist/components/GenericTable/GenericTable.js +12 -18731
  8. package/dist/components/HealthChecks/DataBaseHealthCheck.js +2 -2
  9. package/dist/components/HealthChecks/DefaultHealthCheck.js +4 -4
  10. package/dist/components/HealthChecks/IotServiceHealthCheck.js +5 -5
  11. package/dist/components/HealthChecks/PlatformHealthCheck.js +4 -4
  12. package/dist/components/ImpatienceLoadingSpinner/ImpatienceLoadingSpinner.js +9 -9
  13. package/dist/components/InternationalizationWrapper/InternationalizationWrapper.js +4 -4
  14. package/dist/components/OfflineView/OfflineView.js +9 -9
  15. package/dist/i18n.js +1696 -5
  16. package/dist/{i18nInstance-D_96ADqd.js → i18nInstance-CYqpK5II.js} +2 -2
  17. package/dist/locales/en-US.js +16 -14
  18. package/dist/locales/en-US.json.d.ts +3 -0
  19. package/dist/locales/es-MX.js +16 -14
  20. package/dist/locales/es-MX.json.d.ts +3 -0
  21. package/dist/locales/tr-TR.js +17 -15
  22. package/dist/locales/tr-TR.json.d.ts +3 -0
  23. package/dist/main.d.ts +1 -0
  24. package/dist/main.js +24 -22
  25. package/dist/useTranslation-DGtUf8nl.js +101 -0
  26. package/package.json +3 -32
  27. package/dist/Iconify-aUog1Oez.js +0 -83
  28. package/dist/InfoCard-BxjAQiFE.js +0 -58
  29. package/dist/LoadingSpinner-DBMjIfY1.js +0 -502
  30. package/dist/OfflineView-NUM9WE0F-BI9rnget.js +0 -46
  31. package/dist/assets/DefaultFormNumber.css +0 -1
  32. package/dist/assets/DefaultFormSelect.css +0 -1
  33. package/dist/assets/GenericTable.css +0 -1
  34. package/dist/assets/Iconify.css +0 -1
  35. package/dist/assets/InfoCard.css +0 -1
  36. package/dist/assets/LoadingSpinner.css +0 -1
  37. package/dist/assets/OfflineView-NUM9WE0F.css +0 -1
  38. package/dist/component-DsB0poTj-DgsYK0_R.js +0 -570
  39. package/dist/correct-is-regexp-logic-BBlm4UpN-CvII841s.js +0 -493
  40. package/dist/i18n-CCQpJsQK.js +0 -1707
  41. package/dist/index.es-B0QNuIUR-Bte5aF5M.js +0 -360
  42. package/dist/index.es-CIsLNz4j-ZEEcPmTs.js +0 -79
  43. package/dist/index.es-CvHDFF6V-CjZvA03R.js +0 -2004
  44. package/dist/index.es-DiONypF4-eT98Y3u_.js +0 -844
  45. package/dist/index.es-DnEIFMjv-DuuORGfo.js +0 -1044
  46. package/dist/index.es-NEYPxnlS-C8xQv2De.js +0 -860
  47. package/dist/index.es-fV9oWpEf-BXuhoGtE.js +0 -14374
  48. package/dist/isTypedArray-Dw_IY7Zq-wj3MphCb.js +0 -210
  49. package/dist/slicedToArray-h0Nnkd_P-C4SkVJMK.js +0 -432
  50. package/dist/useHelperText-B7OMZXvE.js +0 -391
  51. package/dist/useTranslation-B_lNCuLm.js +0 -5343
@@ -1,1707 +0,0 @@
1
- import ke from "./locales/en-US.js";
2
- import $e from "./locales/es-MX.js";
3
- import Re from "./locales/tr-TR.js";
4
- import { s as Pe, a as Ne } from "./i18nInstance-D_96ADqd.js";
5
- const Ee = [
6
- "en",
7
- "es",
8
- "tr"
9
- // 'de' currently not supported
10
- ], pt = {
11
- en: "en-US",
12
- es: "es-MX",
13
- tr: "tr-TR"
14
- }, Fe = {
15
- type: "3rdParty",
16
- init(r) {
17
- Pe(r.options.react), Ne(r);
18
- }
19
- }, c = (r) => typeof r == "string", H = () => {
20
- let r, e;
21
- const t = new Promise((n, s) => {
22
- r = n, e = s;
23
- });
24
- return t.resolve = r, t.reject = e, t;
25
- }, ie = (r) => r == null ? "" : "" + r, De = (r, e, t) => {
26
- r.forEach((n) => {
27
- e[n] && (t[n] = e[n]);
28
- });
29
- }, je = /###/g, re = (r) => r && r.indexOf("###") > -1 ? r.replace(je, ".") : r, ae = (r) => !r || c(r), z = (r, e, t) => {
30
- const n = c(e) ? e.split(".") : e;
31
- let s = 0;
32
- for (; s < n.length - 1; ) {
33
- if (ae(r)) return {};
34
- const i = re(n[s]);
35
- !r[i] && t && (r[i] = new t()), Object.prototype.hasOwnProperty.call(r, i) ? r = r[i] : r = {}, ++s;
36
- }
37
- return ae(r) ? {} : {
38
- obj: r,
39
- k: re(n[s])
40
- };
41
- }, oe = (r, e, t) => {
42
- const {
43
- obj: n,
44
- k: s
45
- } = z(r, e, Object);
46
- if (n !== void 0 || e.length === 1) {
47
- n[s] = t;
48
- return;
49
- }
50
- let i = e[e.length - 1], a = e.slice(0, e.length - 1), l = z(r, a, Object);
51
- for (; l.obj === void 0 && a.length; )
52
- i = `${a[a.length - 1]}.${i}`, a = a.slice(0, a.length - 1), l = z(r, a, Object), l != null && l.obj && typeof l.obj[`${l.k}.${i}`] < "u" && (l.obj = void 0);
53
- l.obj[`${l.k}.${i}`] = t;
54
- }, Ie = (r, e, t, n) => {
55
- const {
56
- obj: s,
57
- k: i
58
- } = z(r, e, Object);
59
- s[i] = s[i] || [], s[i].push(t);
60
- }, Q = (r, e) => {
61
- const {
62
- obj: t,
63
- k: n
64
- } = z(r, e);
65
- if (t && Object.prototype.hasOwnProperty.call(t, n))
66
- return t[n];
67
- }, Ae = (r, e, t) => {
68
- const n = Q(r, t);
69
- return n !== void 0 ? n : Q(e, t);
70
- }, we = (r, e, t) => {
71
- for (const n in e)
72
- n !== "__proto__" && n !== "constructor" && (n in r ? c(r[n]) || r[n] instanceof String || c(e[n]) || e[n] instanceof String ? t && (r[n] = e[n]) : we(r[n], e[n], t) : r[n] = e[n]);
73
- return r;
74
- }, j = (r) => r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
75
- var Te = {
76
- "&": "&amp;",
77
- "<": "&lt;",
78
- ">": "&gt;",
79
- '"': "&quot;",
80
- "'": "&#39;",
81
- "/": "&#x2F;"
82
- };
83
- const Ve = (r) => c(r) ? r.replace(/[&<>"'\/]/g, (e) => Te[e]) : r;
84
- class Ue {
85
- constructor(e) {
86
- this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
87
- }
88
- getRegExp(e) {
89
- const t = this.regExpMap.get(e);
90
- if (t !== void 0)
91
- return t;
92
- const n = new RegExp(e);
93
- return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
94
- }
95
- }
96
- const Ke = [" ", ",", "?", "!", ";"], Me = new Ue(20), He = (r, e, t) => {
97
- e = e || "", t = t || "";
98
- const n = Ke.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
99
- if (n.length === 0) return !0;
100
- const s = Me.getRegExp(`(${n.map((a) => a === "?" ? "\\?" : a).join("|")})`);
101
- let i = !s.test(r);
102
- if (!i) {
103
- const a = r.indexOf(t);
104
- a > 0 && !s.test(r.substring(0, a)) && (i = !0);
105
- }
106
- return i;
107
- }, _ = function(r, e) {
108
- let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
109
- if (!r) return;
110
- if (r[e])
111
- return Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
112
- const n = e.split(t);
113
- let s = r;
114
- for (let i = 0; i < n.length; ) {
115
- if (!s || typeof s != "object")
116
- return;
117
- let a, l = "";
118
- for (let o = i; o < n.length; ++o)
119
- if (o !== i && (l += t), l += n[o], a = s[l], a !== void 0) {
120
- if (["string", "number", "boolean"].indexOf(typeof a) > -1 && o < n.length - 1)
121
- continue;
122
- i += o - i + 1;
123
- break;
124
- }
125
- s = a;
126
- }
127
- return s;
128
- }, Y = (r) => r == null ? void 0 : r.replace("_", "-"), ze = {
129
- type: "logger",
130
- log(r) {
131
- this.output("log", r);
132
- },
133
- warn(r) {
134
- this.output("warn", r);
135
- },
136
- error(r) {
137
- this.output("error", r);
138
- },
139
- output(r, e) {
140
- var t, n;
141
- (n = (t = console == null ? void 0 : console[r]) == null ? void 0 : t.apply) == null || n.call(t, console, e);
142
- }
143
- };
144
- class q {
145
- constructor(e) {
146
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
147
- this.init(e, t);
148
- }
149
- init(e) {
150
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
151
- this.prefix = t.prefix || "i18next:", this.logger = e || ze, this.options = t, this.debug = t.debug;
152
- }
153
- log() {
154
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
155
- t[n] = arguments[n];
156
- return this.forward(t, "log", "", !0);
157
- }
158
- warn() {
159
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
160
- t[n] = arguments[n];
161
- return this.forward(t, "warn", "", !0);
162
- }
163
- error() {
164
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
165
- t[n] = arguments[n];
166
- return this.forward(t, "error", "");
167
- }
168
- deprecate() {
169
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
170
- t[n] = arguments[n];
171
- return this.forward(t, "warn", "WARNING DEPRECATED: ", !0);
172
- }
173
- forward(e, t, n, s) {
174
- return s && !this.debug ? null : (c(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
175
- }
176
- create(e) {
177
- return new q(this.logger, {
178
- prefix: `${this.prefix}:${e}:`,
179
- ...this.options
180
- });
181
- }
182
- clone(e) {
183
- return e = e || this.options, e.prefix = e.prefix || this.prefix, new q(this.logger, e);
184
- }
185
- }
186
- var P = new q();
187
- class Z {
188
- constructor() {
189
- this.observers = {};
190
- }
191
- on(e, t) {
192
- return e.split(" ").forEach((n) => {
193
- this.observers[n] || (this.observers[n] = /* @__PURE__ */ new Map());
194
- const s = this.observers[n].get(t) || 0;
195
- this.observers[n].set(t, s + 1);
196
- }), this;
197
- }
198
- off(e, t) {
199
- if (this.observers[e]) {
200
- if (!t) {
201
- delete this.observers[e];
202
- return;
203
- }
204
- this.observers[e].delete(t);
205
- }
206
- }
207
- emit(e) {
208
- for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++)
209
- n[s - 1] = arguments[s];
210
- this.observers[e] && Array.from(this.observers[e].entries()).forEach((a) => {
211
- let [l, o] = a;
212
- for (let u = 0; u < o; u++)
213
- l(...n);
214
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach((a) => {
215
- let [l, o] = a;
216
- for (let u = 0; u < o; u++)
217
- l.apply(l, [e, ...n]);
218
- });
219
- }
220
- }
221
- class le extends Z {
222
- constructor(e) {
223
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
224
- ns: ["translation"],
225
- defaultNS: "translation"
226
- };
227
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
228
- }
229
- addNamespaces(e) {
230
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
231
- }
232
- removeNamespaces(e) {
233
- const t = this.options.ns.indexOf(e);
234
- t > -1 && this.options.ns.splice(t, 1);
235
- }
236
- getResource(e, t, n) {
237
- var u, d;
238
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
239
- const i = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, a = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
240
- let l;
241
- e.indexOf(".") > -1 ? l = e.split(".") : (l = [e, t], n && (Array.isArray(n) ? l.push(...n) : c(n) && i ? l.push(...n.split(i)) : l.push(n)));
242
- const o = Q(this.data, l);
243
- return !o && !t && !n && e.indexOf(".") > -1 && (e = l[0], t = l[1], n = l.slice(2).join(".")), o || !a || !c(n) ? o : _((d = (u = this.data) == null ? void 0 : u[e]) == null ? void 0 : d[t], n, i);
244
- }
245
- addResource(e, t, n, s) {
246
- let i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
247
- silent: !1
248
- };
249
- const a = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator;
250
- let l = [e, t];
251
- n && (l = l.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (l = e.split("."), s = t, t = l[1]), this.addNamespaces(t), oe(this.data, l, s), i.silent || this.emit("added", e, t, n, s);
252
- }
253
- addResources(e, t, n) {
254
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
255
- silent: !1
256
- };
257
- for (const i in n)
258
- (c(n[i]) || Array.isArray(n[i])) && this.addResource(e, t, i, n[i], {
259
- silent: !0
260
- });
261
- s.silent || this.emit("added", e, t, n);
262
- }
263
- addResourceBundle(e, t, n, s, i) {
264
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
265
- silent: !1,
266
- skipCopy: !1
267
- }, l = [e, t];
268
- e.indexOf(".") > -1 && (l = e.split("."), s = n, n = t, t = l[1]), this.addNamespaces(t);
269
- let o = Q(this.data, l) || {};
270
- a.skipCopy || (n = JSON.parse(JSON.stringify(n))), s ? we(o, n, i) : o = {
271
- ...o,
272
- ...n
273
- }, oe(this.data, l, o), a.silent || this.emit("added", e, t, n);
274
- }
275
- removeResourceBundle(e, t) {
276
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
277
- }
278
- hasResourceBundle(e, t) {
279
- return this.getResource(e, t) !== void 0;
280
- }
281
- getResourceBundle(e, t) {
282
- return t || (t = this.options.defaultNS), this.getResource(e, t);
283
- }
284
- getDataByLanguage(e) {
285
- return this.data[e];
286
- }
287
- hasLanguageSomeTranslations(e) {
288
- const t = this.getDataByLanguage(e);
289
- return !!(t && Object.keys(t) || []).find((s) => t[s] && Object.keys(t[s]).length > 0);
290
- }
291
- toJSON() {
292
- return this.data;
293
- }
294
- }
295
- var Oe = {
296
- processors: {},
297
- addPostProcessor(r) {
298
- this.processors[r.name] = r;
299
- },
300
- handle(r, e, t, n, s) {
301
- return r.forEach((i) => {
302
- var a;
303
- e = ((a = this.processors[i]) == null ? void 0 : a.process(e, t, n, s)) ?? e;
304
- }), e;
305
- }
306
- };
307
- const ue = {}, fe = (r) => !c(r) && typeof r != "boolean" && typeof r != "number";
308
- class G extends Z {
309
- constructor(e) {
310
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
311
- super(), De(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = P.create("translator");
312
- }
313
- changeLanguage(e) {
314
- e && (this.language = e);
315
- }
316
- exists(e) {
317
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
318
- interpolation: {}
319
- };
320
- if (e == null)
321
- return !1;
322
- const n = this.resolve(e, t);
323
- return (n == null ? void 0 : n.res) !== void 0;
324
- }
325
- extractFromKey(e, t) {
326
- let n = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
327
- n === void 0 && (n = ":");
328
- const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
329
- let i = t.ns || this.options.defaultNS || [];
330
- const a = n && e.indexOf(n) > -1, l = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !He(e, n, s);
331
- if (a && !l) {
332
- const o = e.match(this.interpolator.nestingRegexp);
333
- if (o && o.length > 0)
334
- return {
335
- key: e,
336
- namespaces: c(i) ? [i] : i
337
- };
338
- const u = e.split(n);
339
- (n !== s || n === s && this.options.ns.indexOf(u[0]) > -1) && (i = u.shift()), e = u.join(s);
340
- }
341
- return {
342
- key: e,
343
- namespaces: c(i) ? [i] : i
344
- };
345
- }
346
- translate(e, t, n) {
347
- if (typeof t != "object" && this.options.overloadTranslationOptionHandler && (t = this.options.overloadTranslationOptionHandler(arguments)), typeof t == "object" && (t = {
348
- ...t
349
- }), t || (t = {}), e == null) return "";
350
- Array.isArray(e) || (e = [String(e)]);
351
- const s = t.returnDetails !== void 0 ? t.returnDetails : this.options.returnDetails, i = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator, {
352
- key: a,
353
- namespaces: l
354
- } = this.extractFromKey(e[e.length - 1], t), o = l[l.length - 1], u = t.lng || this.language, d = t.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
355
- if ((u == null ? void 0 : u.toLowerCase()) === "cimode") {
356
- if (d) {
357
- const L = t.nsSeparator || this.options.nsSeparator;
358
- return s ? {
359
- res: `${o}${L}${a}`,
360
- usedKey: a,
361
- exactUsedKey: a,
362
- usedLng: u,
363
- usedNS: o,
364
- usedParams: this.getUsedParamsDetails(t)
365
- } : `${o}${L}${a}`;
366
- }
367
- return s ? {
368
- res: a,
369
- usedKey: a,
370
- exactUsedKey: a,
371
- usedLng: u,
372
- usedNS: o,
373
- usedParams: this.getUsedParamsDetails(t)
374
- } : a;
375
- }
376
- const h = this.resolve(e, t);
377
- let f = h == null ? void 0 : h.res;
378
- const m = (h == null ? void 0 : h.usedKey) || a, g = (h == null ? void 0 : h.exactUsedKey) || a, p = ["[object Number]", "[object Function]", "[object RegExp]"], x = t.joinArrays !== void 0 ? t.joinArrays : this.options.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, w = t.count !== void 0 && !c(t.count), $ = G.hasDefaultValue(t), C = w ? this.pluralResolver.getSuffix(u, t.count, t) : "", V = t.ordinal && w ? this.pluralResolver.getSuffix(u, t.count, {
379
- ordinal: !1
380
- }) : "", U = w && !t.ordinal && t.count === 0, y = U && t[`defaultValue${this.options.pluralSeparator}zero`] || t[`defaultValue${C}`] || t[`defaultValue${V}`] || t.defaultValue;
381
- let O = f;
382
- b && !f && $ && (O = y);
383
- const F = fe(O), D = Object.prototype.toString.apply(O);
384
- if (b && O && F && p.indexOf(D) < 0 && !(c(x) && Array.isArray(O))) {
385
- if (!t.returnObjects && !this.options.returnObjects) {
386
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
387
- const L = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, O, {
388
- ...t,
389
- ns: l
390
- }) : `key '${a} (${this.language})' returned an object instead of string.`;
391
- return s ? (h.res = L, h.usedParams = this.getUsedParamsDetails(t), h) : L;
392
- }
393
- if (i) {
394
- const L = Array.isArray(O), k = L ? [] : {}, ee = L ? g : m;
395
- for (const R in O)
396
- if (Object.prototype.hasOwnProperty.call(O, R)) {
397
- const N = `${ee}${i}${R}`;
398
- $ && !f ? k[R] = this.translate(N, {
399
- ...t,
400
- defaultValue: fe(y) ? y[R] : void 0,
401
- joinArrays: !1,
402
- ns: l
403
- }) : k[R] = this.translate(N, {
404
- ...t,
405
- joinArrays: !1,
406
- ns: l
407
- }), k[R] === N && (k[R] = O[R]);
408
- }
409
- f = k;
410
- }
411
- } else if (b && c(x) && Array.isArray(f))
412
- f = f.join(x), f && (f = this.extendTranslation(f, e, t, n));
413
- else {
414
- let L = !1, k = !1;
415
- !this.isValidLookup(f) && $ && (L = !0, f = y), this.isValidLookup(f) || (k = !0, f = a);
416
- const R = (t.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && k ? void 0 : f, N = $ && y !== f && this.options.updateMissing;
417
- if (k || L || N) {
418
- if (this.logger.log(N ? "updateKey" : "missingKey", u, o, a, N ? y : f), i) {
419
- const v = this.resolve(a, {
420
- ...t,
421
- keySeparator: !1
422
- });
423
- v && v.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
424
- }
425
- let K = [];
426
- const J = this.languageUtils.getFallbackCodes(this.options.fallbackLng, t.lng || this.language);
427
- if (this.options.saveMissingTo === "fallback" && J && J[0])
428
- for (let v = 0; v < J.length; v++)
429
- K.push(J[v]);
430
- else this.options.saveMissingTo === "all" ? K = this.languageUtils.toResolveHierarchy(t.lng || this.language) : K.push(t.lng || this.language);
431
- const te = (v, E, M) => {
432
- var se;
433
- const ne = $ && M !== f ? M : R;
434
- this.options.missingKeyHandler ? this.options.missingKeyHandler(v, o, E, ne, N, t) : (se = this.backendConnector) != null && se.saveMissing && this.backendConnector.saveMissing(v, o, E, ne, N, t), this.emit("missingKey", v, o, E, f);
435
- };
436
- this.options.saveMissing && (this.options.saveMissingPlurals && w ? K.forEach((v) => {
437
- const E = this.pluralResolver.getSuffixes(v, t);
438
- U && t[`defaultValue${this.options.pluralSeparator}zero`] && E.indexOf(`${this.options.pluralSeparator}zero`) < 0 && E.push(`${this.options.pluralSeparator}zero`), E.forEach((M) => {
439
- te([v], a + M, t[`defaultValue${M}`] || y);
440
- });
441
- }) : te(K, a, y));
442
- }
443
- f = this.extendTranslation(f, e, t, h, n), k && f === a && this.options.appendNamespaceToMissingKey && (f = `${o}:${a}`), (k || L) && this.options.parseMissingKeyHandler && (f = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${o}:${a}` : a, L ? f : void 0));
444
- }
445
- return s ? (h.res = f, h.usedParams = this.getUsedParamsDetails(t), h) : f;
446
- }
447
- extendTranslation(e, t, n, s, i) {
448
- var u, d;
449
- var a = this;
450
- if ((u = this.i18nFormat) != null && u.parse)
451
- e = this.i18nFormat.parse(e, {
452
- ...this.options.interpolation.defaultVariables,
453
- ...n
454
- }, n.lng || this.language || s.usedLng, s.usedNS, s.usedKey, {
455
- resolved: s
456
- });
457
- else if (!n.skipInterpolation) {
458
- n.interpolation && this.interpolator.init({
459
- ...n,
460
- interpolation: {
461
- ...this.options.interpolation,
462
- ...n.interpolation
463
- }
464
- });
465
- const h = c(e) && (((d = n == null ? void 0 : n.interpolation) == null ? void 0 : d.skipOnVariables) !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
466
- let f;
467
- if (h) {
468
- const g = e.match(this.interpolator.nestingRegexp);
469
- f = g && g.length;
470
- }
471
- let m = n.replace && !c(n.replace) ? n.replace : n;
472
- if (this.options.interpolation.defaultVariables && (m = {
473
- ...this.options.interpolation.defaultVariables,
474
- ...m
475
- }), e = this.interpolator.interpolate(e, m, n.lng || this.language || s.usedLng, n), h) {
476
- const g = e.match(this.interpolator.nestingRegexp), p = g && g.length;
477
- f < p && (n.nest = !1);
478
- }
479
- !n.lng && s && s.res && (n.lng = this.language || s.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, function() {
480
- for (var g = arguments.length, p = new Array(g), x = 0; x < g; x++)
481
- p[x] = arguments[x];
482
- return (i == null ? void 0 : i[0]) === p[0] && !n.context ? (a.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`), null) : a.translate(...p, t);
483
- }, n)), n.interpolation && this.interpolator.reset();
484
- }
485
- const l = n.postProcess || this.options.postProcess, o = c(l) ? [l] : l;
486
- return e != null && (o != null && o.length) && n.applyPostProcessor !== !1 && (e = Oe.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
487
- i18nResolved: {
488
- ...s,
489
- usedParams: this.getUsedParamsDetails(n)
490
- },
491
- ...n
492
- } : n, this)), e;
493
- }
494
- resolve(e) {
495
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, s, i, a, l;
496
- return c(e) && (e = [e]), e.forEach((o) => {
497
- if (this.isValidLookup(n)) return;
498
- const u = this.extractFromKey(o, t), d = u.key;
499
- s = d;
500
- let h = u.namespaces;
501
- this.options.fallbackNS && (h = h.concat(this.options.fallbackNS));
502
- const f = t.count !== void 0 && !c(t.count), m = f && !t.ordinal && t.count === 0, g = t.context !== void 0 && (c(t.context) || typeof t.context == "number") && t.context !== "", p = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
503
- h.forEach((x) => {
504
- var b, w;
505
- this.isValidLookup(n) || (l = x, !ue[`${p[0]}-${x}`] && ((b = this.utils) != null && b.hasLoadedNamespace) && !((w = this.utils) != null && w.hasLoadedNamespace(l)) && (ue[`${p[0]}-${x}`] = !0, this.logger.warn(`key "${s}" for languages "${p.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), p.forEach(($) => {
506
- var U;
507
- if (this.isValidLookup(n)) return;
508
- a = $;
509
- const C = [d];
510
- if ((U = this.i18nFormat) != null && U.addLookupKeys)
511
- this.i18nFormat.addLookupKeys(C, d, $, x, t);
512
- else {
513
- let y;
514
- f && (y = this.pluralResolver.getSuffix($, t.count, t));
515
- const O = `${this.options.pluralSeparator}zero`, F = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
516
- if (f && (C.push(d + y), t.ordinal && y.indexOf(F) === 0 && C.push(d + y.replace(F, this.options.pluralSeparator)), m && C.push(d + O)), g) {
517
- const D = `${d}${this.options.contextSeparator}${t.context}`;
518
- C.push(D), f && (C.push(D + y), t.ordinal && y.indexOf(F) === 0 && C.push(D + y.replace(F, this.options.pluralSeparator)), m && C.push(D + O));
519
- }
520
- }
521
- let V;
522
- for (; V = C.pop(); )
523
- this.isValidLookup(n) || (i = V, n = this.getResource($, x, V, t));
524
- }));
525
- });
526
- }), {
527
- res: n,
528
- usedKey: s,
529
- exactUsedKey: i,
530
- usedLng: a,
531
- usedNS: l
532
- };
533
- }
534
- isValidLookup(e) {
535
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
536
- }
537
- getResource(e, t, n) {
538
- var i;
539
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
540
- return (i = this.i18nFormat) != null && i.getResource ? this.i18nFormat.getResource(e, t, n, s) : this.resourceStore.getResource(e, t, n, s);
541
- }
542
- getUsedParamsDetails() {
543
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
544
- const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = e.replace && !c(e.replace);
545
- let s = n ? e.replace : e;
546
- if (n && typeof e.count < "u" && (s.count = e.count), this.options.interpolation.defaultVariables && (s = {
547
- ...this.options.interpolation.defaultVariables,
548
- ...s
549
- }), !n) {
550
- s = {
551
- ...s
552
- };
553
- for (const i of t)
554
- delete s[i];
555
- }
556
- return s;
557
- }
558
- static hasDefaultValue(e) {
559
- const t = "defaultValue";
560
- for (const n in e)
561
- if (Object.prototype.hasOwnProperty.call(e, n) && t === n.substring(0, t.length) && e[n] !== void 0)
562
- return !0;
563
- return !1;
564
- }
565
- }
566
- class de {
567
- constructor(e) {
568
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = P.create("languageUtils");
569
- }
570
- getScriptPartFromCode(e) {
571
- if (e = Y(e), !e || e.indexOf("-") < 0) return null;
572
- const t = e.split("-");
573
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
574
- }
575
- getLanguagePartFromCode(e) {
576
- if (e = Y(e), !e || e.indexOf("-") < 0) return e;
577
- const t = e.split("-");
578
- return this.formatLanguageCode(t[0]);
579
- }
580
- formatLanguageCode(e) {
581
- if (c(e) && e.indexOf("-") > -1) {
582
- let t;
583
- try {
584
- t = Intl.getCanonicalLocales(e)[0];
585
- } catch {
586
- }
587
- return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
588
- }
589
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
590
- }
591
- isSupportedCode(e) {
592
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
593
- }
594
- getBestMatchFromCodes(e) {
595
- if (!e) return null;
596
- let t;
597
- return e.forEach((n) => {
598
- if (t) return;
599
- const s = this.formatLanguageCode(n);
600
- (!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
601
- }), !t && this.options.supportedLngs && e.forEach((n) => {
602
- if (t) return;
603
- const s = this.getLanguagePartFromCode(n);
604
- if (this.isSupportedCode(s)) return t = s;
605
- t = this.options.supportedLngs.find((i) => {
606
- if (i === s) return i;
607
- if (!(i.indexOf("-") < 0 && s.indexOf("-") < 0) && (i.indexOf("-") > 0 && s.indexOf("-") < 0 && i.substring(0, i.indexOf("-")) === s || i.indexOf(s) === 0 && s.length > 1))
608
- return i;
609
- });
610
- }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
611
- }
612
- getFallbackCodes(e, t) {
613
- if (!e) return [];
614
- if (typeof e == "function" && (e = e(t)), c(e) && (e = [e]), Array.isArray(e)) return e;
615
- if (!t) return e.default || [];
616
- let n = e[t];
617
- return n || (n = e[this.getScriptPartFromCode(t)]), n || (n = e[this.formatLanguageCode(t)]), n || (n = e[this.getLanguagePartFromCode(t)]), n || (n = e.default), n || [];
618
- }
619
- toResolveHierarchy(e, t) {
620
- const n = this.getFallbackCodes(t || this.options.fallbackLng || [], e), s = [], i = (a) => {
621
- a && (this.isSupportedCode(a) ? s.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
622
- };
623
- return c(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : c(e) && i(this.formatLanguageCode(e)), n.forEach((a) => {
624
- s.indexOf(a) < 0 && i(this.formatLanguageCode(a));
625
- }), s;
626
- }
627
- }
628
- const he = {
629
- zero: 0,
630
- one: 1,
631
- two: 2,
632
- few: 3,
633
- many: 4,
634
- other: 5
635
- }, ge = {
636
- select: (r) => r === 1 ? "one" : "other",
637
- resolvedOptions: () => ({
638
- pluralCategories: ["one", "other"]
639
- })
640
- };
641
- class Be {
642
- constructor(e) {
643
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
644
- this.languageUtils = e, this.options = t, this.logger = P.create("pluralResolver"), this.pluralRulesCache = {};
645
- }
646
- addRule(e, t) {
647
- this.rules[e] = t;
648
- }
649
- clearCache() {
650
- this.pluralRulesCache = {};
651
- }
652
- getRule(e) {
653
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
654
- const n = Y(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
655
- cleanedCode: n,
656
- type: s
657
- });
658
- if (i in this.pluralRulesCache)
659
- return this.pluralRulesCache[i];
660
- let a;
661
- try {
662
- a = new Intl.PluralRules(n, {
663
- type: s
664
- });
665
- } catch {
666
- if (!Intl)
667
- return this.logger.error("No Intl support, please use an Intl polyfill!"), ge;
668
- if (!e.match(/-|_/)) return ge;
669
- const o = this.languageUtils.getLanguagePartFromCode(e);
670
- a = this.getRule(o, t);
671
- }
672
- return this.pluralRulesCache[i] = a, a;
673
- }
674
- needsPlural(e) {
675
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, t);
676
- return n || (n = this.getRule("dev", t)), (n == null ? void 0 : n.resolvedOptions().pluralCategories.length) > 1;
677
- }
678
- getPluralFormsOfKey(e, t) {
679
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
680
- return this.getSuffixes(e, n).map((s) => `${t}${s}`);
681
- }
682
- getSuffixes(e) {
683
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = this.getRule(e, t);
684
- return n || (n = this.getRule("dev", t)), n ? n.resolvedOptions().pluralCategories.sort((s, i) => he[s] - he[i]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : [];
685
- }
686
- getSuffix(e, t) {
687
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
688
- const s = this.getRule(e, n);
689
- return s ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
690
- }
691
- }
692
- const ce = function(r, e, t) {
693
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = Ae(r, e, t);
694
- return !i && s && c(t) && (i = _(r, t, n), i === void 0 && (i = _(e, t, n))), i;
695
- }, X = (r) => r.replace(/\$/g, "$$$$");
696
- class Je {
697
- constructor() {
698
- var t;
699
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
700
- this.logger = P.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((n) => n), this.init(e);
701
- }
702
- init() {
703
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
704
- e.interpolation || (e.interpolation = {
705
- escapeValue: !0
706
- });
707
- const {
708
- escape: t,
709
- escapeValue: n,
710
- useRawValueToEscape: s,
711
- prefix: i,
712
- prefixEscaped: a,
713
- suffix: l,
714
- suffixEscaped: o,
715
- formatSeparator: u,
716
- unescapeSuffix: d,
717
- unescapePrefix: h,
718
- nestingPrefix: f,
719
- nestingPrefixEscaped: m,
720
- nestingSuffix: g,
721
- nestingSuffixEscaped: p,
722
- nestingOptionsSeparator: x,
723
- maxReplaces: b,
724
- alwaysFormat: w
725
- } = e.interpolation;
726
- this.escape = t !== void 0 ? t : Ve, this.escapeValue = n !== void 0 ? n : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = i ? j(i) : a || "{{", this.suffix = l ? j(l) : o || "}}", this.formatSeparator = u || ",", this.unescapePrefix = d ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : d || "", this.nestingPrefix = f ? j(f) : m || j("$t("), this.nestingSuffix = g ? j(g) : p || j(")"), this.nestingOptionsSeparator = x || ",", this.maxReplaces = b || 1e3, this.alwaysFormat = w !== void 0 ? w : !1, this.resetRegExp();
727
- }
728
- reset() {
729
- this.options && this.init(this.options);
730
- }
731
- resetRegExp() {
732
- const e = (t, n) => (t == null ? void 0 : t.source) === n ? (t.lastIndex = 0, t) : new RegExp(n, "g");
733
- this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
734
- }
735
- interpolate(e, t, n, s) {
736
- var m;
737
- let i, a, l;
738
- const o = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (g) => {
739
- if (g.indexOf(this.formatSeparator) < 0) {
740
- const w = ce(t, o, g, this.options.keySeparator, this.options.ignoreJSONStructure);
741
- return this.alwaysFormat ? this.format(w, void 0, n, {
742
- ...s,
743
- ...t,
744
- interpolationkey: g
745
- }) : w;
746
- }
747
- const p = g.split(this.formatSeparator), x = p.shift().trim(), b = p.join(this.formatSeparator).trim();
748
- return this.format(ce(t, o, x, this.options.keySeparator, this.options.ignoreJSONStructure), b, n, {
749
- ...s,
750
- ...t,
751
- interpolationkey: x
752
- });
753
- };
754
- this.resetRegExp();
755
- const d = (s == null ? void 0 : s.missingInterpolationHandler) || this.options.missingInterpolationHandler, h = ((m = s == null ? void 0 : s.interpolation) == null ? void 0 : m.skipOnVariables) !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
756
- return [{
757
- regex: this.regexpUnescape,
758
- safeValue: (g) => X(g)
759
- }, {
760
- regex: this.regexp,
761
- safeValue: (g) => this.escapeValue ? X(this.escape(g)) : X(g)
762
- }].forEach((g) => {
763
- for (l = 0; i = g.regex.exec(e); ) {
764
- const p = i[1].trim();
765
- if (a = u(p), a === void 0)
766
- if (typeof d == "function") {
767
- const b = d(e, i, s);
768
- a = c(b) ? b : "";
769
- } else if (s && Object.prototype.hasOwnProperty.call(s, p))
770
- a = "";
771
- else if (h) {
772
- a = i[0];
773
- continue;
774
- } else
775
- this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`), a = "";
776
- else !c(a) && !this.useRawValueToEscape && (a = ie(a));
777
- const x = g.safeValue(a);
778
- if (e = e.replace(i[0], x), h ? (g.regex.lastIndex += a.length, g.regex.lastIndex -= i[0].length) : g.regex.lastIndex = 0, l++, l >= this.maxReplaces)
779
- break;
780
- }
781
- }), e;
782
- }
783
- nest(e, t) {
784
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s, i, a;
785
- const l = (o, u) => {
786
- const d = this.nestingOptionsSeparator;
787
- if (o.indexOf(d) < 0) return o;
788
- const h = o.split(new RegExp(`${d}[ ]*{`));
789
- let f = `{${h[1]}`;
790
- o = h[0], f = this.interpolate(f, a);
791
- const m = f.match(/'/g), g = f.match(/"/g);
792
- (((m == null ? void 0 : m.length) ?? 0) % 2 === 0 && !g || g.length % 2 !== 0) && (f = f.replace(/'/g, '"'));
793
- try {
794
- a = JSON.parse(f), u && (a = {
795
- ...u,
796
- ...a
797
- });
798
- } catch (p) {
799
- return this.logger.warn(`failed parsing options string in nesting for key ${o}`, p), `${o}${d}${f}`;
800
- }
801
- return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, o;
802
- };
803
- for (; s = this.nestingRegexp.exec(e); ) {
804
- let o = [];
805
- a = {
806
- ...n
807
- }, a = a.replace && !c(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
808
- let u = !1;
809
- if (s[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(s[1])) {
810
- const d = s[1].split(this.formatSeparator).map((h) => h.trim());
811
- s[1] = d.shift(), o = d, u = !0;
812
- }
813
- if (i = t(l.call(this, s[1].trim(), a), a), i && s[0] === e && !c(i)) return i;
814
- c(i) || (i = ie(i)), i || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), i = ""), u && (i = o.reduce((d, h) => this.format(d, h, n.lng, {
815
- ...n,
816
- interpolationkey: s[1].trim()
817
- }), i.trim())), e = e.replace(s[0], i), this.regexp.lastIndex = 0;
818
- }
819
- return e;
820
- }
821
- }
822
- const We = (r) => {
823
- let e = r.toLowerCase().trim();
824
- const t = {};
825
- if (r.indexOf("(") > -1) {
826
- const n = r.split("(");
827
- e = n[0].toLowerCase().trim();
828
- const s = n[1].substring(0, n[1].length - 1);
829
- e === "currency" && s.indexOf(":") < 0 ? t.currency || (t.currency = s.trim()) : e === "relativetime" && s.indexOf(":") < 0 ? t.range || (t.range = s.trim()) : s.split(";").forEach((a) => {
830
- if (a) {
831
- const [l, ...o] = a.split(":"), u = o.join(":").trim().replace(/^'+|'+$/g, ""), d = l.trim();
832
- t[d] || (t[d] = u), u === "false" && (t[d] = !1), u === "true" && (t[d] = !0), isNaN(u) || (t[d] = parseInt(u, 10));
833
- }
834
- });
835
- }
836
- return {
837
- formatName: e,
838
- formatOptions: t
839
- };
840
- }, I = (r) => {
841
- const e = {};
842
- return (t, n, s) => {
843
- let i = s;
844
- s && s.interpolationkey && s.formatParams && s.formatParams[s.interpolationkey] && s[s.interpolationkey] && (i = {
845
- ...i,
846
- [s.interpolationkey]: void 0
847
- });
848
- const a = n + JSON.stringify(i);
849
- let l = e[a];
850
- return l || (l = r(Y(n), s), e[a] = l), l(t);
851
- };
852
- };
853
- class Qe {
854
- constructor() {
855
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
856
- this.logger = P.create("formatter"), this.options = e, this.formats = {
857
- number: I((t, n) => {
858
- const s = new Intl.NumberFormat(t, {
859
- ...n
860
- });
861
- return (i) => s.format(i);
862
- }),
863
- currency: I((t, n) => {
864
- const s = new Intl.NumberFormat(t, {
865
- ...n,
866
- style: "currency"
867
- });
868
- return (i) => s.format(i);
869
- }),
870
- datetime: I((t, n) => {
871
- const s = new Intl.DateTimeFormat(t, {
872
- ...n
873
- });
874
- return (i) => s.format(i);
875
- }),
876
- relativetime: I((t, n) => {
877
- const s = new Intl.RelativeTimeFormat(t, {
878
- ...n
879
- });
880
- return (i) => s.format(i, n.range || "day");
881
- }),
882
- list: I((t, n) => {
883
- const s = new Intl.ListFormat(t, {
884
- ...n
885
- });
886
- return (i) => s.format(i);
887
- })
888
- }, this.init(e);
889
- }
890
- init(e) {
891
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
892
- interpolation: {}
893
- };
894
- this.formatSeparator = t.interpolation.formatSeparator || ",";
895
- }
896
- add(e, t) {
897
- this.formats[e.toLowerCase().trim()] = t;
898
- }
899
- addCached(e, t) {
900
- this.formats[e.toLowerCase().trim()] = I(t);
901
- }
902
- format(e, t, n) {
903
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
904
- const i = t.split(this.formatSeparator);
905
- if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((l) => l.indexOf(")") > -1)) {
906
- const l = i.findIndex((o) => o.indexOf(")") > -1);
907
- i[0] = [i[0], ...i.splice(1, l)].join(this.formatSeparator);
908
- }
909
- return i.reduce((l, o) => {
910
- var h;
911
- const {
912
- formatName: u,
913
- formatOptions: d
914
- } = We(o);
915
- if (this.formats[u]) {
916
- let f = l;
917
- try {
918
- const m = ((h = s == null ? void 0 : s.formatParams) == null ? void 0 : h[s.interpolationkey]) || {}, g = m.locale || m.lng || s.locale || s.lng || n;
919
- f = this.formats[u](l, g, {
920
- ...d,
921
- ...s,
922
- ...m
923
- });
924
- } catch (m) {
925
- this.logger.warn(m);
926
- }
927
- return f;
928
- } else
929
- this.logger.warn(`there was no format function for ${u}`);
930
- return l;
931
- }, e);
932
- }
933
- }
934
- const Ye = (r, e) => {
935
- r.pending[e] !== void 0 && (delete r.pending[e], r.pendingCount--);
936
- };
937
- class qe extends Z {
938
- constructor(e, t, n) {
939
- var i, a;
940
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
941
- super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = s, this.logger = P.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = s.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = s.maxRetries >= 0 ? s.maxRetries : 5, this.retryTimeout = s.retryTimeout >= 1 ? s.retryTimeout : 350, this.state = {}, this.queue = [], (a = (i = this.backend) == null ? void 0 : i.init) == null || a.call(i, n, s.backend, s);
942
- }
943
- queueLoad(e, t, n, s) {
944
- const i = {}, a = {}, l = {}, o = {};
945
- return e.forEach((u) => {
946
- let d = !0;
947
- t.forEach((h) => {
948
- const f = `${u}|${h}`;
949
- !n.reload && this.store.hasResourceBundle(u, h) ? this.state[f] = 2 : this.state[f] < 0 || (this.state[f] === 1 ? a[f] === void 0 && (a[f] = !0) : (this.state[f] = 1, d = !1, a[f] === void 0 && (a[f] = !0), i[f] === void 0 && (i[f] = !0), o[h] === void 0 && (o[h] = !0)));
950
- }), d || (l[u] = !0);
951
- }), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
952
- pending: a,
953
- pendingCount: Object.keys(a).length,
954
- loaded: {},
955
- errors: [],
956
- callback: s
957
- }), {
958
- toLoad: Object.keys(i),
959
- pending: Object.keys(a),
960
- toLoadLanguages: Object.keys(l),
961
- toLoadNamespaces: Object.keys(o)
962
- };
963
- }
964
- loaded(e, t, n) {
965
- const s = e.split("|"), i = s[0], a = s[1];
966
- t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, {
967
- skipCopy: !0
968
- }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
969
- const l = {};
970
- this.queue.forEach((o) => {
971
- Ie(o.loaded, [i], a), Ye(o, e), t && o.errors.push(t), o.pendingCount === 0 && !o.done && (Object.keys(o.loaded).forEach((u) => {
972
- l[u] || (l[u] = {});
973
- const d = o.loaded[u];
974
- d.length && d.forEach((h) => {
975
- l[u][h] === void 0 && (l[u][h] = !0);
976
- });
977
- }), o.done = !0, o.errors.length ? o.callback(o.errors) : o.callback());
978
- }), this.emit("loaded", l), this.queue = this.queue.filter((o) => !o.done);
979
- }
980
- read(e, t, n) {
981
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, a = arguments.length > 5 ? arguments[5] : void 0;
982
- if (!e.length) return a(null, {});
983
- if (this.readingCalls >= this.maxParallelReads) {
984
- this.waitingReads.push({
985
- lng: e,
986
- ns: t,
987
- fcName: n,
988
- tried: s,
989
- wait: i,
990
- callback: a
991
- });
992
- return;
993
- }
994
- this.readingCalls++;
995
- const l = (u, d) => {
996
- if (this.readingCalls--, this.waitingReads.length > 0) {
997
- const h = this.waitingReads.shift();
998
- this.read(h.lng, h.ns, h.fcName, h.tried, h.wait, h.callback);
999
- }
1000
- if (u && d && s < this.maxRetries) {
1001
- setTimeout(() => {
1002
- this.read.call(this, e, t, n, s + 1, i * 2, a);
1003
- }, i);
1004
- return;
1005
- }
1006
- a(u, d);
1007
- }, o = this.backend[n].bind(this.backend);
1008
- if (o.length === 2) {
1009
- try {
1010
- const u = o(e, t);
1011
- u && typeof u.then == "function" ? u.then((d) => l(null, d)).catch(l) : l(null, u);
1012
- } catch (u) {
1013
- l(u);
1014
- }
1015
- return;
1016
- }
1017
- return o(e, t, l);
1018
- }
1019
- prepareLoading(e, t) {
1020
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s = arguments.length > 3 ? arguments[3] : void 0;
1021
- if (!this.backend)
1022
- return this.logger.warn("No backend was added via i18next.use. Will not load resources."), s && s();
1023
- c(e) && (e = this.languageUtils.toResolveHierarchy(e)), c(t) && (t = [t]);
1024
- const i = this.queueLoad(e, t, n, s);
1025
- if (!i.toLoad.length)
1026
- return i.pending.length || s(), null;
1027
- i.toLoad.forEach((a) => {
1028
- this.loadOne(a);
1029
- });
1030
- }
1031
- load(e, t, n) {
1032
- this.prepareLoading(e, t, {}, n);
1033
- }
1034
- reload(e, t, n) {
1035
- this.prepareLoading(e, t, {
1036
- reload: !0
1037
- }, n);
1038
- }
1039
- loadOne(e) {
1040
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
1041
- const n = e.split("|"), s = n[0], i = n[1];
1042
- this.read(s, i, "read", void 0, void 0, (a, l) => {
1043
- a && this.logger.warn(`${t}loading namespace ${i} for language ${s} failed`, a), !a && l && this.logger.log(`${t}loaded namespace ${i} for language ${s}`, l), this.loaded(e, a, l);
1044
- });
1045
- }
1046
- saveMissing(e, t, n, s, i) {
1047
- var o, u, d, h, f;
1048
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, l = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
1049
- };
1050
- if ((u = (o = this.services) == null ? void 0 : o.utils) != null && u.hasLoadedNamespace && !((h = (d = this.services) == null ? void 0 : d.utils) != null && h.hasLoadedNamespace(t))) {
1051
- this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
1052
- return;
1053
- }
1054
- if (!(n == null || n === "")) {
1055
- if ((f = this.backend) != null && f.create) {
1056
- const m = {
1057
- ...a,
1058
- isUpdate: i
1059
- }, g = this.backend.create.bind(this.backend);
1060
- if (g.length < 6)
1061
- try {
1062
- let p;
1063
- g.length === 5 ? p = g(e, t, n, s, m) : p = g(e, t, n, s), p && typeof p.then == "function" ? p.then((x) => l(null, x)).catch(l) : l(null, p);
1064
- } catch (p) {
1065
- l(p);
1066
- }
1067
- else
1068
- g(e, t, n, s, l, m);
1069
- }
1070
- !e || !e[0] || this.store.addResource(e[0], t, n, s);
1071
- }
1072
- }
1073
- }
1074
- const pe = () => ({
1075
- debug: !1,
1076
- initAsync: !0,
1077
- ns: ["translation"],
1078
- defaultNS: ["translation"],
1079
- fallbackLng: ["dev"],
1080
- fallbackNS: !1,
1081
- supportedLngs: !1,
1082
- nonExplicitSupportedLngs: !1,
1083
- load: "all",
1084
- preload: !1,
1085
- simplifyPluralSuffix: !0,
1086
- keySeparator: ".",
1087
- nsSeparator: ":",
1088
- pluralSeparator: "_",
1089
- contextSeparator: "_",
1090
- partialBundledLanguages: !1,
1091
- saveMissing: !1,
1092
- updateMissing: !1,
1093
- saveMissingTo: "fallback",
1094
- saveMissingPlurals: !0,
1095
- missingKeyHandler: !1,
1096
- missingInterpolationHandler: !1,
1097
- postProcess: !1,
1098
- postProcessPassResolved: !1,
1099
- returnNull: !1,
1100
- returnEmptyString: !0,
1101
- returnObjects: !1,
1102
- joinArrays: !1,
1103
- returnedObjectHandler: !1,
1104
- parseMissingKeyHandler: !1,
1105
- appendNamespaceToMissingKey: !1,
1106
- appendNamespaceToCIMode: !1,
1107
- overloadTranslationOptionHandler: (r) => {
1108
- let e = {};
1109
- if (typeof r[1] == "object" && (e = r[1]), c(r[1]) && (e.defaultValue = r[1]), c(r[2]) && (e.tDescription = r[2]), typeof r[2] == "object" || typeof r[3] == "object") {
1110
- const t = r[3] || r[2];
1111
- Object.keys(t).forEach((n) => {
1112
- e[n] = t[n];
1113
- });
1114
- }
1115
- return e;
1116
- },
1117
- interpolation: {
1118
- escapeValue: !0,
1119
- format: (r) => r,
1120
- prefix: "{{",
1121
- suffix: "}}",
1122
- formatSeparator: ",",
1123
- unescapePrefix: "-",
1124
- nestingPrefix: "$t(",
1125
- nestingSuffix: ")",
1126
- nestingOptionsSeparator: ",",
1127
- maxReplaces: 1e3,
1128
- skipOnVariables: !0
1129
- }
1130
- }), me = (r) => {
1131
- var e, t;
1132
- return c(r.ns) && (r.ns = [r.ns]), c(r.fallbackLng) && (r.fallbackLng = [r.fallbackLng]), c(r.fallbackNS) && (r.fallbackNS = [r.fallbackNS]), ((t = (e = r.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (r.supportedLngs = r.supportedLngs.concat(["cimode"])), typeof r.initImmediate == "boolean" && (r.initAsync = r.initImmediate), r;
1133
- }, W = () => {
1134
- }, Ge = (r) => {
1135
- Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach((t) => {
1136
- typeof r[t] == "function" && (r[t] = r[t].bind(r));
1137
- });
1138
- };
1139
- class B extends Z {
1140
- constructor() {
1141
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
1142
- if (super(), this.options = me(e), this.services = {}, this.logger = P, this.modules = {
1143
- external: []
1144
- }, Ge(this), t && !this.isInitialized && !e.isClone) {
1145
- if (!this.options.initAsync)
1146
- return this.init(e, t), this;
1147
- setTimeout(() => {
1148
- this.init(e, t);
1149
- }, 0);
1150
- }
1151
- }
1152
- init() {
1153
- var e = this;
1154
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 ? arguments[1] : void 0;
1155
- this.isInitializing = !0, typeof t == "function" && (n = t, t = {}), t.defaultNS == null && t.ns && (c(t.ns) ? t.defaultNS = t.ns : t.ns.indexOf("translation") < 0 && (t.defaultNS = t.ns[0]));
1156
- const s = pe();
1157
- this.options = {
1158
- ...s,
1159
- ...this.options,
1160
- ...me(t)
1161
- }, this.options.interpolation = {
1162
- ...s.interpolation,
1163
- ...this.options.interpolation
1164
- }, t.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = t.keySeparator), t.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = t.nsSeparator);
1165
- const i = (d) => d ? typeof d == "function" ? new d() : d : null;
1166
- if (!this.options.isClone) {
1167
- this.modules.logger ? P.init(i(this.modules.logger), this.options) : P.init(null, this.options);
1168
- let d;
1169
- this.modules.formatter ? d = this.modules.formatter : d = Qe;
1170
- const h = new de(this.options);
1171
- this.store = new le(this.options.resources, this.options);
1172
- const f = this.services;
1173
- f.logger = P, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
1174
- prepend: this.options.pluralSeparator,
1175
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1176
- }), d && (!this.options.interpolation.format || this.options.interpolation.format === s.interpolation.format) && (f.formatter = i(d), f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new Je(this.options), f.utils = {
1177
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1178
- }, f.backendConnector = new qe(i(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", function(m) {
1179
- for (var g = arguments.length, p = new Array(g > 1 ? g - 1 : 0), x = 1; x < g; x++)
1180
- p[x - 1] = arguments[x];
1181
- e.emit(m, ...p);
1182
- }), this.modules.languageDetector && (f.languageDetector = i(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = i(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new G(this.services, this.options), this.translator.on("*", function(m) {
1183
- for (var g = arguments.length, p = new Array(g > 1 ? g - 1 : 0), x = 1; x < g; x++)
1184
- p[x - 1] = arguments[x];
1185
- e.emit(m, ...p);
1186
- }), this.modules.external.forEach((m) => {
1187
- m.init && m.init(this);
1188
- });
1189
- }
1190
- if (this.format = this.options.interpolation.format, n || (n = W), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1191
- const d = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1192
- d.length > 0 && d[0] !== "dev" && (this.options.lng = d[0]);
1193
- }
1194
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((d) => {
1195
- this[d] = function() {
1196
- return e.store[d](...arguments);
1197
- };
1198
- }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((d) => {
1199
- this[d] = function() {
1200
- return e.store[d](...arguments), e;
1201
- };
1202
- });
1203
- const o = H(), u = () => {
1204
- const d = (h, f) => {
1205
- this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), o.resolve(f), n(h, f);
1206
- };
1207
- if (this.languages && !this.isInitialized) return d(null, this.t.bind(this));
1208
- this.changeLanguage(this.options.lng, d);
1209
- };
1210
- return this.options.resources || !this.options.initAsync ? u() : setTimeout(u, 0), o;
1211
- }
1212
- loadResources(e) {
1213
- var i, a;
1214
- let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : W;
1215
- const s = c(e) ? e : this.language;
1216
- if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
1217
- if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
1218
- const l = [], o = (u) => {
1219
- if (!u || u === "cimode") return;
1220
- this.services.languageUtils.toResolveHierarchy(u).forEach((h) => {
1221
- h !== "cimode" && l.indexOf(h) < 0 && l.push(h);
1222
- });
1223
- };
1224
- s ? o(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((d) => o(d)), (a = (i = this.options.preload) == null ? void 0 : i.forEach) == null || a.call(i, (u) => o(u)), this.services.backendConnector.load(l, this.options.ns, (u) => {
1225
- !u && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(u);
1226
- });
1227
- } else
1228
- n(null);
1229
- }
1230
- reloadResources(e, t, n) {
1231
- const s = H();
1232
- return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), n || (n = W), this.services.backendConnector.reload(e, t, (i) => {
1233
- s.resolve(), n(i);
1234
- }), s;
1235
- }
1236
- use(e) {
1237
- if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1238
- if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1239
- return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && Oe.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1240
- }
1241
- setResolvedLanguage(e) {
1242
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1))
1243
- for (let t = 0; t < this.languages.length; t++) {
1244
- const n = this.languages[t];
1245
- if (!(["cimode", "dev"].indexOf(n) > -1) && this.store.hasLanguageSomeTranslations(n)) {
1246
- this.resolvedLanguage = n;
1247
- break;
1248
- }
1249
- }
1250
- }
1251
- changeLanguage(e, t) {
1252
- var n = this;
1253
- this.isLanguageChangingTo = e;
1254
- const s = H();
1255
- this.emit("languageChanging", e);
1256
- const i = (o) => {
1257
- this.language = o, this.languages = this.services.languageUtils.toResolveHierarchy(o), this.resolvedLanguage = void 0, this.setResolvedLanguage(o);
1258
- }, a = (o, u) => {
1259
- u ? (i(u), this.translator.changeLanguage(u), this.isLanguageChangingTo = void 0, this.emit("languageChanged", u), this.logger.log("languageChanged", u)) : this.isLanguageChangingTo = void 0, s.resolve(function() {
1260
- return n.t(...arguments);
1261
- }), t && t(o, function() {
1262
- return n.t(...arguments);
1263
- });
1264
- }, l = (o) => {
1265
- var d, h;
1266
- !e && !o && this.services.languageDetector && (o = []);
1267
- const u = c(o) ? o : this.services.languageUtils.getBestMatchFromCodes(o);
1268
- u && (this.language || i(u), this.translator.language || this.translator.changeLanguage(u), (h = (d = this.services.languageDetector) == null ? void 0 : d.cacheUserLanguage) == null || h.call(d, u)), this.loadResources(u, (f) => {
1269
- a(f, u);
1270
- });
1271
- };
1272
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? l(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(l) : this.services.languageDetector.detect(l) : l(e), s;
1273
- }
1274
- getFixedT(e, t, n) {
1275
- var s = this;
1276
- const i = function(a, l) {
1277
- let o;
1278
- if (typeof l != "object") {
1279
- for (var u = arguments.length, d = new Array(u > 2 ? u - 2 : 0), h = 2; h < u; h++)
1280
- d[h - 2] = arguments[h];
1281
- o = s.options.overloadTranslationOptionHandler([a, l].concat(d));
1282
- } else
1283
- o = {
1284
- ...l
1285
- };
1286
- o.lng = o.lng || i.lng, o.lngs = o.lngs || i.lngs, o.ns = o.ns || i.ns, o.keyPrefix !== "" && (o.keyPrefix = o.keyPrefix || n || i.keyPrefix);
1287
- const f = s.options.keySeparator || ".";
1288
- let m;
1289
- return o.keyPrefix && Array.isArray(a) ? m = a.map((g) => `${o.keyPrefix}${f}${g}`) : m = o.keyPrefix ? `${o.keyPrefix}${f}${a}` : a, s.t(m, o);
1290
- };
1291
- return c(e) ? i.lng = e : i.lngs = e, i.ns = t, i.keyPrefix = n, i;
1292
- }
1293
- t() {
1294
- var s;
1295
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
1296
- t[n] = arguments[n];
1297
- return (s = this.translator) == null ? void 0 : s.translate(...t);
1298
- }
1299
- exists() {
1300
- var s;
1301
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
1302
- t[n] = arguments[n];
1303
- return (s = this.translator) == null ? void 0 : s.exists(...t);
1304
- }
1305
- setDefaultNamespace(e) {
1306
- this.options.defaultNS = e;
1307
- }
1308
- hasLoadedNamespace(e) {
1309
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1310
- if (!this.isInitialized)
1311
- return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1312
- if (!this.languages || !this.languages.length)
1313
- return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1314
- const n = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
1315
- if (n.toLowerCase() === "cimode") return !0;
1316
- const a = (l, o) => {
1317
- const u = this.services.backendConnector.state[`${l}|${o}`];
1318
- return u === -1 || u === 0 || u === 2;
1319
- };
1320
- if (t.precheck) {
1321
- const l = t.precheck(this, a);
1322
- if (l !== void 0) return l;
1323
- }
1324
- return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!s || a(i, e)));
1325
- }
1326
- loadNamespaces(e, t) {
1327
- const n = H();
1328
- return this.options.ns ? (c(e) && (e = [e]), e.forEach((s) => {
1329
- this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
1330
- }), this.loadResources((s) => {
1331
- n.resolve(), t && t(s);
1332
- }), n) : (t && t(), Promise.resolve());
1333
- }
1334
- loadLanguages(e, t) {
1335
- const n = H();
1336
- c(e) && (e = [e]);
1337
- const s = this.options.preload || [], i = e.filter((a) => s.indexOf(a) < 0 && this.services.languageUtils.isSupportedCode(a));
1338
- return i.length ? (this.options.preload = s.concat(i), this.loadResources((a) => {
1339
- n.resolve(), t && t(a);
1340
- }), n) : (t && t(), Promise.resolve());
1341
- }
1342
- dir(e) {
1343
- var s, i;
1344
- if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e) return "rtl";
1345
- const t = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"], n = ((i = this.services) == null ? void 0 : i.languageUtils) || new de(pe());
1346
- return t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1347
- }
1348
- static createInstance() {
1349
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
1350
- return new B(e, t);
1351
- }
1352
- cloneInstance() {
1353
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : W;
1354
- const n = e.forkResourceStore;
1355
- n && delete e.forkResourceStore;
1356
- const s = {
1357
- ...this.options,
1358
- ...e,
1359
- isClone: !0
1360
- }, i = new B(s);
1361
- if ((e.debug !== void 0 || e.prefix !== void 0) && (i.logger = i.logger.clone(e)), ["store", "services", "language"].forEach((l) => {
1362
- i[l] = this[l];
1363
- }), i.services = {
1364
- ...this.services
1365
- }, i.services.utils = {
1366
- hasLoadedNamespace: i.hasLoadedNamespace.bind(i)
1367
- }, n) {
1368
- const l = Object.keys(this.store.data).reduce((o, u) => (o[u] = {
1369
- ...this.store.data[u]
1370
- }, Object.keys(o[u]).reduce((d, h) => (d[h] = {
1371
- ...o[u][h]
1372
- }, d), {})), {});
1373
- i.store = new le(l, s), i.services.resourceStore = i.store;
1374
- }
1375
- return i.translator = new G(i.services, s), i.translator.on("*", function(l) {
1376
- for (var o = arguments.length, u = new Array(o > 1 ? o - 1 : 0), d = 1; d < o; d++)
1377
- u[d - 1] = arguments[d];
1378
- i.emit(l, ...u);
1379
- }), i.init(s, t), i.translator.options = s, i.translator.backendConnector.services.utils = {
1380
- hasLoadedNamespace: i.hasLoadedNamespace.bind(i)
1381
- }, i;
1382
- }
1383
- toJSON() {
1384
- return {
1385
- options: this.options,
1386
- store: this.store,
1387
- language: this.language,
1388
- languages: this.languages,
1389
- resolvedLanguage: this.resolvedLanguage
1390
- };
1391
- }
1392
- }
1393
- const S = B.createInstance();
1394
- S.createInstance = B.createInstance;
1395
- S.createInstance;
1396
- S.dir;
1397
- S.init;
1398
- S.loadResources;
1399
- S.reloadResources;
1400
- S.use;
1401
- S.changeLanguage;
1402
- S.getFixedT;
1403
- S.t;
1404
- S.exists;
1405
- S.setDefaultNamespace;
1406
- S.hasLoadedNamespace;
1407
- S.loadNamespaces;
1408
- S.loadLanguages;
1409
- const {
1410
- slice: Ze,
1411
- forEach: Xe
1412
- } = [];
1413
- function _e(r) {
1414
- return Xe.call(Ze.call(arguments, 1), (e) => {
1415
- if (e)
1416
- for (const t in e)
1417
- r[t] === void 0 && (r[t] = e[t]);
1418
- }), r;
1419
- }
1420
- const xe = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/, et = function(r, e) {
1421
- const n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
1422
- path: "/"
1423
- }, s = encodeURIComponent(e);
1424
- let i = `${r}=${s}`;
1425
- if (n.maxAge > 0) {
1426
- const a = n.maxAge - 0;
1427
- if (Number.isNaN(a)) throw new Error("maxAge should be a Number");
1428
- i += `; Max-Age=${Math.floor(a)}`;
1429
- }
1430
- if (n.domain) {
1431
- if (!xe.test(n.domain))
1432
- throw new TypeError("option domain is invalid");
1433
- i += `; Domain=${n.domain}`;
1434
- }
1435
- if (n.path) {
1436
- if (!xe.test(n.path))
1437
- throw new TypeError("option path is invalid");
1438
- i += `; Path=${n.path}`;
1439
- }
1440
- if (n.expires) {
1441
- if (typeof n.expires.toUTCString != "function")
1442
- throw new TypeError("option expires is invalid");
1443
- i += `; Expires=${n.expires.toUTCString()}`;
1444
- }
1445
- if (n.httpOnly && (i += "; HttpOnly"), n.secure && (i += "; Secure"), n.sameSite)
1446
- switch (typeof n.sameSite == "string" ? n.sameSite.toLowerCase() : n.sameSite) {
1447
- case !0:
1448
- i += "; SameSite=Strict";
1449
- break;
1450
- case "lax":
1451
- i += "; SameSite=Lax";
1452
- break;
1453
- case "strict":
1454
- i += "; SameSite=Strict";
1455
- break;
1456
- case "none":
1457
- i += "; SameSite=None";
1458
- break;
1459
- default:
1460
- throw new TypeError("option sameSite is invalid");
1461
- }
1462
- return i;
1463
- }, ye = {
1464
- create(r, e, t, n) {
1465
- let s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
1466
- path: "/",
1467
- sameSite: "strict"
1468
- };
1469
- t && (s.expires = /* @__PURE__ */ new Date(), s.expires.setTime(s.expires.getTime() + t * 60 * 1e3)), n && (s.domain = n), document.cookie = et(r, encodeURIComponent(e), s);
1470
- },
1471
- read(r) {
1472
- const e = `${r}=`, t = document.cookie.split(";");
1473
- for (let n = 0; n < t.length; n++) {
1474
- let s = t[n];
1475
- for (; s.charAt(0) === " "; ) s = s.substring(1, s.length);
1476
- if (s.indexOf(e) === 0) return s.substring(e.length, s.length);
1477
- }
1478
- return null;
1479
- },
1480
- remove(r) {
1481
- this.create(r, "", -1);
1482
- }
1483
- };
1484
- var tt = {
1485
- name: "cookie",
1486
- // Deconstruct the options object and extract the lookupCookie property
1487
- lookup(r) {
1488
- let {
1489
- lookupCookie: e
1490
- } = r;
1491
- if (e && typeof document < "u")
1492
- return ye.read(e) || void 0;
1493
- },
1494
- // Deconstruct the options object and extract the lookupCookie, cookieMinutes, cookieDomain, and cookieOptions properties
1495
- cacheUserLanguage(r, e) {
1496
- let {
1497
- lookupCookie: t,
1498
- cookieMinutes: n,
1499
- cookieDomain: s,
1500
- cookieOptions: i
1501
- } = e;
1502
- t && typeof document < "u" && ye.create(t, r, n, s, i);
1503
- }
1504
- }, nt = {
1505
- name: "querystring",
1506
- // Deconstruct the options object and extract the lookupQuerystring property
1507
- lookup(r) {
1508
- var n;
1509
- let {
1510
- lookupQuerystring: e
1511
- } = r, t;
1512
- if (typeof window < "u") {
1513
- let {
1514
- search: s
1515
- } = window.location;
1516
- !window.location.search && ((n = window.location.hash) == null ? void 0 : n.indexOf("?")) > -1 && (s = window.location.hash.substring(window.location.hash.indexOf("?")));
1517
- const a = s.substring(1).split("&");
1518
- for (let l = 0; l < a.length; l++) {
1519
- const o = a[l].indexOf("=");
1520
- o > 0 && a[l].substring(0, o) === e && (t = a[l].substring(o + 1));
1521
- }
1522
- }
1523
- return t;
1524
- }
1525
- };
1526
- let A = null;
1527
- const Se = () => {
1528
- if (A !== null) return A;
1529
- try {
1530
- if (A = typeof window < "u" && window.localStorage !== null, !A)
1531
- return !1;
1532
- const r = "i18next.translate.boo";
1533
- window.localStorage.setItem(r, "foo"), window.localStorage.removeItem(r);
1534
- } catch {
1535
- A = !1;
1536
- }
1537
- return A;
1538
- };
1539
- var st = {
1540
- name: "localStorage",
1541
- // Deconstruct the options object and extract the lookupLocalStorage property
1542
- lookup(r) {
1543
- let {
1544
- lookupLocalStorage: e
1545
- } = r;
1546
- if (e && Se())
1547
- return window.localStorage.getItem(e) || void 0;
1548
- },
1549
- // Deconstruct the options object and extract the lookupLocalStorage property
1550
- cacheUserLanguage(r, e) {
1551
- let {
1552
- lookupLocalStorage: t
1553
- } = e;
1554
- t && Se() && window.localStorage.setItem(t, r);
1555
- }
1556
- };
1557
- let T = null;
1558
- const be = () => {
1559
- if (T !== null) return T;
1560
- try {
1561
- if (T = typeof window < "u" && window.sessionStorage !== null, !T)
1562
- return !1;
1563
- const r = "i18next.translate.boo";
1564
- window.sessionStorage.setItem(r, "foo"), window.sessionStorage.removeItem(r);
1565
- } catch {
1566
- T = !1;
1567
- }
1568
- return T;
1569
- };
1570
- var it = {
1571
- name: "sessionStorage",
1572
- lookup(r) {
1573
- let {
1574
- lookupSessionStorage: e
1575
- } = r;
1576
- if (e && be())
1577
- return window.sessionStorage.getItem(e) || void 0;
1578
- },
1579
- cacheUserLanguage(r, e) {
1580
- let {
1581
- lookupSessionStorage: t
1582
- } = e;
1583
- t && be() && window.sessionStorage.setItem(t, r);
1584
- }
1585
- }, rt = {
1586
- name: "navigator",
1587
- lookup(r) {
1588
- const e = [];
1589
- if (typeof navigator < "u") {
1590
- const {
1591
- languages: t,
1592
- userLanguage: n,
1593
- language: s
1594
- } = navigator;
1595
- if (t)
1596
- for (let i = 0; i < t.length; i++)
1597
- e.push(t[i]);
1598
- n && e.push(n), s && e.push(s);
1599
- }
1600
- return e.length > 0 ? e : void 0;
1601
- }
1602
- }, at = {
1603
- name: "htmlTag",
1604
- // Deconstruct the options object and extract the htmlTag property
1605
- lookup(r) {
1606
- let {
1607
- htmlTag: e
1608
- } = r, t;
1609
- const n = e || (typeof document < "u" ? document.documentElement : null);
1610
- return n && typeof n.getAttribute == "function" && (t = n.getAttribute("lang")), t;
1611
- }
1612
- }, ot = {
1613
- name: "path",
1614
- // Deconstruct the options object and extract the lookupFromPathIndex property
1615
- lookup(r) {
1616
- var s;
1617
- let {
1618
- lookupFromPathIndex: e
1619
- } = r;
1620
- if (typeof window > "u") return;
1621
- const t = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
1622
- return Array.isArray(t) ? (s = t[typeof e == "number" ? e : 0]) == null ? void 0 : s.replace("/", "") : void 0;
1623
- }
1624
- }, lt = {
1625
- name: "subdomain",
1626
- lookup(r) {
1627
- var s, i;
1628
- let {
1629
- lookupFromSubdomainIndex: e
1630
- } = r;
1631
- const t = typeof e == "number" ? e + 1 : 1, n = typeof window < "u" && ((i = (s = window.location) == null ? void 0 : s.hostname) == null ? void 0 : i.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));
1632
- if (n)
1633
- return n[t];
1634
- }
1635
- };
1636
- let Le = !1;
1637
- try {
1638
- document.cookie, Le = !0;
1639
- } catch {
1640
- }
1641
- const ve = ["querystring", "cookie", "localStorage", "sessionStorage", "navigator", "htmlTag"];
1642
- Le || ve.splice(1, 1);
1643
- const ut = () => ({
1644
- order: ve,
1645
- lookupQuerystring: "lng",
1646
- lookupCookie: "i18next",
1647
- lookupLocalStorage: "i18nextLng",
1648
- lookupSessionStorage: "i18nextLng",
1649
- // cache user language
1650
- caches: ["localStorage"],
1651
- excludeCacheFor: ["cimode"],
1652
- // cookieMinutes: 10,
1653
- // cookieDomain: 'myDomain'
1654
- convertDetectedLanguage: (r) => r
1655
- });
1656
- class Ce {
1657
- constructor(e) {
1658
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1659
- this.type = "languageDetector", this.detectors = {}, this.init(e, t);
1660
- }
1661
- init() {
1662
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1663
- languageUtils: {}
1664
- }, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1665
- this.services = e, this.options = _e(t, this.options || {}, ut()), typeof this.options.convertDetectedLanguage == "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1 && (this.options.convertDetectedLanguage = (s) => s.replace("-", "_")), this.options.lookupFromUrlIndex && (this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex), this.i18nOptions = n, this.addDetector(tt), this.addDetector(nt), this.addDetector(st), this.addDetector(it), this.addDetector(rt), this.addDetector(at), this.addDetector(ot), this.addDetector(lt);
1666
- }
1667
- addDetector(e) {
1668
- return this.detectors[e.name] = e, this;
1669
- }
1670
- detect() {
1671
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.order, t = [];
1672
- return e.forEach((n) => {
1673
- if (this.detectors[n]) {
1674
- let s = this.detectors[n].lookup(this.options);
1675
- s && typeof s == "string" && (s = [s]), s && (t = t.concat(s));
1676
- }
1677
- }), t = t.map((n) => this.options.convertDetectedLanguage(n)), this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes ? t : t.length > 0 ? t[0] : null;
1678
- }
1679
- cacheUserLanguage(e) {
1680
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.caches;
1681
- t && (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(e) > -1 || t.forEach((n) => {
1682
- this.detectors[n] && this.detectors[n].cacheUserLanguage(e, this.options);
1683
- }));
1684
- }
1685
- }
1686
- Ce.type = "languageDetector";
1687
- const ft = S.createInstance();
1688
- ft.use(Ce).use(Fe).init({
1689
- lng: "en",
1690
- fallbackLng: Ee,
1691
- debug: !0,
1692
- resources: {
1693
- en: { translation: ke },
1694
- es: { translation: $e },
1695
- tr: { translation: Re }
1696
- },
1697
- returnObjects: !0,
1698
- returnNull: !1,
1699
- interpolation: {
1700
- escapeValue: !1
1701
- // not needed for react as it escapes by default
1702
- }
1703
- });
1704
- export {
1705
- ft as i,
1706
- pt as t
1707
- };