configcat-vue 1.2.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +1,30 @@
1
- import { openBlock as se, createElementBlock as ae, renderSlot as de } from "vue";
2
- const Be = (t, e) => {
3
- const r = t.__vccOpts || t;
4
- for (const [n, i] of e)
5
- r[n] = i;
6
- return r;
7
- }, Ge = {
8
- emits: ["flagValueChanged"],
9
- props: {
10
- featureKey: {
11
- type: String,
12
- required: !0
13
- },
14
- userObject: {
15
- type: Object,
16
- required: !1,
17
- default: {}
18
- }
19
- },
20
- data() {
21
- return {
22
- isFeatureFlagEnabled: !1
23
- };
24
- },
25
- mounted() {
26
- this.configCatClient.getValueAsync(this.featureKey, !1, this.userObject).then((t) => {
27
- this.isFeatureFlagEnabled = t;
28
- }), this.configCatClient.on("configChanged", (t) => {
29
- const e = t.settings[this.featureKey].value;
30
- this.isFeatureFlagEnabled = e, this.$emit("flagValueChanged", e);
31
- });
32
- },
33
- unmounted() {
34
- this.configCatClient.dispose();
35
- }
36
- }, Je = { key: 0 }, $e = { key: 1 };
37
- function Ye(t, e, r, n, i, o) {
38
- return se(), ae("div", null, [
39
- i.isFeatureFlagEnabled ? (se(), ae("div", Je, [
40
- de(t.$slots, "default")
41
- ])) : (se(), ae("div", $e, [
42
- de(t.$slots, "else")
43
- ]))
44
- ]);
45
- }
46
- const Ut = /* @__PURE__ */ Be(Ge, [["render", Ye]]);
47
- var ue = function(t, e) {
48
- return ue = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
1
+ import { openBlock as Q, createElementBlock as ee, renderSlot as ge } from "vue";
2
+ var pe = function(t, e) {
3
+ return pe = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
49
4
  r.__proto__ = n;
50
5
  } || function(r, n) {
51
6
  for (var i in n)
52
7
  Object.prototype.hasOwnProperty.call(n, i) && (r[i] = n[i]);
53
- }, ue(t, e);
8
+ }, pe(t, e);
54
9
  };
55
- function z(t, e) {
10
+ function B(t, e) {
56
11
  if (typeof e != "function" && e !== null)
57
12
  throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
58
- ue(t, e);
13
+ pe(t, e);
59
14
  function r() {
60
15
  this.constructor = t;
61
16
  }
62
17
  t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r());
63
18
  }
