@braze/web-sdk 4.10.0 → 4.10.1

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 (202) hide show
  1. package/index.d.ts +9 -9
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -8
  4. package/shared-lib/encoding-utils.js +1 -12
  5. package/shared-lib/event-types.js +1 -34
  6. package/shared-lib/guid.js +1 -10
  7. package/shared-lib/indexed-db-adapter.js +1 -352
  8. package/shared-lib/logger.js +1 -38
  9. package/shared-lib/supported-options.js +1 -27
  10. package/shared-lib/types.js +1 -1
  11. package/src/Card/card-manager-factory.js +1 -14
  12. package/src/Card/card-manager.js +1 -78
  13. package/src/Card/display/card-display.js +1 -138
  14. package/src/Card/index.js +1 -6
  15. package/src/Card/log-card-click.js +1 -11
  16. package/src/Card/log-card-dismissal.js +1 -11
  17. package/src/Card/log-card-impressions.js +1 -13
  18. package/src/Card/log-content-card-click.js +1 -4
  19. package/src/Card/log-content-card-impressions.js +1 -4
  20. package/src/Card/models/banner.js +1 -31
  21. package/src/Card/models/captioned-image.js +1 -33
  22. package/src/Card/models/card.js +1 -196
  23. package/src/Card/models/classic-card.js +1 -32
  24. package/src/Card/models/control-card.js +1 -23
  25. package/src/Card/models/image-only.js +1 -32
  26. package/src/Card/models/index.js +1 -6
  27. package/src/Card/types.js +1 -1
  28. package/src/Card/util/card-factory.js +1 -104
  29. package/src/ContentCards/content-cards-provider-factory.js +1 -20
  30. package/src/ContentCards/content-cards-provider.js +1 -391
  31. package/src/ContentCards/content-cards.js +1 -24
  32. package/src/ContentCards/get-cached-content-cards.js +1 -5
  33. package/src/ContentCards/index.js +1 -8
  34. package/src/ContentCards/log-content-cards-displayed.js +1 -5
  35. package/src/ContentCards/request-content-cards-refresh.js +1 -5
  36. package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -17
  37. package/src/ContentCards/types.js +1 -1
  38. package/src/ContentCards/ui/hide-content-cards.js +1 -8
  39. package/src/ContentCards/ui/show-content-cards.js +1 -77
  40. package/src/ContentCards/ui/toggle-content-cards.js +1 -8
  41. package/src/Core/add-sdk-metadata.js +1 -26
  42. package/src/Core/braze-sdk-metadata.js +1 -10
  43. package/src/Core/change-user.js +1 -17
  44. package/src/Core/destroy.js +1 -5
  45. package/src/Core/device-properties.js +1 -9
  46. package/src/Core/disable-sdk.js +1 -15
  47. package/src/Core/enable-sdk.js +1 -11
  48. package/src/Core/get-device-id.js +1 -13
  49. package/src/Core/get-user.js +1 -4
  50. package/src/Core/handle-braze-action.js +1 -87
  51. package/src/Core/index.js +1 -23
  52. package/src/Core/initialize.js +1 -4
  53. package/src/Core/is-disabled.js +1 -4
  54. package/src/Core/log-custom-event.js +1 -38
  55. package/src/Core/log-purchase.js +1 -245
  56. package/src/Core/open-session.js +1 -25
  57. package/src/Core/remove-all-subscriptions.js +1 -4
  58. package/src/Core/remove-subscription.js +1 -4
  59. package/src/Core/request-immediate-data-flush.js +1 -6
  60. package/src/Core/set-logger.js +1 -4
  61. package/src/Core/set-sdk-authentication-signature.js +1 -8
  62. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -6
  63. package/src/Core/toggle-logging.js +1 -4
  64. package/src/Core/types.js +1 -1
  65. package/src/Core/wipe-data.js +1 -16
  66. package/src/FeatureFlags/feature-flag-factory.js +1 -24
  67. package/src/FeatureFlags/feature-flag.js +1 -64
  68. package/src/FeatureFlags/feature-flags-provider-factory.js +1 -19
  69. package/src/FeatureFlags/feature-flags-provider.js +1 -145
  70. package/src/FeatureFlags/get-all-feature-flags.js +1 -12
  71. package/src/FeatureFlags/get-feature-flag.js +1 -12
  72. package/src/FeatureFlags/index.js +1 -6
  73. package/src/FeatureFlags/log-feature-flag-impression.js +1 -23
  74. package/src/FeatureFlags/refresh-feature-flags.js +1 -9
  75. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -9
  76. package/src/FeatureFlags/types.js +1 -1
  77. package/src/Feed/feed-provider-factory.js +1 -18
  78. package/src/Feed/feed-provider.js +1 -90
  79. package/src/Feed/feed.js +1 -20
  80. package/src/Feed/get-cached-feed.js +1 -5
  81. package/src/Feed/index.js +1 -8
  82. package/src/Feed/log-feed-displayed.js +1 -7
  83. package/src/Feed/request-feed-refresh.js +1 -5
  84. package/src/Feed/subscribe-to-feed-updates.js +1 -5
  85. package/src/Feed/types.js +1 -1
  86. package/src/Feed/ui/hide-feed.js +1 -7
  87. package/src/Feed/ui/show-feed.js +1 -96
  88. package/src/Feed/ui/toggle-feed.js +1 -8
  89. package/src/InAppMessage/defer-in-app-message.js +1 -13
  90. package/src/InAppMessage/display/get-animation-effect.js +1 -19
  91. package/src/InAppMessage/display/html-message-to-html.js +1 -244
  92. package/src/InAppMessage/display/in-app-message-to-html.js +1 -188
  93. package/src/InAppMessage/display/modal-utils.js +1 -73
  94. package/src/InAppMessage/get-deferred-in-app-message.js +1 -5
  95. package/src/InAppMessage/in-app-message-factory.js +1 -166
  96. package/src/InAppMessage/in-app-message-manager-factory.js +1 -16
  97. package/src/InAppMessage/in-app-message-manager.js +1 -248
  98. package/src/InAppMessage/index.js +1 -16
  99. package/src/InAppMessage/log-in-app-message-button-click.js +1 -27
  100. package/src/InAppMessage/log-in-app-message-click.js +1 -19
  101. package/src/InAppMessage/log-in-app-message-html-click.js +1 -23
  102. package/src/InAppMessage/log-in-app-message-impression.js +1 -13
  103. package/src/InAppMessage/models/control-message.js +1 -11
  104. package/src/InAppMessage/models/full-screen-message.js +1 -105
  105. package/src/InAppMessage/models/html-message.js +1 -68
  106. package/src/InAppMessage/models/in-app-message-button.js +1 -47
  107. package/src/InAppMessage/models/in-app-message.js +1 -382
  108. package/src/InAppMessage/models/modal-message.js +1 -101
  109. package/src/InAppMessage/models/slide-up-message.js +1 -84
  110. package/src/InAppMessage/models/templated-in-app-message.js +1 -19
  111. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -10
  112. package/src/InAppMessage/types.js +1 -1
  113. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -15
  114. package/src/InAppMessage/ui/show-in-app-message.js +1 -181
  115. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  116. package/src/Push/index.js +1 -5
  117. package/src/Push/is-push-blocked.js +1 -5
  118. package/src/Push/is-push-permission-granted.js +1 -5
  119. package/src/Push/is-push-supported.js +1 -5
  120. package/src/Push/push-manager-factory.js +1 -30
  121. package/src/Push/push-manager.js +1 -387
  122. package/src/Push/request-push-permission.js +1 -9
  123. package/src/Push/types.js +1 -1
  124. package/src/Push/unregister-push.js +1 -5
  125. package/src/Push/utils/push-utils.js +1 -36
  126. package/src/User/index.js +1 -1
  127. package/src/User/types.js +1 -1
  128. package/src/User/user-manager.js +1 -73
  129. package/src/User/user.js +1 -302
  130. package/src/common/base-feed.js +1 -28
  131. package/src/common/base-provider.js +1 -6
  132. package/src/common/constants.js +1 -14
  133. package/src/common/event-logger.js +1 -31
  134. package/src/common/feed-display.js +1 -210
  135. package/src/common/translations.js +1 -148
  136. package/src/common/types.js +1 -1
  137. package/src/index.js +1 -9
  138. package/src/l10n/l10n-manager-factory.js +1 -22
  139. package/src/l10n/l10n-manager.js +1 -25
  140. package/src/l10n/types.js +1 -1
  141. package/src/managers/auth-manager.js +1 -51
  142. package/src/managers/braze-instance.js +1 -331
  143. package/src/managers/device-manager.js +1 -85
  144. package/src/managers/network-manager.js +1 -256
  145. package/src/managers/server-config-manager.js +1 -108
  146. package/src/managers/session-manager.js +1 -75
  147. package/src/managers/storage-manager-factory.js +1 -42
  148. package/src/managers/storage-manager.js +1 -419
  149. package/src/managers/subscription-manager.js +1 -28
  150. package/src/managers/types.js +1 -1
  151. package/src/models/backend-errors.js +1 -8
  152. package/src/models/braze-event.js +1 -47
  153. package/src/models/braze-sdk-metadata.js +1 -10
  154. package/src/models/device.js +1 -18
  155. package/src/models/identifier.js +1 -19
  156. package/src/models/push-token.js +1 -27
  157. package/src/models/request-result.js +1 -8
  158. package/src/models/server-config.js +1 -48
  159. package/src/models/types.js +1 -1
  160. package/src/request-controller.js +1 -311
  161. package/src/triggers/models/custom-event-data.js +1 -14
  162. package/src/triggers/models/custom-event-property-data.js +1 -21
  163. package/src/triggers/models/filter-set.js +1 -55
  164. package/src/triggers/models/filter.js +1 -102
  165. package/src/triggers/models/in-app-message-click-data.js +1 -25
  166. package/src/triggers/models/purchase-data.js +1 -14
  167. package/src/triggers/models/purchase-property-data.js +1 -21
  168. package/src/triggers/models/push-click-data.js +1 -15
  169. package/src/triggers/models/trigger-condition.js +1 -105
  170. package/src/triggers/models/trigger-events.js +1 -8
  171. package/src/triggers/models/trigger.js +1 -122
  172. package/src/triggers/triggers-provider-factory.js +1 -34
  173. package/src/triggers/triggers-provider.js +1 -326
  174. package/src/triggers/types.js +1 -1
  175. package/src/types.js +1 -1
  176. package/src/ui/js/attach-css.js +1 -13
  177. package/src/ui/js/feed-css.js +1 -12
  178. package/src/ui/js/iam-css.js +1 -12
  179. package/src/ui/js/index.js +1 -3
  180. package/src/ui/js/load-font-awesome.js +1 -13
  181. package/src/util/base-device-parser.js +1 -14
  182. package/src/util/braze-actions.js +1 -84
  183. package/src/util/browser-detector.js +1 -84
  184. package/src/util/client-hints-parser.js +1 -66
  185. package/src/util/code-utils.js +1 -100
  186. package/src/util/color-utils.js +1 -29
  187. package/src/util/component-utils.js +1 -26
  188. package/src/util/date-utils.js +1 -28
  189. package/src/util/deprecation-utils.js +1 -5
  190. package/src/util/device-constants.js +1 -14
  191. package/src/util/dom-utils.js +1 -91
  192. package/src/util/error-utils.js +1 -2
  193. package/src/util/key-codes.js +1 -1
  194. package/src/util/math.js +1 -5
  195. package/src/util/net.js +1 -71
  196. package/src/util/request-header-utils.js +1 -46
  197. package/src/util/string-utils.js +1 -22
  198. package/src/util/types.js +1 -1
  199. package/src/util/url-utils.js +1 -20
  200. package/src/util/user-agent-parser.js +1 -85
  201. package/src/util/validation-utils.js +1 -217
  202. package/src/util/window-utils.js +1 -34
