@braze/web-sdk 4.10.1 → 4.10.2

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 (203) hide show
  1. package/index.d.ts +9 -9
  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 +34 -1
  6. package/shared-lib/guid.js +10 -1
  7. package/shared-lib/index.js +6 -0
  8. package/shared-lib/indexed-db-adapter.js +352 -1
  9. package/shared-lib/logger.js +38 -1
  10. package/shared-lib/supported-options.js +27 -1
  11. package/shared-lib/types.js +1 -1
  12. package/src/Card/card-manager-factory.js +14 -1
  13. package/src/Card/card-manager.js +78 -1
  14. package/src/Card/display/card-display.js +138 -1
  15. package/src/Card/index.js +6 -1
  16. package/src/Card/log-card-click.js +11 -1
  17. package/src/Card/log-card-dismissal.js +11 -1
  18. package/src/Card/log-card-impressions.js +13 -1
  19. package/src/Card/log-content-card-click.js +4 -1
  20. package/src/Card/log-content-card-impressions.js +4 -1
  21. package/src/Card/models/banner.js +31 -1
  22. package/src/Card/models/captioned-image.js +33 -1
  23. package/src/Card/models/card.js +196 -1
  24. package/src/Card/models/classic-card.js +32 -1
  25. package/src/Card/models/control-card.js +23 -1
  26. package/src/Card/models/image-only.js +32 -1
  27. package/src/Card/models/index.js +6 -1
  28. package/src/Card/types.js +1 -1
  29. package/src/Card/util/card-factory.js +104 -1
  30. package/src/ContentCards/content-cards-provider-factory.js +20 -1
  31. package/src/ContentCards/content-cards-provider.js +391 -1
  32. package/src/ContentCards/content-cards.js +24 -1
  33. package/src/ContentCards/get-cached-content-cards.js +5 -1
  34. package/src/ContentCards/index.js +8 -1
  35. package/src/ContentCards/log-content-cards-displayed.js +5 -1
  36. package/src/ContentCards/request-content-cards-refresh.js +5 -1
  37. package/src/ContentCards/subscribe-to-content-cards-updates.js +17 -1
  38. package/src/ContentCards/types.js +1 -1
  39. package/src/ContentCards/ui/hide-content-cards.js +8 -1
  40. package/src/ContentCards/ui/show-content-cards.js +77 -1
  41. package/src/ContentCards/ui/toggle-content-cards.js +8 -1
  42. package/src/Core/add-sdk-metadata.js +26 -1
  43. package/src/Core/braze-sdk-metadata.js +10 -1
  44. package/src/Core/change-user.js +17 -1
  45. package/src/Core/destroy.js +5 -1
  46. package/src/Core/device-properties.js +9 -1
  47. package/src/Core/disable-sdk.js +15 -1
  48. package/src/Core/enable-sdk.js +11 -1
  49. package/src/Core/get-device-id.js +13 -1
  50. package/src/Core/get-user.js +4 -1
  51. package/src/Core/handle-braze-action.js +87 -1
  52. package/src/Core/index.js +23 -1
  53. package/src/Core/initialize.js +4 -1
  54. package/src/Core/is-disabled.js +4 -1
  55. package/src/Core/log-custom-event.js +38 -1
  56. package/src/Core/log-purchase.js +245 -1
  57. package/src/Core/open-session.js +25 -1
  58. package/src/Core/remove-all-subscriptions.js +4 -1
  59. package/src/Core/remove-subscription.js +4 -1
  60. package/src/Core/request-immediate-data-flush.js +6 -1
  61. package/src/Core/set-logger.js +4 -1
  62. package/src/Core/set-sdk-authentication-signature.js +8 -1
  63. package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -1
  64. package/src/Core/toggle-logging.js +4 -1
  65. package/src/Core/types.js +1 -1
  66. package/src/Core/wipe-data.js +16 -1
  67. package/src/FeatureFlags/feature-flag-factory.js +24 -1
  68. package/src/FeatureFlags/feature-flag.js +64 -1
  69. package/src/FeatureFlags/feature-flags-provider-factory.js +19 -1
  70. package/src/FeatureFlags/feature-flags-provider.js +145 -1
  71. package/src/FeatureFlags/get-all-feature-flags.js +12 -1
  72. package/src/FeatureFlags/get-feature-flag.js +12 -1
  73. package/src/FeatureFlags/index.js +6 -1
  74. package/src/FeatureFlags/log-feature-flag-impression.js +23 -1
  75. package/src/FeatureFlags/refresh-feature-flags.js +9 -1
  76. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -1
  77. package/src/FeatureFlags/types.js +1 -1
  78. package/src/Feed/feed-provider-factory.js +18 -1
  79. package/src/Feed/feed-provider.js +90 -1
  80. package/src/Feed/feed.js +20 -1
  81. package/src/Feed/get-cached-feed.js +5 -1
  82. package/src/Feed/index.js +8 -1
  83. package/src/Feed/log-feed-displayed.js +7 -1
  84. package/src/Feed/request-feed-refresh.js +5 -1
  85. package/src/Feed/subscribe-to-feed-updates.js +5 -1
  86. package/src/Feed/types.js +1 -1
  87. package/src/Feed/ui/hide-feed.js +7 -1
  88. package/src/Feed/ui/show-feed.js +96 -1
  89. package/src/Feed/ui/toggle-feed.js +8 -1
  90. package/src/InAppMessage/defer-in-app-message.js +13 -1
  91. package/src/InAppMessage/display/get-animation-effect.js +19 -1
  92. package/src/InAppMessage/display/html-message-to-html.js +244 -1
  93. package/src/InAppMessage/display/in-app-message-to-html.js +188 -1
  94. package/src/InAppMessage/display/modal-utils.js +73 -1
  95. package/src/InAppMessage/get-deferred-in-app-message.js +5 -1
  96. package/src/InAppMessage/in-app-message-factory.js +166 -1
  97. package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
  98. package/src/InAppMessage/in-app-message-manager.js +248 -1
  99. package/src/InAppMessage/index.js +16 -1
  100. package/src/InAppMessage/log-in-app-message-button-click.js +27 -1
  101. package/src/InAppMessage/log-in-app-message-click.js +19 -1
  102. package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
  103. package/src/InAppMessage/log-in-app-message-impression.js +13 -1
  104. package/src/InAppMessage/models/control-message.js +11 -1
  105. package/src/InAppMessage/models/full-screen-message.js +105 -1
  106. package/src/InAppMessage/models/html-message.js +68 -1
  107. package/src/InAppMessage/models/in-app-message-button.js +47 -1
  108. package/src/InAppMessage/models/in-app-message.js +382 -1
  109. package/src/InAppMessage/models/modal-message.js +101 -1
  110. package/src/InAppMessage/models/slide-up-message.js +84 -1
  111. package/src/InAppMessage/models/templated-in-app-message.js +19 -1
  112. package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
  113. package/src/InAppMessage/types.js +1 -1
  114. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
  115. package/src/InAppMessage/ui/show-in-app-message.js +181 -1
  116. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  117. package/src/Push/index.js +5 -1
  118. package/src/Push/is-push-blocked.js +5 -1
  119. package/src/Push/is-push-permission-granted.js +5 -1
  120. package/src/Push/is-push-supported.js +5 -1
  121. package/src/Push/push-manager-factory.js +30 -1
  122. package/src/Push/push-manager.js +387 -1
  123. package/src/Push/request-push-permission.js +9 -1
  124. package/src/Push/types.js +1 -1
  125. package/src/Push/unregister-push.js +5 -1
  126. package/src/Push/utils/push-utils.js +36 -1
  127. package/src/User/index.js +1 -1
  128. package/src/User/types.js +1 -1
  129. package/src/User/user-manager.js +73 -1
  130. package/src/User/user.js +302 -1
  131. package/src/common/base-feed.js +28 -1
  132. package/src/common/base-provider.js +6 -1
  133. package/src/common/constants.js +14 -1
  134. package/src/common/event-logger.js +31 -1
  135. package/src/common/feed-display.js +210 -1
  136. package/src/common/translations.js +148 -1
  137. package/src/common/types.js +1 -1
  138. package/src/index.js +9 -1
  139. package/src/l10n/l10n-manager-factory.js +22 -1
  140. package/src/l10n/l10n-manager.js +25 -1
  141. package/src/l10n/types.js +1 -1
  142. package/src/managers/auth-manager.js +51 -1
  143. package/src/managers/braze-instance.js +331 -1
  144. package/src/managers/device-manager.js +85 -1
  145. package/src/managers/network-manager.js +256 -1
  146. package/src/managers/server-config-manager.js +108 -1
  147. package/src/managers/session-manager.js +75 -1
  148. package/src/managers/storage-manager-factory.js +42 -1
  149. package/src/managers/storage-manager.js +419 -1
  150. package/src/managers/subscription-manager.js +28 -1
  151. package/src/managers/types.js +1 -1
  152. package/src/models/backend-errors.js +8 -1
  153. package/src/models/braze-event.js +47 -1
  154. package/src/models/braze-sdk-metadata.js +10 -1
  155. package/src/models/device.js +18 -1
  156. package/src/models/identifier.js +19 -1
  157. package/src/models/push-token.js +27 -1
  158. package/src/models/request-result.js +8 -1
  159. package/src/models/server-config.js +48 -1
  160. package/src/models/types.js +1 -1
  161. package/src/request-controller.js +311 -1
  162. package/src/triggers/models/custom-event-data.js +14 -1
  163. package/src/triggers/models/custom-event-property-data.js +21 -1
  164. package/src/triggers/models/filter-set.js +55 -1
  165. package/src/triggers/models/filter.js +102 -1
  166. package/src/triggers/models/in-app-message-click-data.js +25 -1
  167. package/src/triggers/models/purchase-data.js +14 -1
  168. package/src/triggers/models/purchase-property-data.js +21 -1
  169. package/src/triggers/models/push-click-data.js +15 -1
  170. package/src/triggers/models/trigger-condition.js +105 -1
  171. package/src/triggers/models/trigger-events.js +8 -1
  172. package/src/triggers/models/trigger.js +122 -1
  173. package/src/triggers/triggers-provider-factory.js +34 -1
  174. package/src/triggers/triggers-provider.js +326 -1
  175. package/src/triggers/types.js +1 -1
  176. package/src/types.js +1 -1
  177. package/src/ui/js/attach-css.js +13 -1
  178. package/src/ui/js/feed-css.js +12 -1
  179. package/src/ui/js/iam-css.js +12 -1
  180. package/src/ui/js/index.js +3 -1
  181. package/src/ui/js/load-font-awesome.js +13 -1
  182. package/src/util/base-device-parser.js +14 -1
  183. package/src/util/braze-actions.js +84 -1
  184. package/src/util/browser-detector.js +84 -1
  185. package/src/util/client-hints-parser.js +66 -1
  186. package/src/util/code-utils.js +100 -1
  187. package/src/util/color-utils.js +29 -1
  188. package/src/util/component-utils.js +26 -1
  189. package/src/util/date-utils.js +28 -1
  190. package/src/util/deprecation-utils.js +5 -1
  191. package/src/util/device-constants.js +14 -1
  192. package/src/util/dom-utils.js +91 -1
  193. package/src/util/error-utils.js +2 -1
  194. package/src/util/key-codes.js +1 -1
  195. package/src/util/math.js +5 -1
  196. package/src/util/net.js +71 -1
  197. package/src/util/request-header-utils.js +46 -1
  198. package/src/util/string-utils.js +22 -1
  199. package/src/util/types.js +1 -1
  200. package/src/util/url-utils.js +20 -1
  201. package/src/util/user-agent-parser.js +85 -1
  202. package/src/util/validation-utils.js +217 -1
  203. package/src/util/window-utils.js +34 -1
