@braze/web-sdk 5.1.1 → 5.3.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.
Files changed (99) hide show
  1. package/index.d.ts +65 -10
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +20 -20
  5. package/shared-lib/indexed-db-adapter.js +52 -52
  6. package/shared-lib/logger.js +7 -7
  7. package/shared-lib/supported-options.js +22 -21
  8. package/src/ContentCards/content-cards-provider.js +107 -135
  9. package/src/ContentCards/get-cached-content-cards.js +1 -1
  10. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  11. package/src/ContentCards/subscribe-to-content-cards-updates.js +2 -2
  12. package/src/ContentCards/ui/show-content-cards.js +1 -1
  13. package/src/FeatureFlags/feature-flag.js +41 -30
  14. package/src/FeatureFlags/feature-flags-provider.js +88 -84
  15. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  16. package/src/FeatureFlags/get-feature-flag.js +2 -2
  17. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  18. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  19. package/src/Feed/feed-provider.js +24 -24
  20. package/src/Feed/get-cached-feed.js +1 -1
  21. package/src/Feed/log-feed-displayed.js +1 -1
  22. package/src/Feed/request-feed-refresh.js +1 -1
  23. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  24. package/src/Feed/ui/show-feed.js +1 -1
  25. package/src/InAppMessage/defer-in-app-message.js +1 -1
  26. package/src/InAppMessage/display/html-message-to-html.js +45 -42
  27. package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
  28. package/src/InAppMessage/display/modal-utils.js +7 -7
  29. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  30. package/src/InAppMessage/in-app-message-factory.js +23 -21
  31. package/src/InAppMessage/in-app-message-manager.js +95 -112
  32. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  33. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  34. package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
  35. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  36. package/src/InAppMessage/models/control-message.js +4 -2
  37. package/src/InAppMessage/models/full-screen-message.js +14 -11
  38. package/src/InAppMessage/models/html-message.js +11 -9
  39. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  40. package/src/InAppMessage/models/in-app-message.js +127 -120
  41. package/src/InAppMessage/models/modal-message.js +14 -11
  42. package/src/InAppMessage/models/slide-up-message.js +46 -21
  43. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  44. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  45. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  46. package/src/InAppMessage/ui/show-in-app-message.js +37 -43
  47. package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
  48. package/src/Push/push-manager-factory.js +4 -4
  49. package/src/Push/push-manager.js +118 -110
  50. package/src/Push/utils/push-utils.js +4 -4
  51. package/src/User/user-manager.js +4 -4
  52. package/src/User/user.js +19 -19
  53. package/src/common/base-feed.js +1 -1
  54. package/src/common/base-provider.js +1 -1
  55. package/src/common/constants.js +0 -2
  56. package/src/common/event-logger.js +2 -2
  57. package/src/common/feed-display.js +12 -12
  58. package/src/l10n/l10n-manager-factory.js +1 -1
  59. package/src/l10n/l10n-manager.js +4 -4
  60. package/src/managers/auth-manager.js +27 -27
  61. package/src/managers/braze-instance.js +119 -112
  62. package/src/managers/device-manager.js +19 -19
  63. package/src/managers/network-manager.js +215 -165
  64. package/src/managers/server-config-manager.js +46 -50
  65. package/src/managers/session-manager.js +21 -21
  66. package/src/managers/storage-manager-factory.js +1 -1
  67. package/src/managers/storage-manager.js +128 -125
  68. package/src/managers/utils.js +6 -0
  69. package/src/models/backend-errors.js +5 -5
  70. package/src/models/braze-event.js +19 -11
  71. package/src/models/device.js +3 -3
  72. package/src/models/identifier.js +34 -20
  73. package/src/models/push-token.js +4 -4
  74. package/src/models/server-config.js +24 -24
  75. package/src/request-controller.js +134 -124
  76. package/src/triggers/models/filter-set.js +2 -2
  77. package/src/triggers/models/filter.js +56 -56
  78. package/src/triggers/models/in-app-message-click-data.js +8 -8
  79. package/src/triggers/models/push-click-data.js +3 -3
  80. package/src/triggers/models/trigger-condition.js +30 -30
  81. package/src/triggers/models/trigger-events.js +1 -1
  82. package/src/triggers/models/trigger.js +36 -36
  83. package/src/triggers/triggers-provider-factory.js +2 -2
  84. package/src/triggers/triggers-provider.js +84 -95
  85. package/src/ui/js/attach-css.js +2 -2
  86. package/src/ui/js/load-font-awesome.js +1 -1
  87. package/src/util/base-device-parser.js +7 -7
  88. package/src/util/braze-actions.js +4 -4
  89. package/src/util/browser-detector.js +25 -24
  90. package/src/util/client-hints-parser.js +4 -4
  91. package/src/util/component-utils.js +2 -2
  92. package/src/util/device-constants.js +2 -2
  93. package/src/util/dom-utils.js +6 -6
  94. package/src/util/key-codes.js +1 -1
  95. package/src/util/net.js +4 -4
  96. package/src/util/request-header-utils.js +36 -37
  97. package/src/util/user-agent-parser.js +8 -8
  98. package/src/util/validation-utils.js +2 -0
  99. package/src/util/window-utils.js +3 -3