@@ -1,105 +1 @@
1
- import { buttonsFromSerializedInAppMessage as pe } from "../in-app-message-factory.js";
2
- import InAppMessage from "./in-app-message.js";
3
- export default class FullScreenMessage extends InAppMessage {
4
- constructor(
5
- e,
6
- r,
7
- s,
8
- t,
9
- i,
10
- a,
11
- o,
12
- p,
13
- m,
14
- n,
15
- u,
16
- c,
17
- f,
18
- d,
19
- l,
20
- g,
21
- j,
22
- x,
23
- z,
24
- h,
25
- v,
26
- w,
27
- y,
28
- S,
29
- b,
30
- k,
31
- q,
32
- A,
33
- ) {
34
- (p = p || InAppMessage.DismissType.MANUAL),
35
- (k = k || InAppMessage.Orientation.PORTRAIT),
36
- super(
37
- e,
38
- r,
39
- void 0,
40
- s,
41
- t,
42
- i,
43
- a,
44
- o,
45
- p,
46
- m,
47
- n,
48
- u,
49
- c,
50
- f,
51
- d,
52
- l,
53
- g,
54
- j,
55
- x,
56
- z,
57
- h,
58
- v,
59
- w,
60
- y,
61
- S,
62
- (b = b || InAppMessage.CropType.CENTER_CROP),
63
- k,
64
- q,
65
- A,
66
- ),
67
- (this.Te = InAppMessage.TextAlignment.CENTER);
68
- }
69
- ss() {
70
- return super.ss(FullScreenMessage.es);
71
- }
72
- static an(e) {
73
- return new FullScreenMessage(
74
- e[InAppMessage.hs.ea],
75
- e[InAppMessage.hs.ra],
76
- e[InAppMessage.hs.xs],
77
- e[InAppMessage.hs.sa],
78
- e[InAppMessage.hs.ta],
79
- e[InAppMessage.hs.URI],
80
- e[InAppMessage.hs.ia],
81
- e[InAppMessage.hs.oa],
82
- e[InAppMessage.hs.pa],
83
- e[InAppMessage.hs.ma],
84
- e[InAppMessage.hs.os],
85
- e[InAppMessage.hs.na],
86
- e[InAppMessage.hs.ua],
87
- e[InAppMessage.hs.ca],
88
- e[InAppMessage.hs.fa],
89
- e[InAppMessage.hs.da],
90
- e[InAppMessage.hs.la],
91
- e[InAppMessage.hs.ga],
92
- e[InAppMessage.hs.ja],
93
- e[InAppMessage.hs.xa],
94
- e[InAppMessage.hs.za],
95
- e[InAppMessage.hs.ha],
96
- e[InAppMessage.hs.va],
97
- pe(e[InAppMessage.hs.wa]),
98
- e[InAppMessage.hs.ya],
99
- e[InAppMessage.hs.Sa],
100
- e[InAppMessage.hs.ba],
101
- e[InAppMessage.hs.CSS],
102
- );
103
- }
104
- }
105
- FullScreenMessage.es = InAppMessage.qe.on;
1
+ import{buttonsFromSerializedInAppMessage as pe}from"../in-app-message-factory.js";import InAppMessage from"./in-app-message.js";export default class FullScreenMessage extends InAppMessage{constructor(e,r,s,t,i,a,o,p,m,n,u,c,f,d,l,g,j,x,z,h,v,w,y,S,b,k,q,A){p=p||InAppMessage.DismissType.MANUAL,k=k||InAppMessage.Orientation.PORTRAIT,super(e,r,void 0,s,t,i,a,o,p,m,n,u,c,f,d,l,g,j,x,z,h,v,w,y,S,b=b||InAppMessage.CropType.CENTER_CROP,k,q,A),this.Te=InAppMessage.TextAlignment.CENTER}ss(){return super.ss(FullScreenMessage.es)}static an(e){return new FullScreenMessage(e[InAppMessage.hs.ea],e[InAppMessage.hs.ra],e[InAppMessage.hs.xs],e[InAppMessage.hs.sa],e[InAppMessage.hs.ta],e[InAppMessage.hs.URI],e[InAppMessage.hs.ia],e[InAppMessage.hs.oa],e[InAppMessage.hs.pa],e[InAppMessage.hs.ma],e[InAppMessage.hs.os],e[InAppMessage.hs.na],e[InAppMessage.hs.ua],e[InAppMessage.hs.ca],e[InAppMessage.hs.fa],e[InAppMessage.hs.da],e[InAppMessage.hs.la],e[InAppMessage.hs.ga],e[InAppMessage.hs.ja],e[InAppMessage.hs.xa],e[InAppMessage.hs.za],e[InAppMessage.hs.ha],e[InAppMessage.hs.va],pe(e[InAppMessage.hs.wa]),e[InAppMessage.hs.ya],e[InAppMessage.hs.Sa],e[InAppMessage.hs.ba],e[InAppMessage.hs.CSS])}}FullScreenMessage.es=InAppMessage.qe.on;
@@ -1,68 +1 @@
1
- import InAppMessage from "./in-app-message.js";
2
- export default class HtmlMessage extends InAppMessage {
3
- constructor(i, o, e, r, d, t, s, v, n, u, a) {
4
- super(
5
- i,
6
- void 0,
7
- void 0,
8
- o,
9
- e,
10
- void 0,
11
- void 0,
12
- void 0,
13
- (r = r || InAppMessage.DismissType.MANUAL),
14
- d,
15
- void 0,
16
- void 0,
17
- void 0,
18
- void 0,
19
- void 0,
20
- void 0,
21
- void 0,
22
- void 0,
23
- t,
24
- s,
25
- void 0,
26
- void 0,
27
- void 0,
28
- v,
29
- void 0,
30
- void 0,
31
- void 0,
32
- n,
33
- u,
34
- ),
35
- (this.messageFields = a),
36
- (this.messageFields = a);
37
- }
38
- io() {
39
- return !1;
40
- }
41
- p(i) {
42
- if (this.Pe === InAppMessage.qe.ln) {
43
- if (this.do) return !1;
44
- this.do = !0;
45
- }
46
- return this.ht.Et(i), !0;
47
- }
48
- ss() {
49
- const i = super.ss(HtmlMessage.es);
50
- return (i[InAppMessage.hs.vo] = this.messageFields), i;
51
- }
52
- static an(i) {
53
- return new HtmlMessage(
54
- i[InAppMessage.hs.ea],
55
- i[InAppMessage.hs.xs],
56
- i[InAppMessage.hs.sa],
57
- i[InAppMessage.hs.oa],
58
- i[InAppMessage.hs.pa],
59
- i[InAppMessage.hs.ga],
60
- i[InAppMessage.hs.ja],
61
- i[InAppMessage.hs.va],
62
- i[InAppMessage.hs.ba],
63
- i[InAppMessage.hs.CSS],
64
- i[InAppMessage.hs.vo],
65
- );
66
- }
67
- }
68
- HtmlMessage.es = InAppMessage.qe.ln;
1
+ import InAppMessage from"./in-app-message.js";export default class HtmlMessage extends InAppMessage{constructor(i,o,e,r,d,t,s,v,n,u,a){super(i,void 0,void 0,o,e,void 0,void 0,void 0,r=r||InAppMessage.DismissType.MANUAL,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,t,s,void 0,void 0,void 0,v,void 0,void 0,void 0,n,u),this.messageFields=a,this.messageFields=a}io(){return!1}p(i){if(this.Pe===InAppMessage.qe.ln){if(this.do)return!1;this.do=!0}return this.ht.Et(i),!0}ss(){const i=super.ss(HtmlMessage.es);return i[InAppMessage.hs.vo]=this.messageFields,i}static an(i){return new HtmlMessage(i[InAppMessage.hs.ea],i[InAppMessage.hs.xs],i[InAppMessage.hs.sa],i[InAppMessage.hs.oa],i[InAppMessage.hs.pa],i[InAppMessage.hs.ga],i[InAppMessage.hs.ja],i[InAppMessage.hs.va],i[InAppMessage.hs.ba],i[InAppMessage.hs.CSS],i[InAppMessage.hs.vo])}}HtmlMessage.es=InAppMessage.qe.ln;
@@ -1,47 +1 @@
1
- import InAppMessage from "./in-app-message.js";
2
- import E from "../../managers/subscription-manager.js";
3
- export default class InAppMessageButton {
4
- constructor(s, t, i, r, h, e, n) {
5
- (this.text = s),
6
- (this.backgroundColor = t),
7
- (this.textColor = i),
8
- (this.borderColor = r),
9
- (this.clickAction = h),
10
- (this.uri = e),
11
- (this.id = n),
12
- (this.text = s || ""),
13
- (this.backgroundColor = t || InAppMessage.th.sh),
14
- (this.textColor = i || InAppMessage.th.ih),
15
- (this.borderColor = r || this.backgroundColor),
16
- (this.clickAction = h || InAppMessage.ClickAction.NONE),
17
- (this.uri = e),
18
- null == n && (n = InAppMessageButton.Yi),
19
- (this.id = n),
20
- (this.do = !1),
21
- (this.ht = new E());
22
- }
23
- subscribeToClickedEvent(s) {
24
- return this.ht.lt(s);
25
- }
26
- removeSubscription(s) {
27
- this.ht.removeSubscription(s);
28
- }
29
- removeAllSubscriptions() {
30
- this.ht.removeAllSubscriptions();
31
- }
32
- p() {
33
- return !this.do && ((this.do = !0), this.ht.Et(), !0);
34
- }
35
- static fromJson(s) {
36
- return new InAppMessageButton(
37
- s.text,
38
- s.bg_color,
39
- s.text_color,
40
- s.border_color,
41
- s.click_action,
42
- s.uri,
43
- s.id,
44
- );
45
- }
46
- }
47
- InAppMessageButton.Yi = -1;
1
+ import InAppMessage from"./in-app-message.js";import E from"../../managers/subscription-manager.js";export default class InAppMessageButton{constructor(s,t,i,r,h,e,n){this.text=s,this.backgroundColor=t,this.textColor=i,this.borderColor=r,this.clickAction=h,this.uri=e,this.id=n,this.text=s||"",this.backgroundColor=t||InAppMessage.th.sh,this.textColor=i||InAppMessage.th.ih,this.borderColor=r||this.backgroundColor,this.clickAction=h||InAppMessage.ClickAction.NONE,this.uri=e,null==n&&(n=InAppMessageButton.Yi),this.id=n,this.do=!1,this.ht=new E}subscribeToClickedEvent(s){return this.ht.lt(s)}removeSubscription(s){this.ht.removeSubscription(s)}removeAllSubscriptions(){this.ht.removeAllSubscriptions()}p(){return!this.do&&(this.do=!0,this.ht.Et(),!0)}static fromJson(s){return new InAppMessageButton(s.text,s.bg_color,s.text_color,s.border_color,s.click_action,s.uri,s.id)}}InAppMessageButton.Yi=-1;
@@ -1,382 +1 @@
1
- import e, { OPTIONS as L } from "../../managers/braze-instance.js";
2
- import V from "../../util/browser-detector.js";
3
- import {
4
- clickElement as Et,
5
- supportsPassive as Tt,
6
- } from "../../util/dom-utils.js";
7
- import { KeyCodes as lt } from "../../util/key-codes.js";
8
- import E from "../../managers/subscription-manager.js";
9
- import { isIFrame as It } from "../utils/in-app-message-utils.js";
10
- export default class InAppMessage {
11
- constructor(
12
- t,
13
- s,
14
- i,
15
- h,
16
- e,
17
- n,
18
- T,
19
- o,
20
- r,
21
- l,
22
- u,
23
- a,
24
- I,
25
- c,
26
- O,
27
- A,
28
- L,
29
- _,
30
- m,
31
- N,
32
- R,
33
- S,
34
- D,
35
- M,
36
- C,
37
- d,
38
- U,
39
- b,
40
- P,
41
- ) {
42
- (this.message = t),
43
- (this.messageAlignment = s),
44
- (this.slideFrom = i),
45
- (this.extras = h),
46
- (this.triggerId = e),
47
- (this.clickAction = n),
48
- (this.uri = T),
49
- (this.openTarget = o),
50
- (this.dismissType = r),
51
- (this.duration = l),
52
- (this.icon = u),
53
- (this.imageUrl = a),
54
- (this.imageStyle = I),
55
- (this.iconColor = c),
56
- (this.iconBackgroundColor = O),
57
- (this.backgroundColor = A),
58
- (this.textColor = L),
59
- (this.closeButtonColor = _),
60
- (this.animateIn = m),
61
- (this.animateOut = N),
62
- (this.header = R),
63
- (this.headerAlignment = S),
64
- (this.headerTextColor = D),
65
- (this.frameColor = M),
66
- (this.buttons = C),
67
- (this.cropType = d),
68
- (this.orientation = U),
69
- (this.htmlId = b),
70
- (this.css = P),
71
- (this.message = t),
72
- (this.messageAlignment = s || InAppMessage.TextAlignment.CENTER),
73
- (this.duration = l || 5e3),
74
- (this.slideFrom = i || InAppMessage.SlideFrom.BOTTOM),
75
- (this.extras = h || {}),
76
- (this.triggerId = e),
77
- (this.clickAction = n || InAppMessage.ClickAction.NONE),
78
- (this.uri = T),
79
- (this.openTarget = o || InAppMessage.OpenTarget.NONE),
80
- (this.dismissType = r || InAppMessage.DismissType.AUTO_DISMISS),
81
- (this.icon = u),
82
- (this.imageUrl = a),
83
- (this.imageStyle = I || InAppMessage.ImageStyle.TOP),
84
- (this.iconColor = c || InAppMessage.th.ih),
85
- (this.iconBackgroundColor = O || InAppMessage.th.sh),
86
- (this.backgroundColor = A || InAppMessage.th.ih),
87
- (this.textColor = L || InAppMessage.th.hh),
88
- (this.closeButtonColor = _ || InAppMessage.th.eh),
89
- (this.animateIn = m),
90
- null == this.animateIn && (this.animateIn = !0),
91
- (this.animateOut = N),
92
- null == this.animateOut && (this.animateOut = !0),
93
- (this.header = R),
94
- (this.headerAlignment = S || InAppMessage.TextAlignment.CENTER),
95
- (this.headerTextColor = D || InAppMessage.th.hh),
96
- (this.frameColor = M || InAppMessage.th.Eh),
97
- (this.buttons = C || []),
98
- (this.cropType = d || InAppMessage.CropType.FIT_CENTER),
99
- (this.orientation = U),
100
- (this.htmlId = b),
101
- (this.css = P),
102
- (this.isControl = !1),
103
- (this.nh = !1),
104
- (this.Th = !1),
105
- (this.do = !1),
106
- (this.oh = !1),
107
- (this.Me = null),
108
- (this.ke = null),
109
- (this.ht = new E()),
110
- (this.rh = new E()),
111
- (this.Te = InAppMessage.TextAlignment.CENTER);
112
- }
113
- subscribeToClickedEvent(t) {
114
- return this.ht.lt(t);
115
- }
116
- subscribeToDismissedEvent(t) {
117
- return this.rh.lt(t);
118
- }
119
- removeSubscription(t) {
120
- this.ht.removeSubscription(t), this.rh.removeSubscription(t);
121
- }
122
- removeAllSubscriptions() {
123
- this.ht.removeAllSubscriptions(), this.rh.removeAllSubscriptions();
124
- }
125
- closeMessage() {
126
- this.ye(this.Me);
127
- }
128
- xe() {
129
- return !0;
130
- }
131
- io() {
132
- return this.xe();
133
- }
134
- Ne() {
135
- return null != this.htmlId && this.htmlId.length > 4;
136
- }
137
- Ae() {
138
- return this.Ne() && null != this.css && this.css.length > 0;
139
- }
140
- Ce() {
141
- if (this.Ne() && this.Ae()) return this.htmlId + "-css";
142
- }
143
- M() {
144
- return !this.Th && ((this.Th = !0), !0);
145
- }
146
- so() {
147
- return this.Th;
148
- }
149
- p(t) {
150
- return !this.do && ((this.do = !0), this.ht.Et(), !0);
151
- }
152
- F() {
153
- return !this.oh && ((this.oh = !0), this.rh.Et(), !0);
154
- }
155
- hide(t) {
156
- if (t && t.parentNode) {
157
- let s = t.closest(".ab-iam-root");
158
- if ((null == s && (s = t), this.xe() && null != s.parentNode)) {
159
- const t = s.parentNode.classList;
160
- t && t.contains(InAppMessage.lh) && t.remove(InAppMessage.lh),
161
- document.body.removeEventListener("touchmove", InAppMessage.uh);
162
- }
163
- s.className = s.className.replace(InAppMessage.ah, InAppMessage.Ih);
164
- }
165
- return this.animateOut || !1;
166
- }
167
- ye(t, s) {
168
- if (null == t) return;
169
- let i;
170
- (this.Me = null),
171
- (i =
172
- -1 === t.className.indexOf("ab-in-app-message")
173
- ? t.getElementsByClassName("ab-in-app-message")[0]
174
- : t);
175
- let h = !1;
176
- i && (h = this.hide(i));
177
- const e = document.body;
178
- let E;
179
- null != e && (E = e.scrollTop);
180
- const n = () => {
181
- if (t && t.parentNode) {
182
- let s = t.closest(".ab-iam-root");
183
- null == s && (s = t), s.parentNode && s.parentNode.removeChild(s);
184
- }
185
- const i = this.Ce();
186
- if (null != i) {
187
- const t = document.getElementById(i);
188
- t && t.parentNode && t.parentNode.removeChild(t);
189
- }
190
- null != e && "Safari" === V.browser && (e.scrollTop = E),
191
- s ? s() : this.F();
192
- };
193
- h ? setTimeout(n, InAppMessage.Oh) : n(), this.ke && this.ke.focus();
194
- }
195
- Ge() {
196
- return document.createTextNode(this.message || "");
197
- }
198
- Be(t) {
199
- let s = "";
200
- this.message || this.header || !this.xe() || (s = "Modal Image"),
201
- t.setAttribute("alt", s);
202
- }
203
- static uh(t) {
204
- if (t.targetTouches && t.targetTouches.length > 1) return;
205
- const s = t.target;
206
- (s &&
207
- s.classList &&
208
- s.classList.contains("ab-message-text") &&
209
- s.scrollHeight > s.clientHeight) ||
210
- (document.querySelector(`.${InAppMessage.lh}`) && t.preventDefault());
211
- }
212
- Ah(t) {
213
- const s = t.parentNode;
214
- this.xe() &&
215
- null != s &&
216
- this.orientation !== InAppMessage.Orientation.LANDSCAPE &&
217
- (null != s.classList && s.classList.add(InAppMessage.lh),
218
- document.body.addEventListener(
219
- "touchmove",
220
- InAppMessage.uh,
221
- !!Tt() && { passive: !1 },
222
- )),
223
- (t.className += " " + InAppMessage.ah);
224
- }
225
- static Lh(t) {
226
- if (
227
- t.keyCode === lt._h &&
228
- !e.nn(L.mh) &&
229
- document.querySelectorAll(".ab-modal-interactions").length > 0
230
- ) {
231
- const t = document.getElementsByClassName("ab-html-message");
232
- let s = !1;
233
- for (const i of t) {
234
- let t = null;
235
- It(i) &&
236
- i.contentWindow &&
237
- (t = i.contentWindow.document.getElementsByClassName(
238
- "ab-programmatic-close-button",
239
- )[0]),
240
- null != t && (Et(t), (s = !0));
241
- }
242
- if (!s) {
243
- const t = document.querySelectorAll(
244
- ".ab-modal-interactions > .ab-close-button",
245
- )[0];
246
- null != t && Et(t);
247
- }
248
- }
249
- }
250
- Nh() {
251
- this.nh ||
252
- e.nn(L.mh) ||
253
- (document.addEventListener("keydown", InAppMessage.Lh, !1),
254
- e.Rh(() => {
255
- document.removeEventListener("keydown", InAppMessage.Lh);
256
- }),
257
- (this.nh = !0));
258
- }
259
- ss(t) {
260
- const s = {};
261
- return t
262
- ? ((s[InAppMessage.hs.ea] = this.message),
263
- (s[InAppMessage.hs.ra] = this.messageAlignment),
264
- (s[InAppMessage.hs.Sh] = this.slideFrom),
265
- (s[InAppMessage.hs.xs] = this.extras),
266
- (s[InAppMessage.hs.sa] = this.triggerId),
267
- (s[InAppMessage.hs.ta] = this.clickAction),
268
- (s[InAppMessage.hs.URI] = this.uri),
269
- (s[InAppMessage.hs.ia] = this.openTarget),
270
- (s[InAppMessage.hs.oa] = this.dismissType),
271
- (s[InAppMessage.hs.pa] = this.duration),
272
- (s[InAppMessage.hs.ma] = this.icon),
273
- (s[InAppMessage.hs.os] = this.imageUrl),
274
- (s[InAppMessage.hs.na] = this.imageStyle),
275
- (s[InAppMessage.hs.ua] = this.iconColor),
276
- (s[InAppMessage.hs.ca] = this.iconBackgroundColor),
277
- (s[InAppMessage.hs.fa] = this.backgroundColor),
278
- (s[InAppMessage.hs.da] = this.textColor),
279
- (s[InAppMessage.hs.la] = this.closeButtonColor),
280
- (s[InAppMessage.hs.ga] = this.animateIn),
281
- (s[InAppMessage.hs.ja] = this.animateOut),
282
- (s[InAppMessage.hs.xa] = this.header),
283
- (s[InAppMessage.hs.za] = this.headerAlignment),
284
- (s[InAppMessage.hs.ha] = this.headerTextColor),
285
- (s[InAppMessage.hs.va] = this.frameColor),
286
- (s[InAppMessage.hs.wa] = this.buttons),
287
- (s[InAppMessage.hs.ya] = this.cropType),
288
- (s[InAppMessage.hs.Sa] = this.orientation),
289
- (s[InAppMessage.hs.ba] = this.htmlId),
290
- (s[InAppMessage.hs.CSS] = this.css),
291
- (s[InAppMessage.hs.ts] = t),
292
- s)
293
- : s;
294
- }
295
- }
296
- (InAppMessage.th = {
297
- hh: 4281545523,
298
- ih: 4294967295,
299
- sh: 4278219733,
300
- Dh: 4293914607,
301
- Mh: 4283782485,
302
- Eh: 3224580915,
303
- eh: 4288387995,
304
- }),
305
- (InAppMessage.Ie = {
306
- Ch: "hd",
307
- Le: "ias",
308
- dh: "of",
309
- Uh: "do",
310
- Xr: "umt",
311
- Qr: "tf",
312
- bh: "te",
313
- }),
314
- (InAppMessage.SlideFrom = { TOP: "TOP", BOTTOM: "BOTTOM" }),
315
- (InAppMessage.ClickAction = {
316
- NEWS_FEED: "NEWS_FEED",
317
- URI: "URI",
318
- NONE: "NONE",
319
- }),
320
- (InAppMessage.DismissType = {
321
- AUTO_DISMISS: "AUTO_DISMISS",
322
- MANUAL: "SWIPE",
323
- }),
324
- (InAppMessage.OpenTarget = { NONE: "NONE", BLANK: "BLANK" }),
325
- (InAppMessage.ImageStyle = { TOP: "TOP", GRAPHIC: "GRAPHIC" }),
326
- (InAppMessage.Orientation = { PORTRAIT: "PORTRAIT", LANDSCAPE: "LANDSCAPE" }),
327
- (InAppMessage.TextAlignment = {
328
- START: "START",
329
- CENTER: "CENTER",
330
- END: "END",
331
- }),
332
- (InAppMessage.CropType = {
333
- CENTER_CROP: "CENTER_CROP",
334
- FIT_CENTER: "FIT_CENTER",
335
- }),
336
- (InAppMessage.qe = {
337
- pn: "SLIDEUP",
338
- un: "MODAL",
339
- Se: "MODAL_STYLED",
340
- on: "FULL",
341
- ln: "WEB_HTML",
342
- Ee: "HTML",
343
- Ue: "HTML_FULL",
344
- }),
345
- (InAppMessage.Oh = 500),
346
- (InAppMessage.Ph = 200),
347
- (InAppMessage.ah = "ab-show"),
348
- (InAppMessage.Ih = "ab-hide"),
349
- (InAppMessage.lh = "ab-pause-scrolling"),
350
- (InAppMessage.hs = {
351
- ea: "m",
352
- ra: "ma",
353
- Sh: "sf",
354
- xs: "e",
355
- sa: "ti",
356
- ta: "ca",
357
- URI: "u",
358
- ia: "oa",
359
- oa: "dt",
360
- pa: "d",
361
- ma: "i",
362
- os: "iu",
363
- na: "is",
364
- ua: "ic",
365
- ca: "ibc",
366
- fa: "bc",
367
- da: "tc",
368
- la: "cbc",
369
- ga: "ai",
370
- ja: "ao",
371
- xa: "h",
372
- za: "ha",
373
- ha: "htc",
374
- va: "fc",
375
- wa: "b",
376
- ya: "ct",
377
- Sa: "o",
378
- ba: "hi",
379
- CSS: "css",
380
- ts: "type",
381
- vo: "messageFields",
382
- });
1
+ import e,{OPTIONS as L}from"../../managers/braze-instance.js";import V from"../../util/browser-detector.js";import{clickElement as Et,supportsPassive as Tt}from"../../util/dom-utils.js";import{KeyCodes as lt}from"../../util/key-codes.js";import E from"../../managers/subscription-manager.js";import{isIFrame as It}from"../utils/in-app-message-utils.js";export default class InAppMessage{constructor(t,s,i,h,e,n,T,o,r,l,u,a,I,c,O,A,L,_,m,N,R,S,D,M,C,d,U,b,P){this.message=t,this.messageAlignment=s,this.slideFrom=i,this.extras=h,this.triggerId=e,this.clickAction=n,this.uri=T,this.openTarget=o,this.dismissType=r,this.duration=l,this.icon=u,this.imageUrl=a,this.imageStyle=I,this.iconColor=c,this.iconBackgroundColor=O,this.backgroundColor=A,this.textColor=L,this.closeButtonColor=_,this.animateIn=m,this.animateOut=N,this.header=R,this.headerAlignment=S,this.headerTextColor=D,this.frameColor=M,this.buttons=C,this.cropType=d,this.orientation=U,this.htmlId=b,this.css=P,this.message=t,this.messageAlignment=s||InAppMessage.TextAlignment.CENTER,this.duration=l||5e3,this.slideFrom=i||InAppMessage.SlideFrom.BOTTOM,this.extras=h||{},this.triggerId=e,this.clickAction=n||InAppMessage.ClickAction.NONE,this.uri=T,this.openTarget=o||InAppMessage.OpenTarget.NONE,this.dismissType=r||InAppMessage.DismissType.AUTO_DISMISS,this.icon=u,this.imageUrl=a,this.imageStyle=I||InAppMessage.ImageStyle.TOP,this.iconColor=c||InAppMessage.th.ih,this.iconBackgroundColor=O||InAppMessage.th.sh,this.backgroundColor=A||InAppMessage.th.ih,this.textColor=L||InAppMessage.th.hh,this.closeButtonColor=_||InAppMessage.th.eh,this.animateIn=m,null==this.animateIn&&(this.animateIn=!0),this.animateOut=N,null==this.animateOut&&(this.animateOut=!0),this.header=R,this.headerAlignment=S||InAppMessage.TextAlignment.CENTER,this.headerTextColor=D||InAppMessage.th.hh,this.frameColor=M||InAppMessage.th.Eh,this.buttons=C||[],this.cropType=d||InAppMessage.CropType.FIT_CENTER,this.orientation=U,this.htmlId=b,this.css=P,this.isControl=!1,this.nh=!1,this.Th=!1,this.do=!1,this.oh=!1,this.Me=null,this.ke=null,this.ht=new E,this.rh=new E,this.Te=InAppMessage.TextAlignment.CENTER}subscribeToClickedEvent(t){return this.ht.lt(t)}subscribeToDismissedEvent(t){return this.rh.lt(t)}removeSubscription(t){this.ht.removeSubscription(t),this.rh.removeSubscription(t)}removeAllSubscriptions(){this.ht.removeAllSubscriptions(),this.rh.removeAllSubscriptions()}closeMessage(){this.ye(this.Me)}xe(){return!0}io(){return this.xe()}Ne(){return null!=this.htmlId&&this.htmlId.length>4}Ae(){return this.Ne()&&null!=this.css&&this.css.length>0}Ce(){if(this.Ne()&&this.Ae())return this.htmlId+"-css"}M(){return!this.Th&&(this.Th=!0,!0)}so(){return this.Th}p(t){return!this.do&&(this.do=!0,this.ht.Et(),!0)}F(){return!this.oh&&(this.oh=!0,this.rh.Et(),!0)}hide(t){if(t&&t.parentNode){let s=t.closest(".ab-iam-root");if(null==s&&(s=t),this.xe()&&null!=s.parentNode){const t=s.parentNode.classList;t&&t.contains(InAppMessage.lh)&&t.remove(InAppMessage.lh),document.body.removeEventListener("touchmove",InAppMessage.uh)}s.className=s.className.replace(InAppMessage.ah,InAppMessage.Ih)}return this.animateOut||!1}ye(t,s){if(null==t)return;let i;this.Me=null,i=-1===t.className.indexOf("ab-in-app-message")?t.getElementsByClassName("ab-in-app-message")[0]:t;let h=!1;i&&(h=this.hide(i));const e=document.body;let E;null!=e&&(E=e.scrollTop);const n=()=>{if(t&&t.parentNode){let s=t.closest(".ab-iam-root");null==s&&(s=t),s.parentNode&&s.parentNode.removeChild(s)}const i=this.Ce();if(null!=i){const t=document.getElementById(i);t&&t.parentNode&&t.parentNode.removeChild(t)}null!=e&&"Safari"===V.browser&&(e.scrollTop=E),s?s():this.F()};h?setTimeout(n,InAppMessage.Oh):n(),this.ke&&this.ke.focus()}Ge(){return document.createTextNode(this.message||"")}Be(t){let s="";this.message||this.header||!this.xe()||(s="Modal Image"),t.setAttribute("alt",s)}static uh(t){if(t.targetTouches&&t.targetTouches.length>1)return;const s=t.target;s&&s.classList&&s.classList.contains("ab-message-text")&&s.scrollHeight>s.clientHeight||document.querySelector(`.${InAppMessage.lh}`)&&t.preventDefault()}Ah(t){const s=t.parentNode;this.xe()&&null!=s&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=s.classList&&s.classList.add(InAppMessage.lh),document.body.addEventListener("touchmove",InAppMessage.uh,!!Tt()&&{passive:!1})),t.className+=" "+InAppMessage.ah}static Lh(t){if(t.keyCode===lt._h&&!e.nn(L.mh)&&document.querySelectorAll(".ab-modal-interactions").length>0){const t=document.getElementsByClassName("ab-html-message");let s=!1;for(const i of t){let t=null;It(i)&&i.contentWindow&&(t=i.contentWindow.document.getElementsByClassName("ab-programmatic-close-button")[0]),null!=t&&(Et(t),s=!0)}if(!s){const t=document.querySelectorAll(".ab-modal-interactions > .ab-close-button")[0];null!=t&&Et(t)}}}Nh(){this.nh||e.nn(L.mh)||(document.addEventListener("keydown",InAppMessage.Lh,!1),e.Rh((()=>{document.removeEventListener("keydown",InAppMessage.Lh)})),this.nh=!0)}ss(t){const s={};return t?(s[InAppMessage.hs.ea]=this.message,s[InAppMessage.hs.ra]=this.messageAlignment,s[InAppMessage.hs.Sh]=this.slideFrom,s[InAppMessage.hs.xs]=this.extras,s[InAppMessage.hs.sa]=this.triggerId,s[InAppMessage.hs.ta]=this.clickAction,s[InAppMessage.hs.URI]=this.uri,s[InAppMessage.hs.ia]=this.openTarget,s[InAppMessage.hs.oa]=this.dismissType,s[InAppMessage.hs.pa]=this.duration,s[InAppMessage.hs.ma]=this.icon,s[InAppMessage.hs.os]=this.imageUrl,s[InAppMessage.hs.na]=this.imageStyle,s[InAppMessage.hs.ua]=this.iconColor,s[InAppMessage.hs.ca]=this.iconBackgroundColor,s[InAppMessage.hs.fa]=this.backgroundColor,s[InAppMessage.hs.da]=this.textColor,s[InAppMessage.hs.la]=this.closeButtonColor,s[InAppMessage.hs.ga]=this.animateIn,s[InAppMessage.hs.ja]=this.animateOut,s[InAppMessage.hs.xa]=this.header,s[InAppMessage.hs.za]=this.headerAlignment,s[InAppMessage.hs.ha]=this.headerTextColor,s[InAppMessage.hs.va]=this.frameColor,s[InAppMessage.hs.wa]=this.buttons,s[InAppMessage.hs.ya]=this.cropType,s[InAppMessage.hs.Sa]=this.orientation,s[InAppMessage.hs.ba]=this.htmlId,s[InAppMessage.hs.CSS]=this.css,s[InAppMessage.hs.ts]=t,s):s}}InAppMessage.th={hh:4281545523,ih:4294967295,sh:4278219733,Dh:4293914607,Mh:4283782485,Eh:3224580915,eh:4288387995},InAppMessage.Ie={Ch:"hd",Le:"ias",dh:"of",Uh:"do",Xr:"umt",Qr:"tf",bh:"te"},InAppMessage.SlideFrom={TOP:"TOP",BOTTOM:"BOTTOM"},InAppMessage.ClickAction={NEWS_FEED:"NEWS_FEED",URI:"URI",NONE:"NONE"},InAppMessage.DismissType={AUTO_DISMISS:"AUTO_DISMISS",MANUAL:"SWIPE"},InAppMessage.OpenTarget={NONE:"NONE",BLANK:"BLANK"},InAppMessage.ImageStyle={TOP:"TOP",GRAPHIC:"GRAPHIC"},InAppMessage.Orientation={PORTRAIT:"PORTRAIT",LANDSCAPE:"LANDSCAPE"},InAppMessage.TextAlignment={START:"START",CENTER:"CENTER",END:"END"},InAppMessage.CropType={CENTER_CROP:"CENTER_CROP",FIT_CENTER:"FIT_CENTER"},InAppMessage.qe={pn:"SLIDEUP",un:"MODAL",Se:"MODAL_STYLED",on:"FULL",ln:"WEB_HTML",Ee:"HTML",Ue:"HTML_FULL"},InAppMessage.Oh=500,InAppMessage.Ph=200,InAppMessage.ah="ab-show",InAppMessage.Ih="ab-hide",InAppMessage.lh="ab-pause-scrolling",InAppMessage.hs={ea:"m",ra:"ma",Sh:"sf",xs:"e",sa:"ti",ta:"ca",URI:"u",ia:"oa",oa:"dt",pa:"d",ma:"i",os:"iu",na:"is",ua:"ic",ca:"ibc",fa:"bc",da:"tc",la:"cbc",ga:"ai",ja:"ao",xa:"h",za:"ha",ha:"htc",va:"fc",wa:"b",ya:"ct",Sa:"o",ba:"hi",CSS:"css",ts:"type",vo:"messageFields"};