64
- var q = function() {
65
- return q = Object.assign || function(e) {
19
+ var k = function() {
20
+ return k = Object.assign || function(e) {
66
21
  for (var r, n = 1, i = arguments.length; n < i; n++) {
67
22
  r = arguments[n];
68
23
  for (var o in r)
69
24
  Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
70
25
  }
71
26
  return e;
72
- }, q.apply(this, arguments);
27
+ }, k.apply(this, arguments);
73
28
  };
74
29
  function S(t, e, r, n) {
75
30
  function i(o) {
@@ -80,22 +35,22 @@ function S(t, e, r, n) {
80
35
  return new (r || (r = Promise))(function(o, s) {
81
36
  function a(l) {
82
37
  try {
83
- c(n.next(l));
84
- } catch (g) {
85
- s(g);
38
+ u(n.next(l));
39
+ } catch (h) {
40
+ s(h);
86
41
  }
87
42
  }
88
- function u(l) {
43
+ function c(l) {
89
44
  try {
90
- c(n.throw(l));
91
- } catch (g) {
92
- s(g);
45
+ u(n.throw(l));
46
+ } catch (h) {
47
+ s(h);
93
48
  }
94
49
  }
95
- function c(l) {
96
- l.done ? o(l.value) : i(l.value).then(a, u);
50
+ function u(l) {
51
+ l.done ? o(l.value) : i(l.value).then(a, c);
97
52
  }
98
- c((n = n.apply(t, e || [])).next());
53
+ u((n = n.apply(t, e || [])).next());
99
54
  });
100
55
  }
101
56
  function O(t, e) {
@@ -107,1023 +62,1194 @@ function O(t, e) {
107
62
  return s = { next: a(0), throw: a(1), return: a(2) }, typeof Symbol == "function" && (s[Symbol.iterator] = function() {
108
63
  return this;
109
64
  }), s;
110
- function a(c) {
65
+ function a(u) {
111
66
  return function(l) {
112
- return u([c, l]);
67
+ return c([u, l]);
113
68
  };
114
69
  }
115
- function u(c) {
70
+ function c(u) {
116
71
  if (n)
117
72
  throw new TypeError("Generator is already executing.");
118
- for (; s && (s = 0, c[0] && (r = 0)), r; )
73
+ for (; s && (s = 0, u[0] && (r = 0)), r; )
119
74
  try {
120
- if (n = 1, i && (o = c[0] & 2 ? i.return : c[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, c[1])).done)
75
+ if (n = 1, i && (o = u[0] & 2 ? i.return : u[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, u[1])).done)
121
76
  return o;
122
- switch (i = 0, o && (c = [c[0] & 2, o.value]), c[0]) {
77
+ switch (i = 0, o && (u = [u[0] & 2, o.value]), u[0]) {
123
78
  case 0:
124
79
  case 1:
125
- o = c;
80
+ o = u;
126
81
  break;
127
82
  case 4:
128
- return r.label++, { value: c[1], done: !1 };
83
+ return r.label++, { value: u[1], done: !1 };
129
84
  case 5:
130
- r.label++, i = c[1], c = [0];
85
+ r.label++, i = u[1], u = [0];
131
86
  continue;
132
87
  case 7:
133
- c = r.ops.pop(), r.trys.pop();
88
+ u = r.ops.pop(), r.trys.pop();
134
89
  continue;
135
90
  default:
136
- if (o = r.trys, !(o = o.length > 0 && o[o.length - 1]) && (c[0] === 6 || c[0] === 2)) {
91
+ if (o = r.trys, !(o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
137
92
  r = 0;
138
93
  continue;
139
94
  }
140
- if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
141
- r.label = c[1];
95
+ if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
96
+ r.label = u[1];
142
97
  break;
143
98
  }
144
- if (c[0] === 6 && r.label < o[1]) {
145
- r.label = o[1], o = c;
99
+ if (u[0] === 6 && r.label < o[1]) {
100
+ r.label = o[1], o = u;
146
101
  break;
147
102
  }
148
103
  if (o && r.label < o[2]) {
149
- r.label = o[2], r.ops.push(c);
104
+ r.label = o[2], r.ops.push(u);
150
105
  break;
151
106
  }
152
107
  o[2] && r.ops.pop(), r.trys.pop();
153
108
  continue;
154
109
  }
155
- c = e.call(t, r);
110
+ u = e.call(t, r);
156
111
  } catch (l) {
157
- c = [6, l], i = 0;
112
+ u = [6, l], i = 0;
158
113
  } finally {
159
114
  n = o = 0;
160
115
  }
161
- if (c[0] & 5)
162
- throw c[1];
163
- return { value: c[0] ? c[1] : void 0, done: !0 };
116
+ if (u[0] & 5)
117
+ throw u[1];
118
+ return { value: u[0] ? u[1] : void 0, done: !0 };
164
119
  }
165
120
  }
166
- function Xe(t, e, r) {
167
- if (r || arguments.length === 2)
168
- for (var n = 0, i = e.length, o; n < i; n++)
169
- (o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
170
- return t.concat(o || Array.prototype.slice.call(e));
121
+ function $e() {
122
+ for (var t = 0, e = 0, r = arguments.length; e < r; e++)
123
+ t += arguments[e].length;
124
+ for (var n = Array(t), i = 0, e = 0; e < r; e++)
125
+ for (var o = arguments[e], s = 0, a = o.length; s < a; s++, i++)
126
+ n[i] = o[s];
127
+ return n;
171
128
  }
172
- function A(t, e) {
129
+ function C(t, e) {
173
130
  return Object.defineProperty ? Object.defineProperty(t, "raw", { value: e }) : t.raw = e, t;
174
131
  }
175
132
  var K;
176
133
  (function(t) {
177
134
  t[t.Fetched = 0] = "Fetched", t[t.NotModified = 1] = "NotModified", t[t.Errored = 2] = "Errored";
178
135
  })(K || (K = {}));
179
- var x = function() {
180
- function t(e, r, n, i) {
181
- this.status = e, this.config = r, this.errorMessage = n, this.errorException = i;
182
- }
183
- return t.success = function(e) {
184
- return new t(K.Fetched, e);
185
- }, t.notModified = function(e) {
186
- return new t(K.NotModified, e);
187
- }, t.error = function(e, r, n) {
188
- return new t(K.Errored, e, r ?? "Unknown error.", n);
189
- }, t;
190
- }(), ee = function(t) {
191
- z(e, t);
192
- function e(r) {
193
- for (var n = [], i = 1; i < arguments.length; i++)
194
- n[i - 1] = arguments[i];
195
- var o = this, s;
196
- switch (r) {
197
- case "abort":
198
- s = "Request was aborted.";
199
- break;
200
- case "timeout":
201
- var a = n[0];
202
- s = "Request timed out. Timeout value: ".concat(a, "ms");
203
- break;
204
- case "failure":
205
- var u = n[0];
206
- s = "Request failed due to a network or protocol error.", u && (s += " " + (u instanceof Error ? u.message : u + ""));
207
- break;
136
+ var q = (
137
+ /** @class */
138
+ function() {
139
+ function t(e, r, n, i) {
140
+ this.status = e, this.config = r, this.errorMessage = n, this.errorException = i;
208
141
  }
209
- return o = t.call(this, s) || this, o.cause = r, o instanceof e || (Object.setPrototypeOf || function(c, l) {
210
- return c.__proto__ = l;
211
- })(o, e.prototype), o.args = n, o;
212
- }
213
- return e;
214
- }(Error), P = function() {
215
- function t(e, r, n, i) {
216
- this.configJson = e, this.config = r, this.timestamp = n, this.httpETag = i;
217
- }
218
- return t.prototype.with = function(e) {
219
- return new t(this.configJson, this.config, e, this.httpETag);
220
- }, Object.defineProperty(t.prototype, "isEmpty", {
221
- get: function() {
222
- return !this.config;
223
- },
224
- enumerable: !1,
225
- configurable: !0
226
- }), t.prototype.isExpired = function(e) {
227
- return this === t.empty || this.timestamp + e < t.generateTimestamp();
228
- }, t.generateTimestamp = function() {
229
- return new Date().getTime();
230
- }, t.serialize = function(e) {
231
- var r, n;
232
- return e.timestamp + `
142
+ return t.success = function(e) {
143
+ return new t(K.Fetched, e);
144
+ }, t.notModified = function(e) {
145
+ return new t(K.NotModified, e);
146
+ }, t.error = function(e, r, n) {
147
+ return new t(K.Errored, e, r ?? "Unknown error.", n);
148
+ }, t;
149
+ }()
150
+ ), ie = (
151
+ /** @class */
152
+ function(t) {
153
+ B(e, t);
154
+ function e(r) {
155
+ for (var n = [], i = 1; i < arguments.length; i++)
156
+ n[i - 1] = arguments[i];
157
+ var o = t.call(this, function(s, a) {
158
+ switch (s) {
159
+ case "abort":
160
+ return "Request was aborted.";
161
+ case "timeout":
162
+ var c = a[0];
163
+ return "Request timed out. Timeout value: " + c + "ms";
164
+ case "failure":
165
+ var u = a[0], l = "Request failed due to a network or protocol error.";
166
+ return u ? l + " " + (u instanceof Error ? u.message : u + "") : l;
167
+ }
168
+ }(r, n)) || this;
169
+ return o.cause = r, o instanceof e || (Object.setPrototypeOf || function(s, a) {
170
+ return s.__proto__ = a;
171
+ })(o, e.prototype), o.args = n, o;
172
+ }
173
+ return e;
174
+ }(Error)
175
+ ), M = (
176
+ /** @class */
177
+ function() {
178
+ function t(e, r, n, i) {
179
+ this.configJson = e, this.config = r, this.timestamp = n, this.httpETag = i;
180
+ }
181
+ return t.equals = function(e, r) {
182
+ return e.httpETag && r.httpETag ? e.httpETag === r.httpETag : e.configJson === r.configJson;
183
+ }, t.prototype.with = function(e) {
184
+ return new t(this.configJson, this.config, e, this.httpETag);
185
+ }, Object.defineProperty(t.prototype, "isEmpty", {
186
+ get: function() {
187
+ return !this.config;
188
+ },
189
+ enumerable: !1,
190
+ configurable: !0
191
+ }), t.prototype.isExpired = function(e) {
192
+ return this === t.empty || this.timestamp + e < t.generateTimestamp();
193
+ }, t.generateTimestamp = function() {
194
+ return (/* @__PURE__ */ new Date()).getTime();
195
+ }, t.serialize = function(e) {
196
+ var r, n;
197
+ return e.timestamp + `
233
198
  ` + ((r = e.httpETag) !== null && r !== void 0 ? r : "") + `
234
199
  ` + ((n = e.configJson) !== null && n !== void 0 ? n : "");
235
- }, t.deserialize = function(e) {
236
- for (var r = Array(2), n = 0, i = 0; i < r.length; i++) {
237
- if (n = e.indexOf(`
200
+ }, t.deserialize = function(e) {
201
+ for (var r = Array(2), n = 0, i = 0; i < r.length; i++) {
202
+ if (n = e.indexOf(`
238
203
  `, n), n < 0)
239
- throw new Error("Number of values is fewer than expected.");
240
- r[i] = n++;
241
- }
242
- var o = r[0], s = e.substring(0, o), a = parseInt(s);
243
- if (isNaN(a))
244
- throw new Error("Invalid fetch time: " + s);
245
- n = o + 1, o = r[1], s = e.substring(n, o);
246
- var u = s.length > 0 ? s : void 0;
247
- n = o + 1, s = e.substring(n);
248
- var c, l;
249
- if (s.length > 0) {
250
- try {
251
- c = new le(JSON.parse(s));
252
- } catch {
253
- throw new Error("Invalid config JSON content: " + s);
204
+ throw new Error("Number of values is fewer than expected.");
205
+ r[i] = n++;
206
+ }
207
+ var o = r[0], s = e.substring(0, o), a = parseInt(s);
208
+ if (isNaN(a))
209
+ throw new Error("Invalid fetch time: " + s);
210
+ n = o + 1, o = r[1], s = e.substring(n, o);
211
+ var c = s.length > 0 ? s : void 0;
212
+ n = o + 1, s = e.substring(n);
213
+ var u, l;
214
+ if (s.length > 0) {
215
+ try {
216
+ u = new de(JSON.parse(s));
217
+ } catch {
218
+ throw new Error("Invalid config JSON content: " + s);
219
+ }
220
+ l = s;
254
221
  }
255
- l = s;
222
+ return new t(l, u, a, c);
223
+ }, t.serializationFormatVersion = "v2", t.empty = new t(void 0, void 0, 0, void 0), t;
224
+ }()
225
+ ), de = (
226
+ /** @class */
227
+ function() {
228
+ function t(e) {
229
+ this.settings = e.f ? Object.fromEntries(Object.entries(e.f).map(function(r) {
230
+ var n = r[0], i = r[1];
231
+ return [n, new _e(i)];
232
+ })) : {}, this.preferences = e.p ? new Ye(e.p) : void 0;
256
233
  }
257
- return new t(l, c, a, u);
258
- }, t.serializationFormatVersion = "v2", t.empty = new t(void 0, void 0, 0, void 0), t;
259
- }(), le = function() {
260
- function t(e) {
261
- this.settings = e.f ? Object.fromEntries(Object.entries(e.f).map(function(r) {
262
- var n = r[0], i = r[1];
263
- return [n, new Qe(i)];
264
- })) : {}, this.preferences = e.p ? new Ze(e.p) : void 0;
265
- }
266
- return t;
267
- }(), J;
234
+ return t;
235
+ }()
236
+ ), X;
268
237
  (function(t) {
269
238
  t[t.No = 0] = "No", t[t.Should = 1] = "Should", t[t.Force = 2] = "Force";
270
- })(J || (J = {}));
271
- var Ze = function() {
272
- function t(e) {
273
- this.baseUrl = e.u, this.redirectMode = e.r;
274
- }
275
- return t;
276
- }(), ye;
239
+ })(X || (X = {}));
240
+ var Ye = (
241
+ /** @class */
242
+ function() {
243
+ function t(e) {
244
+ this.baseUrl = e.u, this.redirectMode = e.r;
245
+ }
246
+ return t;
247
+ }()
248
+ ), Se;
277
249
  (function(t) {
278
250
  t[t.Boolean = 0] = "Boolean", t[t.String = 1] = "String", t[t.Int = 2] = "Int", t[t.Double = 3] = "Double";
279
- })(ye || (ye = {}));
280
- var Qe = function() {
281
- function t(e) {
282
- var r, n, i, o;
283
- this.value = e.v, this.type = e.t, this.percentageOptions = (n = (r = e.p) === null || r === void 0 ? void 0 : r.map(function(s) {
284
- return new tt(s);
285
- })) !== null && n !== void 0 ? n : [], this.targetingRules = (o = (i = e.r) === null || i === void 0 ? void 0 : i.map(function(s) {
286
- return new et(s);
287
- })) !== null && o !== void 0 ? o : [], this.variationId = e.i;
288
- }
289
- return t.fromValue = function(e) {
290
- return new t({
291
- t: -1,
292
- v: e
293
- });
294
- }, t;
295
- }(), h;
251
+ })(Se || (Se = {}));
252
+ var _e = (
253
+ /** @class */
254
+ function() {
255
+ function t(e) {
256
+ var r, n, i, o;
257
+ this.value = e.v, this.type = e.t, this.percentageOptions = (n = (r = e.p) === null || r === void 0 ? void 0 : r.map(function(s) {
258
+ return new Ze(s);
259
+ })) !== null && n !== void 0 ? n : [], this.targetingRules = (o = (i = e.r) === null || i === void 0 ? void 0 : i.map(function(s) {
260
+ return new Xe(s);
261
+ })) !== null && o !== void 0 ? o : [], this.variationId = e.i;
262
+ }
263
+ return t.fromValue = function(e) {
264
+ return new t({
265
+ t: -1,
266
+ v: e
267
+ });
268
+ }, t;
269
+ }()
270
+ ), g;
296
271
  (function(t) {
297
272
  t[t.In = 0] = "In", t[t.NotIn = 1] = "NotIn", t[t.Contains = 2] = "Contains", t[t.NotContains = 3] = "NotContains", t[t.SemVerIn = 4] = "SemVerIn", t[t.SemVerNotIn = 5] = "SemVerNotIn", t[t.SemVerLessThan = 6] = "SemVerLessThan", t[t.SemVerLessThanEqual = 7] = "SemVerLessThanEqual", t[t.SemVerGreaterThan = 8] = "SemVerGreaterThan", t[t.SemVerGreaterThanEqual = 9] = "SemVerGreaterThanEqual", t[t.NumberEqual = 10] = "NumberEqual", t[t.NumberNotEqual = 11] = "NumberNotEqual", t[t.NumberLessThan = 12] = "NumberLessThan", t[t.NumberLessThanEqual = 13] = "NumberLessThanEqual", t[t.NumberGreaterThan = 14] = "NumberGreaterThan", t[t.NumberGreaterThanEqual = 15] = "NumberGreaterThanEqual", t[t.SensitiveOneOf = 16] = "SensitiveOneOf", t[t.SensitiveNotOneOf = 17] = "SensitiveNotOneOf";
298
- })(h || (h = {}));
299
- var et = function() {
300
- function t(e) {
301
- this.order = e.o, this.comparisonAttribute = e.a, this.comparator = e.t, this.comparisonValue = e.c, this.value = e.v, this.variationId = e.i;
302
- }
303
- return t;
304
- }(), tt = function() {
305
- function t(e) {
306
- this.order = e.o, this.percentage = e.p, this.value = e.v, this.variationId = e.i;
307
- }
308
- return t;
309
- }(), ne = function() {
310
- function t(e, r) {
311
- this.errorMessage = e, this.errorException = r;
312
- }
313
- return Object.defineProperty(t.prototype, "isSuccess", {
314
- get: function() {
315
- return this.errorMessage === null;
316
- },
317
- enumerable: !1,
318
- configurable: !0
319
- }), t.from = function(e) {
320
- return e.status !== K.Errored ? t.success() : t.failure(e.errorMessage, e.errorException);
321
- }, t.success = function() {
322
- return new t(null);
323
- }, t.failure = function(e, r) {
324
- return new t(e, r);
325
- }, t;
326
- }(), I;
273
+ })(g || (g = {}));
274
+ var Xe = (
275
+ /** @class */
276
+ function() {
277
+ function t(e) {
278
+ this.order = e.o, this.comparisonAttribute = e.a, this.comparator = e.t, this.comparisonValue = e.c, this.value = e.v, this.variationId = e.i;
279
+ }
280
+ return t;
281
+ }()
282
+ ), Ze = (
283
+ /** @class */
284
+ function() {
285
+ function t(e) {
286
+ this.order = e.o, this.percentage = e.p, this.value = e.v, this.variationId = e.i;
287
+ }
288
+ return t;
289
+ }()
290
+ ), ae = (
291
+ /** @class */
292
+ function() {
293
+ function t(e, r) {
294
+ this.errorMessage = e, this.errorException = r;
295
+ }
296
+ return Object.defineProperty(t.prototype, "isSuccess", {
297
+ /** Indicates whether the operation was successful or not. */
298
+ get: function() {
299
+ return this.errorMessage === null;
300
+ },
301
+ enumerable: !1,
302
+ configurable: !0
303
+ }), t.from = function(e) {
304
+ return e.status !== K.Errored ? t.success() : t.failure(e.errorMessage, e.errorException);
305
+ }, t.success = function() {
306
+ return new t(null);
307
+ }, t.failure = function(e, r) {
308
+ return new t(e, r);
309
+ }, t;
310
+ }()
311
+ ), T;
312
+ (function(t) {
313
+ t[t.NoFlagData = 0] = "NoFlagData", t[t.HasLocalOverrideFlagDataOnly = 1] = "HasLocalOverrideFlagDataOnly", t[t.HasCachedFlagDataOnly = 2] = "HasCachedFlagDataOnly", t[t.HasUpToDateFlagData = 3] = "HasUpToDateFlagData";
314
+ })(T || (T = {}));
315
+ var I;
327
316
  (function(t) {
328
317
  t[t.Online = 0] = "Online", t[t.Offline = 1] = "Offline", t[t.Disposed = 2] = "Disposed";
329
318
  })(I || (I = {}));
330
- var ge = function() {
331
- function t(e, r) {
332
- this.configFetcher = e, this.options = r, this.pendingFetch = null, this.cacheKey = r.getCacheKey(), this.configFetcher = e, this.options = r, this.status = r.offline ? I.Offline : I.Online;
333
- }
334
- return t.prototype.dispose = function() {
335
- this.status = I.Disposed;
336
- }, Object.defineProperty(t.prototype, "disposed", {
337
- get: function() {
338
- return this.status === I.Disposed;
339
- },
340
- enumerable: !1,
341
- configurable: !0
342
- }), t.prototype.refreshConfigAsync = function() {
343
- return S(this, void 0, void 0, function() {
344
- var e, r, n, i, o;
345
- return O(this, function(s) {
346
- switch (s.label) {
347
- case 0:
348
- return [4, this.options.cache.get(this.cacheKey)];
349
- case 1:
350
- return e = s.sent(), this.isOffline ? [3, 3] : [4, this.refreshConfigCoreAsync(e)];
351
- case 2:
352
- return r = s.sent(), n = r[0], i = r[1], [2, [ne.from(n), i]];
353
- case 3:
354
- return o = this.options.logger.configServiceCannotInitiateHttpCalls().toString(), [2, [ne.failure(o), e]];
355
- }
356
- });
357
- });
358
- }, t.prototype.refreshConfigCoreAsync = function(e) {
359
- return S(this, void 0, void 0, function() {
360
- var r, n;
361
- return O(this, function(i) {
362
- switch (i.label) {
363
- case 0:
364
- return [4, this.fetchAsync(e)];
365
- case 1:
366
- return r = i.sent(), n = r.status === K.Fetched, n || r.config.timestamp > e.timestamp && (!r.config.isEmpty || e.isEmpty) ? [4, this.options.cache.set(this.cacheKey, r.config)] : [3, 3];
367
- case 2:
368
- i.sent(), this.onConfigUpdated(r.config), n && (r.config.httpETag != e.httpETag || r.config.configJson != e.configJson) && this.onConfigChanged(r.config), e = r.config, i.label = 3;
369
- case 3:
370
- return [2, [r, e]];
371
- }
319
+ var me = (
320
+ /** @class */
321
+ function() {
322
+ function t(e, r) {
323
+ this.configFetcher = e, this.options = r, this.pendingFetch = null, this.cacheKey = r.getCacheKey(), this.configFetcher = e, this.options = r, this.status = r.offline ? I.Offline : I.Online;
324
+ }
325
+ return t.prototype.dispose = function() {
326
+ this.status = I.Disposed;
327
+ }, Object.defineProperty(t.prototype, "disposed", {
328
+ get: function() {
329
+ return this.status === I.Disposed;
330
+ },
331
+ enumerable: !1,
332
+ configurable: !0
333
+ }), t.prototype.refreshConfigAsync = function() {
334
+ return S(this, void 0, void 0, function() {
335
+ var e, r, n, i, o;
336
+ return O(this, function(s) {
337
+ switch (s.label) {
338
+ case 0:
339
+ return [4, this.options.cache.get(this.cacheKey)];
340
+ case 1:
341
+ return e = s.sent(), this.isOffline ? [3, 3] : [4, this.refreshConfigCoreAsync(e)];
342
+ case 2:
343
+ return r = s.sent(), n = r[0], i = r[1], [2, [ae.from(n), i]];
344
+ case 3:
345
+ return o = this.options.logger.configServiceCannotInitiateHttpCalls().toString(), [2, [ae.failure(o), e]];
346
+ }
347
+ });
372
348
  });
373
- });
374
- }, t.prototype.onConfigUpdated = function(e) {
375
- }, t.prototype.onConfigChanged = function(e) {
376
- var r;
377
- this.options.logger.debug("config changed"), this.options.hooks.emit("configChanged", (r = e.config) !== null && r !== void 0 ? r : new le({}));
378
- }, t.prototype.fetchAsync = function(e) {
379
- var r = this, n;
380
- return (n = this.pendingFetch) !== null && n !== void 0 ? n : this.pendingFetch = function() {
381
- return S(r, void 0, void 0, function() {
349
+ }, t.prototype.refreshConfigCoreAsync = function(e) {
350
+ return S(this, void 0, void 0, function() {
351
+ var r, n;
382
352
  return O(this, function(i) {
383
353
  switch (i.label) {
384
354
  case 0:
385
- return i.trys.push([0, , 2, 3]), [4, this.fetchLogicAsync(e)];
355
+ return [4, this.fetchAsync(e)];
386
356
  case 1:
387
- return [2, i.sent()];
357
+ return r = i.sent(), n = r.status === K.Fetched, n || r.config.timestamp > e.timestamp && (!r.config.isEmpty || e.isEmpty) ? [4, this.options.cache.set(this.cacheKey, r.config)] : [3, 3];
388
358
  case 2:
389
- return this.pendingFetch = null, [7];
359
+ i.sent(), this.onConfigUpdated(r.config), n && !M.equals(r.config, e) && this.onConfigChanged(r.config), e = r.config, i.label = 3;
390
360
  case 3:
391
- return [2];
361
+ return [2, [r, e]];
392
362
  }
393
363
  });
394
364
  });
395
- }();
396
- }, t.prototype.fetchLogicAsync = function(e) {
397
- var r;
398
- return S(this, void 0, void 0, function() {
399
- var n, i, o, s, a, u;
400
- return O(this, function(c) {
401
- switch (c.label) {
402
- case 0:
403
- n = this.options, n.logger.debug("ConfigServiceBase.fetchLogicAsync() - called."), c.label = 1;
404
- case 1:
405
- return c.trys.push([1, 3, , 4]), [4, this.fetchRequestAsync((r = e.httpETag) !== null && r !== void 0 ? r : null)];
406
- case 2:
407
- switch (o = c.sent(), s = o[0], a = o[1], s.statusCode) {
408
- case 200:
409
- return a ? (n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was successful. Returning new config."), [2, x.success(new P(s.body, a, P.generateTimestamp(), s.eTag))]) : (i = n.logger.fetchReceived200WithInvalidBody().toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): ".concat(s.statusCode, " ").concat(s.reasonPhrase, " was received but the HTTP response content was invalid. Returning null.")), [2, x.error(e, i)]);
410
- case 304:
411
- return e ? (n.logger.debug("ConfigServiceBase.fetchLogicAsync(): content was not modified. Returning last config with updated timestamp."), [2, x.notModified(e.with(P.generateTimestamp()))]) : (i = n.logger.fetchReceived304WhenLocalCacheIsEmpty(s.statusCode, s.reasonPhrase).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): ".concat(s.statusCode, " ").concat(s.reasonPhrase, " was received when no config is cached locally. Returning null.")), [2, x.error(e, i)]);
412
- case 403:
413
- case 404:
414
- return i = n.logger.fetchFailedDueToInvalidSdkKey().toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."), [2, x.error(e.with(P.generateTimestamp()), i)];
415
- default:
416
- return i = n.logger.fetchFailedDueToUnexpectedHttpResponse(s.statusCode, s.reasonPhrase).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."), [2, x.error(e, i)];
365
+ }, t.prototype.onConfigUpdated = function(e) {
366
+ }, t.prototype.onConfigChanged = function(e) {
367
+ var r;
368
+ this.options.logger.debug("config changed"), this.options.hooks.emit("configChanged", (r = e.config) !== null && r !== void 0 ? r : new de({}));
369
+ }, t.prototype.fetchAsync = function(e) {
370
+ var r = this, n;
371
+ return (n = this.pendingFetch) !== null && n !== void 0 ? n : this.pendingFetch = function() {
372
+ return S(r, void 0, void 0, function() {
373
+ return O(this, function(i) {
374
+ switch (i.label) {
375
+ case 0:
376
+ return i.trys.push([0, , 2, 3]), [4, this.fetchLogicAsync(e)];
377
+ case 1:
378
+ return [2, i.sent()];
379
+ case 2:
380
+ return this.pendingFetch = null, [
381
+ 7
382
+ /*endfinally*/
383
+ ];
384
+ case 3:
385
+ return [
386
+ 2
387
+ /*return*/
388
+ ];
417
389
  }
418
- return [3, 4];
419
- case 3:
420
- return u = c.sent(), i = (u instanceof ee && u.cause === "timeout" ? n.logger.fetchFailedDueToRequestTimeout(u.args[0], u) : n.logger.fetchFailedDueToUnexpectedError(u)).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."), [2, x.error(e, i, u)];
421
- case 4:
422
- return [2];
423
- }
390
+ });
391
+ });
392
+ }();
393
+ }, t.prototype.fetchLogicAsync = function(e) {
394
+ var r;
395
+ return S(this, void 0, void 0, function() {
396
+ var n, i, o, s, a, c;
397
+ return O(this, function(u) {
398
+ switch (u.label) {
399
+ case 0:
400
+ n = this.options, n.logger.debug("ConfigServiceBase.fetchLogicAsync() - called."), u.label = 1;
401
+ case 1:
402
+ return u.trys.push([1, 3, , 4]), [4, this.fetchRequestAsync((r = e.httpETag) !== null && r !== void 0 ? r : null)];
403
+ case 2:
404
+ switch (o = u.sent(), s = o[0], a = o[1], s.statusCode) {
405
+ case 200:
406
+ return a ? (n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was successful. Returning new config."), [2, q.success(new M(s.body, a, M.generateTimestamp(), s.eTag))]) : (i = n.logger.fetchReceived200WithInvalidBody().toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): " + s.statusCode + " " + s.reasonPhrase + " was received but the HTTP response content was invalid. Returning null."), [2, q.error(e, i)]);
407
+ case 304:
408
+ return e ? (n.logger.debug("ConfigServiceBase.fetchLogicAsync(): content was not modified. Returning last config with updated timestamp."), [2, q.notModified(e.with(M.generateTimestamp()))]) : (i = n.logger.fetchReceived304WhenLocalCacheIsEmpty(s.statusCode, s.reasonPhrase).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): " + s.statusCode + " " + s.reasonPhrase + " was received when no config is cached locally. Returning null."), [2, q.error(e, i)]);
409
+ case 403:
410
+ case 404:
411
+ return i = n.logger.fetchFailedDueToInvalidSdkKey().toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."), [2, q.error(e.with(M.generateTimestamp()), i)];
412
+ default:
413
+ return i = n.logger.fetchFailedDueToUnexpectedHttpResponse(s.statusCode, s.reasonPhrase).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."), [2, q.error(e, i)];
414
+ }
415
+ return [3, 4];
416
+ case 3:
417
+ return c = u.sent(), i = (c instanceof ie && c.cause === "timeout" ? n.logger.fetchFailedDueToRequestTimeout(c.args[0], c) : n.logger.fetchFailedDueToUnexpectedError(c)).toString(), n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."), [2, q.error(e, i, c)];
418
+ case 4:
419
+ return [
420
+ 2
421
+ /*return*/
422
+ ];
423
+ }
424
+ });
424
425
  });
425
- });
426
- }, t.prototype.fetchRequestAsync = function(e, r) {
427
- return r === void 0 && (r = 2), S(this, void 0, void 0, function() {
428
- var n, i, o, s, a, u, c;
429
- return O(this, function(l) {
430
- switch (l.label) {
431
- case 0:
432
- n = this.options, n.logger.debug("ConfigServiceBase.fetchRequestAsync() - called."), i = 0, l.label = 1;
433
- case 1:
434
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()".concat(i > 0 ? ", retry ".concat(i, "/").concat(r) : "")), [4, this.configFetcher.fetchLogic(n, e)];
435
- case 2:
436
- if (o = l.sent(), o.statusCode !== 200)
437
- return [2, [o]];
438
- if (!o.body)
439
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."), [2, [o]];
440
- s = void 0;
441
- try {
442
- s = new le(JSON.parse(o.body));
443
- } catch {
444
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."), [2, [o]];
445
- }
446
- if (a = s.preferences, !a)
447
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences is empty."), [2, [o, s]];
448
- if (u = a.baseUrl, !u || u === n.baseUrl)
449
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."), [2, [o, s]];
450
- if (c = a.redirectMode, n.baseUrlOverriden && c !== J.Force)
451
- return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."), [2, [o, s]];
452
- if (n.baseUrl = u, c === J.No)
453
- return [2, [o, s]];
454
- if (c === J.Should && n.logger.dataGovernanceIsOutOfSync(), i >= r)
455
- return n.logger.fetchFailedDueToRedirectLoop(), [2, [o, s]];
456
- l.label = 3;
457
- case 3:
458
- return i++, [3, 1];
459
- case 4:
460
- return [2];
461
- }
426
+ }, t.prototype.fetchRequestAsync = function(e, r) {
427
+ return r === void 0 && (r = 2), S(this, void 0, void 0, function() {
428
+ var n, i, o, s, a, c, u;
429
+ return O(this, function(l) {
430
+ switch (l.label) {
431
+ case 0:
432
+ n = this.options, n.logger.debug("ConfigServiceBase.fetchRequestAsync() - called."), i = 0, l.label = 1;
433
+ case 1:
434
+ return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()" + (i > 0 ? ", retry " + i + "/" + r : "")), [4, this.configFetcher.fetchLogic(n, e)];
435
+ case 2:
436
+ if (o = l.sent(), o.statusCode !== 200)
437
+ return [2, [o]];
438
+ if (!o.body)
439
+ return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."), [2, [o]];
440
+ s = void 0;
441
+ try {
442
+ s = new de(JSON.parse(o.body));
443
+ } catch {
444
+ return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."), [2, [o]];
445
+ }
446
+ if (a = s.preferences, !a)
447
+ return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences is empty."), [2, [o, s]];
448
+ if (c = a.baseUrl, !c || c === n.baseUrl)
449
+ return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."), [2, [o, s]];
450
+ if (u = a.redirectMode, n.baseUrlOverriden && u !== X.Force)
451
+ return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."), [2, [o, s]];
452
+ if (n.baseUrl = c, u === X.No)
453
+ return [2, [o, s]];
454
+ if (u === X.Should && n.logger.dataGovernanceIsOutOfSync(), i >= r)
455
+ return n.logger.fetchFailedDueToRedirectLoop(), [2, [o, s]];
456
+ l.label = 3;
457
+ case 3:
458
+ return i++, [3, 1];
459
+ case 4:
460
+ return [
461
+ 2
462
+ /*return*/
463
+ ];
464
+ }
465
+ });
462
466
  });
463
- });
464
- }, Object.defineProperty(t.prototype, "isOfflineExactly", {
465
- get: function() {
466
- return this.status === I.Offline;
467
- },
468
- enumerable: !1,
469
- configurable: !0
470
- }), Object.defineProperty(t.prototype, "isOffline", {
471
- get: function() {
472
- return this.status !== I.Online;
473
- },
474
- enumerable: !1,
475
- configurable: !0
476
- }), t.prototype.setOnlineCore = function() {
477
- }, t.prototype.setOnline = function() {
478
- this.status === I.Offline ? (this.setOnlineCore(), this.status = I.Online, this.options.logger.configServiceStatusChanged(I[this.status])) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline");
479
- }, t.prototype.setOfflineCore = function() {
480
- }, t.prototype.setOffline = function() {
481
- this.status === I.Online ? (this.setOfflineCore(), this.status = I.Offline, this.options.logger.configServiceStatusChanged(I[this.status])) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline");
482
- }, t;
483
- }();
484
- function rt(t, e) {
467
+ }, Object.defineProperty(t.prototype, "isOfflineExactly", {
468
+ get: function() {
469
+ return this.status === I.Offline;
470
+ },
471
+ enumerable: !1,
472
+ configurable: !0
473
+ }), Object.defineProperty(t.prototype, "isOffline", {
474
+ get: function() {
475
+ return this.status !== I.Online;
476
+ },
477
+ enumerable: !1,
478
+ configurable: !0
479
+ }), t.prototype.setOnlineCore = function() {
480
+ }, t.prototype.setOnline = function() {
481
+ this.status === I.Offline ? (this.setOnlineCore(), this.status = I.Online, this.options.logger.configServiceStatusChanged(I[this.status])) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline");
482
+ }, t.prototype.setOfflineCore = function() {
483
+ }, t.prototype.setOffline = function() {
484
+ this.status === I.Online ? (this.setOfflineCore(), this.status = I.Offline, this.options.logger.configServiceStatusChanged(I[this.status])) : this.disposed && this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline");
485
+ }, t.prototype.onCacheSynced = function(e) {
486
+ this.options.hooks.emit("clientReady", this.getCacheState(e));
487
+ }, t.prototype.syncUpWithCache = function() {
488
+ return S(this, void 0, void 0, function() {
489
+ var e;
490
+ return O(this, function(r) {
491
+ switch (r.label) {
492
+ case 0:
493
+ return [4, this.options.cache.get(this.cacheKey)];
494
+ case 1:
495
+ return e = r.sent(), this.onCacheSynced(e), [2, e];
496
+ }
497
+ });
498
+ });
499
+ }, t;
500
+ }()
501
+ );
502
+ function Qe(t, e) {
485
503
  var r, n = new Promise(function(i) {
486
504
  return r = setTimeout(i, t);
487
505
  });
488
- return e == null || e(function() {
506
+ return e && (e.clearTimer = function() {
489
507
  return clearTimeout(r);
490
508
  }), n;
491
509
  }
492
- function $(t, e) {
510
+ function _(t, e) {
493
511
  return e === void 0 && (e = !1), t instanceof Error ? e && t.stack ? t.stack : t.toString() : t + "";
494
512
  }
495
- var nt = function(t) {
496
- z(e, t);
497
- function e(r, n) {
498
- var i = t.call(this, r, n) || this;
499
- return i.signalInitialization = function() {
500
- }, i.pollIntervalMs = n.pollIntervalSeconds * 1e3, n.maxInitWaitTimeSeconds !== 0 ? (i.initialized = !1, i.initialization = new Promise(function(o) {
501
- return i.signalInitialization = function() {
502
- i.initialized = !0, o();
503
- };
504
- }), i.initialization.then(function() {
505
- return !i.disposed && n.hooks.emit("clientReady");
506
- }), n.maxInitWaitTimeSeconds > 0 && setTimeout(function() {
507
- return i.signalInitialization();
508
- }, n.maxInitWaitTimeSeconds * 1e3)) : (i.initialized = !0, i.initialization = Promise.resolve(), n.hooks.emit("clientReady")), n.offline || i.startRefreshWorker(), i;
509
- }
510
- return e.prototype.waitForInitializationAsync = function() {
511
- return S(this, void 0, void 0, function() {
512
- var r, n, i = this;
513
- return O(this, function(o) {
514
- switch (o.label) {
515
- case 0:
516
- return this.options.maxInitWaitTimeSeconds < 0 ? [4, this.initialization] : [3, 2];
517
- case 1:
518
- return o.sent(), [2, !0];
519
- case 2:
520
- return [4, Promise.race([
521
- function() {
522
- return S(i, void 0, void 0, function() {
523
- return O(this, function(s) {
524
- switch (s.label) {
525
- case 0:
526
- return [4, this.initialization];
527
- case 1:
528
- return s.sent(), [2, !0];
529
- }
530
- });
531
- });
532
- }(),
533
- rt(this.options.maxInitWaitTimeSeconds * 1e3, function(s) {
534
- return r = s;
535
- })
536
- ])];
537
- case 3:
538
- return n = o.sent(), r(), [2, !!n];
539
- }
513
+ function et(t) {
514
+ var e;
515
+ return typeof ((e = t) === null || e === void 0 ? void 0 : e.then) == "function";
516
+ }
517
+ var tt = (
518
+ /** @class */
519
+ function(t) {
520
+ B(e, t);
521
+ function e(r, n) {
522
+ var i = t.call(this, r, n) || this;
523
+ i.signalInitialization = function() {
524
+ }, i.pollIntervalMs = n.pollIntervalSeconds * 1e3;
525
+ var o = t.prototype.syncUpWithCache.call(i);
526
+ return n.maxInitWaitTimeSeconds !== 0 ? (i.initialized = !1, i.initialization = new Promise(function(s) {
527
+ return i.signalInitialization = function() {
528
+ i.initialized = !0, clearTimeout(i.initTimerId), s();
529
+ };
530
+ }), i.initialization.then(function() {
531
+ return t.prototype.onCacheSynced.call(i, n.cache.getInMemory());
532
+ }), n.maxInitWaitTimeSeconds > 0 && (i.initTimerId = setTimeout(function() {
533
+ return i.signalInitialization();
534
+ }, n.maxInitWaitTimeSeconds * 1e3))) : (i.initialized = !0, i.initialization = Promise.resolve(), o.then(function(s) {
535
+ return t.prototype.onCacheSynced.call(i, s);
536
+ })), n.offline || i.startRefreshWorker(o), i;
537
+ }
538
+ return e.prototype.onCacheSynced = function() {
539
+ }, e.prototype.waitForInitializationAsync = function() {
540
+ return S(this, void 0, void 0, function() {
541
+ var r, n;
542
+ return O(this, function(i) {
543
+ switch (i.label) {
544
+ case 0:
545
+ return this.options.maxInitWaitTimeSeconds < 0 ? [4, this.initialization] : [3, 2];
546
+ case 1:
547
+ return i.sent(), [2, !0];
548
+ case 2:
549
+ return r = {}, [4, Promise.race([
550
+ this.initialization.then(function() {
551
+ return !0;
552
+ }),
553
+ Qe(this.options.maxInitWaitTimeSeconds * 1e3, r).then(function() {
554
+ return !1;
555
+ })
556
+ ])];
557
+ case 3:
558
+ return n = i.sent(), r.clearTimer(), [2, n];
559
+ }
560
+ });
540
561
  });
541
- });
542
- }, e.prototype.getConfig = function() {
543
- return S(this, void 0, void 0, function() {
544
- function r(i) {
545
- i.debug("AutoPollConfigService.getConfig() - returning value from cache.");
546
- }
547
- var n;
548
- return O(this, function(i) {
549
- switch (i.label) {
550
- case 0:
551
- return this.options.logger.debug("AutoPollConfigService.getConfig() called."), !this.isOffline && !this.initialized ? [4, this.options.cache.get(this.cacheKey)] : [3, 3];
552
- case 1:
553
- return n = i.sent(), n.isExpired(this.pollIntervalMs) ? (this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired, waiting for initialization."), [4, this.waitForInitializationAsync()]) : (r(this.options.logger), [2, n]);
554
- case 2:
555
- i.sent(), i.label = 3;
556
- case 3:
557
- return [4, this.options.cache.get(this.cacheKey)];
558
- case 4:
559
- return n = i.sent(), n.isExpired(this.pollIntervalMs) ? this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired.") : r(this.options.logger), [2, n];
562
+ }, e.prototype.getConfig = function() {
563
+ return S(this, void 0, void 0, function() {
564
+ function r(i) {
565
+ i.debug("AutoPollConfigService.getConfig() - returning value from cache.");
560
566
  }
567
+ var n;
568
+ return O(this, function(i) {
569
+ switch (i.label) {
570
+ case 0:
571
+ return this.options.logger.debug("AutoPollConfigService.getConfig() called."), !this.isOffline && !this.initialized ? [4, this.options.cache.get(this.cacheKey)] : [3, 3];
572
+ case 1:
573
+ return n = i.sent(), n.isExpired(this.pollIntervalMs) ? (this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired, waiting for initialization."), [4, this.waitForInitializationAsync()]) : (r(this.options.logger), [2, n]);
574
+ case 2:
575
+ i.sent(), i.label = 3;
576
+ case 3:
577
+ return [4, this.options.cache.get(this.cacheKey)];
578
+ case 4:
579
+ return n = i.sent(), n.isExpired(this.pollIntervalMs) ? this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired.") : r(this.options.logger), [2, n];
580
+ }
581
+ });
561
582
  });
562
- });
563
- }, e.prototype.refreshConfigAsync = function() {
564
- return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."), t.prototype.refreshConfigAsync.call(this);
565
- }, e.prototype.dispose = function() {
566
- this.options.logger.debug("AutoPollConfigService.dispose() called."), t.prototype.dispose.call(this), this.timerId && this.stopRefreshWorker();
567
- }, e.prototype.onConfigUpdated = function(r) {
568
- t.prototype.onConfigUpdated.call(this, r), this.signalInitialization();
569
- }, e.prototype.setOnlineCore = function() {
570
- this.startRefreshWorker();
571
- }, e.prototype.setOfflineCore = function() {
572
- this.stopRefreshWorker();
573
- }, e.prototype.startRefreshWorker = function() {
574
- return S(this, void 0, void 0, function() {
575
- var r, n, i = this;
576
- return O(this, function(o) {
577
- switch (o.label) {
578
- case 0:
579
- return this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called."), r = this.pollIntervalMs, [4, this.options.cache.get(this.cacheKey)];
580
- case 1:
581
- return n = o.sent(), n.isExpired(this.pollIntervalMs) ? this.isOfflineExactly ? [3, 3] : [4, this.refreshConfigCoreAsync(n)] : [3, 4];
582
- case 2:
583
- o.sent(), o.label = 3;
584
- case 3:
585
- return [3, 5];
586
- case 4:
587
- this.signalInitialization(), o.label = 5;
588
- case 5:
589
- return this.options.logger.debug("AutoPollConfigService.startRefreshWorker() - calling refreshWorkerLogic()'s setTimeout."), this.timerId = setTimeout(function(s) {
590
- return i.refreshWorkerLogic(s);
591
- }, r, r), [2];
592
- }
583
+ }, e.prototype.refreshConfigAsync = function() {
584
+ return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."), t.prototype.refreshConfigAsync.call(this);
585
+ }, e.prototype.dispose = function() {
586
+ this.options.logger.debug("AutoPollConfigService.dispose() called."), t.prototype.dispose.call(this), this.workerTimerId && this.stopRefreshWorker();
587
+ }, e.prototype.onConfigUpdated = function(r) {
588
+ t.prototype.onConfigUpdated.call(this, r), this.signalInitialization();
589
+ }, e.prototype.setOnlineCore = function() {
590
+ this.startRefreshWorker();
591
+ }, e.prototype.setOfflineCore = function() {
592
+ this.stopRefreshWorker();
593
+ }, e.prototype.startRefreshWorker = function(r) {
594
+ return S(this, void 0, void 0, function() {
595
+ var n, i, o = this;
596
+ return O(this, function(s) {
597
+ switch (s.label) {
598
+ case 0:
599
+ return this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called."), n = this.pollIntervalMs, [4, r ?? this.options.cache.get(this.cacheKey)];
600
+ case 1:
601
+ return i = s.sent(), i.isExpired(this.pollIntervalMs) ? this.isOfflineExactly ? [3, 3] : [4, this.refreshConfigCoreAsync(i)] : [3, 4];
602
+ case 2:
603
+ s.sent(), s.label = 3;
604
+ case 3:
605
+ return [3, 5];
606
+ case 4:
607
+ this.signalInitialization(), s.label = 5;
608
+ case 5:
609
+ return this.options.logger.debug("AutoPollConfigService.startRefreshWorker() - calling refreshWorkerLogic()'s setTimeout."), this.workerTimerId = setTimeout(function(a) {
610
+ return o.refreshWorkerLogic(a);
611
+ }, n, n), [
612
+ 2
613
+ /*return*/
614
+ ];
615
+ }
616
+ });
593
617
  });
594
- });
595
- }, e.prototype.stopRefreshWorker = function() {
596
- this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() - clearing setTimeout."), clearTimeout(this.timerId);
597
- }, e.prototype.refreshWorkerLogic = function(r) {
598
- return S(this, void 0, void 0, function() {
599
- var n, i = this;
600
- return O(this, function(o) {
601
- switch (o.label) {
602
- case 0:
603
- return this.disposed ? (this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called on a disposed client."), [2]) : (this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called."), this.isOffline ? [3, 3] : [4, this.options.cache.get(this.cacheKey)]);
604
- case 1:
605
- return n = o.sent(), [4, this.refreshConfigCoreAsync(n)];
606
- case 2:
607
- o.sent(), o.label = 3;
608
- case 3:
609
- return this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - calling refreshWorkerLogic()'s setTimeout."), this.timerId = setTimeout(function(s) {
610
- return i.refreshWorkerLogic(s);
611
- }, r, r), [2];
612
- }
618
+ }, e.prototype.stopRefreshWorker = function() {
619
+ this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() - clearing setTimeout."), clearTimeout(this.workerTimerId);
620
+ }, e.prototype.refreshWorkerLogic = function(r) {
621
+ return S(this, void 0, void 0, function() {
622
+ var n, i = this;
623
+ return O(this, function(o) {
624
+ switch (o.label) {
625
+ case 0:
626
+ return this.disposed ? (this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called on a disposed client."), [
627
+ 2
628
+ /*return*/
629
+ ]) : (this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called."), this.isOffline ? [3, 3] : [4, this.options.cache.get(this.cacheKey)]);
630
+ case 1:
631
+ return n = o.sent(), [4, this.refreshConfigCoreAsync(n)];
632
+ case 2:
633
+ o.sent(), o.label = 3;
634
+ case 3:
635
+ return this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - calling refreshWorkerLogic()'s setTimeout."), this.workerTimerId = setTimeout(function(s) {
636
+ return i.refreshWorkerLogic(s);
637
+ }, r, r), [
638
+ 2
639
+ /*return*/
640
+ ];
641
+ }
642
+ });
613
643
  });
614
- });
615
- }, e;
616
- }(ge), it = function() {
617
- function t() {
618
- this.cachedConfig = P.empty;
619
- }
620
- return t.prototype.set = function(e, r) {
621
- this.cachedConfig = r;
622
- }, t.prototype.get = function(e) {
623
- return this.cachedConfig;
624
- }, t;
625
- }(), qe = function() {
626
- function t(e, r) {
627
- this.cache = e, this.logger = r, this.cachedConfig = P.empty;
628
- }
629
- return t.prototype.set = function(e, r) {
630
- return S(this, void 0, void 0, function() {
631
- var n;
632
- return O(this, function(i) {
633
- switch (i.label) {
634
- case 0:
635
- if (i.trys.push([0, 2, , 3]), !r.isEmpty)
636
- this.cachedSerializedConfig = P.serialize(r), this.cachedConfig = r;
637
- else
638
- return this.cachedSerializedConfig = void 0, this.cachedConfig = r, [2];
639
- return [4, this.cache.set(e, this.cachedSerializedConfig)];
640
- case 1:
641
- return i.sent(), [3, 3];
642
- case 2:
643
- return n = i.sent(), this.logger.configServiceCacheWriteError(n), [3, 3];
644
- case 3:
645
- return [2];
644
+ }, e.prototype.getCacheState = function(r) {
645
+ return r.isEmpty ? T.NoFlagData : r.isExpired(this.pollIntervalMs) ? T.HasCachedFlagDataOnly : T.HasUpToDateFlagData;
646
+ }, e;
647
+ }(me)
648
+ ), rt = (
649
+ /** @class */
650
+ function() {
651
+ function t() {
652
+ this.cachedConfig = M.empty;
653
+ }
654
+ return t.prototype.set = function(e, r) {
655
+ this.cachedConfig = r;
656
+ }, t.prototype.get = function(e) {
657
+ return this.cachedConfig;
658
+ }, t.prototype.getInMemory = function() {
659
+ return this.cachedConfig;
660
+ }, t;
661
+ }()
662
+ ), ze = (
663
+ /** @class */
664
+ function() {
665
+ function t(e, r) {
666
+ this.cache = e, this.logger = r, this.cachedConfig = M.empty;
667
+ }
668
+ return t.prototype.set = function(e, r) {
669
+ return S(this, void 0, void 0, function() {
670
+ var n;
671
+ return O(this, function(i) {
672
+ switch (i.label) {
673
+ case 0:
674
+ if (i.trys.push([0, 2, , 3]), !r.isEmpty)
675
+ this.cachedSerializedConfig = M.serialize(r), this.cachedConfig = r;
676
+ else
677
+ return this.cachedSerializedConfig = void 0, this.cachedConfig = r, [
678
+ 2
679
+ /*return*/
680
+ ];
681
+ return [4, this.cache.set(e, this.cachedSerializedConfig)];
682
+ case 1:
683
+ return i.sent(), [3, 3];
684
+ case 2:
685
+ return n = i.sent(), this.logger.configServiceCacheWriteError(n), [3, 3];
686
+ case 3:
687
+ return [
688
+ 2
689
+ /*return*/
690
+ ];
691
+ }
692
+ });
693
+ });
694
+ }, t.prototype.updateCachedConfig = function(e) {
695
+ e == null || e === this.cachedSerializedConfig || (this.cachedConfig = M.deserialize(e), this.cachedSerializedConfig = e);
696
+ }, t.prototype.get = function(e) {
697
+ var r = this;
698
+ try {
699
+ var n = this.cache.get(e);
700
+ if (et(n))
701
+ return function(i) {
702
+ return S(r, void 0, void 0, function() {
703
+ var o, s;
704
+ return O(this, function(a) {
705
+ switch (a.label) {
706
+ case 0:
707
+ return a.trys.push([0, 2, , 3]), o = this.updateCachedConfig, [4, i];
708
+ case 1:
709
+ return o.apply(this, [a.sent()]), [3, 3];
710
+ case 2:
711
+ return s = a.sent(), this.logger.configServiceCacheReadError(s), [3, 3];
712
+ case 3:
713
+ return [2, this.cachedConfig];
714
+ }
715
+ });
716
+ });
717
+ }(n);
718
+ this.updateCachedConfig(n);
719
+ } catch (i) {
720
+ this.logger.configServiceCacheReadError(i);
721
+ }
722
+ return Promise.resolve(this.cachedConfig);
723
+ }, t.prototype.getInMemory = function() {
724
+ return this.cachedConfig;
725
+ }, t;
726
+ }()
727
+ ), v;
728
+ (function(t) {
729
+ t[t.Debug = 4] = "Debug", t[t.Info = 3] = "Info", t[t.Warn = 2] = "Warn", t[t.Error = 1] = "Error", t[t.Off = -1] = "Off";
730
+ })(v || (v = {}));
731
+ var A = (
732
+ /** @class */
733
+ function() {
734
+ function t(e, r, n) {
735
+ this.strings = e, this.argNames = r, this.argValues = n;
736
+ }
737
+ return t.from = function() {
738
+ for (var e = [], r = 0; r < arguments.length; r++)
739
+ e[r] = arguments[r];
740
+ return function(n) {
741
+ for (var i = [], o = 1; o < arguments.length; o++)
742
+ i[o - 1] = arguments[o];
743
+ return new t(n, e, i);
744
+ };
745
+ }, Object.defineProperty(t.prototype, "defaultFormattedMessage", {
746
+ get: function() {
747
+ var e = this.cachedDefaultFormattedMessage;
748
+ if (e === void 0) {
749
+ e = "";
750
+ for (var r = this, n = r.strings, i = r.argValues, o = 0; o < n.length - 1; o++)
751
+ e += n[o], e += i[o];
752
+ e += n[o], this.cachedDefaultFormattedMessage = e;
646
753
  }
754
+ return e;
755
+ },
756
+ enumerable: !1,
757
+ configurable: !0
758
+ }), t.prototype.toString = function() {
759
+ return this.defaultFormattedMessage;
760
+ }, t;
761
+ }()
762
+ ), nt = (
763
+ /** @class */
764
+ function() {
765
+ function t(e, r) {
766
+ this.logger = e, this.hooks = r;
767
+ }
768
+ return Object.defineProperty(t.prototype, "level", {
769
+ get: function() {
770
+ var e;
771
+ return (e = this.logger.level) !== null && e !== void 0 ? e : v.Warn;
772
+ },
773
+ enumerable: !1,
774
+ configurable: !0
775
+ }), t.prototype.isLogLevelEnabled = function(e) {
776
+ return this.level >= e;
777
+ }, t.prototype.log = function(e, r, n, i) {
778
+ var o;
779
+ return this.isLogLevelEnabled(e) && this.logger.log(e, r, n, i), e === v.Error && ((o = this.hooks) === null || o === void 0 || o.emit("clientError", n.toString(), i)), n;
780
+ }, t.prototype.debug = function(e) {
781
+ this.log(v.Debug, 0, e);
782
+ }, t.prototype.configJsonIsNotPresent = function(e) {
783
+ return this.log(v.Error, 1e3, A.from("DEFAULT_RETURN_VALUE")(Oe || (Oe = C(["Config JSON is not present. Returning ", "."], ["Config JSON is not present. Returning ", "."])), e));
784
+ }, t.prototype.configJsonIsNotPresentSingle = function(e, r, n) {
785
+ return this.log(v.Error, 1e3, A.from("KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE")(Ce || (Ce = C(["Config JSON is not present when evaluating setting '", "'. Returning the `", "` parameter that you specified in your application: '", "'."], ["Config JSON is not present when evaluating setting '", "'. Returning the \\`", "\\` parameter that you specified in your application: '", "'."])), e, r, n));
786
+ }, t.prototype.settingEvaluationFailedDueToMissingKey = function(e, r, n, i) {
787
+ return this.log(v.Error, 1001, A.from("KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE", "AVAILABLE_KEYS")(Ae || (Ae = C(["Failed to evaluate setting '", "' (the key was not found in config JSON). Returning the `", "` parameter that you specified in your application: '", "'. Available keys: [", "]."], ["Failed to evaluate setting '", "' (the key was not found in config JSON). Returning the \\`", "\\` parameter that you specified in your application: '", "'. Available keys: [", "]."])), e, r, n, i));
788
+ }, t.prototype.settingEvaluationError = function(e, r, n) {
789
+ return this.log(v.Error, 1002, A.from("METHOD_NAME", "DEFAULT_RETURN_VALUE")(Te || (Te = C(["Error occurred in the `", "` method. Returning ", "."], ["Error occurred in the \\`", "\\` method. Returning ", "."])), e, r), n);
790
+ }, t.prototype.settingEvaluationErrorSingle = function(e, r, n, i, o) {
791
+ return this.log(v.Error, 1002, A.from("METHOD_NAME", "KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE")(we || (we = C(["Error occurred in the `", "` method while evaluating setting '", "'. Returning the `", "` parameter that you specified in your application: '", "'."], ["Error occurred in the \\`", "\\` method while evaluating setting '", "'. Returning the \\`", "\\` parameter that you specified in your application: '", "'."])), e, r, n, i), o);
792
+ }, t.prototype.forceRefreshError = function(e, r) {
793
+ return this.log(v.Error, 1003, A.from("METHOD_NAME")(Ie || (Ie = C(["Error occurred in the `", "` method."], ["Error occurred in the \\`", "\\` method."])), e), r);
794
+ }, t.prototype.fetchFailedDueToInvalidSdkKey = function() {
795
+ return this.log(v.Error, 1100, "Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey");
796
+ }, t.prototype.fetchFailedDueToUnexpectedHttpResponse = function(e, r) {
797
+ return this.log(v.Error, 1101, A.from("STATUS_CODE", "REASON_PHRASE")(Ne || (Ne = C(["Unexpected HTTP response was received while trying to fetch config JSON: ", " ", ""], ["Unexpected HTTP response was received while trying to fetch config JSON: ", " ", ""])), e, r));
798
+ }, t.prototype.fetchFailedDueToRequestTimeout = function(e, r) {
799
+ return this.log(v.Error, 1102, A.from("TIMEOUT")(Le || (Le = C(["Request timed out while trying to fetch config JSON. Timeout value: ", "ms"], ["Request timed out while trying to fetch config JSON. Timeout value: ", "ms"])), e), r);
800
+ }, t.prototype.fetchFailedDueToUnexpectedError = function(e) {
801
+ return this.log(v.Error, 1103, "Unexpected error occurred while trying to fetch config JSON.", e);
802
+ }, t.prototype.fetchFailedDueToRedirectLoop = function() {
803
+ return this.log(v.Error, 1104, "Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/");
804
+ }, t.prototype.fetchReceived200WithInvalidBody = function() {
805
+ return this.log(v.Error, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.");
806
+ }, t.prototype.fetchReceived304WhenLocalCacheIsEmpty = function(e, r) {
807
+ return this.log(v.Error, 1106, A.from("STATUS_CODE", "REASON_PHRASE")(Re || (Re = C(["Unexpected HTTP response was received when no config JSON is cached locally: ", " ", ""], ["Unexpected HTTP response was received when no config JSON is cached locally: ", " ", ""])), e, r));
808
+ }, t.prototype.settingForVariationIdIsNotPresent = function(e) {
809
+ return this.log(v.Error, 2011, A.from("VARIATION_ID")(De || (De = C(["Could not find the setting for the specified variation ID: '", "'."], ["Could not find the setting for the specified variation ID: '", "'."])), e));
810
+ }, t.prototype.configServiceCacheReadError = function(e) {
811
+ return this.log(v.Error, 2200, "Error occurred while reading the cache.", e);
812
+ }, t.prototype.configServiceCacheWriteError = function(e) {
813
+ return this.log(v.Error, 2201, "Error occurred while writing the cache.", e);
814
+ }, t.prototype.clientIsAlreadyCreated = function(e) {
815
+ return this.log(v.Warn, 3e3, A.from("SDK_KEY")(Fe || (Fe = C(["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: '", "'."], ["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));
816
+ }, t.prototype.targetingIsNotPossible = function(e) {
817
+ return this.log(v.Warn, 3001, A.from("KEY")(Pe || (Pe = C(["Cannot evaluate targeting rules and % options for setting '", "' (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/"], ["Cannot evaluate targeting rules and % options for setting '", "' (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/"])), e));
818
+ }, t.prototype.dataGovernanceIsOutOfSync = function() {
819
+ return this.log(v.Warn, 3002, "The `dataGovernance` parameter specified at the client initialization is not in sync with the preferences on the ConfigCat Dashboard. Read more: https://configcat.com/docs/advanced/data-governance/");
820
+ }, t.prototype.configServiceCannotInitiateHttpCalls = function() {
821
+ return this.log(v.Warn, 3200, "Client is in offline mode, it cannot initiate HTTP calls.");
822
+ }, t.prototype.configServiceMethodHasNoEffectDueToDisposedClient = function(e) {
823
+ return this.log(v.Warn, 3201, A.from("METHOD_NAME")(Ue || (Ue = C(["The client object is already disposed, thus `", "()` has no effect."], ["The client object is already disposed, thus \\`", "()\\` has no effect."])), e));
824
+ }, t.prototype.configServiceMethodHasNoEffectDueToOverrideBehavior = function(e, r) {
825
+ return this.log(v.Warn, 3202, A.from("OVERRIDE_BEHAVIOR", "METHOD_NAME")(ke || (ke = C(["Client is configured to use the `", "` override behavior, thus `", "()` has no effect."], ["Client is configured to use the \\`", "\\` override behavior, thus \\`", "()\\` has no effect."])), e, r));
826
+ }, t.prototype.settingEvaluated = function(e) {
827
+ return this.log(v.Info, 5e3, A.from("EVALUATE_LOG")(Me || (Me = C(["", ""], ["", ""])), e));
828
+ }, t.prototype.configServiceStatusChanged = function(e) {
829
+ return this.log(v.Info, 5200, A.from("MODE")(Ve || (Ve = C(["Switched to ", " mode."], ["Switched to ", " mode."])), e.toUpperCase()));
830
+ }, t;
831
+ }()
832
+ ), Be = (
833
+ /** @class */
834
+ function() {
835
+ function t(e) {
836
+ e === void 0 && (e = v.Warn), this.level = e, this.SOURCE = "ConfigCat";
837
+ }
838
+ return t.prototype.log = function(e, r, n, i) {
839
+ var o = e === v.Debug ? [console.info, "DEBUG"] : e === v.Info ? [console.info, "INFO"] : e === v.Warn ? [console.warn, "WARN"] : e === v.Error ? [console.error, "ERROR"] : [console.log, v[e].toUpperCase()], s = o[0], a = o[1], c = i !== void 0 ? `
840
+ ` + _(i, !0) : "";
841
+ s(this.SOURCE + " - " + a + " - [" + r + "] " + n + c);
842
+ }, t;
843
+ }()
844
+ ), Oe, Ce, Ae, Te, we, Ie, Ne, Le, Re, De, Fe, Pe, Ue, ke, Me, Ve;
845
+ function J(t) {
846
+ return !!t.fn;
847
+ }
848
+ var it = (
849
+ /** @class */
850
+ function() {
851
+ function t() {
852
+ this.events = {}, this.eventCount = 0, this.addListener = this.on, this.off = this.removeListener;
853
+ }
854
+ return t.prototype.addListenerCore = function(e, r, n) {
855
+ if (typeof r != "function")
856
+ throw new TypeError("Listener must be a function");
857
+ var i = this.events[e], o = { fn: r, once: n };
858
+ return i ? J(i) ? this.events[e] = [i, o] : i.push(o) : (this.events[e] = o, this.eventCount++), this;
859
+ }, t.prototype.removeListenerCore = function(e, r, n) {
860
+ var i = this.events[e];
861
+ if (!i)
862
+ return this;
863
+ if (J(i))
864
+ n(i, r) && this.removeEvent(e);
865
+ else
866
+ for (var o = i.length - 1; o >= 0; o--)
867
+ if (n(i[o], r)) {
868
+ i.splice(o, 1), i.length ? i.length === 1 && (this.events[e] = i[0]) : this.removeEvent(e);
869
+ break;
870
+ }
871
+ return this;
872
+ }, t.prototype.removeEvent = function(e) {
873
+ --this.eventCount === 0 ? this.events = {} : delete this.events[e];
874
+ }, t.prototype.on = function(e, r) {
875
+ return this.addListenerCore(e, r, !1);
876
+ }, t.prototype.once = function(e, r) {
877
+ return this.addListenerCore(e, r, !0);
878
+ }, t.prototype.removeListener = function(e, r) {
879
+ if (typeof r != "function")
880
+ throw new TypeError("Listener must be a function");
881
+ return this.removeListenerCore(e, r, function(n, i) {
882
+ return n.fn === i;
647
883
  });
648
- });
649
- }, t.prototype.get = function(e) {
650
- return S(this, void 0, void 0, function() {
651
- var r, n;
652
- return O(this, function(i) {
653
- switch (i.label) {
884
+ }, t.prototype.removeAllListeners = function(e) {
885
+ return e ? this.events[e] && this.removeEvent(e) : (this.events = {}, this.eventCount = 0), this;
886
+ }, t.prototype.listeners = function(e) {
887
+ var r = this.events[e];
888
+ if (!r)
889
+ return [];
890
+ if (J(r))
891
+ return [r.fn];
892
+ for (var n = r.length, i = new Array(n), o = 0; o < n; o++)
893
+ i[o] = r[o].fn;
894
+ return i;
895
+ }, t.prototype.listenerCount = function(e) {
896
+ var r = this.events[e];
897
+ return r ? J(r) ? 1 : r.length : 0;
898
+ }, t.prototype.eventNames = function() {
899
+ var e = [];
900
+ if (this.eventCount === 0)
901
+ return e;
902
+ var r = this.events;
903
+ for (var n in r)
904
+ Object.prototype.hasOwnProperty.call(r, n) && e.push(n);
905
+ return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(r)) : e;
906
+ }, t.prototype.emit = function(e, r, n, i, o) {
907
+ var s, a, c = this.events[e];
908
+ if (!c)
909
+ return !1;
910
+ var u, l;
911
+ J(c) ? (s = [c, 1], u = s[0], l = s[1]) : (c = c.slice(), a = [c[0], c.length], u = a[0], l = a[1]);
912
+ for (var h = arguments.length - 1, p = 0; ; ) {
913
+ switch (u.once && this.removeListenerCore(e, u, function(y, E) {
914
+ return y === E;
915
+ }), h) {
654
916
  case 0:
655
- return i.trys.push([0, 2, , 3]), [4, this.cache.get(e)];
917
+ u.fn.call(this);
918
+ break;
656
919
  case 1:
657
- return r = i.sent(), r == null || r === this.cachedSerializedConfig ? [2, this.cachedConfig] : (this.cachedConfig = P.deserialize(r), this.cachedSerializedConfig = r, [3, 3]);
920
+ u.fn.call(this, r);
921
+ break;
658
922
  case 2:
659
- return n = i.sent(), this.logger.configServiceCacheReadError(n), [3, 3];
923
+ u.fn.call(this, r, n);
924
+ break;
660
925
  case 3:
661
- return [2, this.cachedConfig];
926
+ u.fn.call(this, r, n, i);
927
+ break;
928
+ case 4:
929
+ u.fn.call(this, r, n, i, o);
930
+ break;
931
+ default:
932
+ for (var f = new Array(h), d = 0; d < h; d++)
933
+ f[d] = arguments[d + 1];
934
+ u.fn.apply(this, f);
935
+ break;
662
936
  }
663
- });
664
- });
665
- }, t;
666
- }(), d;
667
- (function(t) {
668
- t[t.Debug = 4] = "Debug", t[t.Info = 3] = "Info", t[t.Warn = 2] = "Warn", t[t.Error = 1] = "Error", t[t.Off = -1] = "Off";
669
- })(d || (d = {}));
670
- var C = function() {
671
- function t(e, r, n) {
672
- this.strings = e, this.argNames = r, this.argValues = n;
673
- }
674
- return t.from = function() {
675
- for (var e = [], r = 0; r < arguments.length; r++)
676
- e[r] = arguments[r];
677
- return function(n) {
678
- for (var i = [], o = 1; o < arguments.length; o++)
679
- i[o - 1] = arguments[o];
680
- return new t(n, e, i);
681
- };
682
- }, Object.defineProperty(t.prototype, "defaultFormattedMessage", {
683
- get: function() {
684
- var e = this.cachedDefaultFormattedMessage;
685
- if (e === void 0) {
686
- e = "";
687
- for (var r = this, n = r.strings, i = r.argValues, o = 0; o < n.length - 1; o++)
688
- e += n[o], e += i[o];
689
- e += n[o], this.cachedDefaultFormattedMessage = e;
937
+ if (++p >= l)
938
+ break;
939
+ u = c[p];
690
940
  }
691
- return e;
692
- },
693
- enumerable: !1,
694
- configurable: !0
695
- }), t.prototype.toString = function() {
696
- return this.defaultFormattedMessage;
697
- }, t;
698
- }(), ot = function() {
699
- function t(e, r) {
700
- this.logger = e, this.hooks = r;
701
- }
702
- return Object.defineProperty(t.prototype, "level", {
703
- get: function() {
704
- var e;
705
- return (e = this.logger.level) !== null && e !== void 0 ? e : d.Warn;
706
- },
707
- enumerable: !1,
708
- configurable: !0
709
- }), t.prototype.isLogLevelEnabled = function(e) {
710
- return this.level >= e;
711
- }, t.prototype.log = function(e, r, n, i) {
712
- var o;
713
- return this.isLogLevelEnabled(e) && this.logger.log(e, r, n, i), e === d.Error && ((o = this.hooks) === null || o === void 0 || o.emit("clientError", n.toString(), i)), n;
714
- }, t.prototype.debug = function(e) {
715
- this.log(d.Debug, 0, e);
716
- }, t.prototype.configJsonIsNotPresent = function(e) {
717
- return this.log(d.Error, 1e3, C.from("DEFAULT_RETURN_VALUE")(me || (me = A(["Config JSON is not present. Returning ", "."], ["Config JSON is not present. Returning ", "."])), e));
718
- }, t.prototype.configJsonIsNotPresentSingle = function(e, r, n) {
719
- return this.log(d.Error, 1e3, C.from("KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE")(Ee || (Ee = A(["Config JSON is not present when evaluating setting '", "'. Returning the `", "` parameter that you specified in your application: '", "'."], ["Config JSON is not present when evaluating setting '", "'. Returning the \\`", "\\` parameter that you specified in your application: '", "'."])), e, r, n));
720
- }, t.prototype.settingEvaluationFailedDueToMissingKey = function(e, r, n, i) {
721
- return this.log(d.Error, 1001, C.from("KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE", "AVAILABLE_KEYS")(be || (be = A(["Failed to evaluate setting '", "' (the key was not found in config JSON). Returning the `", "` parameter that you specified in your application: '", "'. Available keys: [", "]."], ["Failed to evaluate setting '", "' (the key was not found in config JSON). Returning the \\`", "\\` parameter that you specified in your application: '", "'. Available keys: [", "]."])), e, r, n, i));
722
- }, t.prototype.settingEvaluationError = function(e, r, n) {
723
- return this.log(d.Error, 1002, C.from("METHOD_NAME", "DEFAULT_RETURN_VALUE")(Se || (Se = A(["Error occurred in the `", "` method. Returning ", "."], ["Error occurred in the \\`", "\\` method. Returning ", "."])), e, r), n);
724
- }, t.prototype.settingEvaluationErrorSingle = function(e, r, n, i, o) {
725
- return this.log(d.Error, 1002, C.from("METHOD_NAME", "KEY", "DEFAULT_PARAM_NAME", "DEFAULT_PARAM_VALUE")(Oe || (Oe = A(["Error occurred in the `", "` method while evaluating setting '", "'. Returning the `", "` parameter that you specified in your application: '", "'."], ["Error occurred in the \\`", "\\` method while evaluating setting '", "'. Returning the \\`", "\\` parameter that you specified in your application: '", "'."])), e, r, n, i), o);
726
- }, t.prototype.forceRefreshError = function(e, r) {
727
- return this.log(d.Error, 1003, C.from("METHOD_NAME")(Ae || (Ae = A(["Error occurred in the `", "` method."], ["Error occurred in the \\`", "\\` method."])), e), r);
728
- }, t.prototype.fetchFailedDueToInvalidSdkKey = function() {
729
- return this.log(d.Error, 1100, "Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey");
730
- }, t.prototype.fetchFailedDueToUnexpectedHttpResponse = function(e, r) {
731
- return this.log(d.Error, 1101, C.from("STATUS_CODE", "REASON_PHRASE")(Ce || (Ce = A(["Unexpected HTTP response was received while trying to fetch config JSON: ", " ", ""], ["Unexpected HTTP response was received while trying to fetch config JSON: ", " ", ""])), e, r));
732
- }, t.prototype.fetchFailedDueToRequestTimeout = function(e, r) {
733
- return this.log(d.Error, 1102, C.from("TIMEOUT")(we || (we = A(["Request timed out while trying to fetch config JSON. Timeout value: ", "ms"], ["Request timed out while trying to fetch config JSON. Timeout value: ", "ms"])), e), r);
734
- }, t.prototype.fetchFailedDueToUnexpectedError = function(e) {
735
- return this.log(d.Error, 1103, "Unexpected error occurred while trying to fetch config JSON.", e);
736
- }, t.prototype.fetchFailedDueToRedirectLoop = function() {
737
- return this.log(d.Error, 1104, "Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/");
738
- }, t.prototype.fetchReceived200WithInvalidBody = function() {
739
- return this.log(d.Error, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.");
740
- }, t.prototype.fetchReceived304WhenLocalCacheIsEmpty = function(e, r) {
741
- return this.log(d.Error, 1106, C.from("STATUS_CODE", "REASON_PHRASE")(Ie || (Ie = A(["Unexpected HTTP response was received when no config JSON is cached locally: ", " ", ""], ["Unexpected HTTP response was received when no config JSON is cached locally: ", " ", ""])), e, r));
742
- }, t.prototype.settingForVariationIdIsNotPresent = function(e) {
743
- return this.log(d.Error, 2011, C.from("VARIATION_ID")(Te || (Te = A(["Could not find the setting for the specified variation ID: '", "'."], ["Could not find the setting for the specified variation ID: '", "'."])), e));
744
- }, t.prototype.configServiceCacheReadError = function(e) {
745
- return this.log(d.Error, 2200, "Error occurred while reading the cache.", e);
746
- }, t.prototype.configServiceCacheWriteError = function(e) {
747
- return this.log(d.Error, 2201, "Error occurred while writing the cache.", e);
748
- }, t.prototype.clientIsAlreadyCreated = function(e) {
749
- return this.log(d.Warn, 3e3, C.from("SDK_KEY")(Ne || (Ne = A(["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: '", "'."], ["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));
750
- }, t.prototype.targetingIsNotPossible = function(e) {
751
- return this.log(d.Warn, 3001, C.from("KEY")(Le || (Le = A(["Cannot evaluate targeting rules and % options for setting '", "' (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/"], ["Cannot evaluate targeting rules and % options for setting '", "' (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/"])), e));
752
- }, t.prototype.dataGovernanceIsOutOfSync = function() {
753
- return this.log(d.Warn, 3002, "The `dataGovernance` parameter specified at the client initialization is not in sync with the preferences on the ConfigCat Dashboard. Read more: https://configcat.com/docs/advanced/data-governance/");
754
- }, t.prototype.configServiceCannotInitiateHttpCalls = function() {
755
- return this.log(d.Warn, 3200, "Client is in offline mode, it cannot initiate HTTP calls.");
756
- }, t.prototype.configServiceMethodHasNoEffectDueToDisposedClient = function(e) {
757
- return this.log(d.Warn, 3201, C.from("METHOD_NAME")(Re || (Re = A(["The client object is already disposed, thus `", "()` has no effect."], ["The client object is already disposed, thus \\`", "()\\` has no effect."])), e));
758
- }, t.prototype.configServiceMethodHasNoEffectDueToOverrideBehavior = function(e, r) {
759
- return this.log(d.Warn, 3202, C.from("OVERRIDE_BEHAVIOR", "METHOD_NAME")(De || (De = A(["Client is configured to use the `", "` override behavior, thus `", "()` has no effect."], ["Client is configured to use the \\`", "\\` override behavior, thus \\`", "()\\` has no effect."])), e, r));
760
- }, t.prototype.settingEvaluated = function(e) {
761
- return this.log(d.Info, 5e3, C.from("EVALUATE_LOG")(Fe || (Fe = A(["", ""], ["", ""])), e));
762
- }, t.prototype.configServiceStatusChanged = function(e) {
763
- return this.log(d.Info, 5200, C.from("MODE")(ke || (ke = A(["Switched to ", " mode."], ["Switched to ", " mode."])), e.toUpperCase()));
764
- }, t;
765
- }(), st = function() {
766
- function t(e) {
767
- e === void 0 && (e = d.Warn), this.level = e, this.SOURCE = "ConfigCat";
768
- }
769
- return t.prototype.log = function(e, r, n, i) {
770
- var o = e === d.Debug ? [console.info, "DEBUG"] : e === d.Info ? [console.info, "INFO"] : e === d.Warn ? [console.warn, "WARN"] : e === d.Error ? [console.error, "ERROR"] : [console.log, d[e].toUpperCase()], s = o[0], a = o[1], u = i !== void 0 ? `
771
- ` + $(i, !0) : "";
772
- s("".concat(this.SOURCE, " - ").concat(a, " - [").concat(r, "] ").concat(n).concat(u));
773
- }, t;
774
- }(), me, Ee, be, Se, Oe, Ae, Ce, we, Ie, Te, Ne, Le, Re, De, Fe, ke;
775
- function _(t) {
776
- return !!t.fn;
777
- }
778
- var at = function() {
779
- function t() {
780
- this.events = {}, this.eventCount = 0, this.addListener = this.on, this.off = this.removeListener;
781
- }
782
- return t.prototype.addListenerCore = function(e, r, n) {
783
- if (typeof r != "function")
784
- throw new TypeError("Listener must be a function");
785
- var i = this.events[e], o = { fn: r, once: n };
786
- return i ? _(i) ? this.events[e] = [i, o] : i.push(o) : (this.events[e] = o, this.eventCount++), this;
787
- }, t.prototype.removeListenerCore = function(e, r, n) {
788
- var i = this.events[e];
789
- if (!i)
941
+ return !0;
942
+ }, t;
943
+ }()
944
+ ), ot = (
945
+ /** @class */
946
+ function() {
947
+ function t() {
948
+ this.addListener = this.on, this.off = this.removeListener;
949
+ }
950
+ return t.prototype.on = function() {
790
951
  return this;
791
- if (_(i))
792
- n(i, r) && this.removeEvent(e);
793
- else
794
- for (var o = i.length - 1; o >= 0; o--)
795
- if (n(i[o], r)) {
796
- i.splice(o, 1), i.length ? i.length === 1 && (this.events[e] = i[0]) : this.removeEvent(e);
797
- break;
798
- }
799
- return this;
800
- }, t.prototype.removeEvent = function(e) {
801
- --this.eventCount === 0 ? this.events = {} : delete this.events[e];
802
- }, t.prototype.on = function(e, r) {
803
- return this.addListenerCore(e, r, !1);
804
- }, t.prototype.once = function(e, r) {
805
- return this.addListenerCore(e, r, !0);
806
- }, t.prototype.removeListener = function(e, r) {
807
- if (typeof r != "function")
808
- throw new TypeError("Listener must be a function");
809
- return this.removeListenerCore(e, r, function(n, i) {
810
- return n.fn === i;
811
- });
812
- }, t.prototype.removeAllListeners = function(e) {
813
- return e ? this.events[e] && this.removeEvent(e) : (this.events = {}, this.eventCount = 0), this;
814
- }, t.prototype.listeners = function(e) {
815
- var r = this.events[e];
816
- if (!r)
952
+ }, t.prototype.once = function() {
953
+ return this;
954
+ }, t.prototype.removeListener = function() {
955
+ return this;
956
+ }, t.prototype.removeAllListeners = function() {
957
+ return this;
958
+ }, t.prototype.listeners = function() {
817
959
  return [];
818
- if (_(r))
819
- return [r.fn];
820
- for (var n = r.length, i = new Array(n), o = 0; o < n; o++)
821
- i[o] = r[o].fn;
822
- return i;
823
- }, t.prototype.listenerCount = function(e) {
824
- var r = this.events[e];
825
- return r ? _(r) ? 1 : r.length : 0;
826
- }, t.prototype.eventNames = function() {
827
- var e = [];
828
- if (this.eventCount === 0)
829
- return e;
830
- var r = this.events;
831
- for (var n in r)
832
- Object.prototype.hasOwnProperty.call(r, n) && e.push(n);
833
- return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(r)) : e;
834
- }, t.prototype.emit = function(e, r, n, i, o) {
835
- var s, a, u = this.events[e];
836
- if (!u)
960
+ }, t.prototype.listenerCount = function() {
961
+ return 0;
962
+ }, t.prototype.eventNames = function() {
963
+ return [];
964
+ }, t.prototype.emit = function() {
837
965
  return !1;
838
- var c, l;
839
- _(u) ? (s = [u, 1], c = s[0], l = s[1]) : (u = u.slice(), a = [u[0], u.length], c = a[0], l = a[1]);
840
- for (var g = arguments.length - 1, v = 0; ; ) {
841
- switch (c.once && this.removeListenerCore(e, c, function(y, E) {
842
- return y === E;
843
- }), g) {
844
- case 0:
845
- c.fn.call(this);
846
- break;
847
- case 1:
848
- c.fn.call(this, r);
849
- break;
850
- case 2:
851
- c.fn.call(this, r, n);
852
- break;
853
- case 3:
854
- c.fn.call(this, r, n, i);
855
- break;
856
- case 4:
857
- c.fn.call(this, r, n, i, o);
858
- break;
859
- default:
860
- for (var f = new Array(g), p = 0; p < g; p++)
861
- f[p] = arguments[p + 1];
862
- c.fn.apply(this, f);
863
- break;
864
- }
865
- if (++v >= l)
866
- break;
867
- c = u[v];
966
+ }, t;
967
+ }()
968
+ ), qt = T, xe = new ot(), st = (
969
+ /** @class */
970
+ function() {
971
+ function t(e) {
972
+ this.addListener = this.on, this.off = this.removeListener, this.eventEmitter = e;
868
973
  }
869
- return !0;
870
- }, t;
871
- }(), ct = function() {
872
- function t() {
873
- this.addListener = this.on, this.off = this.removeListener;
974
+ return t.prototype.tryDisconnect = function() {
975
+ var e = this.eventEmitter;
976
+ return this.eventEmitter = xe, e !== xe;
977
+ }, t.prototype.on = function(e, r) {
978
+ return this.eventEmitter.on(e, r), this;
979
+ }, t.prototype.once = function(e, r) {
980
+ return this.eventEmitter.once(e, r), this;
981
+ }, t.prototype.removeListener = function(e, r) {
982
+ return this.eventEmitter.removeListener(e, r), this;
983
+ }, t.prototype.removeAllListeners = function(e) {
984
+ return this.eventEmitter.removeAllListeners(e), this;
985
+ }, t.prototype.listeners = function(e) {
986
+ return this.eventEmitter.listeners(e);
987
+ }, t.prototype.listenerCount = function(e) {
988
+ return this.eventEmitter.listenerCount(e);
989
+ }, t.prototype.eventNames = function() {
990
+ return this.eventEmitter.eventNames();
991
+ }, t.prototype.emit = function(e) {
992
+ for (var r, n = [], i = 1; i < arguments.length; i++)
993
+ n[i - 1] = arguments[i];
994
+ return (r = this.eventEmitter).emit.apply(r, $e([e], n));
995
+ }, t;
996
+ }()
997
+ );
998
+ function oe(t) {
999
+ function e(V, L) {
1000
+ var H = V << L | V >>> 32 - L;
1001
+ return H;
874
1002
  }
875
- return t.prototype.on = function() {
876
- return this;
877
- }, t.prototype.once = function() {
878
- return this;
879
- }, t.prototype.removeListener = function() {
880
- return this;
881
- }, t.prototype.removeAllListeners = function() {
882
- return this;
883
- }, t.prototype.listeners = function() {
884
- return [];
885
- }, t.prototype.listenerCount = function() {
886
- return 0;
887
- }, t.prototype.eventNames = function() {
888
- return [];
889
- }, t.prototype.emit = function() {
890
- return !1;
891
- }, t;
892
- }(), Pe = new ct(), ut = function() {
893
- function t(e) {
894
- this.addListener = this.on, this.off = this.removeListener, this.eventEmitter = e;
895
- }
896
- return t.prototype.tryDisconnect = function() {
897
- var e = this.eventEmitter;
898
- return this.eventEmitter = Pe, e !== Pe;
899
- }, t.prototype.on = function(e, r) {
900
- return this.eventEmitter.on(e, r), this;
901
- }, t.prototype.once = function(e, r) {
902
- return this.eventEmitter.once(e, r), this;
903
- }, t.prototype.removeListener = function(e, r) {
904
- return this.eventEmitter.removeListener(e, r), this;
905
- }, t.prototype.removeAllListeners = function(e) {
906
- return this.eventEmitter.removeAllListeners(e), this;
907
- }, t.prototype.listeners = function(e) {
908
- return this.eventEmitter.listeners(e);
909
- }, t.prototype.listenerCount = function(e) {
910
- return this.eventEmitter.listenerCount(e);
911
- }, t.prototype.eventNames = function() {
912
- return this.eventEmitter.eventNames();
913
- }, t.prototype.emit = function(e) {
914
- for (var r, n = [], i = 1; i < arguments.length; i++)
915
- n[i - 1] = arguments[i];
916
- return (r = this.eventEmitter).emit.apply(r, Xe([e], n, !1));
917
- }, t;
918
- }();
919
- function te(t) {
920
- function e(k, N) {
921
- var V = k << N | k >>> 32 - N;
922
- return V;
923
- }
924
- function r(k) {
925
- for (var N = "", V, L = 7; L >= 0; L--)
926
- V = k >>> L * 4 & 15, N += V.toString(16);
927
- return N;
1003
+ function r(V) {
1004
+ for (var L = "", H, R = 7; R >= 0; R--)
1005
+ H = V >>> R * 4 & 15, L += H.toString(16);
1006
+ return L;
928
1007
  }
929
- function n(k) {
930
- k = k.replace(/\r\n/g, `
1008
+ function n(V) {
1009
+ V = V.replace(/\r\n/g, `
931
1010
  `);
932
- for (var N = "", V = 0; V < k.length; V++) {
933
- var L = k.charCodeAt(V);
934
- L < 128 ? N += String.fromCharCode(L) : L > 127 && L < 2048 ? (N += String.fromCharCode(L >> 6 | 192), N += String.fromCharCode(L & 63 | 128)) : (N += String.fromCharCode(L >> 12 | 224), N += String.fromCharCode(L >> 6 & 63 | 128), N += String.fromCharCode(L & 63 | 128));
1011
+ for (var L = "", H = 0; H < V.length; H++) {
1012
+ var R = V.charCodeAt(H);
1013
+ R < 128 ? L += String.fromCharCode(R) : R > 127 && R < 2048 ? (L += String.fromCharCode(R >> 6 | 192), L += String.fromCharCode(R & 63 | 128)) : (L += String.fromCharCode(R >> 12 | 224), L += String.fromCharCode(R >> 6 & 63 | 128), L += String.fromCharCode(R & 63 | 128));
935
1014
  }
936
- return N;
1015
+ return L;
937
1016
  }
938
- var i, o, s, a = new Array(80), u = 1732584193, c = 4023233417, l = 2562383102, g = 271733878, v = 3285377520, f, p, y, E, T, F;
1017
+ var i, o, s, a = new Array(80), c = 1732584193, u = 4023233417, l = 2562383102, h = 271733878, p = 3285377520, f, d, y, E, N, U;
939
1018
  t = n(t);
940
- var R = t.length, D = new Array();
941
- for (o = 0; o < R - 3; o += 4)
942
- s = t.charCodeAt(o) << 24 | t.charCodeAt(o + 1) << 16 | t.charCodeAt(o + 2) << 8 | t.charCodeAt(o + 3), D.push(s);
943
- switch (R % 4) {
1019
+ var D = t.length, F = new Array();
1020
+ for (o = 0; o < D - 3; o += 4)
1021
+ s = t.charCodeAt(o) << 24 | t.charCodeAt(o + 1) << 16 | t.charCodeAt(o + 2) << 8 | t.charCodeAt(o + 3), F.push(s);
1022
+ switch (D % 4) {
944
1023
  case 0:
945
1024
  o = 2147483648;
946
1025
  break;
947
1026
  case 1:
948
- o = t.charCodeAt(R - 1) << 24 | 8388608;
1027
+ o = t.charCodeAt(D - 1) << 24 | 8388608;
949
1028
  break;
950
1029
  case 2:
951
- o = t.charCodeAt(R - 2) << 24 | t.charCodeAt(R - 1) << 16 | 32768;
1030
+ o = t.charCodeAt(D - 2) << 24 | t.charCodeAt(D - 1) << 16 | 32768;
952
1031
  break;
953
1032
  case 3:
954
- o = t.charCodeAt(R - 3) << 24 | t.charCodeAt(R - 2) << 16 | t.charCodeAt(R - 1) << 8 | 128;
1033
+ o = t.charCodeAt(D - 3) << 24 | t.charCodeAt(D - 2) << 16 | t.charCodeAt(D - 1) << 8 | 128;
955
1034
  break;
956
1035
  }
957
- for (D.push(o); D.length % 16 != 14; )
958
- D.push(0);
959
- for (D.push(R >>> 29), D.push(R << 3 & 4294967295), i = 0; i < D.length; i += 16) {
1036
+ for (F.push(o); F.length % 16 != 14; )
1037
+ F.push(0);
1038
+ for (F.push(D >>> 29), F.push(D << 3 & 4294967295), i = 0; i < F.length; i += 16) {
960
1039
  for (o = 0; o < 16; o++)
961
- a[o] = D[i + o];
1040
+ a[o] = F[i + o];
962
1041
  for (o = 16; o <= 79; o++)
963
1042
  a[o] = e(a[o - 3] ^ a[o - 8] ^ a[o - 14] ^ a[o - 16], 1);
964
- for (f = u, p = c, y = l, E = g, T = v, o = 0; o <= 19; o++)
965
- F = e(f, 5) + (p & y | ~p & E) + T + a[o] + 1518500249 & 4294967295, T = E, E = y, y = e(p, 30), p = f, f = F;
1043
+ for (f = c, d = u, y = l, E = h, N = p, o = 0; o <= 19; o++)
1044
+ U = e(f, 5) + (d & y | ~d & E) + N + a[o] + 1518500249 & 4294967295, N = E, E = y, y = e(d, 30), d = f, f = U;
966
1045
  for (o = 20; o <= 39; o++)
967
- F = e(f, 5) + (p ^ y ^ E) + T + a[o] + 1859775393 & 4294967295, T = E, E = y, y = e(p, 30), p = f, f = F;
1046
+ U = e(f, 5) + (d ^ y ^ E) + N + a[o] + 1859775393 & 4294967295, N = E, E = y, y = e(d, 30), d = f, f = U;
968
1047
  for (o = 40; o <= 59; o++)
969
- F = e(f, 5) + (p & y | p & E | y & E) + T + a[o] + 2400959708 & 4294967295, T = E, E = y, y = e(p, 30), p = f, f = F;
1048
+ U = e(f, 5) + (d & y | d & E | y & E) + N + a[o] + 2400959708 & 4294967295, N = E, E = y, y = e(d, 30), d = f, f = U;
970
1049
  for (o = 60; o <= 79; o++)
971
- F = e(f, 5) + (p ^ y ^ E) + T + a[o] + 3395469782 & 4294967295, T = E, E = y, y = e(p, 30), p = f, f = F;
972
- u = u + f & 4294967295, c = c + p & 4294967295, l = l + y & 4294967295, g = g + E & 4294967295, v = v + T & 4294967295;
1050
+ U = e(f, 5) + (d ^ y ^ E) + N + a[o] + 3395469782 & 4294967295, N = E, E = y, y = e(d, 30), d = f, f = U;
1051
+ c = c + f & 4294967295, u = u + d & 4294967295, l = l + y & 4294967295, h = h + E & 4294967295, p = p + N & 4294967295;
973
1052
  }
974
- return (r(u) + r(c) + r(l) + r(g) + r(v)).toLowerCase();
1053
+ return (r(c) + r(u) + r(l) + r(h) + r(p)).toLowerCase();
975
1054
  }
976
- var U;
1055
+ var j;
977
1056
  (function(t) {
978
1057
  t[t.AutoPoll = 0] = "AutoPoll", t[t.LazyLoad = 1] = "LazyLoad", t[t.ManualPoll = 2] = "ManualPoll";
979
- })(U || (U = {}));
980
- var ie;
1058
+ })(j || (j = {}));
1059
+ var ue;
981
1060
  (function(t) {
982
1061
  t[t.Global = 0] = "Global", t[t.EuOnly = 1] = "EuOnly";
983
- })(ie || (ie = {}));
984
- var pe = function() {
985
- function t(e, r, n, i, o) {
986
- var s, a, u;
987
- if (this.requestTimeoutMs = 3e4, this.baseUrlOverriden = !1, this.proxy = "", this.offline = !1, !e)
988
- throw new Error("Invalid 'apiKey' value");
989
- switch (this.apiKey = e, this.clientVersion = r, this.dataGovernance = (s = n == null ? void 0 : n.dataGovernance) !== null && s !== void 0 ? s : ie.Global, this.dataGovernance) {
990
- case ie.EuOnly:
991
- this.baseUrl = "https://cdn-eu.configcat.com";
992
- break;
993
- default:
994
- this.baseUrl = "https://cdn-global.configcat.com";
995
- break;
996
- }
997
- var c = (a = o == null ? void 0 : o()) !== null && a !== void 0 ? a : new at();
998
- this.hooks = new ut(c);
999
- var l, g;
1000
- if (n) {
1001
- if (l = n.logger, g = n.cache, n.requestTimeoutMs) {
1002
- if (n.requestTimeoutMs < 0)
1003
- throw new Error("Invalid 'requestTimeoutMs' value");
1004
- this.requestTimeoutMs = n.requestTimeoutMs;
1062
+ })(ue || (ue = {}));
1063
+ var Ee = (
1064
+ /** @class */
1065
+ function() {
1066
+ function t(e, r, n, i, o) {
1067
+ var s = this, a, c, u;
1068
+ if (this.requestTimeoutMs = 3e4, this.baseUrlOverriden = !1, this.proxy = "", this.offline = !1, !e)
1069
+ throw new Error("Invalid 'apiKey' value");
1070
+ switch (this.apiKey = e, this.clientVersion = r, this.dataGovernance = (a = n == null ? void 0 : n.dataGovernance) !== null && a !== void 0 ? a : ue.Global, this.dataGovernance) {
1071
+ case ue.EuOnly:
1072
+ this.baseUrl = "https://cdn-eu.configcat.com";
1073
+ break;
1074
+ default:
1075
+ this.baseUrl = "https://cdn-global.configcat.com";
1076
+ break;
1077
+ }
1078
+ var l = (c = o == null ? void 0 : o()) !== null && c !== void 0 ? c : new it();
1079
+ this.hooks = new st(l), this.readyPromise = new Promise(function(f) {
1080
+ return s.hooks.once("clientReady", f);
1081
+ });
1082
+ var h, p;
1083
+ if (n) {
1084
+ if (h = n.logger, p = n.cache, n.requestTimeoutMs) {
1085
+ if (n.requestTimeoutMs < 0)
1086
+ throw new Error("Invalid 'requestTimeoutMs' value");
1087
+ this.requestTimeoutMs = n.requestTimeoutMs;
1088
+ }
1089
+ n.baseUrl && (this.baseUrl = n.baseUrl, this.baseUrlOverriden = !0), n.proxy && (this.proxy = n.proxy), n.flagOverrides && (this.flagOverrides = n.flagOverrides), n.defaultUser && (this.defaultUser = n.defaultUser), n.offline && (this.offline = n.offline), (u = n.setupHooks) === null || u === void 0 || u.call(n, this.hooks);
1005
1090
  }
1006
- n.baseUrl && (this.baseUrl = n.baseUrl, this.baseUrlOverriden = !0), n.proxy && (this.proxy = n.proxy), n.flagOverrides && (this.flagOverrides = n.flagOverrides), n.defaultUser && (this.defaultUser = n.defaultUser), n.offline && (this.offline = n.offline), (u = n.setupHooks) === null || u === void 0 || u.call(n, this.hooks);
1091
+ this.logger = new nt(h ?? new Be(), this.hooks), this.cache = p ? new ze(p, this.logger) : i ? i(this) : new rt();
1007
1092
  }
1008
- this.logger = new ot(l ?? new st(), this.hooks), this.cache = g ? new qe(g, this.logger) : i ? i(this) : new it();
1009
- }
1010
- return t.prototype.getUrl = function() {
1011
- return this.baseUrl + "/configuration-files/" + this.apiKey + "/" + t.configFileName + "?sdk=" + this.clientVersion;
1012
- }, t.prototype.getCacheKey = function() {
1013
- return te("".concat(this.apiKey, "_").concat(t.configFileName, "_").concat(P.serializationFormatVersion));
1014
- }, t.configFileName = "config_v5.json", t;
1015
- }(), Ue = function(t) {
1016
- z(e, t);
1017
- function e(r, n, i, o, s, a) {
1018
- var u = t.call(this, r, n + "/a-" + i, o, s, a) || this;
1019
- u.pollIntervalSeconds = 60, u.maxInitWaitTimeSeconds = 5, o && (o.pollIntervalSeconds !== void 0 && o.pollIntervalSeconds !== null && (u.pollIntervalSeconds = o.pollIntervalSeconds), o.maxInitWaitTimeSeconds !== void 0 && o.maxInitWaitTimeSeconds !== null && (u.maxInitWaitTimeSeconds = o.maxInitWaitTimeSeconds));
1020
- var c = 2147483;
1021
- if (!(typeof u.pollIntervalSeconds == "number" && 1 <= u.pollIntervalSeconds && u.pollIntervalSeconds <= c))
1022
- throw new Error("Invalid 'pollIntervalSeconds' value");
1023
- if (!(typeof u.maxInitWaitTimeSeconds == "number" && u.maxInitWaitTimeSeconds <= c))
1024
- throw new Error("Invalid 'maxInitWaitTimeSeconds' value");
1025
- return u;
1026
- }
1027
- return e;
1028
- }(pe), Ve = function(t) {
1029
- z(e, t);
1030
- function e(r, n, i, o, s, a) {
1031
- return t.call(this, r, n + "/m-" + i, o, s, a) || this;
1032
- }
1033
- return e;
1034
- }(pe), Me = function(t) {
1035
- z(e, t);
1036
- function e(r, n, i, o, s, a) {
1037
- var u = t.call(this, r, n + "/l-" + i, o, s, a) || this;
1038
- if (u.cacheTimeToLiveSeconds = 60, o && o.cacheTimeToLiveSeconds !== void 0 && o.cacheTimeToLiveSeconds !== null && (u.cacheTimeToLiveSeconds = o.cacheTimeToLiveSeconds), !(typeof u.cacheTimeToLiveSeconds == "number" && 1 <= u.cacheTimeToLiveSeconds && u.cacheTimeToLiveSeconds <= 2147483647))
1039
- throw new Error("Invalid 'cacheTimeToLiveSeconds' value");
1040
- return u;
1041
- }
1042
- return e;
1043
- }(pe), M;
1093
+ return t.prototype.getUrl = function() {
1094
+ return this.baseUrl + "/configuration-files/" + this.apiKey + "/" + t.configFileName + "?sdk=" + this.clientVersion;
1095
+ }, t.prototype.getCacheKey = function() {
1096
+ return oe(this.apiKey + "_" + t.configFileName + "_" + M.serializationFormatVersion);
1097
+ }, t.configFileName = "config_v5.json", t;
1098
+ }()
1099
+ ), He = (
1100
+ /** @class */
1101
+ function(t) {
1102
+ B(e, t);
1103
+ function e(r, n, i, o, s, a) {
1104
+ var c = t.call(this, r, n + "/a-" + i, o, s, a) || this;
1105
+ c.pollIntervalSeconds = 60, c.maxInitWaitTimeSeconds = 5, o && (o.pollIntervalSeconds !== void 0 && o.pollIntervalSeconds !== null && (c.pollIntervalSeconds = o.pollIntervalSeconds), o.maxInitWaitTimeSeconds !== void 0 && o.maxInitWaitTimeSeconds !== null && (c.maxInitWaitTimeSeconds = o.maxInitWaitTimeSeconds));
1106
+ var u = 2147483;
1107
+ if (!(typeof c.pollIntervalSeconds == "number" && 1 <= c.pollIntervalSeconds && c.pollIntervalSeconds <= u))
1108
+ throw new Error("Invalid 'pollIntervalSeconds' value");
1109
+ if (!(typeof c.maxInitWaitTimeSeconds == "number" && c.maxInitWaitTimeSeconds <= u))
1110
+ throw new Error("Invalid 'maxInitWaitTimeSeconds' value");
1111
+ return c;
1112
+ }
1113
+ return e;
1114
+ }(Ee)
1115
+ ), je = (
1116
+ /** @class */
1117
+ function(t) {
1118
+ B(e, t);
1119
+ function e(r, n, i, o, s, a) {
1120
+ return t.call(this, r, n + "/m-" + i, o, s, a) || this;
1121
+ }
1122
+ return e;
1123
+ }(Ee)
1124
+ ), qe = (
1125
+ /** @class */
1126
+ function(t) {
1127
+ B(e, t);
1128
+ function e(r, n, i, o, s, a) {
1129
+ var c = t.call(this, r, n + "/l-" + i, o, s, a) || this;
1130
+ if (c.cacheTimeToLiveSeconds = 60, o && o.cacheTimeToLiveSeconds !== void 0 && o.cacheTimeToLiveSeconds !== null && (c.cacheTimeToLiveSeconds = o.cacheTimeToLiveSeconds), !(typeof c.cacheTimeToLiveSeconds == "number" && 1 <= c.cacheTimeToLiveSeconds && c.cacheTimeToLiveSeconds <= 2147483647))
1131
+ throw new Error("Invalid 'cacheTimeToLiveSeconds' value");
1132
+ return c;
1133
+ }
1134
+ return e;
1135
+ }(Ee)
1136
+ ), P;
1044
1137
  (function(t) {
1045
1138
  t[t.LocalOnly = 0] = "LocalOnly", t[t.LocalOverRemote = 1] = "LocalOverRemote", t[t.RemoteOverLocal = 2] = "RemoteOverLocal";
1046
- })(M || (M = {}));
1047
- var lt = function(t) {
1048
- z(e, t);
1049
- function e(r, n) {
1050
- var i = t.call(this, r, n) || this;
1051
- return i.cacheTimeToLiveMs = n.cacheTimeToLiveSeconds * 1e3, n.hooks.emit("clientReady"), i;
1052
- }
1053
- return e.prototype.getConfig = function() {
1054
- return S(this, void 0, void 0, function() {
1055
- function r(o, s) {
1056
- s === void 0 && (s = ""), o.debug("LazyLoadConfigService.getConfig(): cache is empty or expired".concat(s, "."));
1057
- }
1058
- var n, i;
1059
- return O(this, function(o) {
1060
- switch (o.label) {
1061
- case 0:
1062
- return this.options.logger.debug("LazyLoadConfigService.getConfig() called."), [4, this.options.cache.get(this.cacheKey)];
1063
- case 1:
1064
- return n = o.sent(), n.isExpired(this.cacheTimeToLiveMs) ? this.isOffline ? [3, 3] : (r(this.options.logger, ", calling refreshConfigCoreAsync()"), [4, this.refreshConfigCoreAsync(n)]) : [3, 5];
1065
- case 2:
1066
- return i = o.sent(), n = i[1], [3, 4];
1067
- case 3:
1068
- r(this.options.logger), o.label = 4;
1069
- case 4:
1070
- return [2, n];
1071
- case 5:
1072
- return this.options.logger.debug("LazyLoadConfigService.getConfig(): cache is valid, returning from cache."), [2, n];
1139
+ })(P || (P = {}));
1140
+ var at = (
1141
+ /** @class */
1142
+ function() {
1143
+ function t(e) {
1144
+ this.map = {}, this.map = Object.fromEntries(Object.entries(e).map(function(r) {
1145
+ var n = r[0], i = r[1];
1146
+ return [n, _e.fromValue(i)];
1147
+ }));
1148
+ }
1149
+ return t.prototype.getOverrides = function() {
1150
+ return Promise.resolve(this.map);
1151
+ }, t.prototype.getOverridesSync = function() {
1152
+ return this.map;
1153
+ }, t;
1154
+ }()
1155
+ ), ut = (
1156
+ /** @class */
1157
+ function() {
1158
+ function t(e, r) {
1159
+ this.dataSource = e, this.behaviour = r;
1160
+ }
1161
+ return t;
1162
+ }()
1163
+ ), ct = (
1164
+ /** @class */
1165
+ function(t) {
1166
+ B(e, t);
1167
+ function e(r, n) {
1168
+ var i = t.call(this, r, n) || this;
1169
+ return i.cacheTimeToLiveMs = n.cacheTimeToLiveSeconds * 1e3, t.prototype.syncUpWithCache.call(i), i;
1170
+ }
1171
+ return e.prototype.getConfig = function() {
1172
+ return S(this, void 0, void 0, function() {
1173
+ function r(o, s) {
1174
+ s === void 0 && (s = ""), o.debug("LazyLoadConfigService.getConfig(): cache is empty or expired" + s + ".");
1073
1175
  }
1176
+ var n, i;
1177
+ return O(this, function(o) {
1178
+ switch (o.label) {
1179
+ case 0:
1180
+ return this.options.logger.debug("LazyLoadConfigService.getConfig() called."), [4, this.options.cache.get(this.cacheKey)];
1181
+ case 1:
1182
+ return n = o.sent(), n.isExpired(this.cacheTimeToLiveMs) ? this.isOffline ? [3, 3] : (r(this.options.logger, ", calling refreshConfigCoreAsync()"), [4, this.refreshConfigCoreAsync(n)]) : [3, 5];
1183
+ case 2:
1184
+ return i = o.sent(), n = i[1], [3, 4];
1185
+ case 3:
1186
+ r(this.options.logger), o.label = 4;
1187
+ case 4:
1188
+ return [2, n];
1189
+ case 5:
1190
+ return this.options.logger.debug("LazyLoadConfigService.getConfig(): cache is valid, returning from cache."), [2, n];
1191
+ }
1192
+ });
1074
1193
  });
1075
- });
1076
- }, e.prototype.refreshConfigAsync = function() {
1077
- return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."), t.prototype.refreshConfigAsync.call(this);
1078
- }, e;
1079
- }(ge), ft = function(t) {
1080
- z(e, t);
1081
- function e(r, n) {
1082
- var i = t.call(this, r, n) || this;
1083
- return n.hooks.emit("clientReady"), i;
1084
- }
1085
- return e.prototype.getConfig = function() {
1086
- return S(this, void 0, void 0, function() {
1087
- return O(this, function(r) {
1088
- switch (r.label) {
1089
- case 0:
1090
- return this.options.logger.debug("ManualPollService.getConfig() called."), [4, this.options.cache.get(this.cacheKey)];
1091
- case 1:
1092
- return [2, r.sent()];
1093
- }
1194
+ }, e.prototype.refreshConfigAsync = function() {
1195
+ return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."), t.prototype.refreshConfigAsync.call(this);
1196
+ }, e.prototype.getCacheState = function(r) {
1197
+ return r.isEmpty ? T.NoFlagData : r.isExpired(this.cacheTimeToLiveMs) ? T.HasCachedFlagDataOnly : T.HasUpToDateFlagData;
1198
+ }, e;
1199
+ }(me)
1200
+ ), lt = (
1201
+ /** @class */
1202
+ function(t) {
1203
+ B(e, t);
1204
+ function e(r, n) {
1205
+ var i = t.call(this, r, n) || this;
1206
+ return t.prototype.syncUpWithCache.call(i), i;
1207
+ }
1208
+ return e.prototype.getCacheState = function(r) {
1209
+ return r.isEmpty ? T.NoFlagData : T.HasCachedFlagDataOnly;
1210
+ }, e.prototype.getConfig = function() {
1211
+ return S(this, void 0, void 0, function() {
1212
+ return O(this, function(r) {
1213
+ switch (r.label) {
1214
+ case 0:
1215
+ return this.options.logger.debug("ManualPollService.getConfig() called."), [4, this.options.cache.get(this.cacheKey)];
1216
+ case 1:
1217
+ return [2, r.sent()];
1218
+ }
1219
+ });
1094
1220
  });
1095
- });
1096
- }, e.prototype.refreshConfigAsync = function() {
1097
- return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."), t.prototype.refreshConfigAsync.call(this);
1098
- }, e;
1099
- }(ge);
1100
- function ht() {
1101
- typeof Object.values > "u" && (Object.values = gt), typeof Object.entries > "u" && (Object.entries = pt), typeof Object.fromEntries > "u" && (Object.fromEntries = vt);
1221
+ }, e.prototype.refreshConfigAsync = function() {
1222
+ return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."), t.prototype.refreshConfigAsync.call(this);
1223
+ }, e;
1224
+ }(me)
1225
+ );
1226
+ function ft() {
1227
+ typeof Object.values > "u" && (Object.values = ht), typeof Object.entries > "u" && (Object.entries = gt), typeof Object.fromEntries > "u" && (Object.fromEntries = pt);
1102
1228
  }
1103
- function gt(t) {
1229
+ function ht(t) {
1104
1230
  for (var e = [], r = 0, n = Object.keys(t); r < n.length; r++) {
1105
1231
  var i = n[r];
1106
1232
  e.push(t[i]);
1107
1233
  }
1108
1234
  return e;
1109
1235
  }
1110
- function pt(t) {
1236
+ function gt(t) {
1111
1237
  for (var e = [], r = 0, n = Object.keys(t); r < n.length; r++) {
1112
1238
  var i = n[r];
1113
1239
  e.push([i, t[i]]);
1114
1240
  }
1115
1241
  return e;
1116
1242
  }
1117
- function vt(t) {
1243
+ function pt(t) {
1118
1244
  var e, r = {};
1119
1245
  if (Array.isArray(t))
1120
1246
  for (var n = 0, i = t; n < i.length; n++) {
1121
1247
  var o = i[n], s = o[0], a = o[1];
1122
1248
  r[s] = a;
1123
1249
  }
1124
- else if (typeof Symbol < "u" && (t == null ? void 0 : t[Symbol.iterator]))
1125
- for (var u = t[Symbol.iterator](), c = void 0, l = void 0; e = u.next(), c = e.value, l = e.done, !l; ) {
1126
- var s = c[0], a = c[1];
1250
+ else if (typeof Symbol < "u" && (t != null && t[Symbol.iterator]))
1251
+ for (var c = t[Symbol.iterator](), u = void 0, l = void 0; e = c.next(), u = e.value, l = e.done, !l; ) {
1252
+ var s = u[0], a = u[1];
1127
1253
  r[s] = a;
1128
1254
  }
1129
1255
  else
@@ -1138,414 +1264,432 @@ function dt() {
1138
1264
  return this.target;
1139
1265
  }, t.isFallback = !0, t;
1140
1266
  }
1141
- var yt = function() {
1267
+ var vt = function() {
1142
1268
  return typeof WeakRef == "function";
1143
- }, xe = /^[0-9]+$/, B = function(t, e) {
1144
- var r = xe.test(t), n = xe.test(e);
1269
+ }, We = /^[0-9]+$/, $ = function(t, e) {
1270
+ var r = We.test(t), n = We.test(e);
1145
1271
  return r && n && (t = +t, e = +e), t === e ? 0 : r && !n ? -1 : n && !r ? 1 : t < e ? -1 : 1;
1146
- }, fe = 256, Z = Number.MAX_SAFE_INTEGER || 9007199254740991, Y = [], b = [], m = {}, mt = 0, w = function(t, e) {
1147
- var r = mt++;
1148
- m[t] = r, b[r] = e, Y[r] = new RegExp(e);
1272
+ }, ve = 256, te = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
1273
+ 9007199254740991, Z = [], b = [], m = {}, yt = 0, w = function(t, e) {
1274
+ var r = yt++;
1275
+ m[t] = r, b[r] = e, Z[r] = new RegExp(e);
1149
1276
  };
1150
1277
  w("NUMERICIDENTIFIER", "0|[1-9]\\d*");
1151
1278
  w("NUMERICIDENTIFIERLOOSE", "[0-9]+");
1152
1279
  w("NONNUMERICIDENTIFIER", "\\d*[a-zA-Z-][a-zA-Z0-9-]*");
1153
- w("MAINVERSION", "(".concat(b[m.NUMERICIDENTIFIER], ")\\.") + "(".concat(b[m.NUMERICIDENTIFIER], ")\\.") + "(".concat(b[m.NUMERICIDENTIFIER], ")"));
1154
- w("MAINVERSIONLOOSE", "(".concat(b[m.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(b[m.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(b[m.NUMERICIDENTIFIERLOOSE], ")"));
1155
- w("PRERELEASEIDENTIFIER", "(?:".concat(b[m.NUMERICIDENTIFIER], "|").concat(b[m.NONNUMERICIDENTIFIER], ")"));
1156
- w("PRERELEASEIDENTIFIERLOOSE", "(?:".concat(b[m.NUMERICIDENTIFIERLOOSE], "|").concat(b[m.NONNUMERICIDENTIFIER], ")"));
1157
- w("PRERELEASE", "(?:-(".concat(b[m.PRERELEASEIDENTIFIER], "(?:\\.").concat(b[m.PRERELEASEIDENTIFIER], ")*))"));
1158
- w("PRERELEASELOOSE", "(?:-?(".concat(b[m.PRERELEASEIDENTIFIERLOOSE], "(?:\\.").concat(b[m.PRERELEASEIDENTIFIERLOOSE], ")*))"));
1280
+ w("MAINVERSION", "(" + b[m.NUMERICIDENTIFIER] + ")\\." + ("(" + b[m.NUMERICIDENTIFIER] + ")\\.") + ("(" + b[m.NUMERICIDENTIFIER] + ")"));
1281
+ w("MAINVERSIONLOOSE", "(" + b[m.NUMERICIDENTIFIERLOOSE] + ")\\." + ("(" + b[m.NUMERICIDENTIFIERLOOSE] + ")\\.") + ("(" + b[m.NUMERICIDENTIFIERLOOSE] + ")"));
1282
+ w("PRERELEASEIDENTIFIER", "(?:" + b[m.NUMERICIDENTIFIER] + "|" + b[m.NONNUMERICIDENTIFIER] + ")");
1283
+ w("PRERELEASEIDENTIFIERLOOSE", "(?:" + b[m.NUMERICIDENTIFIERLOOSE] + "|" + b[m.NONNUMERICIDENTIFIER] + ")");
1284
+ w("PRERELEASE", "(?:-(" + b[m.PRERELEASEIDENTIFIER] + "(?:\\." + b[m.PRERELEASEIDENTIFIER] + ")*))");
1285
+ w("PRERELEASELOOSE", "(?:-?(" + b[m.PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + b[m.PRERELEASEIDENTIFIERLOOSE] + ")*))");
1159
1286
  w("BUILDIDENTIFIER", "[0-9A-Za-z-]+");
1160
- w("BUILD", "(?:\\+(".concat(b[m.BUILDIDENTIFIER], "(?:\\.").concat(b[m.BUILDIDENTIFIER], ")*))"));
1161
- w("FULLPLAIN", "v?".concat(b[m.MAINVERSION]).concat(b[m.PRERELEASE], "?").concat(b[m.BUILD], "?"));
1162
- w("FULL", "^".concat(b[m.FULLPLAIN], "$"));
1163
- w("LOOSEPLAIN", "[v=\\s]*".concat(b[m.MAINVERSIONLOOSE]).concat(b[m.PRERELEASELOOSE], "?").concat(b[m.BUILD], "?"));
1164
- w("LOOSE", "^".concat(b[m.LOOSEPLAIN], "$"));
1165
- var oe = function() {
1166
- function t(e, r) {
1167
- if ((!r || typeof r != "object") && (r = {
1168
- loose: !!r,
1169
- includePrerelease: !1
1170
- }), e instanceof t) {
1171
- if (e.loose === !!r.loose && e.includePrerelease === !!r.includePrerelease)
1172
- return e;
1173
- e = e.version;
1174
- } else if (typeof e != "string")
1175
- throw new TypeError("Invalid Version: ".concat(e));
1176
- if (e.length > fe)
1177
- throw new TypeError("version is longer than ".concat(fe, " characters"));
1178
- this.options = r, this.loose = !!r.loose, this.includePrerelease = !!r.includePrerelease;
1179
- var n = e.trim().match(r.loose ? Y[m.LOOSE] : Y[m.FULL]);
1180
- if (!n)
1181
- throw new TypeError("Invalid Version: ".concat(e));
1182
- if (this.raw = e, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > Z || this.major < 0)
1183
- throw new TypeError("Invalid major version");
1184
- if (this.minor > Z || this.minor < 0)
1185
- throw new TypeError("Invalid minor version");
1186
- if (this.patch > Z || this.patch < 0)
1187
- throw new TypeError("Invalid patch version");
1188
- n[4] ? this.prerelease = n[4].split(".").map(function(i) {
1189
- if (/^[0-9]+$/.test(i)) {
1190
- var o = +i;
1191
- if (o >= 0 && o < Z)
1192
- return o;
1193
- }
1194
- return i;
1195
- }) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format();
1196
- }
1197
- return t.prototype.format = function() {
1198
- return this.version = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch), this.prerelease.length && (this.version += "-".concat(this.prerelease.join("."))), this.version;
1199
- }, t.prototype.toString = function() {
1200
- return this.version;
1201
- }, t.prototype.compare = function(e) {
1202
- if (!(e instanceof t)) {
1203
- if (typeof e == "string" && e === this.version)
1204
- return 0;
1205
- e = new t(e, this.options);
1287
+ w("BUILD", "(?:\\+(" + b[m.BUILDIDENTIFIER] + "(?:\\." + b[m.BUILDIDENTIFIER] + ")*))");
1288
+ w("FULLPLAIN", "v?" + b[m.MAINVERSION] + b[m.PRERELEASE] + "?" + b[m.BUILD] + "?");
1289
+ w("FULL", "^" + b[m.FULLPLAIN] + "$");
1290
+ w("LOOSEPLAIN", "[v=\\s]*" + b[m.MAINVERSIONLOOSE] + b[m.PRERELEASELOOSE] + "?" + b[m.BUILD] + "?");
1291
+ w("LOOSE", "^" + b[m.LOOSEPLAIN] + "$");
1292
+ var ce = (
1293
+ /** @class */
1294
+ function() {
1295
+ function t(e, r) {
1296
+ if ((!r || typeof r != "object") && (r = {
1297
+ loose: !!r,
1298
+ includePrerelease: !1
1299
+ }), e instanceof t) {
1300
+ if (e.loose === !!r.loose && e.includePrerelease === !!r.includePrerelease)
1301
+ return e;
1302
+ e = e.version;
1303
+ } else if (typeof e != "string")
1304
+ throw new TypeError("Invalid Version: " + e);
1305
+ if (e.length > ve)
1306
+ throw new TypeError("version is longer than " + ve + " characters");
1307
+ this.options = r, this.loose = !!r.loose, this.includePrerelease = !!r.includePrerelease;
1308
+ var n = e.trim().match(r.loose ? Z[m.LOOSE] : Z[m.FULL]);
1309
+ if (!n)
1310
+ throw new TypeError("Invalid Version: " + e);
1311
+ if (this.raw = e, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > te || this.major < 0)
1312
+ throw new TypeError("Invalid major version");
1313
+ if (this.minor > te || this.minor < 0)
1314
+ throw new TypeError("Invalid minor version");
1315
+ if (this.patch > te || this.patch < 0)
1316
+ throw new TypeError("Invalid patch version");
1317
+ n[4] ? this.prerelease = n[4].split(".").map(function(i) {
1318
+ if (/^[0-9]+$/.test(i)) {
1319
+ var o = +i;
1320
+ if (o >= 0 && o < te)
1321
+ return o;
1322
+ }
1323
+ return i;
1324
+ }) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format();
1206
1325
  }
1207
- return e.version === this.version ? 0 : this.compareMain(e) || this.comparePre(e);
1208
- }, t.prototype.compareMain = function(e) {
1209
- return e instanceof t || (e = new t(e, this.options)), B(this.major, e.major) || B(this.minor, e.minor) || B(this.patch, e.patch);
1210
- }, t.prototype.comparePre = function(e) {
1211
- if (e instanceof t || (e = new t(e, this.options)), this.prerelease.length && !e.prerelease.length)
1212
- return -1;
1213
- if (!this.prerelease.length && e.prerelease.length)
1214
- return 1;
1215
- if (!this.prerelease.length && !e.prerelease.length)
1216
- return 0;
1217
- var r = 0;
1218
- do {
1219
- var n = this.prerelease[r], i = e.prerelease[r];
1220
- if (n === void 0 && i === void 0)
1221
- return 0;
1222
- if (i === void 0)
1223
- return 1;
1224
- if (n === void 0)
1326
+ return t.prototype.format = function() {
1327
+ return this.version = this.major + "." + this.minor + "." + this.patch, this.prerelease.length && (this.version += "-" + this.prerelease.join(".")), this.version;
1328
+ }, t.prototype.toString = function() {
1329
+ return this.version;
1330
+ }, t.prototype.compare = function(e) {
1331
+ if (!(e instanceof t)) {
1332
+ if (typeof e == "string" && e === this.version)
1333
+ return 0;
1334
+ e = new t(e, this.options);
1335
+ }
1336
+ return e.version === this.version ? 0 : this.compareMain(e) || this.comparePre(e);
1337
+ }, t.prototype.compareMain = function(e) {
1338
+ return e instanceof t || (e = new t(e, this.options)), $(this.major, e.major) || $(this.minor, e.minor) || $(this.patch, e.patch);
1339
+ }, t.prototype.comparePre = function(e) {
1340
+ if (e instanceof t || (e = new t(e, this.options)), this.prerelease.length && !e.prerelease.length)
1225
1341
  return -1;
1226
- if (n === i)
1227
- continue;
1228
- return B(n, i);
1229
- } while (++r);
1230
- }, t.prototype.compareBuild = function(e) {
1231
- e instanceof t || (e = new t(e, this.options));
1232
- var r = 0;
1233
- do {
1234
- var n = this.build[r], i = e.build[r];
1235
- if (n === void 0 && i === void 0)
1236
- return 0;
1237
- if (i === void 0)
1342
+ if (!this.prerelease.length && e.prerelease.length)
1238
1343
  return 1;
1239
- if (n === void 0)
1240
- return -1;
1241
- if (n === i)
1242
- continue;
1243
- return B(n, i);
1244
- } while (++r);
1245
- }, t.prototype.inc = function(e, r) {
1246
- switch (e) {
1247
- case "premajor":
1248
- this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", r);
1249
- break;
1250
- case "preminor":
1251
- this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", r);
1252
- break;
1253
- case "prepatch":
1254
- this.prerelease.length = 0, this.inc("patch", r), this.inc("pre", r);
1255
- break;
1256
- case "prerelease":
1257
- this.prerelease.length === 0 && this.inc("patch", r), this.inc("pre", r);
1258
- break;
1259
- case "major":
1260
- (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) && this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
1261
- break;
1262
- case "minor":
1263
- (this.patch !== 0 || this.prerelease.length === 0) && this.minor++, this.patch = 0, this.prerelease = [];
1264
- break;
1265
- case "patch":
1266
- this.prerelease.length === 0 && this.patch++, this.prerelease = [];
1267
- break;
1268
- case "pre":
1269
- if (this.prerelease.length === 0)
1270
- this.prerelease = [0];
1271
- else {
1272
- for (var n = this.prerelease.length; --n >= 0; )
1273
- typeof this.prerelease[n] == "number" && (this.prerelease[n]++, n = -2);
1274
- n === -1 && this.prerelease.push(0);
1275
- }
1276
- r && (this.prerelease[0] === r ? isNaN(this.prerelease[1]) && (this.prerelease = [r, 0]) : this.prerelease = [r, 0]);
1277
- break;
1278
- default:
1279
- throw new Error("invalid increment argument: ".concat(e));
1280
- }
1281
- return this.format(), this.raw = this.version, this;
1282
- }, t;
1283
- }(), Et = function(t, e) {
1344
+ if (!this.prerelease.length && !e.prerelease.length)
1345
+ return 0;
1346
+ var r = 0;
1347
+ do {
1348
+ var n = this.prerelease[r], i = e.prerelease[r];
1349
+ if (n === void 0 && i === void 0)
1350
+ return 0;
1351
+ if (i === void 0)
1352
+ return 1;
1353
+ if (n === void 0)
1354
+ return -1;
1355
+ if (n === i)
1356
+ continue;
1357
+ return $(n, i);
1358
+ } while (++r);
1359
+ }, t.prototype.compareBuild = function(e) {
1360
+ e instanceof t || (e = new t(e, this.options));
1361
+ var r = 0;
1362
+ do {
1363
+ var n = this.build[r], i = e.build[r];
1364
+ if (n === void 0 && i === void 0)
1365
+ return 0;
1366
+ if (i === void 0)
1367
+ return 1;
1368
+ if (n === void 0)
1369
+ return -1;
1370
+ if (n === i)
1371
+ continue;
1372
+ return $(n, i);
1373
+ } while (++r);
1374
+ }, t.prototype.inc = function(e, r) {
1375
+ switch (e) {
1376
+ case "premajor":
1377
+ this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", r);
1378
+ break;
1379
+ case "preminor":
1380
+ this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", r);
1381
+ break;
1382
+ case "prepatch":
1383
+ this.prerelease.length = 0, this.inc("patch", r), this.inc("pre", r);
1384
+ break;
1385
+ case "prerelease":
1386
+ this.prerelease.length === 0 && this.inc("patch", r), this.inc("pre", r);
1387
+ break;
1388
+ case "major":
1389
+ (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) && this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
1390
+ break;
1391
+ case "minor":
1392
+ (this.patch !== 0 || this.prerelease.length === 0) && this.minor++, this.patch = 0, this.prerelease = [];
1393
+ break;
1394
+ case "patch":
1395
+ this.prerelease.length === 0 && this.patch++, this.prerelease = [];
1396
+ break;
1397
+ case "pre":
1398
+ if (this.prerelease.length === 0)
1399
+ this.prerelease = [0];
1400
+ else {
1401
+ for (var n = this.prerelease.length; --n >= 0; )
1402
+ typeof this.prerelease[n] == "number" && (this.prerelease[n]++, n = -2);
1403
+ n === -1 && this.prerelease.push(0);
1404
+ }
1405
+ r && (this.prerelease[0] === r ? isNaN(this.prerelease[1]) && (this.prerelease = [r, 0]) : this.prerelease = [r, 0]);
1406
+ break;
1407
+ default:
1408
+ throw new Error("invalid increment argument: " + e);
1409
+ }
1410
+ return this.format(), this.raw = this.version, this;
1411
+ }, t;
1412
+ }()
1413
+ ), mt = function(t, e) {
1284
1414
  if ((!e || typeof e != "object") && (e = {
1285
1415
  loose: !!e,
1286
1416
  includePrerelease: !1
1287
- }), t instanceof oe)
1417
+ }), t instanceof ce)
1288
1418
  return t;
1289
- if (typeof t != "string" || t.length > fe)
1419
+ if (typeof t != "string" || t.length > ve)
1290
1420
  return null;
1291
- var r = e.loose ? Y[m.LOOSE] : Y[m.FULL];
1421
+ var r = e.loose ? Z[m.LOOSE] : Z[m.FULL];
1292
1422
  if (!r.test(t))
1293
1423
  return null;
1294
1424
  try {
1295
- return new oe(t, e);
1425
+ return new ce(t, e);
1296
1426
  } catch {
1297
1427
  return null;
1298
1428
  }
1299
- }, H = function(t, e, r) {
1300
- return new oe(t, r).compare(new oe(e, r));
1301
- }, j = function(t) {
1302
- var e = Et(t, !1);
1429
+ }, G = function(t, e, r) {
1430
+ return new ce(t, r).compare(new ce(e, r));
1431
+ }, W = function(t) {
1432
+ var e = mt(t, !1);
1303
1433
  return e ? e.version : null;
1434
+ }, Et = function(t, e) {
1435
+ return G(t, e, !0) === 0;
1304
1436
  }, bt = function(t, e) {
1305
- return H(t, e, !0) === 0;
1437
+ return G(t, e, !1) === 0;
1306
1438
  }, St = function(t, e) {
1307
- return H(t, e, !1) === 0;
1439
+ return G(t, e, !1) < 0;
1308
1440
  }, Ot = function(t, e) {
1309
- return H(t, e, !1) < 0;
1310
- }, At = function(t, e) {
1311
- return H(t, e, !1) <= 0;
1441
+ return G(t, e, !1) <= 0;
1312
1442
  }, Ct = function(t, e) {
1313
- return H(t, e, !1) > 0;
1314
- }, wt = function(t, e) {
1315
- return H(t, e, !1) >= 0;
1316
- }, It = function() {
1317
- function t(e) {
1318
- this.logger = e;
1319
- }
1320
- return t.prototype.evaluate = function(e, r, n, i, o) {
1321
- if (this.logger.debug("RolloutEvaluator.Evaluate() called."), e.type < 0 && !_e(e.value))
1322
- throw new TypeError(e.value === null ? "Setting value is null." : e.value === void 0 ? "Setting value is undefined." : "Setting value '".concat(e.value, "' is of an unsupported type (").concat(typeof e.value, ")."));
1323
- var s = new Tt();
1324
- s.user = i, s.keyName = r, s.returnValue = n;
1325
- var a;
1326
- try {
1327
- if (i) {
1328
- if (a = this.evaluateRules(e.targetingRules, i, s), a !== null || (a = this.evaluatePercentageRules(e.percentageOptions, r, i), e.percentageOptions && e.percentageOptions.length > 0 && s.opAppendLine("Evaluating % options => " + (a ? "user targeted" : "user not targeted")), a !== null))
1329
- return s.returnValue = a.value, a;
1330
- } else
1331
- (e.targetingRules && e.targetingRules.length > 0 || e.percentageOptions && e.percentageOptions.length > 0) && this.logger.targetingIsNotPossible(r);
1332
- return a = {
1333
- value: e.value,
1334
- variationId: e.variationId
1335
- }, s.returnValue = a.value, a;
1336
- } finally {
1337
- this.logger.settingEvaluated(s);
1443
+ return G(t, e, !1) > 0;
1444
+ }, At = function(t, e) {
1445
+ return G(t, e, !1) >= 0;
1446
+ }, Wt = (
1447
+ /** @class */
1448
+ function() {
1449
+ function t(e, r, n, i) {
1450
+ this.custom = {}, this.identifier = e, this.email = r, this.country = n, this.custom = i || {};
1338
1451
  }
1339
- }, t.prototype.evaluateRules = function(e, r, n) {
1340
- if (this.logger.debug("RolloutEvaluator.EvaluateRules() called."), e && e.length > 0)
1341
- for (var i = function(u) {
1342
- var c = e[u], l = o.getUserAttribute(r, c.comparisonAttribute), g = c.comparator, v = c.comparisonValue, f = "Evaluating rule: '" + l + "' " + o.ruleToString(g) + " '" + v + "' => ";
1343
- if (!l)
1344
- return f += "NO MATCH (Attribute is not defined on the user object)", n.opAppendLine(f), "continue";
1345
- var p = {
1346
- value: c.value,
1347
- variationId: c.variationId,
1348
- matchedTargetingRule: c
1349
- };
1350
- switch (g) {
1351
- case h.In:
1352
- for (var y = v.split(","), E = 0; E < y.length; E++)
1353
- if (y[E].trim() === l)
1354
- return f += "MATCH", n.opAppendLine(f), { value: p };
1355
- f += "no match";
1356
- break;
1357
- case h.NotIn:
1358
- if (!v.split(",").some(function(D) {
1359
- return D.trim() === l;
1360
- }))
1361
- return f += "MATCH", n.opAppendLine(f), { value: p };
1362
- f += "no match";
1363
- break;
1364
- case h.Contains:
1365
- if (l.indexOf(v) !== -1)
1366
- return f += "MATCH", n.opAppendLine(f), { value: p };
1367
- f += "no match";
1368
- break;
1369
- case h.NotContains:
1370
- if (l.indexOf(v) === -1)
1371
- return f += "MATCH", n.opAppendLine(f), { value: p };
1372
- f += "no match";
1373
- break;
1374
- case h.SemVerIn:
1375
- case h.SemVerNotIn:
1376
- case h.SemVerLessThan:
1377
- case h.SemVerLessThanEqual:
1378
- case h.SemVerGreaterThan:
1379
- case h.SemVerGreaterThanEqual:
1380
- if (o.evaluateSemver(l, v, g))
1381
- return f += "MATCH", n.opAppendLine(f), { value: p };
1382
- f += "no match";
1383
- break;
1384
- case h.NumberEqual:
1385
- case h.NumberNotEqual:
1386
- case h.NumberLessThan:
1387
- case h.NumberLessThanEqual:
1388
- case h.NumberGreaterThan:
1389
- case h.NumberGreaterThanEqual:
1390
- if (o.evaluateNumber(l, v, g))
1391
- return f += "MATCH", n.opAppendLine(f), { value: p };
1392
- f += "no match";
1393
- break;
1394
- case h.SensitiveOneOf: {
1395
- for (var T = v.split(","), F = te(l), E = 0; E < T.length; E++)
1396
- if (T[E].trim() === F)
1397
- return f += "MATCH", n.opAppendLine(f), { value: p };
1398
- f += "no match";
1399
- break;
1400
- }
1401
- case h.SensitiveNotOneOf: {
1402
- var R = te(l);
1403
- if (!v.split(",").some(function(D) {
1404
- return D.trim() === R;
1405
- }))
1406
- return f += "MATCH", n.opAppendLine(f), { value: p };
1407
- f += "no match";
1408
- break;
1409
- }
1410
- }
1411
- n.opAppendLine(f);
1412
- }, o = this, s = 0; s < e.length; s++) {
1413
- var a = i(s);
1414
- if (typeof a == "object")
1415
- return a.value;
1452
+ return t;
1453
+ }()
1454
+ ), Tt = (
1455
+ /** @class */
1456
+ function() {
1457
+ function t(e) {
1458
+ this.logger = e;
1459
+ }
1460
+ return t.prototype.evaluate = function(e, r, n, i, o) {
1461
+ if (this.logger.debug("RolloutEvaluator.Evaluate() called."), e.type < 0 && !Je(e.value))
1462
+ throw new TypeError(e.value === null ? "Setting value is null." : e.value === void 0 ? "Setting value is undefined." : "Setting value '" + e.value + "' is of an unsupported type (" + typeof e.value + ").");
1463
+ var s = new wt();
1464
+ s.user = i, s.keyName = r, s.returnValue = n;
1465
+ var a;
1466
+ try {
1467
+ if (i) {
1468
+ if (a = this.evaluateRules(e.targetingRules, i, s), a !== null || (a = this.evaluatePercentageRules(e.percentageOptions, r, i), e.percentageOptions && e.percentageOptions.length > 0 && s.opAppendLine("Evaluating % options => " + (a ? "user targeted" : "user not targeted")), a !== null))
1469
+ return s.returnValue = a.value, a;
1470
+ } else
1471
+ (e.targetingRules && e.targetingRules.length > 0 || e.percentageOptions && e.percentageOptions.length > 0) && this.logger.targetingIsNotPossible(r);
1472
+ return a = {
1473
+ value: e.value,
1474
+ variationId: e.variationId
1475
+ }, s.returnValue = a.value, a;
1476
+ } finally {
1477
+ this.logger.settingEvaluated(s);
1416
1478
  }
1417
- return null;
1418
- }, t.prototype.evaluatePercentageRules = function(e, r, n) {
1419
- if (this.logger.debug("RolloutEvaluator.EvaluateVariations() called."), e && e.length > 0)
1420
- for (var i = r + (n.identifier === null || n.identifier === void 0 ? "" : n.identifier), o = te(i).substring(0, 7), s = parseInt(o, 16) % 100, a = 0, u = 0; u < e.length; u++) {
1421
- var c = e[u];
1422
- if (a += +c.percentage, s < a)
1423
- return {
1424
- value: c.value,
1425
- variationId: c.variationId,
1426
- matchedPercentageOption: c
1479
+ }, t.prototype.evaluateRules = function(e, r, n) {
1480
+ if (this.logger.debug("RolloutEvaluator.EvaluateRules() called."), e && e.length > 0)
1481
+ for (var i = function(c) {
1482
+ var u = e[c], l = o.getUserAttribute(r, u.comparisonAttribute), h = u.comparator, p = u.comparisonValue, f = "Evaluating rule: '" + l + "' " + o.ruleToString(h) + " '" + p + "' => ";
1483
+ if (!l)
1484
+ return f += "NO MATCH (Attribute is not defined on the user object)", n.opAppendLine(f), "continue";
1485
+ var d = {
1486
+ value: u.value,
1487
+ variationId: u.variationId,
1488
+ matchedTargetingRule: u
1427
1489
  };
1490
+ switch (h) {
1491
+ case g.In:
1492
+ for (var y = p.split(","), E = 0; E < y.length; E++)
1493
+ if (y[E].trim() === l)
1494
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1495
+ f += "no match";
1496
+ break;
1497
+ case g.NotIn:
1498
+ if (!p.split(",").some(function(F) {
1499
+ return F.trim() === l;
1500
+ }))
1501
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1502
+ f += "no match";
1503
+ break;
1504
+ case g.Contains:
1505
+ if (l.indexOf(p) !== -1)
1506
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1507
+ f += "no match";
1508
+ break;
1509
+ case g.NotContains:
1510
+ if (l.indexOf(p) === -1)
1511
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1512
+ f += "no match";
1513
+ break;
1514
+ case g.SemVerIn:
1515
+ case g.SemVerNotIn:
1516
+ case g.SemVerLessThan:
1517
+ case g.SemVerLessThanEqual:
1518
+ case g.SemVerGreaterThan:
1519
+ case g.SemVerGreaterThanEqual:
1520
+ if (o.evaluateSemver(l, p, h))
1521
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1522
+ f += "no match";
1523
+ break;
1524
+ case g.NumberEqual:
1525
+ case g.NumberNotEqual:
1526
+ case g.NumberLessThan:
1527
+ case g.NumberLessThanEqual:
1528
+ case g.NumberGreaterThan:
1529
+ case g.NumberGreaterThanEqual:
1530
+ if (o.evaluateNumber(l, p, h))
1531
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1532
+ f += "no match";
1533
+ break;
1534
+ case g.SensitiveOneOf: {
1535
+ for (var N = p.split(","), U = oe(l), E = 0; E < N.length; E++)
1536
+ if (N[E].trim() === U)
1537
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1538
+ f += "no match";
1539
+ break;
1540
+ }
1541
+ case g.SensitiveNotOneOf: {
1542
+ var D = oe(l);
1543
+ if (!p.split(",").some(function(F) {
1544
+ return F.trim() === D;
1545
+ }))
1546
+ return f += "MATCH", n.opAppendLine(f), { value: d };
1547
+ f += "no match";
1548
+ break;
1549
+ }
1550
+ }
1551
+ n.opAppendLine(f);
1552
+ }, o = this, s = 0; s < e.length; s++) {
1553
+ var a = i(s);
1554
+ if (typeof a == "object")
1555
+ return a.value;
1556
+ }
1557
+ return null;
1558
+ }, t.prototype.evaluatePercentageRules = function(e, r, n) {
1559
+ if (this.logger.debug("RolloutEvaluator.EvaluateVariations() called."), e && e.length > 0)
1560
+ for (var i = r + (n.identifier === null || n.identifier === void 0 ? "" : n.identifier), o = oe(i).substring(0, 7), s = parseInt(o, 16) % 100, a = 0, c = 0; c < e.length; c++) {
1561
+ var u = e[c];
1562
+ if (a += +u.percentage, s < a)
1563
+ return {
1564
+ value: u.value,
1565
+ variationId: u.variationId,
1566
+ matchedPercentageOption: u
1567
+ };
1568
+ }
1569
+ return null;
1570
+ }, t.prototype.evaluateNumber = function(e, r, n) {
1571
+ this.logger.debug("RolloutEvaluator.EvaluateNumber() called.");
1572
+ var i, o;
1573
+ if (e && !Number.isNaN(Number.parseFloat(e.replace(",", "."))))
1574
+ i = Number.parseFloat(e.replace(",", "."));
1575
+ else
1576
+ return !1;
1577
+ if (r && !Number.isNaN(Number.parseFloat(r.replace(",", "."))))
1578
+ o = Number.parseFloat(r.replace(",", "."));
1579
+ else
1580
+ return !1;
1581
+ switch (n) {
1582
+ case g.NumberEqual:
1583
+ return i === o;
1584
+ case g.NumberNotEqual:
1585
+ return i !== o;
1586
+ case g.NumberLessThan:
1587
+ return i < o;
1588
+ case g.NumberLessThanEqual:
1589
+ return i <= o;
1590
+ case g.NumberGreaterThan:
1591
+ return i > o;
1592
+ case g.NumberGreaterThanEqual:
1593
+ return i >= o;
1428
1594
  }
1429
- return null;
1430
- }, t.prototype.evaluateNumber = function(e, r, n) {
1431
- this.logger.debug("RolloutEvaluator.EvaluateNumber() called.");
1432
- var i, o;
1433
- if (e && !Number.isNaN(Number.parseFloat(e.replace(",", "."))))
1434
- i = Number.parseFloat(e.replace(",", "."));
1435
- else
1436
- return !1;
1437
- if (r && !Number.isNaN(Number.parseFloat(r.replace(",", "."))))
1438
- o = Number.parseFloat(r.replace(",", "."));
1439
- else
1440
1595
  return !1;
1441
- switch (n) {
1442
- case h.NumberEqual:
1443
- return i === o;
1444
- case h.NumberNotEqual:
1445
- return i !== o;
1446
- case h.NumberLessThan:
1447
- return i < o;
1448
- case h.NumberLessThanEqual:
1449
- return i <= o;
1450
- case h.NumberGreaterThan:
1451
- return i > o;
1452
- case h.NumberGreaterThanEqual:
1453
- return i >= o;
1454
- }
1455
- return !1;
1456
- }, t.prototype.evaluateSemver = function(e, r, n) {
1457
- if (this.logger.debug("RolloutEvaluator.EvaluateSemver() called."), j(e) == null || r === void 0)
1596
+ }, t.prototype.evaluateSemver = function(e, r, n) {
1597
+ if (this.logger.debug("RolloutEvaluator.EvaluateSemver() called."), W(e) == null || r === void 0)
1598
+ return !1;
1599
+ switch (r = r.trim(), n) {
1600
+ case g.SemVerIn:
1601
+ for (var i = r.split(","), o = !1, s = 0; s < i.length; s++)
1602
+ if (!(!i[s] || i[s].trim() === "")) {
1603
+ if (W(i[s].trim()) == null)
1604
+ return !1;
1605
+ o || (o = Et(e, i[s].trim()));
1606
+ }
1607
+ return o;
1608
+ case g.SemVerNotIn:
1609
+ return !r.split(",").some(function(a) {
1610
+ return !a || a.trim() === "" || (a = W(a.trim()), a == null) ? !1 : bt(e, a);
1611
+ });
1612
+ case g.SemVerLessThan:
1613
+ return W(r) == null ? !1 : St(e, r);
1614
+ case g.SemVerLessThanEqual:
1615
+ return W(r) == null ? !1 : Ot(e, r);
1616
+ case g.SemVerGreaterThan:
1617
+ return W(r) == null ? !1 : Ct(e, r);
1618
+ case g.SemVerGreaterThanEqual:
1619
+ return W(r) == null ? !1 : At(e, r);
1620
+ }
1458
1621
  return !1;
1459
- switch (r = r.trim(), n) {
1460
- case h.SemVerIn:
1461
- for (var i = r.split(","), o = !1, s = 0; s < i.length; s++)
1462
- if (!(!i[s] || i[s].trim() === "")) {
1463
- if (j(i[s].trim()) == null)
1464
- return !1;
1465
- o || (o = bt(e, i[s].trim()));
1466
- }
1467
- return o;
1468
- case h.SemVerNotIn:
1469
- return !r.split(",").some(function(a) {
1470
- return !a || a.trim() === "" || (a = j(a.trim()), a == null) ? !1 : St(e, a);
1471
- });
1472
- case h.SemVerLessThan:
1473
- return j(r) == null ? !1 : Ot(e, r);
1474
- case h.SemVerLessThanEqual:
1475
- return j(r) == null ? !1 : At(e, r);
1476
- case h.SemVerGreaterThan:
1477
- return j(r) == null ? !1 : Ct(e, r);
1478
- case h.SemVerGreaterThanEqual:
1479
- return j(r) == null ? !1 : wt(e, r);
1480
- }
1481
- return !1;
1482
- }, t.prototype.getUserAttribute = function(e, r) {
1483
- switch (r) {
1484
- case "Identifier":
1485
- return e.identifier;
1486
- case "Email":
1487
- return e.email;
1488
- case "Country":
1489
- return e.country;
1490
- default:
1491
- return (e.custom || {})[r];
1492
- }
1493
- }, t.prototype.ruleToString = function(e) {
1494
- switch (e) {
1495
- case h.In:
1496
- return "IS ONE OF";
1497
- case h.NotIn:
1498
- return "IS NOT ONE OF";
1499
- case h.Contains:
1500
- return "CONTAINS";
1501
- case h.NotContains:
1502
- return "DOES NOT CONTAIN";
1503
- case h.SemVerIn:
1504
- return "IS ONE OF (SemVer)";
1505
- case h.SemVerNotIn:
1506
- return "IS NOT ONE OF (SemVer)";
1507
- case h.SemVerLessThan:
1508
- return "< (SemVer)";
1509
- case h.SemVerLessThanEqual:
1510
- return "<= (SemVer)";
1511
- case h.SemVerGreaterThan:
1512
- return "> (SemVer)";
1513
- case h.SemVerGreaterThanEqual:
1514
- return ">= (SemVer)";
1515
- case h.NumberEqual:
1516
- return "= (Number)";
1517
- case h.NumberNotEqual:
1518
- return "!= (Number)";
1519
- case h.NumberLessThan:
1520
- return "< (Number)";
1521
- case h.NumberLessThanEqual:
1522
- return "<= (Number)";
1523
- case h.NumberGreaterThan:
1524
- return "> (Number)";
1525
- case h.NumberGreaterThanEqual:
1526
- return ">= (Number)";
1527
- case h.SensitiveOneOf:
1528
- return "IS ONE OF (Sensitive)";
1529
- case h.SensitiveNotOneOf:
1530
- return "IS NOT ONE OF (Sensitive)";
1531
- default:
1532
- return e + "";
1622
+ }, t.prototype.getUserAttribute = function(e, r) {
1623
+ switch (r) {
1624
+ case "Identifier":
1625
+ return e.identifier;
1626
+ case "Email":
1627
+ return e.email;
1628
+ case "Country":
1629
+ return e.country;
1630
+ default:
1631
+ return (e.custom || {})[r];
1632
+ }
1633
+ }, t.prototype.ruleToString = function(e) {
1634
+ switch (e) {
1635
+ case g.In:
1636
+ return "IS ONE OF";
1637
+ case g.NotIn:
1638
+ return "IS NOT ONE OF";
1639
+ case g.Contains:
1640
+ return "CONTAINS";
1641
+ case g.NotContains:
1642
+ return "DOES NOT CONTAIN";
1643
+ case g.SemVerIn:
1644
+ return "IS ONE OF (SemVer)";
1645
+ case g.SemVerNotIn:
1646
+ return "IS NOT ONE OF (SemVer)";
1647
+ case g.SemVerLessThan:
1648
+ return "< (SemVer)";
1649
+ case g.SemVerLessThanEqual:
1650
+ return "<= (SemVer)";
1651
+ case g.SemVerGreaterThan:
1652
+ return "> (SemVer)";
1653
+ case g.SemVerGreaterThanEqual:
1654
+ return ">= (SemVer)";
1655
+ case g.NumberEqual:
1656
+ return "= (Number)";
1657
+ case g.NumberNotEqual:
1658
+ return "!= (Number)";
1659
+ case g.NumberLessThan:
1660
+ return "< (Number)";
1661
+ case g.NumberLessThanEqual:
1662
+ return "<= (Number)";
1663
+ case g.NumberGreaterThan:
1664
+ return "> (Number)";
1665
+ case g.NumberGreaterThanEqual:
1666
+ return ">= (Number)";
1667
+ case g.SensitiveOneOf:
1668
+ return "IS ONE OF (Sensitive)";
1669
+ case g.SensitiveNotOneOf:
1670
+ return "IS NOT ONE OF (Sensitive)";
1671
+ default:
1672
+ return e + "";
1673
+ }
1674
+ }, t;
1675
+ }()
1676
+ ), wt = (
1677
+ /** @class */
1678
+ function() {
1679
+ function t() {
1680
+ this.operations = "";
1533
1681
  }
1534
- }, t;
1535
- }(), Tt = function() {
1536
- function t() {
1537
- this.operations = "";
1538
- }
1539
- return t.prototype.opAppendLine = function(e) {
1540
- this.operations += " " + e + `
1682
+ return t.prototype.opAppendLine = function(e) {
1683
+ this.operations += " " + e + `
1541
1684
  `;
1542
- }, t.prototype.toString = function() {
1543
- return "Evaluate '" + this.keyName + `'
1685
+ }, t.prototype.toString = function() {
1686
+ return "Evaluate '" + this.keyName + `'
1544
1687
  User : ` + JSON.stringify(this.user) + `
1545
1688
  ` + this.operations + " Returning value : " + this.returnValue;
1546
- }, t;
1547
- }();
1548
- function He(t, e, r, n) {
1689
+ }, t;
1690
+ }()
1691
+ );
1692
+ function Ge(t, e, r, n) {
1549
1693
  return {
1550
1694
  key: t,
1551
1695
  value: e.value,
@@ -1557,7 +1701,7 @@ function He(t, e, r, n) {
1557
1701
  matchedEvaluationPercentageRule: e.matchedPercentageOption
1558
1702
  };
1559
1703
  }
1560
- function X(t, e, r, n, i, o) {
1704
+ function z(t, e, r, n, i, o) {
1561
1705
  return {
1562
1706
  key: t,
1563
1707
  value: e,
@@ -1568,486 +1712,612 @@ function X(t, e, r, n, i, o) {
1568
1712
  errorException: o
1569
1713
  };
1570
1714
  }
1571
- function je(t, e, r, n, i, o, s) {
1715
+ function le(t, e, r, n, i, o, s) {
1572
1716
  var a;
1573
1717
  if (!e)
1574
- return a = s.configJsonIsNotPresentSingle(r, "defaultValue", n).toString(), X(r, n, W(o), i, a);
1575
- var u = e[r];
1576
- if (!u)
1577
- return a = s.settingEvaluationFailedDueToMissingKey(r, "defaultValue", n, Nt(e)).toString(), X(r, n, W(o), i, a);
1578
- var c = t.evaluate(u, r, n, i, o);
1579
- if (n != null && typeof n != typeof c.value)
1718
+ return a = s.configJsonIsNotPresentSingle(r, "defaultValue", n).toString(), z(r, n, x(o), i, a);
1719
+ var c = e[r];
1720
+ if (!c)
1721
+ return a = s.settingEvaluationFailedDueToMissingKey(r, "defaultValue", n, It(e)).toString(), z(r, n, x(o), i, a);
1722
+ var u = t.evaluate(c, r, n, i, o);
1723
+ if (n != null && typeof n != typeof u.value)
1580
1724
  throw new TypeError(`The type of a setting must match the type of the given default value.
1581
- The setting's type was `.concat(typeof n, ", the given default value's type was ").concat(typeof c.value, `.
1582
- Please pass a corresponding default value type.`));
1583
- return He(r, c, W(o), i);
1725
+ The setting's type was ` + typeof n + ", the given default value's type was " + typeof u.value + `.
1726
+ Please pass a corresponding default value type.`);
1727
+ return Ge(r, u, x(o), i);
1584
1728
  }
1585
1729
  function Ke(t, e, r, n, i, o) {
1586
1730
  var s;
1587
- if (!he(e, i, o))
1731
+ if (!ye(e, i, o))
1588
1732
  return [[], s];
1589
- for (var a = [], u = 0, c = Object.entries(e); u < c.length; u++) {
1590
- var l = c[u], g = l[0], v = l[1], f = void 0;
1733
+ for (var a = [], c = 0, u = Object.entries(e); c < u.length; c++) {
1734
+ var l = u[c], h = l[0], p = l[1], f = void 0;
1591
1735
  try {
1592
- var p = t.evaluate(v, g, null, r, n);
1593
- f = He(g, p, W(n), r);
1736
+ var d = t.evaluate(p, h, null, r, n);
1737
+ f = Ge(h, d, x(n), r);
1594
1738
  } catch (y) {
1595
- s ?? (s = []), s.push(y), f = X(g, null, W(n), r, $(y), y);
1739
+ s ?? (s = []), s.push(y), f = z(h, null, x(n), r, _(y), y);
1596
1740
  }
1597
1741
  a.push(f);
1598
1742
  }
1599
1743
  return [a, s];
1600
1744
  }
1601
- function he(t, e, r) {
1745
+ function ye(t, e, r) {
1602
1746
  return t ? !0 : (e.configJsonIsNotPresent(r), !1);
1603
1747
  }
1604
- function _e(t) {
1748
+ function Je(t) {
1605
1749
  return t == null || typeof t == "boolean" || typeof t == "number" || typeof t == "string";
1606
1750
  }
1607
- function W(t) {
1751
+ function x(t) {
1608
1752
  return t ? new Date(t.timestamp) : void 0;
1609
1753
  }
1610
- function Nt(t) {
1754
+ function It(t) {
1611
1755
  return Object.keys(t).map(function(e) {
1612
- return "'".concat(e, "'");
1756
+ return "'" + e + "'";
1613
1757
  }).join(", ");
1614
1758
  }
1615
- var Lt = function() {
1616
- function t() {
1617
- this.instances = {};
1618
- }
1619
- return t.prototype.getOrCreate = function(e, r) {
1620
- var n, i = this.instances[e.apiKey];
1621
- if (i) {
1622
- var o = i[0];
1623
- if (n = o.deref(), n)
1624
- return [n, !0];
1625
- }
1626
- var s = {};
1627
- n = new ve(e, r, s);
1628
- var a = yt() ? WeakRef : dt();
1629
- return this.instances[e.apiKey] = [new a(n), s], [n, !1];
1630
- }, t.prototype.remove = function(e, r) {
1631
- var n = this.instances[e];
1632
- if (n) {
1633
- var i = n[0], o = n[1], s = !!i.deref();
1634
- if (!s || o === r)
1635
- return delete this.instances[e], s;
1636
- }
1637
- return !1;
1638
- }, t.prototype.clear = function() {
1639
- for (var e = [], r = 0, n = Object.entries(this.instances); r < n.length; r++) {
1640
- var i = n[r], o = i[0], s = i[1][0], a = s.deref();
1641
- a && e.push(a), delete this.instances[o];
1759
+ var Nt = (
1760
+ /** @class */
1761
+ function() {
1762
+ function t() {
1763
+ this.instances = {};
1642
1764
  }
1643
- return e;
1644
- }, t;
1645
- }(), G = new Lt(), ve = function() {
1646
- function t(e, r, n) {
1647
- var i;
1648
- if (this.cacheToken = n, this.addListener = this.on, this.off = this.removeListener, !e)
1649
- throw new Error("Invalid 'options' value");
1650
- if (this.options = e, this.options.logger.debug("Initializing ConfigCatClient. Options: " + JSON.stringify(this.options)), !r)
1651
- throw new Error("Invalid 'configCatKernel' value");
1652
- if (!r.configFetcher)
1653
- throw new Error("Invalid 'configCatKernel.configFetcher' value");
1654
- if (e.defaultUser && this.setDefaultUser(e.defaultUser), this.evaluator = new It(e.logger), ((i = e.flagOverrides) === null || i === void 0 ? void 0 : i.behaviour) !== M.LocalOnly) {
1655
- var o = e instanceof Ue ? nt : e instanceof Ve ? ft : e instanceof Me ? lt : function() {
1656
- throw new Error("Invalid 'options' value");
1657
- }();
1658
- this.configService = new o(r.configFetcher, e);
1659
- } else
1660
- this.options.hooks.emit("clientReady");
1661
- this.suppressFinalize = re(this, { sdkKey: e.apiKey, cacheToken: n, configService: this.configService, logger: e.logger });
1662
- }
1663
- return Object.defineProperty(t, "instanceCache", {
1664
- get: function() {
1665
- return G;
1666
- },
1667
- enumerable: !1,
1668
- configurable: !0
1669
- }), t.get = function(e, r, n, i) {
1670
- if (!e)
1671
- throw new Error("Invalid 'sdkKey' value");
1672
- var o = r === U.AutoPoll ? Ue : r === U.ManualPoll ? Ve : r === U.LazyLoad ? Me : function() {
1673
- throw new Error("Invalid 'pollingMode' value");
1674
- }(), s = new o(e, i.sdkType, i.sdkVersion, n, i.defaultCacheFactory, i.eventEmitterFactory), a = G.getOrCreate(s, i), u = a[0], c = a[1];
1675
- return c && n && s.logger.clientIsAlreadyCreated(e), u;
1676
- }, t.finalize = function(e) {
1677
- var r;
1678
- (r = e.logger) === null || r === void 0 || r.debug("finalize() called"), e.cacheToken && G.remove(e.sdkKey, e.cacheToken), t.close(e.configService, e.logger);
1679
- }, t.close = function(e, r, n) {
1680
- r == null || r.debug("close() called"), n == null || n.tryDisconnect(), e == null || e.dispose();
1681
- }, t.prototype.dispose = function() {
1682
- var e = this.options;
1683
- e.logger.debug("dispose() called"), this.cacheToken && G.remove(e.apiKey, this.cacheToken), t.close(this.configService, e.logger, e.hooks), this.suppressFinalize();
1684
- }, t.disposeAll = function() {
1685
- for (var e = G.clear(), r, n = 0, i = e; n < i.length; n++) {
1686
- var o = i[n];
1687
- try {
1688
- t.close(o.configService, o.options.logger, o.options.hooks), o.suppressFinalize();
1689
- } catch (s) {
1690
- r ?? (r = []), r.push(s);
1765
+ return t.prototype.getOrCreate = function(e, r) {
1766
+ var n, i = this.instances[e.apiKey];
1767
+ if (i) {
1768
+ var o = i[0];
1769
+ if (n = o.deref(), n)
1770
+ return [n, !0];
1771
+ }
1772
+ var s = {};
1773
+ n = new be(e, r, s);
1774
+ var a = vt() ? WeakRef : dt();
1775
+ return this.instances[e.apiKey] = [new a(n), s], [n, !1];
1776
+ }, t.prototype.remove = function(e, r) {
1777
+ var n = this.instances[e];
1778
+ if (n) {
1779
+ var i = n[0], o = n[1], s = !!i.deref();
1780
+ if (!s || o === r)
1781
+ return delete this.instances[e], s;
1782
+ }
1783
+ return !1;
1784
+ }, t.prototype.clear = function() {
1785
+ for (var e = [], r = 0, n = Object.entries(this.instances); r < n.length; r++) {
1786
+ var i = n[r], o = i[0], s = i[1][0], a = s.deref();
1787
+ a && e.push(a), delete this.instances[o];
1691
1788
  }
1789
+ return e;
1790
+ }, t;
1791
+ }()
1792
+ ), Y = new Nt(), be = (
1793
+ /** @class */
1794
+ function() {
1795
+ function t(e, r, n) {
1796
+ var i;
1797
+ if (this.cacheToken = n, this.addListener = this.on, this.off = this.removeListener, !e)
1798
+ throw new Error("Invalid 'options' value");
1799
+ if (this.options = e, this.options.logger.debug("Initializing ConfigCatClient. Options: " + JSON.stringify(this.options)), !r)
1800
+ throw new Error("Invalid 'configCatKernel' value");
1801
+ if (!r.configFetcher)
1802
+ throw new Error("Invalid 'configCatKernel.configFetcher' value");
1803
+ e.defaultUser && this.setDefaultUser(e.defaultUser), this.evaluator = new Tt(e.logger), ((i = e.flagOverrides) === null || i === void 0 ? void 0 : i.behaviour) !== P.LocalOnly ? this.configService = e instanceof He ? new tt(r.configFetcher, e) : e instanceof je ? new lt(r.configFetcher, e) : e instanceof qe ? new ct(r.configFetcher, e) : function() {
1804
+ throw new Error("Invalid 'options' value");
1805
+ }() : this.options.hooks.emit("clientReady", T.HasLocalOverrideFlagDataOnly), this.suppressFinalize = se(this, { sdkKey: e.apiKey, cacheToken: n, configService: this.configService, logger: e.logger });
1692
1806
  }
1693
- if (r)
1694
- throw typeof AggregateError < "u" ? new AggregateError(r) : r.pop();
1695
- }, t.prototype.getValueAsync = function(e, r, n) {
1696
- return S(this, void 0, void 0, function() {
1697
- var i, o, s, a, u, c;
1698
- return O(this, function(l) {
1699
- switch (l.label) {
1700
- case 0:
1701
- this.options.logger.debug("getValueAsync() called."), We(e), ze(r), s = null, n ?? (n = this.defaultUser), l.label = 1;
1702
- case 1:
1703
- return l.trys.push([1, 3, , 4]), a = void 0, [4, this.getSettingsAsync()];
1704
- case 2:
1705
- return c = l.sent(), a = c[0], s = c[1], o = je(this.evaluator, a, e, r, n, s, this.options.logger), i = o.value, [3, 4];
1706
- case 3:
1707
- return u = l.sent(), this.options.logger.settingEvaluationErrorSingle("getValueAsync", e, "defaultValue", r, u), o = X(e, r, W(s), n, $(u), u), i = r, [3, 4];
1708
- case 4:
1709
- return this.options.hooks.emit("flagEvaluated", o), [2, i];
1807
+ return Object.defineProperty(t, "instanceCache", {
1808
+ get: function() {
1809
+ return Y;
1810
+ },
1811
+ enumerable: !1,
1812
+ configurable: !0
1813
+ }), t.get = function(e, r, n, i) {
1814
+ if (!e)
1815
+ throw new Error("Invalid 'sdkKey' value");
1816
+ var o = r === j.AutoPoll ? He : r === j.ManualPoll ? je : r === j.LazyLoad ? qe : function() {
1817
+ throw new Error("Invalid 'pollingMode' value");
1818
+ }(), s = new o(e, i.sdkType, i.sdkVersion, n, i.defaultCacheFactory, i.eventEmitterFactory), a = Y.getOrCreate(s, i), c = a[0], u = a[1];
1819
+ return u && n && s.logger.clientIsAlreadyCreated(e), c;
1820
+ }, t.finalize = function(e) {
1821
+ var r;
1822
+ (r = e.logger) === null || r === void 0 || r.debug("finalize() called"), e.cacheToken && Y.remove(e.sdkKey, e.cacheToken), t.close(e.configService, e.logger);
1823
+ }, t.close = function(e, r, n) {
1824
+ r == null || r.debug("close() called"), n == null || n.tryDisconnect(), e == null || e.dispose();
1825
+ }, t.prototype.dispose = function() {
1826
+ var e = this.options;
1827
+ e.logger.debug("dispose() called"), this.cacheToken && Y.remove(e.apiKey, this.cacheToken), t.close(this.configService, e.logger, e.hooks), this.suppressFinalize();
1828
+ }, t.disposeAll = function() {
1829
+ for (var e = Y.clear(), r, n = 0, i = e; n < i.length; n++) {
1830
+ var o = i[n];
1831
+ try {
1832
+ t.close(o.configService, o.options.logger, o.options.hooks), o.suppressFinalize();
1833
+ } catch (s) {
1834
+ r ?? (r = []), r.push(s);
1710
1835
  }
1836
+ }
1837
+ if (r)
1838
+ throw typeof AggregateError < "u" ? new AggregateError(r) : r.pop();
1839
+ }, t.prototype.getValueAsync = function(e, r, n) {
1840
+ return S(this, void 0, void 0, function() {
1841
+ var i, o, s, a, c, u;
1842
+ return O(this, function(l) {
1843
+ switch (l.label) {
1844
+ case 0:
1845
+ this.options.logger.debug("getValueAsync() called."), fe(e), he(r), s = null, n ?? (n = this.defaultUser), l.label = 1;
1846
+ case 1:
1847
+ return l.trys.push([1, 3, , 4]), a = void 0, [4, this.getSettingsAsync()];
1848
+ case 2:
1849
+ return u = l.sent(), a = u[0], s = u[1], o = le(this.evaluator, a, e, r, n, s, this.options.logger), i = o.value, [3, 4];
1850
+ case 3:
1851
+ return c = l.sent(), this.options.logger.settingEvaluationErrorSingle("getValueAsync", e, "defaultValue", r, c), o = z(e, r, x(s), n, _(c), c), i = r, [3, 4];
1852
+ case 4:
1853
+ return this.options.hooks.emit("flagEvaluated", o), [2, i];
1854
+ }
1855
+ });
1711
1856
  });
1712
- });
1713
- }, t.prototype.getValueDetailsAsync = function(e, r, n) {
1714
- return S(this, void 0, void 0, function() {
1715
- var i, o, s, a, u;
1716
- return O(this, function(c) {
1717
- switch (c.label) {
1718
- case 0:
1719
- this.options.logger.debug("getValueDetailsAsync() called."), We(e), ze(r), o = null, n ?? (n = this.defaultUser), c.label = 1;
1720
- case 1:
1721
- return c.trys.push([1, 3, , 4]), s = void 0, [4, this.getSettingsAsync()];
1722
- case 2:
1723
- return u = c.sent(), s = u[0], o = u[1], i = je(this.evaluator, s, e, r, n, o, this.options.logger), [3, 4];
1724
- case 3:
1725
- return a = c.sent(), this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync", e, "defaultValue", r, a), i = X(e, r, W(o), n, $(a), a), [3, 4];
1726
- case 4:
1727
- return this.options.hooks.emit("flagEvaluated", i), [2, i];
1728
- }
1857
+ }, t.prototype.getValueDetailsAsync = function(e, r, n) {
1858
+ return S(this, void 0, void 0, function() {
1859
+ var i, o, s, a, c;
1860
+ return O(this, function(u) {
1861
+ switch (u.label) {
1862
+ case 0:
1863
+ this.options.logger.debug("getValueDetailsAsync() called."), fe(e), he(r), o = null, n ?? (n = this.defaultUser), u.label = 1;
1864
+ case 1:
1865
+ return u.trys.push([1, 3, , 4]), s = void 0, [4, this.getSettingsAsync()];
1866
+ case 2:
1867
+ return c = u.sent(), s = c[0], o = c[1], i = le(this.evaluator, s, e, r, n, o, this.options.logger), [3, 4];
1868
+ case 3:
1869
+ return a = u.sent(), this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync", e, "defaultValue", r, a), i = z(e, r, x(o), n, _(a), a), [3, 4];
1870
+ case 4:
1871
+ return this.options.hooks.emit("flagEvaluated", i), [2, i];
1872
+ }
1873
+ });
1729
1874
  });
1730
- });
1731
- }, t.prototype.getAllKeysAsync = function() {
1732
- return S(this, void 0, void 0, function() {
1733
- var e, r, n;
1734
- return O(this, function(i) {
1735
- switch (i.label) {
1736
- case 0:
1737
- this.options.logger.debug("getAllKeysAsync() called."), e = "empty array", i.label = 1;
1738
- case 1:
1739
- return i.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1740
- case 2:
1741
- return r = i.sent()[0], he(r, this.options.logger, e) ? [2, Object.keys(r)] : [2, []];
1742
- case 3:
1743
- return n = i.sent(), this.options.logger.settingEvaluationError("getAllKeysAsync", e, n), [2, []];
1744
- case 4:
1745
- return [2];
1746
- }
1875
+ }, t.prototype.getAllKeysAsync = function() {
1876
+ return S(this, void 0, void 0, function() {
1877
+ var e, r, n;
1878
+ return O(this, function(i) {
1879
+ switch (i.label) {
1880
+ case 0:
1881
+ this.options.logger.debug("getAllKeysAsync() called."), e = "empty array", i.label = 1;
1882
+ case 1:
1883
+ return i.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1884
+ case 2:
1885
+ return r = i.sent()[0], ye(r, this.options.logger, e) ? [2, Object.keys(r)] : [2, []];
1886
+ case 3:
1887
+ return n = i.sent(), this.options.logger.settingEvaluationError("getAllKeysAsync", e, n), [2, []];
1888
+ case 4:
1889
+ return [
1890
+ 2
1891
+ /*return*/
1892
+ ];
1893
+ }
1894
+ });
1747
1895
  });
1748
- });
1749
- }, t.prototype.getAllValuesAsync = function(e) {
1750
- return S(this, void 0, void 0, function() {
1751
- var r, n, i, o, s, a, u, c, l, g, v, f;
1752
- return O(this, function(p) {
1753
- switch (p.label) {
1754
- case 0:
1755
- this.options.logger.debug("getAllValuesAsync() called."), r = "empty array", e ?? (e = this.defaultUser), p.label = 1;
1756
- case 1:
1757
- return p.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1758
- case 2:
1759
- if (i = p.sent(), o = i[0], s = i[1], a = void 0, f = Ke(this.evaluator, o, e, s, this.options.logger, r), n = f[0], a = f[1], a != null && a.length)
1760
- throw typeof AggregateError < "u" ? new AggregateError(a) : a.pop();
1761
- return [3, 4];
1762
- case 3:
1763
- return u = p.sent(), this.options.logger.settingEvaluationError("getAllValuesAsync", r, u), n ?? (n = []), [3, 4];
1764
- case 4:
1765
- for (c = n.map(function(y) {
1766
- return new Q(y.key, y.value);
1767
- }), l = 0, g = n; l < g.length; l++)
1768
- v = g[l], this.options.hooks.emit("flagEvaluated", v);
1769
- return [2, c];
1770
- }
1896
+ }, t.prototype.getAllValuesAsync = function(e) {
1897
+ return S(this, void 0, void 0, function() {
1898
+ var r, n, i, o, s, a, c, u, l, h, p, f;
1899
+ return O(this, function(d) {
1900
+ switch (d.label) {
1901
+ case 0:
1902
+ this.options.logger.debug("getAllValuesAsync() called."), r = "empty array", e ?? (e = this.defaultUser), d.label = 1;
1903
+ case 1:
1904
+ return d.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1905
+ case 2:
1906
+ return s = d.sent(), a = s[0], c = s[1], f = Ke(this.evaluator, a, e, c, this.options.logger, r), i = f[0], o = f[1], n = i.map(function(y) {
1907
+ return new ne(y.key, y.value);
1908
+ }), [3, 4];
1909
+ case 3:
1910
+ return u = d.sent(), this.options.logger.settingEvaluationError("getAllValuesAsync", r, u), [2, []];
1911
+ case 4:
1912
+ for (o != null && o.length && this.options.logger.settingEvaluationError("getAllValuesAsync", "evaluation result", typeof AggregateError < "u" ? new AggregateError(o) : o.pop()), l = 0, h = i; l < h.length; l++)
1913
+ p = h[l], this.options.hooks.emit("flagEvaluated", p);
1914
+ return [2, n];
1915
+ }
1916
+ });
1771
1917
  });
1772
- });
1773
- }, t.prototype.getAllValueDetailsAsync = function(e) {
1774
- return S(this, void 0, void 0, function() {
1775
- var r, n, i, o, s, a, u, c, l, g, v;
1776
- return O(this, function(f) {
1777
- switch (f.label) {
1778
- case 0:
1779
- this.options.logger.debug("getAllValueDetailsAsync() called."), r = "empty array", e ?? (e = this.defaultUser), f.label = 1;
1780
- case 1:
1781
- return f.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1782
- case 2:
1783
- if (i = f.sent(), o = i[0], s = i[1], a = void 0, v = Ke(this.evaluator, o, e, s, this.options.logger, r), n = v[0], a = v[1], a != null && a.length)
1784
- throw typeof AggregateError < "u" ? new AggregateError(a) : a.pop();
1785
- return [3, 4];
1786
- case 3:
1787
- return u = f.sent(), this.options.logger.settingEvaluationError("getAllValueDetailsAsync", r, u), n ?? (n = []), [3, 4];
1788
- case 4:
1789
- for (c = 0, l = n; c < l.length; c++)
1790
- g = l[c], this.options.hooks.emit("flagEvaluated", g);
1791
- return [2, n];
1792
- }
1918
+ }, t.prototype.getAllValueDetailsAsync = function(e) {
1919
+ return S(this, void 0, void 0, function() {
1920
+ var r, n, i, o, s, a, c, u, l, h, p;
1921
+ return O(this, function(f) {
1922
+ switch (f.label) {
1923
+ case 0:
1924
+ this.options.logger.debug("getAllValueDetailsAsync() called."), r = "empty array", e ?? (e = this.defaultUser), f.label = 1;
1925
+ case 1:
1926
+ return f.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1927
+ case 2:
1928
+ return o = f.sent(), s = o[0], a = o[1], p = Ke(this.evaluator, s, e, a, this.options.logger, r), n = p[0], i = p[1], [3, 4];
1929
+ case 3:
1930
+ return c = f.sent(), this.options.logger.settingEvaluationError("getAllValueDetailsAsync", r, c), [2, []];
1931
+ case 4:
1932
+ for (i != null && i.length && this.options.logger.settingEvaluationError("getAllValueDetailsAsync", "evaluation result", typeof AggregateError < "u" ? new AggregateError(i) : i.pop()), u = 0, l = n; u < l.length; u++)
1933
+ h = l[u], this.options.hooks.emit("flagEvaluated", h);
1934
+ return [2, n];
1935
+ }
1936
+ });
1793
1937
  });
1794
- });
1795
- }, t.prototype.getKeyAndValueAsync = function(e) {
1796
- return S(this, void 0, void 0, function() {
1797
- var r, n, i, o, s, a, u, c, v, l, g, v, f, p;
1798
- return O(this, function(y) {
1799
- switch (y.label) {
1800
- case 0:
1801
- this.options.logger.debug("getKeyAndValueAsync() called."), r = "null", y.label = 1;
1802
- case 1:
1803
- return y.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1804
- case 2:
1805
- if (n = y.sent()[0], !he(n, this.options.logger, r))
1806
- return [2, null];
1807
- for (i = 0, o = Object.entries(n); i < o.length; i++) {
1808
- if (s = o[i], a = s[0], u = s[1], e === u.variationId)
1809
- return [2, new Q(a, u.value)];
1810
- if (c = n[a].targetingRules, c && c.length > 0) {
1811
- for (v = 0; v < c.length; v++)
1812
- if (l = c[v], e === l.variationId)
1813
- return [2, new Q(a, l.value)];
1814
- }
1815
- if (g = n[a].percentageOptions, g && g.length > 0) {
1816
- for (v = 0; v < g.length; v++)
1817
- if (f = g[v], e === f.variationId)
1818
- return [2, new Q(a, f.value)];
1938
+ }, t.prototype.getKeyAndValueAsync = function(e) {
1939
+ return S(this, void 0, void 0, function() {
1940
+ var r, n, i, o, s, a, c, u, p, l, h, p, f, d;
1941
+ return O(this, function(y) {
1942
+ switch (y.label) {
1943
+ case 0:
1944
+ this.options.logger.debug("getKeyAndValueAsync() called."), r = "null", y.label = 1;
1945
+ case 1:
1946
+ return y.trys.push([1, 3, , 4]), [4, this.getSettingsAsync()];
1947
+ case 2:
1948
+ if (n = y.sent()[0], !ye(n, this.options.logger, r))
1949
+ return [2, null];
1950
+ for (i = 0, o = Object.entries(n); i < o.length; i++) {
1951
+ if (s = o[i], a = s[0], c = s[1], e === c.variationId)
1952
+ return [2, new ne(a, c.value)];
1953
+ if (u = n[a].targetingRules, u && u.length > 0) {
1954
+ for (p = 0; p < u.length; p++)
1955
+ if (l = u[p], e === l.variationId)
1956
+ return [2, new ne(a, l.value)];
1957
+ }
1958
+ if (h = n[a].percentageOptions, h && h.length > 0) {
1959
+ for (p = 0; p < h.length; p++)
1960
+ if (f = h[p], e === f.variationId)
1961
+ return [2, new ne(a, f.value)];
1962
+ }
1819
1963
  }
1820
- }
1821
- return this.options.logger.settingForVariationIdIsNotPresent(e), [3, 4];
1822
- case 3:
1823
- return p = y.sent(), this.options.logger.settingEvaluationError("getKeyAndValueAsync", r, p), [3, 4];
1824
- case 4:
1825
- return [2, null];
1826
- }
1827
- });
1828
- });
1829
- }, t.prototype.forceRefreshAsync = function() {
1830
- return S(this, void 0, void 0, function() {
1831
- var e, r;
1832
- return O(this, function(n) {
1833
- switch (n.label) {
1834
- case 0:
1835
- if (this.options.logger.debug("forceRefreshAsync() called."), !this.configService)
1836
- return [3, 5];
1837
- n.label = 1;
1838
- case 1:
1839
- return n.trys.push([1, 3, , 4]), [4, this.configService.refreshConfigAsync()];
1840
- case 2:
1841
- return e = n.sent()[0], [2, e];
1842
- case 3:
1843
- return r = n.sent(), this.options.logger.forceRefreshError("forceRefreshAsync", r), [2, ne.failure($(r), r)];
1844
- case 4:
1845
- return [3, 6];
1846
- case 5:
1847
- return [2, ne.failure("Client is configured to use the LocalOnly override behavior, which prevents making HTTP requests.")];
1848
- case 6:
1849
- return [2];
1850
- }
1964
+ return this.options.logger.settingForVariationIdIsNotPresent(e), [3, 4];
1965
+ case 3:
1966
+ return d = y.sent(), this.options.logger.settingEvaluationError("getKeyAndValueAsync", r, d), [3, 4];
1967
+ case 4:
1968
+ return [2, null];
1969
+ }
1970
+ });
1851
1971
  });
1852
- });
1853
- }, t.prototype.setDefaultUser = function(e) {
1854
- this.defaultUser = e;
1855
- }, t.prototype.clearDefaultUser = function() {
1856
- this.defaultUser = void 0;
1857
- }, Object.defineProperty(t.prototype, "isOffline", {
1858
- get: function() {
1859
- var e, r;
1860
- return (r = (e = this.configService) === null || e === void 0 ? void 0 : e.isOffline) !== null && r !== void 0 ? r : !0;
1861
- },
1862
- enumerable: !1,
1863
- configurable: !0
1864
- }), t.prototype.setOnline = function() {
1865
- this.configService ? this.configService.setOnline() : this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(M[M.LocalOnly], "setOnline");
1866
- }, t.prototype.setOffline = function() {
1867
- var e;
1868
- (e = this.configService) === null || e === void 0 || e.setOffline();
1869
- }, t.prototype.getSettingsAsync = function() {
1870
- var e;
1871
- return S(this, void 0, void 0, function() {
1872
- var r, n, i, o, s, a, u, c, l = this;
1873
- return O(this, function(g) {
1874
- switch (g.label) {
1875
- case 0:
1876
- return this.options.logger.debug("getSettingsAsync() called."), r = function() {
1877
- return S(l, void 0, void 0, function() {
1878
- var v, f;
1879
- return O(this, function(p) {
1880
- switch (p.label) {
1881
- case 0:
1882
- return [4, this.configService.getConfig()];
1883
- case 1:
1884
- return v = p.sent(), f = v.isEmpty ? null : v.config.settings, [2, [f, v]];
1885
- }
1886
- });
1887
- });
1888
- }, n = (e = this.options) === null || e === void 0 ? void 0 : e.flagOverrides, n ? (i = void 0, o = void 0, [4, n.dataSource.getOverrides()]) : [3, 7];
1889
- case 1:
1890
- switch (s = g.sent(), a = n.behaviour, a) {
1891
- case M.LocalOnly:
1892
- return [3, 2];
1893
- case M.LocalOverRemote:
1894
- return [3, 3];
1895
- case M.RemoteOverLocal:
1972
+ }, t.prototype.forceRefreshAsync = function() {
1973
+ return S(this, void 0, void 0, function() {
1974
+ var e, r;
1975
+ return O(this, function(n) {
1976
+ switch (n.label) {
1977
+ case 0:
1978
+ if (this.options.logger.debug("forceRefreshAsync() called."), !this.configService)
1896
1979
  return [3, 5];
1897
- }
1898
- return [3, 7];
1899
- case 2:
1900
- return [2, [s, null]];
1901
- case 3:
1902
- return [4, r()];
1903
- case 4:
1904
- return u = g.sent(), i = u[0], o = u[1], [2, [q(q({}, i ?? {}), s), o]];
1905
- case 5:
1906
- return [4, r()];
1907
- case 6:
1908
- return c = g.sent(), i = c[0], o = c[1], [2, [q(q({}, s), i ?? {}), o]];
1909
- case 7:
1910
- return [4, r()];
1911
- case 8:
1912
- return [2, g.sent()];
1980
+ n.label = 1;
1981
+ case 1:
1982
+ return n.trys.push([1, 3, , 4]), [4, this.configService.refreshConfigAsync()];
1983
+ case 2:
1984
+ return e = n.sent()[0], [2, e];
1985
+ case 3:
1986
+ return r = n.sent(), this.options.logger.forceRefreshError("forceRefreshAsync", r), [2, ae.failure(_(r), r)];
1987
+ case 4:
1988
+ return [3, 6];
1989
+ case 5:
1990
+ return [2, ae.failure("Client is configured to use the LocalOnly override behavior, which prevents making HTTP requests.")];
1991
+ case 6:
1992
+ return [
1993
+ 2
1994
+ /*return*/
1995
+ ];
1996
+ }
1997
+ });
1998
+ });
1999
+ }, t.prototype.setDefaultUser = function(e) {
2000
+ this.defaultUser = e;
2001
+ }, t.prototype.clearDefaultUser = function() {
2002
+ this.defaultUser = void 0;
2003
+ }, Object.defineProperty(t.prototype, "isOffline", {
2004
+ get: function() {
2005
+ var e, r;
2006
+ return (r = (e = this.configService) === null || e === void 0 ? void 0 : e.isOffline) !== null && r !== void 0 ? r : !0;
2007
+ },
2008
+ enumerable: !1,
2009
+ configurable: !0
2010
+ }), t.prototype.setOnline = function() {
2011
+ this.configService ? this.configService.setOnline() : this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(P[P.LocalOnly], "setOnline");
2012
+ }, t.prototype.setOffline = function() {
2013
+ var e;
2014
+ (e = this.configService) === null || e === void 0 || e.setOffline();
2015
+ }, t.prototype.waitForReady = function() {
2016
+ return this.options.readyPromise;
2017
+ }, t.prototype.snapshot = function() {
2018
+ var e, r, n, i = this, o, s = function() {
2019
+ var h = i.options.cache.getInMemory(), p = h.isEmpty ? null : h.config.settings;
2020
+ return [p, h];
2021
+ }, a, c, u = (o = this.options) === null || o === void 0 ? void 0 : o.flagOverrides;
2022
+ if (u) {
2023
+ var l = u.dataSource.getOverridesSync();
2024
+ switch (u.behaviour) {
2025
+ case P.LocalOnly:
2026
+ return new re(l, null, this);
2027
+ case P.LocalOverRemote:
2028
+ return e = s(), a = e[0], c = e[1], new re(k(k({}, a ?? {}), l), c, this);
2029
+ case P.RemoteOverLocal:
2030
+ return r = s(), a = r[0], c = r[1], new re(k(k({}, l), a ?? {}), c, this);
1913
2031
  }
2032
+ }
2033
+ return n = s(), a = n[0], c = n[1], new re(a, c, this);
2034
+ }, t.prototype.getSettingsAsync = function() {
2035
+ var e;
2036
+ return S(this, void 0, void 0, function() {
2037
+ var r, n, i, o, s, a, c, u, l = this;
2038
+ return O(this, function(h) {
2039
+ switch (h.label) {
2040
+ case 0:
2041
+ return this.options.logger.debug("getSettingsAsync() called."), r = function() {
2042
+ return S(l, void 0, void 0, function() {
2043
+ var p, f;
2044
+ return O(this, function(d) {
2045
+ switch (d.label) {
2046
+ case 0:
2047
+ return [4, this.configService.getConfig()];
2048
+ case 1:
2049
+ return p = d.sent(), f = p.isEmpty ? null : p.config.settings, [2, [f, p]];
2050
+ }
2051
+ });
2052
+ });
2053
+ }, n = (e = this.options) === null || e === void 0 ? void 0 : e.flagOverrides, n ? (i = void 0, o = void 0, [4, n.dataSource.getOverrides()]) : [3, 7];
2054
+ case 1:
2055
+ switch (s = h.sent(), a = n.behaviour, a) {
2056
+ case P.LocalOnly:
2057
+ return [3, 2];
2058
+ case P.LocalOverRemote:
2059
+ return [3, 3];
2060
+ case P.RemoteOverLocal:
2061
+ return [3, 5];
2062
+ }
2063
+ return [3, 7];
2064
+ case 2:
2065
+ return [2, [s, null]];
2066
+ case 3:
2067
+ return [4, r()];
2068
+ case 4:
2069
+ return c = h.sent(), i = c[0], o = c[1], [2, [k(k({}, i ?? {}), s), o]];
2070
+ case 5:
2071
+ return [4, r()];
2072
+ case 6:
2073
+ return u = h.sent(), i = u[0], o = u[1], [2, [k(k({}, s), i ?? {}), o]];
2074
+ case 7:
2075
+ return [4, r()];
2076
+ case 8:
2077
+ return [2, h.sent()];
2078
+ }
2079
+ });
1914
2080
  });
1915
- });
1916
- }, t.prototype.on = function(e, r) {
1917
- return this.options.hooks.on(e, r), this;
1918
- }, t.prototype.once = function(e, r) {
1919
- return this.options.hooks.once(e, r), this;
1920
- }, t.prototype.removeListener = function(e, r) {
1921
- return this.options.hooks.removeListener(e, r), this;
1922
- }, t.prototype.removeAllListeners = function(e) {
1923
- return this.options.hooks.removeAllListeners(e), this;
1924
- }, t.prototype.listeners = function(e) {
1925
- return this.options.hooks.listeners(e);
1926
- }, t.prototype.listenerCount = function(e) {
1927
- return this.options.hooks.listenerCount(e);
1928
- }, t.prototype.eventNames = function() {
1929
- return this.options.hooks.eventNames();
1930
- }, t;
1931
- }(), Q = function() {
1932
- function t(e, r) {
1933
- this.settingKey = e, this.settingValue = r;
1934
- }
1935
- return t;
1936
- }();
1937
- function We(t) {
2081
+ }, t.prototype.on = function(e, r) {
2082
+ return this.options.hooks.on(e, r), this;
2083
+ }, t.prototype.once = function(e, r) {
2084
+ return this.options.hooks.once(e, r), this;
2085
+ }, t.prototype.removeListener = function(e, r) {
2086
+ return this.options.hooks.removeListener(e, r), this;
2087
+ }, t.prototype.removeAllListeners = function(e) {
2088
+ return this.options.hooks.removeAllListeners(e), this;
2089
+ }, t.prototype.listeners = function(e) {
2090
+ return this.options.hooks.listeners(e);
2091
+ }, t.prototype.listenerCount = function(e) {
2092
+ return this.options.hooks.listenerCount(e);
2093
+ }, t.prototype.eventNames = function() {
2094
+ return this.options.hooks.eventNames();
2095
+ }, t;
2096
+ }()
2097
+ ), re = (
2098
+ /** @class */
2099
+ function() {
2100
+ function t(e, r, n) {
2101
+ this.mergedSettings = e, this.remoteConfig = r, this.defaultUser = n.defaultUser, this.evaluator = n.evaluator, this.options = n.options, this.cacheState = r ? n.configService.getCacheState(r) : T.HasLocalOverrideFlagDataOnly;
2102
+ }
2103
+ return Object.defineProperty(t.prototype, "fetchedConfig", {
2104
+ get: function() {
2105
+ var e = this.remoteConfig;
2106
+ return e && !e.isEmpty ? e.config : null;
2107
+ },
2108
+ enumerable: !1,
2109
+ configurable: !0
2110
+ }), t.prototype.getAllKeys = function() {
2111
+ return this.mergedSettings ? Object.keys(this.mergedSettings) : [];
2112
+ }, t.prototype.getValue = function(e, r, n) {
2113
+ this.options.logger.debug("Snapshot.getValue() called."), fe(e), he(r);
2114
+ var i, o;
2115
+ n ?? (n = this.defaultUser);
2116
+ try {
2117
+ o = le(this.evaluator, this.mergedSettings, e, r, n, this.remoteConfig, this.options.logger), i = o.value;
2118
+ } catch (s) {
2119
+ this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue", e, "defaultValue", r, s), o = z(e, r, x(this.remoteConfig), n, _(s), s), i = r;
2120
+ }
2121
+ return this.options.hooks.emit("flagEvaluated", o), i;
2122
+ }, t.prototype.getValueDetails = function(e, r, n) {
2123
+ this.options.logger.debug("Snapshot.getValueDetails() called."), fe(e), he(r);
2124
+ var i;
2125
+ n ?? (n = this.defaultUser);
2126
+ try {
2127
+ i = le(this.evaluator, this.mergedSettings, e, r, n, this.remoteConfig, this.options.logger);
2128
+ } catch (o) {
2129
+ this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails", e, "defaultValue", r, o), i = z(e, r, x(this.remoteConfig), n, _(o), o);
2130
+ }
2131
+ return this.options.hooks.emit("flagEvaluated", i), i;
2132
+ }, t;
2133
+ }()
2134
+ ), ne = (
2135
+ /** @class */
2136
+ function() {
2137
+ function t(e, r) {
2138
+ this.settingKey = e, this.settingValue = r;
2139
+ }
2140
+ return t;
2141
+ }()
2142
+ );
2143
+ function fe(t) {
1938
2144
  if (!t)
1939
2145
  throw new Error("Invalid 'key' value");
1940
2146
  }
1941
- function ze(t) {
1942
- if (!_e(t))
2147
+ function he(t) {
2148
+ if (!Je(t))
1943
2149
  throw new TypeError("The default value must be boolean, number, string, null or undefined.");
1944
2150
  }
1945
- var re = function(t, e) {
2151
+ var se = function(t, e) {
1946
2152
  if (typeof FinalizationRegistry < "u") {
1947
2153
  var r = new FinalizationRegistry(function(n) {
1948
- return ve.finalize(n);
2154
+ return be.finalize(n);
1949
2155
  });
1950
- re = function(n, i) {
2156
+ se = function(n, i) {
1951
2157
  var o = {};
1952
2158
  return r.register(n, i, o), function() {
1953
2159
  return r.unregister(o);
1954
2160
  };
1955
2161
  };
1956
2162
  } else
1957
- re = function() {
2163
+ se = function() {
1958
2164
  return function() {
1959
2165
  };
1960
2166
  };
1961
- return re(t, e);
2167
+ return se(t, e);
1962
2168
  };
1963
- ht();
1964
- function Rt(t, e, r, n) {
1965
- return ve.get(t, e, r, n);
2169
+ ft();
2170
+ function Lt(t, e, r, n) {
2171
+ return be.get(t, e, r, n);
1966
2172
  }
1967
- var Dt = function() {
1968
- function t() {
1969
- }
1970
- return t.prototype.set = function(e, r) {
1971
- try {
1972
- localStorage.setItem(e, btoa(r));
1973
- } catch {
1974
- }
1975
- }, t.prototype.get = function(e) {
1976
- try {
1977
- var r = localStorage.getItem(e);
1978
- if (r)
1979
- return atob(r);
1980
- } catch {
2173
+ function Rt(t) {
2174
+ return new Be(t);
2175
+ }
2176
+ const Dt = (t, e) => {
2177
+ const r = t.__vccOpts || t;
2178
+ for (const [n, i] of e)
2179
+ r[n] = i;
2180
+ return r;
2181
+ }, Ft = {
2182
+ emits: ["flagValueChanged"],
2183
+ props: {
2184
+ featureKey: {
2185
+ type: String,
2186
+ required: !0
2187
+ },
2188
+ userObject: {
2189
+ type: Object,
2190
+ required: !1,
2191
+ default: {}
1981
2192
  }
1982
- }, t;
1983
- }(), Ft = function() {
1984
- function t() {
2193
+ },
2194
+ data() {
2195
+ return {
2196
+ isFeatureFlagEnabled: null
2197
+ // `null` indicates that the feature flag value is not available yet
2198
+ };
2199
+ },
2200
+ beforeMount() {
2201
+ this.configChangedHandler = () => {
2202
+ const n = this.$configCat.client.snapshot().getValue(this.featureKey, !1, this.userObject);
2203
+ this.isFeatureFlagEnabled !== n && (this.isFeatureFlagEnabled = n, this.$emit("flagValueChanged", n));
2204
+ };
2205
+ const t = this.$configCat.client.snapshot(), e = t.cacheState;
2206
+ e == T.HasUpToDateFlagData || e == T.HasLocalOverrideFlagDataOnly ? (this.isFeatureFlagEnabled = t.getValue(this.featureKey, !1, this.userObject), this.$configCat.client.on("configChanged", this.configChangedHandler)) : this.$configCat.client.getValueAsync(this.featureKey, !1, this.userObject).then((r) => {
2207
+ const n = this.configChangedHandler;
2208
+ n && (this.isFeatureFlagEnabled = r, this.$configCat.client.on("configChanged", n));
2209
+ });
2210
+ },
2211
+ unmounted() {
2212
+ const t = this.configChangedHandler;
2213
+ delete this.configChangedHandler, this.$configCat.client.off("configChanged", t);
1985
2214
  }
1986
- return t.prototype.handleStateChange = function(e, r, n) {
1987
- var i;
2215
+ }, Pt = { key: 0 }, Ut = { key: 1 }, kt = { key: 2 };
2216
+ function Mt(t, e, r, n, i, o) {
2217
+ return Q(), ee("div", null, [
2218
+ i.isFeatureFlagEnabled === !0 ? (Q(), ee("div", Pt, [
2219
+ ge(t.$slots, "default")
2220
+ ])) : i.isFeatureFlagEnabled === !1 ? (Q(), ee("div", Ut, [
2221
+ ge(t.$slots, "else")
2222
+ ])) : (Q(), ee("div", kt, [
2223
+ ge(t.$slots, "loading")
2224
+ ]))
2225
+ ]);
2226
+ }
2227
+ const Kt = /* @__PURE__ */ Dt(Ft, [["render", Mt]]);
2228
+ class Vt {
2229
+ handleStateChange(e, r, n) {
1988
2230
  try {
1989
2231
  if (e.readyState === 4) {
1990
- var o = e.status, s = e.statusText;
1991
- if (o === 200) {
1992
- var a = (i = e.getResponseHeader("ETag")) !== null && i !== void 0 ? i : void 0;
1993
- r({ statusCode: o, reasonPhrase: s, eTag: a, body: e.responseText });
2232
+ const { status: i, statusText: o } = e;
2233
+ if (i === 200) {
2234
+ const s = e.getResponseHeader("ETag") ?? void 0;
2235
+ r({ statusCode: i, reasonPhrase: o, eTag: s, body: e.responseText });
1994
2236
  } else
1995
- o && r({ statusCode: o, reasonPhrase: s });
2237
+ i && r({ statusCode: i, reasonPhrase: o });
1996
2238
  }
1997
- } catch (u) {
1998
- n(u);
2239
+ } catch (i) {
2240
+ n(i);
1999
2241
  }
2000
- }, t.prototype.fetchLogic = function(e, r) {
2001
- var n = this;
2002
- return new Promise(function(i, o) {
2242
+ }
2243
+ fetchLogic(e) {
2244
+ return new Promise((r, n) => {
2003
2245
  try {
2004
2246
  e.logger.debug("HttpConfigFetcher.fetchLogic() called.");
2005
- var s = new XMLHttpRequest();
2006
- s.onreadystatechange = function() {
2007
- return n.handleStateChange(s, i, o);
2008
- }, s.ontimeout = function() {
2009
- return o(new ee("timeout", e.requestTimeoutMs));
2010
- }, s.onabort = function() {
2011
- return o(new ee("abort"));
2012
- }, s.onerror = function() {
2013
- return o(new ee("failure"));
2014
- }, s.open("GET", e.getUrl(), !0), s.timeout = e.requestTimeoutMs, s.send(null);
2015
- } catch (a) {
2016
- o(a);
2247
+ const i = new XMLHttpRequest();
2248
+ i.onreadystatechange = () => this.handleStateChange(i, r, n), i.ontimeout = () => n(new ie("timeout", e.requestTimeoutMs)), i.onabort = () => n(new ie("abort")), i.onerror = () => n(new ie("failure")), i.open("GET", e.getUrl(), !0), i.timeout = e.requestTimeoutMs, i.send(null);
2249
+ } catch (i) {
2250
+ n(i);
2017
2251
  }
2018
2252
  });
2019
- }, t;
2020
- }();
2021
- const kt = "8.0.2";
2022
- function ce(t, e, r) {
2023
- return Rt(t, e ?? U.AutoPoll, r, {
2024
- configFetcher: new Ft(),
2025
- sdkType: "ConfigCat-JS",
2026
- sdkVersion: kt,
2027
- defaultCacheFactory: function(n) {
2028
- return new qe(new Dt(), n.logger);
2253
+ }
2254
+ }
2255
+ class xt {
2256
+ set(e, r) {
2257
+ try {
2258
+ localStorage.setItem(e, btoa(r));
2259
+ } catch {
2029
2260
  }
2030
- });
2261
+ }
2262
+ get(e) {
2263
+ try {
2264
+ const r = localStorage.getItem(e);
2265
+ if (r)
2266
+ return atob(r);
2267
+ } catch {
2268
+ }
2269
+ }
2031
2270
  }
2032
- const Vt = {
2271
+ const Ht = "1.4.0", _t = {
2033
2272
  install: (t, e) => {
2034
- let r = ce(
2035
- e.SDKKey,
2036
- U.AutoPoll,
2037
- e.clientOptions
2273
+ let r = (
2274
+ // https://configcat.com/docs/sdk-reference/js/#manual-polling
2275
+ e.pollingMode === "manual" ? j.ManualPoll : (
2276
+ // https://configcat.com/docs/sdk-reference/js/#lazy-loading
2277
+ e.pollingMode === "lazy" ? j.LazyLoad : (
2278
+ // Auto poll is default
2279
+ j.AutoPoll
2280
+ )
2281
+ )
2038
2282
  );
2039
- e.pollingMode == "manual" && (r = ce(
2283
+ const n = Lt(
2040
2284
  e.SDKKey,
2041
- U.ManualPoll,
2042
- e.clientOptions
2043
- )), e.pollingMode == "lazy" && (r = ce(
2044
- e.SDKKey,
2045
- U.LazyLoad,
2046
- e.clientOptions
2047
- )), t.config.globalProperties.configCatClient = r;
2285
+ r,
2286
+ e.clientOptions,
2287
+ {
2288
+ sdkType: "ConfigCat-Vue",
2289
+ sdkVersion: Ht,
2290
+ configFetcher: new Vt(),
2291
+ defaultCacheFactory: (s) => new ze(new xt(), s.logger)
2292
+ }
2293
+ ), i = { client: n };
2294
+ t.config.globalProperties.$configCat = i;
2295
+ const o = t.unmount;
2296
+ t.unmount = function() {
2297
+ o.apply(this, arguments), n.dispose();
2298
+ };
2048
2299
  }
2049
2300
  };
2301
+ function zt(t) {
2302
+ return Rt(t);
2303
+ }
2304
+ function Bt(t, e) {
2305
+ return new ut(new at(t), e);
2306
+ }
2050
2307
  export {
2051
- Vt as ConfigCatPlugin,
2052
- Ut as FeatureWrapper
2308
+ qt as ClientReadyState,
2309
+ g as Comparator,
2310
+ _t as ConfigCatPlugin,
2311
+ ue as DataGovernance,
2312
+ Kt as FeatureWrapper,
2313
+ A as FormattableLogMessage,
2314
+ v as LogLevel,
2315
+ P as OverrideBehaviour,
2316
+ j as PollingMode,
2317
+ ae as RefreshResult,
2318
+ ne as SettingKeyValue,
2319
+ Se as SettingType,
2320
+ Wt as User,
2321
+ zt as createConsoleLogger,
2322
+ Bt as createFlagOverridesFromMap
2053
2323
  };