@braze/web-sdk 4.2.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/index.d.ts +57 -6
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +8 -1
  4. package/shared-lib/encoding-utils.js +12 -1
  5. package/shared-lib/event-types.js +32 -1
  6. package/shared-lib/guid.js +10 -1
  7. package/shared-lib/indexed-db-adapter.js +315 -1
  8. package/shared-lib/logger.js +38 -1
  9. package/shared-lib/supported-options.js +26 -1
  10. package/src/Card/card-manager-factory.js +14 -1
  11. package/src/Card/card-manager.js +72 -1
  12. package/src/Card/display/card-display.js +134 -1
  13. package/src/Card/index.js +5 -1
  14. package/src/Card/log-card-click.js +11 -1
  15. package/src/Card/log-card-dismissal.js +11 -1
  16. package/src/Card/log-card-impressions.js +13 -1
  17. package/src/Card/log-content-card-impressions.js +4 -1
  18. package/src/Card/models/banner.js +30 -1
  19. package/src/Card/models/captioned-image.js +32 -1
  20. package/src/Card/models/card.js +174 -1
  21. package/src/Card/models/classic-card.js +32 -1
  22. package/src/Card/models/control-card.js +38 -1
  23. package/src/Card/models/index.js +5 -1
  24. package/src/Card/util/card-factory.js +104 -1
  25. package/src/ContentCards/content-cards-provider-factory.js +20 -1
  26. package/src/ContentCards/content-cards-provider.js +283 -1
  27. package/src/ContentCards/content-cards.js +24 -1
  28. package/src/ContentCards/get-cached-content-cards.js +5 -1
  29. package/src/ContentCards/index.js +8 -1
  30. package/src/ContentCards/log-content-cards-displayed.js +5 -1
  31. package/src/ContentCards/request-content-cards-refresh.js +5 -1
  32. package/src/ContentCards/subscribe-to-content-cards-updates.js +14 -1
  33. package/src/ContentCards/ui/hide-content-cards.js +8 -1
  34. package/src/ContentCards/ui/show-content-cards.js +72 -1
  35. package/src/ContentCards/ui/toggle-content-cards.js +8 -1
  36. package/src/Core/add-sdk-metadata.js +27 -1
  37. package/src/Core/braze-sdk-metadata.js +10 -1
  38. package/src/Core/change-user.js +19 -1
  39. package/src/Core/destroy.js +5 -1
  40. package/src/Core/device-properties.js +9 -1
  41. package/src/Core/disable-sdk.js +10 -1
  42. package/src/Core/enable-sdk.js +8 -1
  43. package/src/Core/get-device-id.js +10 -1
  44. package/src/Core/get-user.js +4 -1
  45. package/src/Core/handle-braze-action.js +64 -1
  46. package/src/Core/index.js +23 -1
  47. package/src/Core/initialize.js +4 -1
  48. package/src/Core/is-disabled.js +4 -1
  49. package/src/Core/log-custom-event.js +36 -1
  50. package/src/Core/log-purchase.js +245 -1
  51. package/src/Core/open-session.js +23 -1
  52. package/src/Core/remove-all-subscriptions.js +4 -1
  53. package/src/Core/remove-subscription.js +4 -1
  54. package/src/Core/request-immediate-data-flush.js +4 -1
  55. package/src/Core/set-logger.js +4 -1
  56. package/src/Core/set-sdk-authentication-signature.js +9 -1
  57. package/src/Core/subscribe-to-sdk-authentication-failures.js +4 -1
  58. package/src/Core/toggle-logging.js +4 -1
  59. package/src/Core/wipe-data.js +15 -1
  60. package/src/FeatureFlags/feature-flag-factory.js +14 -0
  61. package/src/FeatureFlags/feature-flag.js +16 -0
  62. package/src/FeatureFlags/feature-flags-provider-factory.js +19 -0
  63. package/src/FeatureFlags/feature-flags-provider.js +94 -0
  64. package/src/FeatureFlags/get-all-feature-flags.js +12 -0
  65. package/src/FeatureFlags/get-feature-flag.js +12 -0
  66. package/src/FeatureFlags/index.js +4 -0
  67. package/src/FeatureFlags/refresh-feature-flags.js +9 -0
  68. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +6 -0
  69. package/src/Feed/feed-provider-factory.js +18 -1
  70. package/src/Feed/feed-provider.js +79 -1
  71. package/src/Feed/feed.js +20 -1
  72. package/src/Feed/get-cached-feed.js +5 -1
  73. package/src/Feed/index.js +8 -1
  74. package/src/Feed/log-feed-displayed.js +5 -1
  75. package/src/Feed/request-feed-refresh.js +5 -1
  76. package/src/Feed/subscribe-to-feed-updates.js +5 -1
  77. package/src/Feed/ui/hide-feed.js +7 -1
  78. package/src/Feed/ui/show-feed.js +89 -1
  79. package/src/Feed/ui/toggle-feed.js +8 -1
  80. package/src/InAppMessage/display/get-animation-effect.js +19 -1
  81. package/src/InAppMessage/display/html-message-to-html.js +223 -1
  82. package/src/InAppMessage/display/in-app-message-to-html.js +152 -1
  83. package/src/InAppMessage/display/modal-utils.js +68 -1
  84. package/src/InAppMessage/in-app-message-factory.js +145 -1
  85. package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
  86. package/src/InAppMessage/in-app-message-manager.js +189 -1
  87. package/src/InAppMessage/index.js +14 -1
  88. package/src/InAppMessage/log-in-app-message-button-click.js +19 -1
  89. package/src/InAppMessage/log-in-app-message-click.js +16 -1
  90. package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
  91. package/src/InAppMessage/log-in-app-message-impression.js +13 -1
  92. package/src/InAppMessage/models/control-message.js +8 -1
  93. package/src/InAppMessage/models/full-screen-message.js +71 -1
  94. package/src/InAppMessage/models/html-message.js +54 -1
  95. package/src/InAppMessage/models/in-app-message-button.js +40 -1
  96. package/src/InAppMessage/models/in-app-message.js +267 -1
  97. package/src/InAppMessage/models/modal-message.js +68 -1
  98. package/src/InAppMessage/models/slide-up-message.js +58 -1
  99. package/src/InAppMessage/models/templated-in-app-message.js +14 -1
  100. package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
  101. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
  102. package/src/InAppMessage/ui/show-in-app-message.js +170 -1
  103. package/src/Push/index.js +5 -1
  104. package/src/Push/is-push-blocked.js +5 -1
  105. package/src/Push/is-push-permission-granted.js +5 -1
  106. package/src/Push/is-push-supported.js +5 -1
  107. package/src/Push/push-manager-factory.js +30 -1
  108. package/src/Push/push-manager.js +360 -1
  109. package/src/Push/request-push-permission.js +8 -1
  110. package/src/Push/unregister-push.js +5 -1
  111. package/src/Push/utils/push-utils.js +34 -1
  112. package/src/User/index.js +1 -1
  113. package/src/User/user-manager.js +70 -1
  114. package/src/User/user.js +278 -1
  115. package/src/common/base-feed.js +25 -1
  116. package/src/common/base-provider.js +6 -1
  117. package/src/common/constants.js +5 -1
  118. package/src/common/event-logger.js +24 -1
  119. package/src/common/feed-display.js +200 -1
  120. package/src/common/translations.js +148 -1
  121. package/src/index.js +9 -1
  122. package/src/l10n/l10n-manager-factory.js +22 -1
  123. package/src/l10n/l10n-manager.js +21 -1
  124. package/src/managers/auth-manager.js +48 -1
  125. package/src/managers/braze-instance.js +307 -1
  126. package/src/managers/device-manager.js +80 -1
  127. package/src/managers/network-manager.js +219 -1
  128. package/src/managers/server-config-manager.js +88 -1
  129. package/src/managers/session-manager.js +68 -1
  130. package/src/managers/storage-manager-factory.js +35 -1
  131. package/src/managers/storage-manager.js +394 -1
  132. package/src/managers/subscription-manager.js +25 -1
  133. package/src/models/backend-errors.js +8 -1
  134. package/src/models/braze-event.js +41 -1
  135. package/src/models/braze-sdk-metadata.js +10 -1
  136. package/src/models/device.js +26 -1
  137. package/src/models/identifier.js +20 -1
  138. package/src/models/push-token.js +22 -1
  139. package/src/models/request-result.js +8 -1
  140. package/src/models/server-config.js +32 -1
  141. package/src/request-controller.js +288 -1
  142. package/src/triggers/models/custom-event-data.js +14 -1
  143. package/src/triggers/models/custom-event-property-data.js +21 -1
  144. package/src/triggers/models/filter-set.js +55 -1
  145. package/src/triggers/models/filter.js +98 -1
  146. package/src/triggers/models/in-app-message-click-data.js +25 -1
  147. package/src/triggers/models/purchase-data.js +14 -1
  148. package/src/triggers/models/purchase-property-data.js +21 -1
  149. package/src/triggers/models/push-click-data.js +15 -1
  150. package/src/triggers/models/trigger-condition.js +109 -1
  151. package/src/triggers/models/trigger-events.js +8 -1
  152. package/src/triggers/models/trigger.js +110 -1
  153. package/src/triggers/triggers-provider-factory.js +30 -1
  154. package/src/triggers/triggers-provider.js +307 -1
  155. package/src/ui/js/attach-css.js +12 -1
  156. package/src/ui/js/feed-css.js +12 -1
  157. package/src/ui/js/iam-css.js +12 -1
  158. package/src/ui/js/index.js +3 -1
  159. package/src/ui/js/load-font-awesome.js +13 -1
  160. package/src/util/base-device-parser.js +14 -1
  161. package/src/util/braze-actions.js +79 -1
  162. package/src/util/browser-detector.js +85 -1
  163. package/src/util/client-hints-parser.js +60 -1
  164. package/src/util/code-utils.js +92 -1
  165. package/src/util/color-utils.js +23 -1
  166. package/src/util/component-utils.js +26 -1
  167. package/src/util/date-utils.js +27 -1
  168. package/src/util/deprecation-utils.js +5 -1
  169. package/src/util/device-constants.js +14 -1
  170. package/src/util/dom-utils.js +87 -1
  171. package/src/util/key-codes.js +1 -1
  172. package/src/util/math.js +5 -1
  173. package/src/util/net.js +75 -1
  174. package/src/util/string-utils.js +22 -1
  175. package/src/util/url-utils.js +23 -1
  176. package/src/util/user-agent-parser.js +85 -1
  177. package/src/util/validation-utils.js +136 -1
  178. package/src/util/window-utils.js +35 -1
