configcat-vue 2.5.2 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,513 +1,633 @@
1
- import { defineComponent as bt, ref as Ct, inject as Nt, onBeforeMount as Rt, onUnmounted as Ft, renderSlot as ue } from "vue";
2
- var ve;
3
- (function(i) {
4
- i[i.No = 0] = "No", i[i.Should = 1] = "Should", i[i.Force = 2] = "Force";
5
- })(ve || (ve = {}));
6
- var te;
7
- (function(i) {
8
- i[i.Boolean = 0] = "Boolean", i[i.String = 1] = "String", i[i.Int = 2] = "Int", i[i.Double = 3] = "Double";
9
- })(te || (te = {}));
10
- var ye;
11
- (function(i) {
12
- i[i.TextIsOneOf = 0] = "TextIsOneOf", i[i.TextIsNotOneOf = 1] = "TextIsNotOneOf", i[i.TextContainsAnyOf = 2] = "TextContainsAnyOf", i[i.TextNotContainsAnyOf = 3] = "TextNotContainsAnyOf", i[i.SemVerIsOneOf = 4] = "SemVerIsOneOf", i[i.SemVerIsNotOneOf = 5] = "SemVerIsNotOneOf", i[i.SemVerLess = 6] = "SemVerLess", i[i.SemVerLessOrEquals = 7] = "SemVerLessOrEquals", i[i.SemVerGreater = 8] = "SemVerGreater", i[i.SemVerGreaterOrEquals = 9] = "SemVerGreaterOrEquals", i[i.NumberEquals = 10] = "NumberEquals", i[i.NumberNotEquals = 11] = "NumberNotEquals", i[i.NumberLess = 12] = "NumberLess", i[i.NumberLessOrEquals = 13] = "NumberLessOrEquals", i[i.NumberGreater = 14] = "NumberGreater", i[i.NumberGreaterOrEquals = 15] = "NumberGreaterOrEquals", i[i.SensitiveTextIsOneOf = 16] = "SensitiveTextIsOneOf", i[i.SensitiveTextIsNotOneOf = 17] = "SensitiveTextIsNotOneOf", i[i.DateTimeBefore = 18] = "DateTimeBefore", i[i.DateTimeAfter = 19] = "DateTimeAfter", i[i.SensitiveTextEquals = 20] = "SensitiveTextEquals", i[i.SensitiveTextNotEquals = 21] = "SensitiveTextNotEquals", i[i.SensitiveTextStartsWithAnyOf = 22] = "SensitiveTextStartsWithAnyOf", i[i.SensitiveTextNotStartsWithAnyOf = 23] = "SensitiveTextNotStartsWithAnyOf", i[i.SensitiveTextEndsWithAnyOf = 24] = "SensitiveTextEndsWithAnyOf", i[i.SensitiveTextNotEndsWithAnyOf = 25] = "SensitiveTextNotEndsWithAnyOf", i[i.SensitiveArrayContainsAnyOf = 26] = "SensitiveArrayContainsAnyOf", i[i.SensitiveArrayNotContainsAnyOf = 27] = "SensitiveArrayNotContainsAnyOf", i[i.TextEquals = 28] = "TextEquals", i[i.TextNotEquals = 29] = "TextNotEquals", i[i.TextStartsWithAnyOf = 30] = "TextStartsWithAnyOf", i[i.TextNotStartsWithAnyOf = 31] = "TextNotStartsWithAnyOf", i[i.TextEndsWithAnyOf = 32] = "TextEndsWithAnyOf", i[i.TextNotEndsWithAnyOf = 33] = "TextNotEndsWithAnyOf", i[i.ArrayContainsAnyOf = 34] = "ArrayContainsAnyOf", i[i.ArrayNotContainsAnyOf = 35] = "ArrayNotContainsAnyOf";
13
- })(ye || (ye = {}));
14
- var me;
15
- (function(i) {
16
- i[i.Equals = 0] = "Equals", i[i.NotEquals = 1] = "NotEquals";
17
- })(me || (me = {}));
18
- var Ee;
19
- (function(i) {
20
- i[i.IsIn = 0] = "IsIn", i[i.IsNotIn = 1] = "IsNotIn";
21
- })(Ee || (Ee = {}));
22
- const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1
+ import { defineComponent as kn, ref as $n, inject as Un, onBeforeMount as Mn, onUnmounted as Pn, renderSlot as _e } from "vue";
2
+ class He {
3
+ constructor() {
4
+ this.callbacks = [];
5
+ }
6
+ get aborted() {
7
+ return !this.callbacks;
8
+ }
9
+ abort() {
10
+ if (!this.aborted) {
11
+ const e = this.callbacks;
12
+ this.callbacks = void 0;
13
+ for (const t of e)
14
+ t();
15
+ }
16
+ }
17
+ registerCallback(e) {
18
+ return this.aborted ? (e(), () => {
19
+ }) : (this.callbacks.push(e), () => {
20
+ const t = this.callbacks;
21
+ let i;
22
+ t && (i = t.indexOf(e)) >= 0 && t.splice(i, 1);
23
+ });
24
+ }
25
+ }
26
+ function bt(n, e) {
27
+ let t;
28
+ return new Promise((i) => {
29
+ const s = e == null ? void 0 : e.registerCallback(() => {
30
+ clearTimeout(t), i(!1);
31
+ });
32
+ t = setTimeout(() => {
33
+ s == null || s(), i(!0);
34
+ }, n);
35
+ });
36
+ }
37
+ const wt = typeof performance < "u" && P(performance == null ? void 0 : performance.now) ? () => performance.now() : () => (/* @__PURE__ */ new Date()).getTime();
38
+ function Yt(n) {
39
+ return new xn(n);
40
+ }
41
+ const xn = typeof WeakRef == "function" ? WeakRef : _n();
42
+ function _n() {
43
+ const n = function(e) {
44
+ this.target = e;
45
+ };
46
+ return n.prototype.deref = function() {
47
+ return this.target;
48
+ }, n.isFallback = !0, n;
49
+ }
50
+ function F(n) {
51
+ try {
52
+ return typeof n == "symbol" ? "[symbol]" : typeof n == "object" && n !== null && !P(n.toString) ? Object.prototype.toString.call(n) : String(n);
53
+ } catch {
54
+ return "[unknown]";
55
+ }
56
+ }
57
+ function z(n, e = !1) {
58
+ return n instanceof Error ? t(n, "") : F(n);
59
+ function t(i, s, r) {
60
+ const o = i.toString();
61
+ let a = (s && s.substring(4) + "--> ") + o;
62
+ if (e && i.stack) {
63
+ let l = i.stack.trim();
64
+ l.lastIndexOf(o, 0) === 0 && (l = l.substring(o.length).trim()), a += `
65
+ ` + l.replace(/^\s*(?:at\s)?/gm, s + " at ");
66
+ }
67
+ if (typeof AggregateError == "function" && i instanceof AggregateError) {
68
+ (r ?? (r = [])).push(i);
69
+ for (const l of i.errors)
70
+ if (l instanceof Error) {
71
+ if (r.indexOf(l) >= 0)
72
+ continue;
73
+ a += `
74
+ ` + t(l, s + " ", r);
75
+ } else
76
+ a += `
77
+ ` + s + "--> " + F(l);
78
+ r.pop();
79
+ }
80
+ return a;
81
+ }
82
+ }
83
+ function N() {
84
+ return /* @__PURE__ */ Object.create(null);
85
+ }
86
+ const Gt = P(Object.setPrototypeOf) ? Object.setPrototypeOf : (n, e) => (n.__proto__ = e, n);
87
+ function rt(n, e) {
88
+ n instanceof e || Gt(n, e.prototype);
89
+ }
90
+ function L(n, e) {
91
+ return Object.prototype.hasOwnProperty.call(n, e);
92
+ }
93
+ function ot(n) {
94
+ return typeof n == "boolean";
95
+ }
96
+ function W(n) {
97
+ return typeof n == "number";
98
+ }
99
+ function Qt(n, e, t) {
100
+ return W(n) && e <= n && n <= t;
101
+ }
102
+ const at = P(Number.isSafeInteger) ? Number.isSafeInteger : (n) => W(n) && isFinite(n) && Math.floor(n) === n && Math.abs(n) <= 9007199254740991;
103
+ function lt(n, e, t) {
104
+ return at(n) && e <= n && n <= t;
105
+ }
106
+ function S(n) {
107
+ return typeof n == "string";
108
+ }
109
+ function Ce(n) {
110
+ return typeof n == "object" && n !== null && !M(n);
111
+ }
112
+ function M(n) {
113
+ return Array.isArray(n);
114
+ }
115
+ function Xt(n) {
116
+ return M(n) && !n.some((e) => !S(e));
117
+ }
118
+ function P(n) {
119
+ return typeof n == "function";
120
+ }
121
+ function Zt(n) {
122
+ return P(n == null ? void 0 : n.then);
123
+ }
124
+ function ct(n, e, t) {
125
+ return ot(n) || ve(n, e, "boolean", t), n;
126
+ }
127
+ function en(n, e, t) {
128
+ return W(n) || ve(n, e, "number", t), n;
129
+ }
130
+ function Te(n, e, t, i, s) {
131
+ return en(n, e, s), i(n) || Q(e, `Expected a value ${t}, got ${n}.`, s, RangeError), n;
132
+ }
133
+ function Z(n, e, t, i, s) {
134
+ return en(n, e, s), i(n) || Q(e, `Expected a valid \`${t}\` value, got '${n}'.`, s, RangeError), n;
135
+ }
136
+ function G(n, e, t, i) {
137
+ return S(n) || ve(n, e, "string", i), n.length || !t || Q(e, "Expected a non-empty string.", i), n;
138
+ }
139
+ function Rt(n, e, t) {
140
+ return P(n) || ve(n, e, "function", t), n;
141
+ }
142
+ function $(n, e, t, i) {
143
+ if (Ce(n) || ve(n, e, "object", i), t)
144
+ for (const s in t) {
145
+ const r = t[s];
146
+ (!(s in n) || r && !P(n[s])) && Q(e, `Expected an object with ${r ? "method" : "property"} \`${s}\`.`, i, TypeError);
147
+ }
148
+ return n;
149
+ }
150
+ function ve(n, e, t, i) {
151
+ Q(e, `Expected a value of type ${t}, got ${n === null ? "null" : typeof n}.`, i, TypeError);
152
+ }
153
+ function Q(n, e, t, i) {
154
+ const s = t ? "property" : (t = "", "argument");
155
+ throw (i ?? Error)(`Invalid ${s} \`${n}${t}\`. ${e}`);
156
+ }
157
+ function ut(n, e = 0, t, i = ", ") {
158
+ const s = n.length;
159
+ if (!s)
160
+ return "";
161
+ let r = "";
162
+ return e > 0 && s > e && (n = n.slice(0, e), t && (r = t(s - e))), "'" + n.join("'" + i + "'") + "'" + r;
163
+ }
164
+ function ue(n) {
165
+ function e(o, a) {
166
+ const l = o.charCodeAt(a);
167
+ if (55296 <= l && l < 56320) {
168
+ const c = o.charCodeAt(a + 1);
169
+ if (56320 <= c && c <= 57343)
170
+ return (l << 10) + c - 56613888;
171
+ }
172
+ return l;
173
+ }
174
+ let t = "", i = 0;
175
+ const s = String.fromCharCode;
176
+ let r;
177
+ for (r = 0; r < n.length; r++) {
178
+ const o = e(n, r);
179
+ 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);
180
+ }
181
+ return t += n.slice(i, r);
182
+ }
183
+ function Hn(n) {
184
+ if (!n.length || !/^\s*[+-]?\d+\s*$/.test(n))
185
+ return NaN;
186
+ const e = +n;
187
+ return at(e) ? e : NaN;
188
+ }
189
+ function ft(n) {
190
+ return !n.length || /^\s*$|^\s*0[^\d.eE]/.test(n) ? NaN : +n;
191
+ }
192
+ function Nt(n, e) {
193
+ const t = {};
194
+ for (const i in n)
195
+ if (L(n, i)) {
196
+ const s = n[i];
197
+ t[i] = e ? e(i, s) : s;
198
+ }
199
+ return t;
200
+ }
201
+ class pe {
202
+ constructor(e, t) {
203
+ this.state = e, this.factoryOrValue = t;
204
+ }
205
+ toString() {
206
+ let { factoryOrValue: e } = this;
207
+ return S(e) || (this.factoryOrValue = e = e(this.state), this.state = void 0), e;
208
+ }
209
+ }
210
+ class tn {
211
+ constructor() {
212
+ this.events = N(), this.eventCount = 0;
213
+ }
214
+ addListenerCore(e, t, i) {
215
+ if (!P(t))
216
+ throw TypeError("Listener must be a function");
217
+ const s = this.events[e], r = { fn: t, once: i };
218
+ return s ? M(s) ? s.push(r) : this.events[e] = [s, r] : (this.events[e] = r, this.eventCount++), this;
219
+ }
220
+ removeListenerCore(e, t, i) {
221
+ const s = this.events[e];
222
+ if (!s)
223
+ return this;
224
+ if (M(s)) {
225
+ for (let r = s.length - 1; r >= 0; r--)
226
+ if (i(s[r], t)) {
227
+ s.splice(r, 1), s.length ? s.length === 1 && (this.events[e] = s[0]) : this.removeEvent(e);
228
+ break;
229
+ }
230
+ } else i(s, t) && this.removeEvent(e);
231
+ return this;
232
+ }
233
+ removeEvent(e) {
234
+ --this.eventCount === 0 ? this.events = N() : delete this.events[e];
235
+ }
236
+ on(e, t) {
237
+ return this.addListenerCore(e, t, !1);
238
+ }
239
+ once(e, t) {
240
+ return this.addListenerCore(e, t, !0);
241
+ }
242
+ removeListener(e, t) {
243
+ if (!P(t))
244
+ throw TypeError("Listener must be a function");
245
+ return this.removeListenerCore(e, t, (i, s) => i.fn === s);
246
+ }
247
+ removeAllListeners(e) {
248
+ return arguments.length ? this.events[e] && this.removeEvent(e) : (this.events = N(), this.eventCount = 0), this;
249
+ }
250
+ listeners(e) {
251
+ const t = this.events[e];
252
+ if (!t)
253
+ return [];
254
+ if (!M(t))
255
+ return [t.fn];
256
+ const i = t.length, s = new Array(i);
257
+ for (let r = 0; r < i; r++)
258
+ s[r] = t[r].fn;
259
+ return s;
260
+ }
261
+ listenerCount(e) {
262
+ const t = this.events[e];
263
+ return t ? M(t) ? t.length : 1 : 0;
264
+ }
265
+ eventNames() {
266
+ const e = [];
267
+ if (this.eventCount === 0)
268
+ return e;
269
+ const t = this.events;
270
+ for (const i in t)
271
+ e.push(i);
272
+ return P(Object.getOwnPropertySymbols) ? e.concat(Object.getOwnPropertySymbols(t)) : e;
273
+ }
274
+ emit(e, t, i, s, r, ...o) {
275
+ let a = this.events[e];
276
+ if (!a)
277
+ return !1;
278
+ let l, c;
279
+ M(a) ? (a = a.slice(), [l, c] = [a[0], a.length]) : [l, c] = [a, 1];
280
+ const f = arguments.length - 1;
281
+ for (let u = 0; ; ) {
282
+ switch (l.once && this.removeListenerCore(e, l, (h, g) => h === g), f) {
283
+ case 0:
284
+ l.fn.call(this);
285
+ break;
286
+ case 1:
287
+ l.fn.call(this, t);
288
+ break;
289
+ case 2:
290
+ l.fn.call(this, t, i);
291
+ break;
292
+ case 3:
293
+ l.fn.call(this, t, i, s);
294
+ break;
295
+ case 4:
296
+ l.fn.call(this, t, i, s, r);
297
+ break;
298
+ default:
299
+ const h = new Array(f);
300
+ for (let g = 0; g < f; g++)
301
+ h[g] = arguments[g + 1];
302
+ l.fn.apply(this, h);
303
+ break;
304
+ }
305
+ if (++u >= c)
306
+ break;
307
+ l = a[u];
308
+ }
309
+ return !0;
310
+ }
311
+ }
312
+ const Ie = tn.prototype;
313
+ Ie.addListener = Ie.on;
314
+ Ie.off = Ie.removeListener;
315
+ var Ke;
316
+ (function(n) {
317
+ n[n.No = 0] = "No", n[n.Should = 1] = "Should", n[n.Force = 2] = "Force";
318
+ })(Ke || (Ke = {}));
319
+ var be;
320
+ (function(n) {
321
+ n[n.Boolean = 0] = "Boolean", n[n.String = 1] = "String", n[n.Int = 2] = "Int", n[n.Double = 3] = "Double";
322
+ })(be || (be = {}));
323
+ var We;
324
+ (function(n) {
325
+ 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";
326
+ })(We || (We = {}));
327
+ var ze;
328
+ (function(n) {
329
+ n[n.Equals = 0] = "Equals", n[n.NotEquals = 1] = "NotEquals";
330
+ })(ze || (ze = {}));
331
+ var Je;
332
+ (function(n) {
333
+ n[n.IsIn = 0] = "IsIn", n[n.IsNotIn = 1] = "IsNotIn";
334
+ })(Je || (Je = {}));
335
+ const Xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
23
336
  __proto__: null,
24
337
  get PrerequisiteFlagComparator() {
25
- return me;
338
+ return ze;
26
339
  },
27
340
  get RedirectMode() {
28
- return ve;
341
+ return Ke;
29
342
  },
30
343
  get SegmentComparator() {
31
- return Ee;
344
+ return Je;
32
345
  },
33
346
  get SettingType() {
34
- return te;
347
+ return be;
35
348
  },
36
349
  get UserComparator() {
37
- return ye;
350
+ return We;
38
351
  }
39
352
  }, Symbol.toStringTag, { value: "Module" }));
