@braze/web-sdk 4.7.1 → 4.8.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 (161) hide show
  1. package/index.d.ts +27 -24
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +5 -5
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +24 -24
  6. package/shared-lib/guid.js +3 -3
  7. package/shared-lib/indexed-db-adapter.js +17 -17
  8. package/shared-lib/logger.js +18 -18
  9. package/shared-lib/supported-options.js +18 -18
  10. package/src/Card/card-manager-factory.js +2 -2
  11. package/src/Card/card-manager.js +47 -41
  12. package/src/Card/display/card-display.js +70 -67
  13. package/src/Card/log-card-click.js +1 -1
  14. package/src/Card/log-card-dismissal.js +1 -1
  15. package/src/Card/log-card-impressions.js +3 -3
  16. package/src/Card/models/banner.js +3 -2
  17. package/src/Card/models/captioned-image.js +6 -5
  18. package/src/Card/models/card.js +107 -87
  19. package/src/Card/models/classic-card.js +5 -5
  20. package/src/Card/models/control-card.js +5 -21
  21. package/src/Card/types.js +1 -0
  22. package/src/Card/util/card-factory.js +32 -32
  23. package/src/ContentCards/content-cards-provider-factory.js +3 -3
  24. package/src/ContentCards/content-cards-provider.js +283 -175
  25. package/src/ContentCards/content-cards.js +2 -2
  26. package/src/ContentCards/get-cached-content-cards.js +1 -1
  27. package/src/ContentCards/log-content-cards-displayed.js +2 -2
  28. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  29. package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
  30. package/src/ContentCards/types.js +1 -0
  31. package/src/ContentCards/ui/hide-content-cards.js +2 -2
  32. package/src/ContentCards/ui/show-content-cards.js +35 -33
  33. package/src/Core/add-sdk-metadata.js +17 -18
  34. package/src/Core/change-user.js +12 -14
  35. package/src/Core/destroy.js +1 -1
  36. package/src/Core/disable-sdk.js +7 -6
  37. package/src/Core/enable-sdk.js +4 -4
  38. package/src/Core/get-device-id.js +7 -6
  39. package/src/Core/get-user.js +1 -1
  40. package/src/Core/handle-braze-action.js +57 -40
  41. package/src/Core/is-disabled.js +2 -2
  42. package/src/Core/log-custom-event.js +22 -15
  43. package/src/Core/log-purchase.js +33 -33
  44. package/src/Core/open-session.js +17 -15
  45. package/src/Core/request-immediate-data-flush.js +4 -2
  46. package/src/Core/set-logger.js +1 -1
  47. package/src/Core/set-sdk-authentication-signature.js +5 -6
  48. package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
  49. package/src/Core/toggle-logging.js +1 -1
  50. package/src/Core/types.js +1 -0
  51. package/src/Core/wipe-data.js +11 -10
  52. package/src/FeatureFlags/feature-flag-factory.js +6 -6
  53. package/src/FeatureFlags/feature-flag.js +17 -17
  54. package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
  55. package/src/FeatureFlags/feature-flags-provider.js +67 -65
  56. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  57. package/src/FeatureFlags/get-feature-flag.js +4 -4
  58. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
  59. package/src/Feed/feed-provider-factory.js +8 -8
  60. package/src/Feed/feed-provider.js +57 -46
  61. package/src/Feed/feed.js +1 -1
  62. package/src/Feed/get-cached-feed.js +2 -2
  63. package/src/Feed/log-feed-displayed.js +3 -1
  64. package/src/Feed/request-feed-refresh.js +2 -2
  65. package/src/Feed/subscribe-to-feed-updates.js +2 -2
  66. package/src/Feed/types.js +1 -0
  67. package/src/Feed/ui/hide-feed.js +2 -2
  68. package/src/Feed/ui/show-feed.js +40 -36
  69. package/src/InAppMessage/display/html-message-to-html.js +125 -119
  70. package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
  71. package/src/InAppMessage/display/modal-utils.js +18 -13
  72. package/src/InAppMessage/in-app-message-factory.js +9 -8
  73. package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
  74. package/src/InAppMessage/in-app-message-manager.js +122 -108
  75. package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
  76. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  77. package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
  78. package/src/InAppMessage/log-in-app-message-impression.js +5 -5
  79. package/src/InAppMessage/models/control-message.js +4 -1
  80. package/src/InAppMessage/models/full-screen-message.js +35 -37
  81. package/src/InAppMessage/models/html-message.js +34 -33
  82. package/src/InAppMessage/models/in-app-message-button.js +23 -16
  83. package/src/InAppMessage/models/in-app-message.js +147 -105
  84. package/src/InAppMessage/models/modal-message.js +34 -36
  85. package/src/InAppMessage/models/slide-up-message.js +25 -27
  86. package/src/InAppMessage/models/templated-in-app-message.js +12 -7
  87. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  88. package/src/InAppMessage/types.js +1 -0
  89. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
  90. package/src/InAppMessage/ui/show-in-app-message.js +95 -89
  91. package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
  92. package/src/Push/is-push-blocked.js +2 -2
  93. package/src/Push/is-push-permission-granted.js +2 -2
  94. package/src/Push/is-push-supported.js +2 -2
  95. package/src/Push/push-manager-factory.js +20 -20
  96. package/src/Push/push-manager.js +192 -174
  97. package/src/Push/request-push-permission.js +4 -3
  98. package/src/Push/types.js +1 -0
  99. package/src/Push/unregister-push.js +2 -2
  100. package/src/Push/utils/push-utils.js +10 -10
  101. package/src/User/types.js +1 -0
  102. package/src/User/user-manager.js +24 -24
  103. package/src/User/user.js +117 -105
  104. package/src/common/base-feed.js +7 -7
  105. package/src/common/base-provider.js +2 -2
  106. package/src/common/constants.js +6 -0
  107. package/src/common/event-logger.js +6 -6
  108. package/src/common/feed-display.js +18 -18
  109. package/src/common/types.js +1 -0
  110. package/src/l10n/l10n-manager-factory.js +5 -5
  111. package/src/l10n/l10n-manager.js +1 -1
  112. package/src/managers/auth-manager.js +32 -32
  113. package/src/managers/braze-instance.js +204 -202
  114. package/src/managers/device-manager.js +23 -23
  115. package/src/managers/network-manager.js +96 -82
  116. package/src/managers/server-config-manager.js +60 -42
  117. package/src/managers/session-manager.js +41 -41
  118. package/src/managers/storage-manager-factory.js +15 -15
  119. package/src/managers/storage-manager.js +165 -155
  120. package/src/managers/subscription-manager.js +11 -11
  121. package/src/models/backend-errors.js +5 -5
  122. package/src/models/braze-event.js +7 -7
  123. package/src/models/device.js +2 -2
  124. package/src/models/identifier.js +7 -7
  125. package/src/models/push-token.js +7 -7
  126. package/src/models/request-result.js +3 -3
  127. package/src/models/server-config.js +20 -20
  128. package/src/request-controller.js +176 -174
  129. package/src/triggers/models/custom-event-data.js +6 -6
  130. package/src/triggers/models/custom-event-property-data.js +9 -9
  131. package/src/triggers/models/filter-set.js +9 -9
  132. package/src/triggers/models/filter.js +64 -64
  133. package/src/triggers/models/in-app-message-click-data.js +12 -12
  134. package/src/triggers/models/purchase-data.js +3 -3
  135. package/src/triggers/models/purchase-property-data.js +9 -9
  136. package/src/triggers/models/push-click-data.js +5 -5
  137. package/src/triggers/models/trigger-condition.js +52 -52
  138. package/src/triggers/models/trigger-events.js +2 -2
  139. package/src/triggers/models/trigger.js +42 -42
  140. package/src/triggers/triggers-provider-factory.js +8 -8
  141. package/src/triggers/triggers-provider.js +171 -168
  142. package/src/types.js +1 -0
  143. package/src/ui/js/attach-css.js +3 -3
  144. package/src/ui/js/load-font-awesome.js +2 -2
  145. package/src/util/base-device-parser.js +1 -1
  146. package/src/util/braze-actions.js +20 -20
  147. package/src/util/browser-detector.js +22 -22
  148. package/src/util/client-hints-parser.js +6 -6
  149. package/src/util/code-utils.js +1 -1
  150. package/src/util/color-utils.js +2 -2
  151. package/src/util/component-utils.js +2 -2
  152. package/src/util/deprecation-utils.js +1 -1
  153. package/src/util/device-constants.js +5 -5
  154. package/src/util/dom-utils.js +2 -2
  155. package/src/util/key-codes.js +1 -1
  156. package/src/util/net.js +11 -11
  157. package/src/util/request-header-utils.js +23 -0
  158. package/src/util/string-utils.js +1 -1
  159. package/src/util/user-agent-parser.js +20 -20
  160. package/src/util/validation-utils.js +44 -44
  161. package/src/util/window-utils.js +3 -3
