@braze/web-sdk 6.7.1 → 6.9.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 (138) hide show
  1. package/index.d.ts +165 -38
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +2 -2
  4. package/shared-lib/event-types.js +16 -16
  5. package/shared-lib/indexed-db-adapter.js +65 -65
  6. package/shared-lib/logger.js +18 -18
  7. package/shared-lib/supported-options.js +1 -1
  8. package/src/Banner/banner-provider.js +67 -59
  9. package/src/Banner/banner.js +40 -19
  10. package/src/Banner/dismiss-banner.js +4 -0
  11. package/src/Banner/display/banner-to-html.js +10 -10
  12. package/src/Banner/display/destroy-banner-html.js +2 -2
  13. package/src/Banner/get-all-banners.js +6 -6
  14. package/src/Banner/get-banner.js +6 -6
  15. package/src/Banner/index.js +1 -0
  16. package/src/Banner/log-banner-click.js +7 -7
  17. package/src/Banner/log-banner-dismissal.js +7 -7
  18. package/src/Banner/log-banner-impressions.js +27 -18
  19. package/src/Banner/request-banners-refresh.js +8 -8
  20. package/src/Banner/subscribe-to-banners-updates.js +5 -5
  21. package/src/Banner/ui/insert-banner.js +8 -8
  22. package/src/Card/card-manager.js +31 -31
  23. package/src/Card/log-card-dismissal.js +2 -2
  24. package/src/Card/log-content-card-click.js +2 -2
  25. package/src/Card/log-content-card-impressions.js +4 -4
  26. package/src/Card/models/captioned-image.js +15 -15
  27. package/src/Card/models/card.js +89 -89
  28. package/src/Card/models/classic-card.js +16 -16
  29. package/src/Card/models/control-card.js +7 -7
  30. package/src/Card/models/image-only.js +13 -13
  31. package/src/Card/util/card-factory.js +32 -32
  32. package/src/ContentCards/content-cards-provider-factory.js +13 -11
  33. package/src/ContentCards/content-cards-provider.js +105 -105
  34. package/src/ContentCards/get-cached-content-cards.js +2 -2
  35. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  36. package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
  37. package/src/ContentCards/ui/show-content-cards.js +7 -7
  38. package/src/Core/add-sdk-metadata.js +2 -2
  39. package/src/Core/change-user.js +5 -5
  40. package/src/Core/destroy.js +2 -2
  41. package/src/Core/disable-sdk.js +4 -4
  42. package/src/Core/enable-sdk.js +4 -4
  43. package/src/Core/get-device-id.js +2 -2
  44. package/src/Core/handle-braze-action.js +5 -5
  45. package/src/Core/index.js +1 -0
  46. package/src/Core/log-custom-event.js +5 -5
  47. package/src/Core/log-ecommerce-event.js +29 -0
  48. package/src/Core/log-purchase.js +23 -198
  49. package/src/Core/open-session.js +10 -10
  50. package/src/Core/set-logger.js +2 -2
  51. package/src/Core/set-sdk-authentication-signature.js +1 -1
  52. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  53. package/src/Core/toggle-logging.js +2 -2
  54. package/src/Core/wipe-data.js +6 -6
  55. package/src/DUST/dust-connection-core.js +1 -0
  56. package/src/DUST/dust-provider-factory.js +10 -10
  57. package/src/DUST/dust-provider.js +258 -226
  58. package/src/DUST/dust-shared-worker-code.js +1 -1
  59. package/src/DUST/dust-shared-worker-impl.js +97 -103
  60. package/src/DUST/dust-worker-bridge.js +55 -40
  61. package/src/DUST/subscribe-to-dust.js +7 -7
  62. package/src/FeatureFlags/feature-flag-factory.js +8 -8
  63. package/src/FeatureFlags/feature-flag.js +3 -3
  64. package/src/FeatureFlags/feature-flags-provider.js +21 -21
  65. package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
  66. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  67. package/src/InAppMessage/constants.js +3 -3
  68. package/src/InAppMessage/defer-in-app-message.js +3 -3
  69. package/src/InAppMessage/display/html-message-to-html.js +4 -4
  70. package/src/InAppMessage/display/in-app-message-to-html.js +32 -32
  71. package/src/InAppMessage/display/modal-utils.js +2 -2
  72. package/src/InAppMessage/in-app-message-factory.js +36 -36
  73. package/src/InAppMessage/in-app-message-manager.js +35 -35
  74. package/src/InAppMessage/log-in-app-message-button-click.js +3 -3
  75. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  76. package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
  77. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  78. package/src/InAppMessage/models/control-message.js +4 -4
  79. package/src/InAppMessage/models/full-screen-message.js +9 -9
  80. package/src/InAppMessage/models/html-message.js +2 -2
  81. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  82. package/src/InAppMessage/models/in-app-message.js +34 -34
  83. package/src/InAppMessage/models/modal-message.js +7 -7
  84. package/src/InAppMessage/models/slide-up-message.js +8 -8
  85. package/src/InAppMessage/ui/show-in-app-message.js +20 -20
  86. package/src/Push/push-manager.js +44 -44
  87. package/src/User/user-manager.js +19 -19
  88. package/src/User/user.js +17 -17
  89. package/src/common/base-provider.js +1 -1
  90. package/src/common/constants.js +1 -0
  91. package/src/common/content-cards-display.js +6 -6
  92. package/src/common/event-logger.js +3 -3
  93. package/src/common/properties-base.js +3 -3
  94. package/src/l10n/l10n-manager.js +2 -2
  95. package/src/managers/auth-manager.js +11 -11
  96. package/src/managers/braze-instance.js +59 -59
  97. package/src/managers/device-manager.js +9 -9
  98. package/src/managers/network-manager.js +65 -63
  99. package/src/managers/server-config-manager.js +110 -93
  100. package/src/managers/session-manager.js +20 -20
  101. package/src/managers/storage-manager-factory.js +9 -9
  102. package/src/managers/storage-manager.js +137 -137
  103. package/src/managers/subscription-manager.js +2 -2
  104. package/src/managers/utils.js +1 -1
  105. package/src/models/braze-event.js +2 -2
  106. package/src/models/identifier.js +5 -5
  107. package/src/models/push-token.js +8 -8
  108. package/src/models/request-result.js +1 -1
  109. package/src/models/server-config.js +46 -28
  110. package/src/request-controller.js +124 -124
  111. package/src/triggers/models/custom-event-data.js +4 -4
  112. package/src/triggers/models/custom-event-property-data.js +5 -5
  113. package/src/triggers/models/filter-set.js +2 -2
  114. package/src/triggers/models/filter.js +1 -1
  115. package/src/triggers/models/in-app-message-click-data.js +5 -5
  116. package/src/triggers/models/purchase-data.js +1 -1
  117. package/src/triggers/models/purchase-property-data.js +2 -2
  118. package/src/triggers/models/push-click-data.js +5 -5
  119. package/src/triggers/models/trigger-condition.js +45 -45
  120. package/src/triggers/models/trigger-events.js +3 -3
  121. package/src/triggers/models/trigger.js +30 -30
  122. package/src/triggers/triggers-provider.js +63 -63
  123. package/src/types.js +5 -1
  124. package/src/ui/js/attach-css.js +1 -1
  125. package/src/util/braze-actions.js +6 -6
  126. package/src/util/browser-detector.js +13 -13
  127. package/src/util/client-hints-parser.js +5 -5
  128. package/src/util/code-utils.js +2 -2
  129. package/src/util/deprecation-utils.js +2 -2
  130. package/src/util/dom-utils.js +8 -8
  131. package/src/util/ecommerce-event-validation.js +343 -0
  132. package/src/util/html-display-utils.js +11 -11
  133. package/src/util/iso-4217-currency-codes.js +176 -0
  134. package/src/util/net.js +4 -4
  135. package/src/util/request-header-utils.js +10 -10
  136. package/src/util/string-utils.js +2 -2
  137. package/src/util/user-agent-parser.js +15 -15
  138. package/src/util/validation-utils.js +14 -14
