configcat-vue
Version:
A community-maintained SDK for integrating ConfigCat feature flags into Vue.js applications.
1,431 lines • 109 kB
JavaScript
import { defineComponent as kn, ref as $n, inject as Un, onBeforeMount as Mn, onUnmounted as Pn, renderSlot as _e } from "vue";
class He {
constructor() {
this.callbacks = [];
}
get aborted() {
return !this.callbacks;
}
abort() {
if (!this.aborted) {
const e = this.callbacks;
this.callbacks = void 0;
for (const t of e)
t();
}
}
registerCallback(e) {
return this.aborted ? (e(), () => {
}) : (this.callbacks.push(e), () => {
const t = this.callbacks;
let i;
t && (i = t.indexOf(e)) >= 0 && t.splice(i, 1);
});
}
}
function bt(n, e) {
let t;
return new Promise((i) => {
const s = e == null ? void 0 : e.registerCallback(() => {
clearTimeout(t), i(!1);
});
t = setTimeout(() => {
s == null || s(), i(!0);
}, n);
});
}
const wt = typeof performance < "u" && P(performance == null ? void 0 : performance.now) ? () => performance.now() : () => (/* @__PURE__ */ new Date()).getTime();
function Yt(n) {
return new xn(n);
}
const xn = typeof WeakRef == "function" ? WeakRef : _n();
function _n() {
const n = function(e) {
this.target = e;
};
return n.prototype.deref = function() {
return this.target;
}, n.isFallback = !0, n;
}
function F(n) {
try {
return typeof n == "symbol" ? "[symbol]" : typeof n == "object" && n !== null && !P(n.toString) ? Object.prototype.toString.call(n) : String(n);
} catch {
return "[unknown]";
}
}
function z(n, e = !1) {
return n instanceof Error ? t(n, "") : F(n);
function t(i, s, r) {
const o = i.toString();
let a = (s && s.substring(4) + "--> ") + o;
if (e && i.stack) {
let l = i.stack.trim();
l.lastIndexOf(o, 0) === 0 && (l = l.substring(o.length).trim()), a += `
` + l.replace(/^\s*(?:at\s)?/gm, s + " at ");
}
if (typeof AggregateError == "function" && i instanceof AggregateError) {
(r ?? (r = [])).push(i);
for (const l of i.errors)
if (l instanceof Error) {
if (r.indexOf(l) >= 0)
continue;
a += `
` + t(l, s + " ", r);
} else
a += `
` + s + "--> " + F(l);
r.pop();
}
return a;
}
}
function N() {
return /* @__PURE__ */ Object.create(null);
}
const Gt = P(Object.setPrototypeOf) ? Object.setPrototypeOf : (n, e) => (n.__proto__ = e, n);
function rt(n, e) {
n instanceof e || Gt(n, e.prototype);
}
function L(n, e) {
return Object.prototype.hasOwnProperty.call(n, e);
}
function ot(n) {
return typeof n == "boolean";
}
function W(n) {
return typeof n == "number";
}
function Qt(n, e, t) {
return W(n) && e <= n && n <= t;
}
const at = P(Number.isSafeInteger) ? Number.isSafeInteger : (n) => W(n) && isFinite(n) && Math.floor(n) === n && Math.abs(n) <= 9007199254740991;
function lt(n, e, t) {
return at(n) && e <= n && n <= t;
}
function S(n) {
return typeof n == "string";
}
function Ce(n) {
return typeof n == "object" && n !== null && !M(n);
}
function M(n) {
return Array.isArray(n);
}
function Xt(n) {
return M(n) && !n.some((e) => !S(e));
}
function P(n) {
return typeof n == "function";
}
function Zt(n) {
return P(n == null ? void 0 : n.then);
}
function ct(n, e, t) {
return ot(n) || ve(n, e, "boolean", t), n;
}
function en(n, e, t) {
return W(n) || ve(n, e, "number", t), n;
}
function Te(n, e, t, i, s) {
return en(n, e, s), i(n) || Q(e, `Expected a value ${t}, got ${n}.`, s, RangeError), n;
}
function Z(n, e, t, i, s) {
return en(n, e, s), i(n) || Q(e, `Expected a valid \`${t}\` value, got '${n}'.`, s, RangeError), n;
}
function G(n, e, t, i) {
return S(n) || ve(n, e, "string", i), n.length || !t || Q(e, "Expected a non-empty string.", i), n;
}
function Rt(n, e, t) {
return P(n) || ve(n, e, "function", t), n;
}
function $(n, e, t, i) {
if (Ce(n) || ve(n, e, "object", i), t)
for (const s in t) {
const r = t[s];
(!(s in n) || r && !P(n[s])) && Q(e, `Expected an object with ${r ? "method" : "property"} \`${s}\`.`, i, TypeError);
}
return n;
}
function ve(n, e, t, i) {
Q(e, `Expected a value of type ${t}, got ${n === null ? "null" : typeof n}.`, i, TypeError);
}
function Q(n, e, t, i) {
const s = t ? "property" : (t = "", "argument");
throw (i ?? Error)(`Invalid ${s} \`${n}${t}\`. ${e}`);
}
function ut(n, e = 0, t, i = ", ") {
const s = n.length;
if (!s)
return "";
let r = "";
return e > 0 && s > e && (n = n.slice(0, e), t && (r = t(s - e))), "'" + n.join("'" + i + "'") + "'" + r;
}
function ue(n) {
function e(o, a) {
const l = o.charCodeAt(a);
if (55296 <= l && l < 56320) {
const c = o.charCodeAt(a + 1);
if (56320 <= c && c <= 57343)
return (l << 10) + c - 56613888;
}
return l;
}
let t = "", i = 0;
const s = String.fromCharCode;
let r;
for (r = 0; r < n.length; r++) {
const o = e(n, r);
o <= 127 || (t += n.slice(i, r), o <= 2047 ? (t += s(192 | o >> 6), t += s(128 | o & 63)) : o <= 65535 ? (t += s(224 | o >> 12), t += s(128 | o >> 6 & 63), t += s(128 | o & 63)) : (t += s(240 | o >> 18), t += s(128 | o >> 12 & 63), t += s(128 | o >> 6 & 63), t += s(128 | o & 63), ++r), i = r + 1);
}
return t += n.slice(i, r);
}
function Hn(n) {
if (!n.length || !/^\s*[+-]?\d+\s*$/.test(n))
return NaN;
const e = +n;
return at(e) ? e : NaN;
}
function ft(n) {
return !n.length || /^\s*$|^\s*0[^\d.eE]/.test(n) ? NaN : +n;
}
function Nt(n, e) {
const t = {};
for (const i in n)
if (L(n, i)) {
const s = n[i];
t[i] = e ? e(i, s) : s;
}
return t;
}
class pe {
constructor(e, t) {
this.state = e, this.factoryOrValue = t;
}
toString() {
let { factoryOrValue: e } = this;
return S(e) || (this.factoryOrValue = e = e(this.state), this.state = void 0), e;
}
}
class tn {
constructor() {
this.events = N(), this.eventCount = 0;
}
addListenerCore(e, t, i) {
if (!P(t))
throw TypeError("Listener must be a function");
const s = this.events[e], r = { fn: t, once: i };
return s ? M(s) ? s.push(r) : this.events[e] = [s, r] : (this.events[e] = r, this.eventCount++), this;
}
removeListenerCore(e, t, i) {
const s = this.events[e];
if (!s)
return this;
if (M(s)) {
for (let r = s.length - 1; r >= 0; r--)
if (i(s[r], t)) {
s.splice(r, 1), s.length ? s.length === 1 && (this.events[e] = s[0]) : this.removeEvent(e);
break;
}
} else i(s, t) && this.removeEvent(e);
return this;
}
removeEvent(e) {
--this.eventCount === 0 ? this.events = N() : delete this.events[e];
}
on(e, t) {
return this.addListenerCore(e, t, !1);
}
once(e, t) {
return this.addListenerCore(e, t, !0);
}
removeListener(e, t) {
if (!P(t))
throw TypeError("Listener must be a function");
return this.removeListenerCore(e, t, (i, s) => i.fn === s);
}
removeAllListeners(e) {
return arguments.length ? this.events[e] && this.removeEvent(e) : (this.events = N(), this.eventCount = 0), this;
}
listeners(e) {
const t = this.events[e];
if (!t)
return [];
if (!M(t))
return [t.fn];
const i = t.length, s = new Array(i);
for (let r = 0; r < i; r++)
s[r] = t[r].fn;
return s;
}
listenerCount(e) {
const t = this.events[e];
return t ? M(t) ? t.length : 1 : 0;
}
eventNames() {
const e = [];
if (this.eventCount === 0)
return e;
const t = this.events;
for (const i in t)
e.push(i);
return P(Object.getOwnPropertySymbols) ? e.concat(Object.getOwnPropertySymbols(t)) : e;
}
emit(e, t, i, s, r, ...o) {
let a = this.events[e];
if (!a)
return !1;
let l, c;
M(a) ? (a = a.slice(), [l, c] = [a[0], a.length]) : [l, c] = [a, 1];
const f = arguments.length - 1;
for (let u = 0; ; ) {
switch (l.once && this.removeListenerCore(e, l, (h, g) => h === g), f) {
case 0:
l.fn.call(this);
break;
case 1:
l.fn.call(this, t);
break;
case 2:
l.fn.call(this, t, i);
break;
case 3:
l.fn.call(this, t, i, s);
break;
case 4:
l.fn.call(this, t, i, s, r);
break;
default:
const h = new Array(f);
for (let g = 0; g < f; g++)
h[g] = arguments[g + 1];
l.fn.apply(this, h);
break;
}
if (++u >= c)
break;
l = a[u];
}
return !0;
}
}
const Ie = tn.prototype;
Ie.addListener = Ie.on;
Ie.off = Ie.removeListener;
var Ke;
(function(n) {
n[n.No = 0] = "No", n[n.Should = 1] = "Should", n[n.Force = 2] = "Force";
})(Ke || (Ke = {}));
var be;
(function(n) {
n[n.Boolean = 0] = "Boolean", n[n.String = 1] = "String", n[n.Int = 2] = "Int", n[n.Double = 3] = "Double";
})(be || (be = {}));
var We;
(function(n) {
n[n.TextIsOneOf = 0] = "TextIsOneOf", n[n.TextIsNotOneOf = 1] = "TextIsNotOneOf", n[n.TextContainsAnyOf = 2] = "TextContainsAnyOf", n[n.TextNotContainsAnyOf = 3] = "TextNotContainsAnyOf", n[n.SemVerIsOneOf = 4] = "SemVerIsOneOf", n[n.SemVerIsNotOneOf = 5] = "SemVerIsNotOneOf", n[n.SemVerLess = 6] = "SemVerLess", n[n.SemVerLessOrEquals = 7] = "SemVerLessOrEquals", n[n.SemVerGreater = 8] = "SemVerGreater", n[n.SemVerGreaterOrEquals = 9] = "SemVerGreaterOrEquals", n[n.NumberEquals = 10] = "NumberEquals", n[n.NumberNotEquals = 11] = "NumberNotEquals", n[n.NumberLess = 12] = "NumberLess", n[n.NumberLessOrEquals = 13] = "NumberLessOrEquals", n[n.NumberGreater = 14] = "NumberGreater", n[n.NumberGreaterOrEquals = 15] = "NumberGreaterOrEquals", n[n.SensitiveTextIsOneOf = 16] = "SensitiveTextIsOneOf", n[n.SensitiveTextIsNotOneOf = 17] = "SensitiveTextIsNotOneOf", n[n.DateTimeBefore = 18] = "DateTimeBefore", n[n.DateTimeAfter = 19] = "DateTimeAfter", n[n.SensitiveTextEquals = 20] = "SensitiveTextEquals", n[n.SensitiveTextNotEquals = 21] = "SensitiveTextNotEquals", n[n.SensitiveTextStartsWithAnyOf = 22] = "SensitiveTextStartsWithAnyOf", n[n.SensitiveTextNotStartsWithAnyOf = 23] = "SensitiveTextNotStartsWithAnyOf", n[n.SensitiveTextEndsWithAnyOf = 24] = "SensitiveTextEndsWithAnyOf", n[n.SensitiveTextNotEndsWithAnyOf = 25] = "SensitiveTextNotEndsWithAnyOf", n[n.SensitiveArrayContainsAnyOf = 26] = "SensitiveArrayContainsAnyOf", n[n.SensitiveArrayNotContainsAnyOf = 27] = "SensitiveArrayNotContainsAnyOf", n[n.TextEquals = 28] = "TextEquals", n[n.TextNotEquals = 29] = "TextNotEquals", n[n.TextStartsWithAnyOf = 30] = "TextStartsWithAnyOf", n[n.TextNotStartsWithAnyOf = 31] = "TextNotStartsWithAnyOf", n[n.TextEndsWithAnyOf = 32] = "TextEndsWithAnyOf", n[n.TextNotEndsWithAnyOf = 33] = "TextNotEndsWithAnyOf", n[n.ArrayContainsAnyOf = 34] = "ArrayContainsAnyOf", n[n.ArrayNotContainsAnyOf = 35] = "ArrayNotContainsAnyOf";
})(We || (We = {}));
var ze;
(function(n) {
n[n.Equals = 0] = "Equals", n[n.NotEquals = 1] = "NotEquals";
})(ze || (ze = {}));
var Je;
(function(n) {
n[n.IsIn = 0] = "IsIn", n[n.IsNotIn = 1] = "IsNotIn";
})(Je || (Je = {}));
const Xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
get PrerequisiteFlagComparator() {
return ze;
},
get RedirectMode() {
return Ke;
},
get SegmentComparator() {
return Je;
},
get SettingType() {
return be;
},
get UserComparator() {
return We;
}
}, Symbol.toStringTag, { value: "Module" }));
class I {
static contentEquals(e, t) {
return e.httpETag && t.httpETag ? e.httpETag === t.httpETag : e.configJson === t.configJson;
}
constructor(e, t, i, s) {
this.configJson = e, this.config = t, this.timestamp = i, this.httpETag = s;
}
with(e) {
return new I(this.configJson, this.config, e, this.httpETag);
}
get isEmpty() {
return !this.config;
}
isExpired(e) {
return this === I.empty || this.timestamp + e < I.generateTimestamp();
}
static generateTimestamp() {
return (/* @__PURE__ */ new Date()).getTime();
}
static serialize(e) {
var t, i;
return e.timestamp + `
` + ((t = e.httpETag) !== null && t !== void 0 ? t : "") + `
` + ((i = e.configJson) !== null && i !== void 0 ? i : "");
}
static deserialize(e) {
const t = Array(2);
let i = 0;
for (let f = 0; f < t.length; f++) {
if (i = e.indexOf(`
`, i), i < 0)
throw Error("Number of values is fewer than expected.");
t[f] = i++;
}
let s = t[0], r = e.substring(0, s);
const o = parseInt(r);
if (isNaN(o))
throw Error("Invalid fetch time: " + r);
i = s + 1, s = t[1], r = e.substring(i, s);
const a = r.length > 0 ? r : void 0;
i = s + 1, r = e.substring(i);
let l, c;
return r.length > 0 && (l = nn(r), c = r), new I(c, l, o, a);
}
}
I.serializationFormatVersion = "v2";
I.empty = new I(void 0, void 0, 0, void 0);
function V(n) {
return n ? new Date(n.timestamp) : void 0;
}
function nn(n) {
G(n, "configJson", !0);
const e = JSON.parse(n);
return sn(e);
}
function sn(n) {
var e;
qn(n, ["$"]);
const t = n.f;
if (t) {
const i = (e = n.p) === null || e === void 0 ? void 0 : e.s, s = n.s;
for (const r in t)
if (L(t, r)) {
const o = t[r];
o._configJsonSalt = i, o._configSegments = s;
}
}
return n;
}
function rn(n) {
const e = Object.create(ht);
return e.t = -1, e.v = n, e;
}
const ht = /* @__PURE__ */ Object.create(null);
ht.toString = function() {
return Object.prototype.toString.call(this);
};
function qn(n, e) {
n == null && dt(e), D(n, e), v(n, "p", e, jn), v(n, "s", e, Vn), v(n, "f", e, Kn);
}
function jn(n, e) {
D(n, e), v(n, "r", e, K), v(n, "u", e, H), v(n, "s", e, H);
}
function Vn(n, e) {
te(n, e);
for (let t = 0; t < n.length; t++)
ee(n, t, e, Bn);
}
function Bn(n, e) {
D(n, e), v(n, "n", e, H, !0), v(n, "r", e, Gn);
}
function Kn(n, e) {
D(n, e);
for (const t in n)
L(n, t) && v(n, t, e, Wn, !0);
}
function Wn(n, e) {
D(n, e), v(n, "t", e, K, !0), v(n, "a", e, H), v(n, "r", e, zn), v(n, "p", e, an), gt(n, e);
}
function zn(n, e) {
te(n, e);
for (let t = 0; t < n.length; t++)
ee(n, t, e, Jn);
}
function Jn(n, e) {
D(n, e), v(n, "c", e, Yn), v(n, "s", e, gt), v(n, "p", e, an);
}
function Yn(n, e) {
te(n, e);
for (let t = 0; t < n.length; t++)
ee(n, t, e, Qn);
}
function Gn(n, e) {
te(n, e);
for (let t = 0; t < n.length; t++)
ee(n, t, e, on);
}
function Qn(n, e) {
D(n, e), v(n, "u", e, on), v(n, "p", e, Zn), v(n, "s", e, ei);
}
function on(n, e) {
D(n, e), v(n, "a", e, H, !0), v(n, "c", e, K, !0), v(n, "s", e, H), v(n, "d", e, cn), v(n, "l", e, Xn);
}
function Xn(n, e) {
te(n, e);
for (let t = 0; t < n.length; t++)
ee(n, t, e, H);
}
function Zn(n, e) {
D(n, e), v(n, "f", e, H, !0), v(n, "c", e, K, !0), v(n, "v", e, ln, !0);
}
function ei(n, e) {
D(n, e), v(n, "s", e, K, !0), v(n, "c", e, K, !0);
}
function an(n, e) {
te(n, e);
for (let t = 0; t < n.length; t++)
ee(n, t, e, ti);
}
function ti(n, e) {
D(n, e), v(n, "p", e, K, !0), gt(n, e);
}
function gt(n, e) {
D(n, e), v(n, "v", e, ln, !0), v(n, "i", e, H);
}
function ln(n, e) {
D(n, e), v(n, "b", e, ni), v(n, "s", e, H), v(n, "i", e, K), v(n, "d", e, cn);
}
function ee(n, e, t, i) {
const s = n[e];
t.push(`[${e}]`), s == null && dt(t), i(s, t), t.pop();
}
function v(n, e, t, i, s) {
const r = n[e];
t.push(`.${e}`), r == null ? s && dt(t) : i(r, t), t.pop();
}
function te(n, e) {
M(n) || ne(e);
}
function D(n, e) {
Ce(n) || ne(e), Gt(n, ht);
}
function ni(n, e) {
ot(n) || ne(e);
}
function H(n, e) {
S(n) || ne(e);
}
function K(n, e) {
at(n) || ne(e);
}
function cn(n, e) {
W(n) || ne(e);
}
function dt(n) {
throw TypeError(`Invalid config JSON content. Missing required value at ${n.join("")}`);
}
function ne(n) {
throw TypeError(`Invalid config JSON content. Type mismatch at ${n.join("")}`);
}
function ii(n) {
return be[n];
}
function vt(n) {
const e = n.t;
if (lt(e, 0, 3) || e === -1 && ri(n))
return e;
T("Setting type is invalid.");
}
function Ye(n) {
switch (typeof n) {
case "boolean":
return 0;
case "string":
return 1;
case "number":
return 3;
}
}
function si(n, e) {
switch (e) {
case 0:
return ot(n);
case 1:
return S(n);
case 2:
case 3:
return W(n);
default:
return !1;
}
}
function pt(n) {
return Ye(n) !== void 0;
}
function ri(n) {
var e, t;
return !(!((e = n.r) === null || e === void 0) && e.length) && !(!((t = n.p) === null || t === void 0) && t.length);
}
function yt(n, e) {
const t = n.s, i = n.p;
if (t != null) {
if (i == null)
return !1;
} else if (i != null && i.length)
return !0;
e || T("Targeting rule THEN part is missing or invalid.");
}
function oi(n) {
let e, t;
return t = n.u, t != null && (e = "u"), t = n.p, t != null && (e = e ? !1 : "p"), t = n.s, t != null && (e = e ? !1 : "s"), e || T("Condition is missing or invalid."), e;
}
function U(n, e, t) {
switch (e) {
case 0: {
const i = n.b;
if (i != null)
return i;
break;
}
case 1: {
const i = n.s;
if (i != null)
return i;
break;
}
case 2: {
const i = n.i;
if (i != null)
return i;
break;
}
case 3: {
const i = n.d;
if (i != null)
return i;
break;
}
case -1:
if (pt(n))
return n;
default:
t || T(n === null ? "Setting value is null." : n === void 0 ? "Setting value is undefined." : `Setting value '${F(n)}' is of an unsupported type (${typeof n}).`);
return;
}
t || T("Setting value is missing or invalid.");
}
function T(n) {
throw new fe(n);
}
class fe extends Error {
constructor(e) {
super(e), this.message = e, this.name = fe.name, rt(this, fe);
}
}
class un {
constructor() {
this.cachedConfig = I.empty;
}
set(e, t) {
this.cachedConfig = t;
}
get(e) {
return this.cachedConfig;
}
getInMemory() {
return this.cachedConfig;
}
}
class Me {
constructor(e, t) {
this.cache = e, this.logger = t, this.cachedConfig = I.empty, this.cachedSerializedConfig = void 0;
}
async set(e, t) {
try {
if (!t.isEmpty)
this.cachedSerializedConfig = I.serialize(t), this.cachedConfig = t;
else {
this.cachedSerializedConfig = void 0, this.cachedConfig = t;
return;
}
await this.cache.set(e, this.cachedSerializedConfig);
} catch (i) {
this.logger.configServiceCacheWriteError(i);
}
}
updateCachedConfig(e) {
if (e == null || e === this.cachedSerializedConfig)
return this.cachedConfig;
const t = I.deserialize(e), i = !I.contentEquals(t, this.cachedConfig);
return this.cachedConfig = t, this.cachedSerializedConfig = e, i ? [this.cachedConfig] : this.cachedConfig;
}
get(e) {
let t;
try {
const i = this.cache.get(e);
if (Zt(i))
return (async (s) => {
let r;
try {
r = this.updateCachedConfig(await s);
} catch (o) {
r = this.cachedConfig, this.logger.configServiceCacheReadError(o);
}
return r;
})(i);
t = this.updateCachedConfig(i);
} catch (i) {
t = this.cachedConfig, this.logger.configServiceCacheReadError(i);
}
return t;
}
getInMemory() {
return this.cachedConfig;
}
}
var Ge;
(function(n) {
n[n.Debug = 4] = "Debug", n[n.Info = 3] = "Info", n[n.Warn = 2] = "Warn", n[n.Error = 1] = "Error", n[n.Off = -1] = "Off";
})(Ge || (Ge = {}));
function fn(n) {
return Ge[n];
}
class y {
static from(...e) {
return (t, ...i) => new y(t, e, i);
}
constructor(e, t, i) {
this.strings = e, this.argNames = t, this.argValues = i, this.cachedDefaultFormattedMessage = void 0;
}
get defaultFormattedMessage() {
let e = this.cachedDefaultFormattedMessage;
if (!S(e)) {
e = "";
const { strings: t, argValues: i } = this;
let s = 0;
for (; s < t.length - 1; s++)
e += t[s], e += F(i[s]);
e += t[s], this.cachedDefaultFormattedMessage = e;
}
return e;
}
toString() {
return this.defaultFormattedMessage;
}
}
function j(n) {
var e;
return S(n) ? n : (e = n.cachedDefaultFormattedMessage) !== null && e !== void 0 ? e : new pe(n, (t) => t.defaultFormattedMessage);
}
class ai {
get level() {
var e;
return (e = this.logger.level) !== null && e !== void 0 ? e : 2;
}
get eol() {
var e;
return (e = this.logger.eol) !== null && e !== void 0 ? e : `
`;
}
constructor(e, t, i) {
this.logger = e, this.filter = t, this.hooks = i;
}
isEnabled(e) {
return this.level >= e;
}
log(e, t, i, s) {
var r;
return this.isEnabled(e) && (!this.filter || this.filter(e, t, i, s)) && this.logger.log(e, t, i, s), e === 1 && ((r = this.hooks) === null || r === void 0 || r.emit("clientError", j(i), s)), i;
}
debug(e, t) {
this.log(4, 0, e, t);
}
configJsonIsNotPresent(e) {
return this.log(1, 1e3, y.from("DEFAULT_RETURN_VALUE")`Config JSON is not present. Returning ${e}.`);
}
configJsonIsNotPresentSingle(e, t, i) {
return this.log(1, 1e3, y.from("KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE")`Config JSON is not present when evaluating setting '${e}'. Returning the \`${t}\` parameter that you specified in your application: '${i}'.`);
}
settingEvaluationFailedDueToMissingKey(e, t, i, s) {
return this.log(1, 1001, y.from("KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE", "AVAILABLE_KEYS")`Failed to evaluate setting '${e}' (the key was not found in config JSON). Returning the \`${t}\` parameter that you specified in your application: '${i}'. Available keys: [${s}].`);
}
settingEvaluationError(e, t, i) {
return this.log(1, 1002, y.from("METHOD_NAME", "DEFAULT_RETURN_VALUE")`Error occurred in the \`${e}\` method. Returning ${t}.`, i);
}
settingEvaluationErrorSingle(e, t, i, s, r) {
return this.log(1, 1002, y.from("METHOD_NAME", "KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE")`Error occurred in the \`${e}\` method while evaluating setting '${t}'. Returning the \`${i}\` parameter that you specified in your application: '${s}'.`, r);
}
clientMethodError(e, t) {
return this.log(1, 1003, y.from("METHOD_NAME")`Error occurred in the \`${e}\` method.`, t);
}
fetchFailedDueToInvalidSdkKey(e, t) {
return e = Ft(e), this.log(1, 1100, t == null ? y.from("SDK_KEY")`Your SDK Key seems to be wrong: '${e}'. You can find the valid SDK Key at https://app.configcat.com/sdkkey` : y.from("SDK_KEY", "RAY_ID")`Your SDK Key seems to be wrong: '${e}'. You can find the valid SDK Key at https://app.configcat.com/sdkkey (Ray ID: ${t})`);
}
fetchFailedDueToUnexpectedHttpResponse(e, t, i) {
return this.log(1, 1101, i == null ? y.from("STATUS_CODE", "REASON_PHRASE")`Unexpected HTTP response was received while trying to fetch config JSON: ${e} ${t}` : y.from("STATUS_CODE", "REASON_PHRASE", "RAY_ID")`Unexpected HTTP response was received while trying to fetch config JSON: ${e} ${t} (Ray ID: ${i})`);
}
fetchFailedDueToRequestTimeout(e, t) {
return this.log(1, 1102, y.from("TIMEOUT")`Request timed out while trying to fetch config JSON. Timeout value: ${e}ms`, t);
}
fetchFailedDueToUnexpectedError(e) {
return this.log(1, 1103, "Unexpected error occurred while trying to fetch config JSON. It is most likely due to a local network issue. Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.", e);
}
fetchFailedDueToRedirectLoop(e) {
return this.log(1, 1104, e == null ? "Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/" : y.from("RAY_ID")`Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/ (Ray ID: ${e})`);
}
fetchReceived200WithInvalidBody(e, t) {
return this.log(1, 1105, e == null ? "Fetching config JSON was successful but the HTTP response content was invalid." : y.from("RAY_ID")`Fetching config JSON was successful but the HTTP response content was invalid. (Ray ID: ${e})`, t);
}
fetchReceived304WhenLocalCacheIsEmpty(e, t, i) {
return this.log(1, 1106, i == null ? y.from("STATUS_CODE", "REASON_PHRASE")`Unexpected HTTP response was received when no config JSON is cached locally: ${e} ${t}` : y.from("STATUS_CODE", "REASON_PHRASE", "RAY_ID")`Unexpected HTTP response was received when no config JSON is cached locally: ${e} ${t} (Ray ID: ${i})`);
}
autoPollConfigServiceErrorDuringPolling(e) {
return this.log(1, 1200, "Error occurred during auto polling.", e);
}
settingForVariationIdIsNotPresent(e) {
return this.log(1, 2011, y.from("VARIATION_ID")`Could not find the setting for the specified variation ID: '${e}'.`);
}
configServiceCacheReadError(e) {
return this.log(1, 2200, "Error occurred while reading the cache.", e);
}
configServiceCacheWriteError(e) {
return this.log(1, 2201, "Error occurred while writing the cache.", e);
}
clientIsAlreadyCreated(e) {
return e = Ft(e), this.log(2, 3e3, y.from("SDK_KEY")`There is an existing client instance for the specified SDK Key. No new client instance will be created and the specified options are ignored. Returning the existing client instance. SDK Key: '${e}'.`);
}
userObjectIsMissing(e) {
return this.log(2, 3001, y.from("KEY")`Cannot evaluate targeting rules and % options for setting '${e}' (User Object is missing). You should pass a User Object to the evaluation methods like \`getValueAsync()\` in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/`);
}
dataGovernanceIsOutOfSync() {
return this.log(2, 3002, "The `dataGovernance` parameter specified at the client initialization is not in sync with the preferences on the ConfigCat Dashboard. Read more: https://configcat.com/docs/advanced/data-governance/");
}
userObjectAttributeIsMissingPercentage(e, t) {
return this.log(2, 3003, y.from("KEY", "ATTRIBUTE_NAME", "ATTRIBUTE_NAME")`Cannot evaluate % options for setting '${e}' (the User.${t} attribute is missing). You should set the User.${t} attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/`);
}
userObjectAttributeIsMissingCondition(e, t, i) {
return this.log(2, 3003, y.from("CONDITION", "KEY", "ATTRIBUTE_NAME", "ATTRIBUTE_NAME")`Cannot evaluate condition (${e}) for setting '${t}' (the User.${i} attribute is missing). You should set the User.${i} attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/`);
}
userObjectAttributeIsInvalid(e, t, i, s) {
return this.log(2, 3004, y.from("CONDITION", "KEY", "REASON", "ATTRIBUTE_NAME")`Cannot evaluate condition (${e}) for setting '${t}' (${i}). Please check the User.${s} attribute and make sure that its value corresponds to the comparison operator.`);
}
userObjectAttributeIsAutoConverted(e, t, i, s) {
return this.log(2, 3005, y.from("CONDITION", "KEY", "ATTRIBUTE_NAME", "ATTRIBUTE_VALUE")`Evaluation of condition (${e}) for setting '${t}' may not produce the expected result (the User.${i} attribute is not a string value, thus it was automatically converted to the string value '${s}'). Please make sure that using a non-string value was intended.`);
}
configServiceCannotInitiateHttpCalls() {
return this.log(2, 3200, "Client is in offline mode, it cannot initiate HTTP calls.");
}
configServiceMethodHasNoEffectDueToDisposedClient(e) {
return this.log(2, 3201, y.from("METHOD_NAME")`The client object is already disposed, thus \`${e}()\` has no effect.`);
}
configServiceMethodHasNoEffectDueToOverrideBehavior(e, t) {
return this.log(2, 3202, y.from("OVERRIDE_BEHAVIOR", "METHOD_NAME")`Client is configured to use the \`${e}\` override behavior, thus \`${t}()\` has no effect.`);
}
settingEvaluated(e) {
return this.log(3, 5e3, y.from("EVALUATE_LOG")`${e}`);
}
configServiceStatusChanged(e) {
return this.log(3, 5200, y.from("MODE")`Switched to ${e.toUpperCase()} mode.`);
}
}
class hn {
constructor(e = 2, t = `
`) {
this.level = e, this.eol = t, this.SOURCE = "ConfigCat";
}
log(e, t, i, s) {
const [r, o] = e === 4 ? [console.info, "DEBUG"] : e === 3 ? [console.info, "INFO"] : e === 2 ? [console.warn, "WARN"] : e === 1 ? [console.error, "ERROR"] : [console.log, fn(e).toUpperCase()], a = s !== void 0 ? this.eol + z(s, !0) : "";
r(`${this.SOURCE} - ${o} - [${t}] ${i}${a}`);
}
}
function Ft(n) {
return n.substring(0, n.length - 6).replace(/[^/]/g, "*") + n.substring(n.length - 6);
}
var Lt;
(function(n) {
n[n.Fetched = 0] = "Fetched", n[n.NotModified = 1] = "NotModified", n[n.Errored = 2] = "Errored";
})(Lt || (Lt = {}));
function li(n) {
return { status: 0, config: n, errorCode: 0 };
}
function ci(n) {
return { status: 1, config: n, errorCode: 0 };
}
function ie(n, e, t, i) {
return { status: 2, config: n, errorCode: e, errorMessage: t, errorException: i };
}
class ui {
constructor(e, t, i, s) {
this.url = e, this.lastETag = t, this.headers = i, this.timeoutMs = s;
}
}
class gn {
constructor(e, t, i, s) {
this.statusCode = e, this.reasonPhrase = t, this.body = s, this.eTag = void 0, this.rayId = void 0;
let r, o;
for (const [a, l] of i) {
const c = a.toLowerCase();
if (r == null && c === "etag") {
if (this.eTag = r = l, o != null)
break;
} else if (o == null && c === "cf-ray" && (this.rayId = o = l, r != null))
break;
}
}
}
class _ extends Error {
constructor(e, ...t) {
super(((i, s) => {
switch (i) {
case "abort":
return "Request was aborted.";
case "timeout":
const [r] = s;
return `Request timed out. Timeout value: ${r}ms`;
case "failure":
const [o] = s, a = "Request failed due to a network or protocol error.";
return o ? a + " " + (o instanceof Error ? o.message : F(o)) : a;
}
})(e, t)), this.cause = e, this.name = _.name, rt(this, _), this.args = t;
}
}
var Dt;
(function(n) {
n[n.UnexpectedError = -1] = "UnexpectedError", n[n.None = 0] = "None", n[n.LocalOnlyClient = 1] = "LocalOnlyClient", n[n.OfflineClient = 3200] = "OfflineClient", n[n.InvalidSdkKey = 1100] = "InvalidSdkKey", n[n.UnexpectedHttpResponse = 1101] = "UnexpectedHttpResponse", n[n.HttpRequestTimeout = 1102] = "HttpRequestTimeout", n[n.HttpRequestFailure = 1103] = "HttpRequestFailure", n[n.InvalidHttpResponseContent = 1105] = "InvalidHttpResponseContent", n[n.InvalidHttpResponseWhenLocalCacheIsEmpty = 1106] = "InvalidHttpResponseWhenLocalCacheIsEmpty";
})(Dt || (Dt = {}));
function dn() {
return { isSuccess: !0, errorCode: 0 };
}
function we(n, e, t) {
return {
isSuccess: !1,
errorCode: n,
_errorMessage: e,
get errorMessage() {
var i;
return (i = this._errorMessage) === null || i === void 0 ? void 0 : i.toString();
},
errorException: t
};
}
function kt(n) {
return n.status !== 2 ? dn() : we(n.errorCode, n.errorMessage, n.errorException);
}
var Re;
(function(n) {
n[n.NoFlagData = 0] = "NoFlagData", n[n.HasLocalOverrideFlagDataOnly = 1] = "HasLocalOverrideFlagDataOnly", n[n.HasCachedFlagDataOnly = 2] = "HasCachedFlagDataOnly", n[n.HasUpToDateFlagData = 3] = "HasUpToDateFlagData";
})(Re || (Re = {}));
var Qe;
(function(n) {
n[n.Online = 0] = "Online", n[n.Offline = 1] = "Offline", n[n.Disposed = 2] = "Disposed";
})(Qe || (Qe = {}));
function $t(n) {
return Qe[n];
}
class mt {
constructor(e) {
this.options = e, this.pendingCacheSyncUp = null, this.pendingConfigRefresh = null, this.cacheKey = e.getCacheKey(), this.configFetcher = e.configFetcher, this.requestHeaders = [
["User-Agent", e.clientVersion],
["X-ConfigCat-UserAgent", e.clientVersion]
], this.status = e.offline ? 1 : 0;
}
prepareClientForEvents() {
var e;
const t = (e = this.options.hooks.unwrap()) === null || e === void 0 ? void 0 : e.configCatClient, i = t == null ? void 0 : t.initConfigService;
P(i) && i.call(t, this);
}
dispose() {
this.status = 2;
}
get disposed() {
return this.status === 2;
}
async refreshConfigAsync() {
const e = await this.syncUpWithCache();
if (this.isOffline) {
if (this.options.cache instanceof Me)
return [dn(), e];
{
const t = this.options.logger.configServiceCannotInitiateHttpCalls();
return [we(3200, j(t)), e];
}
} else {
const [t, i] = await this.refreshConfigCoreAsync(e, !0);
return [kt(t), i];
}
}
refreshConfigCoreAsync(e, t) {
if (this.pendingConfigRefresh)
return this.pendingConfigRefresh;
const i = (async (s) => {
const r = await this.fetchAsync(s);
return (r.status === 0 || r.status === 1 || r.config.timestamp > s.timestamp && (!r.config.isEmpty || this.options.cache.getInMemory().isEmpty)) && (await this.options.cache.set(this.cacheKey, r.config), s = r.config), this.onConfigFetched(r, t), r.status === 0 && this.onConfigChanged(r.config), [r, s];
})(e);
this.pendingConfigRefresh = i;
try {
i.finally(() => this.pendingConfigRefresh = null);
} catch (s) {
throw this.pendingConfigRefresh = null, s;
}
return i;
}
onConfigFetched(e, t) {
this.options.logger.debug("config fetched"), this.options.hooks.emit("configFetched", kt(e), t);
}
onConfigChanged(e) {
var t;
this.options.logger.debug("config changed"), this.options.hooks.emit("configChanged", (t = e.config) !== null && t !== void 0 ? t : sn({}));
}
async fetchAsync(e) {
const t = this.options;
t.logger.debug("ConfigServiceBase.fetchAsync() called.");
let i;
try {
const [s, r, o] = await this.fetchRequestAsync(e.httpETag);
switch (s.statusCode) {
case 200:
return r ? (t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was successful. Returning new config."), li(new I(s.body, r, I.generateTimestamp(), s.eTag))) : (i = t.logger.fetchReceived200WithInvalidBody(s.rayId, o), t.logger.debug(`ConfigServiceBase.fetchAsync(): ${s.statusCode} ${s.reasonPhrase} was received but the HTTP response content was invalid. Returning null.`), ie(e, 1105, j(i), o));
case 304:
return e.isEmpty ? (i = t.logger.fetchReceived304WhenLocalCacheIsEmpty(s.statusCode, s.reasonPhrase, s.rayId), t.logger.debug(`ConfigServiceBase.fetchAsync(): ${s.statusCode} ${s.reasonPhrase} was received when no config is cached locally. Returning null.`), ie(e, 1106, j(i))) : (t.logger.debug("ConfigServiceBase.fetchAsync(): content was not modified. Returning last config with updated timestamp."), ci(e.with(I.generateTimestamp())));
case 403:
case 404:
return i = t.logger.fetchFailedDueToInvalidSdkKey(t.sdkKey, s.rayId), t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."), ie(e.with(I.generateTimestamp()), 1100, j(i));
default:
return i = t.logger.fetchFailedDueToUnexpectedHttpResponse(s.statusCode, s.reasonPhrase, s.rayId), t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."), ie(e, 1101, j(i));
}
} catch (s) {
let r;
return [r, i] = s instanceof _ && s.cause === "timeout" ? [1102, t.logger.fetchFailedDueToRequestTimeout(s.args[0], s)] : [1103, t.logger.fetchFailedDueToUnexpectedError(s)], t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."), ie(e, r, j(i), s);
}
}
async fetchRequestAsync(e, t = 2) {
const i = this.options;
i.logger.debug("ConfigServiceBase.fetchRequestAsync() called.");
for (let s = 0; ; s++) {
i.logger.debug(`ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()${s > 0 ? `, retry ${s}/${t}` : ""}.`);
const r = new ui(i.getUrl(), e, this.requestHeaders, i.requestTimeoutMs), o = await this.configFetcher.fetchAsync(r);
if (o.statusCode !== 200)
return [o];
if (!o.body)
return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."), [o, void 0, Error("No response body.")];
let a;
try {
a = nn(o.body);
} catch (u) {
return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."), [o, void 0, u];
}
const l = a.p;
if (!l)
return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences are missing or invalid."), [o, a];
const c = l.u;
if (c == null || c === i.baseUrl)
return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."), [o, a];
const f = l.r;
if (i.baseUrlOverriden && f !== 2)
return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."), [o, a];
if (i.baseUrl = c, f === 0)
return [o, a];
if (f === 1 && i.logger.dataGovernanceIsOutOfSync(), s >= t)
return i.logger.fetchFailedDueToRedirectLoop(o.rayId), [o, a];
}
}
get isOfflineExactly() {
return this.status === 1;
}
get isOffline() {
return this.status !== 0;
}
goOnline() {
}
setOnline() {
this.status === 1 ? (this.goOnline(), this.status = 0, this.options.logger.configServiceStatusChanged($t(this.status))) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline");
}
setOffline() {
this.status === 0 ? (this.status = 1, this.options.logger.configServiceStatusChanged($t(this.status))) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline");
}
syncUpWithCache() {
const { cache: e } = this.options;
if (e instanceof un)
return e.get(this.cacheKey);
if (this.pendingCacheSyncUp)
return this.pendingCacheSyncUp;
const t = e.get(this.cacheKey);
if (!Zt(t))
return this.onCacheSynced(t);
const i = t.then((s) => this.onCacheSynced(s));
this.pendingCacheSyncUp = i;
try {
i.finally(() => this.pendingCacheSyncUp = null);
} catch (s) {
throw this.pendingCacheSyncUp = null, s;
}
return i;
}
onCacheSynced(e) {
if (!M(e))
return e;
const [t] = e;
return t.isEmpty || this.onConfigChanged(t), t;
}
async waitForReadyAsync(e) {
return this.getCacheState(await e);
}
getReadyPromise(e) {
return this.waitForReadyAsync(e).then((t) => (this.options.hooks.emit("clientReady", t), t));
}
}
const fi = 500;
class hi extends mt {
constructor(e) {
super(e), this.signalInitialization = () => {
}, this.stopToken = new He(), this.pollIntervalMs = e.pollIntervalSeconds * 1e3, this.pollExpirationMs = this.pollIntervalMs - fi, this.prepareClientForEvents();
const t = this.syncUpWithCache();
if (e.maxInitWaitTimeSeconds !== 0) {
this.initialized = !1;
const i = new Promise((s) => this.signalInitialization = s);
this.initializationPromise = this.waitForInitializationAsync(i).then((s) => (this.initialized = !0, s));
} else
this.initialized = !0, this.initializationPromise = Promise.resolve(!1);
this.readyPromise = this.getReadyPromise(t), this.startRefreshWorker(t, this.stopToken);
}
async waitForInitializationAsync(e) {
if (this.options.maxInitWaitTimeSeconds < 0)
return await e, !0;
const t = new He(), i = await Promise.race([
e.then(() => !0),
bt(this.options.maxInitWaitTimeSeconds * 1e3, t).then(() => !1)
]);
return t.abort(), i;
}
async waitForReadyAsync() {
return await this.initializationPromise, this.getCacheState(this.options.cache.getInMemory());
}
async getConfigAsync() {
this.options.logger.debug("AutoPollConfigService.getConfigAsync() called.");
let e = await this.syncUpWithCache();
if (!e.isExpired(this.pollIntervalMs))
this.signalInitialization();
else if (!this.isOffline && !this.initialized)
this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired, waiting for initialization."), await this.initializationPromise, e = this.options.cache.getInMemory();
else
return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired."), e;
return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - returning value from cache."), e;
}
refreshConfigAsync() {
return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."), super.refreshConfigAsync();
}
dispose() {
this.options.logger.debug("AutoPollConfigService.dispose() called."), super.dispose(), this.stopToken.aborted || this.stopRefreshWorker();
}
onConfigFetched(e, t) {
this.signalInitialization(), super.onConfigFetched(e, t);
}
goOnline() {
this.stopRefreshWorker(), this.stopToken = new He(), this.startRefreshWorker(null, this.stopToken);
}
async startRefreshWorker(e, t) {
for (this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called."); !t.aborted; ) {
try {
const i = wt() + this.pollIntervalMs;
try {
await this.refreshWorkerLogic(e);
} catch (r) {
this.options.logger.autoPollConfigServiceErrorDuringPolling(r);
}
const s = i - wt();
s > 0 && await bt(s, t);
} catch (i) {
this.options.logger.autoPollConfigServiceErrorDuringPolling(i);
}
e = null;
}
}
stopRefreshWorker() {
this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() called."), this.stopToken.abort();
}
async refreshWorkerLogic(e) {
this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() called.");
const t = await (e ?? this.syncUpWithCache());
if (t.isExpired(this.pollExpirationMs) && (e ? !this.isOfflineExactly : !this.isOffline)) {
await this.refreshConfigCoreAsync(t, !1);
return;
}
this.signalInitialization();
}
getCacheState(e) {
return e.isEmpty ? 0 : e.isExpired(this.pollIntervalMs) ? 2 : 3;
}
}
class Ne {
on() {
return this;
}
once() {
return this;
}
removeListener() {
return this;
}
removeAllListeners() {
return this;
}
listeners() {
return [];
}
listenerCount() {
return 0;
}
eventNames() {
return [];
}
emit() {
return !1;
}
}
const Fe = Ne.prototype;
Fe.addListener = Fe.on;
Fe.off = Fe.removeListener;
var Xe;
(function(n) {
n[n.LocalOnly = 0] = "LocalOnly", n[n.LocalOverRemote = 1] = "LocalOverRemote", n[n.RemoteOverLocal = 2] = "RemoteOverLocal";
})(Xe || (Xe = {}));
function Pe(n) {
return Xe[n];
}
class gi {
constructor(e, t) {
this.initialSettings = Ut(e), this.map = t ? e : null;
}
getOverrides() {
return this.map ? Ut(this.map) : this.initialSettings;
}
}
function Ut(n) {
const e = {};
for (const t in n)
L(n, t) && (e[t] = rn(n[t]));
return e;
}
const di = "cc-", Ee = ";str";
class vi {
get currentValue() {
if (!(typeof location > "u" || location === null))
return location.search;
}
}
let Se;
class pi {
constructor(e, t, i) {
this.watchChanges = !!e, this.paramPrefix = t ?? di, i ?? (i = Se ?? (Se = new vi())), this.queryStringProvider = i;
const s = i.currentValue;
this.settings = Pt(s, this.paramPrefix), this.queryString = Mt(s);
}
getOverrides() {
if (this.watchChanges) {
const e = this.queryStringProvider.currentValue, t = Mt(e);
this.queryString !== t && (this.settings = Pt(e, this.paramPrefix), this.queryString = t);
}
return this.settings;
}
}
function Mt(n) {
if (n == null)
return "";
if (S(n))
return n;
let e = "", t = "?";
for (const i in n) {
if (!L(n, i))
continue;
const s = n[i];
let r, o;
if (!M(s))
r = s, o = 1;
else if (s.length)
r = s[0], o = s.length;
else
continue;
for (let a = 0; e += t + encodeURIComponent(i) + "=" + encodeURIComponent(r), !(++a >= o); )
t = "&", r = s[a];
}
return e;
}
function Pt(n, e) {
const t = {};
return S(n) ? mi(n, e, t) : n != null && yi(n, e, t), t;
}
function yi(n, e, t) {
for (const i in n) {
if (!L(n, i))
continue;
const s = n[i];
let r, o;
if (!M(s))
r = s, o = 1;
else if (s.length)
r = s[0], o = s.length;
else
continue;
for (let a = 0; vn(i, r, e, t), !(++a >= o); )
r = s[a];
}
}
function mi(n, e, t) {
if (!n || n.lastIndexOf("?", 0) < 0)
return;
const i = n.substring(1).split("&");
for (let s of i) {
s = s.replace(/\+/g, " ");
const r = s.indexOf("="), o = decodeURIComponent(r >= 0 ? s.substring(0, r) : s), a = r >= 0 ? decodeURIComponent(s.substring(r + 1)) : "";
vn(o, a, e, t);
}
}
function vn(n, e, t, i) {
if (!n || n.length <= t.length || n.lastIndexOf(t, 0) < 0)
return;
n = n.substring(t.length), n.length > Ee.length && n.indexOf(Ee, n.length - Ee.length) >= 0 ? n = n.substring(0, n.length - Ee.length) : e = Ei(e), i[n] = rn(e);
}
function Ei(n) {
switch (n.toLowerCase()) {
case "false":
return !1;
case "true":
return !0;
default:
const e = ft(n);
return isNaN(e) ? n : e;
}
}
function pn(n) {
function e(b, x) {
var me = b << x | b >>> 32 - x;
return me;
}
var t, i, s, r = new Array(80), o = 1732584193, a = 4023233417, l = 2562383102, c = 271733878, f = 3285377520, u, h, g, d, E, A;
n = ue(n);
var p = n.length, C = new Array();
for (i = 0; i < p - 3; i += 4)
s = n.charCodeAt(i) << 24 | n.charCodeAt(i + 1) << 16 | n.charCodeAt(i + 2) << 8 | n.charCodeAt(i + 3), C.push(s);
switch (p % 4) {
case 0:
i = 2147483648;
break;
case 1:
i = n.charCodeAt(p - 1) << 24 | 8388608;
break;
case 2:
i = n.charCodeAt(p - 2) << 24 | n.charCodeAt(p - 1) << 16 | 32768;
break;
case 3:
i = n.charCodeAt(p - 3) << 24 | n.charCodeAt(p - 2) << 16 | n.charCodeAt(p - 1) << 8 | 128;
break;
}
for (C.push(i); C.length % 16 != 14; )
C.push(0);
for (C.push(p >>> 29), C.push(p << 3 & 4294967295), t = 0; t < C.length; t += 16) {
for (i = 0; i < 16; i++)
r[i] = C[t + i];
for (i = 16; i <= 79; i++)
r[i] = e(r[i - 3] ^ r[i - 8] ^ r[i - 14] ^ r[i - 16], 1);
for (u = o, h = a, g = l, d = c, E = f, i = 0; i <= 19; i++)
A = e(u, 5) + (h & g | ~h & d) + E + r[i] + 1518500249 & 4294967295, E = d, d = g, g = e(h, 30), h = u, u = A;
for (i = 20; i <= 39; i++)
A = e(u, 5) + (h ^ g ^ d) + E + r[i] + 1859775393 & 4294967295, E = d, d = g, g = e(h, 30), h = u, u = A;
for (i = 40; i <= 59; i++)
A = e(u, 5) + (h & g | h & d | g & d) + E + r[i] + 2400959708 & 4294967295, E = d, d = g, g = e(h, 30), h = u, u = A;
for (i = 60; i <= 79; i++)
A = e(u, 5) + (h ^ g ^ d) + E + r[i] + 3395469782 & 4294967295, E = d, d = g, g = e(h, 30), h = u, u = A;
o = o + u & 4294967295, a = a + h & 4294967295, l = l + g & 4294967295, c = c + d & 4294967295, f = f + E & 4294967295;
}
return yn([o, a, l, c, f]);
}
const Si = /* @__PURE__ */ Object.create(null);
function Ai(n) {
function e(Tt, It) {
return Tt >>> It | Tt << 32 - It;
}
const t = "length";
var i = Math.pow, s = i(2, 32), r, o, a = Si, l = a.h, c = a.k;
if (!c) {
l = [], c = [];
for (var f = N(), u = 2, h = 0; h < 64; u++)
if (!f[u]) {
for (r = 0; r < 313; r += u)
f[r] = u;
l[h] = i(u, 0.5) * s | 0, c[h++] = i(u, 1 / 3) * s | 0;
}
a.h = l = l.slice(0, 8), a.k = c;
}
var g = n[t] * 8;
n += "";
for (var d = []; n[t] % 64 - 56; )
n += "\0";
for (r = 0; r < n[t]; r++)
o = n.charCodeAt(r), d[r >> 2] |= o << (3 - r) % 4 * 8;
for (d[d[t]] = g / s | 0, d[d[t]] = g, o = 0; o < d[t]; ) {
var E = d.slice(o, o += 16), A = l;
for (l = l.slice(0, 8), r = 0; r < 64; r++) {
var p = E[r - 15], C = E[r - 2], b = l[0], x = l[4], me = l[7] + (e(x, 6) ^ e(x, 11) ^ e(x, 25)) + (x & l[5] ^ ~x & l[6]) + c[r] + (E[r] = r < 16 ? E[r] : E[r - 16] + (e(p, 7) ^ e(p, 18) ^ p >>> 3) + E[r - 7] + (e(C, 17) ^ e(C, 19) ^ C >>> 10) | 0), Dn = (e(b, 2) ^ e(b, 13) ^ e(b, 22)) + (b & l[1] ^ b & l[2] ^ l[1] & l[2]);
l = [me + Dn | 0].concat(l), l[4] = l[4] + me | 0;
}
for (r = 0; r < 8; r++)
l[r] = l[r] + A[r] | 0;
}
return yn(l, 8);
}
function yn(n, e) {
const t = "0123456789abcdef";
var i = "";
e ?? (e = n.length);
for (let s = 0; s < e; s++)
for (let r = 3; r >= 0; r--) {
const o = n[s] >> (r << 3) & 255;
i += t[o >> 4], i += t[o & 15];
}
return i;
}
const xt = new Ne();
class Ze {
constructor(e) {
this.eventEmitter = e;
const t = /* @__PURE__ */ Object.create(null);
t.get = () => this.configCatClient, t.enumerable = !0, Object.defineProperty(e, "configCatClient", t);
}
tryDisconnect() {
const e = this.eventEmitter;
return this.eventEmitter = xt, e !== xt;
}
on(e, t) {
return this.eventEmitter.on(e, t), this;
}
once(e, t) {
return this.eventEmitter.once(e, t), this;
}
removeListener(e, t) {
return this.eventEmitter.removeListener(e, t), this;
}
removeAllListeners(e) {
return this.eventEmitter.removeAllListeners(e), this;
}
listeners(e) {
return this.eventEmitter.listeners(e);
}
listenerCount(e) {
return this.eventEmitter.listenerCount(e);
}
eventNames() {
return this.eventEmitter.eventNames();
}
emit(e, ...t) {
return this.eventEmitter.emit(e, ...t);
}
}
const Le = Ze.prototype;
Le.addListener = Le.on;
Le.off = Le.removeListener;
class Oi extends mt {
constructor(e) {
super(e), this.cacheTi