@@ -0,0 +1,12 @@
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ import e from "../managers/braze-instance.js";
3
+ import { newFeatureFlagFromJson as tt } from "./feature-flag-factory.js";
4
+ import ee from "./feature-flag.js";
5
+ import ir from "./feature-flags-provider-factory.js";
6
+ export function getFeatureFlag(a) {
7
+ if (!e.rr()) return;
8
+ if (!e.ir().ye())
9
+ return r.D.info("Feature flags are not enabled."), new ee(a);
10
+ const t = ir.er().xe();
11
+ return t[a] ? tt(t[a]) : new ee(a);
12
+ }
@@ -0,0 +1,4 @@
1
+ export { refreshFeatureFlags } from "./refresh-feature-flags.js";
2
+ export { getFeatureFlag } from "./get-feature-flag.js";
3
+ export { subscribeToFeatureFlagsUpdates } from "./subscribe-to-feature-flags-updates.js";
4
+ export { getAllFeatureFlags } from "./get-all-feature-flags.js";
@@ -0,0 +1,9 @@
1
+ import e from "../managers/braze-instance.js";
2
+ import ir from "./feature-flags-provider-factory.js";
3
+ function tr(r, t, a) {
4
+ if (e.rr()) return ir.er().refreshFeatureFlags(r, t, a);
5
+ }
6
+ export function refreshFeatureFlags(r, e) {
7
+ tr(r, e);
8
+ }
9
+ export default tr;
@@ -0,0 +1,6 @@
1
+ import e from "../managers/braze-instance.js";
2
+ import ir from "./feature-flags-provider-factory.js";
3
+ export function subscribeToFeatureFlagsUpdates(r) {
4
+ if (!e.rr()) return;
5
+ return ir.er().Ws(r);
6
+ }
@@ -1 +1,18 @@
1
- import e from"../managers/braze-instance.js";import ee from"./feed-provider.js";const re={t:!1,provider:null,er:()=>(re.o(),re.provider||(re.provider=new ee(e.l(),e.mr()),e.ar(re.provider)),re.provider),o:()=>{re.t||(e.u(re),re.t=!0)},destroy:()=>{re.provider=null,re.t=!1}};export default re;
1
+ import e from "../managers/braze-instance.js";
2
+ import re from "./feed-provider.js";
3
+ const ie = {
4
+ t: !1,
5
+ provider: null,
6
+ er: () => (
7
+ ie.o(),
8
+ ie.provider || ((ie.provider = new re(e.l(), e.mr())), e.ar(ie.provider)),
9
+ ie.provider
10
+ ),
11
+ o: () => {
12
+ ie.t || (e.u(ie), (ie.t = !0));
13
+ },
14
+ destroy: () => {
15
+ (ie.provider = null), (ie.t = !1);
16
+ }
17
+ };
18
+ export default ie;
@@ -1 +1,79 @@
1
- import y from"../common/base-provider.js";import e from"../managers/braze-instance.js";import Feed from"./feed.js";import{newCardFromFeedJson as tt,newCardFromSerializedValue as S}from"../Card/util/card-factory.js";import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import u from"../managers/subscription-manager.js";export default class ee extends y{constructor(t,s){super(),this.h=t,this.si=s,this.yt=new u,e.jt(this.yt),this.zt()}zt(){const t=this.h.I(o.q.ei)||[],s=[];for(let i=0;i<t.length;i++){const e=S(t[i]);null!=e&&s.push(e)}this.Zt=s,this.ri=w(this.h.I(o.q.hi))}oi(t){const s=[];let i=null;const e=this.h.I(o.q.P)||{},r={};for(let h=0;h<t.length;h++){i=t[h];const o=tt(i);null!=o&&(e[o.id]&&(o.viewed=!0,r[o.id]=!0),s.push(o))}this.h.B(o.q.P,r),this.Zt=s,this.Ss(),this.ri=new Date,this.h.B(o.q.hi,this.ri)}Ss(){const t=[];for(let s=0;s<this.Zt.length;s++)t.push(this.Zt[s].ss());this.h.B(o.q.ei,t)}Rs(t){null!=t&&t.feed&&(this.zt(),this.oi(t.feed),this.yt.St(new Feed(this.Zt.slice(),this.ri)))}ai(){this.zt();const t=[],s=new Date;for(let i=0;i<this.Zt.length;i++)(null==this.Zt[i].expiresAt||this.Zt[i].expiresAt>=s)&&t.push(this.Zt[i]);return new Feed(t,this.ri)}Is(){this.si.requestFeedRefresh()}Ws(t){return this.yt.ut(t)}clearData(t){null==t&&(t=!1),this.Zt=[],this.ri=null,t&&(this.h.Xs(o.q.ei),this.h.Xs(o.q.hi)),this.yt.St(new Feed(this.Zt.slice(),this.ri))}}
1
+ import y from "../common/base-provider.js";
2
+ import e from "../managers/braze-instance.js";
3
+ import Feed from "./feed.js";
4
+ import {
5
+ newCardFromFeedJson as st,
6
+ newCardFromSerializedValue as S
7
+ } from "../Card/util/card-factory.js";
8
+ import { rehydrateDateAfterJsonization as w } from "../util/date-utils.js";
9
+ import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
10
+ import u from "../managers/subscription-manager.js";
11
+ export default class re extends y {
12
+ constructor(t, s) {
13
+ super(),
14
+ (this.h = t),
15
+ (this.si = s),
16
+ (this.yt = new u()),
17
+ e.jt(this.yt),
18
+ this.zt();
19
+ }
20
+ zt() {
21
+ const t = this.h.I(o.q.ei) || [],
22
+ s = [];
23
+ for (let i = 0; i < t.length; i++) {
24
+ const e = S(t[i]);
25
+ null != e && s.push(e);
26
+ }
27
+ (this.Zt = s), (this.ri = w(this.h.I(o.q.hi)));
28
+ }
29
+ oi(t) {
30
+ const s = [];
31
+ let i = null;
32
+ const e = this.h.I(o.q.P) || {},
33
+ r = {};
34
+ for (let h = 0; h < t.length; h++) {
35
+ i = t[h];
36
+ const o = st(i);
37
+ null != o && (e[o.id] && ((o.viewed = !0), (r[o.id] = !0)), s.push(o));
38
+ }
39
+ this.h.B(o.q.P, r),
40
+ (this.Zt = s),
41
+ this.Ss(),
42
+ (this.ri = new Date()),
43
+ this.h.B(o.q.hi, this.ri);
44
+ }
45
+ Ss() {
46
+ const t = [];
47
+ for (let s = 0; s < this.Zt.length; s++) t.push(this.Zt[s].ss());
48
+ this.h.B(o.q.ei, t);
49
+ }
50
+ Rs(t) {
51
+ null != t &&
52
+ t.feed &&
53
+ (this.zt(),
54
+ this.oi(t.feed),
55
+ this.yt.St(new Feed(this.Zt.slice(), this.ri)));
56
+ }
57
+ ai() {
58
+ this.zt();
59
+ const t = [],
60
+ s = new Date();
61
+ for (let i = 0; i < this.Zt.length; i++)
62
+ (null == this.Zt[i].expiresAt || this.Zt[i].expiresAt >= s) &&
63
+ t.push(this.Zt[i]);
64
+ return new Feed(t, this.ri);
65
+ }
66
+ Is() {
67
+ this.si.requestFeedRefresh();
68
+ }
69
+ Ws(t) {
70
+ return this.yt.ut(t);
71
+ }
72
+ clearData(t) {
73
+ null == t && (t = !1),
74
+ (this.Zt = []),
75
+ (this.ri = null),
76
+ t && (this.h.Xs(o.q.ei), this.h.Xs(o.q.hi)),
77
+ this.yt.St(new Feed(this.Zt.slice(), this.ri));
78
+ }
79
+ }
package/src/Feed/feed.js CHANGED
@@ -1 +1,20 @@
1
- import x from"../common/base-feed.js";import{logCardClick,logCardImpressions}from"../Card/index.js";import{requestFeedRefresh}from"./request-feed-refresh.js";export default class Feed extends x{constructor(r,e){super(r,e)}logCardImpressions(r){logCardImpressions(r,!1)}logCardClick(r){logCardClick(r,!1)}sr(){requestFeedRefresh()}dr(){return!1}}
1
+ import x from "../common/base-feed.js";
2
+ import { logCardClick, logCardImpressions } from "../Card/index.js";
3
+ import { requestFeedRefresh } from "./request-feed-refresh.js";
4
+ export default class Feed extends x {
5
+ constructor(r, e) {
6
+ super(r, e);
7
+ }
8
+ logCardImpressions(r) {
9
+ logCardImpressions(r, !1);
10
+ }
11
+ logCardClick(r) {
12
+ logCardClick(r, !1);
13
+ }
14
+ sr() {
15
+ requestFeedRefresh();
16
+ }
17
+ dr() {
18
+ return !1;
19
+ }
20
+ }
@@ -1 +1,5 @@
1
- import e from"../managers/braze-instance.js";import re from"./feed-provider-factory.js";export function getCachedFeed(){if(e.rr())return re.er().ai()}
1
+ import e from "../managers/braze-instance.js";
2
+ import ie from "./feed-provider-factory.js";
3
+ export function getCachedFeed() {
4
+ if (e.rr()) return ie.er().ai();
5
+ }
package/src/Feed/index.js CHANGED
@@ -1 +1,8 @@
1
- export{default as Feed}from"./feed.js";export{getCachedFeed}from"./get-cached-feed.js";export{destroyFeed}from"./ui/hide-feed.js";export{logFeedDisplayed}from"./log-feed-displayed.js";export{requestFeedRefresh}from"./request-feed-refresh.js";export{showFeed}from"./ui/show-feed.js";export{subscribeToFeedUpdates}from"./subscribe-to-feed-updates.js";export{toggleFeed}from"./ui/toggle-feed.js";
1
+ export { default as Feed } from "./feed.js";
2
+ export { getCachedFeed } from "./get-cached-feed.js";
3
+ export { destroyFeed } from "./ui/hide-feed.js";
4
+ export { logFeedDisplayed } from "./log-feed-displayed.js";
5
+ export { requestFeedRefresh } from "./request-feed-refresh.js";
6
+ export { showFeed } from "./ui/show-feed.js";
7
+ export { subscribeToFeedUpdates } from "./subscribe-to-feed-updates.js";
8
+ export { toggleFeed } from "./ui/toggle-feed.js";
@@ -1 +1,5 @@
1
- import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function logFeedDisplayed(){if(e.rr())return e.nr().yr(r.qr.Fr).S}
1
+ import e from "../managers/braze-instance.js";
2
+ import r from "../../shared-lib/braze-shared-lib.js";
3
+ export function logFeedDisplayed() {
4
+ if (e.rr()) return e.nr().yr(r.qr.Fr).S;
5
+ }
@@ -1 +1,5 @@
1
- import e from"../managers/braze-instance.js";import re from"./feed-provider-factory.js";export function requestFeedRefresh(){if(e.rr())return re.er().Is()}
1
+ import e from "../managers/braze-instance.js";
2
+ import ie from "./feed-provider-factory.js";
3
+ export function requestFeedRefresh() {
4
+ if (e.rr()) return ie.er().Is();
5
+ }
@@ -1 +1,5 @@
1
- import e from"../managers/braze-instance.js";import re from"./feed-provider-factory.js";export function subscribeToFeedUpdates(r){if(e.rr())return re.er().Ws(r)}
1
+ import e from "../managers/braze-instance.js";
2
+ import ie from "./feed-provider-factory.js";
3
+ export function subscribeToFeedUpdates(r) {
4
+ if (e.rr()) return ie.er().Ws(r);
5
+ }
@@ -1 +1,7 @@
1
- import e from"../../managers/braze-instance.js";import{destroyFeedHtml as z}from"../../common/feed-display.js";export function destroyFeed(){if(!e.rr())return;const o=document.querySelectorAll(".ab-feed");for(let e=0;e<o.length;e++)z(o[e])}
1
+ import e from "../../managers/braze-instance.js";
2
+ import { destroyFeedHtml as z } from "../../common/feed-display.js";
3
+ export function destroyFeed() {
4
+ if (!e.rr()) return;
5
+ const o = document.querySelectorAll(".ab-feed");
6
+ for (let e = 0; e < o.length; e++) z(o[e]);
7
+ }
@@ -1 +1,89 @@
1
- import e,{OPTIONS as T}from"../../managers/braze-instance.js";import{destroyFeedHtml as z,detectFeedImpressions as q,feedToHtml as I,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as L,refreshFeed as M,registerFeedSubscriptionId as $,updateFeedCards as k}from"../../common/feed-display.js";import{Feed,logFeedDisplayed,subscribeToFeedUpdates}from"../index.js";import re from"../feed-provider-factory.js";import{intersection as te}from"../../util/code-utils.js";import{setCardHeight as A}from"../../Card/display/card-display.js";import{setupFeedUI as B}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showFeed(t,n,o){if(!e.rr())return;B();const s=(e,t)=>{if(null==t)return e;const n=[];for(let e=0;e<t.length;e++)n.push(t[e].toLowerCase());const o=[];for(let t=0;t<e.length;t++){const r=[];for(let n=0;n<e[t].categories.length;n++)r.push(e[t].categories[n].toLowerCase());te(r,n).length>0&&o.push(e[t])}return o},i=e.nn(T.tn)||e.nn(T.en)||!1;let l=!1;null==t&&(t=document.body,l=!0);let a=!1,f=null;null==n?(f=re.er().ai(),k(f,s(f.cards,o),f.lastUpdated,null,i),a=!0):f=new Feed(s(n,o),new Date);const u=I(f,i);if(a){(null==f.lastUpdated||(new Date).valueOf()-f.lastUpdated.valueOf()>Feed.ur)&&(r.D.info(`Cached feed was older than max TTL of ${Feed.ur} ms, requesting an update from the server.`),M(f,u));const e=(new Date).valueOf(),t=subscribeToFeedUpdates((function(t){const n=u.querySelectorAll(".ab-refresh-button")[0];if(null!=n){let t=500;const o=parseInt(u.getAttribute(L));isNaN(o)?t-=(new Date).valueOf()-e:t-=(new Date).valueOf()-o,setTimeout((function(){n.className=n.className.replace(/fa-spin/g,"")}),Math.max(t,0))}k(f,s(t.cards,o),t.lastUpdated,u,i)}));$(t,u)}const m=e=>{const t=e.querySelectorAll(".ab-feed");let n=null;for(let o=0;o<t.length;o++)t[o].parentNode===e&&(n=t[o]);null!=n?(z(n),n.parentNode.replaceChild(u,n)):e.appendChild(u),setTimeout((function(){u.className=u.className.replace("ab-hide","ab-show")}),0),l&&u.focus(),logFeedDisplayed(),q(f,u),A(f.cards,e)};var c;null!=t?m(t):window.onload=(c=window.onload,function(){"function"==typeof c&&c(),m(document.body)})}
1
+ import e, { OPTIONS as T } from "../../managers/braze-instance.js";
2
+ import {
3
+ destroyFeedHtml as z,
4
+ detectFeedImpressions as q,
5
+ feedToHtml as I,
6
+ LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as L,
7
+ refreshFeed as M,
8
+ registerFeedSubscriptionId as $,
9
+ updateFeedCards as k
10
+ } from "../../common/feed-display.js";
11
+ import { Feed, logFeedDisplayed, subscribeToFeedUpdates } from "../index.js";
12
+ import ie from "../feed-provider-factory.js";
13
+ import { intersection as te } from "../../util/code-utils.js";
14
+ import { setCardHeight as A } from "../../Card/display/card-display.js";
15
+ import { setupFeedUI as B } from "../../ui/js/index.js";
16
+ import r from "../../../shared-lib/braze-shared-lib.js";
17
+ export function showFeed(t, n, o) {
18
+ if (!e.rr()) return;
19
+ B();
20
+ const s = (e, t) => {
21
+ if (null == t) return e;
22
+ const n = [];
23
+ for (let e = 0; e < t.length; e++) n.push(t[e].toLowerCase());
24
+ const o = [];
25
+ for (let t = 0; t < e.length; t++) {
26
+ const r = [];
27
+ for (let n = 0; n < e[t].categories.length; n++)
28
+ r.push(e[t].categories[n].toLowerCase());
29
+ te(r, n).length > 0 && o.push(e[t]);
30
+ }
31
+ return o;
32
+ },
33
+ i = e.nn(T.tn) || e.nn(T.en) || !1;
34
+ let l = !1;
35
+ null == t && ((t = document.body), (l = !0));
36
+ let a = !1,
37
+ f = null;
38
+ null == n
39
+ ? ((f = ie.er().ai()),
40
+ k(f, s(f.cards, o), f.lastUpdated, null, i),
41
+ (a = !0))
42
+ : (f = new Feed(s(n, o), new Date()));
43
+ const u = I(f, i);
44
+ if (a) {
45
+ (null == f.lastUpdated ||
46
+ new Date().valueOf() - f.lastUpdated.valueOf() > Feed.ur) &&
47
+ (r.D.info(
48
+ `Cached feed was older than max TTL of ${Feed.ur} ms, requesting an update from the server.`
49
+ ),
50
+ M(f, u));
51
+ const e = new Date().valueOf(),
52
+ t = subscribeToFeedUpdates(function(t) {
53
+ const n = u.querySelectorAll(".ab-refresh-button")[0];
54
+ if (null != n) {
55
+ let t = 500;
56
+ const o = parseInt(u.getAttribute(L));
57
+ isNaN(o)
58
+ ? (t -= new Date().valueOf() - e)
59
+ : (t -= new Date().valueOf() - o),
60
+ setTimeout(function() {
61
+ n.className = n.className.replace(/fa-spin/g, "");
62
+ }, Math.max(t, 0));
63
+ }
64
+ k(f, s(t.cards, o), t.lastUpdated, u, i);
65
+ });
66
+ $(t, u);
67
+ }
68
+ const m = e => {
69
+ const t = e.querySelectorAll(".ab-feed");
70
+ let n = null;
71
+ for (let o = 0; o < t.length; o++) t[o].parentNode === e && (n = t[o]);
72
+ null != n ? (z(n), n.parentNode.replaceChild(u, n)) : e.appendChild(u),
73
+ setTimeout(function() {
74
+ u.className = u.className.replace("ab-hide", "ab-show");
75
+ }, 0),
76
+ l && u.focus(),
77
+ logFeedDisplayed(),
78
+ q(f, u),
79
+ A(f.cards, e);
80
+ };
81
+ var c;
82
+ null != t
83
+ ? m(t)
84
+ : (window.onload =
85
+ ((c = window.onload),
86
+ function() {
87
+ "function" == typeof c && c(), m(document.body);
88
+ }));
89
+ }
@@ -1 +1,8 @@
1
- import e from"../../managers/braze-instance.js";import{destroyFeed,showFeed}from"../index.js";export function toggleFeed(o,n,r){e.rr()&&(document.querySelectorAll(".ab-feed").length>0?destroyFeed():showFeed(o,n,r))}
1
+ import e from "../../managers/braze-instance.js";
2
+ import { destroyFeed, showFeed } from "../index.js";
3
+ export function toggleFeed(o, n, r) {
4
+ e.rr() &&
5
+ (document.querySelectorAll(".ab-feed").length > 0
6
+ ? destroyFeed()
7
+ : showFeed(o, n, r));
8
+ }
@@ -1 +1,19 @@
1
- import FullScreenMessage from"../models/full-screen-message.js";import HtmlMessage from"../models/html-message.js";import ModalMessage from"../models/modal-message.js";import SlideUpMessage from"../models/slide-up-message.js";export default function se(e){let s="";return e.animateIn&&(s+=" ab-animate-in"),e.animateOut&&(s+=" ab-animate-out"),e instanceof FullScreenMessage?s+=" ab-effect-fullscreen":e instanceof HtmlMessage?s+=" ab-effect-html":e instanceof ModalMessage?s+=" ab-effect-modal":e instanceof SlideUpMessage&&(s+=" ab-effect-slide"),s}
1
+ import FullScreenMessage from "../models/full-screen-message.js";
2
+ import HtmlMessage from "../models/html-message.js";
3
+ import ModalMessage from "../models/modal-message.js";
4
+ import SlideUpMessage from "../models/slide-up-message.js";
5
+ export default function se(e) {
6
+ let s = "";
7
+ return (
8
+ e.animateIn && (s += " ab-animate-in"),
9
+ e.animateOut && (s += " ab-animate-out"),
10
+ e instanceof FullScreenMessage
11
+ ? (s += " ab-effect-fullscreen")
12
+ : e instanceof HtmlMessage
13
+ ? (s += " ab-effect-html")
14
+ : e instanceof ModalMessage
15
+ ? (s += " ab-effect-modal")
16
+ : e instanceof SlideUpMessage && (s += " ab-effect-slide"),
17
+ s
18
+ );
19
+ }
@@ -1 +1,223 @@
1
- import{attachInAppMessageCSS as nt}from"../../ui/js/iam-css.js";import et from"../../util/browser-detector.js";import{logInAppMessageHtmlClick}from"../log-in-app-message-html-click.js";import{getUser as Q}from"../../Core/get-user.js";import{InAppMessage}from"../index.js";import{keys as rr}from"../../util/code-utils.js";import{OperatingSystems as ot}from"../../util/device-constants.js";import{parseQueryStringKeyValues as st}from"../../util/url-utils.js";import{WindowUtils as H}from"../../util/window-utils.js";export default function rt(t,n,e,o,s,r){const i=document.createElement("iframe");i.setAttribute("title","Modal Message"),s&&(i.style.zIndex=s+1);const u=n=>{const e=n.getAttribute("href"),s=n.onclick;return r=>{if(null!=s&&"function"==typeof s&&!1===s())return;let u=st(e).abButtonId;if(null!=u&&""!==u||(u=n.getAttribute("id")),null!=e&&""!==e&&0!==e.indexOf("#")){const s="blank"===(n.getAttribute("target")||"").toLowerCase().replace("_",""),c=o||t.openTarget===InAppMessage.OpenTarget.BLANK||s,a=()=>{logInAppMessageHtmlClick(t,u,e),H.openUri(e,c,r)};c?a():t.on(i,a)}else logInAppMessageHtmlClick(t,u,e);return r.stopPropagation(),!1}},c=(t,n,e)=>{const o=`([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,s=t.match(new RegExp(o));if(s){const e=`${s[1]}.setAttribute("nonce", "${n}")`;return`${t.slice(0,s.index+s[0].length)};${e};${t.slice(s.index+s[0].length)}`}return null};if(i.onload=()=>{let o=null;if(null!=r){o=document.createElement("html"),o.innerHTML=t.message;const n=o.getElementsByTagName("style");for(let t=0;t<n.length;t++)n[t].setAttribute("nonce",r);const e=o.getElementsByTagName("script");for(let t=0;t<e.length;t++){e[t].setAttribute("nonce",r),e[t].innerHTML=e[t].innerHTML.replace(/<style>/g,`<style nonce='${r}'>`);const n=c(e[t].innerHTML,r,"script");n&&(e[t].innerHTML=n);const o=c(e[t].innerHTML,r,"style");o&&(e[t].innerHTML=o)}}i.contentWindow.focus(),i.contentWindow.document.write(o?o.innerHTML:t.message);const s=i.contentWindow.document.getElementsByTagName("head")[0];if(null!=s){if(nt(s),t.sn()){const n=document.createElement("style");n.innerHTML=t.css,n.id=t.rn(),null!=r&&n.setAttribute("nonce",r),s.appendChild(n)}const n=i.contentWindow.document.createElement("base");n.setAttribute("target","_parent"),s.appendChild(n)}const a=i.contentWindow.document.getElementsByTagName("title");a.length>0&&i.setAttribute("title",a[0].textContent);const l={closeMessage:function(){t.on(i)},logClick:function(){const n=[t,...arguments];logInAppMessageHtmlClick.apply(t,Array.prototype.slice.call(n))},display:{},web:{}},requestPushPermission=function(){return function(){const t=arguments;import("../../Push/request-push-permission.js").then((n=>{n.requestPushPermission.apply(null,Array.prototype.slice.call(t))}))}},m={requestImmediateDataFlush:async function(){const t=arguments,n=await import("../../Core/request-immediate-data-flush.js");n.requestImmediateDataFlush.apply(null,Array.prototype.slice.call(t))},logCustomEvent:async function(){const t=arguments,n=await import("../../Core/log-custom-event.js");n.logCustomEvent.apply(null,Array.prototype.slice.call(t))},logPurchase:async function(){const t=arguments,n=await import("../../Core/log-purchase.js");n.logPurchase.apply(null,Array.prototype.slice.call(t))},unregisterPush:async function(){const t=arguments,n=await import("../../Push/unregister-push.js");n.unregisterPush.apply(null,Array.prototype.slice.call(t))},requestPushPermission:requestPushPermission()},f=function(t){return function(){m[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of rr(m))l[t]=f(t);const p=["setFirstName","setLastName","setEmail","setGender","setDateOfBirth","setCountry","setHomeCity","setEmailNotificationSubscriptionType","setLanguage","addAlias","setPushNotificationSubscriptionType","setPhoneNumber","setCustomUserAttribute","addToCustomAttributeArray","removeFromCustomAttributeArray","incrementCustomUserAttribute","setCustomLocationAttribute","addToSubscriptionGroup","removeFromSubscriptionGroup"],d=function(t){return function(){const n=Q();n[t].apply(n,Array.prototype.slice.call(arguments))}},y={};for(let t=0;t<p.length;t++)y[p[t]]=d(p[t]);l.getUser=function(){return y};const b={showFeed:n},g=function(n){return function(){const e=arguments;t.on(i,(function(){b[n].apply(null,Array.prototype.slice.call(e))}))}};for(const t of rr(b))l.display[t]=g(t);const h={registerAppboyPushMessages:requestPushPermission()},A=function(t){return function(){h[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of rr(h))l.web[t]=A(t);if(i.contentWindow.appboyBridge=l,i.contentWindow.brazeBridge=l,t.un!==InAppMessage.es.cn){const t=i.contentWindow.document.getElementsByTagName("a");for(let n=0;n<t.length;n++)t[n].onclick=u(t[n]);const n=i.contentWindow.document.getElementsByTagName("button");for(let t=0;t<n.length;t++)n[t].onclick=u(n[t])}const j=i.contentWindow.document.body;if(null!=j){t.an()&&(j.id=t.htmlId);const n=document.createElement("hidden");n.onclick=l.closeMessage,n.className="ab-programmatic-close-button",j.appendChild(n)}i.contentWindow.dispatchEvent(new CustomEvent("ab.BridgeReady")),-1!==i.className.indexOf("ab-start-hidden")&&(i.className=i.className.replace("ab-start-hidden",""),e(i)),document.activeElement!==i&&i.focus()},i.className="ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions",et.OS===ot.ln){const n=document.createElement("div");return n.className="ab-ios-scroll-wrapper",n.appendChild(i),t.mn=n,n}return t.mn=i,i}
1
+ import { attachInAppMessageCSS as nt } from "../../ui/js/iam-css.js";
2
+ import ot from "../../util/browser-detector.js";
3
+ import { logInAppMessageHtmlClick } from "../log-in-app-message-html-click.js";
4
+ import { getUser as Q } from "../../Core/get-user.js";
5
+ import { InAppMessage } from "../index.js";
6
+ import { keys as rr } from "../../util/code-utils.js";
7
+ import { OperatingSystems as rt } from "../../util/device-constants.js";
8
+ import { parseQueryStringKeyValues as it } from "../../util/url-utils.js";
9
+ import { WindowUtils as H } from "../../util/window-utils.js";
10
+ export default function ut(t, n, e, o, s, r) {
11
+ const i = document.createElement("iframe");
12
+ i.setAttribute("title", "Modal Message"), s && (i.style.zIndex = s + 1);
13
+ const u = n => {
14
+ const e = n.getAttribute("href"),
15
+ s = n.onclick;
16
+ return r => {
17
+ if (null != s && "function" == typeof s && !1 === s()) return;
18
+ let u = it(e).abButtonId;
19
+ if (
20
+ ((null != u && "" !== u) || (u = n.getAttribute("id")),
21
+ null != e && "" !== e && 0 !== e.indexOf("#"))
22
+ ) {
23
+ const s =
24
+ "blank" ===
25
+ (n.getAttribute("target") || "").toLowerCase().replace("_", ""),
26
+ c = o || t.openTarget === InAppMessage.OpenTarget.BLANK || s,
27
+ a = () => {
28
+ logInAppMessageHtmlClick(t, u, e), H.openUri(e, c, r);
29
+ };
30
+ c ? a() : t.on(i, a);
31
+ } else logInAppMessageHtmlClick(t, u, e);
32
+ return r.stopPropagation(), !1;
33
+ };
34
+ },
35
+ c = (t, n, e) => {
36
+ const o = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,
37
+ s = t.match(new RegExp(o));
38
+ if (s) {
39
+ const e = `${s[1]}.setAttribute("nonce", "${n}")`;
40
+ return `${t.slice(0, s.index + s[0].length)};${e};${t.slice(
41
+ s.index + s[0].length
42
+ )}`;
43
+ }
44
+ return null;
45
+ };
46
+ if (
47
+ ((i.onload = () => {
48
+ let o = null;
49
+ if (null != r) {
50
+ (o = document.createElement("html")), (o.innerHTML = t.message);
51
+ const n = o.getElementsByTagName("style");
52
+ for (let t = 0; t < n.length; t++) n[t].setAttribute("nonce", r);
53
+ const e = o.getElementsByTagName("script");
54
+ for (let t = 0; t < e.length; t++) {
55
+ e[t].setAttribute("nonce", r),
56
+ (e[t].innerHTML = e[t].innerHTML.replace(
57
+ /<style>/g,
58
+ `<style nonce='${r}'>`
59
+ ));
60
+ const n = c(e[t].innerHTML, r, "script");
61
+ n && (e[t].innerHTML = n);
62
+ const o = c(e[t].innerHTML, r, "style");
63
+ o && (e[t].innerHTML = o);
64
+ }
65
+ }
66
+ i.contentWindow.focus(),
67
+ i.contentWindow.document.write(o ? o.innerHTML : t.message);
68
+ const s = i.contentWindow.document.getElementsByTagName("head")[0];
69
+ if (null != s) {
70
+ if ((nt(s), t.sn())) {
71
+ const n = document.createElement("style");
72
+ (n.innerHTML = t.css),
73
+ (n.id = t.rn()),
74
+ null != r && n.setAttribute("nonce", r),
75
+ s.appendChild(n);
76
+ }
77
+ const n = i.contentWindow.document.createElement("base");
78
+ n.setAttribute("target", "_parent"), s.appendChild(n);
79
+ }
80
+ const a = i.contentWindow.document.getElementsByTagName("title");
81
+ a.length > 0 && i.setAttribute("title", a[0].textContent);
82
+ const l = {
83
+ closeMessage: function() {
84
+ t.on(i);
85
+ },
86
+ logClick: function() {
87
+ const n = [t, ...arguments];
88
+ logInAppMessageHtmlClick.apply(t, Array.prototype.slice.call(n));
89
+ },
90
+ display: {},
91
+ web: {}
92
+ },
93
+ requestPushPermission = function() {
94
+ return function() {
95
+ const t = arguments;
96
+ import("../../Push/request-push-permission.js").then(n => {
97
+ n.requestPushPermission.apply(
98
+ null,
99
+ Array.prototype.slice.call(t)
100
+ );
101
+ });
102
+ };
103
+ },
104
+ m = {
105
+ requestImmediateDataFlush: async function() {
106
+ const t = arguments,
107
+ n = await import("../../Core/request-immediate-data-flush.js");
108
+ n.requestImmediateDataFlush.apply(
109
+ null,
110
+ Array.prototype.slice.call(t)
111
+ );
112
+ },
113
+ logCustomEvent: async function() {
114
+ const t = arguments,
115
+ n = await import("../../Core/log-custom-event.js");
116
+ n.logCustomEvent.apply(null, Array.prototype.slice.call(t));
117
+ },
118
+ logPurchase: async function() {
119
+ const t = arguments,
120
+ n = await import("../../Core/log-purchase.js");
121
+ n.logPurchase.apply(null, Array.prototype.slice.call(t));
122
+ },
123
+ unregisterPush: async function() {
124
+ const t = arguments,
125
+ n = await import("../../Push/unregister-push.js");
126
+ n.unregisterPush.apply(null, Array.prototype.slice.call(t));
127
+ },
128
+ requestPushPermission: requestPushPermission(),
129
+ changeUser: async function() {
130
+ const t = arguments,
131
+ n = await import("../../Core/change-user.js");
132
+ n.changeUser.apply(null, Array.prototype.slice.call(t));
133
+ }
134
+ },
135
+ f = function(t) {
136
+ return function() {
137
+ m[t].apply(null, Array.prototype.slice.call(arguments));
138
+ };
139
+ };
140
+ for (const t of rr(m)) l[t] = f(t);
141
+ const p = [
142
+ "setFirstName",
143
+ "setLastName",
144
+ "setEmail",
145
+ "setGender",
146
+ "setDateOfBirth",
147
+ "setCountry",
148
+ "setHomeCity",
149
+ "setEmailNotificationSubscriptionType",
150
+ "setLanguage",
151
+ "addAlias",
152
+ "setPushNotificationSubscriptionType",
153
+ "setPhoneNumber",
154
+ "setCustomUserAttribute",
155
+ "addToCustomAttributeArray",
156
+ "removeFromCustomAttributeArray",
157
+ "incrementCustomUserAttribute",
158
+ "setCustomLocationAttribute",
159
+ "addToSubscriptionGroup",
160
+ "removeFromSubscriptionGroup"
161
+ ],
162
+ d = function(t) {
163
+ return function() {
164
+ const n = Q();
165
+ n[t].apply(n, Array.prototype.slice.call(arguments));
166
+ };
167
+ },
168
+ y = {};
169
+ for (let t = 0; t < p.length; t++) y[p[t]] = d(p[t]);
170
+ l.getUser = function() {
171
+ return y;
172
+ };
173
+ const b = { showFeed: n },
174
+ g = function(n) {
175
+ return function() {
176
+ const e = arguments;
177
+ t.on(i, function() {
178
+ b[n].apply(null, Array.prototype.slice.call(e));
179
+ });
180
+ };
181
+ };
182
+ for (const t of rr(b)) l.display[t] = g(t);
183
+ const h = { registerAppboyPushMessages: requestPushPermission() },
184
+ A = function(t) {
185
+ return function() {
186
+ h[t].apply(null, Array.prototype.slice.call(arguments));
187
+ };
188
+ };
189
+ for (const t of rr(h)) l.web[t] = A(t);
190
+ if (
191
+ ((i.contentWindow.appboyBridge = l),
192
+ (i.contentWindow.brazeBridge = l),
193
+ t.un !== InAppMessage.es.cn)
194
+ ) {
195
+ const t = i.contentWindow.document.getElementsByTagName("a");
196
+ for (let n = 0; n < t.length; n++) t[n].onclick = u(t[n]);
197
+ const n = i.contentWindow.document.getElementsByTagName("button");
198
+ for (let t = 0; t < n.length; t++) n[t].onclick = u(n[t]);
199
+ }
200
+ const j = i.contentWindow.document.body;
201
+ if (null != j) {
202
+ t.an() && (j.id = t.htmlId);
203
+ const n = document.createElement("hidden");
204
+ (n.onclick = l.closeMessage),
205
+ (n.className = "ab-programmatic-close-button"),
206
+ j.appendChild(n);
207
+ }
208
+ i.contentWindow.dispatchEvent(new CustomEvent("ab.BridgeReady")),
209
+ -1 !== i.className.indexOf("ab-start-hidden") &&
210
+ ((i.className = i.className.replace("ab-start-hidden", "")), e(i)),
211
+ document.activeElement !== i && i.focus();
212
+ }),
213
+ (i.className =
214
+ "ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions"),
215
+ ot.OS === rt.ln)
216
+ ) {
217
+ const n = document.createElement("div");
218
+ return (
219
+ (n.className = "ab-ios-scroll-wrapper"), n.appendChild(i), (t.mn = n), n
220
+ );
221
+ }
222
+ return (t.mn = i), i;
223
+ }