@@ -3,17 +3,17 @@ import y from "../common/base-provider.js";
3
3
  import e from "../managers/braze-instance.js";
4
4
  import ContentCards from "./content-cards.js";
5
5
  import { dateFromUnixTimestamp as l } from "../util/date-utils.js";
6
- import { isURIJavascriptOrData as N } from "../util/url-utils.js";
6
+ import { isURIJavascriptOrData as R } from "../util/url-utils.js";
7
7
  import {
8
- newCardFromContentCardsJson as R,
9
- newCardFromSerializedValue as D,
8
+ newCardFromContentCardsJson as N,
9
+ newCardFromSerializedValue as S,
10
10
  } from "../Card/util/card-factory.js";
11
11
  import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
12
12
  import T from "../managers/subscription-manager.js";
13
13
  import s from "../common/event-logger.js";
14
- import S from "../util/request-header-utils.js";
15
- import { randomInclusive as k } from "../util/math.js";
16
- import { MAX_ERROR_RETRIES_CONTENT_CARDS as U } from "../common/constants.js";
14
+ import D from "../util/request-header-utils.js";
15
+ import { randomInclusive as U } from "../util/math.js";
16
+ import { MAX_ERROR_RETRIES_CONTENT_CARDS as k } from "../common/constants.js";
17
17
  import {
18
18
  logger as r,
19
19
  IndexedDBAdapter as A,
@@ -64,17 +64,17 @@ export default class v extends y {
64
64
  }
65
65
  Kt() {
66
66
  if (!this.u) return;
67
- const t = this.u.j(o.C.Cs) || [],
67
+ const t = this.u.j(o.C.ws) || [],
68
68
  s = [];
69
69
  for (let i = 0; i < t.length; i++) {
70
- const e = D(t[i]);
70
+ const e = S(t[i]);
71
71
  null != e && s.push(e);
72
72
  }
73
- (this.cards = this.ws(this.bs(s, !1))),
73
+ (this.cards = this.Cs(this.bs(s, !1))),
74
74
  (this.Bt = this.u.j(o.C.gs) || this.Bt),
75
75
  (this.Ht = this.u.j(o.C.ys) || this.Ht);
76
76
  }
77
- Ns(t, s = !1, i = 0, e = 0) {
77
+ js(t, s = !1, i = 0, e = 0) {
78
78
  let h;
79
79
  if (s) {
80
80
  h = [];
@@ -89,10 +89,10 @@ export default class v extends y {
89
89
  break;
90
90
  }
91
91
  if (s) {
92
- const t = R(e);
92
+ const t = N(e);
93
93
  null != r && r.viewed && t && (t.viewed = !0), null != t && h.push(t);
94
94
  } else if (null == r) {
95
- const t = R(e);
95
+ const t = N(e);
96
96
  null != t && h.push(t);
97
97
  } else {
98
98
  if (!r.Ct(e))
@@ -103,31 +103,31 @@ export default class v extends y {
103
103
  }
104
104
  }
105
105
  }
106
- (this.cards = this.ws(this.bs(h, s))),
107
- this.js(),
106
+ (this.cards = this.Cs(this.bs(h, s))),
107
+ this.Rs(),
108
108
  (this.Bt = i),
109
109
  (this.Ht = e),
110
110
  this.u && (this.u.k(o.C.gs, this.Bt), this.u.k(o.C.ys, this.Ht));
111
111
  }
112
- Rs(t) {
112
+ Ns(t) {
113
113
  if (this.Ts() && null != t && t.cards) {
114
- this.u && this.u.k(o.C.Ds, e.Ss());
114
+ this.u && this.u.k(o.C.Ss, e.Ds());
115
115
  const s = t.full_sync;
116
116
  s || this.Kt(),
117
- this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
118
- this.Jt.Dt(this.ks(!0));
117
+ this.js(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
118
+ this.Jt.Dt(this.Us(!0));
119
119
  }
120
120
  }
121
- Us(t) {
121
+ ks(t) {
122
122
  this.u && this.u.k(o.C.As, t);
123
123
  }
124
- Ls(t, e, h) {
124
+ Fs(t, e, h) {
125
125
  const r = () => {
126
- this.Fs(e, h, !0);
126
+ this.xs(e, h, !0);
127
127
  },
128
128
  n = t ? b(t) : null;
129
129
  let l;
130
- if ((this.xs(), !n || !n["retry-after"])) return void this.Us(0);
130
+ if ((this.zs(), !n || !n["retry-after"])) return void this.ks(0);
131
131
  const a = n["retry-after"];
132
132
  if (isNaN(a) && !isNaN(Date.parse(a)))
133
133
  (l = Date.parse(a) - new Date().getTime()), l < 0 && r();
@@ -135,7 +135,7 @@ export default class v extends y {
135
135
  if (isNaN(parseFloat(a.toString()))) {
136
136
  const t =
137
137
  "Received unexpected value for retry-after header in /sync response";
138
- return s.q(i.Ms, { e: t + ": " + a }), void this.Us(0);
138
+ return s.q(i.qs, { e: t + ": " + a }), void this.ks(0);
139
139
  }
140
140
  l = 1e3 * parseFloat(a.toString());
141
141
  }
@@ -145,7 +145,7 @@ export default class v extends y {
145
145
  let u = 0;
146
146
  this.u && (u = this.u.j(o.C.As)),
147
147
  (null == u || isNaN(parseInt(u.toString()))) && (u = 0),
148
- this.Us(parseInt(u.toString()) + 1);
148
+ this.ks(parseInt(u.toString()) + 1);
149
149
  }
150
150
  es(t) {
151
151
  var s;
@@ -164,7 +164,7 @@ export default class v extends y {
164
164
  break;
165
165
  }
166
166
  if (null == h) {
167
- const t = R(e);
167
+ const t = N(e);
168
168
  null != t && i.push(t);
169
169
  } else {
170
170
  if (!h.Ct(e))
@@ -175,7 +175,7 @@ export default class v extends y {
175
175
  }
176
176
  }
177
177
  }
178
- (this.cards = this.ws(this.bs(i, !1))), this.js(), this.Jt.Dt(this.ks(!0));
178
+ (this.cards = this.Cs(this.bs(i, !1))), this.Rs(), this.Jt.Dt(this.Us(!0));
179
179
  }
180
180
  bs(t, s) {
181
181
  let i = {},
@@ -202,7 +202,7 @@ export default class v extends y {
202
202
  t
203
203
  );
204
204
  }
205
- ws(t) {
205
+ Cs(t) {
206
206
  const s = [],
207
207
  i = new Date();
208
208
  let e = {};
@@ -210,7 +210,7 @@ export default class v extends y {
210
210
  let h = !1;
211
211
  for (let n = 0; n < t.length; n++) {
212
212
  const o = t[n].url;
213
- if (!this.Ft && o && N(o)) {
213
+ if (!this.Ft && o && R(o)) {
214
214
  r.error(
215
215
  `Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
216
216
  );
@@ -227,97 +227,90 @@ export default class v extends y {
227
227
  }
228
228
  return h && this.u && this.u.k(o.C.A, e), s;
229
229
  }
230
- js() {
230
+ Rs() {
231
231
  var t;
232
232
  const s = [];
233
233
  for (let t = 0; t < this.cards.length; t++) s.push(this.cards[t].Y());
234
- null === (t = this.u) || void 0 === t || t.k(o.C.Cs, s);
234
+ null === (t = this.u) || void 0 === t || t.k(o.C.ws, s);
235
235
  }
236
- xs() {
236
+ zs() {
237
237
  this.ns && (clearTimeout(this.ns), (this.ns = null));
238
238
  }
239
- zs() {
239
+ Es() {
240
240
  null != this.os && (clearTimeout(this.os), (this.os = null));
241
241
  }
242
- Es(t = 1e3 * this.us, s, i) {
243
- this.zs(),
242
+ Ls(t = 1e3 * this.us, s, i) {
243
+ this.Es(),
244
244
  (this.os = window.setTimeout(() => {
245
- this.Fs(s, i, !0);
245
+ this.xs(s, i, !0);
246
246
  }, t)),
247
247
  (this.ls = t);
248
248
  }
249
- Fs(t, s, i = !1, h = !0) {
250
- var n, l;
251
- const a = this.qt,
252
- u = this.u;
253
- if (!a || !u) return void ("function" == typeof s && s());
254
- const c = !i;
255
- if ((c && (this.xs(), this.Us(0)), !this.Ts()))
249
+ xs(t, s, i = !1, h = !0) {
250
+ var r;
251
+ const n = this.qt,
252
+ l = this.u;
253
+ if (!n || !l) return void ("function" == typeof s && s());
254
+ if ((!i && (this.zs(), this.ks(0)), !this.Ts()))
256
255
  return void (
257
- null === (n = this.yt) ||
258
- void 0 === n ||
259
- n.qs(() => {
260
- this.Fs(t, s);
256
+ null === (r = this.yt) ||
257
+ void 0 === r ||
258
+ r.Is(() => {
259
+ this.xs(t, s);
261
260
  })
262
261
  );
263
- let f = !0;
264
- if (
265
- (c &&
266
- (null === (l = this.yt) || void 0 === l ? void 0 : l.Is()) &&
267
- (f = this.Js()),
268
- !f)
269
- )
270
- return void r.info("Content card sync being throttled.");
271
- h && this.zs();
272
- const d = a.Ps({}, !0);
273
- u.j(o.C.Ds) !== e.Ss() && this.$s(),
274
- (d.last_full_sync_at = this.Bt),
275
- (d.last_card_updated_at = this.Ht);
276
- const m = a._s(d, S.Gs.Bs, i);
277
- let p = !1;
278
- a.Hs(
279
- d,
280
- () => {
262
+ h && this.Es();
263
+ const a = n.Js({}, !0);
264
+ l.j(o.C.Ss) !== e.Ds() && this.Ms(),
265
+ (a.last_full_sync_at = this.Bt),
266
+ (a.last_card_updated_at = this.Ht);
267
+ const u = n.$s(a, D.Ps.Bs, i);
268
+ let c = !1;
269
+ n.Xs(
270
+ a,
271
+ (i = -1) => {
281
272
  if (this.u) {
282
273
  const t = new Date().valueOf();
283
- c && this.u.k(o.C.Ks, t), S.Os(this.u, S.Gs.Bs, t);
274
+ D._s(this.u, D.Ps.Bs, t);
284
275
  }
285
- C.Qs({
286
- url: a.Vs() + "/content_cards/sync",
287
- data: d,
288
- headers: m,
289
- L: (i, e) => {
290
- if (!a.Ws(d, i, m))
291
- return (p = !0), void ("function" == typeof s && s());
292
- a.Xs(),
293
- this.Ls(e, t, s),
294
- this.Rs(i),
295
- (p = !1),
296
- S.Ys(this.u, S.Gs.Bs, 1),
297
- "function" == typeof t && t();
298
- },
299
- error: (t) => {
300
- a.Zs(t, "retrieving content cards"),
301
- (p = !0),
302
- "function" == typeof s && s();
303
- },
304
- ti: () => {
305
- if (p && h && !this.os && this.cs + 1 < U) {
306
- S.si(this.u, S.Gs.Bs);
307
- let i = this.ls;
308
- (null == i || i < 1e3 * this.us) && (i = 1e3 * this.us),
309
- this.Es(Math.min(3e5, k(1e3 * this.us, 3 * i)), t, s),
310
- (this.cs = this.cs + 1);
311
- }
312
- },
313
- });
276
+ -1 !== i && u.push(["X-Braze-Req-Tokens-Remaining", i.toString()]),
277
+ C.Gs({
278
+ url: `${n.Hs()}/content_cards/sync`,
279
+ data: a,
280
+ headers: u,
281
+ L: (i, e) => {
282
+ if (!n.Ks(a, i, u))
283
+ return (c = !0), void ("function" == typeof s && s());
284
+ n.Os(),
285
+ this.Fs(e, t, s),
286
+ this.Ns(i),
287
+ (c = !1),
288
+ D.Qs(this.u, D.Ps.Bs, 1),
289
+ "function" == typeof t && t();
290
+ },
291
+ error: (t) => {
292
+ n.Vs(t, "retrieving content cards"),
293
+ (c = !0),
294
+ "function" == typeof s && s();
295
+ },
296
+ Ws: () => {
297
+ if (c && h && !this.os && this.cs + 1 < k) {
298
+ D.Ys(this.u, D.Ps.Bs);
299
+ let i = this.ls;
300
+ (null == i || i < 1e3 * this.us) && (i = 1e3 * this.us),
301
+ this.Ls(Math.min(3e5, U(1e3 * this.us, 3 * i)), t, s),
302
+ (this.cs = this.cs + 1);
303
+ }
304
+ },
305
+ });
314
306
  },
315
- S.ii.Bs,
307
+ D.Ps.Bs,
308
+ s,
316
309
  );
317
310
  }
318
- ks(t) {
311
+ Us(t) {
319
312
  t || this.Kt();
320
- const s = this.ws(this.cards);
313
+ const s = this.Cs(this.cards);
321
314
  s.sort((t, s) =>
322
315
  t.pinned && !s.pinned
323
316
  ? -1
@@ -336,24 +329,24 @@ export default class v extends y {
336
329
  new ContentCards(s, l(i))
337
330
  );
338
331
  }
339
- ei(t) {
332
+ Zs(t) {
340
333
  return this.Jt.It(t);
341
334
  }
342
- $s() {
335
+ Ms() {
343
336
  (this.Bt = 0),
344
337
  (this.Ht = 0),
345
- this.u && (this.u.hi(o.C.gs), this.u.hi(o.C.ys));
338
+ this.u && (this.u.ti(o.C.gs), this.u.ti(o.C.ys));
346
339
  }
347
340
  changeUser(t) {
348
341
  t ||
349
342
  ((this.cards = []),
350
343
  this.Jt.Dt(new ContentCards(this.cards.slice(), null)),
351
344
  this.u &&
352
- (this.u.hi(o.C.Cs),
353
- this.u.hi(o.C.v),
354
- this.u.hi(o.C.H),
355
- this.u.hi(o.C.A))),
356
- this.$s();
345
+ (this.u.ti(o.C.ws),
346
+ this.u.ti(o.C.v),
347
+ this.u.ti(o.C.H),
348
+ this.u.ti(o.C.A))),
349
+ this.Ms();
357
350
  }
358
351
  clearData(t) {
359
352
  (this.Bt = 0),
@@ -362,40 +355,19 @@ export default class v extends y {
362
355
  this.Jt.Dt(new ContentCards(this.cards.slice(), null)),
363
356
  t &&
364
357
  this.u &&
365
- (this.u.hi(o.C.Cs),
366
- this.u.hi(o.C.v),
367
- this.u.hi(o.C.H),
368
- this.u.hi(o.C.A),
369
- this.u.hi(o.C.gs),
370
- this.u.hi(o.C.ys));
358
+ (this.u.ti(o.C.ws),
359
+ this.u.ti(o.C.v),
360
+ this.u.ti(o.C.H),
361
+ this.u.ti(o.C.A),
362
+ this.u.ti(o.C.gs),
363
+ this.u.ti(o.C.ys));
371
364
  }
372
365
  Ts() {
373
366
  return (
374
- !!this.yt && (!!this.yt.ri() || (0 !== this.yt.ni() && this.oi(), !1))
375
- );
376
- }
377
- li(t) {
378
- this.u && this.u.k(o.C.ai, t);
379
- }
380
- ui() {
381
- return this.u ? this.u.j(o.C.ai) : null;
382
- }
383
- Js() {
384
- var t, s, i;
385
- const e = null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.Ks);
386
- if (null == e || isNaN(e)) return !0;
387
- const h = (null === (s = this.yt) || void 0 === s ? void 0 : s.ci()) || -1,
388
- r = (null === (i = this.yt) || void 0 === i ? void 0 : i.fi()) || -1;
389
- if (-1 === h || -1 === r) return !0;
390
- let n = this.ui();
391
- (null == n || isNaN(n)) && (n = h);
392
- const l = (new Date().valueOf() - e) / 1e3;
393
- return (
394
- (n = Math.min(n + l / r, h)),
395
- !(n < 1) && ((n = Math.trunc(n) - 1), this.li(n), !0)
367
+ !!this.yt && (!!this.yt.si() || (0 !== this.yt.ii() && this.ei(), !1))
396
368
  );
397
369
  }
398
- oi() {
399
- this.Jt.Dt(new ContentCards([], new Date())), this.u && this.u.hi(o.C.Cs);
370
+ ei() {
371
+ this.Jt.Dt(new ContentCards([], new Date())), this.u && this.u.ti(o.C.ws);
400
372
  }
401
373
  }
@@ -1,5 +1,5 @@
1
1
  import g from "./content-cards-provider-factory.js";
2
2
  import e from "../managers/braze-instance.js";
3
3
  export function getCachedContentCards() {
4
- if (e.X()) return g.rr().ks(!1);
4
+ if (e.X()) return g.rr().Us(!1);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import e from "../managers/braze-instance.js";
2
2
  import g from "./content-cards-provider-factory.js";
3
3
  export function requestContentCardsRefresh(r, t) {
4
- if (e.X()) return g.rr().Fs(r, t);
4
+ if (e.X()) return g.rr().xs(r, t);
5
5
  }
@@ -3,12 +3,12 @@ import g from "./content-cards-provider-factory.js";
3
3
  export function subscribeToContentCardsUpdates(r) {
4
4
  if (!e.X()) return;
5
5
  const t = g.rr(),
6
- n = t.ei(r);
6
+ n = t.Zs(r);
7
7
  if (!t.ps()) {
8
8
  const r = e.cr();
9
9
  if (r) {
10
10
  const n = r.mr(() => {
11
- t.Fs();
11
+ t.xs();
12
12
  });
13
13
  n && t.vs(n);
14
14
  }
@@ -19,7 +19,7 @@ export function showContentCards(n, t) {
19
19
  let o = !1;
20
20
  null == n && ((n = document.body), (o = !0));
21
21
  const i = e.nn(L.tn) || e.nn(L.en) || !1,
22
- a = g.rr().ks(!1);
22
+ a = g.rr().Us(!1);
23
23
  "function" == typeof t && F(a, t(a.cards.slice()), a.lastUpdated, null, i);
24
24
  const s = I(a, i, o),
25
25
  f = g.rr(),
@@ -1,38 +1,36 @@
1
1
  import { logger as r } from "../../shared-lib/index.js";
2
2
  export default class FeatureFlag {
3
- constructor(t, r = !1, e = {}, s) {
3
+ constructor(t, e = !1, r = {}, i) {
4
4
  (this.id = t),
5
- (this.enabled = r),
6
- (this.properties = e),
7
- (this.trackingString = s),
5
+ (this.enabled = e),
6
+ (this.properties = r),
7
+ (this.trackingString = i),
8
8
  (this.id = t),
9
- (this.enabled = r),
10
- (this.properties = e),
11
- (this.trackingString = s);
9
+ (this.enabled = e),
10
+ (this.properties = r),
11
+ (this.trackingString = i);
12
+ }
13
+ he(t, e, r) {
14
+ const i = this.properties[t];
15
+ return null == i ? (this.ye(t), null) : e(i) ? i.value : (this.Pe(r), null);
12
16
  }
13
17
  getStringProperty(t) {
14
- const r = this.properties[t];
15
- return null == r
16
- ? (this.Er(t), null)
17
- : this.Ir(r)
18
- ? r.value
19
- : (this.Nr("string"), null);
18
+ return this.he(t, this.be, "string");
20
19
  }
21
20
  getNumberProperty(t) {
22
- const r = this.properties[t];
23
- return null == r
24
- ? (this.Er(t), null)
25
- : this.Tr(r)
26
- ? r.value
27
- : (this.Nr("number"), null);
21
+ return this.he(t, this.Ie, "number");
28
22
  }
29
23
  getBooleanProperty(t) {
30
- const r = this.properties[t];
31
- return null == r
32
- ? (this.Er(t), null)
33
- : this.Ar(r)
34
- ? r.value
35
- : (this.Nr("boolean"), null);
24
+ return this.he(t, this.de, "boolean");
25
+ }
26
+ getImageProperty(t) {
27
+ return this.he(t, this.Te, "image");
28
+ }
29
+ getJsonProperty(t) {
30
+ return this.he(t, this.Ee, "jsonobject");
31
+ }
32
+ getTimestampProperty(t) {
33
+ return this.he(t, this.Ne, "datetime");
36
34
  }
37
35
  Y() {
38
36
  const t = {};
@@ -44,21 +42,34 @@ export default class FeatureFlag {
44
42
  t
45
43
  );
46
44
  }
47
- Nr(t) {
45
+ Pe(t) {
48
46
  r.info(`Property is not of type ${t}.`);
49
47
  }
50
- Er(t) {
48
+ ye(t) {
51
49
  r.info(`${t} not found in feature flag properties.`);
52
50
  }
53
- Ir(t) {
51
+ be(t) {
54
52
  return "string" === t.type && "string" == typeof t.value;
55
53
  }
56
- Tr(t) {
54
+ Ie(t) {
57
55
  return "number" === t.type && "number" == typeof t.value;
58
56
  }
59
- Ar(t) {
57
+ de(t) {
60
58
  return "boolean" === t.type && "boolean" == typeof t.value;
61
59
  }
60
+ Te(t) {
61
+ return "image" === t.type && "string" == typeof t.value;
62
+ }
63
+ Ee(t) {
64
+ return (
65
+ "jsonobject" === t.type &&
66
+ "object" == typeof t.value &&
67
+ t.value.constructor == Object
68
+ );
69
+ }
70
+ Ne(t) {
71
+ return "datetime" === t.type && "number" == typeof t.value;
72
+ }
62
73
  }
63
74
  (FeatureFlag.tt = { ht: "id", le: "e", pe: "pr", Fe: "fts" }),
64
75
  (FeatureFlag.Rt = { ht: "id", le: "enabled", pe: "properties", Fe: "fts" });