package/src/User/user.js CHANGED
@@ -1 +1,302 @@
1
- import{isArray as p,isDate as yt,isObject as Nt,validateValueIsFromEnum as H}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{isValidEmail as Ct,validateCustomAttributeArrayType as St,validateCustomAttributeKey as At,validateCustomProperties as rt,validateCustomString as ot,validatePropertyType as Ut,validateStandardString as J}from"../util/validation-utils.js";import{SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft}from"../common/constants.js";import{toValidBackendTimeString as $t}from"../util/date-utils.js";export default class User{constructor(t,e){this.ft=t,this.ki=e,this.ft=t,this.ki=e}getUserId(t){const e=this.ft.getUserId();if("function"!=typeof t)return e;r.j.warn("The callback for getUserId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getUser().getUserId()`)"),t(e)}addAlias(t,e){return!J(t,"add alias","the alias",!1)||t.length<=0?(r.j.error("addAlias requires a non-empty alias"),!1):!J(e,"add alias","the label",!1)||e.length<=0?(r.j.error("addAlias requires a non-empty label"),!1):this.ki.$n(t,e).O}setFirstName(t){return!!J(t,"set first name","the firstName",!0)&&this.ft.nu("first_name",t)}setLastName(t){return!!J(t,"set last name","the lastName",!0)&&this.ft.nu("last_name",t)}setEmail(t){return null===t||Ct(t)?this.ft.nu("email",t):(r.j.error(`Cannot set email address - "${t}" did not pass RFC-5322 validation.`),!1)}setGender(t){return"string"==typeof t&&(t=t.toLowerCase()),!(null!==t&&!H(User.Genders,t,`Gender "${t}" is not a valid gender.`,"User.Genders"))&&this.ft.nu("gender",t)}setDateOfBirth(t,e,s){return null===t&&null===e&&null===s?this.ft.nu("dob",null):(t=null!=t?parseInt(t.toString()):null,e=null!=e?parseInt(e.toString()):null,s=null!=s?parseInt(s.toString()):null,null==t||null==e||null==s||isNaN(t)||isNaN(e)||isNaN(s)||e>12||e<1||s>31||s<1?(r.j.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):this.ft.nu("dob",`${t}-${e}-${s}`))}setCountry(t){return!!J(t,"set country","the country",!0)&&this.ft.nu("country",t)}setHomeCity(t){return!!J(t,"set home city","the homeCity",!0)&&this.ft.nu("home_city",t)}setLanguage(t){return!!J(t,"set language","the language",!0)&&this.ft.nu("language",t)}setEmailNotificationSubscriptionType(t){return!!H(User.NotificationSubscriptionTypes,t,`Email notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.ft.nu("email_subscribe",t)}setPushNotificationSubscriptionType(t){return!!H(User.NotificationSubscriptionTypes,t,`Push notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.ft.nu("push_subscribe",t)}setPhoneNumber(t){return!!J(t,"set phone number","the phoneNumber",!0)&&(null===t||t.match(User.Ln)?this.ft.nu("phone",t):(r.j.error(`Cannot set phone number - "${t}" did not pass validation.`),!1))}setLastKnownLocation(t,e,s,i,n){return null==t||null==e?(r.j.error("Cannot set last-known location - latitude and longitude are required."),!1):(t=parseFloat(t.toString()),e=parseFloat(e.toString()),null!=s&&(s=parseFloat(s.toString())),null!=i&&(i=parseFloat(i.toString())),null!=n&&(n=parseFloat(n.toString())),isNaN(t)||isNaN(e)||null!=s&&isNaN(s)||null!=i&&isNaN(i)||null!=n&&isNaN(n)?(r.j.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):t>90||t<-90||e>180||e<-180?(r.j.error("Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."),!1):null!=s&&s<0||null!=n&&n<0?(r.j.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.ki.setLastKnownLocation(this.ft.getUserId(),t,e,i,s,n).O)}setCustomUserAttribute(t,e,s){if(!At(t))return!1;const i=e=>{const[r]=rt(e,Ft,"attribute value",`set custom user attribute "${t}"`,"custom user attribute");return r};if(p(e)){const[s,n]=St(t,e);if(!s&&!n&&0!==e.length)return!1;if(s||0===e.length)return this.ki.Gn(r.q.Hn,t,e).O;for(const t of e)if(!i(t))return!1}else if(Nt(e)){if(!i(e))return!1;if(s)return this.ki.Gn(r.q.Kn,t,e).O}else{if(!(void 0!==e&&Ut(e)))return!1;if(yt(e)&&(e=$t(e)),"string"==typeof e&&!ot(e,`set custom user attribute "${t}"`,"the element in the given array"))return!1}return this.ft.setCustomUserAttribute(t,e)}addToCustomAttributeArray(t,e){return!!ot(t,"add to custom user attribute array","the given key")&&(!(null!=e&&!ot(e,"add to custom user attribute array","the given value"))&&this.ki.Gn(r.q.Jn,t,e).O)}removeFromCustomAttributeArray(t,e){return!!ot(t,"remove from custom user attribute array","the given key")&&(!(null!=e&&!ot(e,"remove from custom user attribute array","the given value"))&&this.ki.Gn(r.q.Qn,t,e).O)}incrementCustomUserAttribute(t,e){if(!ot(t,"increment custom user attribute","the given key"))return!1;null==e&&(e=1);const s=parseInt(e.toString());return isNaN(s)||s!==parseFloat(e.toString())?(r.j.error(`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`),!1):this.ki.Gn(r.q.Xn,t,s).O}setCustomLocationAttribute(t,e,s){return!!ot(t,"set custom location attribute","the given key")&&((null!==e||null!==s)&&(e=null!=e?parseFloat(e.toString()):null,s=null!=s?parseFloat(s.toString()):null,null==e&&null!=s||null!=e&&null==s||null!=e&&(isNaN(e)||e>90||e<-90)||null!=s&&(isNaN(s)||s>180||s<-180))?(r.j.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal."),!1):this.ki.Zn(t,e,s).O)}addToSubscriptionGroup(t){return!J(t,"add user to subscription group","subscription group ID",!1)||t.length<=0?(r.j.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):this.ki.au(t,User.du.SUBSCRIBED).O}removeFromSubscriptionGroup(t){return!J(t,"remove user from subscription group","subscription group ID",!1)||t.length<=0?(r.j.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):this.ki.au(t,User.du.UNSUBSCRIBED).O}_n(t,e,r,s,i){this.ft._n(t,e,r,s,i),this.ki.pu()}Nn(t){this.ft.Nn(t)}}User.Genders={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},User.NotificationSubscriptionTypes={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.Ln=/^[0-9 .\\(\\)\\+\\-]+$/,User.du={SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.bu="user_id",User.lu="custom",User.lr=997;
1
+ import {
2
+ isArray as p,
3
+ isDate as yt,
4
+ isObject as Nt,
5
+ validateValueIsFromEnum as H,
6
+ } from "../util/code-utils.js";
7
+ import r from "../../shared-lib/braze-shared-lib.js";
8
+ import {
9
+ isValidEmail as Ct,
10
+ validateCustomAttributeArrayType as St,
11
+ validateCustomAttributeKey as At,
12
+ validateCustomProperties as rt,
13
+ validateCustomString as ot,
14
+ validatePropertyType as Ut,
15
+ validateStandardString as J,
16
+ } from "../util/validation-utils.js";
17
+ import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
18
+ import { toValidBackendTimeString as $t } from "../util/date-utils.js";
19
+ export default class User {
20
+ constructor(t, e) {
21
+ (this.ft = t), (this.ki = e), (this.ft = t), (this.ki = e);
22
+ }
23
+ getUserId(t) {
24
+ const e = this.ft.getUserId();
25
+ if ("function" != typeof t) return e;
26
+ r.j.warn(
27
+ "The callback for getUserId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getUser().getUserId()`)",
28
+ ),
29
+ t(e);
30
+ }
31
+ addAlias(t, e) {
32
+ return !J(t, "add alias", "the alias", !1) || t.length <= 0
33
+ ? (r.j.error("addAlias requires a non-empty alias"), !1)
34
+ : !J(e, "add alias", "the label", !1) || e.length <= 0
35
+ ? (r.j.error("addAlias requires a non-empty label"), !1)
36
+ : this.ki.$n(t, e).O;
37
+ }
38
+ setFirstName(t) {
39
+ return (
40
+ !!J(t, "set first name", "the firstName", !0) &&
41
+ this.ft.nu("first_name", t)
42
+ );
43
+ }
44
+ setLastName(t) {
45
+ return (
46
+ !!J(t, "set last name", "the lastName", !0) && this.ft.nu("last_name", t)
47
+ );
48
+ }
49
+ setEmail(t) {
50
+ return null === t || Ct(t)
51
+ ? this.ft.nu("email", t)
52
+ : (r.j.error(
53
+ `Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
54
+ ),
55
+ !1);
56
+ }
57
+ setGender(t) {
58
+ return (
59
+ "string" == typeof t && (t = t.toLowerCase()),
60
+ !(
61
+ null !== t &&
62
+ !H(
63
+ User.Genders,
64
+ t,
65
+ `Gender "${t}" is not a valid gender.`,
66
+ "User.Genders",
67
+ )
68
+ ) && this.ft.nu("gender", t)
69
+ );
70
+ }
71
+ setDateOfBirth(t, e, s) {
72
+ return null === t && null === e && null === s
73
+ ? this.ft.nu("dob", null)
74
+ : ((t = null != t ? parseInt(t.toString()) : null),
75
+ (e = null != e ? parseInt(e.toString()) : null),
76
+ (s = null != s ? parseInt(s.toString()) : null),
77
+ null == t ||
78
+ null == e ||
79
+ null == s ||
80
+ isNaN(t) ||
81
+ isNaN(e) ||
82
+ isNaN(s) ||
83
+ e > 12 ||
84
+ e < 1 ||
85
+ s > 31 ||
86
+ s < 1
87
+ ? (r.j.error(
88
+ "Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);",
89
+ ),
90
+ !1)
91
+ : this.ft.nu("dob", `${t}-${e}-${s}`));
92
+ }
93
+ setCountry(t) {
94
+ return !!J(t, "set country", "the country", !0) && this.ft.nu("country", t);
95
+ }
96
+ setHomeCity(t) {
97
+ return (
98
+ !!J(t, "set home city", "the homeCity", !0) && this.ft.nu("home_city", t)
99
+ );
100
+ }
101
+ setLanguage(t) {
102
+ return (
103
+ !!J(t, "set language", "the language", !0) && this.ft.nu("language", t)
104
+ );
105
+ }
106
+ setEmailNotificationSubscriptionType(t) {
107
+ return (
108
+ !!H(
109
+ User.NotificationSubscriptionTypes,
110
+ t,
111
+ `Email notification setting "${t}" is not a valid subscription type.`,
112
+ "User.NotificationSubscriptionTypes",
113
+ ) && this.ft.nu("email_subscribe", t)
114
+ );
115
+ }
116
+ setPushNotificationSubscriptionType(t) {
117
+ return (
118
+ !!H(
119
+ User.NotificationSubscriptionTypes,
120
+ t,
121
+ `Push notification setting "${t}" is not a valid subscription type.`,
122
+ "User.NotificationSubscriptionTypes",
123
+ ) && this.ft.nu("push_subscribe", t)
124
+ );
125
+ }
126
+ setPhoneNumber(t) {
127
+ return (
128
+ !!J(t, "set phone number", "the phoneNumber", !0) &&
129
+ (null === t || t.match(User.Ln)
130
+ ? this.ft.nu("phone", t)
131
+ : (r.j.error(
132
+ `Cannot set phone number - "${t}" did not pass validation.`,
133
+ ),
134
+ !1))
135
+ );
136
+ }
137
+ setLastKnownLocation(t, e, s, i, n) {
138
+ return null == t || null == e
139
+ ? (r.j.error(
140
+ "Cannot set last-known location - latitude and longitude are required.",
141
+ ),
142
+ !1)
143
+ : ((t = parseFloat(t.toString())),
144
+ (e = parseFloat(e.toString())),
145
+ null != s && (s = parseFloat(s.toString())),
146
+ null != i && (i = parseFloat(i.toString())),
147
+ null != n && (n = parseFloat(n.toString())),
148
+ isNaN(t) ||
149
+ isNaN(e) ||
150
+ (null != s && isNaN(s)) ||
151
+ (null != i && isNaN(i)) ||
152
+ (null != n && isNaN(n))
153
+ ? (r.j.error(
154
+ "Cannot set last-known location - all supplied parameters must be numeric.",
155
+ ),
156
+ !1)
157
+ : t > 90 || t < -90 || e > 180 || e < -180
158
+ ? (r.j.error(
159
+ "Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively.",
160
+ ),
161
+ !1)
162
+ : (null != s && s < 0) || (null != n && n < 0)
163
+ ? (r.j.error(
164
+ "Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
165
+ ),
166
+ !1)
167
+ : this.ki.setLastKnownLocation(this.ft.getUserId(), t, e, i, s, n).O);
168
+ }
169
+ setCustomUserAttribute(t, e, s) {
170
+ if (!At(t)) return !1;
171
+ const i = (e) => {
172
+ const [r] = rt(
173
+ e,
174
+ Ft,
175
+ "attribute value",
176
+ `set custom user attribute "${t}"`,
177
+ "custom user attribute",
178
+ );
179
+ return r;
180
+ };
181
+ if (p(e)) {
182
+ const [s, n] = St(t, e);
183
+ if (!s && !n && 0 !== e.length) return !1;
184
+ if (s || 0 === e.length) return this.ki.Gn(r.q.Hn, t, e).O;
185
+ for (const t of e) if (!i(t)) return !1;
186
+ } else if (Nt(e)) {
187
+ if (!i(e)) return !1;
188
+ if (s) return this.ki.Gn(r.q.Kn, t, e).O;
189
+ } else {
190
+ if (!(void 0 !== e && Ut(e))) return !1;
191
+ if (
192
+ (yt(e) && (e = $t(e)),
193
+ "string" == typeof e &&
194
+ !ot(
195
+ e,
196
+ `set custom user attribute "${t}"`,
197
+ "the element in the given array",
198
+ ))
199
+ )
200
+ return !1;
201
+ }
202
+ return this.ft.setCustomUserAttribute(t, e);
203
+ }
204
+ addToCustomAttributeArray(t, e) {
205
+ return (
206
+ !!ot(t, "add to custom user attribute array", "the given key") &&
207
+ !(
208
+ null != e &&
209
+ !ot(e, "add to custom user attribute array", "the given value")
210
+ ) &&
211
+ this.ki.Gn(r.q.Jn, t, e).O
212
+ );
213
+ }
214
+ removeFromCustomAttributeArray(t, e) {
215
+ return (
216
+ !!ot(t, "remove from custom user attribute array", "the given key") &&
217
+ !(
218
+ null != e &&
219
+ !ot(e, "remove from custom user attribute array", "the given value")
220
+ ) &&
221
+ this.ki.Gn(r.q.Qn, t, e).O
222
+ );
223
+ }
224
+ incrementCustomUserAttribute(t, e) {
225
+ if (!ot(t, "increment custom user attribute", "the given key")) return !1;
226
+ null == e && (e = 1);
227
+ const s = parseInt(e.toString());
228
+ return isNaN(s) || s !== parseFloat(e.toString())
229
+ ? (r.j.error(
230
+ `Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
231
+ ),
232
+ !1)
233
+ : this.ki.Gn(r.q.Xn, t, s).O;
234
+ }
235
+ setCustomLocationAttribute(t, e, s) {
236
+ return (
237
+ !!ot(t, "set custom location attribute", "the given key") &&
238
+ ((null !== e || null !== s) &&
239
+ ((e = null != e ? parseFloat(e.toString()) : null),
240
+ (s = null != s ? parseFloat(s.toString()) : null),
241
+ (null == e && null != s) ||
242
+ (null != e && null == s) ||
243
+ (null != e && (isNaN(e) || e > 90 || e < -90)) ||
244
+ (null != s && (isNaN(s) || s > 180 || s < -180)))
245
+ ? (r.j.error(
246
+ "Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal.",
247
+ ),
248
+ !1)
249
+ : this.ki.Zn(t, e, s).O)
250
+ );
251
+ }
252
+ addToSubscriptionGroup(t) {
253
+ return !J(
254
+ t,
255
+ "add user to subscription group",
256
+ "subscription group ID",
257
+ !1,
258
+ ) || t.length <= 0
259
+ ? (r.j.error(
260
+ "addToSubscriptionGroup requires a non-empty subscription group ID",
261
+ ),
262
+ !1)
263
+ : this.ki.au(t, User.du.SUBSCRIBED).O;
264
+ }
265
+ removeFromSubscriptionGroup(t) {
266
+ return !J(
267
+ t,
268
+ "remove user from subscription group",
269
+ "subscription group ID",
270
+ !1,
271
+ ) || t.length <= 0
272
+ ? (r.j.error(
273
+ "removeFromSubscriptionGroup requires a non-empty subscription group ID",
274
+ ),
275
+ !1)
276
+ : this.ki.au(t, User.du.UNSUBSCRIBED).O;
277
+ }
278
+ _n(t, e, r, s, i) {
279
+ this.ft._n(t, e, r, s, i), this.ki.pu();
280
+ }
281
+ Nn(t) {
282
+ this.ft.Nn(t);
283
+ }
284
+ }
285
+ (User.Genders = {
286
+ MALE: "m",
287
+ FEMALE: "f",
288
+ OTHER: "o",
289
+ UNKNOWN: "u",
290
+ NOT_APPLICABLE: "n",
291
+ PREFER_NOT_TO_SAY: "p",
292
+ }),
293
+ (User.NotificationSubscriptionTypes = {
294
+ OPTED_IN: "opted_in",
295
+ SUBSCRIBED: "subscribed",
296
+ UNSUBSCRIBED: "unsubscribed",
297
+ }),
298
+ (User.Ln = /^[0-9 .\\(\\)\\+\\-]+$/),
299
+ (User.du = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
300
+ (User.bu = "user_id"),
301
+ (User.lu = "custom"),
302
+ (User.lr = 997);
@@ -1 +1,28 @@
1
- import{ControlCard}from"../Card/index.js";export const FEED_ANIMATION_DURATION=500;export default class x{constructor(e,s){this.cards=e,this.lastUpdated=s,this.cards=e,this.lastUpdated=s}getUnreadCardCount(){let e=0;for(const s of this.cards)s.viewed||s instanceof ControlCard||e++;return e}ur(){throw new Error("Must be implemented in a subclass")}logCardImpressions(e){throw new Error("Must be implemented in a subclass")}logCardClick(e){throw new Error("Must be implemented in a subclass")}sr(){throw new Error("Must be implemented in a subclass")}}x.mr=6e4,x.Oh=500,x.uo=1e4;
1
+ import { ControlCard } from "../Card/index.js";
2
+ export const FEED_ANIMATION_DURATION = 500;
3
+ export default class x {
4
+ constructor(e, s) {
5
+ (this.cards = e),
6
+ (this.lastUpdated = s),
7
+ (this.cards = e),
8
+ (this.lastUpdated = s);
9
+ }
10
+ getUnreadCardCount() {
11
+ let e = 0;
12
+ for (const s of this.cards) s.viewed || s instanceof ControlCard || e++;
13
+ return e;
14
+ }
15
+ ur() {
16
+ throw new Error("Must be implemented in a subclass");
17
+ }
18
+ logCardImpressions(e) {
19
+ throw new Error("Must be implemented in a subclass");
20
+ }
21
+ logCardClick(e) {
22
+ throw new Error("Must be implemented in a subclass");
23
+ }
24
+ sr() {
25
+ throw new Error("Must be implemented in a subclass");
26
+ }
27
+ }
28
+ (x.mr = 6e4), (x.Oh = 500), (x.uo = 1e4);
@@ -1 +1,6 @@
1
- export default class y{constructor(){}Ts(a){}changeUser(a=!1){}clearData(a=!1){}}
1
+ export default class y {
2
+ constructor() {}
3
+ Ts(a) {}
4
+ changeUser(a = !1) {}
5
+ clearData(a = !1) {}
6
+ }
@@ -1 +1,14 @@
1
- export const MAX_PURCHASE_QUANTITY=100;export const MUST_BE_IN_APP_MESSAGE_WARNING="inAppMessage must be an InAppMessage object";export const MUST_BE_CARD_WARNING_SUFFIX="must be a Card object";export const FEED_ANIMATION_DURATION=500;export const LOG_CUSTOM_EVENT_STRING="logCustomEvent";export const SET_CUSTOM_USER_ATTRIBUTE_STRING="setCustomUserAttribute";export const BRAZE_MUST_BE_INITIALIZED_ERROR="Braze must be initialized before calling methods.";export const CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT=5;export const CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT=90;export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT=72e5;export const MAX_ERROR_RETRIES_CONTENT_CARDS=3;export const REQUEST_ATTEMPT_DEFAULT=1;
1
+ export const MAX_PURCHASE_QUANTITY = 100;
2
+ export const MUST_BE_IN_APP_MESSAGE_WARNING =
3
+ "inAppMessage must be an InAppMessage object";
4
+ export const MUST_BE_CARD_WARNING_SUFFIX = "must be a Card object";
5
+ export const FEED_ANIMATION_DURATION = 500;
6
+ export const LOG_CUSTOM_EVENT_STRING = "logCustomEvent";
7
+ export const SET_CUSTOM_USER_ATTRIBUTE_STRING = "setCustomUserAttribute";
8
+ export const BRAZE_MUST_BE_INITIALIZED_ERROR =
9
+ "Braze must be initialized before calling methods.";
10
+ export const CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT = 5;
11
+ export const CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT = 90;
12
+ export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT = 72e5;
13
+ export const MAX_ERROR_RETRIES_CONTENT_CARDS = 3;
14
+ export const REQUEST_ATTEMPT_DEFAULT = 1;
@@ -1 +1,31 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";import e from"../managers/braze-instance.js";import be from"../models/braze-event.js";import t from"../models/request-result.js";const s={N:(o,n,s)=>{var i;const a=new t,l=e.aa();if(!l)return r.j.info(`Not logging event with type "${o}" because the current session ID could not be found.`),a;const m=l.co();a.ve.push(new be(s||(null===(i=e.ir())||void 0===i?void 0:i.getUserId()),o,(new Date).valueOf(),m,n));const u=e.l();return u&&(a.O=u.bo(a.ve)),a}};export default s;
1
+ import r from "../../shared-lib/braze-shared-lib.js";
2
+ import e from "../managers/braze-instance.js";
3
+ import be from "../models/braze-event.js";
4
+ import t from "../models/request-result.js";
5
+ const s = {
6
+ N: (o, n, s) => {
7
+ var i;
8
+ const a = new t(),
9
+ l = e.aa();
10
+ if (!l)
11
+ return (
12
+ r.j.info(
13
+ `Not logging event with type "${o}" because the current session ID could not be found.`,
14
+ ),
15
+ a
16
+ );
17
+ const m = l.co();
18
+ a.ve.push(
19
+ new be(
20
+ s || (null === (i = e.ir()) || void 0 === i ? void 0 : i.getUserId()),
21
+ o,
22
+ new Date().valueOf(),
23
+ m,
24
+ n,
25
+ ),
26
+ );
27
+ const u = e.l();
28
+ return u && (a.O = u.bo(a.ve)), a;
29
+ },
30
+ };
31
+ export default s;
@@ -1 +1,210 @@
1
- import x from"./base-feed.js";import{bottomHadImpression as ye,getCardId as Fe,impressOnBottom as Te,impressOnTop as xe,markCardAsRead as Ee,topHadImpression as he}from"../Card/display/card-display.js";import{bottomIsInView as Se,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as je}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as lt}from"../util/key-codes.js";import Ce from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as X}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as vt,ineligibleBrazeActionURLErrorMessage as dt,getDecodedBrazeAction as Q,containsUnknownBrazeAction as ft}from"../util/braze-actions.js";export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE="data-last-requested-refresh";export const SUBSCRIPTION_ID_DATA_ATTRIBUTE="data-update-subscription-id";export const SCROLL_LISTENER_ID="data-listener-id";export const scrollListeners={};export function destroyFeedHtml(e){e&&(e.className=e.className.replace("ab-show","ab-hide"),setTimeout((()=>{e&&e.parentNode&&e.parentNode.removeChild(e)}),x.Oh));const t=e.getAttribute("data-update-subscription-id");null!=t&&removeSubscription(t);const o=e.getAttribute("data-listener-id");null!=o&&(window.removeEventListener("scroll",scrollListeners[o]),delete scrollListeners[o])}export function generateFeedBody(e,t){const o=document.createElement("div");if(o.className="ab-feed-body",o.setAttribute("aria-label","Feed"),o.setAttribute("role","feed"),null==e.lastUpdated){const e=document.createElement("div");e.className="ab-no-cards-message";const t=document.createElement("i");t.className="fa fa-spinner fa-spin fa-4x ab-initial-spinner",e.appendChild(t),o.appendChild(e)}else{let s=!1;const logCardClick=t=>e.logCardClick(t);for(const n of e.cards){const i=n instanceof ControlCard;!i||e.ur()?(o.appendChild(je(n,logCardClick,t)),s=s||!i):r.j.error("Received a control card for a legacy news feed. Control cards are only supported with content cards.")}if(!s){const e=document.createElement("div");e.className="ab-no-cards-message",e.innerHTML=Ce.m().get("NO_CARDS_MESSAGE")||"",e.setAttribute("role","article"),o.appendChild(e)}}return o}export function detectFeedImpressions(e,t){if(null!=e&&null!=t){const o=[],s=t.querySelectorAll(".ab-card");e.yo||(e.yo={});for(let t=0;t<s.length;t++){const n=Fe(s[t]),r=_e(s[t]),i=Se(s[t]);if(e.yo[n]){r||i||Ee(s[t]);continue}let a=he(s[t]),d=ye(s[t]);const l=a,c=d;if(!a&&r&&(a=!0,xe(s[t])),!d&&i&&(d=!0,Te(s[t])),a&&d){if(l&&c)continue;for(const t of e.cards)if(t.id===n){e.yo[t.id]=!0,o.push(t);break}}}o.length>0&&e.logCardImpressions(o)}}export function refreshFeed(e,t){if(null==e||null==t)return;t.setAttribute("aria-busy","true");const o=t.querySelectorAll(".ab-refresh-button")[0];null!=o&&(o.className+=" fa-spin");const s=(new Date).valueOf().toString();t.setAttribute("data-last-requested-refresh",s),setTimeout((()=>{if(t.getAttribute("data-last-requested-refresh")===s){const e=t.querySelectorAll(".fa-spin");for(let t=0;t<e.length;t++)e[t].className=e[t].className.replace(/fa-spin/g,"");const o=t.querySelectorAll(".ab-initial-spinner")[0];if(null!=o){const e=document.createElement("span");e.innerHTML=Ce.m().get("FEED_TIMEOUT_MESSAGE")||"",null!=o.parentNode&&(o.parentNode.appendChild(e),o.parentNode.removeChild(o))}"true"===t.getAttribute("aria-busy")&&t.setAttribute("aria-busy","false")}}),x.uo),e.sr()}export function feedToHtml(e,t,o){const s=document.createElement("div");s.className="ab-feed ab-hide ab-effect-slide",s.setAttribute("role","dialog"),s.setAttribute("aria-label","Feed"),s.setAttribute("tabindex","-1");const n=document.createElement("div");n.className="ab-feed-buttons-wrapper",n.setAttribute("role","group"),s.appendChild(n);const i=document.createElement("i");i.className="fa fa-times ab-close-button",i.setAttribute("aria-label","Close Feed"),i.setAttribute("tabindex","0"),i.setAttribute("role","button");const a=e=>{destroyFeedHtml(s),e.stopPropagation()};i.addEventListener("keydown",(e=>{e.keyCode!==lt.Fo&&e.keyCode!==lt.To||a(e)})),i.onclick=a;const d=document.createElement("i");d.className="fa fa-refresh ab-refresh-button",e&&null==e.lastUpdated&&(d.className+=" fa-spin"),d.setAttribute("aria-label","Refresh Feed"),d.setAttribute("tabindex","0"),d.setAttribute("role","button");const l=t=>{refreshFeed(e,s),t.stopPropagation()};d.addEventListener("keydown",(e=>{e.keyCode!==lt.Fo&&e.keyCode!==lt.To||l(e)})),d.onclick=l,n.appendChild(d),n.appendChild(i),s.appendChild(generateFeedBody(e,t));const c=()=>detectFeedImpressions(e,s);if(s.addEventListener("scroll",c),!o){window.addEventListener("scroll",c);const e=r.Z.Y();scrollListeners[e]=c,s.setAttribute("data-listener-id",e)}return s}export function updateFeedCards(e,t,o,s,n){if(!p(t))return;const i=[];for(const e of t)if(e instanceof Card){if(e.url&&X.test(e.url)){const t=Q(e.url);if(ft(t)){r.j.error(dt(vt._r,"Content Card"));continue}}i.push(e)}if(e.cards=i,e.lastUpdated=o,null!=s)if(s.setAttribute("aria-busy","false"),null==e.lastUpdated)destroyFeedHtml(s);else{const t=s.querySelectorAll(".ab-feed-body")[0];if(null!=t){const o=generateFeedBody(e,n);t.parentNode&&t.parentNode.replaceChild(o,t),detectFeedImpressions(e,o.parentNode)}}}export function registerFeedSubscriptionId(e,t){e&&t.setAttribute("data-update-subscription-id",e)}
1
+ import x from "./base-feed.js";
2
+ import {
3
+ bottomHadImpression as ye,
4
+ getCardId as Fe,
5
+ impressOnBottom as Te,
6
+ impressOnTop as xe,
7
+ markCardAsRead as Ee,
8
+ topHadImpression as he,
9
+ } from "../Card/display/card-display.js";
10
+ import { bottomIsInView as Se, topIsInView as _e } from "../util/dom-utils.js";
11
+ import { Card, ControlCard } from "../Card/index.js";
12
+ import { cardToHtml as je } from "../Card/display/card-display.js";
13
+ import { isArray as p } from "../util/code-utils.js";
14
+ import { KeyCodes as lt } from "../util/key-codes.js";
15
+ import Ce from "../l10n/l10n-manager-factory.js";
16
+ import { removeSubscription } from "../Core/remove-subscription.js";
17
+ import r from "../../shared-lib/braze-shared-lib.js";
18
+ import { BRAZE_ACTION_URI_REGEX as X } from "../util/validation-utils.js";
19
+ import {
20
+ INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as vt,
21
+ ineligibleBrazeActionURLErrorMessage as dt,
22
+ getDecodedBrazeAction as Q,
23
+ containsUnknownBrazeAction as ft,
24
+ } from "../util/braze-actions.js";
25
+ export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE =
26
+ "data-last-requested-refresh";
27
+ export const SUBSCRIPTION_ID_DATA_ATTRIBUTE = "data-update-subscription-id";
28
+ export const SCROLL_LISTENER_ID = "data-listener-id";
29
+ export const scrollListeners = {};
30
+ export function destroyFeedHtml(e) {
31
+ e &&
32
+ ((e.className = e.className.replace("ab-show", "ab-hide")),
33
+ setTimeout(() => {
34
+ e && e.parentNode && e.parentNode.removeChild(e);
35
+ }, x.Oh));
36
+ const t = e.getAttribute("data-update-subscription-id");
37
+ null != t && removeSubscription(t);
38
+ const o = e.getAttribute("data-listener-id");
39
+ null != o &&
40
+ (window.removeEventListener("scroll", scrollListeners[o]),
41
+ delete scrollListeners[o]);
42
+ }
43
+ export function generateFeedBody(e, t) {
44
+ const o = document.createElement("div");
45
+ if (
46
+ ((o.className = "ab-feed-body"),
47
+ o.setAttribute("aria-label", "Feed"),
48
+ o.setAttribute("role", "feed"),
49
+ null == e.lastUpdated)
50
+ ) {
51
+ const e = document.createElement("div");
52
+ e.className = "ab-no-cards-message";
53
+ const t = document.createElement("i");
54
+ (t.className = "fa fa-spinner fa-spin fa-4x ab-initial-spinner"),
55
+ e.appendChild(t),
56
+ o.appendChild(e);
57
+ } else {
58
+ let s = !1;
59
+ const logCardClick = (t) => e.logCardClick(t);
60
+ for (const n of e.cards) {
61
+ const i = n instanceof ControlCard;
62
+ !i || e.ur()
63
+ ? (o.appendChild(je(n, logCardClick, t)), (s = s || !i))
64
+ : r.j.error(
65
+ "Received a control card for a legacy news feed. Control cards are only supported with content cards.",
66
+ );
67
+ }
68
+ if (!s) {
69
+ const e = document.createElement("div");
70
+ (e.className = "ab-no-cards-message"),
71
+ (e.innerHTML = Ce.m().get("NO_CARDS_MESSAGE") || ""),
72
+ e.setAttribute("role", "article"),
73
+ o.appendChild(e);
74
+ }
75
+ }
76
+ return o;
77
+ }
78
+ export function detectFeedImpressions(e, t) {
79
+ if (null != e && null != t) {
80
+ const o = [],
81
+ s = t.querySelectorAll(".ab-card");
82
+ e.yo || (e.yo = {});
83
+ for (let t = 0; t < s.length; t++) {
84
+ const n = Fe(s[t]),
85
+ r = _e(s[t]),
86
+ i = Se(s[t]);
87
+ if (e.yo[n]) {
88
+ r || i || Ee(s[t]);
89
+ continue;
90
+ }
91
+ let a = he(s[t]),
92
+ d = ye(s[t]);
93
+ const l = a,
94
+ c = d;
95
+ if (
96
+ (!a && r && ((a = !0), xe(s[t])),
97
+ !d && i && ((d = !0), Te(s[t])),
98
+ a && d)
99
+ ) {
100
+ if (l && c) continue;
101
+ for (const t of e.cards)
102
+ if (t.id === n) {
103
+ (e.yo[t.id] = !0), o.push(t);
104
+ break;
105
+ }
106
+ }
107
+ }
108
+ o.length > 0 && e.logCardImpressions(o);
109
+ }
110
+ }
111
+ export function refreshFeed(e, t) {
112
+ if (null == e || null == t) return;
113
+ t.setAttribute("aria-busy", "true");
114
+ const o = t.querySelectorAll(".ab-refresh-button")[0];
115
+ null != o && (o.className += " fa-spin");
116
+ const s = new Date().valueOf().toString();
117
+ t.setAttribute("data-last-requested-refresh", s),
118
+ setTimeout(() => {
119
+ if (t.getAttribute("data-last-requested-refresh") === s) {
120
+ const e = t.querySelectorAll(".fa-spin");
121
+ for (let t = 0; t < e.length; t++)
122
+ e[t].className = e[t].className.replace(/fa-spin/g, "");
123
+ const o = t.querySelectorAll(".ab-initial-spinner")[0];
124
+ if (null != o) {
125
+ const e = document.createElement("span");
126
+ (e.innerHTML = Ce.m().get("FEED_TIMEOUT_MESSAGE") || ""),
127
+ null != o.parentNode &&
128
+ (o.parentNode.appendChild(e), o.parentNode.removeChild(o));
129
+ }
130
+ "true" === t.getAttribute("aria-busy") &&
131
+ t.setAttribute("aria-busy", "false");
132
+ }
133
+ }, x.uo),
134
+ e.sr();
135
+ }
136
+ export function feedToHtml(e, t, o) {
137
+ const s = document.createElement("div");
138
+ (s.className = "ab-feed ab-hide ab-effect-slide"),
139
+ s.setAttribute("role", "dialog"),
140
+ s.setAttribute("aria-label", "Feed"),
141
+ s.setAttribute("tabindex", "-1");
142
+ const n = document.createElement("div");
143
+ (n.className = "ab-feed-buttons-wrapper"),
144
+ n.setAttribute("role", "group"),
145
+ s.appendChild(n);
146
+ const i = document.createElement("i");
147
+ (i.className = "fa fa-times ab-close-button"),
148
+ i.setAttribute("aria-label", "Close Feed"),
149
+ i.setAttribute("tabindex", "0"),
150
+ i.setAttribute("role", "button");
151
+ const a = (e) => {
152
+ destroyFeedHtml(s), e.stopPropagation();
153
+ };
154
+ i.addEventListener("keydown", (e) => {
155
+ (e.keyCode !== lt.Fo && e.keyCode !== lt.To) || a(e);
156
+ }),
157
+ (i.onclick = a);
158
+ const d = document.createElement("i");
159
+ (d.className = "fa fa-refresh ab-refresh-button"),
160
+ e && null == e.lastUpdated && (d.className += " fa-spin"),
161
+ d.setAttribute("aria-label", "Refresh Feed"),
162
+ d.setAttribute("tabindex", "0"),
163
+ d.setAttribute("role", "button");
164
+ const l = (t) => {
165
+ refreshFeed(e, s), t.stopPropagation();
166
+ };
167
+ d.addEventListener("keydown", (e) => {
168
+ (e.keyCode !== lt.Fo && e.keyCode !== lt.To) || l(e);
169
+ }),
170
+ (d.onclick = l),
171
+ n.appendChild(d),
172
+ n.appendChild(i),
173
+ s.appendChild(generateFeedBody(e, t));
174
+ const c = () => detectFeedImpressions(e, s);
175
+ if ((s.addEventListener("scroll", c), !o)) {
176
+ window.addEventListener("scroll", c);
177
+ const e = r.Z.Y();
178
+ (scrollListeners[e] = c), s.setAttribute("data-listener-id", e);
179
+ }
180
+ return s;
181
+ }
182
+ export function updateFeedCards(e, t, o, s, n) {
183
+ if (!p(t)) return;
184
+ const i = [];
185
+ for (const e of t)
186
+ if (e instanceof Card) {
187
+ if (e.url && X.test(e.url)) {
188
+ const t = Q(e.url);
189
+ if (ft(t)) {
190
+ r.j.error(dt(vt._r, "Content Card"));
191
+ continue;
192
+ }
193
+ }
194
+ i.push(e);
195
+ }
196
+ if (((e.cards = i), (e.lastUpdated = o), null != s))
197
+ if ((s.setAttribute("aria-busy", "false"), null == e.lastUpdated))
198
+ destroyFeedHtml(s);
199
+ else {
200
+ const t = s.querySelectorAll(".ab-feed-body")[0];
201
+ if (null != t) {
202
+ const o = generateFeedBody(e, n);
203
+ t.parentNode && t.parentNode.replaceChild(o, t),
204
+ detectFeedImpressions(e, o.parentNode);
205
+ }
206
+ }
207
+ }
208
+ export function registerFeedSubscriptionId(e, t) {
209
+ e && t.setAttribute("data-update-subscription-id", e);
210
+ }