40
- class O {
41
- static equals(e, t) {
353
+ class I {
354
+ static contentEquals(e, t) {
42
355
  return e.httpETag && t.httpETag ? e.httpETag === t.httpETag : e.configJson === t.configJson;
43
356
  }
44
- constructor(e, t, n, s) {
45
- this.configJson = e, this.config = t, this.timestamp = n, this.httpETag = s;
357
+ constructor(e, t, i, s) {
358
+ this.configJson = e, this.config = t, this.timestamp = i, this.httpETag = s;
46
359
  }
47
360
  with(e) {
48
- return new O(this.configJson, this.config, e, this.httpETag);
361
+ return new I(this.configJson, this.config, e, this.httpETag);
49
362
  }
50
363
  get isEmpty() {
51
364
  return !this.config;
52
365
  }
53
366
  isExpired(e) {
54
- return this === O.empty || this.timestamp + e < O.generateTimestamp();
367
+ return this === I.empty || this.timestamp + e < I.generateTimestamp();
55
368
  }
56
369
  static generateTimestamp() {
57
370
  return (/* @__PURE__ */ new Date()).getTime();
58
371
  }
59
372
  static serialize(e) {
60
- var t, n;
373
+ var t, i;
61
374
  return e.timestamp + `
62
375
  ` + ((t = e.httpETag) !== null && t !== void 0 ? t : "") + `
63
- ` + ((n = e.configJson) !== null && n !== void 0 ? n : "");
376
+ ` + ((i = e.configJson) !== null && i !== void 0 ? i : "");
64
377
  }
65
378
  static deserialize(e) {
66
379
  const t = Array(2);
67
- let n = 0;
68
- for (let u = 0; u < t.length; u++) {
69
- if (n = e.indexOf(`
70
- `, n), n < 0)
71
- throw new Error("Number of values is fewer than expected.");
72
- t[u] = n++;
380
+ let i = 0;
381
+ for (let f = 0; f < t.length; f++) {
382
+ if (i = e.indexOf(`
383
+ `, i), i < 0)
384
+ throw Error("Number of values is fewer than expected.");
385
+ t[f] = i++;
73
386
  }
74
387
  let s = t[0], r = e.substring(0, s);
75
388
  const o = parseInt(r);
76
389
  if (isNaN(o))
77
- throw new Error("Invalid fetch time: " + r);
78
- n = s + 1, s = t[1], r = e.substring(n, s);
390
+ throw Error("Invalid fetch time: " + r);
391
+ i = s + 1, s = t[1], r = e.substring(i, s);
79
392
  const a = r.length > 0 ? r : void 0;
80
- n = s + 1, r = e.substring(n);
393
+ i = s + 1, r = e.substring(i);
81
394
  let l, c;
82
- return r.length > 0 && (l = U.deserialize(r), c = r), new O(c, l, o, a);
395
+ return r.length > 0 && (l = nn(r), c = r), new I(c, l, o, a);
83
396
  }
84
397
  }
85
- O.serializationFormatVersion = "v2";
86
- O.empty = new O(void 0, void 0, 0, void 0);
87
- class U {
88
- static deserialize(e) {
89
- const t = JSON.parse(e);
90
- if (typeof t != "object" || !t)
91
- throw new Error("Invalid config JSON content:" + e);
92
- return new U(t);
93
- }
94
- constructor(e) {
95
- var t, n;
96
- this.preferences = e.p != null ? new Lt(e.p) : void 0, this.segments = (n = (t = e.s) === null || t === void 0 ? void 0 : t.map((s) => new kt(s))) !== null && n !== void 0 ? n : [], this.settings = e.f != null ? Object.entries(e.f).reduce((s, [r, o]) => (s[r] = new $(o, this), s), {}) : {};
97
- }
98
- get salt() {
99
- var e;
100
- return (e = this.preferences) === null || e === void 0 ? void 0 : e.salt;
101
- }
398
+ I.serializationFormatVersion = "v2";
399
+ I.empty = new I(void 0, void 0, 0, void 0);
400
+ function V(n) {
401
+ return n ? new Date(n.timestamp) : void 0;
102
402
  }
103
- class Lt {
104
- constructor(e) {
105
- this.baseUrl = e.u, this.redirectMode = e.r, this.salt = e.s;
106
- }
403
+ function nn(n) {
404
+ G(n, "configJson", !0);
405
+ const e = JSON.parse(n);
406
+ return sn(e);
107
407
  }
108
- class kt {
109
- constructor(e) {
110
- var t, n;
111
- this.name = e.n, this.conditions = (n = (t = e.r) === null || t === void 0 ? void 0 : t.map((s) => new ot(s))) !== null && n !== void 0 ? n : [];
408
+ function sn(n) {
409
+ var e;
410
+ qn(n, ["$"]);
411
+ const t = n.f;
412
+ if (t) {
413
+ const i = (e = n.p) === null || e === void 0 ? void 0 : e.s, s = n.s;
414
+ for (const r in t)
415
+ if (L(t, r)) {
416
+ const o = t[r];
417
+ o._configJsonSalt = i, o._configSegments = s;
418
+ }
112
419
  }
420
+ return n;
113
421
  }
114
- class Fe {
115
- constructor(e, t = !1) {
116
- this.value = t ? e.v : at(e.v), this.variationId = e.i;
117
- }
422
+ function rn(n) {
423
+ const e = Object.create(ht);
424
+ return e.t = -1, e.v = n, e;
118
425
  }
119
- class $ extends Fe {
120
- constructor(e, t) {
121
- var n, s, r, o, a, l;
122
- super(e, e.t < 0), this.type = e.t, this.percentageOptionsAttribute = (n = e.a) !== null && n !== void 0 ? n : "Identifier", this.targetingRules = (r = (s = e.r) === null || s === void 0 ? void 0 : s.map((c) => new Dt(c, t))) !== null && r !== void 0 ? r : [], this.percentageOptions = (a = (o = e.p) === null || o === void 0 ? void 0 : o.map((c) => new rt(c))) !== null && a !== void 0 ? a : [], this.configJsonSalt = (l = t == null ? void 0 : t.salt) !== null && l !== void 0 ? l : "";
123
- }
124
- static fromValue(e) {
125
- return new $({
126
- t: -1,
127
- v: e
128
- });
129
- }
426
+ const ht = /* @__PURE__ */ Object.create(null);
427
+ ht.toString = function() {
428
+ return Object.prototype.toString.call(this);
429
+ };
430
+ function qn(n, e) {
431
+ n == null && dt(e), D(n, e), v(n, "p", e, jn), v(n, "s", e, Vn), v(n, "f", e, Kn);
130
432
  }
131
- class Dt {
132
- constructor(e, t) {
133
- var n, s;
134
- this.conditions = (s = (n = e.c) === null || n === void 0 ? void 0 : n.map((r) => r.u != null ? new ot(r.u) : r.p != null ? new $t(r.p) : r.s != null ? new Pt(r.s, t) : void 0)) !== null && s !== void 0 ? s : [], this.then = e.p != null ? e.p.map((r) => new rt(r)) : new Fe(e.s);
135
- }
433
+ function jn(n, e) {
434
+ D(n, e), v(n, "r", e, K), v(n, "u", e, H), v(n, "s", e, H);
136
435
  }
137
- class rt extends Fe {
138
- constructor(e) {
139
- super(e), this.percentage = e.p;
140
- }
436
+ function Vn(n, e) {
437
+ te(n, e);
438
+ for (let t = 0; t < n.length; t++)
439
+ ee(n, t, e, Bn);
141
440
  }
142
- class ot {
143
- constructor(e) {
144
- var t, n;
145
- this.type = "UserCondition", this.comparisonAttribute = e.a, this.comparator = e.c, this.comparisonValue = (n = (t = e.s) !== null && t !== void 0 ? t : e.d) !== null && n !== void 0 ? n : e.l;
146
- }
441
+ function Bn(n, e) {
442
+ D(n, e), v(n, "n", e, H, !0), v(n, "r", e, Gn);
147
443
  }
148
- class $t {
149
- constructor(e) {
150
- this.type = "PrerequisiteFlagCondition", this.prerequisiteFlagKey = e.f, this.comparator = e.c, this.comparisonValue = at(e.v);
151
- }
444
+ function Kn(n, e) {
445
+ D(n, e);
446
+ for (const t in n)
447
+ L(n, t) && v(n, t, e, Wn, !0);
152
448
  }
153
- class Pt {
154
- constructor(e, t) {
155
- this.type = "SegmentCondition", this.segment = t.segments[e.s], this.comparator = e.c;
156
- }
449
+ function Wn(n, e) {
450
+ 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);
157
451
  }
158
- function at(i) {
159
- var e, t, n;
160
- return (n = (t = (e = i.b) !== null && e !== void 0 ? e : i.s) !== null && t !== void 0 ? t : i.i) !== null && n !== void 0 ? n : i.d;
452
+ function zn(n, e) {
453
+ te(n, e);
454
+ for (let t = 0; t < n.length; t++)
455
+ ee(n, t, e, Jn);
161
456
  }
162
- function Mt(i) {
163
- return te[i];
457
+ function Jn(n, e) {
458
+ D(n, e), v(n, "c", e, Yn), v(n, "s", e, gt), v(n, "p", e, an);
164
459
  }
165
- var Oe;
166
- (function(i) {
167
- i[i.Fetched = 0] = "Fetched", i[i.NotModified = 1] = "NotModified", i[i.Errored = 2] = "Errored";
168
- })(Oe || (Oe = {}));
169
- class I {
170
- constructor(e, t, n, s) {
171
- this.status = e, this.config = t, this.errorMessage = n, this.errorException = s;
172
- }
173
- static success(e) {
174
- return new I(0, e);
175
- }
176
- static notModified(e) {
177
- return new I(1, e);
178
- }
179
- static error(e, t, n) {
180
- return new I(2, e, t ?? "Unknown error.", n);
181
- }
460
+ function Yn(n, e) {
461
+ te(n, e);
462
+ for (let t = 0; t < n.length; t++)
463
+ ee(n, t, e, Qn);
182
464
  }
183
- class b extends Error {
184
- constructor(e, ...t) {
185
- super(((n, s) => {
186
- switch (n) {
187
- case "abort":
188
- return "Request was aborted.";
189
- case "timeout":
190
- const [r] = s;
191
- return `Request timed out. Timeout value: ${r}ms`;
192
- case "failure":
193
- const [o] = s, a = "Request failed due to a network or protocol error.";
194
- return o ? a + " " + (o instanceof Error ? o.message : o + "") : a;
195
- }
196
- })(e, t)), this.cause = e, this instanceof b || (Object.setPrototypeOf || ((n, s) => n.__proto__ = s))(this, b.prototype), this.args = t;
197
- }
465
+ function Gn(n, e) {
466
+ te(n, e);
467
+ for (let t = 0; t < n.length; t++)
468
+ ee(n, t, e, on);
198
469
  }
199
- class N {
200
- constructor(e, t) {
201
- this.errorMessage = e, this.errorException = t;
202
- }
203
- get isSuccess() {
204
- return this.errorMessage === null;
205
- }
206
- static from(e) {
207
- return e.status !== 2 ? N.success() : N.failure(e.errorMessage, e.errorException);
208
- }
209
- static success() {
210
- return new N(null);
211
- }
212
- static failure(e, t) {
213
- return new N(e, t);
214
- }
470
+ function Qn(n, e) {
471
+ D(n, e), v(n, "u", e, on), v(n, "p", e, Zn), v(n, "s", e, ei);
215
472
  }
216
- var ne;
217
- (function(i) {
218
- i[i.NoFlagData = 0] = "NoFlagData", i[i.HasLocalOverrideFlagDataOnly = 1] = "HasLocalOverrideFlagDataOnly", i[i.HasCachedFlagDataOnly = 2] = "HasCachedFlagDataOnly", i[i.HasUpToDateFlagData = 3] = "HasUpToDateFlagData";
219
- })(ne || (ne = {}));
220
- var Se;
221
- (function(i) {
222
- i[i.Online = 0] = "Online", i[i.Offline = 1] = "Offline", i[i.Disposed = 2] = "Disposed";
223
- })(Se || (Se = {}));
224
- function Ve(i) {
225
- return Se[i];
473
+ function on(n, e) {
474
+ 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);
226
475
  }
227
- class Le {
228
- constructor(e, t) {
229
- this.configFetcher = e, this.options = t, this.pendingFetch = null, this.cacheKey = t.getCacheKey(), this.configFetcher = e, this.options = t, this.status = t.offline ? 1 : 0;
230
- }
231
- dispose() {
232
- this.status = 2;
233
- }
234
- get disposed() {
235
- return this.status === 2;
236
- }
237
- async refreshConfigAsync() {
238
- const e = await this.options.cache.get(this.cacheKey);
239
- if (this.isOffline) {
240
- const t = this.options.logger.configServiceCannotInitiateHttpCalls().toString();
241
- return [N.failure(t), e];
242
- } else {
243
- const [t, n] = await this.refreshConfigCoreAsync(e);
244
- return [N.from(t), n];
245
- }
246
- }
247
- async refreshConfigCoreAsync(e) {
248
- const t = await this.fetchAsync(e);
249
- let n = !1;
250
- const s = t.status === 0;
251
- return (s || t.config.timestamp > e.timestamp && (!t.config.isEmpty || e.isEmpty)) && (await this.options.cache.set(this.cacheKey, t.config), n = s && !O.equals(t.config, e), e = t.config), this.onConfigFetched(t.config), n && this.onConfigChanged(t.config), [t, e];
252
- }
253
- onConfigFetched(e) {
254
- this.options.logger.debug("config fetched");
255
- }
256
- onConfigChanged(e) {
257
- var t;
258
- this.options.logger.debug("config changed"), this.options.hooks.emit("configChanged", (t = e.config) !== null && t !== void 0 ? t : new U({}));
259
- }
260
- fetchAsync(e) {
261
- var t;
262
- return (t = this.pendingFetch) !== null && t !== void 0 ? t : this.pendingFetch = (async () => {
263
- try {
264
- return await this.fetchLogicAsync(e);
265
- } finally {
266
- this.pendingFetch = null;
267
- }
268
- })();
269
- }
270
- async fetchLogicAsync(e) {
271
- var t;
272
- const n = this.options;
273
- n.logger.debug("ConfigServiceBase.fetchLogicAsync() - called.");
274
- let s;
275
- try {
276
- const [r, o] = await this.fetchRequestAsync((t = e.httpETag) !== null && t !== void 0 ? t : null);
277
- switch (r.statusCode) {
278
- case 200:
279
- return o instanceof U ? (n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was successful. Returning new config."), I.success(new O(r.body, o, O.generateTimestamp(), r.eTag))) : (s = n.logger.fetchReceived200WithInvalidBody(o).toString(), n.logger.debug(`ConfigServiceBase.fetchLogicAsync(): ${r.statusCode} ${r.reasonPhrase} was received but the HTTP response content was invalid. Returning null.`), I.error(e, s, o));
280
- case 304:
281
- return e.isEmpty ? (s = n.logger.fetchReceived304WhenLocalCacheIsEmpty(r.statusCode, r.reasonPhrase).toString(), n.logger.debug(`ConfigServiceBase.fetchLogicAsync(): ${r.statusCode} ${r.reasonPhrase} was received when no config is cached locally. Returning null.`), I.error(e, s)) : (n.logger.debug("ConfigServiceBase.fetchLogicAsync(): content was not modified. Returning last config with updated timestamp."), I.notModified(e.with(O.generateTimestamp())));
282
- case 403:
283
- case 404:
284
- return s = n.logger.fetchFailedDueToInvalidSdkKey().toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."), I.error(e.with(O.generateTimestamp()), s);
285
- default:
286
- return s = n.logger.fetchFailedDueToUnexpectedHttpResponse(r.statusCode, r.reasonPhrase).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."), I.error(e, s);
287
- }
288
- } catch (r) {
289
- return s = (r instanceof b && r.cause === "timeout" ? n.logger.fetchFailedDueToRequestTimeout(r.args[0], r) : n.logger.fetchFailedDueToUnexpectedError(r)).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."), I.error(e, s, r);
290
- }
291
- }
292
- async fetchRequestAsync(e, t = 2) {
293
- const n = this.options;
294
- n.logger.debug("ConfigServiceBase.fetchRequestAsync() - called.");
295
- for (let s = 0; ; s++) {
296
- n.logger.debug(`ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()${s > 0 ? `, retry ${s}/${t}` : ""}`);
297
- const r = await this.configFetcher.fetchLogic(n, e);
298
- if (r.statusCode !== 200)
299
- return [r];
300
- if (!r.body)
301
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."), [r, new Error("No response body.")];
302
- let o;
303
- try {
304
- o = U.deserialize(r.body);
305
- } catch (u) {
306
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."), [r, u];
307
- }
308
- const a = o.preferences;
309
- if (!a)
310
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences is empty."), [r, o];
311
- const l = a.baseUrl;
312
- if (!l || l === n.baseUrl)
313
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."), [r, o];
314
- const c = a.redirectMode;
315
- if (n.baseUrlOverriden && c !== 2)
316
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."), [r, o];
317
- if (n.baseUrl = l, c === 0)
318
- return [r, o];
319
- if (c === 1 && n.logger.dataGovernanceIsOutOfSync(), s >= t)
320
- return n.logger.fetchFailedDueToRedirectLoop(), [r, o];
321
- }
322
- }
323
- get isOfflineExactly() {
324
- return this.status === 1;
325
- }
326
- get isOffline() {
327
- return this.status !== 0;
328
- }
329
- setOnlineCore() {
330
- }
331
- setOnline() {
332
- this.status === 1 ? (this.setOnlineCore(), this.status = 0, this.options.logger.configServiceStatusChanged(Ve(this.status))) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline");
333
- }
334
- setOfflineCore() {
335
- }
336
- setOffline() {
337
- this.status === 0 ? (this.setOfflineCore(), this.status = 1, this.options.logger.configServiceStatusChanged(Ve(this.status))) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline");
338
- }
339
- syncUpWithCache() {
340
- return this.options.cache.get(this.cacheKey);
341
- }
342
- async getReadyPromise(e, t) {
343
- const n = await t(e);
344
- return this.options.hooks.emit("clientReady", n), n;
345
- }
476
+ function Xn(n, e) {
477
+ te(n, e);
478
+ for (let t = 0; t < n.length; t++)
479
+ ee(n, t, e, H);
346
480
  }
347
- class he {
348
- constructor() {
349
- this.callbacks = [];
350
- }
351
- get aborted() {
352
- return !this.callbacks;
353
- }
354
- abort() {
355
- if (!this.aborted) {
356
- const e = this.callbacks;
357
- this.callbacks = null;
358
- for (const t of e)
359
- t();
360
- }
361
- }
362
- registerCallback(e) {
363
- return this.aborted ? (e(), () => {
364
- }) : (this.callbacks.push(e), () => {
365
- const t = this.callbacks;
366
- let n;
367
- t && (n = t.indexOf(e)) >= 0 && t.splice(n, 1);
368
- });
369
- }
481
+ function Zn(n, e) {
482
+ D(n, e), v(n, "f", e, H, !0), v(n, "c", e, K, !0), v(n, "v", e, ln, !0);
370
483
  }
371
- function qe(i, e) {
372
- let t;
373
- return new Promise((n) => {
374
- const s = e == null ? void 0 : e.registerCallback(() => {
375
- clearTimeout(t), n(!1);
376
- });
377
- t = setTimeout(() => {
378
- s == null || s(), n(!0);
379
- }, i);
380
- });
484
+ function ei(n, e) {
485
+ D(n, e), v(n, "s", e, K, !0), v(n, "c", e, K, !0);
381
486
  }
382
- function D(i, e = !1) {
383
- return i instanceof Error ? e && i.stack ? i.stack : i.toString() : i + "";
487
+ function an(n, e) {
488
+ te(n, e);
489
+ for (let t = 0; t < n.length; t++)
490
+ ee(n, t, e, ti);
384
491
  }
385
- function Be(i) {
386
- throw i;
492
+ function ti(n, e) {
493
+ D(n, e), v(n, "p", e, K, !0), gt(n, e);
387
494
  }
388
- function x(i) {
389
- return Array.isArray(i);
495
+ function gt(n, e) {
496
+ D(n, e), v(n, "v", e, ln, !0), v(n, "i", e, H);
390
497
  }
391
- function ke(i) {
392
- return x(i) && !i.some((e) => typeof e != "string");
498
+ function ln(n, e) {
499
+ D(n, e), v(n, "b", e, ni), v(n, "s", e, H), v(n, "i", e, K), v(n, "d", e, cn);
393
500
  }
394
- function De(i, e = 0, t, n = ", ") {
395
- const s = i.length;
396
- if (!s)
397
- return "";
398
- let r = "";
399
- return e > 0 && s > e && (i = i.slice(0, e), t && (r = t(s - e))), "'" + i.join("'" + n + "'") + "'" + r;
501
+ function ee(n, e, t, i) {
502
+ const s = n[e];
503
+ t.push(`[${e}]`), s == null && dt(t), i(s, t), t.pop();
400
504
  }
401
- function Ut(i) {
402
- return typeof (i == null ? void 0 : i.then) == "function";
505
+ function v(n, e, t, i, s) {
506
+ const r = n[e];
507
+ t.push(`.${e}`), r == null ? s && dt(t) : i(r, t), t.pop();
403
508
  }
404
- function K(i) {
405
- function e(o, a) {
406
- const l = o.charCodeAt(a);
407
- if (55296 <= l && l < 56320) {
408
- const c = o.charCodeAt(a + 1);
409
- if (56320 <= c && c <= 57343)
410
- return (l << 10) + c - 56613888;
411
- }
412
- return l;
413
- }
414
- let t = "", n = 0;
415
- const s = String.fromCharCode;
416
- let r;
417
- for (r = 0; r < i.length; r++) {
418
- const o = e(i, r);
419
- o <= 127 || (t += i.slice(n, 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), n = r + 1);
420
- }
421
- return t += i.slice(n, r);
509
+ function te(n, e) {
510
+ M(n) || ne(e);
422
511
  }
423
- function $e(i) {
424
- return typeof i == "number" ? i : typeof i != "string" || !i.length || /^\s*$|^\s*0[^\d.e]/.test(i) ? NaN : +i;
512
+ function D(n, e) {
513
+ Ce(n) || ne(e), Gt(n, ht);
425
514
  }
426
- const xt = 500;
427
- class _t extends Le {
428
- constructor(e, t) {
429
- super(e, t), this.signalInitialization = () => {
430
- }, this.stopToken = new he(), this.pollIntervalMs = t.pollIntervalSeconds * 1e3, this.pollExpirationMs = this.pollIntervalMs - xt;
431
- const n = this.syncUpWithCache();
432
- if (t.maxInitWaitTimeSeconds !== 0) {
433
- this.initialized = !1;
434
- const s = new Promise((r) => this.signalInitialization = r);
435
- this.initializationPromise = this.waitForInitializationAsync(s).then((r) => (this.initialized = !0, r));
436
- } else
437
- this.initialized = !0, this.initializationPromise = Promise.resolve(!1);
438
- this.readyPromise = this.getReadyPromise(this.initializationPromise, async (s) => (await s, this.getCacheState(this.options.cache.getInMemory()))), t.offline || this.startRefreshWorker(n, this.stopToken);
515
+ function ni(n, e) {
516
+ ot(n) || ne(e);
517
+ }
518
+ function H(n, e) {
519
+ S(n) || ne(e);
520
+ }
521
+ function K(n, e) {
522
+ at(n) || ne(e);
523
+ }
524
+ function cn(n, e) {
525
+ W(n) || ne(e);
526
+ }
527
+ function dt(n) {
528
+ throw TypeError(`Invalid config JSON content. Missing required value at ${n.join("")}`);
529
+ }
530
+ function ne(n) {
531
+ throw TypeError(`Invalid config JSON content. Type mismatch at ${n.join("")}`);
532
+ }
533
+ function ii(n) {
534
+ return be[n];
535
+ }
536
+ function vt(n) {
537
+ const e = n.t;
538
+ if (lt(e, 0, 3) || e === -1 && ri(n))
539
+ return e;
540
+ T("Setting type is invalid.");
541
+ }
542
+ function Ye(n) {
543
+ switch (typeof n) {
544
+ case "boolean":
545
+ return 0;
546
+ case "string":
547
+ return 1;
548
+ case "number":
549
+ return 3;
439
550
  }
440
- async waitForInitializationAsync(e) {
441
- if (this.options.maxInitWaitTimeSeconds < 0)
442
- return await e, !0;
443
- const t = new he(), n = await Promise.race([
444
- e.then(() => !0),
445
- qe(this.options.maxInitWaitTimeSeconds * 1e3, t).then(() => !1)
446
- ]);
447
- return t.abort(), n;
551
+ }
552
+ function si(n, e) {
553
+ switch (e) {
554
+ case 0:
555
+ return ot(n);
556
+ case 1:
557
+ return S(n);
558
+ case 2:
559
+ case 3:
560
+ return W(n);
561
+ default:
562
+ return !1;
448
563
  }
449
- async getConfig() {
450
- this.options.logger.debug("AutoPollConfigService.getConfig() called.");
451
- function e(n) {
452
- n.debug("AutoPollConfigService.getConfig() - returning value from cache.");
564
+ }
565
+ function pt(n) {
566
+ return Ye(n) !== void 0;
567
+ }
568
+ function ri(n) {
569
+ var e, t;
570
+ return !(!((e = n.r) === null || e === void 0) && e.length) && !(!((t = n.p) === null || t === void 0) && t.length);
571
+ }
572
+ function yt(n, e) {
573
+ const t = n.s, i = n.p;
574
+ if (t != null) {
575
+ if (i == null)
576
+ return !1;
577
+ } else if (i != null && i.length)
578
+ return !0;
579
+ e || T("Targeting rule THEN part is missing or invalid.");
580
+ }
581
+ function oi(n) {
582
+ let e, t;
583
+ 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;
584
+ }
585
+ function U(n, e, t) {
586
+ switch (e) {
587
+ case 0: {
588
+ const i = n.b;
589
+ if (i != null)
590
+ return i;
591
+ break;
453
592
  }
454
- let t;
455
- if (!this.isOffline && !this.initialized) {
456
- if (t = await this.options.cache.get(this.cacheKey), !t.isExpired(this.pollIntervalMs))
457
- return e(this.options.logger), t;
458
- this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired, waiting for initialization."), await this.initializationPromise;
593
+ case 1: {
594
+ const i = n.s;
595
+ if (i != null)
596
+ return i;
597
+ break;
459
598
  }
460
- return t = await this.options.cache.get(this.cacheKey), t.isExpired(this.pollIntervalMs) ? this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired.") : e(this.options.logger), t;
461
- }
462
- refreshConfigAsync() {
463
- return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."), super.refreshConfigAsync();
464
- }
465
- dispose() {
466
- this.options.logger.debug("AutoPollConfigService.dispose() called."), super.dispose(), this.stopToken.aborted || this.stopRefreshWorker();
467
- }
468
- onConfigFetched(e) {
469
- this.signalInitialization(), super.onConfigFetched(e);
470
- }
471
- setOnlineCore() {
472
- this.startRefreshWorker(null, this.stopToken);
473
- }
474
- setOfflineCore() {
475
- this.stopRefreshWorker(), this.stopToken = new he();
476
- }
477
- async startRefreshWorker(e, t) {
478
- this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called.");
479
- let n = !0;
480
- for (; !t.aborted; ) {
481
- try {
482
- const s = (/* @__PURE__ */ new Date()).getTime() + this.pollIntervalMs;
483
- try {
484
- await this.refreshWorkerLogic(n, e);
485
- } catch (o) {
486
- this.options.logger.autoPollConfigServiceErrorDuringPolling(o);
487
- }
488
- const r = s - (/* @__PURE__ */ new Date()).getTime();
489
- r > 0 && await qe(r, t);
490
- } catch (s) {
491
- this.options.logger.autoPollConfigServiceErrorDuringPolling(s);
492
- }
493
- n = !1, e = null;
599
+ case 2: {
600
+ const i = n.i;
601
+ if (i != null)
602
+ return i;
603
+ break;
494
604
  }
605
+ case 3: {
606
+ const i = n.d;
607
+ if (i != null)
608
+ return i;
609
+ break;
610
+ }
611
+ case -1:
612
+ if (pt(n))
613
+ return n;
614
+ default:
615
+ 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}).`);
616
+ return;
495
617
  }
496
- stopRefreshWorker() {
497
- this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() called."), this.stopToken.abort();
498
- }
499
- async refreshWorkerLogic(e, t) {
500
- this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called.");
501
- const n = await (t ?? this.options.cache.get(this.cacheKey));
502
- n.isExpired(this.pollExpirationMs) ? (e ? !this.isOfflineExactly : !this.isOffline) && await this.refreshConfigCoreAsync(n) : e && this.signalInitialization();
503
- }
504
- getCacheState(e) {
505
- return e.isEmpty ? 0 : e.isExpired(this.pollIntervalMs) ? 2 : 3;
618
+ t || T("Setting value is missing or invalid.");
619
+ }
620
+ function T(n) {
621
+ throw new fe(n);
622
+ }
623
+ class fe extends Error {
624
+ constructor(e) {
625
+ super(e), this.message = e, this.name = fe.name, rt(this, fe);
506
626
  }
507
627
  }
508
- class lt {
628
+ class un {
509
629
  constructor() {
510
- this.cachedConfig = O.empty;
630
+ this.cachedConfig = I.empty;
511
631
  }
512
632
  set(e, t) {
513
633
  this.cachedConfig = t;
@@ -519,70 +639,75 @@ class lt {
519
639
  return this.cachedConfig;
520
640
  }
521
641
  }
522
- class ae {
642
+ class Me {
523
643
  constructor(e, t) {
524
- this.cache = e, this.logger = t, this.cachedConfig = O.empty;
644
+ this.cache = e, this.logger = t, this.cachedConfig = I.empty, this.cachedSerializedConfig = void 0;
525
645
  }
526
646
  async set(e, t) {
527
647
  try {
528
648
  if (!t.isEmpty)
529
- this.cachedSerializedConfig = O.serialize(t), this.cachedConfig = t;
649
+ this.cachedSerializedConfig = I.serialize(t), this.cachedConfig = t;
530
650
  else {
531
651
  this.cachedSerializedConfig = void 0, this.cachedConfig = t;
532
652
  return;
533
653
  }
534
654
  await this.cache.set(e, this.cachedSerializedConfig);
535
- } catch (n) {
536
- this.logger.configServiceCacheWriteError(n);
655
+ } catch (i) {
656
+ this.logger.configServiceCacheWriteError(i);
537
657
  }
538
658
  }
539
659
  updateCachedConfig(e) {
540
- e == null || e === this.cachedSerializedConfig || (this.cachedConfig = O.deserialize(e), this.cachedSerializedConfig = e);
660
+ if (e == null || e === this.cachedSerializedConfig)
661
+ return this.cachedConfig;
662
+ const t = I.deserialize(e), i = !I.contentEquals(t, this.cachedConfig);
663
+ return this.cachedConfig = t, this.cachedSerializedConfig = e, i ? [this.cachedConfig] : this.cachedConfig;
541
664
  }
542
665
  get(e) {
666
+ let t;
543
667
  try {
544
- const t = this.cache.get(e);
545
- if (Ut(t))
546
- return (async (n) => {
668
+ const i = this.cache.get(e);
669
+ if (Zt(i))
670
+ return (async (s) => {
671
+ let r;
547
672
  try {
548
- this.updateCachedConfig(await n);
549
- } catch (s) {
550
- this.logger.configServiceCacheReadError(s);
673
+ r = this.updateCachedConfig(await s);
674
+ } catch (o) {
675
+ r = this.cachedConfig, this.logger.configServiceCacheReadError(o);
551
676
  }
552
- return this.cachedConfig;
553
- })(t);
554
- this.updateCachedConfig(t);
555
- } catch (t) {
556
- this.logger.configServiceCacheReadError(t);
677
+ return r;
678
+ })(i);
679
+ t = this.updateCachedConfig(i);
680
+ } catch (i) {
681
+ t = this.cachedConfig, this.logger.configServiceCacheReadError(i);
557
682
  }
558
- return Promise.resolve(this.cachedConfig);
683
+ return t;
559
684
  }
560
685
  getInMemory() {
561
686
  return this.cachedConfig;
562
687
  }
563
688
  }
564
- var Ae;
565
- (function(i) {
566
- i[i.Debug = 4] = "Debug", i[i.Info = 3] = "Info", i[i.Warn = 2] = "Warn", i[i.Error = 1] = "Error", i[i.Off = -1] = "Off";
567
- })(Ae || (Ae = {}));
568
- function Vt(i) {
569
- return Ae[i];
689
+ var Ge;
690
+ (function(n) {
691
+ 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";
692
+ })(Ge || (Ge = {}));
693
+ function fn(n) {
694
+ return Ge[n];
570
695
  }
571
696
  class y {
572
697
  static from(...e) {
573
- return (t, ...n) => new y(t, e, n);
698
+ return (t, ...i) => new y(t, e, i);
574
699
  }
575
- constructor(e, t, n) {
576
- this.strings = e, this.argNames = t, this.argValues = n;
700
+ constructor(e, t, i) {
701
+ this.strings = e, this.argNames = t, this.argValues = i, this.cachedDefaultFormattedMessage = void 0;
577
702
  }
578
703
  get defaultFormattedMessage() {
579
704
  let e = this.cachedDefaultFormattedMessage;
580
- if (e === void 0) {
705
+ if (!S(e)) {
581
706
  e = "";
582
- const { strings: t, argValues: n } = this;
707
+ const { strings: t, argValues: i } = this;
583
708
  let s = 0;
584
709
  for (; s < t.length - 1; s++)
585
- e += t[s], e += n[s];
710
+ e += t[s], e += F(i[s]);
586
711
  e += t[s], this.cachedDefaultFormattedMessage = e;
587
712
  }
588
713
  return e;
@@ -591,7 +716,11 @@ class y {
591
716
  return this.defaultFormattedMessage;
592
717
  }
593
718
  }
594
- class qt {
719
+ function j(n) {
720
+ var e;
721
+ return S(n) ? n : (e = n.cachedDefaultFormattedMessage) !== null && e !== void 0 ? e : new pe(n, (t) => t.defaultFormattedMessage);
722
+ }
723
+ class ai {
595
724
  get level() {
596
725
  var e;
597
726
  return (e = this.logger.level) !== null && e !== void 0 ? e : 2;
@@ -601,42 +730,42 @@ class qt {
601
730
  return (e = this.logger.eol) !== null && e !== void 0 ? e : `
602
731
  `;
603
732
  }
604
- constructor(e, t) {
605
- this.logger = e, this.hooks = t;
733
+ constructor(e, t, i) {
734
+ this.logger = e, this.filter = t, this.hooks = i;
606
735
  }
607
736
  isEnabled(e) {
608
737
  return this.level >= e;
609
738
  }
610
- log(e, t, n, s) {
739
+ log(e, t, i, s) {
611
740
  var r;
612
- return this.isEnabled(e) && this.logger.log(e, t, n, s), e === 1 && ((r = this.hooks) === null || r === void 0 || r.emit("clientError", n.toString(), s)), n;
741
+ 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;
613
742
  }
614
- debug(e) {
615
- this.log(4, 0, e);
743
+ debug(e, t) {
744
+ this.log(4, 0, e, t);
616
745
  }
617
746
  configJsonIsNotPresent(e) {
618
747
  return this.log(1, 1e3, y.from("DEFAULT_RETURN_VALUE")`Config JSON is not present. Returning ${e}.`);
619
748
  }
620
- configJsonIsNotPresentSingle(e, t, n) {
621
- 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: '${n}'.`);
749
+ configJsonIsNotPresentSingle(e, t, i) {
750
+ 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}'.`);
622
751
  }
623
- settingEvaluationFailedDueToMissingKey(e, t, n, s) {
624
- 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: '${n}'. Available keys: [${s}].`);
752
+ settingEvaluationFailedDueToMissingKey(e, t, i, s) {
753
+ 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}].`);
625
754
  }
626
- settingEvaluationError(e, t, n) {
627
- return this.log(1, 1002, y.from("METHOD_NAME", "DEFAULT_RETURN_VALUE")`Error occurred in the \`${e}\` method. Returning ${t}.`, n);
755
+ settingEvaluationError(e, t, i) {
756
+ return this.log(1, 1002, y.from("METHOD_NAME", "DEFAULT_RETURN_VALUE")`Error occurred in the \`${e}\` method. Returning ${t}.`, i);
628
757
  }
629
- settingEvaluationErrorSingle(e, t, n, s, r) {
630
- 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 \`${n}\` parameter that you specified in your application: '${s}'.`, r);
758
+ settingEvaluationErrorSingle(e, t, i, s, r) {
759
+ 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);
631
760
  }
632
- forceRefreshError(e, t) {
761
+ clientMethodError(e, t) {
633
762
  return this.log(1, 1003, y.from("METHOD_NAME")`Error occurred in the \`${e}\` method.`, t);
634
763
  }
635
- fetchFailedDueToInvalidSdkKey() {
636
- return this.log(1, 1100, "Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey");
764
+ fetchFailedDueToInvalidSdkKey(e, t) {
765
+ 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})`);
637
766
  }
638
- fetchFailedDueToUnexpectedHttpResponse(e, t) {
639
- return this.log(1, 1101, y.from("STATUS_CODE", "REASON_PHRASE")`Unexpected HTTP response was received while trying to fetch config JSON: ${e} ${t}`);
767
+ fetchFailedDueToUnexpectedHttpResponse(e, t, i) {
768
+ 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})`);
640
769
  }
641
770
  fetchFailedDueToRequestTimeout(e, t) {
642
771
  return this.log(1, 1102, y.from("TIMEOUT")`Request timed out while trying to fetch config JSON. Timeout value: ${e}ms`, t);
@@ -644,14 +773,14 @@ class qt {
644
773
  fetchFailedDueToUnexpectedError(e) {
645
774
  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);
646
775
  }
647
- fetchFailedDueToRedirectLoop() {
648
- return this.log(1, 1104, "Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/");
776
+ fetchFailedDueToRedirectLoop(e) {
777
+ 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})`);
649
778
  }
650
- fetchReceived200WithInvalidBody(e) {
651
- return this.log(1, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.", e);
779
+ fetchReceived200WithInvalidBody(e, t) {
780
+ 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);
652
781
  }
653
- fetchReceived304WhenLocalCacheIsEmpty(e, t) {
654
- return this.log(1, 1106, y.from("STATUS_CODE", "REASON_PHRASE")`Unexpected HTTP response was received when no config JSON is cached locally: ${e} ${t}`);
782
+ fetchReceived304WhenLocalCacheIsEmpty(e, t, i) {
783
+ 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})`);
655
784
  }
656
785
  autoPollConfigServiceErrorDuringPolling(e) {
657
786
  return this.log(1, 1200, "Error occurred during auto polling.", e);
@@ -666,7 +795,7 @@ class qt {
666
795
  return this.log(1, 2201, "Error occurred while writing the cache.", e);
667
796
  }
668
797
  clientIsAlreadyCreated(e) {
669
- return 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}'.`);
798
+ 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}'.`);
670
799
  }
671
800
  userObjectIsMissing(e) {
672
801
  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/`);
@@ -677,14 +806,14 @@ class qt {
677
806
  userObjectAttributeIsMissingPercentage(e, t) {
678
807
  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/`);
679
808
  }
680
- userObjectAttributeIsMissingCondition(e, t, n) {
681
- return this.log(2, 3003, y.from("CONDITION", "KEY", "ATTRIBUTE_NAME", "ATTRIBUTE_NAME")`Cannot evaluate condition (${e}) for setting '${t}' (the User.${n} attribute is missing). You should set the User.${n} attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/`);
809
+ userObjectAttributeIsMissingCondition(e, t, i) {
810
+ 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/`);
682
811
  }
683
- userObjectAttributeIsInvalid(e, t, n, s) {
684
- return this.log(2, 3004, y.from("CONDITION", "KEY", "REASON", "ATTRIBUTE_NAME")`Cannot evaluate condition (${e}) for setting '${t}' (${n}). Please check the User.${s} attribute and make sure that its value corresponds to the comparison operator.`);
812
+ userObjectAttributeIsInvalid(e, t, i, s) {
813
+ 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.`);
685
814
  }
686
- userObjectAttributeIsAutoConverted(e, t, n, s) {
687
- 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.${n} 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.`);
815
+ userObjectAttributeIsAutoConverted(e, t, i, s) {
816
+ 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.`);
688
817
  }
689
818
  configServiceCannotInitiateHttpCalls() {
690
819
  return this.log(2, 3200, "Client is in offline mode, it cannot initiate HTTP calls.");
@@ -702,379 +831,614 @@ class qt {
702
831
  return this.log(3, 5200, y.from("MODE")`Switched to ${e.toUpperCase()} mode.`);
703
832
  }
704
833
  }
705
- class ct {
834
+ class hn {
706
835
  constructor(e = 2, t = `
707
836
  `) {
708
837
  this.level = e, this.eol = t, this.SOURCE = "ConfigCat";
709
838
  }
710
- log(e, t, n, s) {
711
- 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, Vt(e).toUpperCase()], a = s !== void 0 ? this.eol + D(s, !0) : "";
712
- r(`${this.SOURCE} - ${o} - [${t}] ${n}${a}`);
839
+ log(e, t, i, s) {
840
+ 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) : "";
841
+ r(`${this.SOURCE} - ${o} - [${t}] ${i}${a}`);
713
842
  }
714
843
  }
715
- class we {
716
- constructor() {
717
- this.addListener = this.on, this.off = this.removeListener;
718
- }
719
- on() {
720
- return this;
844
+ function Ft(n) {
845
+ return n.substring(0, n.length - 6).replace(/[^/]/g, "*") + n.substring(n.length - 6);
846
+ }
847
+ var Lt;
848
+ (function(n) {
849
+ n[n.Fetched = 0] = "Fetched", n[n.NotModified = 1] = "NotModified", n[n.Errored = 2] = "Errored";
850
+ })(Lt || (Lt = {}));
851
+ function li(n) {
852
+ return { status: 0, config: n, errorCode: 0 };
853
+ }
854
+ function ci(n) {
855
+ return { status: 1, config: n, errorCode: 0 };
856
+ }
857
+ function ie(n, e, t, i) {
858
+ return { status: 2, config: n, errorCode: e, errorMessage: t, errorException: i };
859
+ }
860
+ class ui {
861
+ constructor(e, t, i, s) {
862
+ this.url = e, this.lastETag = t, this.headers = i, this.timeoutMs = s;
721
863
  }
722
- once() {
723
- return this;
864
+ }
865
+ class gn {
866
+ constructor(e, t, i, s) {
867
+ this.statusCode = e, this.reasonPhrase = t, this.body = s, this.eTag = void 0, this.rayId = void 0;
868
+ let r, o;
869
+ for (const [a, l] of i) {
870
+ const c = a.toLowerCase();
871
+ if (r == null && c === "etag") {
872
+ if (this.eTag = r = l, o != null)
873
+ break;
874
+ } else if (o == null && c === "cf-ray" && (this.rayId = o = l, r != null))
875
+ break;
876
+ }
724
877
  }
725
- removeListener() {
726
- return this;
878
+ }
879
+ class _ extends Error {
880
+ constructor(e, ...t) {
881
+ super(((i, s) => {
882
+ switch (i) {
883
+ case "abort":
884
+ return "Request was aborted.";
885
+ case "timeout":
886
+ const [r] = s;
887
+ return `Request timed out. Timeout value: ${r}ms`;
888
+ case "failure":
889
+ const [o] = s, a = "Request failed due to a network or protocol error.";
890
+ return o ? a + " " + (o instanceof Error ? o.message : F(o)) : a;
891
+ }
892
+ })(e, t)), this.cause = e, this.name = _.name, rt(this, _), this.args = t;
727
893
  }
728
- removeAllListeners() {
729
- return this;
894
+ }
895
+ var Dt;
896
+ (function(n) {
897
+ 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";
898
+ })(Dt || (Dt = {}));
899
+ function dn() {
900
+ return { isSuccess: !0, errorCode: 0 };
901
+ }
902
+ function we(n, e, t) {
903
+ return {
904
+ isSuccess: !1,
905
+ errorCode: n,
906
+ _errorMessage: e,
907
+ get errorMessage() {
908
+ var i;
909
+ return (i = this._errorMessage) === null || i === void 0 ? void 0 : i.toString();
910
+ },
911
+ errorException: t
912
+ };
913
+ }
914
+ function kt(n) {
915
+ return n.status !== 2 ? dn() : we(n.errorCode, n.errorMessage, n.errorException);
916
+ }
917
+ var Re;
918
+ (function(n) {
919
+ n[n.NoFlagData = 0] = "NoFlagData", n[n.HasLocalOverrideFlagDataOnly = 1] = "HasLocalOverrideFlagDataOnly", n[n.HasCachedFlagDataOnly = 2] = "HasCachedFlagDataOnly", n[n.HasUpToDateFlagData = 3] = "HasUpToDateFlagData";
920
+ })(Re || (Re = {}));
921
+ var Qe;
922
+ (function(n) {
923
+ n[n.Online = 0] = "Online", n[n.Offline = 1] = "Offline", n[n.Disposed = 2] = "Disposed";
924
+ })(Qe || (Qe = {}));
925
+ function $t(n) {
926
+ return Qe[n];
927
+ }
928
+ class mt {
929
+ constructor(e) {
930
+ this.options = e, this.pendingCacheSyncUp = null, this.pendingConfigRefresh = null, this.cacheKey = e.getCacheKey(), this.configFetcher = e.configFetcher, this.requestHeaders = [
931
+ ["User-Agent", e.clientVersion],
932
+ ["X-ConfigCat-UserAgent", e.clientVersion]
933
+ ], this.status = e.offline ? 1 : 0;
730
934
  }
731
- listeners() {
732
- return [];
935
+ prepareClientForEvents() {
936
+ var e;
937
+ const t = (e = this.options.hooks.unwrap()) === null || e === void 0 ? void 0 : e.configCatClient, i = t == null ? void 0 : t.initConfigService;
938
+ P(i) && i.call(t, this);
733
939
  }
734
- listenerCount() {
735
- return 0;
940
+ dispose() {
941
+ this.status = 2;
736
942
  }
737
- eventNames() {
738
- return [];
943
+ get disposed() {
944
+ return this.status === 2;
739
945
  }
740
- emit() {
741
- return !1;
946
+ async refreshConfigAsync() {
947
+ const e = await this.syncUpWithCache();
948
+ if (this.isOffline) {
949
+ if (this.options.cache instanceof Me)
950
+ return [dn(), e];
951
+ {
952
+ const t = this.options.logger.configServiceCannotInitiateHttpCalls();
953
+ return [we(3200, j(t)), e];
954
+ }
955
+ } else {
956
+ const [t, i] = await this.refreshConfigCoreAsync(e, !0);
957
+ return [kt(t), i];
958
+ }
742
959
  }
743
- }
744
- function ut(i) {
745
- function e(F, L) {
746
- var J = F << L | F >>> 32 - L;
747
- return J;
960
+ refreshConfigCoreAsync(e, t) {
961
+ if (this.pendingConfigRefresh)
962
+ return this.pendingConfigRefresh;
963
+ const i = (async (s) => {
964
+ const r = await this.fetchAsync(s);
965
+ 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];
966
+ })(e);
967
+ this.pendingConfigRefresh = i;
968
+ try {
969
+ i.finally(() => this.pendingConfigRefresh = null);
970
+ } catch (s) {
971
+ throw this.pendingConfigRefresh = null, s;
972
+ }
973
+ return i;
748
974
  }
749
- var t, n, s, r = new Array(80), o = 1732584193, a = 4023233417, l = 2562383102, c = 271733878, u = 3285377520, h, g, f, p, m, A;
750
- i = K(i);
751
- var E = i.length, w = new Array();
752
- for (n = 0; n < E - 3; n += 4)
753
- s = i.charCodeAt(n) << 24 | i.charCodeAt(n + 1) << 16 | i.charCodeAt(n + 2) << 8 | i.charCodeAt(n + 3), w.push(s);
754
- switch (E % 4) {
755
- case 0:
756
- n = 2147483648;
757
- break;
758
- case 1:
759
- n = i.charCodeAt(E - 1) << 24 | 8388608;
760
- break;
761
- case 2:
762
- n = i.charCodeAt(E - 2) << 24 | i.charCodeAt(E - 1) << 16 | 32768;
763
- break;
764
- case 3:
765
- n = i.charCodeAt(E - 3) << 24 | i.charCodeAt(E - 2) << 16 | i.charCodeAt(E - 1) << 8 | 128;
766
- break;
975
+ onConfigFetched(e, t) {
976
+ this.options.logger.debug("config fetched"), this.options.hooks.emit("configFetched", kt(e), t);
767
977
  }
768
- for (w.push(n); w.length % 16 != 14; )
769
- w.push(0);
770
- for (w.push(E >>> 29), w.push(E << 3 & 4294967295), t = 0; t < w.length; t += 16) {
771
- for (n = 0; n < 16; n++)
772
- r[n] = w[t + n];
773
- for (n = 16; n <= 79; n++)
774
- r[n] = e(r[n - 3] ^ r[n - 8] ^ r[n - 14] ^ r[n - 16], 1);
775
- for (h = o, g = a, f = l, p = c, m = u, n = 0; n <= 19; n++)
776
- A = e(h, 5) + (g & f | ~g & p) + m + r[n] + 1518500249 & 4294967295, m = p, p = f, f = e(g, 30), g = h, h = A;
777
- for (n = 20; n <= 39; n++)
778
- A = e(h, 5) + (g ^ f ^ p) + m + r[n] + 1859775393 & 4294967295, m = p, p = f, f = e(g, 30), g = h, h = A;
779
- for (n = 40; n <= 59; n++)
780
- A = e(h, 5) + (g & f | g & p | f & p) + m + r[n] + 2400959708 & 4294967295, m = p, p = f, f = e(g, 30), g = h, h = A;
781
- for (n = 60; n <= 79; n++)
782
- A = e(h, 5) + (g ^ f ^ p) + m + r[n] + 3395469782 & 4294967295, m = p, p = f, f = e(g, 30), g = h, h = A;
783
- o = o + h & 4294967295, a = a + g & 4294967295, l = l + f & 4294967295, c = c + p & 4294967295, u = u + m & 4294967295;
784
- }
785
- return gt([o, a, l, c, u]);
786
- }
787
- function ht(i) {
788
- function e(xe, _e) {
789
- return xe >>> _e | xe << 32 - _e;
978
+ onConfigChanged(e) {
979
+ var t;
980
+ this.options.logger.debug("config changed"), this.options.hooks.emit("configChanged", (t = e.config) !== null && t !== void 0 ? t : sn({}));
790
981
  }
791
- const t = "length";
792
- var n = Math.pow, s = n(2, 32), r, o, a = ht, l = a.h, c = a.k;
793
- if (!c) {
794
- l = [], c = [];
795
- for (var u = {}, h = 2, g = 0; g < 64; h++)
796
- if (!u[h]) {
797
- for (r = 0; r < 313; r += h)
798
- u[r] = h;
799
- l[g] = n(h, 0.5) * s | 0, c[g++] = n(h, 1 / 3) * s | 0;
982
+ async fetchAsync(e) {
983
+ const t = this.options;
984
+ t.logger.debug("ConfigServiceBase.fetchAsync() called.");
985
+ let i;
986
+ try {
987
+ const [s, r, o] = await this.fetchRequestAsync(e.httpETag);
988
+ switch (s.statusCode) {
989
+ case 200:
990
+ 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));
991
+ case 304:
992
+ 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())));
993
+ case 403:
994
+ case 404:
995
+ 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));
996
+ default:
997
+ 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));
800
998
  }
801
- a.h = l = l.slice(0, 8), a.k = c;
802
- }
803
- var f = i[t] * 8;
804
- i += "€";
805
- for (var p = []; i[t] % 64 - 56; )
806
- i += "\0";
807
- for (r = 0; r < i[t]; r++)
808
- o = i.charCodeAt(r), p[r >> 2] |= o << (3 - r) % 4 * 8;
809
- for (p[p[t]] = f / s | 0, p[p[t]] = f, o = 0; o < p[t]; ) {
810
- var m = p.slice(o, o += 16), A = l;
811
- for (l = l.slice(0, 8), r = 0; r < 64; r++) {
812
- var E = m[r - 15], w = m[r - 2], F = l[0], L = l[4], J = l[7] + (e(L, 6) ^ e(L, 11) ^ e(L, 25)) + (L & l[5] ^ ~L & l[6]) + c[r] + (m[r] = r < 16 ? m[r] : m[r - 16] + (e(E, 7) ^ e(E, 18) ^ E >>> 3) + m[r - 7] + (e(w, 17) ^ e(w, 19) ^ w >>> 10) | 0), It = (e(F, 2) ^ e(F, 13) ^ e(F, 22)) + (F & l[1] ^ F & l[2] ^ l[1] & l[2]);
813
- l = [J + It | 0].concat(l), l[4] = l[4] + J | 0;
999
+ } catch (s) {
1000
+ let r;
1001
+ 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);
814
1002
  }
815
- for (r = 0; r < 8; r++)
816
- l[r] = l[r] + A[r] | 0;
817
1003
  }
818
- return gt(l, 8);
819
- }
820
- function gt(i, e) {
821
- const t = "0123456789abcdef";
822
- var n = "";
823
- e ?? (e = i.length);
824
- for (let s = 0; s < e; s++)
825
- for (let r = 3; r >= 0; r--) {
826
- const o = i[s] >> (r << 3) & 255;
827
- n += t[o >> 4], n += t[o & 15];
1004
+ async fetchRequestAsync(e, t = 2) {
1005
+ const i = this.options;
1006
+ i.logger.debug("ConfigServiceBase.fetchRequestAsync() called.");
1007
+ for (let s = 0; ; s++) {
1008
+ i.logger.debug(`ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()${s > 0 ? `, retry ${s}/${t}` : ""}.`);
1009
+ const r = new ui(i.getUrl(), e, this.requestHeaders, i.requestTimeoutMs), o = await this.configFetcher.fetchAsync(r);
1010
+ if (o.statusCode !== 200)
1011
+ return [o];
1012
+ if (!o.body)
1013
+ return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."), [o, void 0, Error("No response body.")];
1014
+ let a;
1015
+ try {
1016
+ a = nn(o.body);
1017
+ } catch (u) {
1018
+ return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."), [o, void 0, u];
1019
+ }
1020
+ const l = a.p;
1021
+ if (!l)
1022
+ return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences are missing or invalid."), [o, a];
1023
+ const c = l.u;
1024
+ if (c == null || c === i.baseUrl)
1025
+ return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."), [o, a];
1026
+ const f = l.r;
1027
+ if (i.baseUrlOverriden && f !== 2)
1028
+ return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."), [o, a];
1029
+ if (i.baseUrl = c, f === 0)
1030
+ return [o, a];
1031
+ if (f === 1 && i.logger.dataGovernanceIsOutOfSync(), s >= t)
1032
+ return i.logger.fetchFailedDueToRedirectLoop(o.rayId), [o, a];
828
1033
  }
829
- return n;
830
- }
831
- const We = new we();
832
- class Ke {
833
- constructor(e) {
834
- this.addListener = this.on, this.off = this.removeListener, this.eventEmitter = e;
835
1034
  }
836
- tryDisconnect() {
837
- const e = this.eventEmitter;
838
- return this.eventEmitter = We, e !== We;
1035
+ get isOfflineExactly() {
1036
+ return this.status === 1;
839
1037
  }
840
- on(e, t) {
841
- return this.eventEmitter.on(e, t), this;
1038
+ get isOffline() {
1039
+ return this.status !== 0;
842
1040
  }
843
- once(e, t) {
844
- return this.eventEmitter.once(e, t), this;
1041
+ goOnline() {
845
1042
  }
846
- removeListener(e, t) {
847
- return this.eventEmitter.removeListener(e, t), this;
1043
+ setOnline() {
1044
+ this.status === 1 ? (this.goOnline(), this.status = 0, this.options.logger.configServiceStatusChanged($t(this.status))) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline");
848
1045
  }
849
- removeAllListeners(e) {
850
- return this.eventEmitter.removeAllListeners(e), this;
1046
+ setOffline() {
1047
+ this.status === 0 ? (this.status = 1, this.options.logger.configServiceStatusChanged($t(this.status))) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline");
851
1048
  }
852
- listeners(e) {
853
- return this.eventEmitter.listeners(e);
1049
+ syncUpWithCache() {
1050
+ const { cache: e } = this.options;
1051
+ if (e instanceof un)
1052
+ return e.get(this.cacheKey);
1053
+ if (this.pendingCacheSyncUp)
1054
+ return this.pendingCacheSyncUp;
1055
+ const t = e.get(this.cacheKey);
1056
+ if (!Zt(t))
1057
+ return this.onCacheSynced(t);
1058
+ const i = t.then((s) => this.onCacheSynced(s));
1059
+ this.pendingCacheSyncUp = i;
1060
+ try {
1061
+ i.finally(() => this.pendingCacheSyncUp = null);
1062
+ } catch (s) {
1063
+ throw this.pendingCacheSyncUp = null, s;
1064
+ }
1065
+ return i;
854
1066
  }
855
- listenerCount(e) {
856
- return this.eventEmitter.listenerCount(e);
1067
+ onCacheSynced(e) {
1068
+ if (!M(e))
1069
+ return e;
1070
+ const [t] = e;
1071
+ return t.isEmpty || this.onConfigChanged(t), t;
857
1072
  }
858
- eventNames() {
859
- return this.eventEmitter.eventNames();
1073
+ async waitForReadyAsync(e) {
1074
+ return this.getCacheState(await e);
860
1075
  }
861
- emit(e, ...t) {
862
- return this.eventEmitter.emit(e, ...t);
1076
+ getReadyPromise(e) {
1077
+ return this.waitForReadyAsync(e).then((t) => (this.options.hooks.emit("clientReady", t), t));
863
1078
  }
864
1079
  }
865
- function ft() {
866
- const i = function(e) {
867
- this.target = e;
868
- };
869
- return i.prototype.deref = function() {
870
- return this.target;
871
- }, i.isFallback = !0, i;
872
- }
873
- const dt = () => typeof WeakRef == "function";
874
- var Te;
875
- (function(i) {
876
- i[i.AutoPoll = 0] = "AutoPoll", i[i.LazyLoad = 1] = "LazyLoad", i[i.ManualPoll = 2] = "ManualPoll";
877
- })(Te || (Te = {}));
878
- var He;
879
- (function(i) {
880
- i[i.Global = 0] = "Global", i[i.EuOnly = 1] = "EuOnly";
881
- })(He || (He = {}));
882
- class P {
883
- constructor(e, t, n, s, r) {
884
- var o, a, l;
885
- if (this.requestTimeoutMs = 3e4, this.baseUrlOverriden = !1, this.offline = !1, !e)
886
- throw new Error("Invalid 'sdkKey' value");
887
- switch (this.sdkKey = e, this.clientVersion = t, this.dataGovernance = (o = n == null ? void 0 : n.dataGovernance) !== null && o !== void 0 ? o : 0, this.dataGovernance) {
888
- case 1:
889
- this.baseUrl = "https://cdn-eu.configcat.com";
890
- break;
891
- default:
892
- this.baseUrl = "https://cdn-global.configcat.com";
893
- break;
894
- }
895
- const c = (a = r == null ? void 0 : r()) !== null && a !== void 0 ? a : new we(), u = new Ke(c), h = new (dt() ? WeakRef : ft())(u);
896
- this.hooks = {
897
- hooks: u,
898
- hooksWeakRef: h,
899
- emit(p, ...m) {
900
- var A, E;
901
- return (E = (A = this.hooksWeakRef.deref()) === null || A === void 0 ? void 0 : A.emit(p, ...m)) !== null && E !== void 0 ? E : !1;
902
- }
903
- };
904
- let g, f;
905
- if (n) {
906
- if (g = n.logger, f = n.cache, n.requestTimeoutMs) {
907
- if (n.requestTimeoutMs < 0)
908
- throw new Error("Invalid 'requestTimeoutMs' value");
909
- this.requestTimeoutMs = n.requestTimeoutMs;
1080
+ const fi = 500;
1081
+ class hi extends mt {
1082
+ constructor(e) {
1083
+ super(e), this.signalInitialization = () => {
1084
+ }, this.stopToken = new He(), this.pollIntervalMs = e.pollIntervalSeconds * 1e3, this.pollExpirationMs = this.pollIntervalMs - fi, this.prepareClientForEvents();
1085
+ const t = this.syncUpWithCache();
1086
+ if (e.maxInitWaitTimeSeconds !== 0) {
1087
+ this.initialized = !1;
1088
+ const i = new Promise((s) => this.signalInitialization = s);
1089
+ this.initializationPromise = this.waitForInitializationAsync(i).then((s) => (this.initialized = !0, s));
1090
+ } else
1091
+ this.initialized = !0, this.initializationPromise = Promise.resolve(!1);
1092
+ this.readyPromise = this.getReadyPromise(t), this.startRefreshWorker(t, this.stopToken);
1093
+ }
1094
+ async waitForInitializationAsync(e) {
1095
+ if (this.options.maxInitWaitTimeSeconds < 0)
1096
+ return await e, !0;
1097
+ const t = new He(), i = await Promise.race([
1098
+ e.then(() => !0),
1099
+ bt(this.options.maxInitWaitTimeSeconds * 1e3, t).then(() => !1)
1100
+ ]);
1101
+ return t.abort(), i;
1102
+ }
1103
+ async waitForReadyAsync() {
1104
+ return await this.initializationPromise, this.getCacheState(this.options.cache.getInMemory());
1105
+ }
1106
+ async getConfigAsync() {
1107
+ this.options.logger.debug("AutoPollConfigService.getConfigAsync() called.");
1108
+ let e = await this.syncUpWithCache();
1109
+ if (!e.isExpired(this.pollIntervalMs))
1110
+ this.signalInitialization();
1111
+ else if (!this.isOffline && !this.initialized)
1112
+ this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired, waiting for initialization."), await this.initializationPromise, e = this.options.cache.getInMemory();
1113
+ else
1114
+ return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired."), e;
1115
+ return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - returning value from cache."), e;
1116
+ }
1117
+ refreshConfigAsync() {
1118
+ return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."), super.refreshConfigAsync();
1119
+ }
1120
+ dispose() {
1121
+ this.options.logger.debug("AutoPollConfigService.dispose() called."), super.dispose(), this.stopToken.aborted || this.stopRefreshWorker();
1122
+ }
1123
+ onConfigFetched(e, t) {
1124
+ this.signalInitialization(), super.onConfigFetched(e, t);
1125
+ }
1126
+ goOnline() {
1127
+ this.stopRefreshWorker(), this.stopToken = new He(), this.startRefreshWorker(null, this.stopToken);
1128
+ }
1129
+ async startRefreshWorker(e, t) {
1130
+ for (this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called."); !t.aborted; ) {
1131
+ try {
1132
+ const i = wt() + this.pollIntervalMs;
1133
+ try {
1134
+ await this.refreshWorkerLogic(e);
1135
+ } catch (r) {
1136
+ this.options.logger.autoPollConfigServiceErrorDuringPolling(r);
1137
+ }
1138
+ const s = i - wt();
1139
+ s > 0 && await bt(s, t);
1140
+ } catch (i) {
1141
+ this.options.logger.autoPollConfigServiceErrorDuringPolling(i);
910
1142
  }
911
- n.baseUrl && (this.baseUrl = n.baseUrl, this.baseUrlOverriden = !0), n.flagOverrides && (this.flagOverrides = n.flagOverrides), n.defaultUser && (this.defaultUser = n.defaultUser), n.offline && (this.offline = n.offline), (l = n.setupHooks) === null || l === void 0 || l.call(n, u);
1143
+ e = null;
912
1144
  }
913
- this.logger = new qt(g ?? new ct(), this.hooks), this.cache = f ? new ae(f, this.logger) : s ? s(this) : new lt();
914
1145
  }
915
- yieldHooks() {
916
- const e = this.hooks, t = e.hooks;
917
- return delete e.hooks, t ?? new Ke(new we());
1146
+ stopRefreshWorker() {
1147
+ this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() called."), this.stopToken.abort();
918
1148
  }
919
- getUrl() {
920
- return this.baseUrl + "/configuration-files/" + this.sdkKey + "/" + P.configFileName + "?sdk=" + this.clientVersion;
1149
+ async refreshWorkerLogic(e) {
1150
+ this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() called.");
1151
+ const t = await (e ?? this.syncUpWithCache());
1152
+ if (t.isExpired(this.pollExpirationMs) && (e ? !this.isOfflineExactly : !this.isOffline)) {
1153
+ await this.refreshConfigCoreAsync(t, !1);
1154
+ return;
1155
+ }
1156
+ this.signalInitialization();
921
1157
  }
922
- getCacheKey() {
923
- return ut(`${this.sdkKey}_${P.configFileName}_${O.serializationFormatVersion}`);
1158
+ getCacheState(e) {
1159
+ return e.isEmpty ? 0 : e.isExpired(this.pollIntervalMs) ? 2 : 3;
924
1160
  }
925
1161
  }
926
- P.configFileName = "config_v6.json";
927
- class ze extends P {
928
- constructor(e, t, n, s, r, o) {
929
- super(e, t + "/a-" + n, s, r, o), this.pollIntervalSeconds = 60, this.maxInitWaitTimeSeconds = 5, s && (s.pollIntervalSeconds != null && (this.pollIntervalSeconds = s.pollIntervalSeconds), s.maxInitWaitTimeSeconds != null && (this.maxInitWaitTimeSeconds = s.maxInitWaitTimeSeconds));
930
- const a = 2147483;
931
- if (!(typeof this.pollIntervalSeconds == "number" && 1 <= this.pollIntervalSeconds && this.pollIntervalSeconds <= a))
932
- throw new Error("Invalid 'pollIntervalSeconds' value");
933
- if (!(typeof this.maxInitWaitTimeSeconds == "number" && this.maxInitWaitTimeSeconds <= a))
934
- throw new Error("Invalid 'maxInitWaitTimeSeconds' value");
1162
+ class Ne {
1163
+ on() {
1164
+ return this;
935
1165
  }
936
- }
937
- class je extends P {
938
- constructor(e, t, n, s, r, o) {
939
- super(e, t + "/m-" + n, s, r, o);
1166
+ once() {
1167
+ return this;
940
1168
  }
941
- }
942
- class Je extends P {
943
- constructor(e, t, n, s, r, o) {
944
- if (super(e, t + "/l-" + n, s, r, o), this.cacheTimeToLiveSeconds = 60, s && s.cacheTimeToLiveSeconds != null && (this.cacheTimeToLiveSeconds = s.cacheTimeToLiveSeconds), !(typeof this.cacheTimeToLiveSeconds == "number" && 1 <= this.cacheTimeToLiveSeconds && this.cacheTimeToLiveSeconds <= 2147483647))
945
- throw new Error("Invalid 'cacheTimeToLiveSeconds' value");
1169
+ removeListener() {
1170
+ return this;
1171
+ }
1172
+ removeAllListeners() {
1173
+ return this;
1174
+ }
1175
+ listeners() {
1176
+ return [];
1177
+ }
1178
+ listenerCount() {
1179
+ return 0;
1180
+ }
1181
+ eventNames() {
1182
+ return [];
1183
+ }
1184
+ emit() {
1185
+ return !1;
946
1186
  }
947
1187
  }
948
- var Ie;
949
- (function(i) {
950
- i[i.LocalOnly = 0] = "LocalOnly", i[i.LocalOverRemote = 1] = "LocalOverRemote", i[i.RemoteOverLocal = 2] = "RemoteOverLocal";
951
- })(Ie || (Ie = {}));
952
- function Bt(i) {
953
- return Ie[i];
1188
+ const Fe = Ne.prototype;
1189
+ Fe.addListener = Fe.on;
1190
+ Fe.off = Fe.removeListener;
1191
+ var Xe;
1192
+ (function(n) {
1193
+ n[n.LocalOnly = 0] = "LocalOnly", n[n.LocalOverRemote = 1] = "LocalOverRemote", n[n.RemoteOverLocal = 2] = "RemoteOverLocal";
1194
+ })(Xe || (Xe = {}));
1195
+ function Pe(n) {
1196
+ return Xe[n];
954
1197
  }
955
- class Wt {
1198
+ class gi {
956
1199
  constructor(e, t) {
957
- this.initialSettings = Ge(e), t && (this.map = e);
1200
+ this.initialSettings = Ut(e), this.map = t ? e : null;
958
1201
  }
959
1202
  getOverrides() {
960
- return Promise.resolve(this.getOverridesSync());
961
- }
962
- getOverridesSync() {
963
- return this.map ? Ge(this.map) : this.initialSettings;
1203
+ return this.map ? Ut(this.map) : this.initialSettings;
964
1204
  }
965
1205
  }
966
- function Ge(i) {
1206
+ function Ut(n) {
967
1207
  const e = {};
968
- for (const t in i)
969
- Object.prototype.hasOwnProperty.call(i, t) && (e[t] = $.fromValue(i[t]));
1208
+ for (const t in n)
1209
+ L(n, t) && (e[t] = rn(n[t]));
970
1210
  return e;
971
1211
  }
972
- const Kt = "cc-", G = ";str";
973
- class Ht {
1212
+ const di = "cc-", Ee = ";str";
1213
+ class vi {
974
1214
  get currentValue() {
975
- if (!(typeof location > "u"))
1215
+ if (!(typeof location > "u" || location === null))
976
1216
  return location.search;
977
1217
  }
978
1218
  }
979
- let Y;
980
- class zt {
981
- constructor(e, t, n) {
982
- this.watchChanges = e, this.paramPrefix = t ?? Kt, n ?? (n = Y ?? (Y = new Ht())), this.queryStringProvider = n;
983
- const s = n.currentValue;
984
- this.settings = Qe(s, this.paramPrefix), this.queryString = Ye(s);
1219
+ let Se;
1220
+ class pi {
1221
+ constructor(e, t, i) {
1222
+ this.watchChanges = !!e, this.paramPrefix = t ?? di, i ?? (i = Se ?? (Se = new vi())), this.queryStringProvider = i;
1223
+ const s = i.currentValue;
1224
+ this.settings = Pt(s, this.paramPrefix), this.queryString = Mt(s);
985
1225
  }
986
1226
  getOverrides() {
987
- return Promise.resolve(this.getOverridesSync());
988
- }
989
- getOverridesSync() {
990
1227
  if (this.watchChanges) {
991
- const e = this.queryStringProvider.currentValue, t = Ye(e);
992
- this.queryString !== t && (this.settings = Qe(e, this.paramPrefix), this.queryString = t);
1228
+ const e = this.queryStringProvider.currentValue, t = Mt(e);
1229
+ this.queryString !== t && (this.settings = Pt(e, this.paramPrefix), this.queryString = t);
993
1230
  }
994
1231
  return this.settings;
995
1232
  }
996
1233
  }
997
- function Ye(i) {
998
- if (i == null)
1234
+ function Mt(n) {
1235
+ if (n == null)
999
1236
  return "";
1000
- if (typeof i == "string")
1001
- return i;
1237
+ if (S(n))
1238
+ return n;
1002
1239
  let e = "", t = "?";
1003
- for (const n in i) {
1004
- if (!Object.prototype.hasOwnProperty.call(i, n))
1240
+ for (const i in n) {
1241
+ if (!L(n, i))
1005
1242
  continue;
1006
- const s = i[n];
1243
+ const s = n[i];
1007
1244
  let r, o;
1008
- if (!x(s))
1245
+ if (!M(s))
1009
1246
  r = s, o = 1;
1010
1247
  else if (s.length)
1011
1248
  r = s[0], o = s.length;
1012
1249
  else
1013
1250
  continue;
1014
- for (let a = 0; e += t + encodeURIComponent(n) + "=" + encodeURIComponent(r), !(++a >= o); )
1251
+ for (let a = 0; e += t + encodeURIComponent(i) + "=" + encodeURIComponent(r), !(++a >= o); )
1015
1252
  t = "&", r = s[a];
1016
1253
  }
1017
1254
  return e;
1018
1255
  }
1019
- function Qe(i, e) {
1256
+ function Pt(n, e) {
1020
1257
  const t = {};
1021
- return typeof i == "string" ? Jt(i, e, t) : i != null && jt(i, e, t), t;
1258
+ return S(n) ? mi(n, e, t) : n != null && yi(n, e, t), t;
1022
1259
  }
1023
- function jt(i, e, t) {
1024
- for (const n in i) {
1025
- if (!Object.prototype.hasOwnProperty.call(i, n))
1260
+ function yi(n, e, t) {
1261
+ for (const i in n) {
1262
+ if (!L(n, i))
1026
1263
  continue;
1027
- const s = i[n];
1264
+ const s = n[i];
1028
1265
  let r, o;
1029
- if (!x(s))
1266
+ if (!M(s))
1030
1267
  r = s, o = 1;
1031
1268
  else if (s.length)
1032
1269
  r = s[0], o = s.length;
1033
1270
  else
1034
1271
  continue;
1035
- for (let a = 0; pt(n, r, e, t), !(++a >= o); )
1272
+ for (let a = 0; vn(i, r, e, t), !(++a >= o); )
1036
1273
  r = s[a];
1037
1274
  }
1038
1275
  }
1039
- function Jt(i, e, t) {
1040
- if (!i || i.lastIndexOf("?", 0) < 0)
1276
+ function mi(n, e, t) {
1277
+ if (!n || n.lastIndexOf("?", 0) < 0)
1041
1278
  return;
1042
- const n = i.substring(1).split("&");
1043
- for (let s of n) {
1279
+ const i = n.substring(1).split("&");
1280
+ for (let s of i) {
1044
1281
  s = s.replace(/\+/g, " ");
1045
1282
  const r = s.indexOf("="), o = decodeURIComponent(r >= 0 ? s.substring(0, r) : s), a = r >= 0 ? decodeURIComponent(s.substring(r + 1)) : "";
1046
- pt(o, a, e, t);
1283
+ vn(o, a, e, t);
1047
1284
  }
1048
1285
  }
1049
- function pt(i, e, t, n) {
1050
- if (!i || i.length <= t.length || i.lastIndexOf(t, 0) < 0)
1286
+ function vn(n, e, t, i) {
1287
+ if (!n || n.length <= t.length || n.lastIndexOf(t, 0) < 0)
1051
1288
  return;
1052
- i = i.substring(t.length), i.length > G.length && i.indexOf(G, i.length - G.length) >= 0 ? i = i.substring(0, i.length - G.length) : e = Gt(e), n[i] = $.fromValue(e);
1289
+ 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);
1053
1290
  }
1054
- function Gt(i) {
1055
- switch (i.toLowerCase()) {
1291
+ function Ei(n) {
1292
+ switch (n.toLowerCase()) {
1056
1293
  case "false":
1057
1294
  return !1;
1058
1295
  case "true":
1059
1296
  return !0;
1060
1297
  default:
1061
- const e = $e(i);
1062
- return isNaN(e) ? i : e;
1298
+ const e = ft(n);
1299
+ return isNaN(e) ? n : e;
1300
+ }
1301
+ }
1302
+ function pn(n) {
1303
+ function e(b, x) {
1304
+ var me = b << x | b >>> 32 - x;
1305
+ return me;
1306
+ }
1307
+ var t, i, s, r = new Array(80), o = 1732584193, a = 4023233417, l = 2562383102, c = 271733878, f = 3285377520, u, h, g, d, E, A;
1308
+ n = ue(n);
1309
+ var p = n.length, C = new Array();
1310
+ for (i = 0; i < p - 3; i += 4)
1311
+ s = n.charCodeAt(i) << 24 | n.charCodeAt(i + 1) << 16 | n.charCodeAt(i + 2) << 8 | n.charCodeAt(i + 3), C.push(s);
1312
+ switch (p % 4) {
1313
+ case 0:
1314
+ i = 2147483648;
1315
+ break;
1316
+ case 1:
1317
+ i = n.charCodeAt(p - 1) << 24 | 8388608;
1318
+ break;
1319
+ case 2:
1320
+ i = n.charCodeAt(p - 2) << 24 | n.charCodeAt(p - 1) << 16 | 32768;
1321
+ break;
1322
+ case 3:
1323
+ i = n.charCodeAt(p - 3) << 24 | n.charCodeAt(p - 2) << 16 | n.charCodeAt(p - 1) << 8 | 128;
1324
+ break;
1325
+ }
1326
+ for (C.push(i); C.length % 16 != 14; )
1327
+ C.push(0);
1328
+ for (C.push(p >>> 29), C.push(p << 3 & 4294967295), t = 0; t < C.length; t += 16) {
1329
+ for (i = 0; i < 16; i++)
1330
+ r[i] = C[t + i];
1331
+ for (i = 16; i <= 79; i++)
1332
+ r[i] = e(r[i - 3] ^ r[i - 8] ^ r[i - 14] ^ r[i - 16], 1);
1333
+ for (u = o, h = a, g = l, d = c, E = f, i = 0; i <= 19; i++)
1334
+ 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;
1335
+ for (i = 20; i <= 39; i++)
1336
+ A = e(u, 5) + (h ^ g ^ d) + E + r[i] + 1859775393 & 4294967295, E = d, d = g, g = e(h, 30), h = u, u = A;
1337
+ for (i = 40; i <= 59; i++)
1338
+ 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;
1339
+ for (i = 60; i <= 79; i++)
1340
+ A = e(u, 5) + (h ^ g ^ d) + E + r[i] + 3395469782 & 4294967295, E = d, d = g, g = e(h, 30), h = u, u = A;
1341
+ o = o + u & 4294967295, a = a + h & 4294967295, l = l + g & 4294967295, c = c + d & 4294967295, f = f + E & 4294967295;
1342
+ }
1343
+ return yn([o, a, l, c, f]);
1344
+ }
1345
+ const Si = /* @__PURE__ */ Object.create(null);
1346
+ function Ai(n) {
1347
+ function e(Tt, It) {
1348
+ return Tt >>> It | Tt << 32 - It;
1349
+ }
1350
+ const t = "length";
1351
+ var i = Math.pow, s = i(2, 32), r, o, a = Si, l = a.h, c = a.k;
1352
+ if (!c) {
1353
+ l = [], c = [];
1354
+ for (var f = N(), u = 2, h = 0; h < 64; u++)
1355
+ if (!f[u]) {
1356
+ for (r = 0; r < 313; r += u)
1357
+ f[r] = u;
1358
+ l[h] = i(u, 0.5) * s | 0, c[h++] = i(u, 1 / 3) * s | 0;
1359
+ }
1360
+ a.h = l = l.slice(0, 8), a.k = c;
1361
+ }
1362
+ var g = n[t] * 8;
1363
+ n += "€";
1364
+ for (var d = []; n[t] % 64 - 56; )
1365
+ n += "\0";
1366
+ for (r = 0; r < n[t]; r++)
1367
+ o = n.charCodeAt(r), d[r >> 2] |= o << (3 - r) % 4 * 8;
1368
+ for (d[d[t]] = g / s | 0, d[d[t]] = g, o = 0; o < d[t]; ) {
1369
+ var E = d.slice(o, o += 16), A = l;
1370
+ for (l = l.slice(0, 8), r = 0; r < 64; r++) {
1371
+ 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]);
1372
+ l = [me + Dn | 0].concat(l), l[4] = l[4] + me | 0;
1373
+ }
1374
+ for (r = 0; r < 8; r++)
1375
+ l[r] = l[r] + A[r] | 0;
1376
+ }
1377
+ return yn(l, 8);
1378
+ }
1379
+ function yn(n, e) {
1380
+ const t = "0123456789abcdef";
1381
+ var i = "";
1382
+ e ?? (e = n.length);
1383
+ for (let s = 0; s < e; s++)
1384
+ for (let r = 3; r >= 0; r--) {
1385
+ const o = n[s] >> (r << 3) & 255;
1386
+ i += t[o >> 4], i += t[o & 15];
1387
+ }
1388
+ return i;
1389
+ }
1390
+ const xt = new Ne();
1391
+ class Ze {
1392
+ constructor(e) {
1393
+ this.eventEmitter = e;
1394
+ const t = /* @__PURE__ */ Object.create(null);
1395
+ t.get = () => this.configCatClient, t.enumerable = !0, Object.defineProperty(e, "configCatClient", t);
1396
+ }
1397
+ tryDisconnect() {
1398
+ const e = this.eventEmitter;
1399
+ return this.eventEmitter = xt, e !== xt;
1400
+ }
1401
+ on(e, t) {
1402
+ return this.eventEmitter.on(e, t), this;
1403
+ }
1404
+ once(e, t) {
1405
+ return this.eventEmitter.once(e, t), this;
1406
+ }
1407
+ removeListener(e, t) {
1408
+ return this.eventEmitter.removeListener(e, t), this;
1409
+ }
1410
+ removeAllListeners(e) {
1411
+ return this.eventEmitter.removeAllListeners(e), this;
1412
+ }
1413
+ listeners(e) {
1414
+ return this.eventEmitter.listeners(e);
1415
+ }
1416
+ listenerCount(e) {
1417
+ return this.eventEmitter.listenerCount(e);
1418
+ }
1419
+ eventNames() {
1420
+ return this.eventEmitter.eventNames();
1421
+ }
1422
+ emit(e, ...t) {
1423
+ return this.eventEmitter.emit(e, ...t);
1063
1424
  }
1064
1425
  }
1065
- class Yt extends Le {
1066
- constructor(e, t) {
1067
- super(e, t), this.cacheTimeToLiveMs = t.cacheTimeToLiveSeconds * 1e3;
1068
- const n = this.syncUpWithCache();
1069
- this.readyPromise = this.getReadyPromise(n, async (s) => this.getCacheState(await s));
1070
- }
1071
- async getConfig() {
1072
- this.options.logger.debug("LazyLoadConfigService.getConfig() called.");
1073
- function e(n, s = "") {
1074
- n.debug(`LazyLoadConfigService.getConfig(): cache is empty or expired${s}.`);
1426
+ const Le = Ze.prototype;
1427
+ Le.addListener = Le.on;
1428
+ Le.off = Le.removeListener;
1429
+ class Oi extends mt {
1430
+ constructor(e) {
1431
+ super(e), this.cacheTimeToLiveMs = e.cacheTimeToLiveSeconds * 1e3, this.prepareClientForEvents();
1432
+ const t = this.syncUpWithCache();
1433
+ this.readyPromise = this.getReadyPromise(t);
1434
+ }
1435
+ async getConfigAsync() {
1436
+ this.options.logger.debug("LazyLoadConfigService.getConfigAsync() called.");
1437
+ function e(i, s = "") {
1438
+ i.debug(`LazyLoadConfigService.getConfigAsync(): cache is empty or expired${s}.`);
1075
1439
  }
1076
- let t = await this.options.cache.get(this.cacheKey);
1077
- return t.isExpired(this.cacheTimeToLiveMs) ? (this.isOffline ? e(this.options.logger) : (e(this.options.logger, ", calling refreshConfigCoreAsync()"), [, t] = await this.refreshConfigCoreAsync(t)), t) : (this.options.logger.debug("LazyLoadConfigService.getConfig(): cache is valid, returning from cache."), t);
1440
+ let t = await this.syncUpWithCache();
1441
+ return t.isExpired(this.cacheTimeToLiveMs) ? (this.isOffline ? e(this.options.logger) : (e(this.options.logger, ", calling refreshConfigCoreAsync()"), [, t] = await this.refreshConfigCoreAsync(t, !1)), t) : (this.options.logger.debug("LazyLoadConfigService.getConfigAsync(): cache is valid, returning from cache."), t);
1078
1442
  }
1079
1443
  refreshConfigAsync() {
1080
1444
  return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."), super.refreshConfigAsync();
@@ -1083,24 +1447,131 @@ class Yt extends Le {
1083
1447
  return e.isEmpty ? 0 : e.isExpired(this.cacheTimeToLiveMs) ? 2 : 3;
1084
1448
  }
1085
1449
  }
1086
- class Qt extends Le {
1087
- constructor(e, t) {
1088
- super(e, t);
1089
- const n = this.syncUpWithCache();
1090
- this.readyPromise = this.getReadyPromise(n, async (s) => this.getCacheState(await s));
1450
+ class Ci extends mt {
1451
+ constructor(e) {
1452
+ super(e), this.prepareClientForEvents();
1453
+ const t = this.syncUpWithCache();
1454
+ this.readyPromise = this.getReadyPromise(t);
1091
1455
  }
1092
1456
  getCacheState(e) {
1093
1457
  return e.isEmpty ? 0 : 2;
1094
1458
  }
1095
- async getConfig() {
1096
- return this.options.logger.debug("ManualPollService.getConfig() called."), await this.options.cache.get(this.cacheKey);
1459
+ async getConfigAsync() {
1460
+ return this.options.logger.debug("ManualPollService.getConfigAsync() called."), await this.syncUpWithCache();
1097
1461
  }
1098
1462
  refreshConfigAsync() {
1099
1463
  return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."), super.refreshConfigAsync();
1100
1464
  }
1101
1465
  }
1102
- const vt = "<invalid value>", ge = "<invalid name>", Pe = "<invalid operator>", Xe = "<invalid reference>", Xt = 10;
1103
- class yt {
1466
+ const et = "configcat-proxy/";
1467
+ var tt;
1468
+ (function(n) {
1469
+ n[n.AutoPoll = 0] = "AutoPoll", n[n.LazyLoad = 1] = "LazyLoad", n[n.ManualPoll = 2] = "ManualPoll";
1470
+ })(tt || (tt = {}));
1471
+ var nt;
1472
+ (function(n) {
1473
+ n[n.Global = 0] = "Global", n[n.EuOnly = 1] = "EuOnly";
1474
+ })(nt || (nt = {}));
1475
+ function Ti(n) {
1476
+ return nt[n];
1477
+ }
1478
+ class J {
1479
+ constructor(e, t, i, s) {
1480
+ var r, o, a, l;
1481
+ this.requestTimeoutMs = 3e4, this.dataGovernance = 0, this.flagOverrides = null, this.defaultUser = void 0, this.offline = !1, this.sdkKey = e, this.clientVersion = i;
1482
+ const c = (o = (r = t.eventEmitterFactory) === null || r === void 0 ? void 0 : r.call(t)) !== null && o !== void 0 ? o : new Ne(), f = new Ze(c);
1483
+ this.hooks = {
1484
+ hooks: f,
1485
+ unwrap() {
1486
+ return this.hooks;
1487
+ },
1488
+ emit(A, ...p) {
1489
+ var C, b;
1490
+ return (b = (C = this.unwrap()) === null || C === void 0 ? void 0 : C.emit(A, ...p)) !== null && b !== void 0 ? b : !1;
1491
+ }
1492
+ };
1493
+ let u, h, g, d, E;
1494
+ if (s) {
1495
+ const A = "options";
1496
+ if (s.logFilter != null && (u = Rt(s.logFilter, A, ".logFilter")), s.logger != null) {
1497
+ const p = N();
1498
+ p.log = !0, h = $(s.logger, A, p, ".logger");
1499
+ }
1500
+ if (s.cache != null) {
1501
+ const p = N();
1502
+ p.get = p.set = !0, g = $(s.cache, A, p, ".cache");
1503
+ }
1504
+ if (s.configFetcher != null) {
1505
+ const p = N();
1506
+ p.fetchAsync = !0, d = $(s.configFetcher, A, p, ".configFetcher");
1507
+ }
1508
+ if (s.requestTimeoutMs != null && (this.requestTimeoutMs = Te(s.requestTimeoutMs, A, "greater than 0", (p) => p > 0, ".requestTimeoutMs")), s.dataGovernance != null && (this.dataGovernance = Z(s.dataGovernance, A, "DataGovernance", (p) => Ti(p) !== void 0, ".dataGovernance")), s.baseUrl != null && (E = G(s.baseUrl, A, !0, ".baseUrl")), s.flagOverrides != null) {
1509
+ const p = N();
1510
+ p.behaviour = p.dataSource = !1;
1511
+ const C = $(s.flagOverrides, A, p, ".flagOverrides");
1512
+ Z(C.behaviour, A, "OverrideBehaviour", (x) => Pe(x) !== void 0, ".flagOverrides.behaviour");
1513
+ const b = N();
1514
+ b.getOverrides = !0, $(C.dataSource, A, b, ".flagOverrides.dataSource"), this.flagOverrides = C;
1515
+ }
1516
+ s.defaultUser != null && (this.defaultUser = $(s.defaultUser, A, void 0, ".defaultUser")), s.offline != null && (this.offline = ct(s.offline, A, ".offline")), s.setupHooks != null && Rt(s.setupHooks, A, ".setupHooks")(f);
1517
+ }
1518
+ (this.baseUrlOverriden = E != null) ? this.baseUrl = E : this.baseUrl = this.dataGovernance === 1 ? "https://cdn-eu.configcat.com" : "https://cdn-global.configcat.com", this.logger = new ai(h ?? new hn(), u, this.hooks), this.cache = g ? new Me(g, this.logger) : (l = (a = t.defaultCacheFactory) === null || a === void 0 ? void 0 : a.call(t, this)) !== null && l !== void 0 ? l : new un(), this.configFetcher = d ?? t.configFetcherFactory(this);
1519
+ }
1520
+ yieldHooks() {
1521
+ var e;
1522
+ const t = this.hooks, i = (e = t.unwrap()) !== null && e !== void 0 ? e : new Ze(new Ne());
1523
+ return t.hooks = Yt(i), t.unwrap = function() {
1524
+ return this.hooks.deref();
1525
+ }, i;
1526
+ }
1527
+ getUrl() {
1528
+ const { baseUrl: e } = this;
1529
+ return e + (e.charCodeAt(e.length - 1) !== 47 ? "/" : "") + "configuration-files/" + this.sdkKey + "/" + J.configFileName + "?sdk=" + this.clientVersion;
1530
+ }
1531
+ getCacheKey() {
1532
+ return pn(`${this.sdkKey}_${J.configFileName}_${I.serializationFormatVersion}`);
1533
+ }
1534
+ }
1535
+ J.configFileName = "config_v6.json";
1536
+ const _t = "/" + et, Ii = /^https?:\/\/(?:[a-z0-9-]+\.)+configcat\.com\.?(?:[:/]|$)/i;
1537
+ function mn(n) {
1538
+ if (!Ii.test(n))
1539
+ return !1;
1540
+ let e = n.indexOf("?");
1541
+ return e = n.lastIndexOf(_t, (e >= 0 ? e : n.length) - _t.length), e < 0;
1542
+ }
1543
+ class bi extends J {
1544
+ constructor(e, t, i) {
1545
+ if (super(e, t, t.sdkType + "/a-" + t.sdkVersion, i), this.pollIntervalSeconds = 60, this.maxInitWaitTimeSeconds = 5, i) {
1546
+ const s = "options";
1547
+ i.pollIntervalSeconds != null && (this.pollIntervalSeconds = Te(i.pollIntervalSeconds, s, "between 1 and 2147483", (l) => Qt(l, 1, 2147483), ".pollIntervalSeconds")), i.maxInitWaitTimeSeconds != null && (this.maxInitWaitTimeSeconds = Te(i.maxInitWaitTimeSeconds, s, "less than or equal to 2147483", (a) => a <= 2147483, ".maxInitWaitTimeSeconds"));
1548
+ }
1549
+ }
1550
+ createConfigService() {
1551
+ return new hi(this);
1552
+ }
1553
+ }
1554
+ class wi extends J {
1555
+ constructor(e, t, i) {
1556
+ super(e, t, t.sdkType + "/m-" + t.sdkVersion, i);
1557
+ }
1558
+ createConfigService() {
1559
+ return new Ci(this);
1560
+ }
1561
+ }
1562
+ class Ri extends J {
1563
+ constructor(e, t, i) {
1564
+ if (super(e, t, t.sdkType + "/l-" + t.sdkVersion, i), this.cacheTimeToLiveSeconds = 60, i) {
1565
+ const s = "options";
1566
+ i.cacheTimeToLiveSeconds != null && (this.cacheTimeToLiveSeconds = Te(i.cacheTimeToLiveSeconds, s, "between 1 and 2147483647", (a) => Qt(a, 1, 2147483647), ".cacheTimeToLiveSeconds")), i.cacheTimeToLiveSeconds != null && (this.cacheTimeToLiveSeconds = i.cacheTimeToLiveSeconds);
1567
+ }
1568
+ }
1569
+ createConfigService() {
1570
+ return new Oi(this);
1571
+ }
1572
+ }
1573
+ const En = "<invalid value>", Ni = "<invalid name>", Et = "<invalid operator>", Ht = "<invalid reference>", Fi = 10;
1574
+ class Sn {
1104
1575
  constructor(e) {
1105
1576
  this.eol = e, this.log = "", this.indent = "";
1106
1577
  }
@@ -1122,33 +1593,33 @@ class yt {
1122
1593
  toString() {
1123
1594
  return this.log;
1124
1595
  }
1125
- appendUserConditionCore(e, t, n) {
1126
- return this.append(`User.${e} ${fe(t)} '${n ?? vt}'`);
1596
+ appendUserConditionCore(e, t, i) {
1597
+ return this.append(`User.${e} ${qe(t)} '${i ?? En}'`);
1127
1598
  }
1128
- appendUserConditionString(e, t, n, s) {
1129
- return typeof n != "string" ? this.appendUserConditionCore(e, t) : this.appendUserConditionCore(e, t, s ? "<hashed value>" : n);
1599
+ appendUserConditionString(e, t, i, s) {
1600
+ return i == null ? this.appendUserConditionCore(e, t) : this.appendUserConditionCore(e, t, s ? "<hashed value>" : i);
1130
1601
  }
1131
- appendUserConditionStringList(e, t, n, s) {
1132
- if (!ke(n))
1602
+ appendUserConditionStringList(e, t, i, s) {
1603
+ if (i == null)
1133
1604
  return this.appendUserConditionCore(e, t);
1134
- const r = "value", o = "values", a = fe(t);
1605
+ const r = "value", o = "values", a = qe(t);
1135
1606
  if (s)
1136
- return this.append(`User.${e} ${a} [<${n.length} hashed ${n.length === 1 ? r : o}>]`);
1607
+ return this.append(`User.${e} ${a} [<${i.length} hashed ${i.length === 1 ? r : o}>]`);
1137
1608
  {
1138
- const l = De(n, Xt, (c) => `, ... <${c} more ${c === 1 ? r : o}>`);
1609
+ const l = ut(i, Fi, (c) => `, ... <${c} more ${c === 1 ? r : o}>`);
1139
1610
  return this.append(`User.${e} ${a} [${l}]`);
1140
1611
  }
1141
1612
  }
1142
- appendUserConditionNumber(e, t, n, s) {
1143
- if (typeof n != "number")
1613
+ appendUserConditionNumber(e, t, i, s) {
1614
+ if (i == null)
1144
1615
  return this.appendUserConditionCore(e, t);
1145
- const r = fe(t);
1616
+ const r = qe(t);
1146
1617
  let o;
1147
- return s && !isNaN(o = new Date(n * 1e3)) ? this.append(`User.${e} ${r} '${n}' (${o.toISOString()} UTC)`) : this.append(`User.${e} ${r} '${n}'`);
1618
+ return s && !isNaN(o = new Date(i * 1e3)) ? this.append(`User.${e} ${r} '${i}' (${o.toISOString()} UTC)`) : this.append(`User.${e} ${r} '${i}'`);
1148
1619
  }
1149
1620
  appendUserCondition(e) {
1150
- const t = typeof e.comparisonAttribute == "string" ? e.comparisonAttribute : ge, n = e.comparator;
1151
- switch (e.comparator) {
1621
+ const t = e.a, i = e.c;
1622
+ switch (i) {
1152
1623
  case 0:
1153
1624
  case 1:
1154
1625
  case 2:
@@ -1161,21 +1632,21 @@ class yt {
1161
1632
  case 33:
1162
1633
  case 34:
1163
1634
  case 35:
1164
- return this.appendUserConditionStringList(t, n, e.comparisonValue, !1);
1635
+ return this.appendUserConditionStringList(t, i, e.l, !1);
1165
1636
  case 6:
1166
1637
  case 7:
1167
1638
  case 8:
1168
1639
  case 9:
1169
1640
  case 28:
1170
1641
  case 29:
1171
- return this.appendUserConditionString(t, n, e.comparisonValue, !1);
1642
+ return this.appendUserConditionString(t, i, e.s, !1);
1172
1643
  case 10:
1173
1644
  case 11:
1174
1645
  case 12:
1175
1646
  case 13:
1176
1647
  case 14:
1177
1648
  case 15:
1178
- return this.appendUserConditionNumber(t, n, e.comparisonValue);
1649
+ return this.appendUserConditionNumber(t, i, e.d);
1179
1650
  case 16:
1180
1651
  case 17:
1181
1652
  case 22:
@@ -1184,24 +1655,29 @@ class yt {
1184
1655
  case 25:
1185
1656
  case 26:
1186
1657
  case 27:
1187
- return this.appendUserConditionStringList(t, n, e.comparisonValue, !0);
1658
+ return this.appendUserConditionStringList(t, i, e.l, !0);
1188
1659
  case 18:
1189
1660
  case 19:
1190
- return this.appendUserConditionNumber(t, n, e.comparisonValue, !0);
1661
+ return this.appendUserConditionNumber(t, i, e.d, !0);
1191
1662
  case 20:
1192
1663
  case 21:
1193
- return this.appendUserConditionString(t, n, e.comparisonValue, !0);
1194
- default:
1195
- return this.appendUserConditionCore(t, n, e.comparisonValue);
1664
+ return this.appendUserConditionString(t, i, e.s, !0);
1665
+ default: {
1666
+ const s = Di(e);
1667
+ return S(s) ? this.appendUserConditionString(t, i, s, !1) : W(s) ? this.appendUserConditionNumber(t, i, s) : s ? this.appendUserConditionCore(t, i) : this.appendUserConditionStringList(t, i, s, !1);
1668
+ }
1196
1669
  }
1197
1670
  }
1198
1671
  appendPrerequisiteFlagCondition(e, t) {
1199
- const n = typeof e.prerequisiteFlagKey != "string" ? ge : e.prerequisiteFlagKey in t ? e.prerequisiteFlagKey : Xe, s = e.comparator, r = e.comparisonValue;
1200
- return this.append(`Flag '${n}' ${Zt(s)} '${ie(r)}'`);
1672
+ const i = L(t, e.f) ? e.f : Ht, s = e.c, r = On(e.v);
1673
+ return this.append(`Flag '${i}' ${Li(s)} '${ce(r)}'`);
1201
1674
  }
1202
- appendSegmentCondition(e) {
1203
- const t = e.segment, n = e.comparator, s = t == null ? Xe : typeof t.name != "string" || !t.name ? ge : t.name;
1204
- return this.append(`User ${mt(n)} '${s}'`);
1675
+ appendSegmentCondition(e, t) {
1676
+ const i = e.s;
1677
+ let s;
1678
+ t && lt(i, 0, t.length - 1) ? (s = t[i].n, s.length || (s = Ni)) : s = Ht;
1679
+ const r = e.c;
1680
+ return this.append(`User ${An(r)} '${s}'`);
1205
1681
  }
1206
1682
  appendConditionResult(e) {
1207
1683
  return this.append(`${e}`);
@@ -1209,17 +1685,19 @@ class yt {
1209
1685
  appendConditionConsequence(e) {
1210
1686
  return this.append(" => ").appendConditionResult(e), e ? this : this.append(", skipping the remaining AND conditions");
1211
1687
  }
1212
- appendTargetingRuleThenPart(e, t) {
1213
- (t ? this.newLine() : this.append(" ")).append("THEN");
1214
- const n = e.then;
1215
- return this.append(x(n) ? " % options" : ` '${ie(n.value)}'`);
1688
+ appendTargetingRuleThenPart(e, t, i) {
1689
+ if ((i ? this.newLine() : this.append(" ")).append("THEN"), !yt(e, !0)) {
1690
+ const s = e.s, r = U(s.v, t, !0);
1691
+ return this.append(` '${ce(r)}'`);
1692
+ }
1693
+ return this.append(" % options");
1216
1694
  }
1217
- appendTargetingRuleConsequence(e, t, n) {
1218
- return this.increaseIndent(), this.appendTargetingRuleThenPart(e, n).append(" => ").append(t === !0 ? "MATCH, applying rule" : t === !1 ? "no match" : t), this.decreaseIndent();
1695
+ appendTargetingRuleConsequence(e, t, i, s) {
1696
+ return this.increaseIndent(), this.appendTargetingRuleThenPart(e, t, s).append(" => ").append(i === !0 ? "MATCH, applying rule" : i === !1 ? "no match" : i), this.decreaseIndent();
1219
1697
  }
1220
1698
  }
1221
- function fe(i) {
1222
- switch (i) {
1699
+ function qe(n) {
1700
+ switch (n) {
1223
1701
  case 0:
1224
1702
  case 16:
1225
1703
  case 4:
@@ -1277,90 +1755,123 @@ function fe(i) {
1277
1755
  case 27:
1278
1756
  return "ARRAY NOT CONTAINS ANY OF";
1279
1757
  default:
1280
- return Pe;
1758
+ return Et;
1281
1759
  }
1282
1760
  }
1283
- function Me(i) {
1284
- return new yt("").appendUserCondition(i).toString();
1761
+ function St(n) {
1762
+ return new Sn("").appendUserCondition(n).toString();
1285
1763
  }
1286
- function Zt(i) {
1287
- switch (i) {
1764
+ function Li(n) {
1765
+ switch (n) {
1288
1766
  case 0:
1289
1767
  return "EQUALS";
1290
1768
  case 1:
1291
1769
  return "NOT EQUALS";
1292
1770
  default:
1293
- return Pe;
1771
+ return Et;
1294
1772
  }
1295
1773
  }
1296
- function mt(i) {
1297
- switch (i) {
1774
+ function An(n) {
1775
+ switch (n) {
1298
1776
  case 0:
1299
1777
  return "IS IN SEGMENT";
1300
1778
  case 1:
1301
1779
  return "IS NOT IN SEGMENT";
1302
1780
  default:
1303
- return Pe;
1781
+ return Et;
1304
1782
  }
1305
1783
  }
1306
- function ie(i) {
1307
- return z(i) ? i.toString() : vt;
1784
+ function ce(n) {
1785
+ return pt(n) ? n.toString() : En;
1308
1786
  }
1309
- const Ze = /^[0-9]+$/, _ = (i, e) => {
1310
- const t = Ze.test(i), n = Ze.test(e);
1311
- return t && n && (i = +i, e = +e), i === e ? 0 : t && !n ? -1 : n && !t ? 1 : i < e ? -1 : 1;
1312
- }, be = 256, Q = Number.MAX_SAFE_INTEGER || 9007199254740991, H = [], v = [], d = {};
1313
- let en = 0;
1314
- const S = (i, e) => {
1315
- const t = en++;
1316
- d[i] = t, v[t] = e, H[t] = new RegExp(e);
1787
+ function On(n) {
1788
+ let e, t;
1789
+ if (e = n.b, t = n.s, t != null) {
1790
+ if (e != null)
1791
+ return;
1792
+ e = t;
1793
+ }
1794
+ if (t = n.i, t != null) {
1795
+ if (e != null)
1796
+ return;
1797
+ e = t;
1798
+ }
1799
+ if (t = n.d, t != null) {
1800
+ if (e != null)
1801
+ return;
1802
+ e = t;
1803
+ }
1804
+ return e ?? void 0;
1805
+ }
1806
+ function Di(n) {
1807
+ let e, t;
1808
+ if (e = n.s, t = n.d, t != null) {
1809
+ if (e != null)
1810
+ return;
1811
+ e = t;
1812
+ }
1813
+ if (t = n.l, t != null) {
1814
+ if (e != null)
1815
+ return;
1816
+ e = t;
1817
+ }
1818
+ return e ?? void 0;
1819
+ }
1820
+ const qt = /^[0-9]+$/, se = (n, e) => {
1821
+ const t = qt.test(n), i = qt.test(e);
1822
+ return t && i && (n = +n, e = +e), n === e ? 0 : t && !i ? -1 : i && !t ? 1 : n < e ? -1 : 1;
1823
+ }, it = 256, Ae = Number.MAX_SAFE_INTEGER || 9007199254740991, he = [], O = [], m = {};
1824
+ let ki = 0;
1825
+ const R = (n, e) => {
1826
+ const t = ki++;
1827
+ m[n] = t, O[t] = e, he[t] = new RegExp(e);
1317
1828
  };
1318
- S("NUMERICIDENTIFIER", "0|[1-9]\\d*");
1319
- S("NUMERICIDENTIFIERLOOSE", "[0-9]+");
1320
- S("NONNUMERICIDENTIFIER", "\\d*[a-zA-Z-][a-zA-Z0-9-]*");
1321
- S("MAINVERSION", `(${v[d.NUMERICIDENTIFIER]})\\.(${v[d.NUMERICIDENTIFIER]})\\.(${v[d.NUMERICIDENTIFIER]})`);
1322
- S("MAINVERSIONLOOSE", `(${v[d.NUMERICIDENTIFIERLOOSE]})\\.(${v[d.NUMERICIDENTIFIERLOOSE]})\\.(${v[d.NUMERICIDENTIFIERLOOSE]})`);
1323
- S("PRERELEASEIDENTIFIER", `(?:${v[d.NUMERICIDENTIFIER]}|${v[d.NONNUMERICIDENTIFIER]})`);
1324
- S("PRERELEASEIDENTIFIERLOOSE", `(?:${v[d.NUMERICIDENTIFIERLOOSE]}|${v[d.NONNUMERICIDENTIFIER]})`);
1325
- S("PRERELEASE", `(?:-(${v[d.PRERELEASEIDENTIFIER]}(?:\\.${v[d.PRERELEASEIDENTIFIER]})*))`);
1326
- S("PRERELEASELOOSE", `(?:-?(${v[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${v[d.PRERELEASEIDENTIFIERLOOSE]})*))`);
1327
- S("BUILDIDENTIFIER", "[0-9A-Za-z-]+");
1328
- S("BUILD", `(?:\\+(${v[d.BUILDIDENTIFIER]}(?:\\.${v[d.BUILDIDENTIFIER]})*))`);
1329
- S("FULLPLAIN", `v?${v[d.MAINVERSION]}${v[d.PRERELEASE]}?${v[d.BUILD]}?`);
1330
- S("FULL", `^${v[d.FULLPLAIN]}$`);
1331
- S("LOOSEPLAIN", `[v=\\s]*${v[d.MAINVERSIONLOOSE]}${v[d.PRERELEASELOOSE]}?${v[d.BUILD]}?`);
1332
- S("LOOSE", `^${v[d.LOOSEPLAIN]}$`);
1333
- class T {
1829
+ R("NUMERICIDENTIFIER", "0|[1-9]\\d*");
1830
+ R("NUMERICIDENTIFIERLOOSE", "[0-9]+");
1831
+ R("NONNUMERICIDENTIFIER", "\\d*[a-zA-Z-][a-zA-Z0-9-]*");
1832
+ R("MAINVERSION", `(${O[m.NUMERICIDENTIFIER]})\\.(${O[m.NUMERICIDENTIFIER]})\\.(${O[m.NUMERICIDENTIFIER]})`);
1833
+ R("MAINVERSIONLOOSE", `(${O[m.NUMERICIDENTIFIERLOOSE]})\\.(${O[m.NUMERICIDENTIFIERLOOSE]})\\.(${O[m.NUMERICIDENTIFIERLOOSE]})`);
1834
+ R("PRERELEASEIDENTIFIER", `(?:${O[m.NUMERICIDENTIFIER]}|${O[m.NONNUMERICIDENTIFIER]})`);
1835
+ R("PRERELEASEIDENTIFIERLOOSE", `(?:${O[m.NUMERICIDENTIFIERLOOSE]}|${O[m.NONNUMERICIDENTIFIER]})`);
1836
+ R("PRERELEASE", `(?:-(${O[m.PRERELEASEIDENTIFIER]}(?:\\.${O[m.PRERELEASEIDENTIFIER]})*))`);
1837
+ R("PRERELEASELOOSE", `(?:-?(${O[m.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${O[m.PRERELEASEIDENTIFIERLOOSE]})*))`);
1838
+ R("BUILDIDENTIFIER", "[0-9A-Za-z-]+");
1839
+ R("BUILD", `(?:\\+(${O[m.BUILDIDENTIFIER]}(?:\\.${O[m.BUILDIDENTIFIER]})*))`);
1840
+ R("FULLPLAIN", `v?${O[m.MAINVERSION]}${O[m.PRERELEASE]}?${O[m.BUILD]}?`);
1841
+ R("FULL", `^${O[m.FULLPLAIN]}$`);
1842
+ R("LOOSEPLAIN", `[v=\\s]*${O[m.MAINVERSIONLOOSE]}${O[m.PRERELEASELOOSE]}?${O[m.BUILD]}?`);
1843
+ R("LOOSE", `^${O[m.LOOSEPLAIN]}$`);
1844
+ class k {
1334
1845
  constructor(e, t) {
1335
1846
  if ((!t || typeof t != "object") && (t = {
1336
1847
  loose: !!t,
1337
1848
  includePrerelease: !1
1338
- }), e instanceof T) {
1849
+ }), e instanceof k) {
1339
1850
  if (e.loose === !!t.loose && e.includePrerelease === !!t.includePrerelease)
1340
1851
  return e;
1341
1852
  e = e.version;
1342
1853
  } else if (typeof e != "string")
1343
- throw new TypeError(`Invalid Version: ${e}`);
1344
- if (e.length > be)
1345
- throw new TypeError(`version is longer than ${be} characters`);
1854
+ throw TypeError(`Invalid Version: ${e}`);
1855
+ if (e.length > it)
1856
+ throw TypeError(`version is longer than ${it} characters`);
1346
1857
  this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease;
1347
- const n = e.trim().match(t.loose ? H[d.LOOSE] : H[d.FULL]);
1348
- if (!n)
1349
- throw new TypeError(`Invalid Version: ${e}`);
1350
- if (this.raw = e, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > Q || this.major < 0)
1351
- throw new TypeError("Invalid major version");
1352
- if (this.minor > Q || this.minor < 0)
1353
- throw new TypeError("Invalid minor version");
1354
- if (this.patch > Q || this.patch < 0)
1355
- throw new TypeError("Invalid patch version");
1356
- n[4] ? this.prerelease = n[4].split(".").map((s) => {
1858
+ const i = e.trim().match(t.loose ? he[m.LOOSE] : he[m.FULL]);
1859
+ if (!i)
1860
+ throw TypeError(`Invalid Version: ${e}`);
1861
+ if (this.raw = e, this.major = +i[1], this.minor = +i[2], this.patch = +i[3], this.major > Ae || this.major < 0)
1862
+ throw TypeError("Invalid major version");
1863
+ if (this.minor > Ae || this.minor < 0)
1864
+ throw TypeError("Invalid minor version");
1865
+ if (this.patch > Ae || this.patch < 0)
1866
+ throw TypeError("Invalid patch version");
1867
+ i[4] ? this.prerelease = i[4].split(".").map((s) => {
1357
1868
  if (/^[0-9]+$/.test(s)) {
1358
1869
  const r = +s;
1359
- if (r >= 0 && r < Q)
1870
+ if (r >= 0 && r < Ae)
1360
1871
  return r;
1361
1872
  }
1362
1873
  return s;
1363
- }) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format();
1874
+ }) : this.prerelease = [], this.build = i[5] ? i[5].split(".") : [], this.format();
1364
1875
  }
1365
1876
  format() {
1366
1877
  return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version;
@@ -1369,18 +1880,18 @@ class T {
1369
1880
  return this.version;
1370
1881
  }
1371
1882
  compare(e) {
1372
- if (!(e instanceof T)) {
1883
+ if (!(e instanceof k)) {
1373
1884
  if (typeof e == "string" && e === this.version)
1374
1885
  return 0;
1375
- e = new T(e, this.options);
1886
+ e = new k(e, this.options);
1376
1887
  }
1377
1888
  return e.version === this.version ? 0 : this.compareMain(e) || this.comparePre(e);
1378
1889
  }
1379
1890
  compareMain(e) {
1380
- return e instanceof T || (e = new T(e, this.options)), _(this.major, e.major) || _(this.minor, e.minor) || _(this.patch, e.patch);
1891
+ return e instanceof k || (e = new k(e, this.options)), se(this.major, e.major) || se(this.minor, e.minor) || se(this.patch, e.patch);
1381
1892
  }
1382
1893
  comparePre(e) {
1383
- if (e instanceof T || (e = new T(e, this.options)), this.prerelease.length && !e.prerelease.length)
1894
+ if (e instanceof k || (e = new k(e, this.options)), this.prerelease.length && !e.prerelease.length)
1384
1895
  return -1;
1385
1896
  if (!this.prerelease.length && e.prerelease.length)
1386
1897
  return 1;
@@ -1388,32 +1899,32 @@ class T {
1388
1899
  return 0;
1389
1900
  let t = 0;
1390
1901
  do {
1391
- const n = this.prerelease[t], s = e.prerelease[t];
1392
- if (n === void 0 && s === void 0)
1902
+ const i = this.prerelease[t], s = e.prerelease[t];
1903
+ if (i === void 0 && s === void 0)
1393
1904
  return 0;
1394
1905
  if (s === void 0)
1395
1906
  return 1;
1396
- if (n === void 0)
1907
+ if (i === void 0)
1397
1908
  return -1;
1398
- if (n === s)
1909
+ if (i === s)
1399
1910
  continue;
1400
- return _(n, s);
1911
+ return se(i, s);
1401
1912
  } while (++t);
1402
1913
  }
1403
1914
  compareBuild(e) {
1404
- e instanceof T || (e = new T(e, this.options));
1915
+ e instanceof k || (e = new k(e, this.options));
1405
1916
  let t = 0;
1406
1917
  do {
1407
- const n = this.build[t], s = e.build[t];
1408
- if (n === void 0 && s === void 0)
1918
+ const i = this.build[t], s = e.build[t];
1919
+ if (i === void 0 && s === void 0)
1409
1920
  return 0;
1410
1921
  if (s === void 0)
1411
1922
  return 1;
1412
- if (n === void 0)
1923
+ if (i === void 0)
1413
1924
  return -1;
1414
- if (n === s)
1925
+ if (i === s)
1415
1926
  continue;
1416
- return _(n, s);
1927
+ return se(i, s);
1417
1928
  } while (++t);
1418
1929
  }
1419
1930
  inc(e, t) {
@@ -1443,297 +1954,319 @@ class T {
1443
1954
  if (this.prerelease.length === 0)
1444
1955
  this.prerelease = [0];
1445
1956
  else {
1446
- let n = this.prerelease.length;
1447
- for (; --n >= 0; )
1448
- typeof this.prerelease[n] == "number" && (this.prerelease[n]++, n = -2);
1449
- n === -1 && this.prerelease.push(0);
1957
+ let i = this.prerelease.length;
1958
+ for (; --i >= 0; )
1959
+ typeof this.prerelease[i] == "number" && (this.prerelease[i]++, i = -2);
1960
+ i === -1 && this.prerelease.push(0);
1450
1961
  }
1451
1962
  t && (this.prerelease[0] === t ? isNaN(this.prerelease[1]) && (this.prerelease = [t, 0]) : this.prerelease = [t, 0]);
1452
1963
  break;
1453
1964
  default:
1454
- throw new Error(`invalid increment argument: ${e}`);
1965
+ throw Error(`invalid increment argument: ${e}`);
1455
1966
  }
1456
1967
  return this.format(), this.raw = this.version, this;
1457
1968
  }
1458
1969
  }
1459
- const Ce = (i, e) => {
1970
+ const st = (n, e) => {
1460
1971
  if ((!e || typeof e != "object") && (e = {
1461
1972
  loose: !!e,
1462
1973
  includePrerelease: !1
1463
- }), i instanceof T)
1464
- return i;
1465
- if (typeof i != "string" || i.length > be || !(e.loose ? H[d.LOOSE] : H[d.FULL]).test(i))
1974
+ }), n instanceof k)
1975
+ return n;
1976
+ if (typeof n != "string" || n.length > it || !(e.loose ? he[m.LOOSE] : he[m.FULL]).test(n))
1466
1977
  return null;
1467
1978
  try {
1468
- return new T(i, e);
1979
+ return new k(n, e);
1469
1980
  } catch {
1470
1981
  return null;
1471
1982
  }
1472
1983
  };
1473
- class In {
1474
- constructor(e, t, n, s = {}) {
1475
- this.identifier = e, this.email = t, this.country = n, this.custom = s;
1984
+ class Zi {
1985
+ constructor(e, t, i, s = {}) {
1986
+ this.identifier = e, this.email = t, this.country = i, this.custom = s;
1476
1987
  }
1477
1988
  }
1478
- function et(i, e) {
1479
- var t, n;
1989
+ function Cn(n) {
1990
+ var e;
1991
+ return (e = n.identifier) !== null && e !== void 0 ? e : "";
1992
+ }
1993
+ function jt(n, e) {
1480
1994
  switch (e) {
1481
1995
  case "Identifier":
1482
- return (t = i.identifier) !== null && t !== void 0 ? t : "";
1996
+ return Cn(n);
1483
1997
  case "Email":
1484
- return i.email;
1998
+ return n.email;
1485
1999
  case "Country":
1486
- return i.country;
2000
+ return n.country;
1487
2001
  default:
1488
- return (n = i.custom) === null || n === void 0 ? void 0 : n[e];
2002
+ return n.custom && L(n.custom, e) ? n.custom[e] : void 0;
1489
2003
  }
1490
2004
  }
1491
- function tn(i) {
2005
+ function Tn(n) {
1492
2006
  var e;
1493
- const t = {}, n = "Identifier", s = "Email", r = "Country";
1494
- if (t[n] = (e = i.identifier) !== null && e !== void 0 ? e : "", i.email != null && (t[s] = i.email), i.country != null && (t[r] = i.country), i.custom != null) {
1495
- const o = [n, s, r];
1496
- for (const [a, l] of Object.entries(i.custom))
1497
- l != null && o.indexOf(a) < 0 && (t[a] = l);
2007
+ const t = N(), i = "Identifier", s = "Email", r = "Country";
2008
+ if (t[i] = (e = n.identifier) !== null && e !== void 0 ? e : "", n.email != null && (t[s] = n.email), n.country != null && (t[r] = n.country), n.custom != null) {
2009
+ const o = [i, s, r];
2010
+ for (const a in n.custom) {
2011
+ let l;
2012
+ L(n.custom, a) && (l = n.custom[a]) != null && o.indexOf(a) < 0 && (t[a] = l);
2013
+ }
1498
2014
  }
1499
2015
  return t;
1500
2016
  }
1501
- class j {
2017
+ class ye {
2018
+ get settingType() {
2019
+ var e;
2020
+ return (e = this._settingType) !== null && e !== void 0 ? e : this._settingType = vt(this.setting);
2021
+ }
1502
2022
  get visitedFlags() {
1503
2023
  var e;
1504
- return (e = this.$visitedFlags) !== null && e !== void 0 ? e : this.$visitedFlags = [];
2024
+ return (e = this._visitedFlags) !== null && e !== void 0 ? e : this._visitedFlags = [];
1505
2025
  }
1506
- constructor(e, t, n, s) {
1507
- this.key = e, this.setting = t, this.user = n, this.settings = s;
2026
+ constructor(e, t, i, s) {
2027
+ this.key = e, this.setting = t, this.user = i, this.settings = s, this._settingType = void 0, this._visitedFlags = void 0, this.isMissingUserObjectLogged = !1, this.isMissingUserObjectAttributeLogged = !1;
1508
2028
  }
1509
- static forPrerequisiteFlag(e, t, n) {
1510
- const s = new j(e, t, n.user, n.settings);
1511
- return s.$visitedFlags = n.visitedFlags, s.logBuilder = n.logBuilder, s;
2029
+ static forPrerequisiteFlag(e, t, i) {
2030
+ const s = new ye(e, t, i.user, i.settings);
2031
+ return s._visitedFlags = i.visitedFlags, s.logBuilder = i.logBuilder, s;
1512
2032
  }
1513
2033
  }
1514
- const tt = "The current targeting rule is ignored and the evaluation continues with the next rule.", de = "cannot evaluate, User Object is missing", nn = (i) => `cannot evaluate, the User.${i} attribute is missing`, sn = (i, e) => `cannot evaluate, the User.${i} attribute is invalid (${e})`;
1515
- class rn {
2034
+ const Vt = "The current targeting rule is ignored and the evaluation continues with the next rule.", je = "cannot evaluate, User Object is missing", $i = (n) => `cannot evaluate, the User.${n} attribute is missing`, Ui = (n, e) => `cannot evaluate, the User.${n} attribute is invalid (${e})`;
2035
+ class Mi {
1516
2036
  constructor(e) {
1517
2037
  this.logger = e;
1518
2038
  }
1519
2039
  evaluate(e, t) {
1520
2040
  this.logger.debug("RolloutEvaluator.evaluate() called.");
1521
- let n = t.logBuilder;
1522
- this.logger.isEnabled(3) && (t.logBuilder = n = new yt(this.logger.eol), n.append(`Evaluating '${t.key}'`), t.user && n.append(` for User '${JSON.stringify(tn(t.user))}'`), n.increaseIndent());
2041
+ const i = t.logBuilder = this.logger.isEnabled(3) ? new Sn(this.logger.eol) : null;
2042
+ i && (i.append(`Evaluating '${t.key}'`), t.user && i.append(` for User '${JSON.stringify(Tn(t.user))}'`), i.increaseIndent());
1523
2043
  let s;
1524
2044
  try {
1525
- let r, o;
1526
- if (e != null) {
1527
- const a = t.setting.type;
1528
- if (a >= 0 && !ln(e, a)) {
1529
- const l = Mt(a);
1530
- throw new TypeError(`The type of a setting must match the type of the specified default value. Setting's type was ${l} but the default value's type was ${typeof e}. Please use a default value which corresponds to the setting type ${l}. Learn more: https://configcat.com/docs/sdk-reference/js/#setting-type-mapping`);
1531
- }
1532
- r = this.evaluateSetting(t), s = r.selectedValue.value, o = typeof s == typeof e;
1533
- } else
1534
- r = this.evaluateSetting(t), s = r.selectedValue.value, o = z(s);
1535
- return o || Re(s), r;
2045
+ const r = t.settingType, o = r !== -1 ? r : Ye(t.setting.v);
2046
+ if (e != null && o !== void 0 && !si(e, o)) {
2047
+ const l = ii(o);
2048
+ throw new ge(2, `The type of a setting must match the type of the specified default value. Setting's type was ${l} but the default value's type was ${typeof e}. Please use a default value which corresponds to the setting type ${l}. Learn more: https://configcat.com/docs/sdk-reference/js/overview/#setting-type-mapping`);
2049
+ }
2050
+ const a = this.evaluateSetting(t);
2051
+ return a.returnValue = s = U(a.selectedValue.v, r), a;
1536
2052
  } catch (r) {
1537
- throw n == null || n.resetIndent().increaseIndent(), s = e, r;
2053
+ throw i == null || i.resetIndent().increaseIndent(), s = e, r;
1538
2054
  } finally {
1539
- n && (n.newLine(`Returning '${s}'.`).decreaseIndent(), this.logger.settingEvaluated(n.toString()));
2055
+ i && (i.newLine(`Returning '${s}'.`).decreaseIndent(), this.logger.settingEvaluated(i.toString()));
1540
2056
  }
1541
2057
  }
1542
2058
  evaluateSetting(e) {
1543
2059
  let t;
1544
- const n = e.setting.targetingRules;
1545
- if (n.length > 0 && (t = this.evaluateTargetingRules(n, e)))
2060
+ const i = e.setting.r;
2061
+ if (i != null && i.length && (t = this.evaluateTargetingRules(i, e)))
1546
2062
  return t;
1547
- const s = e.setting.percentageOptions;
1548
- return s.length > 0 && (t = this.evaluatePercentageOptions(s, void 0, e)) ? t : { selectedValue: e.setting };
2063
+ const s = e.setting.p;
2064
+ return s != null && s.length && (t = this.evaluatePercentageOptions(s, void 0, e)) ? t : Ve(e.setting);
1549
2065
  }
1550
2066
  evaluateTargetingRules(e, t) {
1551
- const n = t.logBuilder;
1552
- n == null || n.newLine("Evaluating targeting rules and applying the first match if any:");
2067
+ const i = t.logBuilder;
2068
+ i == null || i.newLine("Evaluating targeting rules and applying the first match if any:");
1553
2069
  for (let s = 0; s < e.length; s++) {
1554
- const r = e[s], o = r.conditions, a = this.evaluateConditions(o, r, t.key, t);
2070
+ const r = e[s], o = r.c, a = this.evaluateConditions(o, void 0, r, t.key, t);
1555
2071
  if (a !== !0) {
1556
- V(a) && (n == null || n.increaseIndent().newLine(tt).decreaseIndent());
2072
+ S(a) && (i == null || i.increaseIndent().newLine(Vt).decreaseIndent());
1557
2073
  continue;
1558
2074
  }
1559
- if (!x(r.then))
1560
- return { selectedValue: r.then, matchedTargetingRule: r };
1561
- const l = r.then;
1562
- n == null || n.increaseIndent();
2075
+ if (!yt(r))
2076
+ return Ve(r.s, r);
2077
+ const l = r.p;
2078
+ i == null || i.increaseIndent();
1563
2079
  const c = this.evaluatePercentageOptions(l, r, t);
1564
2080
  if (c)
1565
- return n == null || n.decreaseIndent(), c;
1566
- n == null || n.newLine(tt).decreaseIndent();
2081
+ return i == null || i.decreaseIndent(), c;
2082
+ i == null || i.newLine(Vt).decreaseIndent();
1567
2083
  }
1568
2084
  }
1569
- evaluatePercentageOptions(e, t, n) {
1570
- const s = n.logBuilder;
1571
- if (!n.user) {
1572
- s == null || s.newLine("Skipping % options because the User Object is missing."), n.isMissingUserObjectLogged || (this.logger.userObjectIsMissing(n.key), n.isMissingUserObjectLogged = !0);
2085
+ evaluatePercentageOptions(e, t, i) {
2086
+ const s = i.logBuilder;
2087
+ if (!i.user) {
2088
+ s == null || s.newLine("Skipping % options because the User Object is missing."), i.isMissingUserObjectLogged || (this.logger.userObjectIsMissing(i.key), i.isMissingUserObjectLogged = !0);
1573
2089
  return;
1574
2090
  }
1575
- const r = n.setting.percentageOptionsAttribute, o = et(n.user, r);
1576
- if (o == null) {
1577
- s == null || s.newLine(`Skipping % options because the User.${r} attribute is missing.`), n.isMissingUserObjectAttributeLogged || (this.logger.userObjectAttributeIsMissingPercentage(n.key, r), n.isMissingUserObjectAttributeLogged = !0);
2091
+ let r = i.setting.a, o;
2092
+ if (r == null ? (r = "Identifier", o = Cn(i.user)) : o = jt(i.user, r), o == null) {
2093
+ s == null || s.newLine(`Skipping % options because the User.${r} attribute is missing.`), i.isMissingUserObjectAttributeLogged || (this.logger.userObjectAttributeIsMissingPercentage(i.key, r), i.isMissingUserObjectAttributeLogged = !0);
1578
2094
  return;
1579
2095
  }
1580
2096
  s == null || s.newLine(`Evaluating % options based on the User.${r} attribute:`);
1581
- const a = ut(n.key + Ot(o)), l = parseInt(a.substring(0, 7), 16) % 100;
2097
+ const a = pn(i.key + bn(o)), l = parseInt(a.substring(0, 7), 16) % 100;
1582
2098
  s == null || s.newLine(`- Computing hash in the [0..99] range from User.${r} => ${l} (this value is sticky and consistent across all SDKs)`);
1583
2099
  let c = 0;
1584
- for (let u = 0; u < e.length; u++) {
1585
- const h = e[u];
1586
- if (c += h.percentage, !(l >= c))
1587
- return s == null || s.newLine(`- Hash value ${l} selects % option ${u + 1} (${h.percentage}%), '${ie(h.value)}'.`), { selectedValue: h, matchedTargetingRule: t, matchedPercentageOption: h };
1588
- }
1589
- throw new Error("Sum of percentage option percentages is less than 100.");
1590
- }
1591
- evaluateConditions(e, t, n, s) {
1592
- let r = !0;
1593
- const o = s.logBuilder;
1594
- let a = !1;
1595
- o == null || o.newLine("- ");
1596
- for (let l = 0; l < e.length; l++) {
1597
- const c = e[l];
1598
- switch (o && (l ? o.increaseIndent().newLine("AND ") : o.append("IF ").increaseIndent()), c.type) {
1599
- case "UserCondition":
1600
- r = this.evaluateUserCondition(c, n, s), a = e.length > 1;
2100
+ for (let f = 0; f < e.length; f++) {
2101
+ const u = e[f], h = u.p;
2102
+ if (h < 0 && T("Percentage option percentage is invalid."), c += h, !(l >= c)) {
2103
+ if (s) {
2104
+ const g = U(u.v, i.settingType, !0);
2105
+ s.newLine(`- Hash value ${l} selects % option ${f + 1} (${h}%), '${ce(g)}'.`);
2106
+ }
2107
+ return Ve(u, t, u);
2108
+ }
2109
+ }
2110
+ T("Sum of percentage option percentages is less than 100.");
2111
+ }
2112
+ evaluateConditions(e, t, i, s, r) {
2113
+ var o;
2114
+ let a = !0;
2115
+ const l = r.logBuilder;
2116
+ let c = !1;
2117
+ l == null || l.newLine("- ");
2118
+ const f = !t;
2119
+ for (let u = 0, h = (o = e == null ? void 0 : e.length) !== null && o !== void 0 ? o : 0; u < h; u++) {
2120
+ let g;
2121
+ if (f) {
2122
+ const E = e[u];
2123
+ t = oi(E), g = E[t];
2124
+ } else
2125
+ g = e[u];
2126
+ switch (l && (u ? l.increaseIndent().newLine("AND ") : l.append("IF ").increaseIndent()), t) {
2127
+ case "u":
2128
+ a = this.evaluateUserCondition(g, s, r), c = h > 1;
1601
2129
  break;
1602
- case "PrerequisiteFlagCondition":
1603
- r = this.evaluatePrerequisiteFlagCondition(c, s), a = !0;
2130
+ case "p":
2131
+ a = this.evaluatePrerequisiteFlagCondition(g, r), c = !0;
1604
2132
  break;
1605
- case "SegmentCondition":
1606
- r = this.evaluateSegmentCondition(c, s), a = !V(r) || r !== de || e.length > 1;
2133
+ case "s":
2134
+ a = this.evaluateSegmentCondition(g, r), c = !S(a) || a !== je || h > 1;
1607
2135
  break;
1608
2136
  default:
1609
- throw new Error();
2137
+ throw Error();
1610
2138
  }
1611
- const u = r === !0;
1612
- if (o && ((!t || e.length > 1) && o.appendConditionConsequence(u), o.decreaseIndent()), !u)
2139
+ const d = a === !0;
2140
+ if (l && ((!i || h > 1) && l.appendConditionConsequence(d), l.decreaseIndent()), !d)
1613
2141
  break;
1614
2142
  }
1615
- return t && (o == null || o.appendTargetingRuleConsequence(t, r, a)), r;
1616
- }
1617
- evaluateUserCondition(e, t, n) {
1618
- const s = n.logBuilder;
1619
- if (s == null || s.appendUserCondition(e), !n.user)
1620
- return n.isMissingUserObjectLogged || (this.logger.userObjectIsMissing(n.key), n.isMissingUserObjectLogged = !0), de;
1621
- const r = e.comparisonAttribute, o = et(n.user, r);
1622
- if (o == null || o === "")
1623
- return this.logger.userObjectAttributeIsMissingCondition(Me(e), n.key, r), nn(r);
1624
- let a, l, c, u;
1625
- switch (e.comparator) {
2143
+ return i && (l == null || l.appendTargetingRuleConsequence(i, r.settingType, a, c)), a;
2144
+ }
2145
+ evaluateUserCondition(e, t, i) {
2146
+ const s = i.logBuilder;
2147
+ if (s == null || s.appendUserCondition(e), !i.user)
2148
+ return i.isMissingUserObjectLogged || (this.logger.userObjectIsMissing(i.key), i.isMissingUserObjectLogged = !0), je;
2149
+ const r = e.a, o = jt(i.user, r);
2150
+ if (o == null || o === "") {
2151
+ const h = new pe(e, (g) => St(g));
2152
+ return this.logger.userObjectAttributeIsMissingCondition(h, i.key, r), $i(r);
2153
+ }
2154
+ let a, l, c, f;
2155
+ const u = e.c;
2156
+ switch (u) {
1626
2157
  case 28:
1627
2158
  case 29:
1628
- return a = C(r, o, e, n.key, this.logger), this.evaluateTextEquals(a, e.comparisonValue, e.comparator === 29);
2159
+ return a = q(r, o, e, i.key, this.logger), this.evaluateTextEquals(a, w(e.s), u === 29);
1629
2160
  case 20:
1630
2161
  case 21:
1631
- return a = C(r, o, e, n.key, this.logger), this.evaluateSensitiveTextEquals(a, e.comparisonValue, n.setting.configJsonSalt, t, e.comparator === 21);
2162
+ return a = q(r, o, e, i.key, this.logger), this.evaluateSensitiveTextEquals(a, w(e.s), re(i.setting), t, u === 21);
1632
2163
  case 0:
1633
2164
  case 1:
1634
- return a = C(r, o, e, n.key, this.logger), this.evaluateTextIsOneOf(a, e.comparisonValue, e.comparator === 1);
2165
+ return a = q(r, o, e, i.key, this.logger), this.evaluateTextIsOneOf(a, w(e.l), u === 1);
1635
2166
  case 16:
1636
2167
  case 17:
1637
- return a = C(r, o, e, n.key, this.logger), this.evaluateSensitiveTextIsOneOf(a, e.comparisonValue, n.setting.configJsonSalt, t, e.comparator === 17);
2168
+ return a = q(r, o, e, i.key, this.logger), this.evaluateSensitiveTextIsOneOf(a, w(e.l), re(i.setting), t, u === 17);
1638
2169
  case 30:
1639
2170
  case 31:
1640
- return a = C(r, o, e, n.key, this.logger), this.evaluateTextSliceEqualsAnyOf(a, e.comparisonValue, !0, e.comparator === 31);
2171
+ return a = q(r, o, e, i.key, this.logger), this.evaluateTextSliceEqualsAnyOf(a, w(e.l), !0, u === 31);
1641
2172
  case 22:
1642
2173
  case 23:
1643
- return a = C(r, o, e, n.key, this.logger), this.evaluateSensitiveTextSliceEqualsAnyOf(a, e.comparisonValue, n.setting.configJsonSalt, t, !0, e.comparator === 23);
2174
+ return a = q(r, o, e, i.key, this.logger), this.evaluateSensitiveTextSliceEqualsAnyOf(a, w(e.l), re(i.setting), t, !0, u === 23);
1644
2175
  case 32:
1645
2176
  case 33:
1646
- return a = C(r, o, e, n.key, this.logger), this.evaluateTextSliceEqualsAnyOf(a, e.comparisonValue, !1, e.comparator === 33);
2177
+ return a = q(r, o, e, i.key, this.logger), this.evaluateTextSliceEqualsAnyOf(a, w(e.l), !1, u === 33);
1647
2178
  case 24:
1648
2179
  case 25:
1649
- return a = C(r, o, e, n.key, this.logger), this.evaluateSensitiveTextSliceEqualsAnyOf(a, e.comparisonValue, n.setting.configJsonSalt, t, !1, e.comparator === 25);
2180
+ return a = q(r, o, e, i.key, this.logger), this.evaluateSensitiveTextSliceEqualsAnyOf(a, w(e.l), re(i.setting), t, !1, u === 25);
1650
2181
  case 2:
1651
2182
  case 3:
1652
- return a = C(r, o, e, n.key, this.logger), this.evaluateTextContainsAnyOf(a, e.comparisonValue, e.comparator === 3);
2183
+ return a = q(r, o, e, i.key, this.logger), this.evaluateTextContainsAnyOf(a, w(e.l), u === 3);
1653
2184
  case 4:
1654
2185
  case 5:
1655
- return l = nt(r, o, e, n.key, this.logger), typeof l != "string" ? this.evaluateSemVerIsOneOf(l, e.comparisonValue, e.comparator === 5) : l;
2186
+ return l = Bt(r, o, e, i.key, this.logger), S(l) ? l : this.evaluateSemVerIsOneOf(l, w(e.l), u === 5);
1656
2187
  case 6:
1657
2188
  case 7:
1658
2189
  case 8:
1659
2190
  case 9:
1660
- return l = nt(r, o, e, n.key, this.logger), typeof l != "string" ? this.evaluateSemVerRelation(l, e.comparator, e.comparisonValue) : l;
2191
+ return l = Bt(r, o, e, i.key, this.logger), S(l) ? l : this.evaluateSemVerRelation(l, u, w(e.s));
1661
2192
  case 10:
1662
2193
  case 11:
1663
2194
  case 12:
1664
2195
  case 13:
1665
2196
  case 14:
1666
2197
  case 15:
1667
- return c = on(r, o, e, n.key, this.logger), typeof c != "string" ? this.evaluateNumberRelation(c, e.comparator, e.comparisonValue) : c;
2198
+ return c = Pi(r, o, e, i.key, this.logger), S(c) ? c : this.evaluateNumberRelation(c, u, w(e.d));
1668
2199
  case 18:
1669
2200
  case 19:
1670
- return c = an(r, o, e, n.key, this.logger), typeof c != "string" ? this.evaluateDateTimeRelation(c, e.comparisonValue, e.comparator === 18) : c;
2201
+ return c = xi(r, o, e, i.key, this.logger), S(c) ? c : this.evaluateDateTimeRelation(c, w(e.d), u === 18);
1671
2202
  case 34:
1672
2203
  case 35:
1673
- return u = it(r, o, e, n.key, this.logger), typeof u != "string" ? this.evaluateArrayContainsAnyOf(u, e.comparisonValue, e.comparator === 35) : u;
2204
+ return f = Kt(r, o, e, i.key, this.logger), S(f) ? f : this.evaluateArrayContainsAnyOf(f, w(e.l), u === 35);
1674
2205
  case 26:
1675
2206
  case 27:
1676
- return u = it(r, o, e, n.key, this.logger), typeof u != "string" ? this.evaluateSensitiveArrayContainsAnyOf(u, e.comparisonValue, n.setting.configJsonSalt, t, e.comparator === 27) : u;
2207
+ return f = Kt(r, o, e, i.key, this.logger), S(f) ? f : this.evaluateSensitiveArrayContainsAnyOf(f, w(e.l), re(i.setting), t, u === 27);
1677
2208
  default:
1678
- throw new Error();
2209
+ T("Comparison operator is invalid.");
1679
2210
  }
1680
2211
  }
1681
- evaluateTextEquals(e, t, n) {
1682
- return e === t !== n;
2212
+ evaluateTextEquals(e, t, i) {
2213
+ return e === t !== i;
1683
2214
  }
1684
- evaluateSensitiveTextEquals(e, t, n, s, r) {
1685
- return pe(e, n, s) === t !== r;
2215
+ evaluateSensitiveTextEquals(e, t, i, s, r) {
2216
+ return Be(e, i, s) === t !== r;
1686
2217
  }
1687
- evaluateTextIsOneOf(e, t, n) {
1688
- return t.indexOf(e) >= 0 !== n;
2218
+ evaluateTextIsOneOf(e, t, i) {
2219
+ return t.indexOf(e) >= 0 !== i;
1689
2220
  }
1690
- evaluateSensitiveTextIsOneOf(e, t, n, s, r) {
1691
- const o = pe(e, n, s);
2221
+ evaluateSensitiveTextIsOneOf(e, t, i, s, r) {
2222
+ const o = Be(e, i, s);
1692
2223
  return t.indexOf(o) >= 0 !== r;
1693
2224
  }
1694
- evaluateTextSliceEqualsAnyOf(e, t, n, s) {
2225
+ evaluateTextSliceEqualsAnyOf(e, t, i, s) {
1695
2226
  for (let r = 0; r < t.length; r++) {
1696
2227
  const o = t[r];
1697
2228
  if (e.length < o.length)
1698
2229
  continue;
1699
- if ((n ? e.lastIndexOf(o, 0) : e.indexOf(o, e.length - o.length)) >= 0)
2230
+ if ((i ? e.lastIndexOf(o, 0) : e.indexOf(o, e.length - o.length)) >= 0)
1700
2231
  return !s;
1701
2232
  }
1702
2233
  return s;
1703
2234
  }
1704
- evaluateSensitiveTextSliceEqualsAnyOf(e, t, n, s, r, o) {
1705
- const a = K(e);
2235
+ evaluateSensitiveTextSliceEqualsAnyOf(e, t, i, s, r, o) {
2236
+ const a = ue(e);
1706
2237
  for (let l = 0; l < t.length; l++) {
1707
- const c = t[l], u = c.indexOf("_"), h = parseInt(c.slice(0, u));
1708
- if (a.length < h)
2238
+ const c = t[l];
2239
+ let f, u;
2240
+ const h = c.indexOf("_");
2241
+ if ((h < 0 || isNaN(f = Hn(c.slice(0, h))) || f < 0 || !(u = c.slice(h + 1))) && T("Comparison value is invalid."), a.length < f)
1709
2242
  continue;
1710
- const g = r ? a.slice(0, h) : a.slice(a.length - h);
1711
- if (Et(g, n, s) === c.slice(u + 1))
2243
+ const g = r ? a.slice(0, f) : a.slice(a.length - f);
2244
+ if (In(g, i, s) === u)
1712
2245
  return !o;
1713
2246
  }
1714
2247
  return o;
1715
2248
  }
1716
- evaluateTextContainsAnyOf(e, t, n) {
2249
+ evaluateTextContainsAnyOf(e, t, i) {
1717
2250
  for (let s = 0; s < t.length; s++)
1718
2251
  if (e.indexOf(t[s]) >= 0)
1719
- return !n;
1720
- return n;
2252
+ return !i;
2253
+ return i;
1721
2254
  }
1722
- evaluateSemVerIsOneOf(e, t, n) {
2255
+ evaluateSemVerIsOneOf(e, t, i) {
1723
2256
  let s = !1;
1724
2257
  for (let r = 0; r < t.length; r++) {
1725
2258
  const o = t[r];
1726
2259
  if (!o.length)
1727
2260
  continue;
1728
- const a = Ce(o.trim());
2261
+ const a = st(o.trim());
1729
2262
  if (!a)
1730
2263
  return !1;
1731
2264
  !s && e.compare(a) === 0 && (s = !0);
1732
2265
  }
1733
- return s !== n;
2266
+ return s !== i;
1734
2267
  }
1735
- evaluateSemVerRelation(e, t, n) {
1736
- const s = Ce(n.trim());
2268
+ evaluateSemVerRelation(e, t, i) {
2269
+ const s = st(i.trim());
1737
2270
  if (!s)
1738
2271
  return !1;
1739
2272
  const r = e.compare(s);
@@ -1748,233 +2281,285 @@ class rn {
1748
2281
  return r >= 0;
1749
2282
  }
1750
2283
  }
1751
- evaluateNumberRelation(e, t, n) {
2284
+ evaluateNumberRelation(e, t, i) {
1752
2285
  switch (t) {
1753
2286
  case 10:
1754
- return e === n;
2287
+ return e === i;
1755
2288
  case 11:
1756
- return e !== n;
2289
+ return e !== i;
1757
2290
  case 12:
1758
- return e < n;
2291
+ return e < i;
1759
2292
  case 13:
1760
- return e <= n;
2293
+ return e <= i;
1761
2294
  case 14:
1762
- return e > n;
2295
+ return e > i;
1763
2296
  case 15:
1764
- return e >= n;
2297
+ return e >= i;
1765
2298
  }
1766
2299
  }
1767
- evaluateDateTimeRelation(e, t, n) {
1768
- return n ? e < t : e > t;
2300
+ evaluateDateTimeRelation(e, t, i) {
2301
+ return i ? e < t : e > t;
1769
2302
  }
1770
- evaluateArrayContainsAnyOf(e, t, n) {
2303
+ evaluateArrayContainsAnyOf(e, t, i) {
1771
2304
  for (let s = 0; s < e.length; s++)
1772
2305
  if (t.indexOf(e[s]) >= 0)
1773
- return !n;
1774
- return n;
2306
+ return !i;
2307
+ return i;
1775
2308
  }
1776
- evaluateSensitiveArrayContainsAnyOf(e, t, n, s, r) {
2309
+ evaluateSensitiveArrayContainsAnyOf(e, t, i, s, r) {
1777
2310
  for (let o = 0; o < e.length; o++) {
1778
- const a = pe(e[o], n, s);
2311
+ const a = Be(e[o], i, s);
1779
2312
  if (t.indexOf(a) >= 0)
1780
2313
  return !r;
1781
2314
  }
1782
2315
  return r;
1783
2316
  }
1784
2317
  evaluatePrerequisiteFlagCondition(e, t) {
1785
- const n = t.logBuilder;
1786
- n == null || n.appendPrerequisiteFlagCondition(e, t.settings);
1787
- const s = e.prerequisiteFlagKey, r = t.settings[s];
1788
- if (t.visitedFlags.push(t.key), t.visitedFlags.indexOf(s) >= 0) {
1789
- t.visitedFlags.push(s);
1790
- const u = De(t.visitedFlags, void 0, void 0, " -> ");
1791
- throw new Error(`Circular dependency detected between the following depending flags: ${u}.`);
1792
- }
1793
- const o = j.forPrerequisiteFlag(s, r, t);
1794
- n == null || n.newLine("(").increaseIndent().newLine(`Evaluating prerequisite flag '${s}':`);
1795
- const a = this.evaluateSetting(o);
1796
- t.visitedFlags.pop();
1797
- const l = a.selectedValue.value;
1798
- if (typeof l != typeof e.comparisonValue) {
1799
- if (z(l))
1800
- throw new Error(`Type mismatch between comparison value '${e.comparisonValue}' and prerequisite flag '${s}'.`);
1801
- Re(l);
1802
- }
1803
- let c;
1804
- switch (e.comparator) {
2318
+ const i = t.logBuilder;
2319
+ i == null || i.appendPrerequisiteFlagCondition(e, t.settings);
2320
+ const s = e.f, r = L(t.settings, s) ? t.settings[s] : T("Prerequisite flag is missing."), o = vt(r);
2321
+ let a, l;
2322
+ if (o !== -1)
2323
+ a = o, l = U(e.v, o, !0);
2324
+ else if (a = Ye(r.v), a !== void 0 && (l = U(e.v, a, !0), a === 3)) {
2325
+ const d = U(e.v, 2, !0);
2326
+ l === void 0 ? l = d : d !== void 0 && (l = void 0);
2327
+ }
2328
+ l === void 0 && a !== void 0 && (l = On(e.v), T(`Type mismatch between comparison value '${ce(l)}' and prerequisite flag '${s}'.`));
2329
+ const c = t.visitedFlags;
2330
+ if (c.push(t.key), c.indexOf(s) >= 0) {
2331
+ c.push(s);
2332
+ const d = ut(c, void 0, void 0, " -> ");
2333
+ T(`Circular dependency detected between the following depending flags: ${d}.`);
2334
+ }
2335
+ const f = ye.forPrerequisiteFlag(s, r, t);
2336
+ i == null || i.newLine("(").increaseIndent().newLine(`Evaluating prerequisite flag '${s}':`);
2337
+ const u = this.evaluateSetting(f);
2338
+ c.pop();
2339
+ const h = U(u.selectedValue.v, o);
2340
+ let g;
2341
+ switch (e.c) {
1805
2342
  case 0:
1806
- c = l === e.comparisonValue;
2343
+ g = h === l;
1807
2344
  break;
1808
2345
  case 1:
1809
- c = l !== e.comparisonValue;
2346
+ g = h !== l;
1810
2347
  break;
1811
2348
  default:
1812
- throw new Error();
2349
+ T("Comparison operator is invalid.");
1813
2350
  }
1814
- return n == null || n.newLine(`Prerequisite flag evaluation result: '${ie(l)}'.`).newLine("Condition (").appendPrerequisiteFlagCondition(e, t.settings).append(") evaluates to ").appendConditionResult(c).append(".").decreaseIndent().newLine(")"), c;
2351
+ return i == null || i.newLine(`Prerequisite flag evaluation result: '${ce(h)}'.`).newLine("Condition (").appendPrerequisiteFlagCondition(e, t.settings).append(") evaluates to ").appendConditionResult(g).append(".").decreaseIndent().newLine(")"), g;
1815
2352
  }
1816
2353
  evaluateSegmentCondition(e, t) {
1817
- const n = t.logBuilder;
1818
- if (n == null || n.appendSegmentCondition(e), !t.user)
1819
- return t.isMissingUserObjectLogged || (this.logger.userObjectIsMissing(t.key), t.isMissingUserObjectLogged = !0), de;
1820
- const s = e.segment;
1821
- n == null || n.newLine("(").increaseIndent().newLine(`Evaluating segment '${s.name}':`);
1822
- const r = this.evaluateConditions(s.conditions, void 0, s.name, t);
1823
- let o = r;
1824
- if (!V(o))
1825
- switch (e.comparator) {
2354
+ const i = t.setting._configSegments, s = t.logBuilder;
2355
+ if (s == null || s.appendSegmentCondition(e, i), !t.user)
2356
+ return t.isMissingUserObjectLogged || (this.logger.userObjectIsMissing(t.key), t.isMissingUserObjectLogged = !0), je;
2357
+ const r = e == null ? void 0 : e.s;
2358
+ (!i || !lt(r, 0, i.length - 1)) && T("Segment reference is invalid.");
2359
+ const o = i[r], a = o == null ? void 0 : o.n;
2360
+ a.length || T("Segment name is missing."), s == null || s.newLine("(").increaseIndent().newLine(`Evaluating segment '${a}':`);
2361
+ const l = o == null ? void 0 : o.r, c = this.evaluateConditions(l, "u", void 0, a, t);
2362
+ let f = c;
2363
+ if (!S(f))
2364
+ switch (e.c) {
1826
2365
  case 0:
1827
2366
  break;
1828
2367
  case 1:
1829
- o = !o;
2368
+ f = !f;
1830
2369
  break;
1831
2370
  default:
1832
- throw new Error();
2371
+ T("Comparison operator is invalid.");
1833
2372
  }
1834
- return n && (n.newLine("Segment evaluation result: "), (V(o) ? n.append(o) : n.append(`User ${mt(r ? 0 : 1)}`)).append("."), n.newLine("Condition (").appendSegmentCondition(e).append(")"), (V(o) ? n.append(" failed to evaluate") : n.append(" evaluates to ").appendConditionResult(o)).append("."), n.decreaseIndent().newLine(")")), o;
2373
+ return s && (s.newLine("Segment evaluation result: "), (S(f) ? s.append(f) : s.append(`User ${An(c ? 0 : 1)}`)).append("."), s.newLine("Condition (").appendSegmentCondition(e, i).append(")"), (S(f) ? s.append(" failed to evaluate") : s.append(" evaluates to ").appendConditionResult(f)).append("."), s.decreaseIndent().newLine(")")), f;
1835
2374
  }
1836
2375
  }
1837
- function V(i) {
1838
- return typeof i == "string";
2376
+ function Ve(n, e, t) {
2377
+ return { selectedValue: n, matchedTargetingRule: e, matchedPercentageOption: t };
1839
2378
  }
1840
- function pe(i, e, t) {
1841
- return Et(K(i), e, t);
2379
+ function Be(n, e, t) {
2380
+ return In(ue(n), e, t);
1842
2381
  }
1843
- function Et(i, e, t) {
1844
- return ht(i + K(e) + K(t));
2382
+ function In(n, e, t) {
2383
+ return Ai(n + ue(e) + ue(t));
1845
2384
  }
1846
- function Ot(i) {
1847
- return typeof i == "string" ? i : i instanceof Date ? i.getTime() / 1e3 + "" : ke(i) ? JSON.stringify(i) : i + "";
2385
+ function bn(n) {
2386
+ return S(n) ? n : n instanceof Date ? String(n.getTime() / 1e3) : Xt(n) ? JSON.stringify(n) : F(n);
1848
2387
  }
1849
- function C(i, e, t, n, s) {
1850
- return typeof e == "string" || (e = Ot(e), s.userObjectAttributeIsAutoConverted(Me(t), n, i, e)), e;
2388
+ function q(n, e, t, i, s) {
2389
+ if (S(e))
2390
+ return e;
2391
+ e = bn(e);
2392
+ const r = new pe(t, (o) => St(o));
2393
+ return s.userObjectAttributeIsAutoConverted(r, i, n, e), e;
1851
2394
  }
1852
- function nt(i, e, t, n, s) {
2395
+ function Bt(n, e, t, i, s) {
1853
2396
  let r;
1854
- return typeof e == "string" && (r = Ce(e.trim())) ? r : le(s, t, n, i, `'${e}' is not a valid semantic version`);
2397
+ return S(e) && (r = st(e.trim())) ? r : xe(s, t, i, n, `'${F(e)}' is not a valid semantic version`);
1855
2398
  }
1856
- function on(i, e, t, n, s) {
1857
- if (typeof e == "number")
2399
+ function Pi(n, e, t, i, s) {
2400
+ if (W(e))
1858
2401
  return e;
1859
2402
  let r;
1860
- return typeof e == "string" && (!isNaN(r = $e(e.replace(",", "."))) || e.trim() === "NaN") ? r : le(s, t, n, i, `'${e}' is not a valid decimal number`);
2403
+ return S(e) && (!isNaN(r = ft(e.replace(",", "."))) || e.trim() === "NaN") ? r : xe(s, t, i, n, `'${F(e)}' is not a valid decimal number`);
1861
2404
  }
1862
- function an(i, e, t, n, s) {
2405
+ function xi(n, e, t, i, s) {
1863
2406
  if (e instanceof Date)
1864
2407
  return e.getTime() / 1e3;
1865
- if (typeof e == "number")
2408
+ if (W(e))
1866
2409
  return e;
1867
2410
  let r;
1868
- return typeof e == "string" && (!isNaN(r = $e(e.replace(",", "."))) || e.trim() === "NaN") ? r : le(s, t, n, i, `'${e}' is not a valid Unix timestamp (number of seconds elapsed since Unix epoch)`);
2411
+ return S(e) && (!isNaN(r = ft(e.replace(",", "."))) || e.trim() === "NaN") ? r : xe(s, t, i, n, `'${F(e)}' is not a valid Unix timestamp (number of seconds elapsed since Unix epoch)`);
1869
2412
  }
1870
- function it(i, e, t, n, s) {
2413
+ function Kt(n, e, t, i, s) {
1871
2414
  let r = e;
1872
- if (typeof r == "string")
2415
+ if (S(r))
1873
2416
  try {
1874
2417
  r = JSON.parse(r);
1875
2418
  } catch {
1876
2419
  }
1877
- return ke(r) ? r : le(s, t, n, i, `'${e}' is not a valid string array`);
2420
+ return Xt(r) ? r : xe(s, t, i, n, `'${F(e)}' is not a valid string array`);
2421
+ }
2422
+ function xe(n, e, t, i, s) {
2423
+ const r = new pe(e, (o) => St(o));
2424
+ return n.userObjectAttributeIsInvalid(r, t, s, i), Ui(i, s);
2425
+ }
2426
+ function re(n) {
2427
+ var e;
2428
+ return (e = n._configJsonSalt) !== null && e !== void 0 ? e : T("Config JSON salt is missing.");
1878
2429
  }
1879
- function le(i, e, t, n, s) {
1880
- return i.userObjectAttributeIsInvalid(Me(e), t, s, n), sn(n, s);
2430
+ function w(n) {
2431
+ return n ?? T("Comparison value is missing.");
1881
2432
  }
1882
- function St(i, e, t, n) {
2433
+ var Wt;
2434
+ (function(n) {
2435
+ n[n.UnexpectedError = -1] = "UnexpectedError", n[n.None = 0] = "None", n[n.InvalidConfigModel = 1] = "InvalidConfigModel", n[n.SettingValueTypeMismatch = 2] = "SettingValueTypeMismatch", n[n.ConfigJsonNotAvailable = 1e3] = "ConfigJsonNotAvailable", n[n.SettingKeyMissing = 1001] = "SettingKeyMissing";
2436
+ })(Wt || (Wt = {}));
2437
+ function wn(n, e, t, i) {
1883
2438
  return {
1884
- key: i,
1885
- value: e.selectedValue.value,
1886
- variationId: e.selectedValue.variationId,
2439
+ key: n,
2440
+ value: e.returnValue,
2441
+ variationId: e.selectedValue.i,
1887
2442
  fetchTime: t,
1888
- user: n,
2443
+ user: i,
1889
2444
  isDefaultValue: !1,
1890
2445
  matchedTargetingRule: e.matchedTargetingRule,
1891
- matchedPercentageOption: e.matchedPercentageOption
2446
+ matchedPercentageOption: e.matchedPercentageOption,
2447
+ errorCode: 0
1892
2448
  };
1893
2449
  }
1894
- function M(i, e, t, n, s, r) {
2450
+ function Y(n, e, t, i, s, r, o = -1) {
1895
2451
  return {
1896
- key: i,
2452
+ key: n,
1897
2453
  value: e,
1898
2454
  fetchTime: t,
1899
- user: n,
2455
+ user: i,
1900
2456
  isDefaultValue: !0,
1901
- errorMessage: s,
2457
+ errorCode: o,
2458
+ _errorMessage: s,
2459
+ get errorMessage() {
2460
+ var a;
2461
+ return (a = this._errorMessage) === null || a === void 0 ? void 0 : a.toString();
2462
+ },
1902
2463
  errorException: r
1903
2464
  };
1904
2465
  }
1905
- function se(i, e, t, n, s, r, o) {
2466
+ function De(n, e, t, i, s, r, o) {
1906
2467
  let a;
1907
2468
  if (!e)
1908
- return a = o.configJsonIsNotPresentSingle(t, "defaultValue", n).toString(), M(t, n, R(r), s, a);
1909
- const l = e[t];
1910
- if (!l)
1911
- return a = o.settingEvaluationFailedDueToMissingKey(t, "defaultValue", n, De(Object.keys(e))).toString(), M(t, n, R(r), s, a);
1912
- const c = i.evaluate(n, new j(t, l, s, e));
1913
- return St(t, c, R(r), s);
1914
- }
1915
- function st(i, e, t, n, s, r) {
2469
+ return a = o.configJsonIsNotPresentSingle(t, "defaultValue", i), Y(t, i, V(r), s, j(a), void 0, 1e3);
2470
+ if (!L(e, t)) {
2471
+ const c = new pe(e, (f) => ut(Object.keys(f)));
2472
+ return a = o.settingEvaluationFailedDueToMissingKey(t, "defaultValue", i, c), Y(t, i, V(r), s, j(a), void 0, 1001);
2473
+ }
2474
+ const l = n.evaluate(i, new ye(t, e[t], s, e));
2475
+ return wn(t, l, V(r), s);
2476
+ }
2477
+ function zt(n, e, t, i, s, r) {
1916
2478
  let o;
1917
- if (!Ne(e, s, r))
2479
+ if (!At(e, s, r))
1918
2480
  return [[], o];
1919
2481
  const a = [];
1920
- for (const [l, c] of Object.entries(e)) {
1921
- let u;
2482
+ for (const l in e) {
2483
+ if (!L(e, l))
2484
+ continue;
2485
+ const c = e[l];
2486
+ let f;
1922
2487
  try {
1923
- const h = i.evaluate(null, new j(l, c, t, e));
1924
- u = St(l, h, R(n), t);
1925
- } catch (h) {
1926
- o ?? (o = []), o.push(h), u = M(l, null, R(n), t, D(h), h);
2488
+ const u = n.evaluate(null, new ye(l, c, t, e));
2489
+ f = wn(l, u, V(i), t);
2490
+ } catch (u) {
2491
+ o ?? (o = []), o.push(u), f = Y(l, null, V(i), t, z(u), u, de(u));
1927
2492
  }
1928
- a.push(u);
2493
+ a.push(f);
1929
2494
  }
1930
2495
  return [a, o];
1931
2496
  }
1932
- function Ne(i, e, t) {
1933
- return i ? !0 : (e.configJsonIsNotPresent(t), !1);
1934
- }
1935
- function z(i) {
1936
- return typeof i == "boolean" || typeof i == "string" || typeof i == "number";
2497
+ function At(n, e, t) {
2498
+ return n ? !0 : (e.configJsonIsNotPresent(t), !1);
1937
2499
  }
1938
- function ln(i, e) {
1939
- switch (e) {
1940
- case 0:
1941
- return typeof i == "boolean";
1942
- case 1:
1943
- return typeof i == "string";
1944
- case 2:
1945
- case 3:
1946
- return typeof i == "number";
1947
- default:
1948
- return !1;
2500
+ function Rn(n, e, t, i) {
2501
+ if (!At(n, t, i))
2502
+ return null;
2503
+ for (const s in n) {
2504
+ if (!L(n, s))
2505
+ continue;
2506
+ const r = n[s], o = vt(r);
2507
+ if (e === r.i)
2508
+ return { settingKey: s, settingValue: U(r.v, o) };
2509
+ const a = r.r;
2510
+ if (a != null && a.length)
2511
+ for (let c = 0; c < a.length; c++) {
2512
+ const f = a[c];
2513
+ if (yt(f)) {
2514
+ const u = f.p;
2515
+ for (let h = 0; h < u.length; h++) {
2516
+ const g = u[h];
2517
+ if (e === g.i)
2518
+ return { settingKey: s, settingValue: U(g.v, o) };
2519
+ }
2520
+ } else {
2521
+ const u = f.s;
2522
+ if (e === u.i)
2523
+ return { settingKey: s, settingValue: U(u.v, o) };
2524
+ }
2525
+ }
2526
+ const l = r.p;
2527
+ if (l != null && l.length)
2528
+ for (let c = 0; c < l.length; c++) {
2529
+ const f = l[c];
2530
+ if (e === f.i)
2531
+ return { settingKey: s, settingValue: U(f.v, o) };
2532
+ }
1949
2533
  }
2534
+ return t.settingForVariationIdIsNotPresent(e), null;
1950
2535
  }
1951
- function Re(i) {
1952
- throw new TypeError(i === null ? "Setting value is null." : i === void 0 ? "Setting value is undefined." : `Setting value '${i}' is of an unsupported type (${typeof i}).`);
2536
+ class ge extends Error {
2537
+ constructor(e, t) {
2538
+ super(t), this.errorCode = e, this.message = t, this.name = ge.name, rt(this, ge);
2539
+ }
1953
2540
  }
1954
- function R(i) {
1955
- return i ? new Date(i.timestamp) : void 0;
2541
+ function de(n) {
2542
+ return n instanceof Error ? n instanceof ge ? n.errorCode : n instanceof fe ? 1 : -1 : -1;
1956
2543
  }
1957
- class cn {
2544
+ class _i {
1958
2545
  constructor() {
1959
- this.instances = {};
2546
+ this.instances = N();
1960
2547
  }
1961
- getOrCreate(e, t) {
1962
- let n;
1963
- const s = this.instances[e.sdkKey];
1964
- if (s) {
1965
- const [a] = s;
1966
- if (n = a.deref(), n)
1967
- return [n, !0];
2548
+ getOrCreate(e) {
2549
+ let t;
2550
+ const i = this.instances[e.sdkKey];
2551
+ if (i) {
2552
+ const [r] = i;
2553
+ if (t = r.deref(), t)
2554
+ return [t, !0];
1968
2555
  }
1969
- const r = {};
1970
- n = new k(e, t, r);
1971
- const o = dt() ? WeakRef : ft();
1972
- return this.instances[e.sdkKey] = [new o(n), r], [n, !1];
2556
+ const s = {};
2557
+ return t = new B(e, s), this.instances[e.sdkKey] = [Yt(t), s], [t, !1];
1973
2558
  }
1974
2559
  remove(e, t) {
1975
- const n = this.instances[e];
1976
- if (n) {
1977
- const [s, r] = n, o = !!s.deref();
2560
+ const i = this.instances[e];
2561
+ if (i) {
2562
+ const [s, r] = i, o = !!s.deref();
1978
2563
  if (!o || r === t)
1979
2564
  return delete this.instances[e], o;
1980
2565
  }
@@ -1982,83 +2567,77 @@ class cn {
1982
2567
  }
1983
2568
  clear() {
1984
2569
  const e = [];
1985
- for (const [t, [n]] of Object.entries(this.instances)) {
1986
- const s = n.deref();
2570
+ for (const t in this.instances) {
2571
+ const [i] = this.instances[t], s = i.deref();
1987
2572
  s && e.push(s), delete this.instances[t];
1988
2573
  }
1989
2574
  return e;
1990
2575
  }
1991
2576
  }
1992
- const q = new cn();
1993
- class k {
2577
+ const oe = new _i();
2578
+ class B {
1994
2579
  static get instanceCache() {
1995
- return q;
2580
+ return oe;
1996
2581
  }
1997
- static get(e, t, n, s) {
2582
+ static get(e, t, i, s) {
1998
2583
  var r;
1999
- const o = "Invalid 'sdkKey' value";
2000
- if (!e)
2001
- throw new Error(o);
2002
- const a = t === 0 ? ze : t === 2 ? je : t === 1 ? Je : Be(new Error("Invalid 'pollingMode' value")), l = new a(e, s.sdkType, s.sdkVersion, n, s.defaultCacheFactory, s.eventEmitterFactory);
2003
- if (((r = l.flagOverrides) === null || r === void 0 ? void 0 : r.behaviour) !== 0 && !un(e, l.baseUrlOverriden))
2004
- throw new Error(o);
2005
- const [c, u] = q.getOrCreate(l, s);
2006
- return u && n && l.logger.clientIsAlreadyCreated(e), c;
2007
- }
2008
- constructor(e, t, n) {
2009
- var s;
2010
- if (this.cacheToken = n, this.addListener = this.on, this.off = this.removeListener, !e)
2011
- throw new Error("Invalid 'options' value");
2012
- if (this.options = e, this.options.logger.debug("Initializing ConfigCatClient. Options: " + JSON.stringify(this.options)), !t)
2013
- throw new Error("Invalid 'configCatKernel' value");
2014
- if (!t.configFetcher)
2015
- throw new Error("Invalid 'configCatKernel.configFetcher' value");
2016
- this.hooks = e.yieldHooks(), e.defaultUser && this.setDefaultUser(e.defaultUser), this.evaluator = new rn(e.logger), ((s = e.flagOverrides) === null || s === void 0 ? void 0 : s.behaviour) !== 0 ? this.configService = e instanceof ze ? new _t(t.configFetcher, e) : e instanceof je ? new Qt(t.configFetcher, e) : e instanceof Je ? new Yt(t.configFetcher, e) : Be(new Error("Invalid 'options' value")) : this.hooks.emit("clientReady", 1), this.suppressFinalize = ee(this, { sdkKey: e.sdkKey, cacheToken: n, configService: this.configService, logger: e.logger });
2584
+ G(e, "sdkKey", !0), i == null || $(i, "options");
2585
+ const o = t === 0 ? new bi(e, s, i) : t === 2 ? new wi(e, s, i) : t === 1 ? new Ri(e, s, i) : Z(t, "pollingMode", "PollingMode", () => !1);
2586
+ ((r = o.flagOverrides) === null || r === void 0 ? void 0 : r.behaviour) !== 0 && !Hi(e, o.baseUrlOverriden) && Q("sdkKey", `Expected a string matching the SDK Key format, got '${F(e)}'.`);
2587
+ const [a, l] = oe.getOrCreate(o);
2588
+ return l && i && o.logger.clientIsAlreadyCreated(e), a;
2589
+ }
2590
+ constructor(e, t) {
2591
+ var i;
2592
+ this.cacheToken = t, this.options = e, e.logger.isEnabled(4) && e.logger.debug(y.from("OPTIONS")`Initializing ConfigCatClient. Options: ${JSON.stringify(qi(e))}`), this.hooks = e.yieldHooks(), this.hooks.configCatClient = this, this.defaultUser = e.defaultUser, this.evaluator = new Mi(e.logger), ((i = e.flagOverrides) === null || i === void 0 ? void 0 : i.behaviour) !== 0 ? this.configService = e.createConfigService() : (this.configService = null, this.hooks.emit("clientReady", 1)), this.suppressFinalize = Oe(this, { sdkKey: e.sdkKey, cacheToken: t, configService: this.configService, logger: e.logger });
2593
+ }
2594
+ initConfigService(e) {
2595
+ this.configService = e;
2017
2596
  }
2018
2597
  static finalize(e) {
2019
2598
  var t;
2020
- (t = e.logger) === null || t === void 0 || t.debug("finalize() called"), e.cacheToken && q.remove(e.sdkKey, e.cacheToken), k.close(e.configService, e.logger);
2599
+ (t = e.logger) === null || t === void 0 || t.debug("finalize() called."), e.cacheToken && oe.remove(e.sdkKey, e.cacheToken), B.close(e.configService, e.logger);
2021
2600
  }
2022
- static close(e, t, n) {
2023
- t == null || t.debug("close() called"), n == null || n.tryDisconnect(), e == null || e.dispose();
2601
+ static close(e, t, i) {
2602
+ t == null || t.debug("close() called."), i == null || i.tryDisconnect(), e == null || e.dispose();
2024
2603
  }
2025
2604
  dispose() {
2026
2605
  const e = this.options;
2027
- e.logger.debug("dispose() called"), this.cacheToken && q.remove(e.sdkKey, this.cacheToken), k.close(this.configService, e.logger, this.hooks), this.suppressFinalize();
2606
+ e.logger.debug("dispose() called."), this.cacheToken && oe.remove(e.sdkKey, this.cacheToken), B.close(this.configService, e.logger, this.hooks), this.suppressFinalize();
2028
2607
  }
2029
2608
  static disposeAll() {
2030
- const e = q.clear();
2609
+ const e = oe.clear();
2031
2610
  let t;
2032
- for (const n of e)
2611
+ for (const i of e)
2033
2612
  try {
2034
- k.close(n.configService, n.options.logger, n.hooks), n.suppressFinalize();
2613
+ B.close(i.configService, i.options.logger, i.hooks), i.suppressFinalize();
2035
2614
  } catch (s) {
2036
2615
  t ?? (t = []), t.push(s);
2037
2616
  }
2038
2617
  if (t)
2039
- throw typeof AggregateError < "u" ? new AggregateError(t) : t.pop();
2618
+ throw typeof AggregateError == "function" ? AggregateError(t) : t.pop();
2040
2619
  }
2041
- async getValueAsync(e, t, n) {
2042
- this.options.logger.debug("getValueAsync() called."), re(e), oe(t);
2620
+ async getValueAsync(e, t, i) {
2621
+ this.options.logger.debug("getValueAsync() called."), $e(e), Ue(t), X(i);
2043
2622
  let s, r, o = null;
2044
- n ?? (n = this.defaultUser);
2623
+ i ?? (i = this.defaultUser);
2045
2624
  try {
2046
2625
  let a;
2047
- [a, o] = await this.getSettingsAsync(), r = se(this.evaluator, a, e, t, n, o, this.options.logger), s = r.value;
2626
+ [a, o] = await this.getSettingsAsync(), r = De(this.evaluator, a, e, t, i, o, this.options.logger), s = r.value;
2048
2627
  } catch (a) {
2049
- this.options.logger.settingEvaluationErrorSingle("getValueAsync", e, "defaultValue", t, a), r = M(e, t, R(o), n, D(a), a), s = t;
2628
+ this.options.logger.settingEvaluationErrorSingle("getValueAsync", e, "defaultValue", t, a), r = Y(e, t, V(o), i, z(a), a, de(a)), s = t;
2050
2629
  }
2051
2630
  return this.hooks.emit("flagEvaluated", r), s;
2052
2631
  }
2053
- async getValueDetailsAsync(e, t, n) {
2054
- this.options.logger.debug("getValueDetailsAsync() called."), re(e), oe(t);
2632
+ async getValueDetailsAsync(e, t, i) {
2633
+ this.options.logger.debug("getValueDetailsAsync() called."), $e(e), Ue(t), X(i);
2055
2634
  let s, r = null;
2056
- n ?? (n = this.defaultUser);
2635
+ i ?? (i = this.defaultUser);
2057
2636
  try {
2058
2637
  let o;
2059
- [o, r] = await this.getSettingsAsync(), s = se(this.evaluator, o, e, t, n, r, this.options.logger);
2638
+ [o, r] = await this.getSettingsAsync(), s = De(this.evaluator, o, e, t, i, r, this.options.logger);
2060
2639
  } catch (o) {
2061
- this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync", e, "defaultValue", t, o), s = M(e, t, R(r), n, D(o), o);
2640
+ this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync", e, "defaultValue", t, o), s = Y(e, t, V(r), i, z(o), o, de(o));
2062
2641
  }
2063
2642
  return this.hooks.emit("flagEvaluated", s), s;
2064
2643
  }
@@ -2067,79 +2646,52 @@ class k {
2067
2646
  const e = "empty array";
2068
2647
  try {
2069
2648
  const [t] = await this.getSettingsAsync();
2070
- return Ne(t, this.options.logger, e) ? Object.keys(t) : [];
2649
+ return At(t, this.options.logger, e) ? Object.keys(t) : [];
2071
2650
  } catch (t) {
2072
2651
  return this.options.logger.settingEvaluationError("getAllKeysAsync", e, t), [];
2073
2652
  }
2074
2653
  }
2075
2654
  async getAllValuesAsync(e) {
2076
- this.options.logger.debug("getAllValuesAsync() called.");
2655
+ this.options.logger.debug("getAllValuesAsync() called."), X(e);
2077
2656
  const t = "empty array";
2078
- let n, s, r;
2657
+ let i, s, r;
2079
2658
  e ?? (e = this.defaultUser);
2080
2659
  try {
2081
2660
  const [o, a] = await this.getSettingsAsync();
2082
- [s, r] = st(this.evaluator, o, e, a, this.options.logger, t), n = s.map((l) => ({ settingKey: l.key, settingValue: l.value }));
2661
+ [s, r] = zt(this.evaluator, o, e, a, this.options.logger, t), i = s.map((l) => ({ settingKey: l.key, settingValue: l.value }));
2083
2662
  } catch (o) {
2084
2663
  return this.options.logger.settingEvaluationError("getAllValuesAsync", t, o), [];
2085
2664
  }
2086
- r != null && r.length && this.options.logger.settingEvaluationError("getAllValuesAsync", "evaluation result", typeof AggregateError < "u" ? new AggregateError(r) : r.pop());
2665
+ r != null && r.length && this.options.logger.settingEvaluationError("getAllValuesAsync", "evaluation result", typeof AggregateError == "function" ? AggregateError(r) : r.pop());
2087
2666
  for (const o of s)
2088
2667
  this.hooks.emit("flagEvaluated", o);
2089
- return n;
2668
+ return i;
2090
2669
  }
2091
2670
  async getAllValueDetailsAsync(e) {
2092
- this.options.logger.debug("getAllValueDetailsAsync() called.");
2671
+ this.options.logger.debug("getAllValueDetailsAsync() called."), X(e);
2093
2672
  const t = "empty array";
2094
- let n, s;
2673
+ let i, s;
2095
2674
  e ?? (e = this.defaultUser);
2096
2675
  try {
2097
2676
  const [r, o] = await this.getSettingsAsync();
2098
- [n, s] = st(this.evaluator, r, e, o, this.options.logger, t);
2677
+ [i, s] = zt(this.evaluator, r, e, o, this.options.logger, t);
2099
2678
  } catch (r) {
2100
2679
  return this.options.logger.settingEvaluationError("getAllValueDetailsAsync", t, r), [];
2101
2680
  }
2102
- s != null && s.length && this.options.logger.settingEvaluationError("getAllValueDetailsAsync", "evaluation result", typeof AggregateError < "u" ? new AggregateError(s) : s.pop());
2103
- for (const r of n)
2681
+ s != null && s.length && this.options.logger.settingEvaluationError("getAllValueDetailsAsync", "evaluation result", typeof AggregateError == "function" ? AggregateError(s) : s.pop());
2682
+ for (const r of i)
2104
2683
  this.hooks.emit("flagEvaluated", r);
2105
- return n;
2684
+ return i;
2106
2685
  }
2107
2686
  async getKeyAndValueAsync(e) {
2108
- this.options.logger.debug("getKeyAndValueAsync() called.");
2687
+ this.options.logger.debug("getKeyAndValueAsync() called."), Nn(e);
2109
2688
  const t = "null";
2110
2689
  try {
2111
- const [n] = await this.getSettingsAsync();
2112
- if (!Ne(n, this.options.logger, t))
2113
- return null;
2114
- for (const [s, r] of Object.entries(n)) {
2115
- if (e === r.variationId)
2116
- return { settingKey: s, settingValue: Z(r.value) };
2117
- const { targetingRules: o } = r;
2118
- if (o.length > 0)
2119
- for (let l = 0; l < o.length; l++) {
2120
- const c = o[l].then;
2121
- if (x(c))
2122
- for (let u = 0; u < c.length; u++) {
2123
- const h = c[u];
2124
- if (e === h.variationId)
2125
- return { settingKey: s, settingValue: Z(h.value) };
2126
- }
2127
- else if (e === c.variationId)
2128
- return { settingKey: s, settingValue: Z(c.value) };
2129
- }
2130
- const { percentageOptions: a } = r;
2131
- if (a.length > 0)
2132
- for (let l = 0; l < a.length; l++) {
2133
- const c = a[l];
2134
- if (e === c.variationId)
2135
- return { settingKey: s, settingValue: Z(c.value) };
2136
- }
2137
- }
2138
- this.options.logger.settingForVariationIdIsNotPresent(e);
2139
- } catch (n) {
2140
- this.options.logger.settingEvaluationError("getKeyAndValueAsync", t, n);
2690
+ const [i] = await this.getSettingsAsync();
2691
+ return Rn(i, e, this.options.logger, t);
2692
+ } catch (i) {
2693
+ return this.options.logger.settingEvaluationError("getKeyAndValueAsync", t, i), null;
2141
2694
  }
2142
- return null;
2143
2695
  }
2144
2696
  async forceRefreshAsync() {
2145
2697
  if (this.options.logger.debug("forceRefreshAsync() called."), this.configService)
@@ -2147,13 +2699,13 @@ class k {
2147
2699
  const [e] = await this.configService.refreshConfigAsync();
2148
2700
  return e;
2149
2701
  } catch (e) {
2150
- return this.options.logger.forceRefreshError("forceRefreshAsync", e), N.failure(D(e), e);
2702
+ return this.options.logger.clientMethodError("forceRefreshAsync", e), we(-1, z(e), e);
2151
2703
  }
2152
2704
  else
2153
- return N.failure("Client is configured to use the LocalOnly override behavior, which prevents making HTTP requests.");
2705
+ return we(1, "Client is configured to use the LocalOnly override behavior, which prevents synchronization with external cache and making HTTP requests.");
2154
2706
  }
2155
2707
  setDefaultUser(e) {
2156
- this.defaultUser = e;
2708
+ this.defaultUser = $(e, "defaultUser");
2157
2709
  }
2158
2710
  clearDefaultUser() {
2159
2711
  this.defaultUser = void 0;
@@ -2163,7 +2715,7 @@ class k {
2163
2715
  return (t = (e = this.configService) === null || e === void 0 ? void 0 : e.isOffline) !== null && t !== void 0 ? t : !0;
2164
2716
  }
2165
2717
  setOnline() {
2166
- this.configService ? this.configService.setOnline() : this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(Bt(0), "setOnline");
2718
+ this.configService ? this.configService.setOnline() : this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(Pe(0), "setOnline");
2167
2719
  }
2168
2720
  setOffline() {
2169
2721
  var e;
@@ -2175,40 +2727,46 @@ class k {
2175
2727
  }
2176
2728
  snapshot() {
2177
2729
  const e = () => {
2730
+ var s;
2178
2731
  const r = this.options.cache.getInMemory();
2179
- return [r.isEmpty ? null : r.config.settings, r];
2732
+ return [r.isEmpty ? null : (s = r.config.f) !== null && s !== void 0 ? s : N(), r];
2180
2733
  };
2181
- let t, n;
2182
- const { flagOverrides: s } = this.options;
2183
- if (s) {
2184
- const r = s.dataSource.getOverridesSync();
2185
- switch (s.behaviour) {
2186
- case 0:
2187
- return new X(r, null, this);
2188
- case 1:
2189
- return [t, n] = e(), new X(Object.assign(Object.assign({}, t ?? {}), r), n, this);
2190
- case 2:
2191
- return [t, n] = e(), new X(Object.assign(Object.assign({}, r), t ?? {}), n, this);
2734
+ let t, i;
2735
+ try {
2736
+ const { flagOverrides: s } = this.options;
2737
+ if (s) {
2738
+ const r = s.dataSource.getOverrides();
2739
+ switch (s.behaviour) {
2740
+ case 0:
2741
+ return new ae(r, null, this);
2742
+ case 1:
2743
+ return [t, i] = e(), new ae(Object.assign(Object.assign({}, t), r), i, this);
2744
+ case 2:
2745
+ return [t, i] = e(), new ae(Object.assign(Object.assign({}, r), t), i, this);
2746
+ }
2192
2747
  }
2748
+ return [t, i] = e(), new ae(t, i, this);
2749
+ } catch (s) {
2750
+ return this.options.logger.clientMethodError("snapshot", s), new ae(N(), null, this);
2193
2751
  }
2194
- return [t, n] = e(), new X(t, n, this);
2195
2752
  }
2196
2753
  async getSettingsAsync() {
2197
2754
  this.options.logger.debug("getSettingsAsync() called.");
2198
2755
  const e = async () => {
2199
- const n = await this.configService.getConfig();
2200
- return [n.isEmpty ? null : n.config.settings, n];
2756
+ var i;
2757
+ const s = await this.configService.getConfigAsync();
2758
+ return [s.isEmpty ? null : (i = s.config.f) !== null && i !== void 0 ? i : N(), s];
2201
2759
  }, { flagOverrides: t } = this.options;
2202
2760
  if (t) {
2203
- let n, s;
2204
- const r = await t.dataSource.getOverrides();
2761
+ let i, s;
2762
+ const r = t.dataSource.getOverrides();
2205
2763
  switch (t.behaviour) {
2206
2764
  case 0:
2207
2765
  return [r, null];
2208
2766
  case 1:
2209
- return [n, s] = await e(), [Object.assign(Object.assign({}, n ?? {}), r), s];
2767
+ return [i, s] = await e(), [Object.assign(Object.assign({}, i), r), s];
2210
2768
  case 2:
2211
- return [n, s] = await e(), [Object.assign(Object.assign({}, r), n ?? {}), s];
2769
+ return [i, s] = await e(), [Object.assign(Object.assign({}, r), i), s];
2212
2770
  }
2213
2771
  }
2214
2772
  return await e();
@@ -2235,9 +2793,12 @@ class k {
2235
2793
  return this.hooks.eventNames();
2236
2794
  }
2237
2795
  }
2238
- class X {
2239
- constructor(e, t, n) {
2240
- this.mergedSettings = e, this.remoteConfig = t, this.defaultUser = n.defaultUser, this.evaluator = n.evaluator, this.options = n.options, this.cacheState = t ? n.configService.getCacheState(t) : 1;
2796
+ const ke = B.prototype;
2797
+ ke.addListener = ke.on;
2798
+ ke.off = ke.removeListener;
2799
+ class ae {
2800
+ constructor(e, t, i) {
2801
+ this.mergedSettings = e, this.remoteConfig = t, this.defaultUser = i.defaultUser, this.evaluator = i.evaluator, this.options = i.options, this.cacheState = t ? i.configService.getCacheState(t) : 1;
2241
2802
  }
2242
2803
  get fetchedConfig() {
2243
2804
  const e = this.remoteConfig;
@@ -2246,423 +2807,356 @@ class X {
2246
2807
  getAllKeys() {
2247
2808
  return this.mergedSettings ? Object.keys(this.mergedSettings) : [];
2248
2809
  }
2249
- getValue(e, t, n) {
2250
- this.options.logger.debug("Snapshot.getValue() called."), re(e), oe(t);
2810
+ getValue(e, t, i) {
2811
+ this.options.logger.debug("Snapshot.getValue() called."), $e(e), Ue(t), X(i);
2251
2812
  let s, r;
2252
- n ?? (n = this.defaultUser);
2813
+ i ?? (i = this.defaultUser);
2253
2814
  try {
2254
- r = se(this.evaluator, this.mergedSettings, e, t, n, this.remoteConfig, this.options.logger), s = r.value;
2815
+ r = De(this.evaluator, this.mergedSettings, e, t, i, this.remoteConfig, this.options.logger), s = r.value;
2255
2816
  } catch (o) {
2256
- this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue", e, "defaultValue", t, o), r = M(e, t, R(this.remoteConfig), n, D(o), o), s = t;
2817
+ this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue", e, "defaultValue", t, o), r = Y(e, t, V(this.remoteConfig), i, z(o), o, de(o)), s = t;
2257
2818
  }
2258
2819
  return this.options.hooks.emit("flagEvaluated", r), s;
2259
2820
  }
2260
- getValueDetails(e, t, n) {
2261
- this.options.logger.debug("Snapshot.getValueDetails() called."), re(e), oe(t);
2821
+ getValueDetails(e, t, i) {
2822
+ this.options.logger.debug("Snapshot.getValueDetails() called."), $e(e), Ue(t), X(i);
2262
2823
  let s;
2263
- n ?? (n = this.defaultUser);
2824
+ i ?? (i = this.defaultUser);
2264
2825
  try {
2265
- s = se(this.evaluator, this.mergedSettings, e, t, n, this.remoteConfig, this.options.logger);
2826
+ s = De(this.evaluator, this.mergedSettings, e, t, i, this.remoteConfig, this.options.logger);
2266
2827
  } catch (r) {
2267
- this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails", e, "defaultValue", t, r), s = M(e, t, R(this.remoteConfig), n, D(r), r);
2828
+ this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails", e, "defaultValue", t, r), s = Y(e, t, V(this.remoteConfig), i, z(r), r, de(r));
2268
2829
  }
2269
2830
  return this.options.hooks.emit("flagEvaluated", s), s;
2270
2831
  }
2832
+ getKeyAndValue(e) {
2833
+ this.options.logger.debug("Snapshot.getKeyAndValue() called."), Nn(e);
2834
+ const t = "null";
2835
+ try {
2836
+ return Rn(this.mergedSettings, e, this.options.logger, t);
2837
+ } catch (i) {
2838
+ return this.options.logger.settingEvaluationError("Snapshot.getKeyAndValue", t, i), null;
2839
+ }
2840
+ }
2271
2841
  }
2272
- function un(i, e) {
2273
- const t = "configcat-proxy/";
2274
- if (e && i.length > t.length && i.lastIndexOf(t, 0) === 0)
2842
+ function Hi(n, e) {
2843
+ if (e && n.length > et.length && n.lastIndexOf(et, 0) === 0)
2275
2844
  return !0;
2276
- const n = i.split("/"), s = 22;
2277
- switch (n.length) {
2845
+ const t = n.split("/"), i = 22;
2846
+ switch (t.length) {
2278
2847
  case 2:
2279
- return n[0].length === s && n[1].length === s;
2848
+ return t[0].length === i && t[1].length === i;
2280
2849
  case 3:
2281
- return n[0] === "configcat-sdk-1" && n[1].length === s && n[2].length === s;
2850
+ return t[0] === "configcat-sdk-1" && t[1].length === i && t[2].length === i;
2282
2851
  default:
2283
2852
  return !1;
2284
2853
  }
2285
2854
  }
2286
- function re(i) {
2287
- if (!i)
2288
- throw new Error("Invalid 'key' value");
2855
+ function $e(n) {
2856
+ G(n, "key", !0);
2289
2857
  }
2290
- function oe(i) {
2291
- if (i != null && !z(i))
2292
- throw new TypeError("The default value must be boolean, number, string, null or undefined.");
2858
+ function Ue(n) {
2859
+ n != null && !pt(n) && Q("defaultValue", "The default value must be boolean, number, string, null or undefined.", void 0, TypeError);
2293
2860
  }
2294
- function Z(i) {
2295
- return z(i) ? i : Re(i);
2861
+ function X(n) {
2862
+ n == null || $(n, "user");
2296
2863
  }
2297
- let ee = function(i, e) {
2298
- if (typeof FinalizationRegistry < "u") {
2299
- const t = new FinalizationRegistry((n) => k.finalize(n));
2300
- ee = (n, s) => {
2864
+ function Nn(n) {
2865
+ G(n, "variationId", !0);
2866
+ }
2867
+ function qi(n) {
2868
+ return Nt(n, (e, t) => t == null ? t : e === "defaultUser" ? Tn(t) : e === "flagOverrides" ? Nt(t, (i, s) => Ce(s) ? F(s) : s) : Ce(t) ? F(t) : t);
2869
+ }
2870
+ let Oe = function(n, e) {
2871
+ if (typeof FinalizationRegistry == "function") {
2872
+ const t = new FinalizationRegistry((i) => B.finalize(i));
2873
+ Oe = (i, s) => {
2301
2874
  const r = {};
2302
- return t.register(n, s, r), () => t.unregister(r);
2875
+ return t.register(i, s, r), () => t.unregister(r);
2303
2876
  };
2304
2877
  } else
2305
- ee = () => () => {
2878
+ Oe = () => () => {
2306
2879
  };
2307
- return ee(i, e);
2880
+ return Oe(n, e);
2308
2881
  };
2309
- function At(i, e, t, n) {
2310
- return k.get(i, e, t, n);
2311
- }
2312
- function hn() {
2313
- k.disposeAll();
2314
- }
2315
- function gn(i, e) {
2316
- return new ct(i, e);
2882
+ function ji(n, e, t, i) {
2883
+ return B.get(n, e, t, i);
2317
2884
  }
2318
- function fn(i, e, t) {
2319
- return { dataSource: new Wt(i, t), behaviour: e };
2885
+ function es(n, e) {
2886
+ return Z(n, "logLevel", "LogLevel", (t) => fn(t) !== void 0), e == null || G(e, "eol", !0), new hn(n, e);
2320
2887
  }
2321
- function dn(i, e, t, n) {
2322
- return { dataSource: new zt(e, t, n), behaviour: i };
2888
+ function ts(n, e, t) {
2889
+ return $(n, "map"), Z(e, "behaviour", "OverrideBehaviour", (i) => Pe(i) !== void 0), t == null || ct(t, "watchChanges"), { dataSource: new gi(n, t), behaviour: e };
2323
2890
  }
2324
- function B(i) {
2325
- return !!i.fn;
2891
+ function ns(n, e, t, i) {
2892
+ return Z(n, "behaviour", "OverrideBehaviour", (s) => Pe(s) !== void 0), e == null || ct(e, "watchChanges"), t == null || G(t, "paramPrefix"), i == null || $(i, "queryStringProvider"), { dataSource: new pi(e, t, i), behaviour: n };
2326
2893
  }
2327
- class wt {
2328
- constructor() {
2329
- this.events = {}, this.eventCount = 0, this.addListener = this.on, this.off = this.removeListener;
2330
- }
2331
- addListenerCore(e, t, n) {
2332
- if (typeof t != "function")
2333
- throw new TypeError("Listener must be a function");
2334
- const s = this.events[e], r = { fn: t, once: n };
2335
- return s ? B(s) ? this.events[e] = [s, r] : s.push(r) : (this.events[e] = r, this.eventCount++), this;
2336
- }
2337
- removeListenerCore(e, t, n) {
2338
- const s = this.events[e];
2339
- if (!s)
2340
- return this;
2341
- if (B(s))
2342
- n(s, t) && this.removeEvent(e);
2343
- else for (let r = s.length - 1; r >= 0; r--)
2344
- if (n(s[r], t)) {
2345
- s.splice(r, 1), s.length ? s.length === 1 && (this.events[e] = s[0]) : this.removeEvent(e);
2346
- break;
2347
- }
2348
- return this;
2349
- }
2350
- removeEvent(e) {
2351
- --this.eventCount === 0 ? this.events = {} : delete this.events[e];
2352
- }
2353
- on(e, t) {
2354
- return this.addListenerCore(e, t, !1);
2355
- }
2356
- once(e, t) {
2357
- return this.addListenerCore(e, t, !0);
2358
- }
2359
- removeListener(e, t) {
2360
- if (typeof t != "function")
2361
- throw new TypeError("Listener must be a function");
2362
- return this.removeListenerCore(e, t, (n, s) => n.fn === s);
2363
- }
2364
- removeAllListeners(e) {
2365
- return e ? this.events[e] && this.removeEvent(e) : (this.events = {}, this.eventCount = 0), this;
2366
- }
2367
- listeners(e) {
2368
- const t = this.events[e];
2369
- if (!t)
2370
- return [];
2371
- if (B(t))
2372
- return [t.fn];
2373
- const n = t.length, s = new Array(n);
2374
- for (let r = 0; r < n; r++)
2375
- s[r] = t[r].fn;
2376
- return s;
2894
+ const le = "configCache";
2895
+ class Fn {
2896
+ static tryGetFactory() {
2897
+ const e = Vi();
2898
+ if (e)
2899
+ return (t) => new Me(new Fn(e), t.logger);
2377
2900
  }
2378
- listenerCount(e) {
2379
- const t = this.events[e];
2380
- return t ? B(t) ? 1 : t.length : 0;
2901
+ constructor(e) {
2902
+ this.dbConnectionFactory = e;
2381
2903
  }
2382
- eventNames() {
2383
- const e = [];
2384
- if (this.eventCount === 0)
2385
- return e;
2386
- const t = this.events;
2387
- for (const n in t)
2388
- Object.prototype.hasOwnProperty.call(t, n) && e.push(n);
2389
- return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(t)) : e;
2904
+ async set(e, t) {
2905
+ const i = await this.dbConnectionFactory();
2906
+ try {
2907
+ await new Promise((s, r) => {
2908
+ const o = i.transaction(le, "readwrite");
2909
+ o.oncomplete = () => s(), o.onerror = (l) => r(l.target.error), o.objectStore(le).put(t, e);
2910
+ });
2911
+ } finally {
2912
+ i.close();
2913
+ }
2390
2914
  }
2391
- emit(e, t, n, s, r, ...o) {
2392
- let a = this.events[e];
2393
- if (!a)
2394
- return !1;
2395
- let l, c;
2396
- B(a) ? [l, c] = [a, 1] : (a = a.slice(), [l, c] = [a[0], a.length]);
2397
- const u = arguments.length - 1;
2398
- for (let h = 0; ; ) {
2399
- switch (l.once && this.removeListenerCore(e, l, (g, f) => g === f), u) {
2400
- case 0:
2401
- l.fn.call(this);
2402
- break;
2403
- case 1:
2404
- l.fn.call(this, t);
2405
- break;
2406
- case 2:
2407
- l.fn.call(this, t, n);
2408
- break;
2409
- case 3:
2410
- l.fn.call(this, t, n, s);
2411
- break;
2412
- case 4:
2413
- l.fn.call(this, t, n, s, r);
2414
- break;
2415
- default:
2416
- const g = new Array(u);
2417
- for (let f = 0; f < u; f++)
2418
- g[f] = arguments[f + 1];
2419
- l.fn.apply(this, g);
2420
- break;
2421
- }
2422
- if (++h >= c)
2423
- break;
2424
- l = a[h];
2915
+ async get(e) {
2916
+ const t = await this.dbConnectionFactory();
2917
+ try {
2918
+ return await new Promise((i, s) => {
2919
+ const r = t.transaction(le, "readonly");
2920
+ let o;
2921
+ r.oncomplete = () => i(o), r.onerror = (c) => s(c.target.error);
2922
+ const l = r.objectStore(le).get(e);
2923
+ l.onsuccess = (c) => o = c.target.result;
2924
+ });
2925
+ } finally {
2926
+ t.close();
2425
2927
  }
2426
- return !0;
2427
2928
  }
2428
2929
  }
2429
- class ce {
2930
+ function Vi() {
2931
+ if (typeof indexedDB < "u")
2932
+ try {
2933
+ const n = () => new Promise((e, t) => {
2934
+ const i = indexedDB.open("@configcat/sdk");
2935
+ i.onupgradeneeded = (s) => s.target.result.createObjectStore(le), i.onsuccess = (s) => e(s.target.result), i.onerror = (s) => t(s.target.error);
2936
+ });
2937
+ return n().then((e) => e.close()).catch(() => {
2938
+ }), n;
2939
+ } catch {
2940
+ }
2941
+ }
2942
+ class Ot {
2430
2943
  static tryGetFactory() {
2431
- const e = pn();
2944
+ const e = Bi();
2432
2945
  if (e)
2433
- return (t) => new ae(new ce(e), t.logger);
2946
+ return (t) => new Me(new Ot(e), t.logger);
2434
2947
  }
2435
2948
  constructor(e) {
2436
2949
  this.storage = e;
2437
2950
  }
2438
2951
  set(e, t) {
2439
- this.storage.setItem(e, vn(t));
2952
+ this.storage.setItem(e, Ki(t));
2440
2953
  }
2441
2954
  get(e) {
2442
2955
  const t = this.storage.getItem(e);
2443
2956
  if (t)
2444
- return yn(t);
2957
+ return Wi(t);
2445
2958
  }
2446
2959
  }
2447
- function pn() {
2960
+ function Bi() {
2448
2961
  if (typeof localStorage < "u") {
2449
- const i = "__configcat_localStorage_test";
2962
+ const n = "__configcat_localStorage_test";
2450
2963
  try {
2451
2964
  const e = localStorage;
2452
- e.setItem(i, i);
2965
+ e.setItem(n, n);
2453
2966
  let t;
2454
2967
  try {
2455
- t = e.getItem(i);
2968
+ t = e.getItem(n);
2456
2969
  } finally {
2457
- e.removeItem(i);
2970
+ e.removeItem(n);
2458
2971
  }
2459
- if (t === i)
2972
+ if (t === n)
2460
2973
  return e;
2461
2974
  } catch {
2462
2975
  }
2463
2976
  }
2464
2977
  }
2465
- function vn(i) {
2466
- return i = encodeURIComponent(i), i = i.replace(/%([0-9A-F]{2})/g, (e, t) => String.fromCharCode(parseInt(t, 16))), btoa(i);
2978
+ function Ki(n) {
2979
+ return n = encodeURIComponent(n), n = n.replace(/%([0-9A-F]{2})/g, (e, t) => String.fromCharCode(parseInt(t, 16))), btoa(n);
2467
2980
  }
2468
- function yn(i) {
2469
- return i = atob(i), i = i.replace(/[%\x80-\xFF]/g, (e) => "%" + e.charCodeAt(0).toString(16)), decodeURIComponent(i);
2981
+ function Wi(n) {
2982
+ return n = atob(n), n = n.replace(/[%\x80-\xFF]/g, (e) => "%" + e.charCodeAt(0).toString(16)), decodeURIComponent(n);
2470
2983
  }
2471
- const W = "configCache";
2472
- class Ue {
2473
- static tryGetFactory() {
2474
- const e = mn();
2475
- if (e)
2476
- return (t) => new ae(new Ue(e), t.logger);
2477
- }
2478
- constructor(e) {
2479
- this.dbConnectionFactory = e;
2480
- }
2481
- async set(e, t) {
2482
- const n = await this.dbConnectionFactory();
2483
- try {
2484
- await new Promise((s, r) => {
2485
- const o = n.transaction(W, "readwrite");
2486
- o.oncomplete = () => s(), o.onerror = (l) => r(l.target.error), o.objectStore(W).put(t, e);
2487
- });
2488
- } finally {
2489
- n.close();
2490
- }
2984
+ class Ct {
2985
+ constructor() {
2986
+ this.logger = null;
2491
2987
  }
2492
- async get(e) {
2493
- const t = await this.dbConnectionFactory();
2494
- try {
2495
- return await new Promise((n, s) => {
2496
- const r = t.transaction(W, "readonly");
2497
- let o;
2498
- r.oncomplete = () => n(o), r.onerror = (c) => s(c.target.error);
2499
- const l = r.objectStore(W).get(e);
2500
- l.onsuccess = (c) => o = c.target.result;
2501
- });
2502
- } finally {
2503
- t.close();
2504
- }
2988
+ static getFactory() {
2989
+ return (e) => {
2990
+ const t = new Ct();
2991
+ return t.logger = e.logger, t;
2992
+ };
2505
2993
  }
2506
- }
2507
- function mn() {
2508
- if (typeof indexedDB < "u")
2509
- try {
2510
- const i = () => new Promise((e, t) => {
2511
- const n = indexedDB.open("@configcat/sdk");
2512
- n.onupgradeneeded = (s) => s.target.result.createObjectStore(W), n.onsuccess = (s) => e(s.target.result), n.onerror = (s) => t(s.target.error);
2513
- });
2514
- return i().then((e) => e.close()).catch(() => {
2515
- }), i;
2516
- } catch {
2517
- }
2518
- }
2519
- class Tt {
2520
- handleStateChange(e, t, n) {
2521
- var s;
2994
+ handleStateChange(e, t, i) {
2522
2995
  try {
2523
2996
  if (e.readyState === 4) {
2524
- const { status: r, statusText: o } = e;
2525
- if (r === 200) {
2526
- const a = (s = e.getResponseHeader("ETag")) !== null && s !== void 0 ? s : void 0;
2527
- t({ statusCode: r, reasonPhrase: o, eTag: a, body: e.responseText });
2528
- } else r && t({ statusCode: r, reasonPhrase: o });
2997
+ const { status: s, statusText: r } = e;
2998
+ if (s) {
2999
+ const o = zi(e), a = s === 200 ? e.responseText : void 0;
3000
+ t(new gn(s, r, o, a));
3001
+ }
2529
3002
  }
2530
- } catch (r) {
2531
- n(r);
3003
+ } catch (s) {
3004
+ i(s);
2532
3005
  }
2533
3006
  }
2534
- fetchLogic(e, t) {
2535
- return new Promise((n, s) => {
3007
+ fetchAsync(e) {
3008
+ return new Promise((t, i) => {
3009
+ var s;
2536
3010
  try {
2537
- e.logger.debug("HttpConfigFetcher.fetchLogic() called.");
2538
- const r = new XMLHttpRequest();
2539
- r.onreadystatechange = () => this.handleStateChange(r, n, s), r.ontimeout = () => s(new b("timeout", e.requestTimeoutMs)), r.onabort = () => s(new b("abort")), r.onerror = () => s(new b("failure"));
2540
- let o = e.getUrl();
2541
- t && (o += "&ccetag=" + encodeURIComponent(t)), r.open("GET", o, !0), r.timeout = e.requestTimeoutMs, r.send(null);
3011
+ (s = this.logger) === null || s === void 0 || s.debug("XmlHttpRequestConfigFetcher.fetchAsync() called.");
3012
+ let { url: r } = e;
3013
+ const o = !mn(r), { lastETag: a, timeoutMs: l } = e;
3014
+ a && (r += "&ccetag=" + encodeURIComponent(a));
3015
+ const c = new XMLHttpRequest();
3016
+ c.onreadystatechange = () => this.handleStateChange(c, t, i), c.ontimeout = () => i(new _("timeout", l)), c.onabort = () => i(new _("abort")), c.onerror = () => i(new _("failure")), c.open("GET", r, !0), c.timeout = l, o && this.setRequestHeaders(c, e.headers), c.send(null);
2542
3017
  } catch (r) {
2543
- s(r);
3018
+ i(r);
2544
3019
  }
2545
3020
  });
2546
3021
  }
3022
+ setRequestHeaders(e, t) {
3023
+ }
2547
3024
  }
2548
- class En {
2549
- async fetchLogic(e, t) {
2550
- var n, s;
2551
- const r = { method: "GET" };
2552
- let o;
2553
- if (typeof AbortController < "u") {
2554
- const a = new AbortController(), l = setTimeout(() => a.abort(), e.requestTimeoutMs);
2555
- r.signal = a.signal, o = () => clearTimeout(l);
2556
- } else
2557
- o = () => {
2558
- };
3025
+ function zi(n) {
3026
+ const e = [];
3027
+ return t("ETag", n, e), t("CF-RAY", n, e), e;
3028
+ function t(i, s, r) {
3029
+ const o = s.getResponseHeader(i);
3030
+ o != null && r.push([i, o]);
3031
+ }
3032
+ }
3033
+ class Ji {
3034
+ constructor(e) {
3035
+ this.runsOnServerSide = e, this.logger = null;
3036
+ }
3037
+ async fetchAsync(e) {
3038
+ var t, i, s;
3039
+ (t = this.logger) === null || t === void 0 || t.debug("FetchApiConfigFetcher.fetchAsync() called.");
3040
+ let { url: r } = e;
3041
+ const o = !mn(r), { lastETag: a, timeoutMs: l } = e, c = /* @__PURE__ */ Object.create(null);
3042
+ c.method = "GET", o ? this.setRequestHeaders(c, e.headers) : this.runsOnServerSide && Jt(c, e.headers), a && (this.runsOnServerSide ? ((i = c.headers) !== null && i !== void 0 ? i : c.headers = []).push(["If-None-Match", a]) : r += "&ccetag=" + encodeURIComponent(a));
3043
+ let f;
3044
+ if (typeof AbortController == "function") {
3045
+ const u = new AbortController(), h = setTimeout(() => u.abort(), l);
3046
+ c.signal = u.signal, f = () => clearTimeout(h);
3047
+ }
2559
3048
  try {
2560
- let a = e.getUrl();
2561
- t && (a += "&ccetag=" + encodeURIComponent(t));
2562
- const l = await fetch(a, r), { status: c, statusText: u } = l;
2563
- if (c === 200) {
2564
- const h = await l.text(), g = (n = l.headers.get("ETag")) !== null && n !== void 0 ? n : void 0;
2565
- return { statusCode: c, reasonPhrase: u, eTag: g, body: h };
2566
- } else
2567
- return { statusCode: c, reasonPhrase: u };
2568
- } catch (a) {
2569
- throw a instanceof DOMException && a.name === "AbortError" ? !((s = r.signal) === null || s === void 0) && s.aborted ? new b("timeout", e.requestTimeoutMs) : new b("abort") : new b("failure", a);
3049
+ const u = await fetch(r, c), { status: h, statusText: g } = u, d = Yi(u), E = h === 200 ? await u.text() : void 0;
3050
+ return new gn(h, g, d, E);
3051
+ } catch (u) {
3052
+ throw u instanceof DOMException && u.name === "AbortError" ? !((s = c.signal) === null || s === void 0) && s.aborted ? new _("timeout", l) : new _("abort") : new _("failure", u);
2570
3053
  } finally {
2571
- o();
3054
+ f == null || f();
2572
3055
  }
2573
3056
  }
3057
+ setRequestHeaders(e, t) {
3058
+ this.runsOnServerSide && Jt(e, t);
3059
+ }
2574
3060
  }
2575
- const On = $.fromValue.bind($), Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2576
- __proto__: null,
2577
- DefaultEventEmitter: wt,
2578
- ExternalConfigCache: ae,
2579
- FetchApiConfigFetcher: En,
2580
- FetchError: b,
2581
- FetchResult: I,
2582
- get FetchStatus() {
2583
- return Oe;
2584
- },
2585
- InMemoryConfigCache: lt,
2586
- IndexedDBConfigCache: Ue,
2587
- LocalStorageConfigCache: ce,
2588
- XmlHttpRequestConfigFetcher: Tt,
2589
- createConsoleLogger: gn,
2590
- createFlagOverridesFromMap: fn,
2591
- createFlagOverridesFromQueryParams: dn,
2592
- disposeAllClients: hn,
2593
- getClient: At,
2594
- settingFromValue: On
2595
- }, Symbol.toStringTag, { value: "Module" })), An = "2.5.2", bn = {
3061
+ function Jt(n, e) {
3062
+ var t;
3063
+ for (const [i, s] of e)
3064
+ ((t = n.headers) !== null && t !== void 0 ? t : n.headers = []).push([i, s]);
3065
+ }
3066
+ function Yi(n) {
3067
+ const e = [];
3068
+ return t("ETag", n, e), t("CF-RAY", n, e), e;
3069
+ function t(i, s, r) {
3070
+ const o = s.headers.get(i);
3071
+ o != null && r.push([i, o]);
3072
+ }
3073
+ }
3074
+ class Ln extends Ji {
3075
+ static getFactory() {
3076
+ return (e) => {
3077
+ const t = new Ln();
3078
+ return t.logger = e.logger, t;
3079
+ };
3080
+ }
3081
+ }
3082
+ const Gi = "2.6.1", is = {
2596
3083
  // Vue's `App.prototype.use` does not play nicely with generic `install` functions, so we resort to using a discriminated union.
2597
- install: (i, e) => {
2598
- const { sdkKey: t, pollingMode: n, clientOptions: s } = e, r = {
3084
+ install: (n, e) => {
3085
+ const { sdkKey: t, pollingMode: i, clientOptions: s } = e, r = {
2599
3086
  sdkType: "ConfigCat-Vue",
2600
- sdkVersion: An,
2601
- configFetcher: new Tt(),
2602
- eventEmitterFactory: () => new wt(),
2603
- defaultCacheFactory: ce.tryGetFactory()
2604
- }, o = At(
3087
+ sdkVersion: Gi,
3088
+ eventEmitterFactory: () => new tn(),
3089
+ defaultCacheFactory: Ot.tryGetFactory(),
3090
+ configFetcherFactory: Ct.getFactory()
3091
+ }, o = ji(
2605
3092
  t,
2606
- n ?? Te.AutoPoll,
3093
+ i ?? tt.AutoPoll,
2607
3094
  s,
2608
3095
  r
2609
3096
  );
2610
- i.provide("configCatClient", o);
2611
- const a = i.unmount;
2612
- i.unmount = function() {
3097
+ n.provide("configCatClient", o);
3098
+ const a = n.unmount;
3099
+ n.unmount = function() {
2613
3100
  a.apply(arguments), o.dispose();
2614
3101
  };
2615
3102
  }
2616
- }, Cn = /* @__PURE__ */ bt({
3103
+ }, ss = /* @__PURE__ */ kn({
2617
3104
  __name: "FeatureWrapper",
2618
3105
  props: {
2619
3106
  featureKey: {},
2620
3107
  userObject: {}
2621
3108
  },
2622
3109
  emits: ["flagValueChanged"],
2623
- setup(i, { emit: e }) {
2624
- const t = e, n = i, s = Ct(null), r = Nt("configCatClient") ?? (() => {
3110
+ setup(n, { emit: e }) {
3111
+ const t = e, i = n, s = $n(null), r = Un("configCatClient") ?? (() => {
2625
3112
  throw new Error("ConfigCatPlugin was not installed.");
2626
3113
  })(), o = () => {
2627
- const l = r.snapshot().getValue(n.featureKey, !1, n.userObject);
3114
+ const l = r.snapshot().getValue(i.featureKey, !1, i.userObject);
2628
3115
  s.value !== l && (s.value = l, t("flagValueChanged", l));
2629
3116
  };
2630
- return Rt(() => {
3117
+ return Mn(() => {
2631
3118
  const a = r.snapshot(), l = a.cacheState;
2632
- l == ne.HasUpToDateFlagData || l == ne.HasLocalOverrideFlagDataOnly ? (s.value = a.getValue(
2633
- n.featureKey,
3119
+ l == Re.HasUpToDateFlagData || l == Re.HasLocalOverrideFlagDataOnly ? (s.value = a.getValue(
3120
+ i.featureKey,
2634
3121
  !1,
2635
- n.userObject
2636
- ), r.on("configChanged", o)) : r.getValueAsync(n.featureKey, !1, n.userObject).then((c) => {
2637
- const u = o;
2638
- u && (s.value = c, r.on("configChanged", u));
3122
+ i.userObject
3123
+ ), r.on("configChanged", o)) : r.getValueAsync(i.featureKey, !1, i.userObject).then((c) => {
3124
+ const f = o;
3125
+ f && (s.value = c, r.on("configChanged", f));
2639
3126
  });
2640
- }), Ft(() => {
3127
+ }), Pn(() => {
2641
3128
  r.off("configChanged", o);
2642
- }), (a, l) => s.value === !0 ? ue(a.$slots, "default", { key: 0 }) : s.value === !1 ? ue(a.$slots, "else", { key: 1 }) : ue(a.$slots, "loading", { key: 2 });
3129
+ }), (a, l) => s.value === !0 ? _e(a.$slots, "default", { key: 0 }) : s.value === !1 ? _e(a.$slots, "else", { key: 1 }) : _e(a.$slots, "loading", { key: 2 });
2643
3130
  }
2644
- }), {
2645
- createConsoleLogger: Nn,
2646
- createFlagOverridesFromMap: Rn,
2647
- createFlagOverridesFromQueryParams: Fn
2648
- } = Sn;
3131
+ });
2649
3132
  export {
2650
- ne as ClientCacheState,
2651
- bn as ConfigCatPlugin,
2652
- Tn as ConfigJson,
2653
- He as DataGovernance,
2654
- Cn as FeatureWrapper,
3133
+ Re as ClientCacheState,
3134
+ Ln as ClientSideFetchApiConfigFetcher,
3135
+ is as ConfigCatPlugin,
3136
+ Xi as ConfigJson,
3137
+ nt as DataGovernance,
3138
+ Wt as EvaluationErrorCode,
3139
+ ss as FeatureWrapper,
3140
+ _ as FetchError,
3141
+ ui as FetchRequest,
3142
+ gn as FetchResponse,
2655
3143
  y as FormattableLogMessage,
2656
- Ae as LogLevel,
2657
- Ie as OverrideBehaviour,
2658
- Te as PollingMode,
2659
- me as PrerequisiteFlagComparator,
2660
- N as RefreshResult,
2661
- Ee as SegmentComparator,
2662
- te as SettingType,
2663
- In as User,
2664
- ye as UserComparator,
2665
- Nn as createConsoleLogger,
2666
- Rn as createFlagOverridesFromMap,
2667
- Fn as createFlagOverridesFromQueryParams
3144
+ Fn as IndexedDBConfigCache,
3145
+ Ot as LocalStorageConfigCache,
3146
+ Ge as LogLevel,
3147
+ Xe as OverrideBehaviour,
3148
+ tt as PollingMode,
3149
+ ze as PrerequisiteFlagComparator,
3150
+ Dt as RefreshErrorCode,
3151
+ Je as SegmentComparator,
3152
+ be as SettingType,
3153
+ Zi as User,
3154
+ We as UserComparator,
3155
+ Ct as XmlHttpRequestConfigFetcher,
3156
+ es as createConsoleLogger,
3157
+ ts as createFlagOverridesFromMap,
3158
+ ns as createFlagOverridesFromQueryParams,
3159
+ rn as createSettingFromValue,
3160
+ nn as deserializeConfig,
3161
+ sn as prepareConfig
2668
3162
  };