@braze/web-sdk 5.9.1 → 6.1.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 (176) hide show
  1. package/index.d.ts +209 -283
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +27 -29
  5. package/shared-lib/guid.js +3 -3
  6. package/shared-lib/indexed-db-adapter.js +22 -22
  7. package/shared-lib/logger.js +18 -18
  8. package/shared-lib/supported-options.js +22 -23
  9. package/src/Banner/banner-factory.js +2 -1
  10. package/src/Banner/banner-provider-factory.js +7 -7
  11. package/src/Banner/banner-provider.js +92 -98
  12. package/src/Banner/banner.js +21 -18
  13. package/src/Banner/display/banner-to-html.js +18 -30
  14. package/src/Banner/display/detect-banner-impressions.js +11 -11
  15. package/src/Banner/get-all-banners.js +5 -5
  16. package/src/Banner/get-banner.js +7 -7
  17. package/src/Banner/index.js +0 -1
  18. package/src/Banner/log-banner-click.js +7 -7
  19. package/src/Banner/log-banner-impressions.js +9 -9
  20. package/src/Banner/request-banners-refresh.js +23 -27
  21. package/src/Banner/subscribe-to-banners-updates.js +9 -9
  22. package/src/Banner/ui/insert-banner.js +10 -10
  23. package/src/Card/card-manager-factory.js +7 -7
  24. package/src/Card/card-manager.js +45 -47
  25. package/src/Card/display/card-display.js +76 -74
  26. package/src/Card/index.js +0 -2
  27. package/src/Card/log-card-dismissal.js +4 -4
  28. package/src/Card/log-content-card-click.js +9 -2
  29. package/src/Card/log-content-card-impressions.js +11 -2
  30. package/src/Card/models/captioned-image.js +21 -21
  31. package/src/Card/models/card.js +116 -110
  32. package/src/Card/models/classic-card.js +21 -21
  33. package/src/Card/models/control-card.js +15 -15
  34. package/src/Card/models/image-only.js +20 -21
  35. package/src/Card/util/card-factory.js +58 -79
  36. package/src/ContentCards/content-cards-provider-factory.js +13 -13
  37. package/src/ContentCards/content-cards-provider.js +148 -148
  38. package/src/ContentCards/content-cards.js +21 -13
  39. package/src/ContentCards/get-cached-content-cards.js +2 -2
  40. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  41. package/src/ContentCards/subscribe-to-content-cards-updates.js +8 -8
  42. package/src/ContentCards/ui/hide-content-cards.js +5 -5
  43. package/src/ContentCards/ui/show-content-cards.js +35 -35
  44. package/src/Core/add-sdk-metadata.js +5 -5
  45. package/src/Core/change-user.js +7 -7
  46. package/src/Core/destroy.js +2 -2
  47. package/src/Core/disable-sdk.js +10 -10
  48. package/src/Core/enable-sdk.js +7 -7
  49. package/src/Core/get-device-id.js +4 -4
  50. package/src/Core/get-user.js +1 -1
  51. package/src/Core/handle-braze-action.js +10 -10
  52. package/src/Core/is-disabled.js +2 -2
  53. package/src/Core/is-initialized.js +1 -1
  54. package/src/Core/log-custom-event.js +18 -18
  55. package/src/Core/log-purchase.js +19 -19
  56. package/src/Core/open-session.js +13 -13
  57. package/src/Core/request-immediate-data-flush.js +1 -1
  58. package/src/Core/set-logger.js +2 -2
  59. package/src/Core/toggle-logging.js +2 -2
  60. package/src/Core/wipe-data.js +9 -9
  61. package/src/FeatureFlags/feature-flag-factory.js +10 -10
  62. package/src/FeatureFlags/feature-flag.js +20 -71
  63. package/src/FeatureFlags/feature-flags-provider-factory.js +7 -7
  64. package/src/FeatureFlags/feature-flags-provider.js +86 -86
  65. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  66. package/src/FeatureFlags/get-feature-flag.js +3 -3
  67. package/src/FeatureFlags/log-feature-flag-impression.js +8 -8
  68. package/src/FeatureFlags/refresh-feature-flags.js +1 -1
  69. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
  70. package/src/InAppMessage/defer-in-app-message.js +4 -4
  71. package/src/InAppMessage/display/html-message-to-html.js +41 -41
  72. package/src/InAppMessage/display/in-app-message-to-html.js +145 -139
  73. package/src/InAppMessage/display/modal-utils.js +40 -42
  74. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  75. package/src/InAppMessage/in-app-message-factory.js +24 -16
  76. package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
  77. package/src/InAppMessage/in-app-message-manager.js +124 -122
  78. package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
  79. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  80. package/src/InAppMessage/log-in-app-message-html-click.js +11 -11
  81. package/src/InAppMessage/log-in-app-message-impression.js +4 -4
  82. package/src/InAppMessage/models/control-message.js +5 -5
  83. package/src/InAppMessage/models/full-screen-message.js +41 -35
  84. package/src/InAppMessage/models/html-message.js +28 -26
  85. package/src/InAppMessage/models/in-app-message-button.js +5 -5
  86. package/src/InAppMessage/models/in-app-message.js +156 -152
  87. package/src/InAppMessage/models/modal-message.js +40 -34
  88. package/src/InAppMessage/models/slide-up-message.js +38 -32
  89. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  90. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  91. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  92. package/src/InAppMessage/ui/show-in-app-message.js +68 -74
  93. package/src/Push/is-push-blocked.js +2 -2
  94. package/src/Push/is-push-permission-granted.js +2 -2
  95. package/src/Push/is-push-supported.js +2 -2
  96. package/src/Push/push-manager-factory.js +17 -17
  97. package/src/Push/push-manager.js +127 -127
  98. package/src/Push/request-push-permission.js +1 -1
  99. package/src/Push/utils/push-utils.js +25 -15
  100. package/src/User/user-manager.js +20 -20
  101. package/src/User/user.js +60 -61
  102. package/src/common/base-provider.js +1 -1
  103. package/src/common/content-cards-display.js +211 -0
  104. package/src/common/event-logger.js +12 -12
  105. package/src/common/properties-base.js +56 -0
  106. package/src/index.js +0 -1
  107. package/src/l10n/l10n-manager-factory.js +10 -10
  108. package/src/l10n/l10n-manager.js +7 -7
  109. package/src/managers/auth-manager.js +36 -36
  110. package/src/managers/braze-instance.js +184 -185
  111. package/src/managers/device-manager.js +26 -26
  112. package/src/managers/network-manager.js +194 -193
  113. package/src/managers/server-config-manager.js +75 -75
  114. package/src/managers/session-manager.js +29 -29
  115. package/src/managers/storage-manager-factory.js +13 -13
  116. package/src/managers/storage-manager.js +162 -164
  117. package/src/managers/subscription-manager.js +12 -12
  118. package/src/managers/utils.js +1 -1
  119. package/src/models/backend-errors.js +5 -5
  120. package/src/models/braze-event.js +16 -16
  121. package/src/models/device.js +3 -3
  122. package/src/models/identifier.js +8 -8
  123. package/src/models/push-token.js +10 -10
  124. package/src/models/request-result.js +4 -4
  125. package/src/models/server-config.js +33 -33
  126. package/src/request-controller.js +193 -192
  127. package/src/triggers/models/custom-event-data.js +7 -7
  128. package/src/triggers/models/custom-event-property-data.js +8 -8
  129. package/src/triggers/models/filter-set.js +8 -8
  130. package/src/triggers/models/filter.js +43 -43
  131. package/src/triggers/models/in-app-message-click-data.js +4 -4
  132. package/src/triggers/models/purchase-data.js +2 -2
  133. package/src/triggers/models/purchase-property-data.js +6 -6
  134. package/src/triggers/models/push-click-data.js +2 -2
  135. package/src/triggers/models/trigger-condition.js +52 -52
  136. package/src/triggers/models/trigger-events.js +4 -4
  137. package/src/triggers/models/trigger.js +19 -19
  138. package/src/triggers/triggers-provider-factory.js +14 -14
  139. package/src/triggers/triggers-provider.js +70 -70
  140. package/src/ui/js/attach-css.js +3 -3
  141. package/src/ui/js/banner-css.js +1 -1
  142. package/src/ui/js/iam-css.js +1 -1
  143. package/src/ui/js/load-font-awesome.js +2 -2
  144. package/src/util/base-device-parser.js +4 -4
  145. package/src/util/braze-actions.js +12 -18
  146. package/src/util/browser-detector.js +27 -20
  147. package/src/util/client-hints-parser.js +8 -8
  148. package/src/util/code-utils.js +2 -2
  149. package/src/util/component-utils.js +14 -14
  150. package/src/util/deprecation-utils.js +2 -2
  151. package/src/util/device-constants.js +5 -5
  152. package/src/util/dom-utils.js +9 -9
  153. package/src/util/html-display-utils.js +38 -38
  154. package/src/util/key-codes.js +1 -1
  155. package/src/util/net.js +12 -12
  156. package/src/util/request-header-utils.js +22 -22
  157. package/src/util/string-utils.js +2 -2
  158. package/src/util/user-agent-parser.js +17 -17
  159. package/src/util/validation-utils.js +28 -28
  160. package/src/util/window-utils.js +2 -2
  161. package/src/Card/log-card-click.js +0 -11
  162. package/src/Card/log-card-impressions.js +0 -13
  163. package/src/Feed/feed-provider-factory.js +0 -18
  164. package/src/Feed/feed-provider.js +0 -90
  165. package/src/Feed/feed.js +0 -20
  166. package/src/Feed/get-cached-feed.js +0 -5
  167. package/src/Feed/index.js +0 -8
  168. package/src/Feed/log-feed-displayed.js +0 -7
  169. package/src/Feed/request-feed-refresh.js +0 -5
  170. package/src/Feed/subscribe-to-feed-updates.js +0 -5
  171. package/src/Feed/types.js +0 -1
  172. package/src/Feed/ui/hide-feed.js +0 -7
  173. package/src/Feed/ui/show-feed.js +0 -96
  174. package/src/Feed/ui/toggle-feed.js +0 -8
  175. package/src/common/base-feed.js +0 -29
  176. package/src/common/feed-display.js +0 -211