@@ -5,8 +5,8 @@ import {
5
5
  convertSecondsToMs as Xe,
6
6
  } from "../util/date-utils.js";
7
7
  import v from "../common/event-logger.js";
8
- import { isArray as g, isEqual as ni } from "../util/code-utils.js";
9
- import { logger as E, EventTypes as p } from "../../shared-lib/index.js";
8
+ import { isArray as g, isEqual as oi } from "../util/code-utils.js";
9
+ import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
10
10
  import { STORAGE_KEYS as s } from "./storage-manager.js";
11
11
  import h from "../util/request-header-utils.js";
12
12
  import {
@@ -18,10 +18,10 @@ import { readResponseHeaders as Oe } from "../util/net.js";
18
18
  export default class Vt {
19
19
  constructor(t, e, i, s, r, n, o, a, h, u, l, c) {
20
20
  (this.eu = t),
21
- (this.C = e),
21
+ (this.j = e),
22
22
  (this.Gh = i),
23
23
  (this.Ss = s),
24
- (this.j = r),
24
+ (this.C = r),
25
25
  (this.h = n),
26
26
  (this.tu = o),
27
27
  (this.Yh = a),
@@ -29,12 +29,12 @@ export default class Vt {
29
29
  (this.Kh = u),
30
30
  (this.appVersion = l),
31
31
  (this.Ra = c),
32
- (this.$a = (t) => (null == t ? "" : `${t} `)),
32
+ (this.Xa = (t) => (null == t ? "" : `${t} `)),
33
33
  (this.eu = t),
34
- (this.C = e),
34
+ (this.j = e),
35
35
  (this.Gh = i),
36
36
  (this.Ss = s),
37
- (this.j = r),
37
+ (this.C = r),
38
38
  (this.h = n),
39
39
  (this.tu = o),
40
40
  (this.Yh = a),
@@ -42,21 +42,21 @@ export default class Vt {
42
42
  (this.Kh = u),
43
43
  (this.appVersion = l),
44
44
  (this.Ra = c),
45
- (this.Xa = ["npm"]),
45
+ (this.$a = ["npm"]),
46
46
  (this.La = {});
47
47
  }
48
48
  Z(t, e = !1, i = !1) {
49
49
  const r = this.eu.ve(!i),
50
50
  n = r.ta(),
51
- o = this.C.Rt(s.Tt.Ba);
52
- ni(o, n) || (t.device = n),
51
+ o = this.j.St(s.It.Ba);
52
+ oi(o, n) || (t.device = n),
53
53
  (t.api_key = this.tu),
54
54
  (t.time = X(new Date().valueOf(), !0));
55
- const a = this.C.Rt(s.Tt.Ka) || [],
56
- h = this.C.Rt(s.Tt.Pa) || "";
57
- this.Xa.length > 0 &&
58
- (!ni(a, this.Xa) || h !== this.j.kt()) &&
59
- (t.sdk_metadata = this.Xa),
55
+ const a = this.j.St(s.It.Ka) || [],
56
+ h = this.j.St(s.It.Pa) || "";
57
+ this.$a.length > 0 &&
58
+ (!oi(a, this.$a) || h !== this.C.$t()) &&
59
+ (t.sdk_metadata = this.$a),
60
60
  (t.sdk_version = this.Vh),
61
61
  this.Kh && (t.sdk_flavor = this.Kh),
62
62
  (t.app_version = this.appVersion),
@@ -64,7 +64,7 @@ export default class Vt {
64
64
  (t.device_id = r.id);
65
65
  const u = this.Ss.getUserId();
66
66
  if ((e && null !== u && (t.user_id = u), !u && !this.Gh.Fh())) {
67
- const e = He(this.C);
67
+ const e = He(this.j);
68
68
  e && (t.alias = e);
69
69
  }
70
70
  return t;
@@ -90,7 +90,7 @@ export default class Vt {
90
90
  this.Gh.Fh() ||
91
91
  (e +=
92
92
  ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
93
- E.error(`SDK Authentication failed ${e}`),
93
+ b.error(`SDK Authentication failed ${e}`),
94
94
  this.Ua(t.events || [], t.attributes || []),
95
95
  this.Gh.Ch(r),
96
96
  !1
@@ -103,15 +103,15 @@ export default class Vt {
103
103
  case Ne.Wa:
104
104
  return (
105
105
  (i = "Received successful response with empty body."),
106
- v.wt(p.Ya, { e: i }),
107
- E.info(i),
106
+ v.Dt(p.Ya, { e: i }),
107
+ b.info(i),
108
108
  !1
109
109
  );
110
110
  case Ne.Qa:
111
111
  return (
112
112
  (i = "Received successful response with invalid JSON"),
113
- v.wt(p.Ya, { e: i + ": " + e.response }),
114
- E.info(i),
113
+ v.Dt(p.Ya, { e: i + ": " + e.response }),
114
+ b.info(i),
115
115
  !1
116
116
  );
117
117
  case Ne.Va:
@@ -122,9 +122,10 @@ export default class Vt {
122
122
  "Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
123
123
  break;
124
124
  case Ne.dl:
125
- s = "No device identifier. Please contact support@braze.com";
125
+ s =
126
+ "No device identifier. Please contact Braze Technical Support for assistance.";
126
127
  }
127
- E.error("Backend error: " + s);
128
+ b.error("Backend error: " + s);
128
129
  }
129
130
  return !1;
130
131
  }
@@ -179,52 +180,52 @@ export default class Vt {
179
180
  const t = Ie.fromJson(i);
180
181
  (t.time = Xe(t.time)), e.push(t);
181
182
  }
182
- this.C.ol(e);
183
+ this.j.ol(e);
183
184
  }
184
- if (e) for (const t of e) this.C.vl(t);
185
+ if (e) for (const t of e) this.j.vl(t);
185
186
  }
186
187
  dt(t, e) {
187
188
  let i = "HTTP error ";
188
- null != t && (i += t + " "), (i += e), E.error(i);
189
+ null != t && (i += t + " "), (i += e), b.error(i);
189
190
  }
190
191
  Rl(t) {
191
- return v.wt(p.gl, { n: t });
192
+ return v.Dt(p.gl, { n: t });
192
193
  }
193
194
  Zo(t, e) {
194
195
  const i = {};
195
196
  t && (i.triggers = !0);
196
197
  const s = null != e ? e : this.Ss.getUserId();
197
198
  if ((s && (i.user_id = s), !i.user_id && !this.Gh.Fh())) {
198
- const t = He(this.C);
199
+ const t = He(this.j);
199
200
  t && (i.alias = t);
200
201
  }
201
- return (i.config = { config_time: this.h.Ot() }), { respond_with: i };
202
+ return (i.config = { config_time: this.h.Qt() }), { respond_with: i };
202
203
  }
203
204
  bl(t) {
204
205
  const e = new Date().valueOf();
205
206
  let i = Ke.toString();
206
- const s = h.ql(this.C, t);
207
+ const s = h.ql(this.j, t);
207
208
  if (-1 !== s) {
208
209
  i = (e - s).toString();
209
210
  }
210
211
  return i;
211
212
  }
212
- tt(t, e, i = !1) {
213
+ tt(t, e, i = "sdk") {
213
214
  const s = [["X-Braze-Api-Key", this.tu]],
214
215
  r = this.bl(e);
215
216
  s.push(["X-Braze-Last-Req-Ms-Ago", r]);
216
- const n = h.Al(this.C, e).toString();
217
+ const n = h.Al(this.j, e).toString();
217
218
  s.push(["X-Braze-Req-Attempt", n]);
218
219
  let o = !1;
219
220
  if (
220
221
  (null != t.respond_with &&
221
222
  t.respond_with.triggers &&
222
223
  (s.push(["X-Braze-TriggersRequest", "true"]), (o = !0)),
223
- e === h.it.Ji)
224
+ e === h.it.Mi)
224
225
  ) {
225
226
  s.push(["X-Braze-ContentCardsRequest", "true"]);
226
- let t = h.Al(this.C, h.it.Ji);
227
- (t && !i) || ((t = 1), h.Dl(this.C, h.it.Ji, t));
227
+ let t = h.Al(this.j, h.it.Mi);
228
+ (t && "client" !== i) || ((t = 1), h.Dl(this.j, h.it.Mi, t));
228
229
  const e = Math.max(0, t - 1);
229
230
  s.push(["BRAZE-SYNC-RETRY-COUNT", e.toString()]), (o = !0);
230
231
  }
@@ -232,6 +233,7 @@ export default class Vt {
232
233
  (e === h.it.Co &&
233
234
  (s.push(["X-Braze-FeatureFlagsRequest", "true"]), (o = !0)),
234
235
  o && s.push(["X-Braze-DataRequest", "true"]),
236
+ "dust" === i && s.push(["X-Braze-Request-Initiated-By", "di"]),
235
237
  this.Gh.Fh())
236
238
  ) {
237
239
  const t = this.Gh.kh();
@@ -242,7 +244,7 @@ export default class Vt {
242
244
  Tl(t, e, i, s) {
243
245
  if (this.La[s]) return;
244
246
  const r = window.setTimeout(() => {
245
- E.info(`Retrying rate limited ${this.$a(s)}SDK request.`),
247
+ b.info(`Retrying rate limited ${this.Xa(s)}SDK request.`),
246
248
  this.et(e, i, s);
247
249
  }, t);
248
250
  this.La[s] = r;
@@ -257,22 +259,22 @@ export default class Vt {
257
259
  et(t, e, i, r) {
258
260
  if (!this.kl(i))
259
261
  return (
260
- E.info(`${this.$a(i)}SDK request being rate limited.`),
262
+ b.info(`${this.Xa(i)}SDK request being rate limited.`),
261
263
  void ("function" == typeof r && r())
262
264
  );
263
265
  const n = this.yl();
264
266
  if (!n.wl)
265
267
  return (
266
268
  this.Tl(n.Nl, t, e, i),
267
- void E.info(
268
- `${this.$a(
269
+ void b.info(
270
+ `${this.Xa(
269
271
  i,
270
272
  )}SDK request being rate limited. Request will be retried in ${Math.trunc(
271
273
  n.Nl / 1e3,
272
274
  )} seconds.`,
273
275
  )
274
276
  );
275
- this.C.It(s.Tt.Cl, new Date().valueOf());
277
+ this.j.Pt(s.It.Bl, new Date().valueOf());
276
278
  const o = t.device;
277
279
  o && o.os_version instanceof Promise
278
280
  ? o.os_version.then((i) => {
@@ -280,7 +282,7 @@ export default class Vt {
280
282
  })
281
283
  : e(n.Sl);
282
284
  }
283
- Bl(t) {
285
+ Cl(t) {
284
286
  const e = t ? Oe(t) : null;
285
287
  if (!e || !e["retry-after"]) return null;
286
288
  const i = e["retry-after"];
@@ -291,21 +293,21 @@ export default class Vt {
291
293
  {
292
294
  const t =
293
295
  "Received unexpected value for retry-after header in /sync response";
294
- v.wt(p.Ya, { e: t + ": " + i });
296
+ v.Dt(p.Ya, { e: t + ": " + i });
295
297
  }
296
298
  return null;
297
299
  }
298
300
  yt(t, e, i, s, r, n) {
299
- if (h.Al(this.C, i) >= Pe) return;
301
+ if (h.Al(this.j, i) >= Pe) return;
300
302
  let o;
301
303
  n = n || 0;
302
- const a = this.Bl(t);
304
+ const a = this.Cl(t);
303
305
  r();
304
306
  const u = (t) => {
305
307
  const r = window.setTimeout(() => {
306
308
  e();
307
309
  }, t);
308
- s(r), h.zl(this.C, i);
310
+ s(r), h.zl(this.j, i);
309
311
  };
310
312
  if (a && !isNaN(a.value)) {
311
313
  switch (a.type) {
@@ -316,46 +318,46 @@ export default class Vt {
316
318
  o = a.value + n;
317
319
  }
318
320
  u(o);
319
- } else n ? u(n) : h.Li(this.C, i);
321
+ } else n ? u(n) : h.Ji(this.j, i);
320
322
  }
321
323
  jl(t) {
322
324
  var e;
323
- null === (e = this.C) || void 0 === e || e.It(s.Tt.Ml, t);
325
+ null === (e = this.j) || void 0 === e || e.Pt(s.It.Ml, t);
324
326
  }
325
- $l(t, e) {
326
- let i = this.Xl();
327
- null == i && (i = {}), (i[t] = e), this.C.It(s.Tt.Ll, i);
327
+ Xl(t, e) {
328
+ let i = this.$l();
329
+ null == i && (i = {}), (i[t] = e), this.j.Pt(s.It.Ll, i);
328
330
  }
329
331
  El() {
330
332
  var t;
331
- return null === (t = this.C) || void 0 === t ? void 0 : t.Rt(s.Tt.Ml);
333
+ return null === (t = this.j) || void 0 === t ? void 0 : t.St(s.It.Ml);
332
334
  }
333
- Xl() {
335
+ $l() {
334
336
  var t;
335
- return null === (t = this.C) || void 0 === t ? void 0 : t.Rt(s.Tt.Ll);
337
+ return null === (t = this.j) || void 0 === t ? void 0 : t.St(s.It.Ll);
336
338
  }
337
339
  Fl(t, e, i, s, r = "") {
338
340
  let n;
339
341
  if (r) {
340
- const t = this.Xl();
342
+ const t = this.$l();
341
343
  n = null == t || isNaN(t[r]) ? e : t[r];
342
344
  } else (n = this.El()), (null == n || isNaN(n)) && (n = e);
343
345
  const o = (t - s) / 1e3;
344
346
  return (n = Math.min(n + o / i, e)), n;
345
347
  }
346
- Kl(t, e) {
348
+ Il(t, e) {
347
349
  return Math.max(0, (1 - t) * e * 1e3);
348
350
  }
349
- Il(t, e = "") {
351
+ Kl(t, e = "") {
350
352
  var i, r, n, o, a;
351
353
  const u = { wl: !0, Sl: -1, Nl: 0 };
352
354
  if ((null == t && (t = !0), !t && !e)) return u;
353
355
  let l,
354
356
  c,
355
357
  d = null;
356
- if (t) d = null === (i = this.C) || void 0 === i ? void 0 : i.Rt(s.Tt.Cl);
358
+ if (t) d = null === (i = this.j) || void 0 === i ? void 0 : i.St(s.It.Bl);
357
359
  else {
358
- const t = h.Pl(this.C);
360
+ const t = h.Pl(this.j);
359
361
  if (null == t || null == t[e]) return u;
360
362
  d = t[e];
361
363
  }
@@ -375,17 +377,17 @@ export default class Vt {
375
377
  const f = new Date().valueOf();
376
378
  let m = this.Fl(f, l, c, d, e);
377
379
  return m < 1
378
- ? ((u.wl = !1), (u.Nl = this.Kl(m, c)), u)
380
+ ? ((u.wl = !1), (u.Nl = this.Il(m, c)), u)
379
381
  : ((m = Math.trunc(m) - 1),
380
382
  (u.Sl = m),
381
- t ? this.jl(m) : this.$l(e, m),
383
+ t ? this.jl(m) : this.Xl(e, m),
382
384
  u);
383
385
  }
384
386
  yl() {
385
- return this.Il(!0);
387
+ return this.Kl(!0);
386
388
  }
387
389
  kl(t) {
388
- const e = this.Il(!1, t);
390
+ const e = this.Kl(!1, t);
389
391
  return !(e && !e.wl);
390
392
  }
391
393
  ct() {
@@ -395,6 +397,6 @@ export default class Vt {
395
397
  return this.Yh;
396
398
  }
397
399
  addSdkMetadata(t) {
398
- for (const e of t) -1 === this.Xa.indexOf(e) && this.Xa.push(e);
400
+ for (const e of t) -1 === this.$a.indexOf(e) && this.$a.push(e);
399
401
  }
400
402
  }
@@ -1,6 +1,6 @@
1
1
  import { STORAGE_KEYS as s } from "./storage-manager.js";
2
2
  import f from "./subscription-manager.js";
3
- import ci from "../models/server-config.js";
3
+ import di from "../models/server-config.js";
4
4
  import v from "../common/event-logger.js";
5
5
  import { EventTypes as p } from "../../shared-lib/index.js";
6
6
  import {
@@ -11,163 +11,174 @@ import {
11
11
  } from "../common/constants.js";
12
12
  export default class Yt {
13
13
  constructor(t) {
14
- (this.C = t),
15
- (this.C = t),
14
+ (this.j = t),
15
+ (this.j = t),
16
16
  (this.Gl = new f()),
17
17
  (this._l = new f()),
18
18
  (this.Vl = new f()),
19
19
  (this.Jl = new f()),
20
20
  (this.Ql = new f()),
21
- (this.Wl = null),
22
- (this.Yl = null);
23
- }
24
- Zl() {
25
- if (null == this.Yl) {
26
- const t = this.C.Rt(s.Tt.tc);
27
- this.Yl = null != t ? ci._u(t) : new ci();
21
+ (this.Wl = new f()),
22
+ (this.Yl = null),
23
+ (this.Zl = null);
24
+ }
25
+ ed() {
26
+ if (null == this.Zl) {
27
+ const t = this.j.St(s.It.sd);
28
+ this.Zl = null != t ? di._u(t) : new di();
28
29
  }
29
- return this.Yl;
30
+ return this.Zl;
30
31
  }
31
- Ot() {
32
- return this.Zl().ec;
32
+ Qt() {
33
+ return this.ed().nd;
33
34
  }
34
- sc(t) {
35
- var i, e, n, r;
35
+ ld(t) {
36
+ var i, e, n, l, r, o;
36
37
  if (null != t && null != t.config) {
37
- const l = t.config;
38
- if (l.time > this.Zl().ec) {
39
- const t = (t) => (null == t ? this.Zl().nc : t),
40
- u = new ci(
41
- l.time,
42
- l.events_blacklist,
43
- l.attributes_blacklist,
44
- l.purchases_blacklist,
45
- l.messaging_session_timeout,
46
- l.vapid_public_key,
47
- l.content_cards,
48
- l.feature_flags,
49
- t(l.global_request_rate_limit),
50
- l.banners,
51
- l.dust,
52
- l.request_backoff,
53
- l.minimum_session_timeout,
38
+ const u = t.config;
39
+ if (u.time > this.ed().nd) {
40
+ const t = (t) => (null == t ? this.ed().ud : t),
41
+ a = new di(
42
+ u.time,
43
+ u.events_blacklist,
44
+ u.attributes_blacklist,
45
+ u.purchases_blacklist,
46
+ u.messaging_session_timeout,
47
+ u.vapid_public_key,
48
+ u.content_cards,
49
+ u.feature_flags,
50
+ t(u.global_request_rate_limit),
51
+ u.banners,
52
+ u.dust,
53
+ u.request_backoff,
54
+ u.minimum_session_timeout,
55
+ u.conversational_chat,
54
56
  );
55
- let o = !1;
56
- null != u.rc && this.ju() !== u.rc && (o = !0);
57
- let a = !1;
58
- null != u.lc.enabled && this.Bi() !== u.lc.enabled && (a = !0);
59
57
  let h = !1;
60
- null != u.Xr.enabled && this.lo() !== u.Xr.enabled && (h = !0);
58
+ null != a.ad && this.ju() !== a.ad && (h = !0);
59
+ let d = !1;
60
+ null != a.hd.enabled && this.Pi() !== a.hd.enabled && (d = !0);
61
61
  let c = !1;
62
+ null != a.Xr.enabled && this.lo() !== a.Xr.enabled && (c = !0);
63
+ let v = !1;
62
64
  null !=
63
- (null === (i = u.banners) || void 0 === i ? void 0 : i.enabled) &&
64
- this.Jt() !==
65
- (null === (e = u.banners) || void 0 === e ? void 0 : e.enabled) &&
66
- (c = !0);
67
- let d = !1;
68
- null != (null === (n = u.dust) || void 0 === n ? void 0 : n.enabled) &&
65
+ (null === (i = a.banners) || void 0 === i ? void 0 : i.enabled) &&
66
+ this.Ot() !==
67
+ (null === (e = a.banners) || void 0 === e ? void 0 : e.enabled) &&
68
+ (v = !0);
69
+ let m = !1;
70
+ null != (null === (n = a.dust) || void 0 === n ? void 0 : n.enabled) &&
69
71
  this.fn() !==
70
- (null === (r = u.dust) || void 0 === r ? void 0 : r.enabled) &&
71
- (d = !0),
72
- (this.Yl = u),
73
- this.C.It(s.Tt.tc, u.qt()),
74
- o && this.Gl.A(),
75
- a && this._l.A(),
76
- h && this.Vl.A(),
77
- c && this.Jl.A(),
78
- d && this.Ql.A();
72
+ (null === (l = a.dust) || void 0 === l ? void 0 : l.enabled) &&
73
+ (m = !0);
74
+ let g = !1;
75
+ null != (null === (r = a.dd) || void 0 === r ? void 0 : r.enabled) &&
76
+ this.vd() !==
77
+ (null === (o = a.dd) || void 0 === o ? void 0 : o.enabled) &&
78
+ (g = !0),
79
+ (this.Zl = a),
80
+ this.j.Pt(s.It.sd, a.qt()),
81
+ h && this.Gl.A(),
82
+ d && this._l.A(),
83
+ c && this.Vl.A(),
84
+ v && this.Jl.A(),
85
+ m && this.Ql.A(),
86
+ g && this.Wl.A();
79
87
  }
80
88
  }
81
89
  }
82
90
  xu(t) {
83
- const i = this.Gl.Kt(t);
84
- return this.Wl && this.Gl.removeSubscription(this.Wl), (this.Wl = i), i;
91
+ const i = this.Gl.Ut(t);
92
+ return this.Yl && this.Gl.removeSubscription(this.Yl), (this.Yl = i), i;
85
93
  }
86
- Mi(t) {
87
- return this._l.Kt(t);
94
+ $i(t) {
95
+ return this._l.Ut(t);
88
96
  }
89
97
  bo(t) {
90
- return this.Vl.Kt(t);
98
+ return this.Vl.Ut(t);
91
99
  }
92
100
  V(t) {
93
- return this.Jl.Kt(t);
101
+ return this.Jl.Ut(t);
94
102
  }
95
103
  Tr(t) {
96
- return this.Ql.Kt(t);
104
+ return this.Ql.Ut(t);
105
+ }
106
+ md(t) {
107
+ return this.Wl.Ut(t);
97
108
  }
98
109
  $e(t) {
99
- return -1 !== this.Zl().uc.indexOf(t);
110
+ return -1 !== this.ed().gd.indexOf(t);
100
111
  }
101
112
  qu(t) {
102
- return -1 !== this.Zl().oc.indexOf(t);
113
+ return -1 !== this.ed().bd.indexOf(t);
103
114
  }
104
- Dr(t) {
105
- return -1 !== this.Zl().ac.indexOf(t);
115
+ $r(t) {
116
+ return -1 !== this.ed().fd.indexOf(t);
106
117
  }
107
- hc() {
108
- return this.Zl().cc;
118
+ pd() {
119
+ return this.ed().Rd;
109
120
  }
110
121
  ju() {
111
- return this.Zl().rc;
122
+ return this.ed().ad;
112
123
  }
113
- Bi() {
114
- return this.Zl().lc.enabled || !1;
124
+ Pi() {
125
+ return this.ed().hd.enabled || !1;
115
126
  }
116
- dc() {
117
- const t = this.Zl().nc;
127
+ Cd() {
128
+ const t = this.ed().ud;
118
129
  return !(!t || null == t.enabled) && t.enabled;
119
130
  }
120
131
  Ul() {
121
- if (!this.dc()) return -1;
122
- const t = this.Zl().nc;
132
+ if (!this.Cd()) return -1;
133
+ const t = this.ed().ud;
123
134
  return null == t.capacity || t.capacity < 10 ? -1 : t.capacity;
124
135
  }
125
136
  xl() {
126
- if (!this.dc()) return -1;
127
- const t = this.Zl().nc;
137
+ if (!this.Cd()) return -1;
138
+ const t = this.ed().ud;
128
139
  return null == t.refill_rate || t.refill_rate <= 0 ? -1 : t.refill_rate;
129
140
  }
130
- mc(t) {
131
- const i = this.Zl().nc.endpoint_overrides;
141
+ Ed(t) {
142
+ const i = this.ed().ud.endpoint_overrides;
132
143
  return null == i ? null : i[t];
133
144
  }
134
145
  Hl(t) {
135
- const i = this.mc(t);
146
+ const i = this.Ed(t);
136
147
  return null == i || isNaN(i.capacity) || i.capacity <= 0 ? -1 : i.capacity;
137
148
  }
138
149
  Ol(t) {
139
- const i = this.mc(t);
150
+ const i = this.Ed(t);
140
151
  return null == i || isNaN(i.refill_rate) || i.refill_rate <= 0
141
152
  ? -1
142
153
  : i.refill_rate;
143
154
  }
144
155
  lo() {
145
- return this.Zl().Xr.enabled && null == this.Ro()
146
- ? (v.wt(p.Ya, { e: "Missing feature flag refresh_rate_limit." }), !1)
147
- : this.Zl().Xr.enabled || !1;
156
+ return this.ed().Xr.enabled && null == this.Ro()
157
+ ? (v.Dt(p.Ya, { e: "Missing feature flag refresh_rate_limit." }), !1)
158
+ : this.ed().Xr.enabled || !1;
148
159
  }
149
160
  Ro() {
150
- return this.Zl().Xr.refresh_rate_limit;
161
+ return this.ed().Xr.refresh_rate_limit;
151
162
  }
152
- Jt() {
163
+ Ot() {
153
164
  var t;
154
165
  return (
155
- (null === (t = this.Zl().banners) || void 0 === t ? void 0 : t.enabled) ||
166
+ (null === (t = this.ed().banners) || void 0 === t ? void 0 : t.enabled) ||
156
167
  null
157
168
  );
158
169
  }
159
170
  re() {
160
171
  var t;
161
172
  return (
162
- (null === (t = this.Zl().banners) || void 0 === t
173
+ (null === (t = this.ed().banners) || void 0 === t
163
174
  ? void 0
164
175
  : t.max_placements) || 0
165
176
  );
166
177
  }
167
- Xt() {
178
+ Gt() {
168
179
  var t;
169
180
  const i =
170
- null === (t = this.Zl().banners) || void 0 === t
181
+ null === (t = this.ed().banners) || void 0 === t
171
182
  ? void 0
172
183
  : t.dismissals_cache_size;
173
184
  return null != i && "number" == typeof i && i > 0 ? i : u;
@@ -175,13 +186,19 @@ export default class Yt {
175
186
  fn() {
176
187
  var t;
177
188
  return (
178
- (null === (t = this.Zl().dust) || void 0 === t ? void 0 : t.enabled) || !1
189
+ (null === (t = this.ed().dust) || void 0 === t ? void 0 : t.enabled) || !1
190
+ );
191
+ }
192
+ vd() {
193
+ var t;
194
+ return (
195
+ (null === (t = this.ed().dd) || void 0 === t ? void 0 : t.enabled) || !1
179
196
  );
180
197
  }
181
198
  vt() {
182
199
  var t;
183
200
  const i =
184
- null === (t = this.Zl().vc) || void 0 === t
201
+ null === (t = this.ed().wd) || void 0 === t
185
202
  ? void 0
186
203
  : t.min_sleep_duration_ms;
187
204
  return null != i ? i : d;
@@ -189,18 +206,18 @@ export default class Yt {
189
206
  gt() {
190
207
  var t;
191
208
  const i =
192
- null === (t = this.Zl().vc) || void 0 === t ? void 0 : t.scale_factor;
209
+ null === (t = this.ed().wd) || void 0 === t ? void 0 : t.scale_factor;
193
210
  return null != i ? i : m;
194
211
  }
195
212
  bt() {
196
213
  var t;
197
214
  const i =
198
- null === (t = this.Zl().vc) || void 0 === t
215
+ null === (t = this.ed().wd) || void 0 === t
199
216
  ? void 0
200
217
  : t.max_sleep_duration_ms;
201
218
  return null != i ? i : c;
202
219
  }
203
- gc() {
204
- return this.Zl().fc;
220
+ Bd() {
221
+ return this.ed().Td;
205
222
  }
206
223
  }