@incodetech/web 2.0.0-alpha.9 → 2.0.0

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.
@@ -1,2140 +0,0 @@
1
- const g = (s) => typeof s == "string", q = () => {
2
- let s, e;
3
- const t = new Promise((n, i) => {
4
- s = n, e = i;
5
- });
6
- return t.resolve = s, t.reject = e, t;
7
- }, he = (s) => s == null ? "" : "" + s, Ge = (s, e, t) => {
8
- s.forEach((n) => {
9
- e[n] && (t[n] = e[n]);
10
- });
11
- }, Ye = /###/g, pe = (s) => s && s.indexOf("###") > -1 ? s.replace(Ye, ".") : s, ge = (s) => !s || g(s), _ = (s, e, t) => {
12
- const n = g(e) ? e.split(".") : e;
13
- let i = 0;
14
- for (; i < n.length - 1; ) {
15
- if (ge(s)) return {};
16
- const r = pe(n[i]);
17
- !s[r] && t && (s[r] = new t()), Object.prototype.hasOwnProperty.call(s, r) ? s = s[r] : s = {}, ++i;
18
- }
19
- return ge(s) ? {} : {
20
- obj: s,
21
- k: pe(n[i])
22
- };
23
- }, me = (s, e, t) => {
24
- const {
25
- obj: n,
26
- k: i
27
- } = _(s, e, Object);
28
- if (n !== void 0 || e.length === 1) {
29
- n[i] = t;
30
- return;
31
- }
32
- let r = e[e.length - 1], o = e.slice(0, e.length - 1), a = _(s, o, Object);
33
- for (; a.obj === void 0 && o.length; )
34
- r = `${o[o.length - 1]}.${r}`, o = o.slice(0, o.length - 1), a = _(s, o, Object), a?.obj && typeof a.obj[`${a.k}.${r}`] < "u" && (a.obj = void 0);
35
- a.obj[`${a.k}.${r}`] = t;
36
- }, Ze = (s, e, t, n) => {
37
- const {
38
- obj: i,
39
- k: r
40
- } = _(s, e, Object);
41
- i[r] = i[r] || [], i[r].push(t);
42
- }, G = (s, e) => {
43
- const {
44
- obj: t,
45
- k: n
46
- } = _(s, e);
47
- if (t && Object.prototype.hasOwnProperty.call(t, n))
48
- return t[n];
49
- }, et = (s, e, t) => {
50
- const n = G(s, t);
51
- return n !== void 0 ? n : G(e, t);
52
- }, Ae = (s, e, t) => {
53
- for (const n in e)
54
- n !== "__proto__" && n !== "constructor" && (n in s ? g(s[n]) || s[n] instanceof String || g(e[n]) || e[n] instanceof String ? t && (s[n] = e[n]) : Ae(s[n], e[n], t) : s[n] = e[n]);
55
- return s;
56
- }, A = (s) => s.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
57
- var tt = {
58
- "&": "&amp;",
59
- "<": "&lt;",
60
- ">": "&gt;",
61
- '"': "&quot;",
62
- "'": "&#39;",
63
- "/": "&#x2F;"
64
- };
65
- const nt = (s) => g(s) ? s.replace(/[&<>"'\/]/g, (e) => tt[e]) : s;
66
- class it {
67
- constructor(e) {
68
- this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
69
- }
70
- getRegExp(e) {
71
- const t = this.regExpMap.get(e);
72
- if (t !== void 0)
73
- return t;
74
- const n = new RegExp(e);
75
- return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
76
- }
77
- }
78
- const st = [" ", ",", "?", "!", ";"], rt = new it(20), ot = (s, e, t) => {
79
- e = e || "", t = t || "";
80
- const n = st.filter((o) => e.indexOf(o) < 0 && t.indexOf(o) < 0);
81
- if (n.length === 0) return !0;
82
- const i = rt.getRegExp(`(${n.map((o) => o === "?" ? "\\?" : o).join("|")})`);
83
- let r = !i.test(s);
84
- if (!r) {
85
- const o = s.indexOf(t);
86
- o > 0 && !i.test(s.substring(0, o)) && (r = !0);
87
- }
88
- return r;
89
- }, re = (s, e, t = ".") => {
90
- if (!s) return;
91
- if (s[e])
92
- return Object.prototype.hasOwnProperty.call(s, e) ? s[e] : void 0;
93
- const n = e.split(t);
94
- let i = s;
95
- for (let r = 0; r < n.length; ) {
96
- if (!i || typeof i != "object")
97
- return;
98
- let o, a = "";
99
- for (let l = r; l < n.length; ++l)
100
- if (l !== r && (a += t), a += n[l], o = i[a], o !== void 0) {
101
- if (["string", "number", "boolean"].indexOf(typeof o) > -1 && l < n.length - 1)
102
- continue;
103
- r += l - r + 1;
104
- break;
105
- }
106
- i = o;
107
- }
108
- return i;
109
- }, B = (s) => s?.replace("_", "-"), at = {
110
- type: "logger",
111
- log(s) {
112
- this.output("log", s);
113
- },
114
- warn(s) {
115
- this.output("warn", s);
116
- },
117
- error(s) {
118
- this.output("error", s);
119
- },
120
- output(s, e) {
121
- console?.[s]?.apply?.(console, e);
122
- }
123
- };
124
- class Y {
125
- constructor(e, t = {}) {
126
- this.init(e, t);
127
- }
128
- init(e, t = {}) {
129
- this.prefix = t.prefix || "i18next:", this.logger = e || at, this.options = t, this.debug = t.debug;
130
- }
131
- log(...e) {
132
- return this.forward(e, "log", "", !0);
133
- }
134
- warn(...e) {
135
- return this.forward(e, "warn", "", !0);
136
- }
137
- error(...e) {
138
- return this.forward(e, "error", "");
139
- }
140
- deprecate(...e) {
141
- return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
142
- }
143
- forward(e, t, n, i) {
144
- return i && !this.debug ? null : (g(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
145
- }
146
- create(e) {
147
- return new Y(this.logger, {
148
- prefix: `${this.prefix}:${e}:`,
149
- ...this.options
150
- });
151
- }
152
- clone(e) {
153
- return e = e || this.options, e.prefix = e.prefix || this.prefix, new Y(this.logger, e);
154
- }
155
- }
156
- var C = new Y();
157
- class te {
158
- constructor() {
159
- this.observers = {};
160
- }
161
- on(e, t) {
162
- return e.split(" ").forEach((n) => {
163
- this.observers[n] || (this.observers[n] = /* @__PURE__ */ new Map());
164
- const i = this.observers[n].get(t) || 0;
165
- this.observers[n].set(t, i + 1);
166
- }), this;
167
- }
168
- off(e, t) {
169
- if (this.observers[e]) {
170
- if (!t) {
171
- delete this.observers[e];
172
- return;
173
- }
174
- this.observers[e].delete(t);
175
- }
176
- }
177
- emit(e, ...t) {
178
- this.observers[e] && Array.from(this.observers[e].entries()).forEach(([i, r]) => {
179
- for (let o = 0; o < r; o++)
180
- i(...t);
181
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([i, r]) => {
182
- for (let o = 0; o < r; o++)
183
- i.apply(i, [e, ...t]);
184
- });
185
- }
186
- }
187
- class ye extends te {
188
- constructor(e, t = {
189
- ns: ["translation"],
190
- defaultNS: "translation"
191
- }) {
192
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
193
- }
194
- addNamespaces(e) {
195
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
196
- }
197
- removeNamespaces(e) {
198
- const t = this.options.ns.indexOf(e);
199
- t > -1 && this.options.ns.splice(t, 1);
200
- }
201
- getResource(e, t, n, i = {}) {
202
- const r = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator, o = i.ignoreJSONStructure !== void 0 ? i.ignoreJSONStructure : this.options.ignoreJSONStructure;
203
- let a;
204
- e.indexOf(".") > -1 ? a = e.split(".") : (a = [e, t], n && (Array.isArray(n) ? a.push(...n) : g(n) && r ? a.push(...n.split(r)) : a.push(n)));
205
- const l = G(this.data, a);
206
- return !l && !t && !n && e.indexOf(".") > -1 && (e = a[0], t = a[1], n = a.slice(2).join(".")), l || !o || !g(n) ? l : re(this.data?.[e]?.[t], n, r);
207
- }
208
- addResource(e, t, n, i, r = {
209
- silent: !1
210
- }) {
211
- const o = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
212
- let a = [e, t];
213
- n && (a = a.concat(o ? n.split(o) : n)), e.indexOf(".") > -1 && (a = e.split("."), i = t, t = a[1]), this.addNamespaces(t), me(this.data, a, i), r.silent || this.emit("added", e, t, n, i);
214
- }
215
- addResources(e, t, n, i = {
216
- silent: !1
217
- }) {
218
- for (const r in n)
219
- (g(n[r]) || Array.isArray(n[r])) && this.addResource(e, t, r, n[r], {
220
- silent: !0
221
- });
222
- i.silent || this.emit("added", e, t, n);
223
- }
224
- addResourceBundle(e, t, n, i, r, o = {
225
- silent: !1,
226
- skipCopy: !1
227
- }) {
228
- let a = [e, t];
229
- e.indexOf(".") > -1 && (a = e.split("."), i = n, n = t, t = a[1]), this.addNamespaces(t);
230
- let l = G(this.data, a) || {};
231
- o.skipCopy || (n = JSON.parse(JSON.stringify(n))), i ? Ae(l, n, r) : l = {
232
- ...l,
233
- ...n
234
- }, me(this.data, a, l), o.silent || this.emit("added", e, t, n);
235
- }
236
- removeResourceBundle(e, t) {
237
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
238
- }
239
- hasResourceBundle(e, t) {
240
- return this.getResource(e, t) !== void 0;
241
- }
242
- getResourceBundle(e, t) {
243
- return t || (t = this.options.defaultNS), this.getResource(e, t);
244
- }
245
- getDataByLanguage(e) {
246
- return this.data[e];
247
- }
248
- hasLanguageSomeTranslations(e) {
249
- const t = this.getDataByLanguage(e);
250
- return !!(t && Object.keys(t) || []).find((i) => t[i] && Object.keys(t[i]).length > 0);
251
- }
252
- toJSON() {
253
- return this.data;
254
- }
255
- }
256
- var He = {
257
- processors: {},
258
- addPostProcessor(s) {
259
- this.processors[s.name] = s;
260
- },
261
- handle(s, e, t, n, i) {
262
- return s.forEach((r) => {
263
- e = this.processors[r]?.process(e, t, n, i) ?? e;
264
- }), e;
265
- }
266
- };
267
- const Ke = Symbol("i18next/PATH_KEY");
268
- function lt() {
269
- const s = [], e = /* @__PURE__ */ Object.create(null);
270
- let t;
271
- return e.get = (n, i) => (t?.revoke?.(), i === Ke ? s : (s.push(i), t = Proxy.revocable(n, e), t.proxy)), Proxy.revocable(/* @__PURE__ */ Object.create(null), e).proxy;
272
- }
273
- function oe(s, e) {
274
- const {
275
- [Ke]: t
276
- } = s(lt());
277
- return t.join(e?.keySeparator ?? ".");
278
- }
279
- const xe = {}, ne = (s) => !g(s) && typeof s != "boolean" && typeof s != "number";
280
- class Z extends te {
281
- constructor(e, t = {}) {
282
- super(), Ge(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = C.create("translator");
283
- }
284
- changeLanguage(e) {
285
- e && (this.language = e);
286
- }
287
- exists(e, t = {
288
- interpolation: {}
289
- }) {
290
- const n = {
291
- ...t
292
- };
293
- if (e == null) return !1;
294
- const i = this.resolve(e, n);
295
- if (i?.res === void 0) return !1;
296
- const r = ne(i.res);
297
- return !(n.returnObjects === !1 && r);
298
- }
299
- extractFromKey(e, t) {
300
- let n = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
301
- n === void 0 && (n = ":");
302
- const i = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
303
- let r = t.ns || this.options.defaultNS || [];
304
- const o = n && e.indexOf(n) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !ot(e, n, i);
305
- if (o && !a) {
306
- const l = e.match(this.interpolator.nestingRegexp);
307
- if (l && l.length > 0)
308
- return {
309
- key: e,
310
- namespaces: g(r) ? [r] : r
311
- };
312
- const u = e.split(n);
313
- (n !== i || n === i && this.options.ns.indexOf(u[0]) > -1) && (r = u.shift()), e = u.join(i);
314
- }
315
- return {
316
- key: e,
317
- namespaces: g(r) ? [r] : r
318
- };
319
- }
320
- translate(e, t, n) {
321
- let i = typeof t == "object" ? {
322
- ...t
323
- } : t;
324
- if (typeof i != "object" && this.options.overloadTranslationOptionHandler && (i = this.options.overloadTranslationOptionHandler(arguments)), typeof i == "object" && (i = {
325
- ...i
326
- }), i || (i = {}), e == null) return "";
327
- typeof e == "function" && (e = oe(e, {
328
- ...this.options,
329
- ...i
330
- })), Array.isArray(e) || (e = [String(e)]);
331
- const r = i.returnDetails !== void 0 ? i.returnDetails : this.options.returnDetails, o = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator, {
332
- key: a,
333
- namespaces: l
334
- } = this.extractFromKey(e[e.length - 1], i), u = l[l.length - 1];
335
- let c = i.nsSeparator !== void 0 ? i.nsSeparator : this.options.nsSeparator;
336
- c === void 0 && (c = ":");
337
- const f = i.lng || this.language, p = i.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
338
- if (f?.toLowerCase() === "cimode")
339
- return p ? r ? {
340
- res: `${u}${c}${a}`,
341
- usedKey: a,
342
- exactUsedKey: a,
343
- usedLng: f,
344
- usedNS: u,
345
- usedParams: this.getUsedParamsDetails(i)
346
- } : `${u}${c}${a}` : r ? {
347
- res: a,
348
- usedKey: a,
349
- exactUsedKey: a,
350
- usedLng: f,
351
- usedNS: u,
352
- usedParams: this.getUsedParamsDetails(i)
353
- } : a;
354
- const d = this.resolve(e, i);
355
- let h = d?.res;
356
- const m = d?.usedKey || a, y = d?.exactUsedKey || a, w = ["[object Number]", "[object Function]", "[object RegExp]"], x = i.joinArrays !== void 0 ? i.joinArrays : this.options.joinArrays, N = !this.i18nFormat || this.i18nFormat.handleAsObject, v = i.count !== void 0 && !g(i.count), j = Z.hasDefaultValue(i), I = v ? this.pluralResolver.getSuffix(f, i.count, i) : "", D = i.ordinal && v ? this.pluralResolver.getSuffix(f, i.count, {
357
- ordinal: !1
358
- }) : "", ue = v && !i.ordinal && i.count === 0, $ = ue && i[`defaultValue${this.options.pluralSeparator}zero`] || i[`defaultValue${I}`] || i[`defaultValue${D}`] || i.defaultValue;
359
- let L = h;
360
- N && !h && j && (L = $);
361
- const We = ne(L), Qe = Object.prototype.toString.apply(L);
362
- if (N && L && We && w.indexOf(Qe) < 0 && !(g(x) && Array.isArray(L))) {
363
- if (!i.returnObjects && !this.options.returnObjects) {
364
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
365
- const P = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, L, {
366
- ...i,
367
- ns: l
368
- }) : `key '${a} (${this.language})' returned an object instead of string.`;
369
- return r ? (d.res = P, d.usedParams = this.getUsedParamsDetails(i), d) : P;
370
- }
371
- if (o) {
372
- const P = Array.isArray(L), O = P ? [] : {}, fe = P ? y : m;
373
- for (const k in L)
374
- if (Object.prototype.hasOwnProperty.call(L, k)) {
375
- const R = `${fe}${o}${k}`;
376
- j && !h ? O[k] = this.translate(R, {
377
- ...i,
378
- defaultValue: ne($) ? $[k] : void 0,
379
- joinArrays: !1,
380
- ns: l
381
- }) : O[k] = this.translate(R, {
382
- ...i,
383
- joinArrays: !1,
384
- ns: l
385
- }), O[k] === R && (O[k] = L[k]);
386
- }
387
- h = O;
388
- }
389
- } else if (N && g(x) && Array.isArray(h))
390
- h = h.join(x), h && (h = this.extendTranslation(h, e, i, n));
391
- else {
392
- let P = !1, O = !1;
393
- !this.isValidLookup(h) && j && (P = !0, h = $), this.isValidLookup(h) || (O = !0, h = a);
394
- const k = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && O ? void 0 : h, R = j && $ !== h && this.options.updateMissing;
395
- if (O || P || R) {
396
- if (this.logger.log(R ? "updateKey" : "missingKey", f, u, a, R ? $ : h), o) {
397
- const S = this.resolve(a, {
398
- ...i,
399
- keySeparator: !1
400
- });
401
- S && S.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.");
402
- }
403
- let M = [];
404
- const J = this.languageUtils.getFallbackCodes(this.options.fallbackLng, i.lng || this.language);
405
- if (this.options.saveMissingTo === "fallback" && J && J[0])
406
- for (let S = 0; S < J.length; S++)
407
- M.push(J[S]);
408
- else this.options.saveMissingTo === "all" ? M = this.languageUtils.toResolveHierarchy(i.lng || this.language) : M.push(i.lng || this.language);
409
- const ce = (S, F, V) => {
410
- const de = j && V !== h ? V : k;
411
- this.options.missingKeyHandler ? this.options.missingKeyHandler(S, u, F, de, R, i) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(S, u, F, de, R, i), this.emit("missingKey", S, u, F, h);
412
- };
413
- this.options.saveMissing && (this.options.saveMissingPlurals && v ? M.forEach((S) => {
414
- const F = this.pluralResolver.getSuffixes(S, i);
415
- ue && i[`defaultValue${this.options.pluralSeparator}zero`] && F.indexOf(`${this.options.pluralSeparator}zero`) < 0 && F.push(`${this.options.pluralSeparator}zero`), F.forEach((V) => {
416
- ce([S], a + V, i[`defaultValue${V}`] || $);
417
- });
418
- }) : ce(M, a, $));
419
- }
420
- h = this.extendTranslation(h, e, i, d, n), O && h === a && this.options.appendNamespaceToMissingKey && (h = `${u}${c}${a}`), (O || P) && this.options.parseMissingKeyHandler && (h = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${c}${a}` : a, P ? h : void 0, i));
421
- }
422
- return r ? (d.res = h, d.usedParams = this.getUsedParamsDetails(i), d) : h;
423
- }
424
- extendTranslation(e, t, n, i, r) {
425
- if (this.i18nFormat?.parse)
426
- e = this.i18nFormat.parse(e, {
427
- ...this.options.interpolation.defaultVariables,
428
- ...n
429
- }, n.lng || this.language || i.usedLng, i.usedNS, i.usedKey, {
430
- resolved: i
431
- });
432
- else if (!n.skipInterpolation) {
433
- n.interpolation && this.interpolator.init({
434
- ...n,
435
- interpolation: {
436
- ...this.options.interpolation,
437
- ...n.interpolation
438
- }
439
- });
440
- const l = g(e) && (n?.interpolation?.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
441
- let u;
442
- if (l) {
443
- const f = e.match(this.interpolator.nestingRegexp);
444
- u = f && f.length;
445
- }
446
- let c = n.replace && !g(n.replace) ? n.replace : n;
447
- if (this.options.interpolation.defaultVariables && (c = {
448
- ...this.options.interpolation.defaultVariables,
449
- ...c
450
- }), e = this.interpolator.interpolate(e, c, n.lng || this.language || i.usedLng, n), l) {
451
- const f = e.match(this.interpolator.nestingRegexp), p = f && f.length;
452
- u < p && (n.nest = !1);
453
- }
454
- !n.lng && i && i.res && (n.lng = this.language || i.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, (...f) => r?.[0] === f[0] && !n.context ? (this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${t[0]}`), null) : this.translate(...f, t), n)), n.interpolation && this.interpolator.reset();
455
- }
456
- const o = n.postProcess || this.options.postProcess, a = g(o) ? [o] : o;
457
- return e != null && a?.length && n.applyPostProcessor !== !1 && (e = He.handle(a, e, t, this.options && this.options.postProcessPassResolved ? {
458
- i18nResolved: {
459
- ...i,
460
- usedParams: this.getUsedParamsDetails(n)
461
- },
462
- ...n
463
- } : n, this)), e;
464
- }
465
- resolve(e, t = {}) {
466
- let n, i, r, o, a;
467
- return g(e) && (e = [e]), e.forEach((l) => {
468
- if (this.isValidLookup(n)) return;
469
- const u = this.extractFromKey(l, t), c = u.key;
470
- i = c;
471
- let f = u.namespaces;
472
- this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
473
- const p = t.count !== void 0 && !g(t.count), d = p && !t.ordinal && t.count === 0, h = t.context !== void 0 && (g(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
474
- f.forEach((y) => {
475
- this.isValidLookup(n) || (a = y, !xe[`${m[0]}-${y}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(a) && (xe[`${m[0]}-${y}`] = !0, this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" 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!!!")), m.forEach((w) => {
476
- if (this.isValidLookup(n)) return;
477
- o = w;
478
- const x = [c];
479
- if (this.i18nFormat?.addLookupKeys)
480
- this.i18nFormat.addLookupKeys(x, c, w, y, t);
481
- else {
482
- let v;
483
- p && (v = this.pluralResolver.getSuffix(w, t.count, t));
484
- const j = `${this.options.pluralSeparator}zero`, I = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
485
- if (p && (t.ordinal && v.indexOf(I) === 0 && x.push(c + v.replace(I, this.options.pluralSeparator)), x.push(c + v), d && x.push(c + j)), h) {
486
- const D = `${c}${this.options.contextSeparator || "_"}${t.context}`;
487
- x.push(D), p && (t.ordinal && v.indexOf(I) === 0 && x.push(D + v.replace(I, this.options.pluralSeparator)), x.push(D + v), d && x.push(D + j));
488
- }
489
- }
490
- let N;
491
- for (; N = x.pop(); )
492
- this.isValidLookup(n) || (r = N, n = this.getResource(w, y, N, t));
493
- }));
494
- });
495
- }), {
496
- res: n,
497
- usedKey: i,
498
- exactUsedKey: r,
499
- usedLng: o,
500
- usedNS: a
501
- };
502
- }
503
- isValidLookup(e) {
504
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
505
- }
506
- getResource(e, t, n, i = {}) {
507
- return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, i) : this.resourceStore.getResource(e, t, n, i);
508
- }
509
- getUsedParamsDetails(e = {}) {
510
- const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = e.replace && !g(e.replace);
511
- let i = n ? e.replace : e;
512
- if (n && typeof e.count < "u" && (i.count = e.count), this.options.interpolation.defaultVariables && (i = {
513
- ...this.options.interpolation.defaultVariables,
514
- ...i
515
- }), !n) {
516
- i = {
517
- ...i
518
- };
519
- for (const r of t)
520
- delete i[r];
521
- }
522
- return i;
523
- }
524
- static hasDefaultValue(e) {
525
- const t = "defaultValue";
526
- for (const n in e)
527
- if (Object.prototype.hasOwnProperty.call(e, n) && t === n.substring(0, t.length) && e[n] !== void 0)
528
- return !0;
529
- return !1;
530
- }
531
- }
532
- class be {
533
- constructor(e) {
534
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = C.create("languageUtils");
535
- }
536
- getScriptPartFromCode(e) {
537
- if (e = B(e), !e || e.indexOf("-") < 0) return null;
538
- const t = e.split("-");
539
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
540
- }
541
- getLanguagePartFromCode(e) {
542
- if (e = B(e), !e || e.indexOf("-") < 0) return e;
543
- const t = e.split("-");
544
- return this.formatLanguageCode(t[0]);
545
- }
546
- formatLanguageCode(e) {
547
- if (g(e) && e.indexOf("-") > -1) {
548
- let t;
549
- try {
550
- t = Intl.getCanonicalLocales(e)[0];
551
- } catch {
552
- }
553
- return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
554
- }
555
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
556
- }
557
- isSupportedCode(e) {
558
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
559
- }
560
- getBestMatchFromCodes(e) {
561
- if (!e) return null;
562
- let t;
563
- return e.forEach((n) => {
564
- if (t) return;
565
- const i = this.formatLanguageCode(n);
566
- (!this.options.supportedLngs || this.isSupportedCode(i)) && (t = i);
567
- }), !t && this.options.supportedLngs && e.forEach((n) => {
568
- if (t) return;
569
- const i = this.getScriptPartFromCode(n);
570
- if (this.isSupportedCode(i)) return t = i;
571
- const r = this.getLanguagePartFromCode(n);
572
- if (this.isSupportedCode(r)) return t = r;
573
- t = this.options.supportedLngs.find((o) => {
574
- if (o === r) return o;
575
- if (!(o.indexOf("-") < 0 && r.indexOf("-") < 0) && (o.indexOf("-") > 0 && r.indexOf("-") < 0 && o.substring(0, o.indexOf("-")) === r || o.indexOf(r) === 0 && r.length > 1))
576
- return o;
577
- });
578
- }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
579
- }
580
- getFallbackCodes(e, t) {
581
- if (!e) return [];
582
- if (typeof e == "function" && (e = e(t)), g(e) && (e = [e]), Array.isArray(e)) return e;
583
- if (!t) return e.default || [];
584
- let n = e[t];
585
- return n || (n = e[this.getScriptPartFromCode(t)]), n || (n = e[this.formatLanguageCode(t)]), n || (n = e[this.getLanguagePartFromCode(t)]), n || (n = e.default), n || [];
586
- }
587
- toResolveHierarchy(e, t) {
588
- const n = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), i = [], r = (o) => {
589
- o && (this.isSupportedCode(o) ? i.push(o) : this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`));
590
- };
591
- return g(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && r(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && r(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && r(this.getLanguagePartFromCode(e))) : g(e) && r(this.formatLanguageCode(e)), n.forEach((o) => {
592
- i.indexOf(o) < 0 && r(this.formatLanguageCode(o));
593
- }), i;
594
- }
595
- }
596
- const Se = {
597
- zero: 0,
598
- one: 1,
599
- two: 2,
600
- few: 3,
601
- many: 4,
602
- other: 5
603
- }, ve = {
604
- select: (s) => s === 1 ? "one" : "other",
605
- resolvedOptions: () => ({
606
- pluralCategories: ["one", "other"]
607
- })
608
- };
609
- class ut {
610
- constructor(e, t = {}) {
611
- this.languageUtils = e, this.options = t, this.logger = C.create("pluralResolver"), this.pluralRulesCache = {};
612
- }
613
- addRule(e, t) {
614
- this.rules[e] = t;
615
- }
616
- clearCache() {
617
- this.pluralRulesCache = {};
618
- }
619
- getRule(e, t = {}) {
620
- const n = B(e === "dev" ? "en" : e), i = t.ordinal ? "ordinal" : "cardinal", r = JSON.stringify({
621
- cleanedCode: n,
622
- type: i
623
- });
624
- if (r in this.pluralRulesCache)
625
- return this.pluralRulesCache[r];
626
- let o;
627
- try {
628
- o = new Intl.PluralRules(n, {
629
- type: i
630
- });
631
- } catch {
632
- if (!Intl)
633
- return this.logger.error("No Intl support, please use an Intl polyfill!"), ve;
634
- if (!e.match(/-|_/)) return ve;
635
- const l = this.languageUtils.getLanguagePartFromCode(e);
636
- o = this.getRule(l, t);
637
- }
638
- return this.pluralRulesCache[r] = o, o;
639
- }
640
- needsPlural(e, t = {}) {
641
- let n = this.getRule(e, t);
642
- return n || (n = this.getRule("dev", t)), n?.resolvedOptions().pluralCategories.length > 1;
643
- }
644
- getPluralFormsOfKey(e, t, n = {}) {
645
- return this.getSuffixes(e, n).map((i) => `${t}${i}`);
646
- }
647
- getSuffixes(e, t = {}) {
648
- let n = this.getRule(e, t);
649
- return n || (n = this.getRule("dev", t)), n ? n.resolvedOptions().pluralCategories.sort((i, r) => Se[i] - Se[r]).map((i) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${i}`) : [];
650
- }
651
- getSuffix(e, t, n = {}) {
652
- const i = this.getRule(e, n);
653
- return i ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${i.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
654
- }
655
- }
656
- const we = (s, e, t, n = ".", i = !0) => {
657
- let r = et(s, e, t);
658
- return !r && i && g(t) && (r = re(s, t, n), r === void 0 && (r = re(e, t, n))), r;
659
- }, ie = (s) => s.replace(/\$/g, "$$$$");
660
- class Oe {
661
- constructor(e = {}) {
662
- this.logger = C.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((t) => t), this.init(e);
663
- }
664
- init(e = {}) {
665
- e.interpolation || (e.interpolation = {
666
- escapeValue: !0
667
- });
668
- const {
669
- escape: t,
670
- escapeValue: n,
671
- useRawValueToEscape: i,
672
- prefix: r,
673
- prefixEscaped: o,
674
- suffix: a,
675
- suffixEscaped: l,
676
- formatSeparator: u,
677
- unescapeSuffix: c,
678
- unescapePrefix: f,
679
- nestingPrefix: p,
680
- nestingPrefixEscaped: d,
681
- nestingSuffix: h,
682
- nestingSuffixEscaped: m,
683
- nestingOptionsSeparator: y,
684
- maxReplaces: w,
685
- alwaysFormat: x
686
- } = e.interpolation;
687
- this.escape = t !== void 0 ? t : nt, this.escapeValue = n !== void 0 ? n : !0, this.useRawValueToEscape = i !== void 0 ? i : !1, this.prefix = r ? A(r) : o || "{{", this.suffix = a ? A(a) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = c ? "" : f || "-", this.unescapeSuffix = this.unescapePrefix ? "" : c || "", this.nestingPrefix = p ? A(p) : d || A("$t("), this.nestingSuffix = h ? A(h) : m || A(")"), this.nestingOptionsSeparator = y || ",", this.maxReplaces = w || 1e3, this.alwaysFormat = x !== void 0 ? x : !1, this.resetRegExp();
688
- }
689
- reset() {
690
- this.options && this.init(this.options);
691
- }
692
- resetRegExp() {
693
- const e = (t, n) => t?.source === n ? (t.lastIndex = 0, t) : new RegExp(n, "g");
694
- 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}`);
695
- }
696
- interpolate(e, t, n, i) {
697
- let r, o, a;
698
- const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (d) => {
699
- if (d.indexOf(this.formatSeparator) < 0) {
700
- const w = we(t, l, d, this.options.keySeparator, this.options.ignoreJSONStructure);
701
- return this.alwaysFormat ? this.format(w, void 0, n, {
702
- ...i,
703
- ...t,
704
- interpolationkey: d
705
- }) : w;
706
- }
707
- const h = d.split(this.formatSeparator), m = h.shift().trim(), y = h.join(this.formatSeparator).trim();
708
- return this.format(we(t, l, m, this.options.keySeparator, this.options.ignoreJSONStructure), y, n, {
709
- ...i,
710
- ...t,
711
- interpolationkey: m
712
- });
713
- };
714
- this.resetRegExp();
715
- const c = i?.missingInterpolationHandler || this.options.missingInterpolationHandler, f = i?.interpolation?.skipOnVariables !== void 0 ? i.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
716
- return [{
717
- regex: this.regexpUnescape,
718
- safeValue: (d) => ie(d)
719
- }, {
720
- regex: this.regexp,
721
- safeValue: (d) => this.escapeValue ? ie(this.escape(d)) : ie(d)
722
- }].forEach((d) => {
723
- for (a = 0; r = d.regex.exec(e); ) {
724
- const h = r[1].trim();
725
- if (o = u(h), o === void 0)
726
- if (typeof c == "function") {
727
- const y = c(e, r, i);
728
- o = g(y) ? y : "";
729
- } else if (i && Object.prototype.hasOwnProperty.call(i, h))
730
- o = "";
731
- else if (f) {
732
- o = r[0];
733
- continue;
734
- } else
735
- this.logger.warn(`missed to pass in variable ${h} for interpolating ${e}`), o = "";
736
- else !g(o) && !this.useRawValueToEscape && (o = he(o));
737
- const m = d.safeValue(o);
738
- if (e = e.replace(r[0], m), f ? (d.regex.lastIndex += o.length, d.regex.lastIndex -= r[0].length) : d.regex.lastIndex = 0, a++, a >= this.maxReplaces)
739
- break;
740
- }
741
- }), e;
742
- }
743
- nest(e, t, n = {}) {
744
- let i, r, o;
745
- const a = (l, u) => {
746
- const c = this.nestingOptionsSeparator;
747
- if (l.indexOf(c) < 0) return l;
748
- const f = l.split(new RegExp(`${c}[ ]*{`));
749
- let p = `{${f[1]}`;
750
- l = f[0], p = this.interpolate(p, o);
751
- const d = p.match(/'/g), h = p.match(/"/g);
752
- ((d?.length ?? 0) % 2 === 0 && !h || h.length % 2 !== 0) && (p = p.replace(/'/g, '"'));
753
- try {
754
- o = JSON.parse(p), u && (o = {
755
- ...u,
756
- ...o
757
- });
758
- } catch (m) {
759
- return this.logger.warn(`failed parsing options string in nesting for key ${l}`, m), `${l}${c}${p}`;
760
- }
761
- return o.defaultValue && o.defaultValue.indexOf(this.prefix) > -1 && delete o.defaultValue, l;
762
- };
763
- for (; i = this.nestingRegexp.exec(e); ) {
764
- let l = [];
765
- o = {
766
- ...n
767
- }, o = o.replace && !g(o.replace) ? o.replace : o, o.applyPostProcessor = !1, delete o.defaultValue;
768
- const u = /{.*}/.test(i[1]) ? i[1].lastIndexOf("}") + 1 : i[1].indexOf(this.formatSeparator);
769
- if (u !== -1 && (l = i[1].slice(u).split(this.formatSeparator).map((c) => c.trim()).filter(Boolean), i[1] = i[1].slice(0, u)), r = t(a.call(this, i[1].trim(), o), o), r && i[0] === e && !g(r)) return r;
770
- g(r) || (r = he(r)), r || (this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`), r = ""), l.length && (r = l.reduce((c, f) => this.format(c, f, n.lng, {
771
- ...n,
772
- interpolationkey: i[1].trim()
773
- }), r.trim())), e = e.replace(i[0], r), this.regexp.lastIndex = 0;
774
- }
775
- return e;
776
- }
777
- }
778
- const ft = (s) => {
779
- let e = s.toLowerCase().trim();
780
- const t = {};
781
- if (s.indexOf("(") > -1) {
782
- const n = s.split("(");
783
- e = n[0].toLowerCase().trim();
784
- const i = n[1].substring(0, n[1].length - 1);
785
- e === "currency" && i.indexOf(":") < 0 ? t.currency || (t.currency = i.trim()) : e === "relativetime" && i.indexOf(":") < 0 ? t.range || (t.range = i.trim()) : i.split(";").forEach((o) => {
786
- if (o) {
787
- const [a, ...l] = o.split(":"), u = l.join(":").trim().replace(/^'+|'+$/g, ""), c = a.trim();
788
- t[c] || (t[c] = u), u === "false" && (t[c] = !1), u === "true" && (t[c] = !0), isNaN(u) || (t[c] = parseInt(u, 10));
789
- }
790
- });
791
- }
792
- return {
793
- formatName: e,
794
- formatOptions: t
795
- };
796
- }, Le = (s) => {
797
- const e = {};
798
- return (t, n, i) => {
799
- let r = i;
800
- i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (r = {
801
- ...r,
802
- [i.interpolationkey]: void 0
803
- });
804
- const o = n + JSON.stringify(r);
805
- let a = e[o];
806
- return a || (a = s(B(n), i), e[o] = a), a(t);
807
- };
808
- }, ct = (s) => (e, t, n) => s(B(t), n)(e);
809
- class dt {
810
- constructor(e = {}) {
811
- this.logger = C.create("formatter"), this.options = e, this.init(e);
812
- }
813
- init(e, t = {
814
- interpolation: {}
815
- }) {
816
- this.formatSeparator = t.interpolation.formatSeparator || ",";
817
- const n = t.cacheInBuiltFormats ? Le : ct;
818
- this.formats = {
819
- number: n((i, r) => {
820
- const o = new Intl.NumberFormat(i, {
821
- ...r
822
- });
823
- return (a) => o.format(a);
824
- }),
825
- currency: n((i, r) => {
826
- const o = new Intl.NumberFormat(i, {
827
- ...r,
828
- style: "currency"
829
- });
830
- return (a) => o.format(a);
831
- }),
832
- datetime: n((i, r) => {
833
- const o = new Intl.DateTimeFormat(i, {
834
- ...r
835
- });
836
- return (a) => o.format(a);
837
- }),
838
- relativetime: n((i, r) => {
839
- const o = new Intl.RelativeTimeFormat(i, {
840
- ...r
841
- });
842
- return (a) => o.format(a, r.range || "day");
843
- }),
844
- list: n((i, r) => {
845
- const o = new Intl.ListFormat(i, {
846
- ...r
847
- });
848
- return (a) => o.format(a);
849
- })
850
- };
851
- }
852
- add(e, t) {
853
- this.formats[e.toLowerCase().trim()] = t;
854
- }
855
- addCached(e, t) {
856
- this.formats[e.toLowerCase().trim()] = Le(t);
857
- }
858
- format(e, t, n, i = {}) {
859
- const r = t.split(this.formatSeparator);
860
- if (r.length > 1 && r[0].indexOf("(") > 1 && r[0].indexOf(")") < 0 && r.find((a) => a.indexOf(")") > -1)) {
861
- const a = r.findIndex((l) => l.indexOf(")") > -1);
862
- r[0] = [r[0], ...r.splice(1, a)].join(this.formatSeparator);
863
- }
864
- return r.reduce((a, l) => {
865
- const {
866
- formatName: u,
867
- formatOptions: c
868
- } = ft(l);
869
- if (this.formats[u]) {
870
- let f = a;
871
- try {
872
- const p = i?.formatParams?.[i.interpolationkey] || {}, d = p.locale || p.lng || i.locale || i.lng || n;
873
- f = this.formats[u](a, d, {
874
- ...c,
875
- ...i,
876
- ...p
877
- });
878
- } catch (p) {
879
- this.logger.warn(p);
880
- }
881
- return f;
882
- } else
883
- this.logger.warn(`there was no format function for ${u}`);
884
- return a;
885
- }, e);
886
- }
887
- }
888
- const ht = (s, e) => {
889
- s.pending[e] !== void 0 && (delete s.pending[e], s.pendingCount--);
890
- };
891
- class pt extends te {
892
- constructor(e, t, n, i = {}) {
893
- super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = i, this.logger = C.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = i.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = i.maxRetries >= 0 ? i.maxRetries : 5, this.retryTimeout = i.retryTimeout >= 1 ? i.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, i.backend, i);
894
- }
895
- queueLoad(e, t, n, i) {
896
- const r = {}, o = {}, a = {}, l = {};
897
- return e.forEach((u) => {
898
- let c = !0;
899
- t.forEach((f) => {
900
- const p = `${u}|${f}`;
901
- !n.reload && this.store.hasResourceBundle(u, f) ? this.state[p] = 2 : this.state[p] < 0 || (this.state[p] === 1 ? o[p] === void 0 && (o[p] = !0) : (this.state[p] = 1, c = !1, o[p] === void 0 && (o[p] = !0), r[p] === void 0 && (r[p] = !0), l[f] === void 0 && (l[f] = !0)));
902
- }), c || (a[u] = !0);
903
- }), (Object.keys(r).length || Object.keys(o).length) && this.queue.push({
904
- pending: o,
905
- pendingCount: Object.keys(o).length,
906
- loaded: {},
907
- errors: [],
908
- callback: i
909
- }), {
910
- toLoad: Object.keys(r),
911
- pending: Object.keys(o),
912
- toLoadLanguages: Object.keys(a),
913
- toLoadNamespaces: Object.keys(l)
914
- };
915
- }
916
- loaded(e, t, n) {
917
- const i = e.split("|"), r = i[0], o = i[1];
918
- t && this.emit("failedLoading", r, o, t), !t && n && this.store.addResourceBundle(r, o, n, void 0, void 0, {
919
- skipCopy: !0
920
- }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
921
- const a = {};
922
- this.queue.forEach((l) => {
923
- Ze(l.loaded, [r], o), ht(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
924
- a[u] || (a[u] = {});
925
- const c = l.loaded[u];
926
- c.length && c.forEach((f) => {
927
- a[u][f] === void 0 && (a[u][f] = !0);
928
- });
929
- }), l.done = !0, l.errors.length ? l.callback(l.errors) : l.callback());
930
- }), this.emit("loaded", a), this.queue = this.queue.filter((l) => !l.done);
931
- }
932
- read(e, t, n, i = 0, r = this.retryTimeout, o) {
933
- if (!e.length) return o(null, {});
934
- if (this.readingCalls >= this.maxParallelReads) {
935
- this.waitingReads.push({
936
- lng: e,
937
- ns: t,
938
- fcName: n,
939
- tried: i,
940
- wait: r,
941
- callback: o
942
- });
943
- return;
944
- }
945
- this.readingCalls++;
946
- const a = (u, c) => {
947
- if (this.readingCalls--, this.waitingReads.length > 0) {
948
- const f = this.waitingReads.shift();
949
- this.read(f.lng, f.ns, f.fcName, f.tried, f.wait, f.callback);
950
- }
951
- if (u && c && i < this.maxRetries) {
952
- setTimeout(() => {
953
- this.read.call(this, e, t, n, i + 1, r * 2, o);
954
- }, r);
955
- return;
956
- }
957
- o(u, c);
958
- }, l = this.backend[n].bind(this.backend);
959
- if (l.length === 2) {
960
- try {
961
- const u = l(e, t);
962
- u && typeof u.then == "function" ? u.then((c) => a(null, c)).catch(a) : a(null, u);
963
- } catch (u) {
964
- a(u);
965
- }
966
- return;
967
- }
968
- return l(e, t, a);
969
- }
970
- prepareLoading(e, t, n = {}, i) {
971
- if (!this.backend)
972
- return this.logger.warn("No backend was added via i18next.use. Will not load resources."), i && i();
973
- g(e) && (e = this.languageUtils.toResolveHierarchy(e)), g(t) && (t = [t]);
974
- const r = this.queueLoad(e, t, n, i);
975
- if (!r.toLoad.length)
976
- return r.pending.length || i(), null;
977
- r.toLoad.forEach((o) => {
978
- this.loadOne(o);
979
- });
980
- }
981
- load(e, t, n) {
982
- this.prepareLoading(e, t, {}, n);
983
- }
984
- reload(e, t, n) {
985
- this.prepareLoading(e, t, {
986
- reload: !0
987
- }, n);
988
- }
989
- loadOne(e, t = "") {
990
- const n = e.split("|"), i = n[0], r = n[1];
991
- this.read(i, r, "read", void 0, void 0, (o, a) => {
992
- o && this.logger.warn(`${t}loading namespace ${r} for language ${i} failed`, o), !o && a && this.logger.log(`${t}loaded namespace ${r} for language ${i}`, a), this.loaded(e, o, a);
993
- });
994
- }
995
- saveMissing(e, t, n, i, r, o = {}, a = () => {
996
- }) {
997
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
998
- 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!!!");
999
- return;
1000
- }
1001
- if (!(n == null || n === "")) {
1002
- if (this.backend?.create) {
1003
- const l = {
1004
- ...o,
1005
- isUpdate: r
1006
- }, u = this.backend.create.bind(this.backend);
1007
- if (u.length < 6)
1008
- try {
1009
- let c;
1010
- u.length === 5 ? c = u(e, t, n, i, l) : c = u(e, t, n, i), c && typeof c.then == "function" ? c.then((f) => a(null, f)).catch(a) : a(null, c);
1011
- } catch (c) {
1012
- a(c);
1013
- }
1014
- else
1015
- u(e, t, n, i, a, l);
1016
- }
1017
- !e || !e[0] || this.store.addResource(e[0], t, n, i);
1018
- }
1019
- }
1020
- }
1021
- const Pe = () => ({
1022
- debug: !1,
1023
- initAsync: !0,
1024
- ns: ["translation"],
1025
- defaultNS: ["translation"],
1026
- fallbackLng: ["dev"],
1027
- fallbackNS: !1,
1028
- supportedLngs: !1,
1029
- nonExplicitSupportedLngs: !1,
1030
- load: "all",
1031
- preload: !1,
1032
- simplifyPluralSuffix: !0,
1033
- keySeparator: ".",
1034
- nsSeparator: ":",
1035
- pluralSeparator: "_",
1036
- contextSeparator: "_",
1037
- partialBundledLanguages: !1,
1038
- saveMissing: !1,
1039
- updateMissing: !1,
1040
- saveMissingTo: "fallback",
1041
- saveMissingPlurals: !0,
1042
- missingKeyHandler: !1,
1043
- missingInterpolationHandler: !1,
1044
- postProcess: !1,
1045
- postProcessPassResolved: !1,
1046
- returnNull: !1,
1047
- returnEmptyString: !0,
1048
- returnObjects: !1,
1049
- joinArrays: !1,
1050
- returnedObjectHandler: !1,
1051
- parseMissingKeyHandler: !1,
1052
- appendNamespaceToMissingKey: !1,
1053
- appendNamespaceToCIMode: !1,
1054
- overloadTranslationOptionHandler: (s) => {
1055
- let e = {};
1056
- if (typeof s[1] == "object" && (e = s[1]), g(s[1]) && (e.defaultValue = s[1]), g(s[2]) && (e.tDescription = s[2]), typeof s[2] == "object" || typeof s[3] == "object") {
1057
- const t = s[3] || s[2];
1058
- Object.keys(t).forEach((n) => {
1059
- e[n] = t[n];
1060
- });
1061
- }
1062
- return e;
1063
- },
1064
- interpolation: {
1065
- escapeValue: !0,
1066
- format: (s) => s,
1067
- prefix: "{{",
1068
- suffix: "}}",
1069
- formatSeparator: ",",
1070
- unescapePrefix: "-",
1071
- nestingPrefix: "$t(",
1072
- nestingSuffix: ")",
1073
- nestingOptionsSeparator: ",",
1074
- maxReplaces: 1e3,
1075
- skipOnVariables: !0
1076
- },
1077
- cacheInBuiltFormats: !0
1078
- }), ke = (s) => (g(s.ns) && (s.ns = [s.ns]), g(s.fallbackLng) && (s.fallbackLng = [s.fallbackLng]), g(s.fallbackNS) && (s.fallbackNS = [s.fallbackNS]), s.supportedLngs?.indexOf?.("cimode") < 0 && (s.supportedLngs = s.supportedLngs.concat(["cimode"])), typeof s.initImmediate == "boolean" && (s.initAsync = s.initImmediate), s), W = () => {
1079
- }, gt = (s) => {
1080
- Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach((t) => {
1081
- typeof s[t] == "function" && (s[t] = s[t].bind(s));
1082
- });
1083
- };
1084
- class z extends te {
1085
- constructor(e = {}, t) {
1086
- if (super(), this.options = ke(e), this.services = {}, this.logger = C, this.modules = {
1087
- external: []
1088
- }, gt(this), t && !this.isInitialized && !e.isClone) {
1089
- if (!this.options.initAsync)
1090
- return this.init(e, t), this;
1091
- setTimeout(() => {
1092
- this.init(e, t);
1093
- }, 0);
1094
- }
1095
- }
1096
- init(e = {}, t) {
1097
- this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (g(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
1098
- const n = Pe();
1099
- this.options = {
1100
- ...n,
1101
- ...this.options,
1102
- ...ke(e)
1103
- }, this.options.interpolation = {
1104
- ...n.interpolation,
1105
- ...this.options.interpolation
1106
- }, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator);
1107
- const i = (u) => u ? typeof u == "function" ? new u() : u : null;
1108
- if (!this.options.isClone) {
1109
- this.modules.logger ? C.init(i(this.modules.logger), this.options) : C.init(null, this.options);
1110
- let u;
1111
- this.modules.formatter ? u = this.modules.formatter : u = dt;
1112
- const c = new be(this.options);
1113
- this.store = new ye(this.options.resources, this.options);
1114
- const f = this.services;
1115
- f.logger = C, f.resourceStore = this.store, f.languageUtils = c, f.pluralResolver = new ut(c, {
1116
- prepend: this.options.pluralSeparator,
1117
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1118
- }), this.options.interpolation.format && this.options.interpolation.format !== n.interpolation.format && this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === n.interpolation.format) && (f.formatter = i(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new Oe(this.options), f.utils = {
1119
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1120
- }, f.backendConnector = new pt(i(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (d, ...h) => {
1121
- this.emit(d, ...h);
1122
- }), 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 Z(this.services, this.options), this.translator.on("*", (d, ...h) => {
1123
- this.emit(d, ...h);
1124
- }), this.modules.external.forEach((d) => {
1125
- d.init && d.init(this);
1126
- });
1127
- }
1128
- if (this.format = this.options.interpolation.format, t || (t = W), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1129
- const u = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1130
- u.length > 0 && u[0] !== "dev" && (this.options.lng = u[0]);
1131
- }
1132
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((u) => {
1133
- this[u] = (...c) => this.store[u](...c);
1134
- }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((u) => {
1135
- this[u] = (...c) => (this.store[u](...c), this);
1136
- });
1137
- const a = q(), l = () => {
1138
- const u = (c, f) => {
1139
- 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), a.resolve(f), t(c, f);
1140
- };
1141
- if (this.languages && !this.isInitialized) return u(null, this.t.bind(this));
1142
- this.changeLanguage(this.options.lng, u);
1143
- };
1144
- return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), a;
1145
- }
1146
- loadResources(e, t = W) {
1147
- let n = t;
1148
- const i = g(e) ? e : this.language;
1149
- if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
1150
- if (i?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
1151
- const r = [], o = (a) => {
1152
- if (!a || a === "cimode") return;
1153
- this.services.languageUtils.toResolveHierarchy(a).forEach((u) => {
1154
- u !== "cimode" && r.indexOf(u) < 0 && r.push(u);
1155
- });
1156
- };
1157
- i ? o(i) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => o(l)), this.options.preload?.forEach?.((a) => o(a)), this.services.backendConnector.load(r, this.options.ns, (a) => {
1158
- !a && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(a);
1159
- });
1160
- } else
1161
- n(null);
1162
- }
1163
- reloadResources(e, t, n) {
1164
- const i = q();
1165
- 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, (r) => {
1166
- i.resolve(), n(r);
1167
- }), i;
1168
- }
1169
- use(e) {
1170
- if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1171
- if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1172
- 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" && He.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1173
- }
1174
- setResolvedLanguage(e) {
1175
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
1176
- for (let t = 0; t < this.languages.length; t++) {
1177
- const n = this.languages[t];
1178
- if (!(["cimode", "dev"].indexOf(n) > -1) && this.store.hasLanguageSomeTranslations(n)) {
1179
- this.resolvedLanguage = n;
1180
- break;
1181
- }
1182
- }
1183
- !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
1184
- }
1185
- }
1186
- changeLanguage(e, t) {
1187
- this.isLanguageChangingTo = e;
1188
- const n = q();
1189
- this.emit("languageChanging", e);
1190
- const i = (a) => {
1191
- this.language = a, this.languages = this.services.languageUtils.toResolveHierarchy(a), this.resolvedLanguage = void 0, this.setResolvedLanguage(a);
1192
- }, r = (a, l) => {
1193
- l ? this.isLanguageChangingTo === e && (i(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, n.resolve((...u) => this.t(...u)), t && t(a, (...u) => this.t(...u));
1194
- }, o = (a) => {
1195
- !e && !a && this.services.languageDetector && (a = []);
1196
- const l = g(a) ? a : a && a[0], u = this.store.hasLanguageSomeTranslations(l) ? l : this.services.languageUtils.getBestMatchFromCodes(g(a) ? [a] : a);
1197
- u && (this.language || i(u), this.translator.language || this.translator.changeLanguage(u), this.services.languageDetector?.cacheUserLanguage?.(u)), this.loadResources(u, (c) => {
1198
- r(c, u);
1199
- });
1200
- };
1201
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? o(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(o) : this.services.languageDetector.detect(o) : o(e), n;
1202
- }
1203
- getFixedT(e, t, n) {
1204
- const i = (r, o, ...a) => {
1205
- let l;
1206
- typeof o != "object" ? l = this.options.overloadTranslationOptionHandler([r, o].concat(a)) : l = {
1207
- ...o
1208
- }, l.lng = l.lng || i.lng, l.lngs = l.lngs || i.lngs, l.ns = l.ns || i.ns, l.keyPrefix !== "" && (l.keyPrefix = l.keyPrefix || n || i.keyPrefix);
1209
- const u = this.options.keySeparator || ".";
1210
- let c;
1211
- return l.keyPrefix && Array.isArray(r) ? c = r.map((f) => (typeof f == "function" && (f = oe(f, {
1212
- ...this.options,
1213
- ...o
1214
- })), `${l.keyPrefix}${u}${f}`)) : (typeof r == "function" && (r = oe(r, {
1215
- ...this.options,
1216
- ...o
1217
- })), c = l.keyPrefix ? `${l.keyPrefix}${u}${r}` : r), this.t(c, l);
1218
- };
1219
- return g(e) ? i.lng = e : i.lngs = e, i.ns = t, i.keyPrefix = n, i;
1220
- }
1221
- t(...e) {
1222
- return this.translator?.translate(...e);
1223
- }
1224
- exists(...e) {
1225
- return this.translator?.exists(...e);
1226
- }
1227
- setDefaultNamespace(e) {
1228
- this.options.defaultNS = e;
1229
- }
1230
- hasLoadedNamespace(e, t = {}) {
1231
- if (!this.isInitialized)
1232
- return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1233
- if (!this.languages || !this.languages.length)
1234
- return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1235
- const n = t.lng || this.resolvedLanguage || this.languages[0], i = this.options ? this.options.fallbackLng : !1, r = this.languages[this.languages.length - 1];
1236
- if (n.toLowerCase() === "cimode") return !0;
1237
- const o = (a, l) => {
1238
- const u = this.services.backendConnector.state[`${a}|${l}`];
1239
- return u === -1 || u === 0 || u === 2;
1240
- };
1241
- if (t.precheck) {
1242
- const a = t.precheck(this, o);
1243
- if (a !== void 0) return a;
1244
- }
1245
- return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || o(n, e) && (!i || o(r, e)));
1246
- }
1247
- loadNamespaces(e, t) {
1248
- const n = q();
1249
- return this.options.ns ? (g(e) && (e = [e]), e.forEach((i) => {
1250
- this.options.ns.indexOf(i) < 0 && this.options.ns.push(i);
1251
- }), this.loadResources((i) => {
1252
- n.resolve(), t && t(i);
1253
- }), n) : (t && t(), Promise.resolve());
1254
- }
1255
- loadLanguages(e, t) {
1256
- const n = q();
1257
- g(e) && (e = [e]);
1258
- const i = this.options.preload || [], r = e.filter((o) => i.indexOf(o) < 0 && this.services.languageUtils.isSupportedCode(o));
1259
- return r.length ? (this.options.preload = i.concat(r), this.loadResources((o) => {
1260
- n.resolve(), t && t(o);
1261
- }), n) : (t && t(), Promise.resolve());
1262
- }
1263
- dir(e) {
1264
- if (e || (e = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language)), !e) return "rtl";
1265
- try {
1266
- const i = new Intl.Locale(e);
1267
- if (i && i.getTextInfo) {
1268
- const r = i.getTextInfo();
1269
- if (r && r.direction) return r.direction;
1270
- }
1271
- } catch {
1272
- }
1273
- 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 = this.services?.languageUtils || new be(Pe());
1274
- return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1275
- }
1276
- static createInstance(e = {}, t) {
1277
- const n = new z(e, t);
1278
- return n.createInstance = z.createInstance, n;
1279
- }
1280
- cloneInstance(e = {}, t = W) {
1281
- const n = e.forkResourceStore;
1282
- n && delete e.forkResourceStore;
1283
- const i = {
1284
- ...this.options,
1285
- ...e,
1286
- isClone: !0
1287
- }, r = new z(i);
1288
- if ((e.debug !== void 0 || e.prefix !== void 0) && (r.logger = r.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
1289
- r[a] = this[a];
1290
- }), r.services = {
1291
- ...this.services
1292
- }, r.services.utils = {
1293
- hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
1294
- }, n) {
1295
- const a = Object.keys(this.store.data).reduce((l, u) => (l[u] = {
1296
- ...this.store.data[u]
1297
- }, l[u] = Object.keys(l[u]).reduce((c, f) => (c[f] = {
1298
- ...l[u][f]
1299
- }, c), l[u]), l), {});
1300
- r.store = new ye(a, i), r.services.resourceStore = r.store;
1301
- }
1302
- return e.interpolation && (r.services.interpolator = new Oe(i)), r.translator = new Z(r.services, i), r.translator.on("*", (a, ...l) => {
1303
- r.emit(a, ...l);
1304
- }), r.init(i, t), r.translator.options = i, r.translator.backendConnector.services.utils = {
1305
- hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
1306
- }, r;
1307
- }
1308
- toJSON() {
1309
- return {
1310
- options: this.options,
1311
- store: this.store,
1312
- language: this.language,
1313
- languages: this.languages,
1314
- resolvedLanguage: this.resolvedLanguage
1315
- };
1316
- }
1317
- }
1318
- const b = z.createInstance();
1319
- b.createInstance;
1320
- b.dir;
1321
- b.init;
1322
- b.loadResources;
1323
- b.reloadResources;
1324
- b.use;
1325
- b.changeLanguage;
1326
- b.getFixedT;
1327
- b.t;
1328
- b.exists;
1329
- b.setDefaultNamespace;
1330
- b.hasLoadedNamespace;
1331
- b.loadNamespaces;
1332
- b.loadLanguages;
1333
- const {
1334
- slice: mt,
1335
- forEach: yt
1336
- } = [];
1337
- function xt(s) {
1338
- return yt.call(mt.call(arguments, 1), (e) => {
1339
- if (e)
1340
- for (const t in e)
1341
- s[t] === void 0 && (s[t] = e[t]);
1342
- }), s;
1343
- }
1344
- function bt(s) {
1345
- return typeof s != "string" ? !1 : [/<\s*script.*?>/i, /<\s*\/\s*script\s*>/i, /<\s*img.*?on\w+\s*=/i, /<\s*\w+\s*on\w+\s*=.*?>/i, /javascript\s*:/i, /vbscript\s*:/i, /expression\s*\(/i, /eval\s*\(/i, /alert\s*\(/i, /document\.cookie/i, /document\.write\s*\(/i, /window\.location/i, /innerHTML/i].some((t) => t.test(s));
1346
- }
1347
- const Ce = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/, St = function(s, e) {
1348
- const n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
1349
- path: "/"
1350
- }, i = encodeURIComponent(e);
1351
- let r = `${s}=${i}`;
1352
- if (n.maxAge > 0) {
1353
- const o = n.maxAge - 0;
1354
- if (Number.isNaN(o)) throw new Error("maxAge should be a Number");
1355
- r += `; Max-Age=${Math.floor(o)}`;
1356
- }
1357
- if (n.domain) {
1358
- if (!Ce.test(n.domain))
1359
- throw new TypeError("option domain is invalid");
1360
- r += `; Domain=${n.domain}`;
1361
- }
1362
- if (n.path) {
1363
- if (!Ce.test(n.path))
1364
- throw new TypeError("option path is invalid");
1365
- r += `; Path=${n.path}`;
1366
- }
1367
- if (n.expires) {
1368
- if (typeof n.expires.toUTCString != "function")
1369
- throw new TypeError("option expires is invalid");
1370
- r += `; Expires=${n.expires.toUTCString()}`;
1371
- }
1372
- if (n.httpOnly && (r += "; HttpOnly"), n.secure && (r += "; Secure"), n.sameSite)
1373
- switch (typeof n.sameSite == "string" ? n.sameSite.toLowerCase() : n.sameSite) {
1374
- case !0:
1375
- r += "; SameSite=Strict";
1376
- break;
1377
- case "lax":
1378
- r += "; SameSite=Lax";
1379
- break;
1380
- case "strict":
1381
- r += "; SameSite=Strict";
1382
- break;
1383
- case "none":
1384
- r += "; SameSite=None";
1385
- break;
1386
- default:
1387
- throw new TypeError("option sameSite is invalid");
1388
- }
1389
- return n.partitioned && (r += "; Partitioned"), r;
1390
- }, Re = {
1391
- create(s, e, t, n) {
1392
- let i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
1393
- path: "/",
1394
- sameSite: "strict"
1395
- };
1396
- t && (i.expires = /* @__PURE__ */ new Date(), i.expires.setTime(i.expires.getTime() + t * 60 * 1e3)), n && (i.domain = n), document.cookie = St(s, e, i);
1397
- },
1398
- read(s) {
1399
- const e = `${s}=`, t = document.cookie.split(";");
1400
- for (let n = 0; n < t.length; n++) {
1401
- let i = t[n];
1402
- for (; i.charAt(0) === " "; ) i = i.substring(1, i.length);
1403
- if (i.indexOf(e) === 0) return i.substring(e.length, i.length);
1404
- }
1405
- return null;
1406
- },
1407
- remove(s, e) {
1408
- this.create(s, "", -1, e);
1409
- }
1410
- };
1411
- var vt = {
1412
- name: "cookie",
1413
- // Deconstruct the options object and extract the lookupCookie property
1414
- lookup(s) {
1415
- let {
1416
- lookupCookie: e
1417
- } = s;
1418
- if (e && typeof document < "u")
1419
- return Re.read(e) || void 0;
1420
- },
1421
- // Deconstruct the options object and extract the lookupCookie, cookieMinutes, cookieDomain, and cookieOptions properties
1422
- cacheUserLanguage(s, e) {
1423
- let {
1424
- lookupCookie: t,
1425
- cookieMinutes: n,
1426
- cookieDomain: i,
1427
- cookieOptions: r
1428
- } = e;
1429
- t && typeof document < "u" && Re.create(t, s, n, i, r);
1430
- }
1431
- }, wt = {
1432
- name: "querystring",
1433
- // Deconstruct the options object and extract the lookupQuerystring property
1434
- lookup(s) {
1435
- let {
1436
- lookupQuerystring: e
1437
- } = s, t;
1438
- if (typeof window < "u") {
1439
- let {
1440
- search: n
1441
- } = window.location;
1442
- !window.location.search && window.location.hash?.indexOf("?") > -1 && (n = window.location.hash.substring(window.location.hash.indexOf("?")));
1443
- const r = n.substring(1).split("&");
1444
- for (let o = 0; o < r.length; o++) {
1445
- const a = r[o].indexOf("=");
1446
- a > 0 && r[o].substring(0, a) === e && (t = r[o].substring(a + 1));
1447
- }
1448
- }
1449
- return t;
1450
- }
1451
- }, Ot = {
1452
- name: "hash",
1453
- // Deconstruct the options object and extract the lookupHash property and the lookupFromHashIndex property
1454
- lookup(s) {
1455
- let {
1456
- lookupHash: e,
1457
- lookupFromHashIndex: t
1458
- } = s, n;
1459
- if (typeof window < "u") {
1460
- const {
1461
- hash: i
1462
- } = window.location;
1463
- if (i && i.length > 2) {
1464
- const r = i.substring(1);
1465
- if (e) {
1466
- const o = r.split("&");
1467
- for (let a = 0; a < o.length; a++) {
1468
- const l = o[a].indexOf("=");
1469
- l > 0 && o[a].substring(0, l) === e && (n = o[a].substring(l + 1));
1470
- }
1471
- }
1472
- if (n) return n;
1473
- if (!n && t > -1) {
1474
- const o = i.match(/\/([a-zA-Z-]*)/g);
1475
- return Array.isArray(o) ? o[typeof t == "number" ? t : 0]?.replace("/", "") : void 0;
1476
- }
1477
- }
1478
- }
1479
- return n;
1480
- }
1481
- };
1482
- let H = null;
1483
- const je = () => {
1484
- if (H !== null) return H;
1485
- try {
1486
- if (H = typeof window < "u" && window.localStorage !== null, !H)
1487
- return !1;
1488
- const s = "i18next.translate.boo";
1489
- window.localStorage.setItem(s, "foo"), window.localStorage.removeItem(s);
1490
- } catch {
1491
- H = !1;
1492
- }
1493
- return H;
1494
- };
1495
- var Lt = {
1496
- name: "localStorage",
1497
- // Deconstruct the options object and extract the lookupLocalStorage property
1498
- lookup(s) {
1499
- let {
1500
- lookupLocalStorage: e
1501
- } = s;
1502
- if (e && je())
1503
- return window.localStorage.getItem(e) || void 0;
1504
- },
1505
- // Deconstruct the options object and extract the lookupLocalStorage property
1506
- cacheUserLanguage(s, e) {
1507
- let {
1508
- lookupLocalStorage: t
1509
- } = e;
1510
- t && je() && window.localStorage.setItem(t, s);
1511
- }
1512
- };
1513
- let K = null;
1514
- const $e = () => {
1515
- if (K !== null) return K;
1516
- try {
1517
- if (K = typeof window < "u" && window.sessionStorage !== null, !K)
1518
- return !1;
1519
- const s = "i18next.translate.boo";
1520
- window.sessionStorage.setItem(s, "foo"), window.sessionStorage.removeItem(s);
1521
- } catch {
1522
- K = !1;
1523
- }
1524
- return K;
1525
- };
1526
- var Pt = {
1527
- name: "sessionStorage",
1528
- lookup(s) {
1529
- let {
1530
- lookupSessionStorage: e
1531
- } = s;
1532
- if (e && $e())
1533
- return window.sessionStorage.getItem(e) || void 0;
1534
- },
1535
- cacheUserLanguage(s, e) {
1536
- let {
1537
- lookupSessionStorage: t
1538
- } = e;
1539
- t && $e() && window.sessionStorage.setItem(t, s);
1540
- }
1541
- }, kt = {
1542
- name: "navigator",
1543
- lookup(s) {
1544
- const e = [];
1545
- if (typeof navigator < "u") {
1546
- const {
1547
- languages: t,
1548
- userLanguage: n,
1549
- language: i
1550
- } = navigator;
1551
- if (t)
1552
- for (let r = 0; r < t.length; r++)
1553
- e.push(t[r]);
1554
- n && e.push(n), i && e.push(i);
1555
- }
1556
- return e.length > 0 ? e : void 0;
1557
- }
1558
- }, Ct = {
1559
- name: "htmlTag",
1560
- // Deconstruct the options object and extract the htmlTag property
1561
- lookup(s) {
1562
- let {
1563
- htmlTag: e
1564
- } = s, t;
1565
- const n = e || (typeof document < "u" ? document.documentElement : null);
1566
- return n && typeof n.getAttribute == "function" && (t = n.getAttribute("lang")), t;
1567
- }
1568
- }, Rt = {
1569
- name: "path",
1570
- // Deconstruct the options object and extract the lookupFromPathIndex property
1571
- lookup(s) {
1572
- let {
1573
- lookupFromPathIndex: e
1574
- } = s;
1575
- if (typeof window > "u") return;
1576
- const t = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
1577
- return Array.isArray(t) ? t[typeof e == "number" ? e : 0]?.replace("/", "") : void 0;
1578
- }
1579
- }, jt = {
1580
- name: "subdomain",
1581
- lookup(s) {
1582
- let {
1583
- lookupFromSubdomainIndex: e
1584
- } = s;
1585
- const t = typeof e == "number" ? e + 1 : 1, n = typeof window < "u" && window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
1586
- if (n)
1587
- return n[t];
1588
- }
1589
- };
1590
- let Ue = !1;
1591
- try {
1592
- document.cookie, Ue = !0;
1593
- } catch {
1594
- }
1595
- const Me = ["querystring", "cookie", "localStorage", "sessionStorage", "navigator", "htmlTag"];
1596
- Ue || Me.splice(1, 1);
1597
- const $t = () => ({
1598
- order: Me,
1599
- lookupQuerystring: "lng",
1600
- lookupCookie: "i18next",
1601
- lookupLocalStorage: "i18nextLng",
1602
- lookupSessionStorage: "i18nextLng",
1603
- // cache user language
1604
- caches: ["localStorage"],
1605
- excludeCacheFor: ["cimode"],
1606
- // cookieMinutes: 10,
1607
- // cookieDomain: 'myDomain'
1608
- convertDetectedLanguage: (s) => s
1609
- });
1610
- class Ve {
1611
- constructor(e) {
1612
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1613
- this.type = "languageDetector", this.detectors = {}, this.init(e, t);
1614
- }
1615
- init() {
1616
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1617
- languageUtils: {}
1618
- }, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1619
- this.services = e, this.options = xt(t, this.options || {}, $t()), typeof this.options.convertDetectedLanguage == "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1 && (this.options.convertDetectedLanguage = (i) => i.replace("-", "_")), this.options.lookupFromUrlIndex && (this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex), this.i18nOptions = n, this.addDetector(vt), this.addDetector(wt), this.addDetector(Lt), this.addDetector(Pt), this.addDetector(kt), this.addDetector(Ct), this.addDetector(Rt), this.addDetector(jt), this.addDetector(Ot);
1620
- }
1621
- addDetector(e) {
1622
- return this.detectors[e.name] = e, this;
1623
- }
1624
- detect() {
1625
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.order, t = [];
1626
- return e.forEach((n) => {
1627
- if (this.detectors[n]) {
1628
- let i = this.detectors[n].lookup(this.options);
1629
- i && typeof i == "string" && (i = [i]), i && (t = t.concat(i));
1630
- }
1631
- }), t = t.filter((n) => n != null && !bt(n)).map((n) => this.options.convertDetectedLanguage(n)), this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes ? t : t.length > 0 ? t[0] : null;
1632
- }
1633
- cacheUserLanguage(e) {
1634
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.caches;
1635
- t && (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(e) > -1 || t.forEach((n) => {
1636
- this.detectors[n] && this.detectors[n].cacheUserLanguage(e, this.options);
1637
- }));
1638
- }
1639
- }
1640
- Ve.type = "languageDetector";
1641
- function ae(s) {
1642
- "@babel/helpers - typeof";
1643
- return ae = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
1644
- return typeof e;
1645
- } : function(e) {
1646
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
1647
- }, ae(s);
1648
- }
1649
- function qe() {
1650
- return typeof XMLHttpRequest == "function" || (typeof XMLHttpRequest > "u" ? "undefined" : ae(XMLHttpRequest)) === "object";
1651
- }
1652
- function Et(s) {
1653
- return !!s && typeof s.then == "function";
1654
- }
1655
- function Nt(s) {
1656
- return Et(s) ? s : Promise.resolve(s);
1657
- }
1658
- function Ee(s, e) {
1659
- var t = Object.keys(s);
1660
- if (Object.getOwnPropertySymbols) {
1661
- var n = Object.getOwnPropertySymbols(s);
1662
- e && (n = n.filter(function(i) {
1663
- return Object.getOwnPropertyDescriptor(s, i).enumerable;
1664
- })), t.push.apply(t, n);
1665
- }
1666
- return t;
1667
- }
1668
- function Ne(s) {
1669
- for (var e = 1; e < arguments.length; e++) {
1670
- var t = arguments[e] != null ? arguments[e] : {};
1671
- e % 2 ? Ee(Object(t), !0).forEach(function(n) {
1672
- Ft(s, n, t[n]);
1673
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(t)) : Ee(Object(t)).forEach(function(n) {
1674
- Object.defineProperty(s, n, Object.getOwnPropertyDescriptor(t, n));
1675
- });
1676
- }
1677
- return s;
1678
- }
1679
- function Ft(s, e, t) {
1680
- return (e = Tt(e)) in s ? Object.defineProperty(s, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : s[e] = t, s;
1681
- }
1682
- function Tt(s) {
1683
- var e = It(s, "string");
1684
- return T(e) == "symbol" ? e : e + "";
1685
- }
1686
- function It(s, e) {
1687
- if (T(s) != "object" || !s) return s;
1688
- var t = s[Symbol.toPrimitive];
1689
- if (t !== void 0) {
1690
- var n = t.call(s, e);
1691
- if (T(n) != "object") return n;
1692
- throw new TypeError("@@toPrimitive must return a primitive value.");
1693
- }
1694
- return (e === "string" ? String : Number)(s);
1695
- }
1696
- function T(s) {
1697
- "@babel/helpers - typeof";
1698
- return T = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
1699
- return typeof e;
1700
- } : function(e) {
1701
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
1702
- }, T(s);
1703
- }
1704
- var E = typeof fetch == "function" ? fetch : void 0;
1705
- typeof global < "u" && global.fetch ? E = global.fetch : typeof window < "u" && window.fetch && (E = window.fetch);
1706
- var X;
1707
- qe() && (typeof global < "u" && global.XMLHttpRequest ? X = global.XMLHttpRequest : typeof window < "u" && window.XMLHttpRequest && (X = window.XMLHttpRequest));
1708
- var ee;
1709
- typeof ActiveXObject == "function" && (typeof global < "u" && global.ActiveXObject ? ee = global.ActiveXObject : typeof window < "u" && window.ActiveXObject && (ee = window.ActiveXObject));
1710
- typeof E != "function" && (E = void 0);
1711
- if (!E && !X && !ee)
1712
- try {
1713
- import("./browser-ponyfill-B6W6hHVY.js").then((s) => s.b).then(function(s) {
1714
- E = s.default;
1715
- }).catch(function() {
1716
- });
1717
- } catch {
1718
- }
1719
- var le = function(e, t) {
1720
- if (t && T(t) === "object") {
1721
- var n = "";
1722
- for (var i in t)
1723
- n += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(t[i]);
1724
- if (!n) return e;
1725
- e = e + (e.indexOf("?") !== -1 ? "&" : "?") + n.slice(1);
1726
- }
1727
- return e;
1728
- }, Fe = function(e, t, n, i) {
1729
- var r = function(l) {
1730
- if (!l.ok) return n(l.statusText || "Error", {
1731
- status: l.status
1732
- });
1733
- l.text().then(function(u) {
1734
- n(null, {
1735
- status: l.status,
1736
- data: u
1737
- });
1738
- }).catch(n);
1739
- };
1740
- if (i) {
1741
- var o = i(e, t);
1742
- if (o instanceof Promise) {
1743
- o.then(r).catch(n);
1744
- return;
1745
- }
1746
- }
1747
- typeof fetch == "function" ? fetch(e, t).then(r).catch(n) : E(e, t).then(r).catch(n);
1748
- }, Te = !1, Dt = function(e, t, n, i) {
1749
- e.queryStringParams && (t = le(t, e.queryStringParams));
1750
- var r = Ne({}, typeof e.customHeaders == "function" ? e.customHeaders() : e.customHeaders);
1751
- typeof window > "u" && typeof global < "u" && typeof global.process < "u" && global.process.versions && global.process.versions.node && (r["User-Agent"] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")")), n && (r["Content-Type"] = "application/json");
1752
- var o = typeof e.requestOptions == "function" ? e.requestOptions(n) : e.requestOptions, a = Ne({
1753
- method: n ? "POST" : "GET",
1754
- body: n ? e.stringify(n) : void 0,
1755
- headers: r
1756
- }, Te ? {} : o), l = typeof e.alternateFetch == "function" && e.alternateFetch.length >= 1 ? e.alternateFetch : void 0;
1757
- try {
1758
- Fe(t, a, i, l);
1759
- } catch (u) {
1760
- if (!o || Object.keys(o).length === 0 || !u.message || u.message.indexOf("not implemented") < 0)
1761
- return i(u);
1762
- try {
1763
- Object.keys(o).forEach(function(c) {
1764
- delete a[c];
1765
- }), Fe(t, a, i, l), Te = !0;
1766
- } catch (c) {
1767
- i(c);
1768
- }
1769
- }
1770
- }, At = function(e, t, n, i) {
1771
- n && T(n) === "object" && (n = le("", n).slice(1)), e.queryStringParams && (t = le(t, e.queryStringParams));
1772
- try {
1773
- var r = X ? new X() : new ee("MSXML2.XMLHTTP.3.0");
1774
- r.open(n ? "POST" : "GET", t, 1), e.crossDomain || r.setRequestHeader("X-Requested-With", "XMLHttpRequest"), r.withCredentials = !!e.withCredentials, n && r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), r.overrideMimeType && r.overrideMimeType("application/json");
1775
- var o = e.customHeaders;
1776
- if (o = typeof o == "function" ? o() : o, o)
1777
- for (var a in o)
1778
- r.setRequestHeader(a, o[a]);
1779
- r.onreadystatechange = function() {
1780
- r.readyState > 3 && i(r.status >= 400 ? r.statusText : null, {
1781
- status: r.status,
1782
- data: r.responseText
1783
- });
1784
- }, r.send(n);
1785
- } catch (l) {
1786
- console && console.log(l);
1787
- }
1788
- }, Ht = function(e, t, n, i) {
1789
- if (typeof n == "function" && (i = n, n = void 0), i = i || function() {
1790
- }, E && t.indexOf("file:") !== 0)
1791
- return Dt(e, t, n, i);
1792
- if (qe() || typeof ActiveXObject == "function")
1793
- return At(e, t, n, i);
1794
- i(new Error("No fetch and no xhr implementation found!"));
1795
- };
1796
- function U(s) {
1797
- "@babel/helpers - typeof";
1798
- return U = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
1799
- return typeof e;
1800
- } : function(e) {
1801
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
1802
- }, U(s);
1803
- }
1804
- function Ie(s, e) {
1805
- var t = Object.keys(s);
1806
- if (Object.getOwnPropertySymbols) {
1807
- var n = Object.getOwnPropertySymbols(s);
1808
- e && (n = n.filter(function(i) {
1809
- return Object.getOwnPropertyDescriptor(s, i).enumerable;
1810
- })), t.push.apply(t, n);
1811
- }
1812
- return t;
1813
- }
1814
- function se(s) {
1815
- for (var e = 1; e < arguments.length; e++) {
1816
- var t = arguments[e] != null ? arguments[e] : {};
1817
- e % 2 ? Ie(Object(t), !0).forEach(function(n) {
1818
- _e(s, n, t[n]);
1819
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(t)) : Ie(Object(t)).forEach(function(n) {
1820
- Object.defineProperty(s, n, Object.getOwnPropertyDescriptor(t, n));
1821
- });
1822
- }
1823
- return s;
1824
- }
1825
- function Kt(s, e) {
1826
- if (!(s instanceof e)) throw new TypeError("Cannot call a class as a function");
1827
- }
1828
- function Ut(s, e) {
1829
- for (var t = 0; t < e.length; t++) {
1830
- var n = e[t];
1831
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(s, ze(n.key), n);
1832
- }
1833
- }
1834
- function Mt(s, e, t) {
1835
- return e && Ut(s.prototype, e), Object.defineProperty(s, "prototype", { writable: !1 }), s;
1836
- }
1837
- function _e(s, e, t) {
1838
- return (e = ze(e)) in s ? Object.defineProperty(s, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : s[e] = t, s;
1839
- }
1840
- function ze(s) {
1841
- var e = Vt(s, "string");
1842
- return U(e) == "symbol" ? e : e + "";
1843
- }
1844
- function Vt(s, e) {
1845
- if (U(s) != "object" || !s) return s;
1846
- var t = s[Symbol.toPrimitive];
1847
- if (t !== void 0) {
1848
- var n = t.call(s, e);
1849
- if (U(n) != "object") return n;
1850
- throw new TypeError("@@toPrimitive must return a primitive value.");
1851
- }
1852
- return String(s);
1853
- }
1854
- var qt = function() {
1855
- return {
1856
- loadPath: "/locales/{{lng}}/{{ns}}.json",
1857
- addPath: "/locales/add/{{lng}}/{{ns}}",
1858
- parse: function(t) {
1859
- return JSON.parse(t);
1860
- },
1861
- stringify: JSON.stringify,
1862
- parsePayload: function(t, n, i) {
1863
- return _e({}, n, i || "");
1864
- },
1865
- parseLoadPayload: function(t, n) {
1866
- },
1867
- request: Ht,
1868
- reloadInterval: typeof window < "u" ? !1 : 3600 * 1e3,
1869
- customHeaders: {},
1870
- queryStringParams: {},
1871
- crossDomain: !1,
1872
- withCredentials: !1,
1873
- overrideMimeType: !1,
1874
- requestOptions: {
1875
- mode: "cors",
1876
- credentials: "same-origin",
1877
- cache: "default"
1878
- }
1879
- };
1880
- }, Be = (function() {
1881
- function s(e) {
1882
- var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1883
- Kt(this, s), this.services = e, this.options = t, this.allOptions = n, this.type = "backend", this.init(e, t, n);
1884
- }
1885
- return Mt(s, [{
1886
- key: "init",
1887
- value: function(t) {
1888
- var n = this, i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1889
- if (this.services = t, this.options = se(se(se({}, qt()), this.options || {}), i), this.allOptions = r, this.services && this.options.reloadInterval) {
1890
- var o = setInterval(function() {
1891
- return n.reload();
1892
- }, this.options.reloadInterval);
1893
- U(o) === "object" && typeof o.unref == "function" && o.unref();
1894
- }
1895
- }
1896
- }, {
1897
- key: "readMulti",
1898
- value: function(t, n, i) {
1899
- this._readAny(t, t, n, n, i);
1900
- }
1901
- }, {
1902
- key: "read",
1903
- value: function(t, n, i) {
1904
- this._readAny([t], t, [n], n, i);
1905
- }
1906
- }, {
1907
- key: "_readAny",
1908
- value: function(t, n, i, r, o) {
1909
- var a = this, l = this.options.loadPath;
1910
- typeof this.options.loadPath == "function" && (l = this.options.loadPath(t, i)), l = Nt(l), l.then(function(u) {
1911
- if (!u) return o(null, {});
1912
- var c = a.services.interpolator.interpolate(u, {
1913
- lng: t.join("+"),
1914
- ns: i.join("+")
1915
- });
1916
- a.loadUrl(c, o, n, r);
1917
- });
1918
- }
1919
- }, {
1920
- key: "loadUrl",
1921
- value: function(t, n, i, r) {
1922
- var o = this, a = typeof i == "string" ? [i] : i, l = typeof r == "string" ? [r] : r, u = this.options.parseLoadPayload(a, l);
1923
- this.options.request(this.options, t, u, function(c, f) {
1924
- if (f && (f.status >= 500 && f.status < 600 || !f.status)) return n("failed loading " + t + "; status code: " + f.status, !0);
1925
- if (f && f.status >= 400 && f.status < 500) return n("failed loading " + t + "; status code: " + f.status, !1);
1926
- if (!f && c && c.message) {
1927
- var p = c.message.toLowerCase(), d = ["failed", "fetch", "network", "load"].find(function(y) {
1928
- return p.indexOf(y) > -1;
1929
- });
1930
- if (d)
1931
- return n("failed loading " + t + ": " + c.message, !0);
1932
- }
1933
- if (c) return n(c, !1);
1934
- var h, m;
1935
- try {
1936
- typeof f.data == "string" ? h = o.options.parse(f.data, i, r) : h = f.data;
1937
- } catch {
1938
- m = "failed parsing " + t + " to json";
1939
- }
1940
- if (m) return n(m, !1);
1941
- n(null, h);
1942
- });
1943
- }
1944
- }, {
1945
- key: "create",
1946
- value: function(t, n, i, r, o) {
1947
- var a = this;
1948
- if (this.options.addPath) {
1949
- typeof t == "string" && (t = [t]);
1950
- var l = this.options.parsePayload(n, i, r), u = 0, c = [], f = [];
1951
- t.forEach(function(p) {
1952
- var d = a.options.addPath;
1953
- typeof a.options.addPath == "function" && (d = a.options.addPath(p, n));
1954
- var h = a.services.interpolator.interpolate(d, {
1955
- lng: p,
1956
- ns: n
1957
- });
1958
- a.options.request(a.options, h, l, function(m, y) {
1959
- u += 1, c.push(m), f.push(y), u === t.length && typeof o == "function" && o(c, f);
1960
- });
1961
- });
1962
- }
1963
- }
1964
- }, {
1965
- key: "reload",
1966
- value: function() {
1967
- var t = this, n = this.services, i = n.backendConnector, r = n.languageUtils, o = n.logger, a = i.language;
1968
- if (!(a && a.toLowerCase() === "cimode")) {
1969
- var l = [], u = function(f) {
1970
- var p = r.toResolveHierarchy(f);
1971
- p.forEach(function(d) {
1972
- l.indexOf(d) < 0 && l.push(d);
1973
- });
1974
- };
1975
- u(a), this.allOptions.preload && this.allOptions.preload.forEach(function(c) {
1976
- return u(c);
1977
- }), l.forEach(function(c) {
1978
- t.allOptions.ns.forEach(function(f) {
1979
- i.read(c, f, "read", null, null, function(p, d) {
1980
- p && o.warn("loading namespace ".concat(f, " for language ").concat(c, " failed"), p), !p && d && o.log("loaded namespace ".concat(f, " for language ").concat(c), d), i.loaded("".concat(c, "|").concat(f), p, d);
1981
- });
1982
- });
1983
- });
1984
- }
1985
- }
1986
- }]);
1987
- })();
1988
- Be.type = "backend";
1989
- const Xe = [
1990
- "en",
1991
- "en-DG",
1992
- "es",
1993
- "es-ES",
1994
- "sr",
1995
- "sr-Latn",
1996
- "fr",
1997
- "pt-BR",
1998
- "pt",
1999
- "bn",
2000
- "zh",
2001
- "hi",
2002
- "id",
2003
- "ms",
2004
- "tr",
2005
- "vi",
2006
- "ht",
2007
- "it",
2008
- "de",
2009
- "nl",
2010
- "tl-PH",
2011
- "pl",
2012
- "hu",
2013
- "ro",
2014
- "hmn",
2015
- "so",
2016
- "ca",
2017
- "af-ZA",
2018
- "ar",
2019
- "ar-EG",
2020
- "ar-AE",
2021
- "zh-CN",
2022
- "zh-TW",
2023
- "zh-HANT",
2024
- "cs-CZ",
2025
- "da-DK",
2026
- "fi-FI",
2027
- "fr-CA",
2028
- "el-GR",
2029
- "he",
2030
- "ja",
2031
- "ja-JP",
2032
- "ko-KP",
2033
- "nb-NO",
2034
- "fa-IR",
2035
- "pt-PT",
2036
- "ru-RU",
2037
- "sr-YU",
2038
- "es-419",
2039
- "es-MX",
2040
- "sv-SE",
2041
- "th-TH",
2042
- "uk-UA",
2043
- "am",
2044
- "az",
2045
- "bs",
2046
- "my",
2047
- "ceb",
2048
- "cs",
2049
- "et",
2050
- "ka",
2051
- "el",
2052
- "jv",
2053
- "kk",
2054
- "km",
2055
- "ko",
2056
- "ky",
2057
- "lo",
2058
- "lv",
2059
- "lt",
2060
- "mk",
2061
- "mn",
2062
- "ne",
2063
- "ru",
2064
- "sk",
2065
- "sl",
2066
- "sw",
2067
- "tl",
2068
- "th",
2069
- "uk",
2070
- "ur",
2071
- "uz",
2072
- "hr"
2073
- ], _t = (s) => {
2074
- const e = s.replace(/([A-Z])/g, " $1");
2075
- return e.charAt(0).toUpperCase() + e.slice(1);
2076
- }, zt = (s) => {
2077
- const e = s.split("."), t = e[e.length - 1];
2078
- return _t(t || "missing key");
2079
- }, Je = new Ve();
2080
- Je.addDetector({
2081
- name: "navigatorOnlyLanguage",
2082
- lookup() {
2083
- if (typeof navigator > "u")
2084
- return "en";
2085
- const s = navigator.language;
2086
- return Xe.includes(s) ? s : s.split("-")[0];
2087
- }
2088
- });
2089
- const Bt = "https://api.i18nexus.com/project_resources/translations/{{lng}}/{{ns}}.json?api_key=cg41dUINoxdp8BaHDQLJhA";
2090
- function De(s, e) {
2091
- for (const [t, n] of Object.entries(e))
2092
- n && s.addResourceBundle(t, "default", n, !0, !0);
2093
- }
2094
- function Xt(s = {}) {
2095
- const { lang: e, translations: t } = s, n = b.createInstance();
2096
- return n.use(Be).use(Je).init({
2097
- lng: e,
2098
- fallbackLng: "en",
2099
- supportedLngs: Xe,
2100
- ns: ["default"],
2101
- defaultNS: "default",
2102
- partialBundledLanguages: !0,
2103
- keySeparator: ".",
2104
- interpolation: {
2105
- escapeValue: !1
2106
- },
2107
- backend: {
2108
- loadPath: Bt
2109
- },
2110
- detection: {
2111
- order: [
2112
- "querystring",
2113
- "cookie",
2114
- "localStorage",
2115
- "sessionStorage",
2116
- "navigatorOnlyLanguage",
2117
- "htmlTag",
2118
- "path",
2119
- "subdomain"
2120
- ],
2121
- lookupQuerystring: "lang"
2122
- },
2123
- initImmediate: !1,
2124
- parseMissingKeyHandler: zt
2125
- }), t && (De(n, t), n.on("loaded", () => {
2126
- De(n, t);
2127
- })), n;
2128
- }
2129
- let Q = null;
2130
- function Jt(s) {
2131
- Q = s;
2132
- }
2133
- function Wt() {
2134
- return Q || (Q = Xt()), Q;
2135
- }
2136
- export {
2137
- Xt as c,
2138
- Wt as g,
2139
- Jt as s
2140
- };