@@ -1,149 +1,169 @@
1
- import b, { readResponseHeaders as C } from "../util/net.js";
1
+ import C, { readResponseHeaders as b } from "../util/net.js";
2
2
  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
- import { dateFromUnixTimestamp as h } from "../util/date-utils.js";
6
- import { isURIJavascriptOrData as j } from "../util/url-utils.js";
5
+ import { dateFromUnixTimestamp as l } from "../util/date-utils.js";
6
+ import { isURIJavascriptOrData as N } from "../util/url-utils.js";
7
7
  import {
8
- newCardFromContentCardsJson as N,
9
- newCardFromSerializedValue as S
8
+ newCardFromContentCardsJson as j,
9
+ newCardFromSerializedValue as R
10
10
  } from "../Card/util/card-factory.js";
11
11
  import r from "../../shared-lib/braze-shared-lib.js";
12
- import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
13
- import u from "../managers/subscription-manager.js";
12
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
13
+ import E from "../managers/subscription-manager.js";
14
14
  import s from "../common/event-logger.js";
15
+ import T from "../util/request-header-utils.js";
16
+ import { randomInclusive as D } from "../util/math.js";
17
+ import { MAX_ERROR_RETRIES_CONTENT_CARDS as S } from "../common/constants.js";
15
18
  export default class v extends y {
16
19
  constructor(t, s, i, h, n) {
17
20
  super(),
18
- (this.v = t),
19
- (this.h = s),
20
- (this.gt = i),
21
- (this.wt = h),
22
- (this.vt = n),
23
- (this.yt = new u()),
21
+ (this.ft = t),
22
+ (this.u = s),
23
+ (this.wt = i),
24
+ (this.vt = h),
25
+ (this.gt = n),
26
+ (this.ft = t),
27
+ (this.u = s),
28
+ (this.wt = i),
29
+ (this.vt = h),
30
+ (this.gt = n),
31
+ (this.yt = new E()),
24
32
  e.jt(this.yt),
25
- (this.Ut = 0),
26
33
  (this.kt = 0),
27
- this.zt();
28
- const o = r.xt.Ft;
29
- new r.qt(o, r.D).Jt(o.$t.Mt, t => {
30
- this.Bt(t);
34
+ (this.Ut = 0),
35
+ (this.cards = []),
36
+ this.Lt();
37
+ const o = r.zt.Ft;
38
+ new r.xt(o, r.j).Mt(o.Jt.qt, t => {
39
+ this.Pt(t);
31
40
  }),
32
- (this.Gt = null);
41
+ (this.$t = null),
42
+ (this._t = null),
43
+ (this.Bt = null),
44
+ (this.Gt = null),
45
+ (this.Ht = null),
46
+ (this.Kt = null),
47
+ (this.Ot = 10),
48
+ (this.Qt = 0);
33
49
  }
34
- Ht() {
35
- return this.Kt;
50
+ Vt() {
51
+ return this._t;
36
52
  }
37
- Qt(t) {
38
- this.Kt = t;
53
+ Wt(t) {
54
+ this._t = t;
39
55
  }
40
- Vt() {
41
- return this.Wt;
56
+ Xt() {
57
+ return this.Bt;
42
58
  }
43
- Xt(t) {
44
- this.Wt = t;
59
+ Yt(t) {
60
+ this.Bt = t;
45
61
  }
46
- zt() {
47
- const t = this.h.I(o.q.Yt) || [],
62
+ Lt() {
63
+ if (!this.u) return;
64
+ const t = this.u.v(i.k.Zt) || [],
48
65
  s = [];
49
66
  for (let i = 0; i < t.length; i++) {
50
- const e = S(t[i]);
67
+ const e = R(t[i]);
51
68
  null != e && s.push(e);
52
69
  }
53
- (this.Zt = this.Cs(this.ws(s, !1))),
54
- (this.Ut = this.h.I(o.q.vs) || this.Ut),
55
- (this.kt = this.h.I(o.q.ys) || this.kt);
70
+ (this.cards = this.Cs(this.ws(s, !1))),
71
+ (this.kt = this.u.v(i.k.vs) || this.kt),
72
+ (this.Ut = this.u.v(i.k.ys) || this.Ut);
56
73
  }
57
- Ns(t, s, i, e) {
58
- let h;
74
+ Ns(t, s = !1, e = 0, h = 0) {
75
+ let r;
59
76
  if (s) {
60
- h = [];
61
- for (const t of this.Zt) t.test && h.push(t);
62
- } else h = this.Zt.slice();
77
+ r = [];
78
+ for (const t of this.cards) t.test && r.push(t);
79
+ } else r = this.cards.slice();
63
80
  for (let i = 0; i < t.length; i++) {
64
81
  const e = t[i];
65
- let r = null;
66
- for (let t = 0; t < this.Zt.length; t++)
67
- if (e.id === this.Zt[t].id) {
68
- r = this.Zt[t];
82
+ let h = null;
83
+ for (let t = 0; t < this.cards.length; t++)
84
+ if (e.id === this.cards[t].id) {
85
+ h = this.cards[t];
69
86
  break;
70
87
  }
71
88
  if (s) {
72
- const t = N(e);
73
- null != r && r.viewed && (t.viewed = !0), null != t && h.push(t);
74
- } else if (null == r) {
75
- const t = N(e);
76
- null != t && h.push(t);
89
+ const t = j(e);
90
+ null != h && h.viewed && t && (t.viewed = !0), null != t && r.push(t);
91
+ } else if (null == h) {
92
+ const t = j(e);
93
+ null != t && r.push(t);
77
94
  } else {
78
- if (!r.ct(e))
79
- for (let t = 0; t < h.length; t++)
80
- if (e.id === h[t].id) {
81
- h.splice(t, 1);
95
+ if (!h.ot(e))
96
+ for (let t = 0; t < r.length; t++)
97
+ if (e.id === r[t].id) {
98
+ r.splice(t, 1);
82
99
  break;
83
100
  }
84
101
  }
85
102
  }
86
- (this.Zt = this.Cs(this.ws(h, s))),
87
- this.Ss(),
88
- (this.Ut = i || 0),
89
- this.h.B(o.q.vs, this.Ut),
90
- (this.kt = e || 0),
91
- this.h.B(o.q.ys, this.kt);
103
+ (this.cards = this.Cs(this.ws(r, s))),
104
+ this.Rs(),
105
+ (this.kt = e),
106
+ (this.Ut = h),
107
+ this.u && (this.u.D(i.k.vs, this.kt), this.u.D(i.k.ys, this.Ut));
92
108
  }
93
- Rs(t) {
94
- if (this.Ts() && null != t && t.cards) {
95
- this.h.B(o.q._s, e.Ds());
109
+ Ts(t) {
110
+ if (this.Ds() && null != t && t.cards) {
111
+ this.u && this.u.D(i.k.Ss, e.Us());
96
112
  const s = t.full_sync;
97
- s || this.zt(),
113
+ s || this.Lt(),
98
114
  this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
99
- this.yt.St(this.Us(!0));
115
+ this.yt.Et(this.As(!0));
100
116
  }
101
117
  }
102
- Fs(t) {
103
- this.h.B(o.q.As, t);
118
+ Ls(t) {
119
+ this.u && this.u.D(i.k.Fs, t);
104
120
  }
105
- Ls(t, i, e) {
106
- const h = () => {
107
- this.Is(i, e, !0);
121
+ Ms(t, e, h) {
122
+ const n = () => {
123
+ this.Es(e, h, !0);
108
124
  },
109
- n = C(t);
110
- let a, l;
111
- if ((this.Js(), !n["retry-after"])) return void this.Fs(0);
112
- if (((a = n["retry-after"]), isNaN(a) && !isNaN(Date.parse(a))))
113
- (l = Date.parse(a) - new Date().getTime()), l < 0 && h();
125
+ o = b(t);
126
+ let l;
127
+ if ((this.qs(), !o["retry-after"])) return void this.Ls(0);
128
+ const a = o["retry-after"];
129
+ if (isNaN(a) && !isNaN(Date.parse(a)))
130
+ (l = Date.parse(a) - new Date().getTime()), l < 0 && n();
114
131
  else {
115
- if (isNaN(parseFloat(a))) {
132
+ if (isNaN(parseFloat(a.toString()))) {
116
133
  const t =
117
134
  "Received unexpected value for retry-after header in /sync response";
118
- return s.G(r.A.qs, { e: t + ": " + a }), void this.Fs(0);
135
+ return s.N(r.q.Is, { e: t + ": " + a }), void this.Ls(0);
119
136
  }
120
- l = 1e3 * a;
137
+ l = 1e3 * parseFloat(a.toString());
121
138
  }
122
- this.Gt = setTimeout(() => {
123
- h();
139
+ this.Gt = window.setTimeout(() => {
140
+ n();
124
141
  }, l);
125
- let c = this.h.I(o.q.As);
126
- (c && !isNaN(parseInt(c))) || (c = 0), this.Fs(parseInt(c) + 1);
142
+ let u = 0;
143
+ this.u && (u = this.u.v(i.k.Fs)),
144
+ (null == u || isNaN(parseInt(u.toString()))) && (u = 0),
145
+ this.Ls(parseInt(u.toString()) + 1);
127
146
  }
128
- Bt(t) {
129
- if (!this.Ts()) return;
130
- this.zt();
131
- const s = this.Zt.slice(),
132
- i = this.v.getUserId();
147
+ Pt(t) {
148
+ if (!this.Ds()) return;
149
+ this.Lt();
150
+ const s = this.cards.slice();
151
+ let i = null;
152
+ this.ft && (i = this.ft.getUserId());
133
153
  for (let e = 0; e < t.length; e++)
134
154
  if (i === t[e].userId || (null == i && null == t[e].userId)) {
135
155
  const i = t[e].card;
136
156
  let h = null;
137
- for (let t = 0; t < this.Zt.length; t++)
138
- if (i.id === this.Zt[t].id) {
139
- h = this.Zt[t];
157
+ for (let t = 0; t < this.cards.length; t++)
158
+ if (i.id === this.cards[t].id) {
159
+ h = this.cards[t];
140
160
  break;
141
161
  }
142
162
  if (null == h) {
143
- const t = N(i);
163
+ const t = j(i);
144
164
  null != t && s.push(t);
145
165
  } else {
146
- if (!h.ct(i))
166
+ if (!h.ot(i))
147
167
  for (let t = 0; t < s.length; t++)
148
168
  if (i.id === s[t].id) {
149
169
  s.splice(t, 1);
@@ -151,133 +171,221 @@ export default class v extends y {
151
171
  }
152
172
  }
153
173
  }
154
- (this.Zt = this.Cs(this.ws(s, !1))), this.Ss(), this.yt.St(this.Us(!0));
174
+ (this.cards = this.Cs(this.ws(s, !1))), this.Rs(), this.yt.Et(this.As(!0));
155
175
  }
156
176
  ws(t, s) {
157
- const i = this.h.I(o.q.$) || {},
158
- e = this.h.I(o.q.O) || {},
159
- h = this.h.I(o.q.K) || {},
160
- r = {},
161
- n = {},
162
- a = {};
163
- for (let s = 0; s < t.length; s++)
164
- i[t[s].id] && ((t[s].clicked = !0), (r[t[s].id] = !0)),
165
- e[t[s].id] && ((t[s].viewed = !0), (n[t[s].id] = !0)),
166
- h[t[s].id] && ((t[s].dismissed = !0), (a[t[s].id] = !0));
167
- return s && (this.h.B(o.q.$, r), this.h.B(o.q.O, n), this.h.B(o.q.K, a)), t;
177
+ let e = {},
178
+ h = {},
179
+ r = {};
180
+ this.u &&
181
+ ((e = this.u.v(i.k.C) || {}),
182
+ (h = this.u.v(i.k.K) || {}),
183
+ (r = this.u.v(i.k.G) || {}));
184
+ const n = {},
185
+ o = {},
186
+ l = {};
187
+ for (let s = 0; s < t.length; s++) {
188
+ const i = t[s].id;
189
+ i &&
190
+ (e[i] && ((t[s].clicked = !0), (n[i] = !0)),
191
+ h[i] && ((t[s].viewed = !0), (o[i] = !0)),
192
+ r[i] && ((t[s].dismissed = !0), (l[i] = !0)));
193
+ }
194
+ return (
195
+ s &&
196
+ this.u &&
197
+ (this.u.D(i.k.C, n), this.u.D(i.k.K, o), this.u.D(i.k.G, l)),
198
+ t
199
+ );
168
200
  }
169
201
  Cs(t) {
170
202
  const s = [],
171
- i = new Date(),
172
- e = this.h.I(o.q.K) || {};
173
- let h = !1;
174
- for (let n = 0; n < t.length; n++) {
175
- const o = t[n].url;
176
- !this.wt && o && j(o)
177
- ? r.D.error(
178
- `Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`
179
- )
180
- : (null == t[n].expiresAt || t[n].expiresAt >= i) && !t[n].dismissed
181
- ? s.push(t[n])
182
- : ((e[t[n].id] = !0), (h = !0));
203
+ e = new Date();
204
+ let h = {};
205
+ this.u && (h = this.u.v(i.k.G) || {});
206
+ let n = !1;
207
+ for (let i = 0; i < t.length; i++) {
208
+ const o = t[i].url;
209
+ if (!this.vt && o && N(o)) {
210
+ r.j.error(
211
+ `Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`
212
+ );
213
+ continue;
214
+ }
215
+ const l = t[i].expiresAt;
216
+ let a = !0;
217
+ if ((null != l && (a = l >= e), (a = a && !t[i].dismissed), a))
218
+ s.push(t[i]);
219
+ else {
220
+ const s = t[i].id;
221
+ s && (h[s] = !0), (n = !0);
222
+ }
183
223
  }
184
- return h && this.h.B(o.q.K, e), s;
224
+ return n && this.u && this.u.D(i.k.G, h), s;
185
225
  }
186
- Ss() {
226
+ Rs() {
227
+ if (!this.u) return;
187
228
  const t = [];
188
- for (let s = 0; s < this.Zt.length; s++) t.push(this.Zt[s].ss());
189
- this.h.B(o.q.Yt, t);
229
+ for (let s = 0; s < this.cards.length; s++) t.push(this.cards[s].ss());
230
+ this.u.D(i.k.Zt, t);
190
231
  }
191
- Js() {
232
+ qs() {
192
233
  this.Gt && (clearTimeout(this.Gt), (this.Gt = null));
193
234
  }
194
- Is(t, s, i) {
195
- if ((i || (this.Js(), this.Fs(0)), !this.Ts()))
235
+ Js() {
236
+ null != this.Ht && (clearTimeout(this.Ht), (this.Ht = null));
237
+ }
238
+ Ps(t = 1e3 * this.Ot, s, i) {
239
+ this.Js(),
240
+ (this.Ht = window.setTimeout(() => {
241
+ this.Es(s, i, !0);
242
+ }, t)),
243
+ (this.Kt = t);
244
+ }
245
+ Es(t, s, h = !1, n = !0) {
246
+ var o;
247
+ const l = this.gt,
248
+ a = this.u;
249
+ if (!l || !a) return void ("function" == typeof s && s());
250
+ const u = !h;
251
+ if ((u && (this.qs(), this.Ls(0)), !this.Ds()))
196
252
  return void (
197
- this.Es ||
198
- (this.Es = this.gt.Ms(() => {
199
- this.Is(t, s);
253
+ !this.$t &&
254
+ this.wt &&
255
+ (this.$t = this.wt.$s(() => {
256
+ this.Es(t, s);
200
257
  }))
201
258
  );
202
- const h = this.vt.Ps({}, !0);
203
- this.h.I(o.q._s) !== e.Ds() && this.$s(),
204
- (h.last_full_sync_at = this.Ut),
205
- (h.last_card_updated_at = this.kt);
206
- const r = this.vt.Bs(h, !0, !1, i);
207
- this.vt.Gs(h, () => {
208
- b.Hs({
209
- url: this.vt.Ks() + "/content_cards/sync",
210
- data: h,
211
- headers: r,
212
- S: (i, e) => {
213
- this.vt.Os(h, i, r)
214
- ? (this.vt.Qs(),
215
- this.Ls(e, t, s),
216
- this.Rs(i),
217
- "function" == typeof t && t())
218
- : "function" == typeof s && s();
259
+ let c = !0;
260
+ if (
261
+ (u &&
262
+ (null === (o = this.wt) || void 0 === o ? void 0 : o._s()) &&
263
+ (c = this.Bs()),
264
+ !c)
265
+ )
266
+ return void r.j.info("Content card sync being throttled.");
267
+ n && this.Js();
268
+ const f = l.Gs({}, !0);
269
+ a.v(i.k.Ss) !== e.Us() && this.Hs(),
270
+ (f.last_full_sync_at = this.kt),
271
+ (f.last_card_updated_at = this.Ut);
272
+ const d = l.Ks(f, T.Qs.Os, h);
273
+ let m = !1;
274
+ l.Vs(f, () => {
275
+ if (this.u) {
276
+ const t = new Date().valueOf();
277
+ u && this.u.D(i.k.Ws, t), T.Xs(this.u, T.Qs.Os, t);
278
+ }
279
+ C.Ys({
280
+ url: l.Zs() + "/content_cards/sync",
281
+ data: f,
282
+ headers: d,
283
+ O: (i, e) => {
284
+ if (!l.ti(f, i, d))
285
+ return (m = !0), void ("function" == typeof s && s());
286
+ l.si(),
287
+ this.Ms(e, t, s),
288
+ this.Ts(i),
289
+ (m = !1),
290
+ "function" == typeof t && t();
219
291
  },
220
292
  error: t => {
221
- this.vt.Vs(t, "retrieving content cards"),
293
+ l.ii(t, "retrieving content cards"),
294
+ (m = !0),
222
295
  "function" == typeof s && s();
296
+ },
297
+ ei: () => {
298
+ if (m && n && !this.Ht && this.Qt + 1 < S) {
299
+ let i = this.Kt;
300
+ (null == i || i < 1e3 * this.Ot) && (i = 1e3 * this.Ot),
301
+ this.Ps(Math.min(3e5, D(1e3 * this.Ot, 3 * i)), t, s),
302
+ (this.Qt = this.Qt + 1);
303
+ }
223
304
  }
224
305
  });
225
306
  });
226
307
  }
227
- Us(t) {
228
- t || this.zt();
229
- const s = this.Cs(this.Zt);
308
+ As(t) {
309
+ t || this.Lt();
310
+ const s = this.Cs(this.cards);
230
311
  s.sort((t, s) =>
231
312
  t.pinned && !s.pinned
232
313
  ? -1
233
314
  : s.pinned && !t.pinned
234
315
  ? 1
235
- : t.updated > s.updated
316
+ : t.updated && s.updated && t.updated > s.updated
236
317
  ? -1
237
- : s.updated > t.updated
318
+ : t.updated && s.updated && s.updated > t.updated
238
319
  ? 1
239
320
  : 0
240
321
  );
241
- let i = Math.max(this.kt || 0, this.Ut || 0);
322
+ let e = Math.max(this.Ut || 0, this.kt || 0);
242
323
  return (
243
- 0 === i && (i = void 0),
244
- this.h.I(o.q.ys) === this.kt && void 0 === i && (i = this.kt),
245
- new ContentCards(s, h(i))
324
+ 0 === e && (e = void 0),
325
+ this.u && this.u.v(i.k.ys) === this.Ut && void 0 === e && (e = this.Ut),
326
+ new ContentCards(s, l(e))
246
327
  );
247
328
  }
248
- Ws(t) {
249
- return this.yt.ut(t);
329
+ hi(t) {
330
+ return this.yt.lt(t);
250
331
  }
251
- $s() {
252
- (this.Ut = 0), (this.kt = 0), this.h.Xs(o.q.vs), this.h.Xs(o.q.ys);
332
+ Hs() {
333
+ (this.kt = 0),
334
+ (this.Ut = 0),
335
+ this.u && (this.u.ri(i.k.vs), this.u.ri(i.k.ys));
253
336
  }
254
337
  changeUser(t) {
255
338
  t ||
256
- ((this.Zt = []),
257
- this.yt.St(new ContentCards(this.Zt.slice(), null)),
258
- this.h.Xs(o.q.Yt),
259
- this.h.Xs(o.q.$),
260
- this.h.Xs(o.q.O),
261
- this.h.Xs(o.q.K)),
262
- this.$s();
339
+ ((this.cards = []),
340
+ this.yt.Et(new ContentCards(this.cards.slice(), null)),
341
+ this.u &&
342
+ (this.u.ri(i.k.Zt),
343
+ this.u.ri(i.k.C),
344
+ this.u.ri(i.k.K),
345
+ this.u.ri(i.k.G))),
346
+ this.Hs();
263
347
  }
264
348
  clearData(t) {
265
- (this.Ut = 0),
266
- (this.kt = 0),
267
- (this.Zt = []),
268
- this.yt.St(new ContentCards(this.Zt.slice(), null)),
349
+ (this.kt = 0),
350
+ (this.Ut = 0),
351
+ (this.cards = []),
352
+ this.yt.Et(new ContentCards(this.cards.slice(), null)),
269
353
  t &&
270
- (this.h.Xs(o.q.Yt),
271
- this.h.Xs(o.q.$),
272
- this.h.Xs(o.q.O),
273
- this.h.Xs(o.q.K),
274
- this.h.Xs(o.q.vs),
275
- this.h.Xs(o.q.ys));
354
+ this.u &&
355
+ (this.u.ri(i.k.Zt),
356
+ this.u.ri(i.k.C),
357
+ this.u.ri(i.k.K),
358
+ this.u.ri(i.k.G),
359
+ this.u.ri(i.k.vs),
360
+ this.u.ri(i.k.ys));
361
+ }
362
+ Ds() {
363
+ return !(this.wt && !this.wt.ni()) || (0 !== this.wt.oi() && this.li(), !1);
364
+ }
365
+ ai(t) {
366
+ this.u && this.u.D(i.k.ui, t);
276
367
  }
277
- Ts() {
278
- return !!this.gt.Ys() || (0 !== this.gt.Zs() && this.ti(), !1);
368
+ ci() {
369
+ return this.u ? this.u.v(i.k.ui) : null;
370
+ }
371
+ Bs() {
372
+ const t = this.u,
373
+ s = this.wt;
374
+ if (!t || !s) return !0;
375
+ const e = t.v(i.k.Ws);
376
+ if (null == e || isNaN(e)) return !0;
377
+ const h = s.fi(),
378
+ r = s.di();
379
+ if (-1 === h || -1 === r) return !0;
380
+ let n = this.ci();
381
+ (null == n || isNaN(n)) && (n = h);
382
+ const o = (new Date().valueOf() - e) / 1e3;
383
+ return (
384
+ (n = Math.min(n + o / r, h)),
385
+ !(n < 1) && ((n = Math.trunc(n) - 1), this.ai(n), !0)
386
+ );
279
387
  }
280
- ti() {
281
- this.yt.St(new ContentCards([], new Date().valueOf())), this.h.Xs(o.q.Yt);
388
+ li() {
389
+ this.yt.Et(new ContentCards([], new Date())), this.u && this.u.ri(i.k.Zt);
282
390
  }
283
391
  }
@@ -17,8 +17,8 @@ export default class ContentCards extends x {
17
17
  sr() {
18
18
  requestContentCardsRefresh();
19
19
  }
20
- dr() {
20
+ ur() {
21
21
  return !0;
22
22
  }
23
23
  }
24
- ContentCards.ur = 6e4;
24
+ ContentCards.mr = 6e4;
@@ -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.rr()) return g.er().Us(!1);
4
+ if (e.rr()) return g.er().As(!1);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import e from "../managers/braze-instance.js";
2
- import { logDeprecationWarning as D } from "../util/deprecation-utils.js";
2
+ import { logDeprecationWarning as z } from "../util/deprecation-utils.js";
3
3
  export function logContentCardsDisplayed() {
4
- if (e.rr()) return D("logContentCardsDisplayed", "method"), !0;
4
+ if (e.rr()) return z("logContentCardsDisplayed", "method"), !0;
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.rr()) return g.er().Is(r, t);
4
+ if (e.rr()) return g.er().Es(r, t);
5
5
  }
@@ -3,12 +3,15 @@ import g from "./content-cards-provider-factory.js";
3
3
  export function subscribeToContentCardsUpdates(r) {
4
4
  if (!e.rr()) return;
5
5
  const t = g.er(),
6
- n = t.Ws(r);
7
- if (!t.Vt()) {
8
- const r = e.mr().cr(() => {
9
- t.Is();
10
- });
11
- t.Xt(r);
6
+ n = t.hi(r);
7
+ if (!t.Xt()) {
8
+ const r = e.cr();
9
+ if (r) {
10
+ const n = r.pr(() => {
11
+ t.Es();
12
+ });
13
+ n && t.Yt(n);
14
+ }
12
15
  }
13
16
  return n;
14
17
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,8 @@
1
1
  import e from "../../managers/braze-instance.js";
2
- import { destroyFeedHtml as z } from "../../common/feed-display.js";
2
+ import { destroyFeedHtml as k } from "../../common/feed-display.js";
3
3
  export function hideContentCards(n) {
4
4
  if (!e.rr()) return;
5
5
  const o = document.querySelectorAll(".ab-feed");
6
6
  for (let e = 0; e < o.length; e++)
7
- (null == n || (null != n && o[e].parentNode === n)) && z(o[e]);
7
+ (null == n || (null != n && o[e].parentNode === n)) && k(o[e]);
8
8
  }