@jaspersoft/jv-input-controls
Version:
Component for rendering input controls for a report or ad hoc view using visualize.js
1,212 lines • 3.25 MB
JavaScript
import TK, { jsx as $, jsxs as gt, Fragment as rs } from "react/jsx-runtime";
import * as F from "react";
import ye, { forwardRef as qt, useRef as SE, createContext as PA, Children as kK, createElement as ep, useMemo as a1, useState as hi, useEffect as Hm, useCallback as I$, useLayoutEffect as oS, isValidElement as HR, PureComponent as IN, Component as TE, useContext as vS, cloneElement as t_, createRef as EK, useReducer as CK } from "react";
function OK(e, t) {
for (var n = 0; n < t.length; n++) {
const a = t[n];
if (typeof a != "string" && !Array.isArray(a)) {
for (const c in a)
if (c !== "default" && !(c in e)) {
const f = Object.getOwnPropertyDescriptor(a, c);
f && Object.defineProperty(e, c, f.get ? f : {
enumerable: !0,
get: () => a[c]
});
}
}
}
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
const RK = {
type: "logger",
log(e) {
this.output("log", e);
},
warn(e) {
this.output("warn", e);
},
error(e) {
this.output("error", e);
},
output(e, t) {
console && console[e] && console[e].apply(console, t);
}
};
class g_ {
constructor(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
this.init(t, n);
}
init(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
this.prefix = n.prefix || "i18next:", this.logger = t || RK, this.options = n, this.debug = n.debug;
}
log() {
for (var t = arguments.length, n = new Array(t), a = 0; a < t; a++)
n[a] = arguments[a];
return this.forward(n, "log", "", !0);
}
warn() {
for (var t = arguments.length, n = new Array(t), a = 0; a < t; a++)
n[a] = arguments[a];
return this.forward(n, "warn", "", !0);
}
error() {
for (var t = arguments.length, n = new Array(t), a = 0; a < t; a++)
n[a] = arguments[a];
return this.forward(n, "error", "");
}
deprecate() {
for (var t = arguments.length, n = new Array(t), a = 0; a < t; a++)
n[a] = arguments[a];
return this.forward(n, "warn", "WARNING DEPRECATED: ", !0);
}
forward(t, n, a, c) {
return c && !this.debug ? null : (typeof t[0] == "string" && (t[0] = `${a}${this.prefix} ${t[0]}`), this.logger[n](t));
}
create(t) {
return new g_(this.logger, {
prefix: `${this.prefix}:${t}:`,
...this.options
});
}
clone(t) {
return t = t || this.options, t.prefix = t.prefix || this.prefix, new g_(this.logger, t);
}
}
var Xv = new g_();
class r2 {
constructor() {
this.observers = {};
}
on(t, n) {
return t.split(" ").forEach((a) => {
this.observers[a] || (this.observers[a] = /* @__PURE__ */ new Map());
const c = this.observers[a].get(n) || 0;
this.observers[a].set(n, c + 1);
}), this;
}
off(t, n) {
if (this.observers[t]) {
if (!n) {
delete this.observers[t];
return;
}
this.observers[t].delete(n);
}
}
emit(t) {
for (var n = arguments.length, a = new Array(n > 1 ? n - 1 : 0), c = 1; c < n; c++)
a[c - 1] = arguments[c];
this.observers[t] && Array.from(this.observers[t].entries()).forEach((p) => {
let [v, w] = p;
for (let x = 0; x < w; x++)
v(...a);
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach((p) => {
let [v, w] = p;
for (let x = 0; x < w; x++)
v.apply(v, [t, ...a]);
});
}
}
const yR = () => {
let e, t;
const n = new Promise((a, c) => {
e = a, t = c;
});
return n.resolve = e, n.reject = t, n;
}, L$ = (e) => e == null ? "" : "" + e, NK = (e, t, n) => {
e.forEach((a) => {
t[a] && (n[a] = t[a]);
});
}, DK = /###/g, j$ = (e) => e && e.indexOf("###") > -1 ? e.replace(DK, ".") : e, z$ = (e) => !e || typeof e == "string", WR = (e, t, n) => {
const a = typeof t != "string" ? t : t.split(".");
let c = 0;
for (; c < a.length - 1; ) {
if (z$(e)) return {};
const f = j$(a[c]);
!e[f] && n && (e[f] = new n()), Object.prototype.hasOwnProperty.call(e, f) ? e = e[f] : e = {}, ++c;
}
return z$(e) ? {} : {
obj: e,
k: j$(a[c])
};
}, F$ = (e, t, n) => {
const {
obj: a,
k: c
} = WR(e, t, Object);
if (a !== void 0 || t.length === 1) {
a[c] = n;
return;
}
let f = t[t.length - 1], p = t.slice(0, t.length - 1), v = WR(e, p, Object);
for (; v.obj === void 0 && p.length; )
f = `${p[p.length - 1]}.${f}`, p = p.slice(0, p.length - 1), v = WR(e, p, Object), v && v.obj && typeof v.obj[`${v.k}.${f}`] < "u" && (v.obj = void 0);
v.obj[`${v.k}.${f}`] = n;
}, PK = (e, t, n, a) => {
const {
obj: c,
k: f
} = WR(e, t, Object);
c[f] = c[f] || [], c[f].push(n);
}, y_ = (e, t) => {
const {
obj: n,
k: a
} = WR(e, t);
if (n)
return n[a];
}, MK = (e, t, n) => {
const a = y_(e, n);
return a !== void 0 ? a : y_(t, n);
}, pH = (e, t, n) => {
for (const a in t)
a !== "__proto__" && a !== "constructor" && (a in e ? typeof e[a] == "string" || e[a] instanceof String || typeof t[a] == "string" || t[a] instanceof String ? n && (e[a] = t[a]) : pH(e[a], t[a], n) : e[a] = t[a]);
return e;
}, xk = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var _K = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
"/": "/"
};
const IK = (e) => typeof e == "string" ? e.replace(/[&<>"'\/]/g, (t) => _K[t]) : e;
class LK {
constructor(t) {
this.capacity = t, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
}
getRegExp(t) {
const n = this.regExpMap.get(t);
if (n !== void 0)
return n;
const a = new RegExp(t);
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(t, a), this.regExpQueue.push(t), a;
}
}
const jK = [" ", ",", "?", "!", ";"], zK = new LK(20), FK = (e, t, n) => {
t = t || "", n = n || "";
const a = jK.filter((p) => t.indexOf(p) < 0 && n.indexOf(p) < 0);
if (a.length === 0) return !0;
const c = zK.getRegExp(`(${a.map((p) => p === "?" ? "\\?" : p).join("|")})`);
let f = !c.test(e);
if (!f) {
const p = e.indexOf(n);
p > 0 && !c.test(e.substring(0, p)) && (f = !0);
}
return f;
}, IF = function(e, t) {
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
if (!e) return;
if (e[t]) return e[t];
const a = t.split(n);
let c = e;
for (let f = 0; f < a.length; ) {
if (!c || typeof c != "object")
return;
let p, v = "";
for (let w = f; w < a.length; ++w)
if (w !== f && (v += n), v += a[w], p = c[v], p !== void 0) {
if (["string", "number", "boolean"].indexOf(typeof p) > -1 && w < a.length - 1)
continue;
f += w - f + 1;
break;
}
c = p;
}
return c;
}, b_ = (e) => e && e.indexOf("_") > 0 ? e.replace("_", "-") : e;
class A$ extends r2 {
constructor(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
ns: ["translation"],
defaultNS: "translation"
};
super(), this.data = t || {}, this.options = n, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
}
addNamespaces(t) {
this.options.ns.indexOf(t) < 0 && this.options.ns.push(t);
}
removeNamespaces(t) {
const n = this.options.ns.indexOf(t);
n > -1 && this.options.ns.splice(n, 1);
}
getResource(t, n, a) {
let c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
const f = c.keySeparator !== void 0 ? c.keySeparator : this.options.keySeparator, p = c.ignoreJSONStructure !== void 0 ? c.ignoreJSONStructure : this.options.ignoreJSONStructure;
let v;
t.indexOf(".") > -1 ? v = t.split(".") : (v = [t, n], a && (Array.isArray(a) ? v.push(...a) : typeof a == "string" && f ? v.push(...a.split(f)) : v.push(a)));
const w = y_(this.data, v);
return !w && !n && !a && t.indexOf(".") > -1 && (t = v[0], n = v[1], a = v.slice(2).join(".")), w || !p || typeof a != "string" ? w : IF(this.data && this.data[t] && this.data[t][n], a, f);
}
addResource(t, n, a, c) {
let f = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
silent: !1
};
const p = f.keySeparator !== void 0 ? f.keySeparator : this.options.keySeparator;
let v = [t, n];
a && (v = v.concat(p ? a.split(p) : a)), t.indexOf(".") > -1 && (v = t.split("."), c = n, n = v[1]), this.addNamespaces(n), F$(this.data, v, c), f.silent || this.emit("added", t, n, a, c);
}
addResources(t, n, a) {
let c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
silent: !1
};
for (const f in a)
(typeof a[f] == "string" || Array.isArray(a[f])) && this.addResource(t, n, f, a[f], {
silent: !0
});
c.silent || this.emit("added", t, n, a);
}
addResourceBundle(t, n, a, c, f) {
let p = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
silent: !1,
skipCopy: !1
}, v = [t, n];
t.indexOf(".") > -1 && (v = t.split("."), c = a, a = n, n = v[1]), this.addNamespaces(n);
let w = y_(this.data, v) || {};
p.skipCopy || (a = JSON.parse(JSON.stringify(a))), c ? pH(w, a, f) : w = {
...w,
...a
}, F$(this.data, v, w), p.silent || this.emit("added", t, n, a);
}
removeResourceBundle(t, n) {
this.hasResourceBundle(t, n) && delete this.data[t][n], this.removeNamespaces(n), this.emit("removed", t, n);
}
hasResourceBundle(t, n) {
return this.getResource(t, n) !== void 0;
}
getResourceBundle(t, n) {
return n || (n = this.options.defaultNS), this.options.compatibilityAPI === "v1" ? {
...this.getResource(t, n)
} : this.getResource(t, n);
}
getDataByLanguage(t) {
return this.data[t];
}
hasLanguageSomeTranslations(t) {
const n = this.getDataByLanguage(t);
return !!(n && Object.keys(n) || []).find((c) => n[c] && Object.keys(n[c]).length > 0);
}
toJSON() {
return this.data;
}
}
var hH = {
processors: {},
addPostProcessor(e) {
this.processors[e.name] = e;
},
handle(e, t, n, a, c) {
return e.forEach((f) => {
this.processors[f] && (t = this.processors[f].process(t, n, a, c));
}), t;
}
};
const V$ = {};
class w_ extends r2 {
constructor(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
super(), NK(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], t, this), this.options = n, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = Xv.create("translator");
}
changeLanguage(t) {
t && (this.language = t);
}
exists(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
interpolation: {}
};
if (t == null)
return !1;
const a = this.resolve(t, n);
return a && a.res !== void 0;
}
extractFromKey(t, n) {
let a = n.nsSeparator !== void 0 ? n.nsSeparator : this.options.nsSeparator;
a === void 0 && (a = ":");
const c = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator;
let f = n.ns || this.options.defaultNS || [];
const p = a && t.indexOf(a) > -1, v = !this.options.userDefinedKeySeparator && !n.keySeparator && !this.options.userDefinedNsSeparator && !n.nsSeparator && !FK(t, a, c);
if (p && !v) {
const w = t.match(this.interpolator.nestingRegexp);
if (w && w.length > 0)
return {
key: t,
namespaces: f
};
const x = t.split(a);
(a !== c || a === c && this.options.ns.indexOf(x[0]) > -1) && (f = x.shift()), t = x.join(c);
}
return typeof f == "string" && (f = [f]), {
key: t,
namespaces: f
};
}
translate(t, n, a) {
if (typeof n != "object" && this.options.overloadTranslationOptionHandler && (n = this.options.overloadTranslationOptionHandler(arguments)), typeof n == "object" && (n = {
...n
}), n || (n = {}), t == null) return "";
Array.isArray(t) || (t = [String(t)]);
const c = n.returnDetails !== void 0 ? n.returnDetails : this.options.returnDetails, f = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, {
key: p,
namespaces: v
} = this.extractFromKey(t[t.length - 1], n), w = v[v.length - 1], x = n.lng || this.language, E = n.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
if (x && x.toLowerCase() === "cimode") {
if (E) {
const W = n.nsSeparator || this.options.nsSeparator;
return c ? {
res: `${w}${W}${p}`,
usedKey: p,
exactUsedKey: p,
usedLng: x,
usedNS: w,
usedParams: this.getUsedParamsDetails(n)
} : `${w}${W}${p}`;
}
return c ? {
res: p,
usedKey: p,
exactUsedKey: p,
usedLng: x,
usedNS: w,
usedParams: this.getUsedParamsDetails(n)
} : p;
}
const C = this.resolve(t, n);
let N = C && C.res;
const D = C && C.usedKey || p, P = C && C.exactUsedKey || p, _ = Object.prototype.toString.apply(N), L = ["[object Number]", "[object Function]", "[object RegExp]"], V = n.joinArrays !== void 0 ? n.joinArrays : this.options.joinArrays, H = !this.i18nFormat || this.i18nFormat.handleAsObject;
if (H && N && (typeof N != "string" && typeof N != "boolean" && typeof N != "number") && L.indexOf(_) < 0 && !(typeof V == "string" && Array.isArray(N))) {
if (!n.returnObjects && !this.options.returnObjects) {
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
const W = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(D, N, {
...n,
ns: v
}) : `key '${p} (${this.language})' returned an object instead of string.`;
return c ? (C.res = W, C.usedParams = this.getUsedParamsDetails(n), C) : W;
}
if (f) {
const W = Array.isArray(N), A = W ? [] : {}, K = W ? P : D;
for (const Q in N)
if (Object.prototype.hasOwnProperty.call(N, Q)) {
const oe = `${K}${f}${Q}`;
A[Q] = this.translate(oe, {
...n,
joinArrays: !1,
ns: v
}), A[Q] === oe && (A[Q] = N[Q]);
}
N = A;
}
} else if (H && typeof V == "string" && Array.isArray(N))
N = N.join(V), N && (N = this.extendTranslation(N, t, n, a));
else {
let W = !1, A = !1;
const K = n.count !== void 0 && typeof n.count != "string", Q = w_.hasDefaultValue(n), oe = K ? this.pluralResolver.getSuffix(x, n.count, n) : "", de = n.ordinal && K ? this.pluralResolver.getSuffix(x, n.count, {
ordinal: !1
}) : "", le = K && !n.ordinal && n.count === 0 && this.pluralResolver.shouldUseIntlApi(), se = le && n[`defaultValue${this.options.pluralSeparator}zero`] || n[`defaultValue${oe}`] || n[`defaultValue${de}`] || n.defaultValue;
!this.isValidLookup(N) && Q && (W = !0, N = se), this.isValidLookup(N) || (A = !0, N = p);
const te = (n.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && A ? void 0 : N, ie = Q && se !== N && this.options.updateMissing;
if (A || W || ie) {
if (this.logger.log(ie ? "updateKey" : "missingKey", x, w, p, ie ? se : N), f) {
const X = this.resolve(p, {
...n,
keySeparator: !1
});
X && X.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.");
}
let ee = [];
const re = this.languageUtils.getFallbackCodes(this.options.fallbackLng, n.lng || this.language);
if (this.options.saveMissingTo === "fallback" && re && re[0])
for (let X = 0; X < re.length; X++)
ee.push(re[X]);
else this.options.saveMissingTo === "all" ? ee = this.languageUtils.toResolveHierarchy(n.lng || this.language) : ee.push(n.lng || this.language);
const ce = (X, ue, J) => {
const me = Q && J !== N ? J : te;
this.options.missingKeyHandler ? this.options.missingKeyHandler(X, w, ue, me, ie, n) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(X, w, ue, me, ie, n), this.emit("missingKey", X, w, ue, N);
};
this.options.saveMissing && (this.options.saveMissingPlurals && K ? ee.forEach((X) => {
const ue = this.pluralResolver.getSuffixes(X, n);
le && n[`defaultValue${this.options.pluralSeparator}zero`] && ue.indexOf(`${this.options.pluralSeparator}zero`) < 0 && ue.push(`${this.options.pluralSeparator}zero`), ue.forEach((J) => {
ce([X], p + J, n[`defaultValue${J}`] || se);
});
}) : ce(ee, p, se));
}
N = this.extendTranslation(N, t, n, C, a), A && N === p && this.options.appendNamespaceToMissingKey && (N = `${w}:${p}`), (A || W) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? N = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${w}:${p}` : p, W ? N : void 0) : N = this.options.parseMissingKeyHandler(N));
}
return c ? (C.res = N, C.usedParams = this.getUsedParamsDetails(n), C) : N;
}
extendTranslation(t, n, a, c, f) {
var p = this;
if (this.i18nFormat && this.i18nFormat.parse)
t = this.i18nFormat.parse(t, {
...this.options.interpolation.defaultVariables,
...a
}, a.lng || this.language || c.usedLng, c.usedNS, c.usedKey, {
resolved: c
});
else if (!a.skipInterpolation) {
a.interpolation && this.interpolator.init({
...a,
interpolation: {
...this.options.interpolation,
...a.interpolation
}
});
const x = typeof t == "string" && (a && a.interpolation && a.interpolation.skipOnVariables !== void 0 ? a.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
let E;
if (x) {
const N = t.match(this.interpolator.nestingRegexp);
E = N && N.length;
}
let C = a.replace && typeof a.replace != "string" ? a.replace : a;
if (this.options.interpolation.defaultVariables && (C = {
...this.options.interpolation.defaultVariables,
...C
}), t = this.interpolator.interpolate(t, C, a.lng || this.language || c.usedLng, a), x) {
const N = t.match(this.interpolator.nestingRegexp), D = N && N.length;
E < D && (a.nest = !1);
}
!a.lng && this.options.compatibilityAPI !== "v1" && c && c.res && (a.lng = this.language || c.usedLng), a.nest !== !1 && (t = this.interpolator.nest(t, function() {
for (var N = arguments.length, D = new Array(N), P = 0; P < N; P++)
D[P] = arguments[P];
return f && f[0] === D[0] && !a.context ? (p.logger.warn(`It seems you are nesting recursively key: ${D[0]} in key: ${n[0]}`), null) : p.translate(...D, n);
}, a)), a.interpolation && this.interpolator.reset();
}
const v = a.postProcess || this.options.postProcess, w = typeof v == "string" ? [v] : v;
return t != null && w && w.length && a.applyPostProcessor !== !1 && (t = hH.handle(w, t, n, this.options && this.options.postProcessPassResolved ? {
i18nResolved: {
...c,
usedParams: this.getUsedParamsDetails(a)
},
...a
} : a, this)), t;
}
resolve(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a, c, f, p, v;
return typeof t == "string" && (t = [t]), t.forEach((w) => {
if (this.isValidLookup(a)) return;
const x = this.extractFromKey(w, n), E = x.key;
c = E;
let C = x.namespaces;
this.options.fallbackNS && (C = C.concat(this.options.fallbackNS));
const N = n.count !== void 0 && typeof n.count != "string", D = N && !n.ordinal && n.count === 0 && this.pluralResolver.shouldUseIntlApi(), P = n.context !== void 0 && (typeof n.context == "string" || typeof n.context == "number") && n.context !== "", _ = n.lngs ? n.lngs : this.languageUtils.toResolveHierarchy(n.lng || this.language, n.fallbackLng);
C.forEach((L) => {
this.isValidLookup(a) || (v = L, !V$[`${_[0]}-${L}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(v) && (V$[`${_[0]}-${L}`] = !0, this.logger.warn(`key "${c}" for languages "${_.join(", ")}" won't get resolved as namespace "${v}" 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!!!")), _.forEach((V) => {
if (this.isValidLookup(a)) return;
p = V;
const H = [E];
if (this.i18nFormat && this.i18nFormat.addLookupKeys)
this.i18nFormat.addLookupKeys(H, E, V, L, n);
else {
let W;
N && (W = this.pluralResolver.getSuffix(V, n.count, n));
const A = `${this.options.pluralSeparator}zero`, K = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
if (N && (H.push(E + W), n.ordinal && W.indexOf(K) === 0 && H.push(E + W.replace(K, this.options.pluralSeparator)), D && H.push(E + A)), P) {
const Q = `${E}${this.options.contextSeparator}${n.context}`;
H.push(Q), N && (H.push(Q + W), n.ordinal && W.indexOf(K) === 0 && H.push(Q + W.replace(K, this.options.pluralSeparator)), D && H.push(Q + A));
}
}
let U;
for (; U = H.pop(); )
this.isValidLookup(a) || (f = U, a = this.getResource(V, L, U, n));
}));
});
}), {
res: a,
usedKey: c,
exactUsedKey: f,
usedLng: p,
usedNS: v
};
}
isValidLookup(t) {
return t !== void 0 && !(!this.options.returnNull && t === null) && !(!this.options.returnEmptyString && t === "");
}
getResource(t, n, a) {
let c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
return this.i18nFormat && this.i18nFormat.getResource ? this.i18nFormat.getResource(t, n, a, c) : this.resourceStore.getResource(t, n, a, c);
}
getUsedParamsDetails() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
const n = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], a = t.replace && typeof t.replace != "string";
let c = a ? t.replace : t;
if (a && typeof t.count < "u" && (c.count = t.count), this.options.interpolation.defaultVariables && (c = {
...this.options.interpolation.defaultVariables,
...c
}), !a) {
c = {
...c
};
for (const f of n)
delete c[f];
}
return c;
}
static hasDefaultValue(t) {
const n = "defaultValue";
for (const a in t)
if (Object.prototype.hasOwnProperty.call(t, a) && n === a.substring(0, n.length) && t[a] !== void 0)
return !0;
return !1;
}
}
const $z = (e) => e.charAt(0).toUpperCase() + e.slice(1);
class $$ {
constructor(t) {
this.options = t, this.supportedLngs = this.options.supportedLngs || !1, this.logger = Xv.create("languageUtils");
}
getScriptPartFromCode(t) {
if (t = b_(t), !t || t.indexOf("-") < 0) return null;
const n = t.split("-");
return n.length === 2 || (n.pop(), n[n.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(n.join("-"));
}
getLanguagePartFromCode(t) {
if (t = b_(t), !t || t.indexOf("-") < 0) return t;
const n = t.split("-");
return this.formatLanguageCode(n[0]);
}
formatLanguageCode(t) {
if (typeof t == "string" && t.indexOf("-") > -1) {
const n = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
let a = t.split("-");
return this.options.lowerCaseLng ? a = a.map((c) => c.toLowerCase()) : a.length === 2 ? (a[0] = a[0].toLowerCase(), a[1] = a[1].toUpperCase(), n.indexOf(a[1].toLowerCase()) > -1 && (a[1] = $z(a[1].toLowerCase()))) : a.length === 3 && (a[0] = a[0].toLowerCase(), a[1].length === 2 && (a[1] = a[1].toUpperCase()), a[0] !== "sgn" && a[2].length === 2 && (a[2] = a[2].toUpperCase()), n.indexOf(a[1].toLowerCase()) > -1 && (a[1] = $z(a[1].toLowerCase())), n.indexOf(a[2].toLowerCase()) > -1 && (a[2] = $z(a[2].toLowerCase()))), a.join("-");
}
return this.options.cleanCode || this.options.lowerCaseLng ? t.toLowerCase() : t;
}
isSupportedCode(t) {
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (t = this.getLanguagePartFromCode(t)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(t) > -1;
}
getBestMatchFromCodes(t) {
if (!t) return null;
let n;
return t.forEach((a) => {
if (n) return;
const c = this.formatLanguageCode(a);
(!this.options.supportedLngs || this.isSupportedCode(c)) && (n = c);
}), !n && this.options.supportedLngs && t.forEach((a) => {
if (n) return;
const c = this.getLanguagePartFromCode(a);
if (this.isSupportedCode(c)) return n = c;
n = this.options.supportedLngs.find((f) => {
if (f === c) return f;
if (!(f.indexOf("-") < 0 && c.indexOf("-") < 0) && (f.indexOf("-") > 0 && c.indexOf("-") < 0 && f.substring(0, f.indexOf("-")) === c || f.indexOf(c) === 0 && c.length > 1))
return f;
});
}), n || (n = this.getFallbackCodes(this.options.fallbackLng)[0]), n;
}
getFallbackCodes(t, n) {
if (!t) return [];
if (typeof t == "function" && (t = t(n)), typeof t == "string" && (t = [t]), Array.isArray(t)) return t;
if (!n) return t.default || [];
let a = t[n];
return a || (a = t[this.getScriptPartFromCode(n)]), a || (a = t[this.formatLanguageCode(n)]), a || (a = t[this.getLanguagePartFromCode(n)]), a || (a = t.default), a || [];
}
toResolveHierarchy(t, n) {
const a = this.getFallbackCodes(n || this.options.fallbackLng || [], t), c = [], f = (p) => {
p && (this.isSupportedCode(p) ? c.push(p) : this.logger.warn(`rejecting language code not found in supportedLngs: ${p}`));
};
return typeof t == "string" && (t.indexOf("-") > -1 || t.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && f(this.formatLanguageCode(t)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && f(this.getScriptPartFromCode(t)), this.options.load !== "currentOnly" && f(this.getLanguagePartFromCode(t))) : typeof t == "string" && f(this.formatLanguageCode(t)), a.forEach((p) => {
c.indexOf(p) < 0 && f(this.formatLanguageCode(p));
}), c;
}
}
let AK = [{
lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
nr: [1, 2],
fc: 1
}, {
lngs: ["af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en", "eo", "es", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi", "hu", "hy", "ia", "it", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr", "nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms", "ps", "pt-PT", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw", "ta", "te", "tk", "ur", "yo"],
nr: [1, 2],
fc: 2
}, {
lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
nr: [1],
fc: 3
}, {
lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
nr: [1, 2, 5],
fc: 4
}, {
lngs: ["ar"],
nr: [0, 1, 2, 3, 11, 100],
fc: 5
}, {
lngs: ["cs", "sk"],
nr: [1, 2, 5],
fc: 6
}, {
lngs: ["csb", "pl"],
nr: [1, 2, 5],
fc: 7
}, {
lngs: ["cy"],
nr: [1, 2, 3, 8],
fc: 8
}, {
lngs: ["fr"],
nr: [1, 2],
fc: 9
}, {
lngs: ["ga"],
nr: [1, 2, 3, 7, 11],
fc: 10
}, {
lngs: ["gd"],
nr: [1, 2, 3, 20],
fc: 11
}, {
lngs: ["is"],
nr: [1, 2],
fc: 12
}, {
lngs: ["jv"],
nr: [0, 1],
fc: 13
}, {
lngs: ["kw"],
nr: [1, 2, 3, 4],
fc: 14
}, {
lngs: ["lt"],
nr: [1, 2, 10],
fc: 15
}, {
lngs: ["lv"],
nr: [1, 2, 0],
fc: 16
}, {
lngs: ["mk"],
nr: [1, 2],
fc: 17
}, {
lngs: ["mnk"],
nr: [0, 1, 2],
fc: 18
}, {
lngs: ["mt"],
nr: [1, 2, 11, 20],
fc: 19
}, {
lngs: ["or"],
nr: [2, 1],
fc: 2
}, {
lngs: ["ro"],
nr: [1, 2, 20],
fc: 20
}, {
lngs: ["sl"],
nr: [5, 1, 2, 3],
fc: 21
}, {
lngs: ["he", "iw"],
nr: [1, 2, 20, 21],
fc: 22
}], VK = {
1: (e) => +(e > 1),
2: (e) => +(e != 1),
3: (e) => 0,
4: (e) => e % 10 == 1 && e % 100 != 11 ? 0 : e % 10 >= 2 && e % 10 <= 4 && (e % 100 < 10 || e % 100 >= 20) ? 1 : 2,
5: (e) => e == 0 ? 0 : e == 1 ? 1 : e == 2 ? 2 : e % 100 >= 3 && e % 100 <= 10 ? 3 : e % 100 >= 11 ? 4 : 5,
6: (e) => e == 1 ? 0 : e >= 2 && e <= 4 ? 1 : 2,
7: (e) => e == 1 ? 0 : e % 10 >= 2 && e % 10 <= 4 && (e % 100 < 10 || e % 100 >= 20) ? 1 : 2,
8: (e) => e == 1 ? 0 : e == 2 ? 1 : e != 8 && e != 11 ? 2 : 3,
9: (e) => +(e >= 2),
10: (e) => e == 1 ? 0 : e == 2 ? 1 : e < 7 ? 2 : e < 11 ? 3 : 4,
11: (e) => e == 1 || e == 11 ? 0 : e == 2 || e == 12 ? 1 : e > 2 && e < 20 ? 2 : 3,
12: (e) => +(e % 10 != 1 || e % 100 == 11),
13: (e) => +(e !== 0),
14: (e) => e == 1 ? 0 : e == 2 ? 1 : e == 3 ? 2 : 3,
15: (e) => e % 10 == 1 && e % 100 != 11 ? 0 : e % 10 >= 2 && (e % 100 < 10 || e % 100 >= 20) ? 1 : 2,
16: (e) => e % 10 == 1 && e % 100 != 11 ? 0 : e !== 0 ? 1 : 2,
17: (e) => e == 1 || e % 10 == 1 && e % 100 != 11 ? 0 : 1,
18: (e) => e == 0 ? 0 : e == 1 ? 1 : 2,
19: (e) => e == 1 ? 0 : e == 0 || e % 100 > 1 && e % 100 < 11 ? 1 : e % 100 > 10 && e % 100 < 20 ? 2 : 3,
20: (e) => e == 1 ? 0 : e == 0 || e % 100 > 0 && e % 100 < 20 ? 1 : 2,
21: (e) => e % 100 == 1 ? 1 : e % 100 == 2 ? 2 : e % 100 == 3 || e % 100 == 4 ? 3 : 0,
22: (e) => e == 1 ? 0 : e == 2 ? 1 : (e < 0 || e > 10) && e % 10 == 0 ? 2 : 3
};
const $K = ["v1", "v2", "v3"], BK = ["v4"], B$ = {
zero: 0,
one: 1,
two: 2,
few: 3,
many: 4,
other: 5
}, UK = () => {
const e = {};
return AK.forEach((t) => {
t.lngs.forEach((n) => {
e[n] = {
numbers: t.nr,
plurals: VK[t.fc]
};
});
}), e;
};
class HK {
constructor(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
this.languageUtils = t, this.options = n, this.logger = Xv.create("pluralResolver"), (!this.options.compatibilityJSON || BK.includes(this.options.compatibilityJSON)) && (typeof Intl > "u" || !Intl.PluralRules) && (this.options.compatibilityJSON = "v3", this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")), this.rules = UK(), this.pluralRulesCache = {};
}
addRule(t, n) {
this.rules[t] = n;
}
clearCache() {
this.pluralRulesCache = {};
}
getRule(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
if (this.shouldUseIntlApi())
try {
const a = b_(t === "dev" ? "en" : t), c = n.ordinal ? "ordinal" : "cardinal", f = JSON.stringify({
cleanedCode: a,
type: c
});
if (f in this.pluralRulesCache)
return this.pluralRulesCache[f];
const p = new Intl.PluralRules(a, {
type: c
});
return this.pluralRulesCache[f] = p, p;
} catch {
return;
}
return this.rules[t] || this.rules[this.languageUtils.getLanguagePartFromCode(t)];
}
needsPlural(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
const a = this.getRule(t, n);
return this.shouldUseIntlApi() ? a && a.resolvedOptions().pluralCategories.length > 1 : a && a.numbers.length > 1;
}
getPluralFormsOfKey(t, n) {
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
return this.getSuffixes(t, a).map((c) => `${n}${c}`);
}
getSuffixes(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
const a = this.getRule(t, n);
return a ? this.shouldUseIntlApi() ? a.resolvedOptions().pluralCategories.sort((c, f) => B$[c] - B$[f]).map((c) => `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${c}`) : a.numbers.map((c) => this.getSuffix(t, c, n)) : [];
}
getSuffix(t, n) {
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
const c = this.getRule(t, a);
return c ? this.shouldUseIntlApi() ? `${this.options.prepend}${a.ordinal ? `ordinal${this.options.prepend}` : ""}${c.select(n)}` : this.getSuffixRetroCompatible(c, n) : (this.logger.warn(`no plural rule found for: ${t}`), "");
}
getSuffixRetroCompatible(t, n) {
const a = t.noAbs ? t.plurals(n) : t.plurals(Math.abs(n));
let c = t.numbers[a];
this.options.simplifyPluralSuffix && t.numbers.length === 2 && t.numbers[0] === 1 && (c === 2 ? c = "plural" : c === 1 && (c = ""));
const f = () => this.options.prepend && c.toString() ? this.options.prepend + c.toString() : c.toString();
return this.options.compatibilityJSON === "v1" ? c === 1 ? "" : typeof c == "number" ? `_plural_${c.toString()}` : f() : this.options.compatibilityJSON === "v2" || this.options.simplifyPluralSuffix && t.numbers.length === 2 && t.numbers[0] === 1 ? f() : this.options.prepend && a.toString() ? this.options.prepend + a.toString() : a.toString();
}
shouldUseIntlApi() {
return !$K.includes(this.options.compatibilityJSON);
}
}
const U$ = function(e, t, n) {
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", c = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, f = MK(e, t, n);
return !f && c && typeof n == "string" && (f = IF(e, n, a), f === void 0 && (f = IF(t, n, a))), f;
}, Bz = (e) => e.replace(/\$/g, "$$$$");
class WK {
constructor() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
this.logger = Xv.create("interpolator"), this.options = t, this.format = t.interpolation && t.interpolation.format || ((n) => n), this.init(t);
}
init() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
t.interpolation || (t.interpolation = {
escapeValue: !0
});
const {
escape: n,
escapeValue: a,
useRawValueToEscape: c,
prefix: f,
prefixEscaped: p,
suffix: v,
suffixEscaped: w,
formatSeparator: x,
unescapeSuffix: E,
unescapePrefix: C,
nestingPrefix: N,
nestingPrefixEscaped: D,
nestingSuffix: P,
nestingSuffixEscaped: _,
nestingOptionsSeparator: L,
maxReplaces: V,
alwaysFormat: H
} = t.interpolation;
this.escape = n !== void 0 ? n : IK, this.escapeValue = a !== void 0 ? a : !0, this.useRawValueToEscape = c !== void 0 ? c : !1, this.prefix = f ? xk(f) : p || "{{", this.suffix = v ? xk(v) : w || "}}", this.formatSeparator = x || ",", this.unescapePrefix = E ? "" : C || "-", this.unescapeSuffix = this.unescapePrefix ? "" : E || "", this.nestingPrefix = N ? xk(N) : D || xk("$t("), this.nestingSuffix = P ? xk(P) : _ || xk(")"), this.nestingOptionsSeparator = L || ",", this.maxReplaces = V || 1e3, this.alwaysFormat = H !== void 0 ? H : !1, this.resetRegExp();
}
reset() {
this.options && this.init(this.options);
}
resetRegExp() {
const t = (n, a) => n && n.source === a ? (n.lastIndex = 0, n) : new RegExp(a, "g");
this.regexp = t(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = t(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = t(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
}
interpolate(t, n, a, c) {
let f, p, v;
const w = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, x = (D) => {
if (D.indexOf(this.formatSeparator) < 0) {
const V = U$(n, w, D, this.options.keySeparator, this.options.ignoreJSONStructure);
return this.alwaysFormat ? this.format(V, void 0, a, {
...c,
...n,
interpolationkey: D
}) : V;
}
const P = D.split(this.formatSeparator), _ = P.shift().trim(), L = P.join(this.formatSeparator).trim();
return this.format(U$(n, w, _, this.options.keySeparator, this.options.ignoreJSONStructure), L, a, {
...c,
...n,
interpolationkey: _
});
};
this.resetRegExp();
const E = c && c.missingInterpolationHandler || this.options.missingInterpolationHandler, C = c && c.interpolation && c.interpolation.skipOnVariables !== void 0 ? c.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
return [{
regex: this.regexpUnescape,
safeValue: (D) => Bz(D)
}, {
regex: this.regexp,
safeValue: (D) => this.escapeValue ? Bz(this.escape(D)) : Bz(D)
}].forEach((D) => {
for (v = 0; f = D.regex.exec(t); ) {
const P = f[1].trim();
if (p = x(P), p === void 0)
if (typeof E == "function") {
const L = E(t, f, c);
p = typeof L == "string" ? L : "";
} else if (c && Object.prototype.hasOwnProperty.call(c, P))
p = "";
else if (C) {
p = f[0];
continue;
} else
this.logger.warn(`missed to pass in variable ${P} for interpolating ${t}`), p = "";
else typeof p != "string" && !this.useRawValueToEscape && (p = L$(p));
const _ = D.safeValue(p);
if (t = t.replace(f[0], _), C ? (D.regex.lastIndex += p.length, D.regex.lastIndex -= f[0].length) : D.regex.lastIndex = 0, v++, v >= this.maxReplaces)
break;
}
}), t;
}
nest(t, n) {
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, c, f, p;
const v = (w, x) => {
const E = this.nestingOptionsSeparator;
if (w.indexOf(E) < 0) return w;
const C = w.split(new RegExp(`${E}[ ]*{`));
let N = `{${C[1]}`;
w = C[0], N = this.interpolate(N, p);
const D = N.match(/'/g), P = N.match(/"/g);
(D && D.length % 2 === 0 && !P || P.length % 2 !== 0) && (N = N.replace(/'/g, '"'));
try {
p = JSON.parse(N), x && (p = {
...x,
...p
});
} catch (_) {
return this.logger.warn(`failed parsing options string in nesting for key ${w}`, _), `${w}${E}${N}`;
}
return p.defaultValue && p.defaultValue.indexOf(this.prefix) > -1 && delete p.defaultValue, w;
};
for (; c = this.nestingRegexp.exec(t); ) {
let w = [];
p = {
...a
}, p = p.replace && typeof p.replace != "string" ? p.replace : p, p.applyPostProcessor = !1, delete p.defaultValue;
let x = !1;
if (c[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(c[1])) {
const E = c[1].split(this.formatSeparator).map((C) => C.trim());
c[1] = E.shift(), w = E, x = !0;
}
if (f = n(v.call(this, c[1].trim(), p), p), f && c[0] === t && typeof f != "string") return f;
typeof f != "string" && (f = L$(f)), f || (this.logger.warn(`missed to resolve ${c[1]} for nesting ${t}`), f = ""), x && (f = w.reduce((E, C) => this.format(E, C, a.lng, {
...a,
interpolationkey: c[1].trim()
}), f.trim())), t = t.replace(c[0], f), this.regexp.lastIndex = 0;
}
return t;
}
}
const YK = (e) => {
let t = e.toLowerCase().trim();
const n = {};
if (e.indexOf("(") > -1) {
const a = e.split("(");
t = a[0].toLowerCase().trim();
const c = a[1].substring(0, a[1].length - 1);
t === "currency" && c.indexOf(":") < 0 ? n.currency || (n.currency = c.trim()) : t === "relativetime" && c.indexOf(":") < 0 ? n.range || (n.range = c.trim()) : c.split(";").forEach((p) => {
if (p) {
const [v, ...w] = p.split(":"), x = w.join(":").trim().replace(/^'+|'+$/g, ""), E = v.trim();
n[E] || (n[E] = x), x === "false" && (n[E] = !1), x === "true" && (n[E] = !0), isNaN(x) || (n[E] = parseInt(x, 10));
}
});
}
return {
formatName: t,
formatOptions: n
};
}, Sk = (e) => {
const t = {};
return (n, a, c) => {
let f = c;
c && c.interpolationkey && c.formatParams && c.formatParams[c.interpolationkey] && c[c.interpolationkey] && (f = {
...f,
[c.interpolationkey]: void 0
});
const p = a + JSON.stringify(f);
let v = t[p];
return v || (v = e(b_(a), c), t[p] = v), v(n);
};
};
class qK {
constructor() {
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
this.logger = Xv.create("formatter"), this.options = t, this.formats = {
number: Sk((n, a) => {
const c = new Intl.NumberFormat(n, {
...a
});
return (f) => c.format(f);
}),
currency: Sk((n, a) => {
const c = new Intl.NumberFormat(n, {
...a,
style: "currency"
});
return (f) => c.format(f);
}),
datetime: Sk((n, a) => {
const c = new Intl.DateTimeFormat(n, {
...a
});
return (f) => c.format(f);
}),
relativetime: Sk((n, a) => {
const c = new Intl.RelativeTimeFormat(n, {
...a
});
return (f) => c.format(f, a.range || "day");
}),
list: Sk((n, a) => {
const c = new Intl.ListFormat(n, {
...a
});
return (f) => c.format(f);
})
}, this.init(t);
}
init(t) {
const a = (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
interpolation: {}
}).interpolation;
this.formatSeparator = a.formatSeparator ? a.formatSeparator : a.formatSeparator || ",";
}
add(t, n) {
this.formats[t.toLowerCase().trim()] = n;
}
addCached(t, n) {
this.formats[t.toLowerCase().trim()] = Sk(n);
}
format(t, n, a) {
let c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
const f = n.split(this.formatSeparator);
if (f.length > 1 && f[0].indexOf("(") > 1 && f[0].indexOf(")") < 0 && f.find((v) => v.indexOf(")") > -1)) {
const v = f.findIndex((w) => w.indexOf(")") > -1);
f[0] = [f[0], ...f.splice(1, v)].join(this.formatSeparator);
}
return f.reduce((v, w) => {
const {
formatName: x,
formatOptions: E
} = YK(w);
if (this.formats[x]) {
let C = v;
try {
const N = c && c.formatParams && c.formatParams[c.interpolationkey] || {}, D = N.locale || N.lng || c.locale || c.lng || a;
C = this.formats[x](v, D, {
...E,
...c,
...N
});
} catch (N) {
this.logger.warn(N);
}
return C;
} else
this.logger.warn(`there was no format function for ${x}`);
return v;
}, t);
}
}
const KK = (e, t) => {
e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
};
class GK extends r2 {
constructor(t, n, a) {
let c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
super(), this.backend = t, this.store = n, this.services = a, this.languageUtils = a.languageUtils, this.options = c, this.logger = Xv.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = c.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = c.maxRetries >= 0 ? c.maxRetries : 5, this.retryTimeout = c.retryTimeout >= 1 ? c.retryTimeout : 350, this.state = {}, this.queue = [], this.backend && this.backend.init && this.backend.init(a, c.backend, c);
}
queueLoad(t, n, a, c) {
const f = {}, p = {}, v = {}, w = {};
return t.forEach((x) => {
let E = !0;
n.forEach((C) => {
const N = `${x}|${C}`;
!a.reload && this.store.hasResourceBundle(x, C) ? this.state[N] = 2 : this.state[N] < 0 || (this.state[N] === 1 ? p[N] === void 0 && (p[N] = !0) : (this.state[N] = 1, E = !1, p[N] === void 0 && (p[N] = !0), f[N] === void 0 && (f[N] = !0), w[C] === void 0 && (w[C] = !0)));
}), E || (v[x] = !0);
}), (Object.keys(f).length || Object.keys(p).length) && this.queue.push({
pending: p,
pendingCount: Object.keys(p).length,
loaded: {},
errors: [],
callback: c
}), {
toLoad: Object.keys(f),
pending: Object.keys(p),
toLoadLanguages: Object.keys(v),
toLoadNamespaces: Object.keys(w)
};
}
loaded(t, n, a) {
const c = t.split("|"), f = c[0], p = c[1];
n && this.emit("failedLoading", f, p, n), !n && a && this.store.addResourceBundle(f, p, a, void 0, void 0, {
skipCopy: !0
}), this.state[t] = n ? -1 : 2, n && a && (this.state[t] = 0);
const v = {};
this.queue.forEach((w) => {
PK(w.loaded, [f], p), KK(w, t), n && w.errors.push(n), w.pendingCount === 0 && !w.done && (Object.keys(w.loaded).forEach((x) => {
v[x] || (v[x] = {});
const E = w.loaded[x];
E.length && E.forEach((C) => {
v[x][C] === void 0 && (v[x][C] = !0);
});
}), w.done = !0, w.errors.length ? w.callback(w.errors) : w.callback());
}), this.emit("loaded", v), this.queue = this.queue.filter((w) => !w.done);
}
read(t, n, a) {
let c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, f = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, p = arguments.length > 5 ? arguments[5] : void 0;
if (!t.length) return p(null, {});
if (this.readingCalls >= this.maxParallelReads) {
this.waitingReads.push({
lng: t,
ns: n,
fcName: a,
tried: c,
wait: f,
callback: p
});
return;
}
this.readingCalls++;
const v = (x, E) => {
if (this.readingCalls--, this.waitingReads.length > 0) {
const C = this.waitingReads.shift();
this.read(C.lng, C.ns, C.fcName, C.tried, C.wait, C.callback);
}
if (x && E && c < this.maxRetries) {
setTimeout(() => {
this.read.call(this, t, n, a, c + 1, f * 2, p);
}, f);
return;
}
p(x, E);
}, w = this.backend[a].bind(this.backend);
if (w.length === 2) {
try {
const x = w(t, n);
x && typeof x.then == "function" ? x.then((E) => v(null, E)).catch(v) : v(null, x);
} catch (x) {
v(x);
}
return;
}
return w(t, n, v);
}
prepareLoading(t, n) {
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, c = arguments.length > 3 ? arguments[3] : void 0;
if (!this.backend)
return this.logger.warn("No backend was added via i18next.use. Will not load resources."), c && c();
typeof t == "string" && (t = this.languageUtils.toResolveHierarchy(t)), typeof n == "string" && (n = [n]);
const f = this.queueLoad(t, n, a, c);
if (!f.toLoad.length)
return f.pending.length || c(), null;
f.toLoad.forEach((p) => {
this.loadOne(p);
});
}
load(t, n, a) {
this.prepareLoading(t, n, {}, a);
}
reload(t, n, a) {
this.prepareLoading(t, n, {
reload: !0
}, a);
}
loadOne(t) {
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
const a = t.split("|"), c = a[0], f = a[1];
this.read(c, f, "read", void 0, void 0, (p, v) => {
p && this.logger.warn(`${n}loading namespace ${f} for language ${c} failed`, p), !p && v && this.logger.log(`${n}loaded namespace ${f} for language ${c}`, v), this.loaded(t, p, v);
});
}
saveMissing(t, n, a, c, f) {
let p = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, v = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
};
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(n)) {
this.logger.warn(`did not save key "${a}" as the namespace "${n}" 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!!!");
return;
}
if (!(a == null || a === "")) {
if (this.backend && this.backend.create) {
const w = {
...p,
isUpdate: f
}, x = this.backend.create.bind(this.backend);
if (x.length < 6)
try {
let E;
x.length === 5 ? E = x(t, n, a, c, w) : E = x(t, n, a, c), E && typeof E.then == "function" ? E.then((C) => v(null, C)).catch(v) : v(null, E);
} catch (E) {
v(E);
}
else
x(t, n, a, c, v, w);
}
!t || !t[0] || this.store.addResource(t[0], n, a, c);
}
}
}
const H$ = () => ({
debug: !1,
initImmediate: !0,
ns: ["translation"],
defaultNS: ["translation"],
fallbackLng: ["dev"],
fallbackNS: !1,
supportedLngs: !1,
nonExplicitSupportedLngs: !1,
load: "all",
preload: !1,
simplifyPluralSuffix: !0,
keySeparator: ".",
nsSeparator: ":",
pluralSeparator: "_",
contextSeparator: "_",
partialBundledLanguages: !1,
saveMissing: !1,
updateMissing: !1,
saveMissingTo: "fallback",
saveMissingPlurals: !0,
missingKeyHandler: !1,
missingInterpolationHandler: !1,
postProcess: !1,
postProcessPassResolved: !1,
returnNull: !1,
returnEmptyString: !0,
returnObjects: !1,