@@ -1,84 +1,84 @@
1
1
  import Xt from "../models/backend-errors.js";
2
- import ve from "../models/braze-event.js";
2
+ import ue from "../models/braze-event.js";
3
3
  import {
4
- convertMsToSeconds as O,
5
- convertSecondsToMs as $t,
4
+ convertMsToSeconds as X,
5
+ convertSecondsToMs as Yt,
6
6
  } from "../util/date-utils.js";
7
7
  import c from "../common/event-logger.js";
8
- import { isArray as z, isEqual as ii } from "../util/code-utils.js";
9
- import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
8
+ import { isArray as D, isEqual as ii } from "../util/code-utils.js";
9
+ import { logger as E, EventTypes as m } 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 {
13
- LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Kt,
14
- MAX_RETRY_COUNT_PER_REQUEST as Ht,
13
+ LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Zt,
14
+ MAX_RETRY_COUNT_PER_REQUEST as he,
15
15
  } from "../common/constants.js";
16
- import { getAlias as Yt } from "./utils.js";
17
- import { readResponseHeaders as Jt } from "../util/net.js";
18
- export default class Pt {
16
+ import { getAlias as ce } from "./utils.js";
17
+ import { readResponseHeaders as ve } from "../util/net.js";
18
+ export default class Mt {
19
19
  constructor(t, e, i, s, r, n, o, a, h, u, l, c) {
20
- (this.hn = t),
21
- (this.C = e),
22
- (this.Pa = i),
20
+ (this.on = t),
21
+ (this.j = e),
22
+ (this.Qh = i),
23
23
  (this.Cs = s),
24
- (this.T = r),
25
- (this.B = n),
26
- (this.an = o),
27
- (this.La = a),
28
- (this.Ta = h),
29
- (this.Ra = u),
24
+ (this.C = r),
25
+ (this.h = n),
26
+ (this.sn = o),
27
+ (this.Ea = a),
28
+ (this.Xh = h),
29
+ (this.Zh = u),
30
30
  (this.appVersion = l),
31
- (this.au = c),
32
- (this.du = (t) => (null == t ? "" : `${t} `)),
33
- (this.hn = t),
34
- (this.C = e),
35
- (this.Pa = i),
31
+ (this.$a = c),
32
+ (this.Xa = (t) => (null == t ? "" : `${t} `)),
33
+ (this.on = t),
34
+ (this.j = e),
35
+ (this.Qh = i),
36
36
  (this.Cs = s),
37
- (this.T = r),
38
- (this.B = n),
39
- (this.an = o),
40
- (this.La = a),
41
- (this.Ta = h),
42
- (this.Ra = u),
37
+ (this.C = r),
38
+ (this.h = n),
39
+ (this.sn = o),
40
+ (this.Ea = a),
41
+ (this.Xh = h),
42
+ (this.Zh = u),
43
43
  (this.appVersion = l),
44
- (this.au = c),
45
- (this.fu = ["npm"]),
46
- (this.vu = []);
44
+ (this.$a = c),
45
+ (this.Ya = ["npm"]),
46
+ (this.Za = {});
47
47
  }
48
- H(t, e = !1, i = !1) {
49
- const r = this.hn.ve(!i),
50
- n = r.Nr(),
51
- o = this.C.ft(s.gt.oc);
48
+ $(t, e = !1, i = !1) {
49
+ const r = this.on.fe(!i),
50
+ n = r.Ar(),
51
+ o = this.j.lt(s.ct.Qa);
52
52
  ii(o, n) || (t.device = n),
53
- (t.api_key = this.an),
54
- (t.time = O(new Date().valueOf(), !0));
55
- const a = this.C.ft(s.gt.pu) || [],
56
- h = this.C.ft(s.gt.Ru) || "";
57
- this.fu.length > 0 &&
58
- (!ii(a, this.fu) || h !== this.T.St()) &&
59
- (t.sdk_metadata = this.fu),
60
- (t.sdk_version = this.Ta),
61
- this.Ra && (t.sdk_flavor = this.Ra),
53
+ (t.api_key = this.sn),
54
+ (t.time = X(new Date().valueOf(), !0));
55
+ const a = this.j.lt(s.ct.au) || [],
56
+ h = this.j.lt(s.ct.du) || "";
57
+ this.Ya.length > 0 &&
58
+ (!ii(a, this.Ya) || h !== this.C.bt()) &&
59
+ (t.sdk_metadata = this.Ya),
60
+ (t.sdk_version = this.Xh),
61
+ this.Zh && (t.sdk_flavor = this.Zh),
62
62
  (t.app_version = this.appVersion),
63
- (t.app_version_code = this.au),
63
+ (t.app_version_code = this.$a),
64
64
  (t.device_id = r.id);
65
65
  const u = this.Cs.getUserId();
66
- if ((e && null !== u && (t.user_id = u), !u && !this.Pa.jh())) {
67
- const e = Yt(this.C);
66
+ if ((e && null !== u && (t.user_id = u), !u && !this.Qh.fh())) {
67
+ const e = ce(this.j);
68
68
  e && (t.alias = e);
69
69
  }
70
70
  return t;
71
71
  }
72
- st(t, e, i) {
72
+ Y(t, e, i) {
73
73
  const s = e.auth_error,
74
74
  r = e.error;
75
75
  if (!s && !r) return !0;
76
76
  if (s) {
77
77
  let e;
78
- this.Pa.Jh();
78
+ this.Qh.Gh();
79
79
  const r = { errorCode: s.error_code };
80
80
  for (const t of i)
81
- z(t) && "X-Braze-Auth-Signature" === t[0] && (r.signature = t[1]);
81
+ D(t) && "X-Braze-Auth-Signature" === t[0] && (r.signature = t[1]);
82
82
  t.respond_with && t.respond_with.user_id
83
83
  ? (r.userId = t.respond_with.user_id)
84
84
  : t.user_id && (r.userId = t.user_id);
@@ -87,12 +87,12 @@ export default class Pt {
87
87
  n
88
88
  ? ((r.reason = n), (e = `due to ${n}`))
89
89
  : (e = `with error code ${s.error_code}.`),
90
- this.Pa.jh() ||
90
+ this.Qh.fh() ||
91
91
  (e +=
92
92
  ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
93
- N.error(`SDK Authentication failed ${e}`),
94
- this.gu(t.events || [], t.attributes || []),
95
- this.Pa.Gh(r),
93
+ E.error(`SDK Authentication failed ${e}`),
94
+ this.fu(t.events || [], t.attributes || []),
95
+ this.Qh.yh(r),
96
96
  !1
97
97
  );
98
98
  }
@@ -100,187 +100,188 @@ export default class Pt {
100
100
  let i,
101
101
  s = r;
102
102
  switch (s) {
103
- case Xt.bu:
103
+ case Xt.vu:
104
104
  return (
105
105
  (i = "Received successful response with empty body."),
106
- c.ut(d.qu, { e: i }),
107
- N.info(i),
106
+ c.rt(m.pu, { e: i }),
107
+ E.info(i),
108
108
  !1
109
109
  );
110
- case Xt.Au:
110
+ case Xt.Ru:
111
111
  return (
112
112
  (i = "Received successful response with invalid JSON"),
113
- c.ut(d.qu, { e: i + ": " + e.response }),
114
- N.info(i),
113
+ c.rt(m.pu, { e: i + ": " + e.response }),
114
+ E.info(i),
115
115
  !1
116
116
  );
117
- case Xt.Du:
118
- s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.La}`;
117
+ case Xt.gu:
118
+ s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Ea}`;
119
119
  break;
120
- case Xt.Tu:
120
+ case Xt.bu:
121
121
  s =
122
122
  "Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
123
123
  break;
124
- case Xt.ku:
124
+ case Xt.qu:
125
125
  s = "No device identifier. Please contact support@braze.com";
126
126
  }
127
- N.error("Backend error: " + s);
127
+ E.error("Backend error: " + s);
128
128
  }
129
129
  return !1;
130
130
  }
131
- yu(t, e, i, s) {
132
- return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i || s);
131
+ Au(t, e, i) {
132
+ return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i);
133
133
  }
134
- wu(t, e, i, s, r = !1) {
135
- const n = [],
136
- o = (t) => t || "",
137
- a = o(this.Cs.getUserId());
138
- let u = this.Gr(t, e);
139
- const l = [],
140
- c = [];
141
- let d,
142
- f = null;
143
- if (i.length > 0) {
134
+ Du(t, e, i, s = !1) {
135
+ const r = [],
136
+ n = (t) => t || "",
137
+ o = n(this.Cs.getUserId());
138
+ let a = this.Mr(t);
139
+ const u = [],
140
+ l = [];
141
+ let c,
142
+ d = null;
143
+ if (e.length > 0) {
144
144
  const t = [];
145
- for (const e of i) {
146
- if (((d = e.Nr()), this.Pa.jh())) {
147
- if (a && !d.user_id) {
148
- f || (f = {}), f.events || (f.events = []), f.events.push(d);
145
+ for (const i of e) {
146
+ if (((c = i.Ar()), this.Qh.fh())) {
147
+ if (o && !c.user_id) {
148
+ d || (d = {}), d.events || (d.events = []), d.events.push(c);
149
149
  continue;
150
150
  }
151
- if (o(d.user_id) !== a) {
152
- c.push(d);
151
+ if (n(c.user_id) !== o) {
152
+ l.push(c);
153
153
  continue;
154
154
  }
155
155
  }
156
- t.push(d);
156
+ t.push(c);
157
157
  }
158
- t.length > 0 && (u.events = t);
158
+ t.length > 0 && (a.events = t);
159
159
  }
160
- if (s.length > 0) {
160
+ if (i.length > 0) {
161
161
  const t = [];
162
- for (const e of s)
163
- e && (this.Pa.jh() && o(e.user_id) !== a ? l.push(e) : t.push(e));
164
- t.length > 0 && (u.attributes = t);
162
+ for (const e of i)
163
+ e && (this.Qh.fh() && n(e.user_id) !== o ? u.push(e) : t.push(e));
164
+ t.length > 0 && (a.attributes = t);
165
165
  }
166
- if ((this.gu(c, l), (u = this.H(u, !1, r)), f)) {
167
- f = this.H(f, !1, r);
168
- const t = { requestData: f, headers: this.J(f, h.O.Nu) };
169
- n.push(t);
166
+ if ((this.fu(l, u), (a = this.$(a, !1, s)), d)) {
167
+ d = this.$(d, !1, s);
168
+ const t = { requestData: d, headers: this.A(d, h.H.Tu) };
169
+ r.push(t);
170
170
  }
171
- if (u && !this.yu(u.events, u.attributes, t, e)) return f ? n : null;
172
- const m = { requestData: u, headers: this.J(u, h.O.Nu) };
173
- return n.push(m), n;
171
+ if (a && !this.Au(a.events, a.attributes, t)) return d ? r : null;
172
+ const f = { requestData: a, headers: this.A(a, h.H.Tu) };
173
+ return r.push(f), r;
174
174
  }
175
- gu(t, e) {
175
+ fu(t, e) {
176
176
  if (t) {
177
177
  const e = [];
178
178
  for (const i of t) {
179
- const t = ve.fromJson(i);
180
- (t.time = $t(t.time)), e.push(t);
179
+ const t = ue.fromJson(i);
180
+ (t.time = Yt(t.time)), e.push(t);
181
181
  }
182
- this.C.Vo(e);
182
+ this.j.Eo(e);
183
183
  }
184
- if (e) for (const t of e) this.C.Cu(t);
184
+ if (e) for (const t of e) this.j.ku(t);
185
185
  }
186
- et(t, e) {
186
+ _(t, e) {
187
187
  let i = "HTTP error ";
188
- null != t && (i += t + " "), (i += e), N.error(i);
188
+ null != t && (i += t + " "), (i += e), E.error(i);
189
189
  }
190
- zr(t) {
191
- return c.ut(d.Su, { n: t });
190
+ yu(t) {
191
+ return c.rt(m.wu, { n: t });
192
192
  }
193
- Gr(t, e, i) {
194
- const s = {};
195
- t && (s.feed = !0), e && (s.triggers = !0);
196
- const r = null != i ? i : this.Cs.getUserId();
197
- if ((r && (s.user_id = r), !s.user_id && !this.Pa.jh())) {
198
- const t = Yt(this.C);
199
- t && (s.alias = t);
193
+ Mr(t, e) {
194
+ const i = {};
195
+ t && (i.triggers = !0);
196
+ const s = null != e ? e : this.Cs.getUserId();
197
+ if ((s && (i.user_id = s), !i.user_id && !this.Qh.fh())) {
198
+ const t = ce(this.j);
199
+ t && (i.alias = t);
200
200
  }
201
- return (s.config = { config_time: this.B.Et() }), { respond_with: s };
201
+ return (i.config = { config_time: this.h.Ft() }), { respond_with: i };
202
202
  }
203
- Bu(t) {
203
+ Nu(t) {
204
204
  const e = new Date().valueOf();
205
- let i = Kt.toString();
206
- const s = h.zu(this.C, t);
205
+ let i = Zt.toString();
206
+ const s = h.Cu(this.j, t);
207
207
  if (-1 !== s) {
208
208
  i = (e - s).toString();
209
209
  }
210
210
  return i;
211
211
  }
212
- J(t, e, i = !1) {
213
- const s = [["X-Braze-Api-Key", this.an]],
214
- r = this.Bu(e);
212
+ A(t, e, i = !1) {
213
+ const s = [["X-Braze-Api-Key", this.sn]],
214
+ r = this.Nu(e);
215
215
  s.push(["X-Braze-Last-Req-Ms-Ago", r]);
216
- const n = h.ju(this.C, e).toString();
216
+ const n = h.Su(this.j, e).toString();
217
217
  s.push(["X-Braze-Req-Attempt", n]);
218
218
  let o = !1;
219
219
  if (
220
220
  (null != t.respond_with &&
221
221
  t.respond_with.triggers &&
222
222
  (s.push(["X-Braze-TriggersRequest", "true"]), (o = !0)),
223
- null != t.respond_with &&
224
- t.respond_with.feed &&
225
- (s.push(["X-Braze-FeedRequest", "true"]), (o = !0)),
226
- e === h.O.wi)
223
+ e === h.H.bi)
227
224
  ) {
228
225
  s.push(["X-Braze-ContentCardsRequest", "true"]);
229
- let t = h.ju(this.C, h.O.wi);
230
- (t && !i) || ((t = 1), h.Mu(this.C, h.O.wi, t));
226
+ let t = h.Su(this.j, h.H.bi);
227
+ (t && !i) || ((t = 1), h.Bu(this.j, h.H.bi, t));
231
228
  const e = Math.max(0, t - 1);
232
229
  s.push(["BRAZE-SYNC-RETRY-COUNT", e.toString()]), (o = !0);
233
230
  }
234
231
  if (
235
- (e === h.O.Le &&
232
+ (e === h.H.$e &&
236
233
  (s.push(["X-Braze-FeatureFlagsRequest", "true"]), (o = !0)),
237
234
  o && s.push(["X-Braze-DataRequest", "true"]),
238
- this.Pa.jh())
235
+ this.Qh.fh())
239
236
  ) {
240
- const t = this.Pa.xh();
237
+ const t = this.Qh.wh();
241
238
  null != t && s.push(["X-Braze-Auth-Signature", t]);
242
239
  }
243
240
  return s;
244
241
  }
245
- Xu(t, e, i, s) {
242
+ zu(t, e, i, s) {
243
+ if (this.Za[s]) return;
246
244
  const r = window.setTimeout(() => {
247
- N.info(`Retrying rate limited ${this.du(s)}SDK request.`),
248
- this.V(e, i, s);
245
+ E.info(`Retrying rate limited ${this.Xa(s)}SDK request.`),
246
+ this.J(e, i, s);
249
247
  }, t);
250
- this.vu.push(r);
248
+ this.Za[s] = r;
251
249
  }
252
250
  fo() {
253
- for (const t of this.vu) window.clearTimeout(t);
254
- this.vu = [];
251
+ for (const t in this.Za) {
252
+ const e = this.Za[t];
253
+ window.clearTimeout(e);
254
+ }
255
+ this.Za = {};
255
256
  }
256
- V(t, e, i, r) {
257
- if (!this.$u(i))
257
+ J(t, e, i, r) {
258
+ if (!this.ju(i))
258
259
  return (
259
- N.info(`${this.du(i)}SDK request being rate limited.`),
260
+ E.info(`${this.Xa(i)}SDK request being rate limited.`),
260
261
  void ("function" == typeof r && r())
261
262
  );
262
- const n = this.Fu();
263
- if (!n.Lu)
263
+ const n = this.Mu();
264
+ if (!n.$u)
264
265
  return (
265
- N.info(
266
- `${this.du(
266
+ this.zu(n.Xu, t, e, i),
267
+ void E.info(
268
+ `${this.Xa(
267
269
  i,
268
270
  )}SDK request being rate limited. Request will be retried in ${Math.trunc(
269
- n.Eu / 1e3,
271
+ n.Xu / 1e3,
270
272
  )} seconds.`,
271
- ),
272
- void this.Xu(n.Eu, t, e, i)
273
+ )
273
274
  );
274
- this.C.Bt(s.gt.Ku, new Date().valueOf());
275
+ this.j.ft(s.ct.Lu, new Date().valueOf());
275
276
  const o = t.device;
276
277
  o && o.os_version instanceof Promise
277
278
  ? o.os_version.then((i) => {
278
- (t.device.os_version = i), e(n.Iu);
279
+ (t.device.os_version = i), e(n.Eu);
279
280
  })
280
- : e(n.Iu);
281
+ : e(n.Eu);
281
282
  }
282
- Pu(t) {
283
- const e = t ? Jt(t) : null;
283
+ Fu(t) {
284
+ const e = t ? ve(t) : null;
284
285
  if (!e || !e["retry-after"]) return null;
285
286
  const i = e["retry-after"];
286
287
  if (isNaN(i) && !isNaN(Date.parse(i)))
@@ -290,21 +291,21 @@ export default class Pt {
290
291
  {
291
292
  const t =
292
293
  "Received unexpected value for retry-after header in /sync response";
293
- c.ut(d.qu, { e: t + ": " + i });
294
+ c.rt(m.pu, { e: t + ": " + i });
294
295
  }
295
296
  return null;
296
297
  }
297
- rt(t, e, i, s, r, n) {
298
- if (h.ju(this.C, i) >= Ht) return;
298
+ st(t, e, i, s, r, n) {
299
+ if (h.Su(this.j, i) >= he) return;
299
300
  let o;
300
301
  n = n || 0;
301
- const a = this.Pu(t);
302
+ const a = this.Fu(t);
302
303
  r();
303
304
  const u = (t) => {
304
305
  const r = window.setTimeout(() => {
305
306
  e();
306
307
  }, t);
307
- s(r), h.Uu(this.C, i);
308
+ s(r), h.Ku(this.j, i);
308
309
  };
309
310
  if (a && !isNaN(a.value)) {
310
311
  switch (a.type) {
@@ -315,46 +316,46 @@ export default class Pt {
315
316
  o = a.value + n;
316
317
  }
317
318
  u(o);
318
- } else n ? u(n) : h.vi(this.C, i);
319
+ } else n ? u(n) : h.Ci(this.j, i);
319
320
  }
320
- xu(t) {
321
+ Iu(t) {
321
322
  var e;
322
- null === (e = this.C) || void 0 === e || e.Bt(s.gt.Hu, t);
323
+ null === (e = this.j) || void 0 === e || e.ft(s.ct.Pu, t);
323
324
  }
324
- Ou(t, e) {
325
- let i = this.Gu();
326
- null == i && (i = {}), (i[t] = e), this.C.Bt(s.gt._u, i);
325
+ Uu(t, e) {
326
+ let i = this.xu();
327
+ null == i && (i = {}), (i[t] = e), this.j.ft(s.ct.Hu, i);
327
328
  }
328
- Wu() {
329
+ Ou() {
329
330
  var t;
330
- return null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.Hu);
331
+ return null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.Pu);
331
332
  }
332
- Gu() {
333
+ xu() {
333
334
  var t;
334
- return null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt._u);
335
+ return null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.Hu);
335
336
  }
336
- Yu(t, e, i, s, r = "") {
337
+ Gu(t, e, i, s, r = "") {
337
338
  let n;
338
339
  if (r) {
339
- const t = this.Gu();
340
+ const t = this.xu();
340
341
  n = null == t || isNaN(t[r]) ? e : t[r];
341
- } else (n = this.Wu()), (null == n || isNaN(n)) && (n = e);
342
+ } else (n = this.Ou()), (null == n || isNaN(n)) && (n = e);
342
343
  const o = (t - s) / 1e3;
343
344
  return (n = Math.min(n + o / i, e)), n;
344
345
  }
345
- Ju(t, e) {
346
+ _u(t, e) {
346
347
  return Math.max(0, (1 - t) * e * 1e3);
347
348
  }
348
- Qu(t, e = "") {
349
+ Wu(t, e = "") {
349
350
  var i, r, n, o, a;
350
- const u = { Lu: !0, Iu: -1, Eu: 0 };
351
+ const u = { $u: !0, Eu: -1, Xu: 0 };
351
352
  if ((null == t && (t = !0), !t && !e)) return u;
352
353
  let l,
353
354
  c,
354
355
  d = null;
355
- if (t) d = null === (i = this.C) || void 0 === i ? void 0 : i.ft(s.gt.Ku);
356
+ if (t) d = null === (i = this.j) || void 0 === i ? void 0 : i.lt(s.ct.Lu);
356
357
  else {
357
- const t = h.Vu(this.C);
358
+ const t = h.Yu(this.j);
358
359
  if (null == t || null == t[e]) return u;
359
360
  d = t[e];
360
361
  }
@@ -362,38 +363,38 @@ export default class Pt {
362
363
  if (
363
364
  (t
364
365
  ? ((l =
365
- (null === (r = this.B) || void 0 === r ? void 0 : r.Zu()) || -1),
366
- (c = (null === (n = this.B) || void 0 === n ? void 0 : n.tl()) || -1))
366
+ (null === (r = this.h) || void 0 === r ? void 0 : r.Ju()) || -1),
367
+ (c = (null === (n = this.h) || void 0 === n ? void 0 : n.Qu()) || -1))
367
368
  : ((l =
368
- (null === (o = this.B) || void 0 === o ? void 0 : o.el(e)) || -1),
369
+ (null === (o = this.h) || void 0 === o ? void 0 : o.Vu(e)) || -1),
369
370
  (c =
370
- (null === (a = this.B) || void 0 === a ? void 0 : a.il(e)) || -1)),
371
+ (null === (a = this.h) || void 0 === a ? void 0 : a.Zu(e)) || -1)),
371
372
  -1 === l || -1 === c)
372
373
  )
373
374
  return u;
374
375
  const f = new Date().valueOf();
375
- let m = this.Yu(f, l, c, d, e);
376
+ let m = this.Gu(f, l, c, d, e);
376
377
  return m < 1
377
- ? ((u.Lu = !1), (u.Eu = this.Ju(m, c)), u)
378
+ ? ((u.$u = !1), (u.Xu = this._u(m, c)), u)
378
379
  : ((m = Math.trunc(m) - 1),
379
- (u.Iu = m),
380
- t ? this.xu(m) : this.Ou(e, m),
380
+ (u.Eu = m),
381
+ t ? this.Iu(m) : this.Uu(e, m),
381
382
  u);
382
383
  }
383
- Fu() {
384
- return this.Qu(!0);
384
+ Mu() {
385
+ return this.Wu(!0);
385
386
  }
386
- $u(t) {
387
- const e = this.Qu(!1, t);
388
- return !(e && !e.Lu);
389
- }
390
- it() {
391
- this.Pa.it();
387
+ ju(t) {
388
+ const e = this.Wu(!1, t);
389
+ return !(e && !e.$u);
392
390
  }
393
391
  Z() {
394
- return this.La;
392
+ this.Qh.Z();
393
+ }
394
+ V() {
395
+ return this.Ea;
395
396
  }
396
397
  addSdkMetadata(t) {
397
- for (const e of t) -1 === this.fu.indexOf(e) && this.fu.push(e);
398
+ for (const e of t) -1 === this.Ya.indexOf(e) && this.Ya.push(e);
398
399
  }
399
400
  }