@connectycube/chat-widget
Version:
A React component that seamlessly integrates ConnectyCube's real-time chat capabilities into your web applications. This widget offers an out-of-the-box solution for embedding chat features—such as instant messaging, user presence, and file sharing—withou
1,333 lines (1,330 loc) • 1.65 MB
JavaScript
import * as C from "react";
import Y, { createContext as hc, useContext as mc, useCallback as sA, useState as Oq, useRef as bq, useEffect as pq, useLayoutEffect as Ic, useMemo as Yq, forwardRef as wc, createElement as Yo, memo as tn } from "react";
import aq from "connectycube";
import * as Ec from "react-dom";
import yc, { createPortal as Ap } from "react-dom";
function RA(q, A) {
for (var e = 0; e < A.length; e++) {
const t = A[e];
if (typeof t != "string" && !Array.isArray(t)) {
for (const V in t)
if (V !== "default" && !(V in q)) {
const r = Object.getOwnPropertyDescriptor(t, V);
r && Object.defineProperty(q, V, r.get ? r : {
enumerable: !0,
get: () => t[V]
});
}
}
}
return Object.freeze(Object.defineProperty(q, Symbol.toStringTag, { value: "Module" }));
}
var Gn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function CA(q) {
return q && q.__esModule && Object.prototype.hasOwnProperty.call(q, "default") ? q.default : q;
}
function ep(q) {
if (Object.prototype.hasOwnProperty.call(q, "__esModule")) return q;
var A = q.default;
if (typeof A == "function") {
var e = function t() {
return this instanceof t ? Reflect.construct(A, arguments, this.constructor) : A.apply(this, arguments);
};
e.prototype = A.prototype;
} else e = {};
return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(q).forEach(function(t) {
var V = Object.getOwnPropertyDescriptor(q, t);
Object.defineProperty(e, t, V.get ? V : {
enumerable: !0,
get: function() {
return q[t];
}
});
}), e;
}
var TV = { exports: {} }, Yt = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Cs;
function tp() {
if (Cs) return Yt;
Cs = 1;
var q = Y, A = Symbol.for("react.element"), e = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, V = q.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, r = { key: !0, ref: !0, __self: !0, __source: !0 };
function n(o, s, i) {
var l, a = {}, g = null, I = null;
i !== void 0 && (g = "" + i), s.key !== void 0 && (g = "" + s.key), s.ref !== void 0 && (I = s.ref);
for (l in s) t.call(s, l) && !r.hasOwnProperty(l) && (a[l] = s[l]);
if (o && o.defaultProps) for (l in s = o.defaultProps, s) a[l] === void 0 && (a[l] = s[l]);
return { $$typeof: A, type: o, key: g, ref: I, props: a, _owner: V.current };
}
return Yt.Fragment = e, Yt.jsx = n, Yt.jsxs = n, Yt;
}
var Kt = {}, Ms;
function Vp() {
if (Ms) return Kt;
Ms = 1;
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
return "production".NODE_ENV !== "production" && function() {
var q = Y, A = Symbol.for("react.element"), e = Symbol.for("react.portal"), t = Symbol.for("react.fragment"), V = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), n = Symbol.for("react.provider"), o = Symbol.for("react.context"), s = Symbol.for("react.forward_ref"), i = Symbol.for("react.suspense"), l = Symbol.for("react.suspense_list"), a = Symbol.for("react.memo"), g = Symbol.for("react.lazy"), I = Symbol.for("react.offscreen"), m = Symbol.iterator, f = "@@iterator";
function E(Q) {
if (Q === null || typeof Q != "object")
return null;
var eq = m && Q[m] || Q[f];
return typeof eq == "function" ? eq : null;
}
var w = q.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function p(Q) {
{
for (var eq = arguments.length, lq = new Array(eq > 1 ? eq - 1 : 0), mq = 1; mq < eq; mq++)
lq[mq - 1] = arguments[mq];
h("error", Q, lq);
}
}
function h(Q, eq, lq) {
{
var mq = w.ReactDebugCurrentFrame, Dq = mq.getStackAddendum();
Dq !== "" && (eq += "%s", lq = lq.concat([Dq]));
var Pq = lq.map(function(kq) {
return String(kq);
});
Pq.unshift("Warning: " + eq), Function.prototype.apply.call(console[Q], console, Pq);
}
}
var d = !1, c = !1, y = !1, v = !1, M = !1, x;
x = Symbol.for("react.module.reference");
function O(Q) {
return !!(typeof Q == "string" || typeof Q == "function" || Q === t || Q === r || M || Q === V || Q === i || Q === l || v || Q === I || d || c || y || typeof Q == "object" && Q !== null && (Q.$$typeof === g || Q.$$typeof === a || Q.$$typeof === n || Q.$$typeof === o || Q.$$typeof === s || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
Q.$$typeof === x || Q.getModuleId !== void 0));
}
function N(Q, eq, lq) {
var mq = Q.displayName;
if (mq)
return mq;
var Dq = eq.displayName || eq.name || "";
return Dq !== "" ? lq + "(" + Dq + ")" : lq;
}
function j(Q) {
return Q.displayName || "Context";
}
function P(Q) {
if (Q == null)
return null;
if (typeof Q.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof Q == "function")
return Q.displayName || Q.name || null;
if (typeof Q == "string")
return Q;
switch (Q) {
case t:
return "Fragment";
case e:
return "Portal";
case r:
return "Profiler";
case V:
return "StrictMode";
case i:
return "Suspense";
case l:
return "SuspenseList";
}
if (typeof Q == "object")
switch (Q.$$typeof) {
case o:
var eq = Q;
return j(eq) + ".Consumer";
case n:
var lq = Q;
return j(lq._context) + ".Provider";
case s:
return N(Q, Q.render, "ForwardRef");
case a:
var mq = Q.displayName || null;
return mq !== null ? mq : P(Q.type) || "Memo";
case g: {
var Dq = Q, Pq = Dq._payload, kq = Dq._init;
try {
return P(kq(Pq));
} catch {
return null;
}
}
}
return null;
}
var b = Object.assign, B = 0, T, W, F, G, R, k, K;
function Z() {
}
Z.__reactDisabledLog = !0;
function qq() {
{
if (B === 0) {
T = console.log, W = console.info, F = console.warn, G = console.error, R = console.group, k = console.groupCollapsed, K = console.groupEnd;
var Q = {
configurable: !0,
enumerable: !0,
value: Z,
writable: !0
};
Object.defineProperties(console, {
info: Q,
log: Q,
warn: Q,
error: Q,
group: Q,
groupCollapsed: Q,
groupEnd: Q
});
}
B++;
}
}
function H() {
{
if (B--, B === 0) {
var Q = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: b({}, Q, {
value: T
}),
info: b({}, Q, {
value: W
}),
warn: b({}, Q, {
value: F
}),
error: b({}, Q, {
value: G
}),
group: b({}, Q, {
value: R
}),
groupCollapsed: b({}, Q, {
value: k
}),
groupEnd: b({}, Q, {
value: K
})
});
}
B < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var _ = w.ReactCurrentDispatcher, Vq;
function iq(Q, eq, lq) {
{
if (Vq === void 0)
try {
throw Error();
} catch (Dq) {
var mq = Dq.stack.trim().match(/\n( *(at )?)/);
Vq = mq && mq[1] || "";
}
return `
` + Vq + Q;
}
}
var sq = !1, Aq;
{
var gq = typeof WeakMap == "function" ? WeakMap : Map;
Aq = new gq();
}
function $(Q, eq) {
if (!Q || sq)
return "";
{
var lq = Aq.get(Q);
if (lq !== void 0)
return lq;
}
var mq;
sq = !0;
var Dq = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var Pq;
Pq = _.current, _.current = null, qq();
try {
if (eq) {
var kq = function() {
throw Error();
};
if (Object.defineProperty(kq.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(kq, []);
} catch (bA) {
mq = bA;
}
Reflect.construct(Q, [], kq);
} else {
try {
kq.call();
} catch (bA) {
mq = bA;
}
Q.call(kq.prototype);
}
} else {
try {
throw Error();
} catch (bA) {
mq = bA;
}
Q();
}
} catch (bA) {
if (bA && mq && typeof bA.stack == "string") {
for (var vq = bA.stack.split(`
`), IA = mq.stack.split(`
`), _q = vq.length - 1, qA = IA.length - 1; _q >= 1 && qA >= 0 && vq[_q] !== IA[qA]; )
qA--;
for (; _q >= 1 && qA >= 0; _q--, qA--)
if (vq[_q] !== IA[qA]) {
if (_q !== 1 || qA !== 1)
do
if (_q--, qA--, qA < 0 || vq[_q] !== IA[qA]) {
var LA = `
` + vq[_q].replace(" at new ", " at ");
return Q.displayName && LA.includes("<anonymous>") && (LA = LA.replace("<anonymous>", Q.displayName)), typeof Q == "function" && Aq.set(Q, LA), LA;
}
while (_q >= 1 && qA >= 0);
break;
}
}
} finally {
sq = !1, _.current = Pq, H(), Error.prepareStackTrace = Dq;
}
var pt = Q ? Q.displayName || Q.name : "", _e = pt ? iq(pt) : "";
return typeof Q == "function" && Aq.set(Q, _e), _e;
}
function Bq(Q, eq, lq) {
return $(Q, !1);
}
function Zq(Q) {
var eq = Q.prototype;
return !!(eq && eq.isReactComponent);
}
function oA(Q, eq, lq) {
if (Q == null)
return "";
if (typeof Q == "function")
return $(Q, Zq(Q));
if (typeof Q == "string")
return iq(Q);
switch (Q) {
case i:
return iq("Suspense");
case l:
return iq("SuspenseList");
}
if (typeof Q == "object")
switch (Q.$$typeof) {
case s:
return Bq(Q.render);
case a:
return oA(Q.type, eq, lq);
case g: {
var mq = Q, Dq = mq._payload, Pq = mq._init;
try {
return oA(Pq(Dq), eq, lq);
} catch {
}
}
}
return "";
}
var BA = Object.prototype.hasOwnProperty, vA = {}, ee = w.ReactDebugCurrentFrame;
function Jq(Q) {
if (Q) {
var eq = Q._owner, lq = oA(Q.type, Q._source, eq ? eq.type : null);
ee.setExtraStackFrame(lq);
} else
ee.setExtraStackFrame(null);
}
function D(Q, eq, lq, mq, Dq) {
{
var Pq = Function.call.bind(BA);
for (var kq in Q)
if (Pq(Q, kq)) {
var vq = void 0;
try {
if (typeof Q[kq] != "function") {
var IA = Error((mq || "React class") + ": " + lq + " type `" + kq + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof Q[kq] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw IA.name = "Invariant Violation", IA;
}
vq = Q[kq](eq, kq, mq, lq, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (_q) {
vq = _q;
}
vq && !(vq instanceof Error) && (Jq(Dq), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", mq || "React class", lq, kq, typeof vq), Jq(null)), vq instanceof Error && !(vq.message in vA) && (vA[vq.message] = !0, Jq(Dq), p("Failed %s type: %s", lq, vq.message), Jq(null));
}
}
}
var L = Array.isArray;
function z(Q) {
return L(Q);
}
function oq(Q) {
{
var eq = typeof Symbol == "function" && Symbol.toStringTag, lq = eq && Q[Symbol.toStringTag] || Q.constructor.name || "Object";
return lq;
}
}
function nq(Q) {
try {
return S(Q), !1;
} catch {
return !0;
}
}
function S(Q) {
return "" + Q;
}
function U(Q) {
if (nq(Q))
return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", oq(Q)), S(Q);
}
var X = w.ReactCurrentOwner, J = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, rq, cq;
function wq(Q) {
if (BA.call(Q, "ref")) {
var eq = Object.getOwnPropertyDescriptor(Q, "ref").get;
if (eq && eq.isReactWarning)
return !1;
}
return Q.ref !== void 0;
}
function Gq(Q) {
if (BA.call(Q, "key")) {
var eq = Object.getOwnPropertyDescriptor(Q, "key").get;
if (eq && eq.isReactWarning)
return !1;
}
return Q.key !== void 0;
}
function Cq(Q, eq) {
typeof Q.ref == "string" && X.current;
}
function xq(Q, eq) {
{
var lq = function() {
rq || (rq = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", eq));
};
lq.isReactWarning = !0, Object.defineProperty(Q, "key", {
get: lq,
configurable: !0
});
}
}
function Kq(Q, eq) {
{
var lq = function() {
cq || (cq = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", eq));
};
lq.isReactWarning = !0, Object.defineProperty(Q, "ref", {
get: lq,
configurable: !0
});
}
}
var cA = function(Q, eq, lq, mq, Dq, Pq, kq) {
var vq = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: A,
// Built-in properties that belong on the element
type: Q,
key: eq,
ref: lq,
props: kq,
// Record the component responsible for creating this element.
_owner: Pq
};
return vq._store = {}, Object.defineProperty(vq._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(vq, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: mq
}), Object.defineProperty(vq, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: Dq
}), Object.freeze && (Object.freeze(vq.props), Object.freeze(vq)), vq;
};
function Ze(Q, eq, lq, mq, Dq) {
{
var Pq, kq = {}, vq = null, IA = null;
lq !== void 0 && (U(lq), vq = "" + lq), Gq(eq) && (U(eq.key), vq = "" + eq.key), wq(eq) && (IA = eq.ref, Cq(eq, Dq));
for (Pq in eq)
BA.call(eq, Pq) && !J.hasOwnProperty(Pq) && (kq[Pq] = eq[Pq]);
if (Q && Q.defaultProps) {
var _q = Q.defaultProps;
for (Pq in _q)
kq[Pq] === void 0 && (kq[Pq] = _q[Pq]);
}
if (vq || IA) {
var qA = typeof Q == "function" ? Q.displayName || Q.name || "Unknown" : Q;
vq && xq(kq, qA), IA && Kq(kq, qA);
}
return cA(Q, vq, IA, Dq, mq, X.current, kq);
}
}
var te = w.ReactCurrentOwner, JA = w.ReactDebugCurrentFrame;
function Qe(Q) {
if (Q) {
var eq = Q._owner, lq = oA(Q.type, Q._source, eq ? eq.type : null);
JA.setExtraStackFrame(lq);
} else
JA.setExtraStackFrame(null);
}
var Ft;
Ft = !1;
function ft(Q) {
return typeof Q == "object" && Q !== null && Q.$$typeof === A;
}
function Lt() {
{
if (te.current) {
var Q = P(te.current.type);
if (Q)
return `
Check the render method of \`` + Q + "`.";
}
return "";
}
}
function Eq(Q) {
return "";
}
var Xq = {};
function aA(Q) {
{
var eq = Lt();
if (!eq) {
var lq = typeof Q == "string" ? Q : Q.displayName || Q.name;
lq && (eq = `
Check the top-level render call using <` + lq + ">.");
}
return eq;
}
}
function uA(Q, eq) {
{
if (!Q._store || Q._store.validated || Q.key != null)
return;
Q._store.validated = !0;
var lq = aA(eq);
if (Xq[lq])
return;
Xq[lq] = !0;
var mq = "";
Q && Q._owner && Q._owner !== te.current && (mq = " It was passed a child from " + P(Q._owner.type) + "."), Qe(Q), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', lq, mq), Qe(null);
}
}
function He(Q, eq) {
{
if (typeof Q != "object")
return;
if (z(Q))
for (var lq = 0; lq < Q.length; lq++) {
var mq = Q[lq];
ft(mq) && uA(mq, eq);
}
else if (ft(Q))
Q._store && (Q._store.validated = !0);
else if (Q) {
var Dq = E(Q);
if (typeof Dq == "function" && Dq !== Q.entries)
for (var Pq = Dq.call(Q), kq; !(kq = Pq.next()).done; )
ft(kq.value) && uA(kq.value, eq);
}
}
}
function tA(Q) {
{
var eq = Q.type;
if (eq == null || typeof eq == "string")
return;
var lq;
if (typeof eq == "function")
lq = eq.propTypes;
else if (typeof eq == "object" && (eq.$$typeof === s || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
eq.$$typeof === a))
lq = eq.propTypes;
else
return;
if (lq) {
var mq = P(eq);
D(lq, Q.props, "prop", mq, Q);
} else if (eq.PropTypes !== void 0 && !Ft) {
Ft = !0;
var Dq = P(eq);
p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", Dq || "Unknown");
}
typeof eq.getDefaultProps == "function" && !eq.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function SA(Q) {
{
for (var eq = Object.keys(Q.props), lq = 0; lq < eq.length; lq++) {
var mq = eq[lq];
if (mq !== "children" && mq !== "key") {
Qe(Q), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", mq), Qe(null);
break;
}
}
Q.ref !== null && (Qe(Q), p("Invalid attribute `ref` supplied to `React.Fragment`."), Qe(null));
}
}
var Xe = {};
function xA(Q, eq, lq, mq, Dq, Pq) {
{
var kq = O(Q);
if (!kq) {
var vq = "";
(Q === void 0 || typeof Q == "object" && Q !== null && Object.keys(Q).length === 0) && (vq += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var IA = Eq();
IA ? vq += IA : vq += Lt();
var _q;
Q === null ? _q = "null" : z(Q) ? _q = "array" : Q !== void 0 && Q.$$typeof === A ? (_q = "<" + (P(Q.type) || "Unknown") + " />", vq = " Did you accidentally export a JSX literal instead of a component?") : _q = typeof Q, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", _q, vq);
}
var qA = Ze(Q, eq, lq, Dq, Pq);
if (qA == null)
return qA;
if (kq) {
var LA = eq.children;
if (LA !== void 0)
if (mq)
if (z(LA)) {
for (var pt = 0; pt < LA.length; pt++)
He(LA[pt], Q);
Object.freeze && Object.freeze(LA);
} else
p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
else
He(LA, Q);
}
if (BA.call(eq, "key")) {
var _e = P(Q), bA = Object.keys(eq).filter(function(qp) {
return qp !== "key";
}), On = bA.length > 0 ? "{key: someKey, " + bA.join(": ..., ") + ": ...}" : "{key: someKey}";
if (!Xe[_e + On]) {
var $f = bA.length > 0 ? "{" + bA.join(": ..., ") + ": ...}" : "{}";
p(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`, On, _e, $f, _e), Xe[_e + On] = !0;
}
}
return Q === t ? SA(qA) : tA(qA), qA;
}
}
function OA(Q, eq, lq) {
return xA(Q, eq, lq, !0);
}
function QV(Q, eq, lq) {
return xA(Q, eq, lq, !1);
}
var me = QV, ys = OA;
Kt.Fragment = t, Kt.jsx = me, Kt.jsxs = ys;
}(), Kt;
}
var Bs;
function rp() {
return Bs || (Bs = 1, "production".NODE_ENV === "production" ? TV.exports = tp() : TV.exports = Vp()), TV.exports;
}
var u = rp();
const Iq = (q) => typeof q == "string", zt = () => {
let q, A;
const e = new Promise((t, V) => {
q = t, A = V;
});
return e.resolve = q, e.reject = A, e;
}, vs = (q) => q == null ? "" : "" + q, np = (q, A, e) => {
q.forEach((t) => {
A[t] && (e[t] = A[t]);
});
}, op = /###/g, Ss = (q) => q && q.indexOf("###") > -1 ? q.replace(op, ".") : q, xs = (q) => !q || Iq(q), rV = (q, A, e) => {
const t = Iq(A) ? A.split(".") : A;
let V = 0;
for (; V < t.length - 1; ) {
if (xs(q)) return {};
const r = Ss(t[V]);
!q[r] && e && (q[r] = new e()), Object.prototype.hasOwnProperty.call(q, r) ? q = q[r] : q = {}, ++V;
}
return xs(q) ? {} : {
obj: q,
k: Ss(t[V])
};
}, bs = (q, A, e) => {
const {
obj: t,
k: V
} = rV(q, A, Object);
if (t !== void 0 || A.length === 1) {
t[V] = e;
return;
}
let r = A[A.length - 1], n = A.slice(0, A.length - 1), o = rV(q, n, Object);
for (; o.obj === void 0 && n.length; )
r = `${n[n.length - 1]}.${r}`, n = n.slice(0, n.length - 1), o = rV(q, n, Object), o != null && o.obj && typeof o.obj[`${o.k}.${r}`] < "u" && (o.obj = void 0);
o.obj[`${o.k}.${r}`] = e;
}, ap = (q, A, e, t) => {
const {
obj: V,
k: r
} = rV(q, A, Object);
V[r] = V[r] || [], V[r].push(e);
}, ur = (q, A) => {
const {
obj: e,
k: t
} = rV(q, A);
if (e && Object.prototype.hasOwnProperty.call(e, t))
return e[t];
}, sp = (q, A, e) => {
const t = ur(q, e);
return t !== void 0 ? t : ur(A, e);
}, Cc = (q, A, e) => {
for (const t in A)
t !== "__proto__" && t !== "constructor" && (t in q ? Iq(q[t]) || q[t] instanceof String || Iq(A[t]) || A[t] instanceof String ? e && (q[t] = A[t]) : Cc(q[t], A[t], e) : q[t] = A[t]);
return q;
}, ht = (q) => q.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var ip = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
"/": "/"
};
const lp = (q) => Iq(q) ? q.replace(/[&<>"'\/]/g, (A) => ip[A]) : q;
class cp {
constructor(A) {
this.capacity = A, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
}
getRegExp(A) {
const e = this.regExpMap.get(A);
if (e !== void 0)
return e;
const t = new RegExp(A);
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(A, t), this.regExpQueue.push(A), t;
}
}
const up = [" ", ",", "?", "!", ";"], dp = new cp(20), gp = (q, A, e) => {
A = A || "", e = e || "";
const t = up.filter((n) => A.indexOf(n) < 0 && e.indexOf(n) < 0);
if (t.length === 0) return !0;
const V = dp.getRegExp(`(${t.map((n) => n === "?" ? "\\?" : n).join("|")})`);
let r = !V.test(q);
if (!r) {
const n = q.indexOf(e);
n > 0 && !V.test(q.substring(0, n)) && (r = !0);
}
return r;
}, Ko = (q, A, e = ".") => {
if (!q) return;
if (q[A])
return Object.prototype.hasOwnProperty.call(q, A) ? q[A] : void 0;
const t = A.split(e);
let V = q;
for (let r = 0; r < t.length; ) {
if (!V || typeof V != "object")
return;
let n, o = "";
for (let s = r; s < t.length; ++s)
if (s !== r && (o += e), o += t[s], n = V[o], n !== void 0) {
if (["string", "number", "boolean"].indexOf(typeof n) > -1 && s < t.length - 1)
continue;
r += s - r + 1;
break;
}
V = n;
}
return V;
}, dV = (q) => q == null ? void 0 : q.replace("_", "-"), fp = {
type: "logger",
log(q) {
this.output("log", q);
},
warn(q) {
this.output("warn", q);
},
error(q) {
this.output("error", q);
},
output(q, A) {
var e, t;
(t = (e = console == null ? void 0 : console[q]) == null ? void 0 : e.apply) == null || t.call(e, console, A);
}
};
class dr {
constructor(A, e = {}) {
this.init(A, e);
}
init(A, e = {}) {
this.prefix = e.prefix || "i18next:", this.logger = A || fp, this.options = e, this.debug = e.debug;
}
log(...A) {
return this.forward(A, "log", "", !0);
}
warn(...A) {
return this.forward(A, "warn", "", !0);
}
error(...A) {
return this.forward(A, "error", "");
}
deprecate(...A) {
return this.forward(A, "warn", "WARNING DEPRECATED: ", !0);
}
forward(A, e, t, V) {
return V && !this.debug ? null : (Iq(A[0]) && (A[0] = `${t}${this.prefix} ${A[0]}`), this.logger[e](A));
}
create(A) {
return new dr(this.logger, {
prefix: `${this.prefix}:${A}:`,
...this.options
});
}
clone(A) {
return A = A || this.options, A.prefix = A.prefix || this.prefix, new dr(this.logger, A);
}
}
var le = new dr();
class Vn {
constructor() {
this.observers = {};
}
on(A, e) {
return A.split(" ").forEach((t) => {
this.observers[t] || (this.observers[t] = /* @__PURE__ */ new Map());
const V = this.observers[t].get(e) || 0;
this.observers[t].set(e, V + 1);
}), this;
}
off(A, e) {
if (this.observers[A]) {
if (!e) {
delete this.observers[A];
return;
}
this.observers[A].delete(e);
}
}
emit(A, ...e) {
this.observers[A] && Array.from(this.observers[A].entries()).forEach(([V, r]) => {
for (let n = 0; n < r; n++)
V(...e);
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([V, r]) => {
for (let n = 0; n < r; n++)
V.apply(V, [A, ...e]);
});
}
}
class ks extends Vn {
constructor(A, e = {
ns: ["translation"],
defaultNS: "translation"
}) {
super(), this.data = A || {}, this.options = e, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
}
addNamespaces(A) {
this.options.ns.indexOf(A) < 0 && this.options.ns.push(A);
}
removeNamespaces(A) {
const e = this.options.ns.indexOf(A);
e > -1 && this.options.ns.splice(e, 1);
}
getResource(A, e, t, V = {}) {
var i, l;
const r = V.keySeparator !== void 0 ? V.keySeparator : this.options.keySeparator, n = V.ignoreJSONStructure !== void 0 ? V.ignoreJSONStructure : this.options.ignoreJSONStructure;
let o;
A.indexOf(".") > -1 ? o = A.split(".") : (o = [A, e], t && (Array.isArray(t) ? o.push(...t) : Iq(t) && r ? o.push(...t.split(r)) : o.push(t)));
const s = ur(this.data, o);
return !s && !e && !t && A.indexOf(".") > -1 && (A = o[0], e = o[1], t = o.slice(2).join(".")), s || !n || !Iq(t) ? s : Ko((l = (i = this.data) == null ? void 0 : i[A]) == null ? void 0 : l[e], t, r);
}
addResource(A, e, t, V, r = {
silent: !1
}) {
const n = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
let o = [A, e];
t && (o = o.concat(n ? t.split(n) : t)), A.indexOf(".") > -1 && (o = A.split("."), V = e, e = o[1]), this.addNamespaces(e), bs(this.data, o, V), r.silent || this.emit("added", A, e, t, V);
}
addResources(A, e, t, V = {
silent: !1
}) {
for (const r in t)
(Iq(t[r]) || Array.isArray(t[r])) && this.addResource(A, e, r, t[r], {
silent: !0
});
V.silent || this.emit("added", A, e, t);
}
addResourceBundle(A, e, t, V, r, n = {
silent: !1,
skipCopy: !1
}) {
let o = [A, e];
A.indexOf(".") > -1 && (o = A.split("."), V = t, t = e, e = o[1]), this.addNamespaces(e);
let s = ur(this.data, o) || {};
n.skipCopy || (t = JSON.parse(JSON.stringify(t))), V ? Cc(s, t, r) : s = {
...s,
...t
}, bs(this.data, o, s), n.silent || this.emit("added", A, e, t);
}
removeResourceBundle(A, e) {
this.hasResourceBundle(A, e) && delete this.data[A][e], this.removeNamespaces(e), this.emit("removed", A, e);
}
hasResourceBundle(A, e) {
return this.getResource(A, e) !== void 0;
}
getResourceBundle(A, e) {
return e || (e = this.options.defaultNS), this.getResource(A, e);
}
getDataByLanguage(A) {
return this.data[A];
}
hasLanguageSomeTranslations(A) {
const e = this.getDataByLanguage(A);
return !!(e && Object.keys(e) || []).find((V) => e[V] && Object.keys(e[V]).length > 0);
}
toJSON() {
return this.data;
}
}
var Mc = {
processors: {},
addPostProcessor(q) {
this.processors[q.name] = q;
},
handle(q, A, e, t, V) {
return q.forEach((r) => {
var n;
A = ((n = this.processors[r]) == null ? void 0 : n.process(A, e, t, V)) ?? A;
}), A;
}
};
const Qs = {}, Ts = (q) => !Iq(q) && typeof q != "boolean" && typeof q != "number";
class gr extends Vn {
constructor(A, e = {}) {
super(), np(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], A, this), this.options = e, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = le.create("translator");
}
changeLanguage(A) {
A && (this.language = A);
}
exists(A, e = {
interpolation: {}
}) {
const t = {
...e
};
if (A == null) return !1;
const V = this.resolve(A, t);
return (V == null ? void 0 : V.res) !== void 0;
}
extractFromKey(A, e) {
let t = e.nsSeparator !== void 0 ? e.nsSeparator : this.options.nsSeparator;
t === void 0 && (t = ":");
const V = e.keySeparator !== void 0 ? e.keySeparator : this.options.keySeparator;
let r = e.ns || this.options.defaultNS || [];
const n = t && A.indexOf(t) > -1, o = !this.options.userDefinedKeySeparator && !e.keySeparator && !this.options.userDefinedNsSeparator && !e.nsSeparator && !gp(A, t, V);
if (n && !o) {
const s = A.match(this.interpolator.nestingRegexp);
if (s && s.length > 0)
return {
key: A,
namespaces: Iq(r) ? [r] : r
};
const i = A.split(t);
(t !== V || t === V && this.options.ns.indexOf(i[0]) > -1) && (r = i.shift()), A = i.join(V);
}
return {
key: A,
namespaces: Iq(r) ? [r] : r
};
}
translate(A, e, t) {
let V = typeof e == "object" ? {
...e
} : e;
if (typeof V != "object" && this.options.overloadTranslationOptionHandler && (V = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (V = {
...V
}), V || (V = {}), A == null) return "";
Array.isArray(A) || (A = [String(A)]);
const r = V.returnDetails !== void 0 ? V.returnDetails : this.options.returnDetails, n = V.keySeparator !== void 0 ? V.keySeparator : this.options.keySeparator, {
key: o,
namespaces: s
} = this.extractFromKey(A[A.length - 1], V), i = s[s.length - 1];
let l = V.nsSeparator !== void 0 ? V.nsSeparator : this.options.nsSeparator;
l === void 0 && (l = ":");
const a = V.lng || this.language, g = V.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
if ((a == null ? void 0 : a.toLowerCase()) === "cimode")
return g ? r ? {
res: `${i}${l}${o}`,
usedKey: o,
exactUsedKey: o,
usedLng: a,
usedNS: i,
usedParams: this.getUsedParamsDetails(V)
} : `${i}${l}${o}` : r ? {
res: o,
usedKey: o,
exactUsedKey: o,
usedLng: a,
usedNS: i,
usedParams: this.getUsedParamsDetails(V)
} : o;
const I = this.resolve(A, V);
let m = I == null ? void 0 : I.res;
const f = (I == null ? void 0 : I.usedKey) || o, E = (I == null ? void 0 : I.exactUsedKey) || o, w = ["[object Number]", "[object Function]", "[object RegExp]"], p = V.joinArrays !== void 0 ? V.joinArrays : this.options.joinArrays, h = !this.i18nFormat || this.i18nFormat.handleAsObject, d = V.count !== void 0 && !Iq(V.count), c = gr.hasDefaultValue(V), y = d ? this.pluralResolver.getSuffix(a, V.count, V) : "", v = V.ordinal && d ? this.pluralResolver.getSuffix(a, V.count, {
ordinal: !1
}) : "", M = d && !V.ordinal && V.count === 0, x = M && V[`defaultValue${this.options.pluralSeparator}zero`] || V[`defaultValue${y}`] || V[`defaultValue${v}`] || V.defaultValue;
let O = m;
h && !m && c && (O = x);
const N = Ts(O), j = Object.prototype.toString.apply(O);
if (h && O && N && w.indexOf(j) < 0 && !(Iq(p) && Array.isArray(O))) {
if (!V.returnObjects && !this.options.returnObjects) {
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
const P = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(f, O, {
...V,
ns: s
}) : `key '${o} (${this.language})' returned an object instead of string.`;
return r ? (I.res = P, I.usedParams = this.getUsedParamsDetails(V), I) : P;
}
if (n) {
const P = Array.isArray(O), b = P ? [] : {}, B = P ? E : f;
for (const T in O)
if (Object.prototype.hasOwnProperty.call(O, T)) {
const W = `${B}${n}${T}`;
c && !m ? b[T] = this.translate(W, {
...V,
defaultValue: Ts(x) ? x[T] : void 0,
joinArrays: !1,
ns: s
}) : b[T] = this.translate(W, {
...V,
joinArrays: !1,
ns: s
}), b[T] === W && (b[T] = O[T]);
}
m = b;
}
} else if (h && Iq(p) && Array.isArray(m))
m = m.join(p), m && (m = this.extendTranslation(m, A, V, t));
else {
let P = !1, b = !1;
!this.isValidLookup(m) && c && (P = !0, m = x), this.isValidLookup(m) || (b = !0, m = o);
const T = (V.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && b ? void 0 : m, W = c && x !== m && this.options.updateMissing;
if (b || P || W) {
if (this.logger.log(W ? "updateKey" : "missingKey", a, i, o, W ? x : m), n) {
const k = this.resolve(o, {
...V,
keySeparator: !1
});
k && k.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 F = [];
const G = this.languageUtils.getFallbackCodes(this.options.fallbackLng, V.lng || this.language);
if (this.options.saveMissingTo === "fallback" && G && G[0])
for (let k = 0; k < G.length; k++)
F.push(G[k]);
else this.options.saveMissingTo === "all" ? F = this.languageUtils.toResolveHierarchy(V.lng || this.language) : F.push(V.lng || this.language);
const R = (k, K, Z) => {
var H;
const qq = c && Z !== m ? Z : T;
this.options.missingKeyHandler ? this.options.missingKeyHandler(k, i, K, qq, W, V) : (H = this.backendConnector) != null && H.saveMissing && this.backendConnector.saveMissing(k, i, K, qq, W, V), this.emit("missingKey", k, i, K, m);
};
this.options.saveMissing && (this.options.saveMissingPlurals && d ? F.forEach((k) => {
const K = this.pluralResolver.getSuffixes(k, V);
M && V[`defaultValue${this.options.pluralSeparator}zero`] && K.indexOf(`${this.options.pluralSeparator}zero`) < 0 && K.push(`${this.options.pluralSeparator}zero`), K.forEach((Z) => {
R([k], o + Z, V[`defaultValue${Z}`] || x);
});
}) : R(F, o, x));
}
m = this.extendTranslation(m, A, V, I, t), b && m === o && this.options.appendNamespaceToMissingKey && (m = `${i}${l}${o}`), (b || P) && this.options.parseMissingKeyHandler && (m = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${i}${l}${o}` : o, P ? m : void 0, V));
}
return r ? (I.res = m, I.usedParams = this.getUsedParamsDetails(V), I) : m;
}
extendTranslation(A, e, t, V, r) {
var s, i;
if ((s = this.i18nFormat) != null && s.parse)
A = this.i18nFormat.parse(A, {
...this.options.interpolation.defaultVariables,
...t
}, t.lng || this.language || V.usedLng, V.usedNS, V.usedKey, {
resolved: V
});
else if (!t.skipInterpolation) {
t.interpolation && this.interpolator.init({
...t,
interpolation: {
...this.options.interpolation,
...t.interpolation
}
});
const l = Iq(A) && (((i = t == null ? void 0 : t.interpolation) == null ? void 0 : i.skipOnVariables) !== void 0 ? t.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
let a;
if (l) {
const I = A.match(this.interpolator.nestingRegexp);
a = I && I.length;
}
let g = t.replace && !Iq(t.replace) ? t.replace : t;
if (this.options.interpolation.defaultVariables && (g = {
...this.options.interpolation.defaultVariables,
...g
}), A = this.interpolator.interpolate(A, g, t.lng || this.language || V.usedLng, t), l) {
const I = A.match(this.interpolator.nestingRegexp), m = I && I.length;
a < m && (t.nest = !1);
}
!t.lng && V && V.res && (t.lng = this.language || V.usedLng), t.nest !== !1 && (A = this.interpolator.nest(A, (...I) => (r == null ? void 0 : r[0]) === I[0] && !t.context ? (this.logger.warn(`It seems you are nesting recursively key: ${I[0]} in key: ${e[0]}`), null) : this.translate(...I, e), t)), t.interpolation && this.interpolator.reset();
}
const n = t.postProcess || this.options.postProcess, o = Iq(n) ? [n] : n;
return A != null && (o != null && o.length) && t.applyPostProcessor !== !1 && (A = Mc.handle(o, A, e, this.options && this.options.postProcessPassResolved ? {
i18nResolved: {
...V,
usedParams: this.getUsedParamsDetails(t)
},
...t
} : t, this)), A;
}
resolve(A, e = {}) {
let t, V, r, n, o;
return Iq(A) && (A = [A]), A.forEach((s) => {
if (this.isValidLookup(t)) return;
const i = this.extractFromKey(s, e), l = i.key;
V = l;
let a = i.namespaces;
this.options.fallbackNS && (a = a.concat(this.options.fallbackNS));
const g = e.count !== void 0 && !Iq(e.count), I = g && !e.ordinal && e.count === 0, m = e.context !== void 0 && (Iq(e.context) || typeof e.context == "number") && e.context !== "", f = e.lngs ? e.lngs : this.languageUtils.toResolveHierarchy(e.lng || this.language, e.fallbackLng);
a.forEach((E) => {
var w, p;
this.isValidLookup(t) || (o = E, !Qs[`${f[0]}-${E}`] && ((w = this.utils) != null && w.hasLoadedNamespace) && !((p = this.utils) != null && p.hasLoadedNamespace(o)) && (Qs[`${f[0]}-${E}`] = !0, this.logger.warn(`key "${V}" for languages "${f.join(", ")}" won't get resolved as namespace "${o}" 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!!!")), f.forEach((h) => {
var y;
if (this.isValidLookup(t)) return;
n = h;
const d = [l];
if ((y = this.i18nFormat) != null && y.addLookupKeys)
this.i18nFormat.addLookupKeys(d, l, h, E, e);
else {
let v;
g && (v = this.pluralResolver.getSuffix(h, e.count, e));
const M = `${this.options.pluralSeparator}zero`, x = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
if (g && (d.push(l + v), e.ordinal && v.indexOf(x) === 0 && d.push(l + v.replace(x, this.options.pluralSeparator)), I && d.push(l + M)), m) {
const O = `${l}${this.options.contextSeparator}${e.context}`;
d.push(O), g && (d.push(O + v), e.ordinal && v.indexOf(x) === 0 && d.push(O + v.replace(x, this.options.pluralSeparator)), I && d.push(O + M));
}
}
let c;
for (; c = d.pop(); )
this.isValidLookup(t) || (r = c, t = this.getResource(h, E, c, e));
}));
});
}), {
res: t,
usedKey: V,
exactUsedKey: r,
usedLng: n,
usedNS: o
};
}
isValidLookup(A) {
return A !== void 0 && !(!this.options.returnNull && A === null) && !(!this.options.returnEmptyString && A === "");
}
getResource(A, e, t, V = {}) {
var r;
return (r = this.i18nFormat) != null && r.getResource ? this.i18nFormat.getResource(A, e, t, V) : this.resourceStore.getResource(A, e, t, V);
}
getUsedParamsDetails(A = {}) {
const e = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], t = A.replace && !Iq(A.replace);
let V = t ? A.replace : A;
if (t && typeof A.count < "u" && (V.count = A.count), this.options.interpolation.defaultVariables && (V = {
...this.options.interpolation.defaultVariables,
...V
}), !t) {
V = {
...V
};
for (const r of e)
delete V[r];
}
return V;
}
static hasDefaultValue(A) {
const e = "defaultValue";
for (const t in A)
if (Object.prototype.hasOwnProperty.call(A, t) && e === t.substring(0, e.length) && A[t] !== void 0)
return !0;
return !1;
}
}
class Ds {
constructor(A) {
this.options = A, this.supportedLngs = this.options.supportedLngs || !1, this.logger = le.create("languageUtils");
}
getScriptPartFromCode(A) {
if (A = dV(A), !A || A.indexOf("-") < 0) return null;
const e = A.split("-");
return e.length === 2 || (e.pop(), e[e.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(e.join("-"));
}
getLanguagePartFromCode(A) {
if (A = dV(A), !A || A.indexOf("-") < 0) return A;
const e = A.split("-");
return this.formatLanguageCode(e[0]);
}
formatLanguageCode(A) {
if (Iq(A) && A.indexOf("-") > -1) {
let e;
try {
e = Intl.getCanonicalLocales(A)[0];
} catch {
}
return e && this.options.lowerCaseLng && (e = e.toLowerCase()), e || (this.options.lowerCaseLng ? A.toLowerCase() : A);
}
return this.options.cleanCode || this.options.lowerCaseLng ? A.toLowerCase() : A;
}
isSupportedCode(A) {
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (A = this.getLanguagePartFromCode(A)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(A) > -1;
}
getBestMatchFromCodes(A) {
if (!A) return null;
let e;
return A.forEach((t) => {
if (e) return;
const V = this.formatLanguageCode(t);
(!this.options.supportedLngs || this.isSupportedCode(V)) && (e = V);
}), !e && this.options.supportedLngs && A.forEach((t) => {
if (e) return;
const V = this.getScriptPartFromCode(t);
if (this.isSupportedCode(V)) return e = V;
const r = this.getLanguagePartFromCode(t);
if (this.isSupportedCode(r)) return e = r;
e = this.options.supportedLngs.find((n) => {
if (n === r) return n;
if (!(n.indexOf("-") < 0 && r.indexOf("-") < 0) && (n.indexOf("-") > 0 && r.indexOf("-") < 0 && n.substring(0, n.indexOf("-")) === r || n.indexOf(r) === 0 && r.length > 1))
return n;
});
}), e || (e = this.getFallbackCodes(this.options.fallbackLng)[0]), e;
}
getFallbackCodes(A, e) {
if (!A) return [];
if (typeof A == "function" && (A = A(e)), Iq(A) && (A = [A]), Array.isArray(A)) return A;
if (!e) return A.default || [];
let t = A[e];
return t || (t = A[this.getScriptPartFromCode(e)]), t || (t = A[this.formatLanguageCode(e)]), t || (t = A[this.getLanguagePartFromCode(e)]), t || (t = A.default), t || [];
}
toResolveHierarchy(A, e) {
const t = this.getFallbackCodes((e === !1 ? [] : e) || this.options.fallbackLng || [], A), V = [], r = (n) => {
n && (this.isSupportedCode(n) ? V.push(n) : this.logger.warn(`rejecting language code not found in supportedLngs: ${n}`));
};
return Iq(A) && (A.indexOf("-") > -1 || A.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && r(this.formatLanguageCode(A)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && r(this.getScriptPartFromCode(A)), this.options.load !== "currentOnly" && r(this.getLanguagePartFromCode(A))) : Iq(A) && r(this.formatLanguageCode(A)), t.forEach((n) => {
V.indexOf(n) < 0 && r(this.formatLanguageCode(n));
}), V;
}
}
const Rs = {
zero: 0,
one: 1,
two: 2,
few: 3,
many: 4,
other: 5
}, Ns = {
select: (q) => q === 1 ? "one" : "other",
resolvedOptions: () => ({
pluralCategories: ["one", "other"]
})
};
class pp {
constructor(A, e = {}) {
this.languageUtils = A, this.options = e, this.logger = le.create("pluralResolver"), this.pluralRulesCache = {};
}
addRule(A, e) {
this.rules[A] = e;
}
clearCache() {
this.pluralRulesCache = {};
}
getRule(A, e = {}) {
const t = dV(A === "dev" ? "en" : A), V = e.ordinal ? "ordinal" : "cardinal", r = JSON.stringify({
cleanedCode: t,
type: V
});
if (r in this.pluralRulesCache)
return this.pluralRulesCache[r];
let n;
try {
n = new Intl.PluralRules(t, {
type: V
});
} catch {
if (!Intl)
return this.logger.error("No Intl support, please use an Intl polyfill!"), Ns;
if (!A.match(/-|_/)) return Ns;
const s = this.languageUtils.getLanguagePartFromCode(A);
n = this.getRule(s, e);
}
return this.pluralRulesCache[r] = n, n;
}
needsPlural(A, e = {}) {
let t = this.getRule(A, e);
return t || (t = this.getRule("dev", e)), (t == null ? void 0 : t.resolvedOptions().pluralCategories.length) > 1;
}
getPluralFormsOfKey(A, e, t = {}) {
return this.getSuffixes(A, t).map((V) => `${e}${V}`);
}
getSuffixes(A, e = {}) {
let t = this.getRule(A, e);
return t || (t = this.getRule("dev", e)), t ? t.resolvedOptions().pluralCategories.sort((V, r) => Rs[V] - Rs[r]).map((V) => `${this.options.prepend}${e.ordinal ? `ordinal${this.options.prepend}` : ""}${V}`) : [];
}
getSuffix(A, e, t = {}) {
const V = this.getRule(A, t);
return V ? `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${V.select(e)}` : (this.logger.warn(`no plural rule found for: ${A}`), this.getSuffix("dev", e, t));
}
}
const Us = (q, A, e, t = ".", V = !0) => {
let r = sp(q, A, e);
return !r && V && Iq(e) && (r = Ko(q, e, t), r === void 0 && (r = Ko(A, e, t))), r;
}, jn = (q) => q.replace(/\$/g, "$$$$");
class hp {
constructor(A = {}) {
var e;
this.logger = le.create("interpolator"), this.options = A, this.format = ((e = A == null ? void 0 : A.interpolation) == null ? void 0 : e.format) || ((t) => t), this.init(A);
}
init(A = {}) {
A.interpolation || (A.interpolation = {
escapeValue: !0