@braze/web-sdk 4.1.0 → 4.2.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 (83) hide show
  1. package/index.d.ts +3 -3
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +1 -1
  6. package/shared-lib/indexed-db-adapter.js +1 -1
  7. package/shared-lib/logger.js +1 -1
  8. package/shared-lib/supported-options.js +1 -1
  9. package/src/ContentCards/content-cards-provider.js +1 -1
  10. package/src/ContentCards/get-cached-content-cards.js +1 -1
  11. package/src/ContentCards/log-content-cards-displayed.js +1 -1
  12. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  13. package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -1
  14. package/src/ContentCards/ui/show-content-cards.js +1 -1
  15. package/src/Core/add-sdk-metadata.js +1 -1
  16. package/src/Core/disable-sdk.js +1 -1
  17. package/src/Core/enable-sdk.js +1 -1
  18. package/src/Core/handle-braze-action.js +1 -1
  19. package/src/Core/is-disabled.js +1 -1
  20. package/src/Core/log-custom-event.js +1 -1
  21. package/src/Core/log-purchase.js +1 -1
  22. package/src/Core/open-session.js +1 -1
  23. package/src/Core/set-sdk-authentication-signature.js +1 -1
  24. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  25. package/src/Core/wipe-data.js +1 -1
  26. package/src/Feed/feed-provider.js +1 -1
  27. package/src/Feed/get-cached-feed.js +1 -1
  28. package/src/Feed/request-feed-refresh.js +1 -1
  29. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  30. package/src/Feed/ui/show-feed.js +1 -1
  31. package/src/InAppMessage/display/html-message-to-html.js +1 -1
  32. package/src/InAppMessage/in-app-message-manager.js +1 -1
  33. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  34. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  35. package/src/InAppMessage/log-in-app-message-html-click.js +1 -1
  36. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  37. package/src/InAppMessage/models/in-app-message-button.js +1 -1
  38. package/src/InAppMessage/models/in-app-message.js +1 -1
  39. package/src/InAppMessage/models/modal-message.js +1 -1
  40. package/src/InAppMessage/models/slide-up-message.js +1 -1
  41. package/src/InAppMessage/models/templated-in-app-message.js +1 -1
  42. package/src/InAppMessage/ui/show-in-app-message.js +1 -1
  43. package/src/Push/push-manager-factory.js +1 -1
  44. package/src/Push/push-manager.js +1 -1
  45. package/src/User/user-manager.js +1 -1
  46. package/src/User/user.js +1 -1
  47. package/src/common/base-feed.js +1 -1
  48. package/src/common/base-provider.js +1 -1
  49. package/src/common/feed-display.js +1 -1
  50. package/src/l10n/l10n-manager-factory.js +1 -1
  51. package/src/managers/auth-manager.js +1 -1
  52. package/src/managers/braze-instance.js +1 -1
  53. package/src/managers/device-manager.js +1 -1
  54. package/src/managers/network-manager.js +1 -1
  55. package/src/managers/server-config-manager.js +1 -1
  56. package/src/managers/session-manager.js +1 -1
  57. package/src/managers/storage-manager-factory.js +1 -1
  58. package/src/managers/storage-manager.js +1 -1
  59. package/src/models/backend-errors.js +1 -1
  60. package/src/models/braze-event.js +1 -1
  61. package/src/models/device.js +1 -1
  62. package/src/models/identifier.js +1 -1
  63. package/src/models/push-token.js +1 -1
  64. package/src/models/server-config.js +1 -1
  65. package/src/request-controller.js +1 -1
  66. package/src/triggers/models/filter-set.js +1 -1
  67. package/src/triggers/models/filter.js +1 -1
  68. package/src/triggers/models/in-app-message-click-data.js +1 -1
  69. package/src/triggers/models/push-click-data.js +1 -1
  70. package/src/triggers/models/trigger-condition.js +1 -1
  71. package/src/triggers/models/trigger.js +1 -1
  72. package/src/triggers/triggers-provider-factory.js +1 -1
  73. package/src/triggers/triggers-provider.js +1 -1
  74. package/src/ui/js/attach-css.js +1 -1
  75. package/src/ui/js/load-font-awesome.js +1 -1
  76. package/src/util/braze-actions.js +1 -1
  77. package/src/util/browser-detector.js +1 -1
  78. package/src/util/dom-utils.js +1 -1
  79. package/src/util/key-codes.js +1 -1
  80. package/src/util/net.js +1 -1
  81. package/src/util/user-agent-parser.js +1 -1
  82. package/src/util/validation-utils.js +1 -1
  83. package/src/util/window-utils.js +1 -1
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v4.1.0
2
+ * Type definitions for @braze/web-sdk v4.2.0
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2022 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
@@ -1920,7 +1920,7 @@
1920
1920
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
1921
1921
  *
1922
1922
  * ```
1923
- * self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.1/service-worker.js');
1923
+ * self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.2/service-worker.js');
1924
1924
  * ```
1925
1925
  *
1926
1926
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -2234,7 +2234,7 @@
2234
2234
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2235
2235
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2236
2236
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2237
- * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.1/service-worker.js');` or by including the content
2237
+ * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.2/service-worker.js');` or by including the content
2238
2238
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2239
2239
  */
2240
2240
  manageServiceWorkerExternally?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Braze SDK for web sites and other JS platforms.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1 +1 @@
1
- import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Be from"./guid.js";import Ae from"./indexed-db-adapter.js";import Ge from"./logger.js";import Oe from"./supported-options.js";const r={Un:je,A:ve,qr:De,it:Be,qt:Ae,xt:Ae.ep,D:Ge,Go:Oe};export default r;
1
+ import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Be from"./guid.js";import Ae from"./indexed-db-adapter.js";import Ge from"./logger.js";import Oe from"./supported-options.js";const r={Vn:je,A:ve,qr:De,it:Be,qt:Ae,xt:Ae.ep,D:Ge,Ko:Oe};export default r;
@@ -1 +1 @@
1
- const je={jn:function(t){const r=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;++t)o[t]=n.charCodeAt(t);return o}};export default je;
1
+ const je={In:function(t){const r=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;++t)o[t]=n.charCodeAt(t);return o}};export default je;
@@ -1 +1 @@
1
- const ve={CustomEvent:"ce",Pr:"p",Al:"pc",cc:"ca",Da:"i",fa:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Je:"si",Re:"sc",He:"sbc",Pe:"sfe",ro:"iec",$l:"lr",jl:"uae",U:"ci",F:"cc",_l:"lcaa",Tl:"lcar",Qr:"inc",Wr:"add",Yr:"rem",Vr:"set",ql:"sgu"},De={Fr:"feed_displayed",dc:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
1
+ const ve={CustomEvent:"ce",Pr:"p",Al:"pc",cc:"ca",Da:"i",qs:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Je:"si",Re:"sc",He:"sbc",Pe:"sfe",ro:"iec",$l:"lr",jl:"uae",U:"ci",F:"cc",_l:"lcaa",Tl:"lcar",Qr:"inc",Wr:"add",Yr:"rem",Vr:"set",ql:"sgu"},De={Fr:"feed_displayed",dc:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
@@ -1 +1 @@
1
- export default class Ae{constructor(t,e){this.td="undefined"==typeof window?self:window,this.ed=t,this.nd=e}od(){if("indexedDB"in this.td)return this.td.indexedDB}rd(){try{if(null==this.od())return!1;if(this.od().open("Braze IndexedDB Support Test"),"undefined"!=typeof window){const t=window.chrome||window.browser||window.msBrowser;if(t&&t.runtime&&t.runtime.id)return this.nd.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(t){return this.nd.info("Not using IndexedDB for storage due to following error: "+t),!1}}dd(t,e){const n=this.od().open(this.ed.sd,this.ed.VERSION);if(null==n)return"function"==typeof e&&e(),!1;const o=this;return n.onupgradeneeded=t=>{o.nd.info("Upgrading indexedDB "+o.ed.sd+" to v"+o.ed.VERSION+"...");const e=t.target.result;for(const t in o.ed.$t)o.ed.$t.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.$t[t])&&e.createObjectStore(o.ed.$t[t])},n.onsuccess=n=>{const i=n.target.result;i.onversionchange=()=>{i.close(),"function"==typeof e&&e(),o.nd.error("Needed to close the database unexpectedly because of an upgrade in another tab")},t(i)},n.onerror=t=>(o.nd.info("Could not open indexedDB "+o.ed.sd+" v"+o.ed.VERSION+": "+t.target.errorCode),"function"==typeof e&&e(),!0),!0}setItem(t,e,n,o,i){if(!this.rd())return"function"==typeof i&&i(),!1;const r=this;return this.dd((d=>{if(!d.objectStoreNames.contains(t))return r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof i&&i());const s=d.transaction([t],"readwrite").objectStore(t).put(n,e);s.onerror=()=>{r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd),"function"==typeof i&&i()},s.onsuccess=()=>{"function"==typeof o&&o()}}),i)}getItem(t,e,n){if(!this.rd())return!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return void o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore");const r=i.transaction([t],"readonly").objectStore(t).get(e);r.onerror=()=>{o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd)},r.onsuccess=t=>{const e=t.target.result;null!=e&&n(e)}}))}hr(t,e,n){if(!this.rd())return"function"==typeof n&&n(),!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return o.nd.error("Could not retrieve last record from "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof n&&n());const r=i.transaction([t],"readonly").objectStore(t).openCursor(null,"prev");r.onerror=()=>{o.nd.error("Could not open cursor for "+t+" on indexedDB "+o.ed.sd),"function"==typeof n&&n()},r.onsuccess=t=>{const o=t.target.result;null!=o&&null!=o.value&&null!=o.key?e(o.key,o.value):"function"==typeof n&&n()}}),n)}br(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");o.transaction([t],"readwrite").objectStore(t).delete(e).onerror=()=>{n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd)}}))}Jt(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not retrieve objects from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");const i=o.transaction([t],"readwrite").objectStore(t),r=i.openCursor(),d=[];r.onerror=()=>{d.length>0?(n.nd.info("Cursor closed midway through for "+t+" on indexedDB "+n.ed.sd),e(d)):n.nd.error("Could not open cursor for "+t+" on indexedDB "+n.ed.sd)},r.onsuccess=t=>{const n=t.target.result;if(null!=n){if(null!=n.value&&null!=n.key){i.delete(n.key).onsuccess=()=>{d.push(n.value)}}n.continue()}else d.length>0&&e(d)}}))}clearData(){if(!this.rd())return!1;const t=[];for(const e in this.ed.$t)this.ed.$t.hasOwnProperty(e)&&this.ed.$t[e]!==this.ed.$t.oe&&t.push(this.ed.$t[e]);const e=this;return this.dd((function(n){const o=n.transaction(t,"readwrite");for(let n=0;n<t.length;n++){const i=t[n];o.objectStore(i).clear().onerror=function(){e.nd.error("Could not clear "+this.source.name+" on indexedDB "+e.ed.sd)}}o.onerror=function(){e.nd.error("Could not clear object stores on indexedDB "+e.ed.sd)}}))}}Ae.ep={Ft:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,$t:{Cl:"data",jr:"pushClicks",Mr:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",On:"sdkAuthenticationSignature"},se:1}};
1
+ export default class Ae{constructor(t,e){this.td="undefined"==typeof window?self:window,this.ed=t,this.nd=e}od(){if("indexedDB"in this.td)return this.td.indexedDB}rd(){try{if(null==this.od())return!1;if(this.od().open("Braze IndexedDB Support Test"),"undefined"!=typeof window){const t=window.chrome||window.browser||window.msBrowser;if(t&&t.runtime&&t.runtime.id)return this.nd.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(t){return this.nd.info("Not using IndexedDB for storage due to following error: "+t),!1}}dd(t,e){const n=this.od().open(this.ed.sd,this.ed.VERSION);if(null==n)return"function"==typeof e&&e(),!1;const o=this;return n.onupgradeneeded=t=>{o.nd.info("Upgrading indexedDB "+o.ed.sd+" to v"+o.ed.VERSION+"...");const e=t.target.result;for(const t in o.ed.$t)o.ed.$t.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.$t[t])&&e.createObjectStore(o.ed.$t[t])},n.onsuccess=n=>{const i=n.target.result;i.onversionchange=()=>{i.close(),"function"==typeof e&&e(),o.nd.error("Needed to close the database unexpectedly because of an upgrade in another tab")},t(i)},n.onerror=t=>(o.nd.info("Could not open indexedDB "+o.ed.sd+" v"+o.ed.VERSION+": "+t.target.errorCode),"function"==typeof e&&e(),!0),!0}setItem(t,e,n,o,i){if(!this.rd())return"function"==typeof i&&i(),!1;const r=this;return this.dd((d=>{if(!d.objectStoreNames.contains(t))return r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof i&&i());const s=d.transaction([t],"readwrite").objectStore(t).put(n,e);s.onerror=()=>{r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd),"function"==typeof i&&i()},s.onsuccess=()=>{"function"==typeof o&&o()}}),i)}getItem(t,e,n){if(!this.rd())return!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return void o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore");const r=i.transaction([t],"readonly").objectStore(t).get(e);r.onerror=()=>{o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd)},r.onsuccess=t=>{const e=t.target.result;null!=e&&n(e)}}))}hr(t,e,n){if(!this.rd())return"function"==typeof n&&n(),!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return o.nd.error("Could not retrieve last record from "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof n&&n());const r=i.transaction([t],"readonly").objectStore(t).openCursor(null,"prev");r.onerror=()=>{o.nd.error("Could not open cursor for "+t+" on indexedDB "+o.ed.sd),"function"==typeof n&&n()},r.onsuccess=t=>{const o=t.target.result;null!=o&&null!=o.value&&null!=o.key?e(o.key,o.value):"function"==typeof n&&n()}}),n)}br(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");o.transaction([t],"readwrite").objectStore(t).delete(e).onerror=()=>{n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd)}}))}Jt(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not retrieve objects from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");const i=o.transaction([t],"readwrite").objectStore(t),r=i.openCursor(),d=[];r.onerror=()=>{d.length>0?(n.nd.info("Cursor closed midway through for "+t+" on indexedDB "+n.ed.sd),e(d)):n.nd.error("Could not open cursor for "+t+" on indexedDB "+n.ed.sd)},r.onsuccess=t=>{const n=t.target.result;if(null!=n){if(null!=n.value&&null!=n.key){i.delete(n.key).onsuccess=()=>{d.push(n.value)}}n.continue()}else d.length>0&&e(d)}}))}clearData(){if(!this.rd())return!1;const t=[];for(const e in this.ed.$t)this.ed.$t.hasOwnProperty(e)&&this.ed.$t[e]!==this.ed.$t.oe&&t.push(this.ed.$t[e]);const e=this;return this.dd((function(n){const o=n.transaction(t,"readwrite");for(let n=0;n<t.length;n++){const i=t[n];o.objectStore(i).clear().onerror=function(){e.nd.error("Could not clear "+this.source.name+" on indexedDB "+e.ed.sd)}}o.onerror=function(){e.nd.error("Could not clear object stores on indexedDB "+e.ed.sd)}}))}}Ae.ep={Ft:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,$t:{Cl:"data",jr:"pushClicks",Mr:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",Zn:"sdkAuthenticationSignature"},se:1}};
@@ -1 +1 @@
1
- const Ge={init:function(n){void 0===n&&void 0!==Ge.zg||(Ge.zg=!!n),Ge.Dg||(Ge.Dg=!0)},destroy:function(){Ge.Dg=!1,Ge.zg=void 0,Ge.nd=void 0},setLogger:function(n){"function"==typeof n?(Ge.init(),Ge.nd=n):Ge.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ge.init(),Ge.zg?(console.log("Disabling Braze logging"),Ge.zg=!1):(console.log("Enabled Braze logging"),Ge.zg=!0)},info:function(n){if(Ge.zg){const o="Braze: "+n;null!=Ge.nd?Ge.nd(o):console.log(o)}},warn:function(n){if(Ge.zg){const o="Braze SDK Warning: "+n+" (v4.1.0)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.1.0)";null!=Ge.nd?Ge.nd(o):console.error(o)}}};export default Ge;
1
+ const Ge={init:function(n){void 0===n&&void 0!==Ge.zg||(Ge.zg=!!n),Ge.Dg||(Ge.Dg=!0)},destroy:function(){Ge.Dg=!1,Ge.zg=void 0,Ge.nd=void 0},setLogger:function(n){"function"==typeof n?(Ge.init(),Ge.nd=n):Ge.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ge.init(),Ge.zg?(console.log("Disabling Braze logging"),Ge.zg=!1):(console.log("Enabled Braze logging"),Ge.zg=!0)},info:function(n){if(Ge.zg){const o="Braze: "+n;null!=Ge.nd?Ge.nd(o):console.log(o)}},warn:function(n){if(Ge.zg){const o="Braze SDK Warning: "+n+" (v4.2.0)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.2.0)";null!=Ge.nd?Ge.nd(o):console.error(o)}}};export default Ge;
@@ -1 +1 @@
1
- export default{$n:"allowCrawlerActivity",ho:"baseUrl",po:"noCookies",Eo:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",_o:"enableLogging",Io:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",Ao:"minimumIntervalBetweenTriggerActionsInSeconds",So:"sessionTimeoutInSeconds",No:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",Mn:"localization",ao:"contentSecurityNonce",wo:"enableHtmlInAppMessages",To:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",Ci:"requireExplicitInAppMessageDismissal",Oo:"doNotLoadFontAwesome",vo:"sdkFlavor",tn:"openCardsInNewTab"};
1
+ export default{ho:"allowCrawlerActivity",po:"baseUrl",Eo:"noCookies",_o:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",Io:"enableLogging",Ao:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",So:"minimumIntervalBetweenTriggerActionsInSeconds",No:"sessionTimeoutInSeconds",wo:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",Mn:"localization",ao:"contentSecurityNonce",To:"enableHtmlInAppMessages",Oo:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",Ui:"requireExplicitInAppMessageDismissal",vo:"doNotLoadFontAwesome",Co:"sdkFlavor",tn:"openCardsInNewTab"};
@@ -1 +1 @@
1
- import b from"../util/net.js";import C from"../common/base-provider.js";import e from"../managers/braze-instance.js";import ContentCards from"./content-cards.js";import{dateFromUnixTimestamp as h}from"../util/date-utils.js";import{isURIJavascriptOrData as j}from"../util/url-utils.js";import{newCardFromContentCardsJson as S,newCardFromSerializedValue as _}from"../Card/util/card-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import u from"../managers/subscription-manager.js";export default class v extends C{constructor(t,s,i,h,n){super(),this.v=t,this.h=s,this.wt=i,this.gt=h,this.jt=n,this.vt=new u,e.yt(this.vt),this.Ut=0,this.kt=0,this.zt();const o=r.xt.Ft;new r.qt(o,r.D).Jt(o.$t.Mt,(t=>{this.Bt(t)}))}Gt(){return this.Ht}Kt(t){this.Ht=t}Qt(){return this.Vt}Wt(t){this.Vt=t}zt(){const t=this.h.I(o.q.Xt)||[],s=[];for(let i=0;i<t.length;i++){const e=_(t[i]);null!=e&&s.push(e)}this.Yt=this.Zt(this.Cs(s,!1)),this.Ut=this.h.I(o.q.ws)||this.Ut,this.kt=this.h.I(o.q.Ss)||this.kt}vs(t,s,i,e){let h;if(s){h=[];for(const t of this.Yt)t.test&&h.push(t)}else h=this.Yt.slice();for(let i=0;i<t.length;i++){const e=t[i];let r=null;for(let t=0;t<this.Yt.length;t++)if(e.id===this.Yt[t].id){r=this.Yt[t];break}if(s){const t=S(e);null!=r&&r.viewed&&(t.viewed=!0),null!=t&&h.push(t)}else if(null==r){const t=S(e);null!=t&&h.push(t)}else{if(!r.ct(e))for(let t=0;t<h.length;t++)if(e.id===h[t].id){h.splice(t,1);break}}}this.Yt=this.Zt(this.Cs(h,s)),this._s(),this.Ut=i||0,this.h.B(o.q.ws,this.Ut),this.kt=e||0,this.h.B(o.q.Ss,this.kt)}ys(t){if(this.Us()&&null!=t&&t.cards){this.h.B(o.q.Ts,e.Ds());const s=t.full_sync;s||this.zt(),this.vs(t.cards,s,t.last_full_sync_at,t.last_card_updated_at),this.vt.St(this.Rs(!0))}}Bt(t){if(!this.Us())return;this.zt();const s=this.Yt.slice(),i=this.v.getUserId();for(let e=0;e<t.length;e++)if(i===t[e].userId||null==i&&null==t[e].userId){const i=t[e].card;let h=null;for(let t=0;t<this.Yt.length;t++)if(i.id===this.Yt[t].id){h=this.Yt[t];break}if(null==h){const t=S(i);null!=t&&s.push(t)}else{if(!h.ct(i))for(let t=0;t<s.length;t++)if(i.id===s[t].id){s.splice(t,1);break}}}this.Yt=this.Zt(this.Cs(s,!1)),this._s(),this.vt.St(this.Rs(!0))}Cs(t,s){const i=this.h.I(o.q.$)||{},e=this.h.I(o.q.O)||{},h=this.h.I(o.q.K)||{},r={},n={},a={};for(let s=0;s<t.length;s++)i[t[s].id]&&(t[s].clicked=!0,r[t[s].id]=!0),e[t[s].id]&&(t[s].viewed=!0,n[t[s].id]=!0),h[t[s].id]&&(t[s].dismissed=!0,a[t[s].id]=!0);return s&&(this.h.B(o.q.$,r),this.h.B(o.q.O,n),this.h.B(o.q.K,a)),t}Zt(t){const s=[],i=new Date,e=this.h.I(o.q.K)||{};let h=!1;for(let n=0;n<t.length;n++){const o=t[n].url;!this.gt&&o&&j(o)?r.D.error(`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`):(null==t[n].expiresAt||t[n].expiresAt>=i)&&!t[n].dismissed?s.push(t[n]):(e[t[n].id]=!0,h=!0)}return h&&this.h.B(o.q.K,e),s}_s(){const t=[];for(let s=0;s<this.Yt.length;s++)t.push(this.Yt[s].ss());this.h.B(o.q.Xt,t)}Fs(t,s){if(!this.Us())return void(this.Ls||(this.Ls=this.wt.Ns((()=>{this.Fs(t,s)}))));const i=this.jt.As({},!0);this.h.I(o.q.Ts)!==e.Ds()&&this.Js(),i.last_full_sync_at=this.Ut,i.last_card_updated_at=this.kt;const h=this.jt.qs(i,!0);this.jt.Es(i,(()=>{b.Ms({url:this.jt.Ps()+"/content_cards/sync",data:i,headers:h,S:e=>{this.jt.$s(i,e,h)?(this.jt.Bs(),this.ys(e),"function"==typeof t&&t()):"function"==typeof s&&s()},error:t=>{this.jt.Gs(t,"retrieving content cards"),"function"==typeof s&&s()}})}))}Rs(t){t||this.zt();const s=this.Zt(this.Yt);s.sort(((t,s)=>t.pinned&&!s.pinned?-1:s.pinned&&!t.pinned?1:t.updated>s.updated?-1:s.updated>t.updated?1:0));let i=Math.max(this.kt||0,this.Ut||0);return 0===i&&(i=void 0),this.h.I(o.q.Ss)===this.kt&&void 0===i&&(i=this.kt),new ContentCards(s,h(i))}Hs(t){return this.vt.ut(t)}Js(){this.Ut=0,this.kt=0,this.h.Is(o.q.ws),this.h.Is(o.q.Ss)}changeUser(t){t||(this.Yt=[],this.vt.St(new ContentCards(this.Yt.slice(),null)),this.h.Is(o.q.Xt),this.h.Is(o.q.$),this.h.Is(o.q.O),this.h.Is(o.q.K)),this.Js()}clearData(t){this.Ut=0,this.kt=0,this.Yt=[],this.vt.St(new ContentCards(this.Yt.slice(),null)),t&&(this.h.Is(o.q.Xt),this.h.Is(o.q.$),this.h.Is(o.q.O),this.h.Is(o.q.K),this.h.Is(o.q.ws),this.h.Is(o.q.Ss))}Us(){return!!this.wt.Ks()||(0!==this.wt.Os()&&this.Qs(),!1)}Qs(){this.vt.St(new ContentCards([],(new Date).valueOf())),this.h.Is(o.q.Xt)}}
1
+ import b,{readResponseHeaders as C}from"../util/net.js";import y from"../common/base-provider.js";import e from"../managers/braze-instance.js";import ContentCards from"./content-cards.js";import{dateFromUnixTimestamp as h}from"../util/date-utils.js";import{isURIJavascriptOrData as j}from"../util/url-utils.js";import{newCardFromContentCardsJson as N,newCardFromSerializedValue as S}from"../Card/util/card-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import u from"../managers/subscription-manager.js";import s from"../common/event-logger.js";export default class v extends y{constructor(t,s,i,h,n){super(),this.v=t,this.h=s,this.gt=i,this.wt=h,this.vt=n,this.yt=new u,e.jt(this.yt),this.Ut=0,this.kt=0,this.zt();const o=r.xt.Ft;new r.qt(o,r.D).Jt(o.$t.Mt,(t=>{this.Bt(t)})),this.Gt=null}Ht(){return this.Kt}Qt(t){this.Kt=t}Vt(){return this.Wt}Xt(t){this.Wt=t}zt(){const t=this.h.I(o.q.Yt)||[],s=[];for(let i=0;i<t.length;i++){const e=S(t[i]);null!=e&&s.push(e)}this.Zt=this.Cs(this.ws(s,!1)),this.Ut=this.h.I(o.q.vs)||this.Ut,this.kt=this.h.I(o.q.ys)||this.kt}Ns(t,s,i,e){let h;if(s){h=[];for(const t of this.Zt)t.test&&h.push(t)}else h=this.Zt.slice();for(let i=0;i<t.length;i++){const e=t[i];let r=null;for(let t=0;t<this.Zt.length;t++)if(e.id===this.Zt[t].id){r=this.Zt[t];break}if(s){const t=N(e);null!=r&&r.viewed&&(t.viewed=!0),null!=t&&h.push(t)}else if(null==r){const t=N(e);null!=t&&h.push(t)}else{if(!r.ct(e))for(let t=0;t<h.length;t++)if(e.id===h[t].id){h.splice(t,1);break}}}this.Zt=this.Cs(this.ws(h,s)),this.Ss(),this.Ut=i||0,this.h.B(o.q.vs,this.Ut),this.kt=e||0,this.h.B(o.q.ys,this.kt)}Rs(t){if(this.Ts()&&null!=t&&t.cards){this.h.B(o.q._s,e.Ds());const s=t.full_sync;s||this.zt(),this.Ns(t.cards,s,t.last_full_sync_at,t.last_card_updated_at),this.yt.St(this.Us(!0))}}Fs(t){this.h.B(o.q.As,t)}Ls(t,i,e){const h=()=>{this.Is(i,e,!0)},n=C(t);let a,l;if(this.Js(),!n["retry-after"])return void this.Fs(0);if(a=n["retry-after"],isNaN(a)&&!isNaN(Date.parse(a)))l=Date.parse(a)-(new Date).getTime(),l<0&&h();else{if(isNaN(parseFloat(a))){const t="Received unexpected value for retry-after header in /sync response";return s.G(r.A.qs,{e:t+": "+a}),void this.Fs(0)}l=1e3*a}this.Gt=setTimeout((()=>{h()}),l);let c=this.h.I(o.q.As);c&&!isNaN(parseInt(c))||(c=0),this.Fs(parseInt(c)+1)}Bt(t){if(!this.Ts())return;this.zt();const s=this.Zt.slice(),i=this.v.getUserId();for(let e=0;e<t.length;e++)if(i===t[e].userId||null==i&&null==t[e].userId){const i=t[e].card;let h=null;for(let t=0;t<this.Zt.length;t++)if(i.id===this.Zt[t].id){h=this.Zt[t];break}if(null==h){const t=N(i);null!=t&&s.push(t)}else{if(!h.ct(i))for(let t=0;t<s.length;t++)if(i.id===s[t].id){s.splice(t,1);break}}}this.Zt=this.Cs(this.ws(s,!1)),this.Ss(),this.yt.St(this.Us(!0))}ws(t,s){const i=this.h.I(o.q.$)||{},e=this.h.I(o.q.O)||{},h=this.h.I(o.q.K)||{},r={},n={},a={};for(let s=0;s<t.length;s++)i[t[s].id]&&(t[s].clicked=!0,r[t[s].id]=!0),e[t[s].id]&&(t[s].viewed=!0,n[t[s].id]=!0),h[t[s].id]&&(t[s].dismissed=!0,a[t[s].id]=!0);return s&&(this.h.B(o.q.$,r),this.h.B(o.q.O,n),this.h.B(o.q.K,a)),t}Cs(t){const s=[],i=new Date,e=this.h.I(o.q.K)||{};let h=!1;for(let n=0;n<t.length;n++){const o=t[n].url;!this.wt&&o&&j(o)?r.D.error(`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`):(null==t[n].expiresAt||t[n].expiresAt>=i)&&!t[n].dismissed?s.push(t[n]):(e[t[n].id]=!0,h=!0)}return h&&this.h.B(o.q.K,e),s}Ss(){const t=[];for(let s=0;s<this.Zt.length;s++)t.push(this.Zt[s].ss());this.h.B(o.q.Yt,t)}Js(){this.Gt&&(clearTimeout(this.Gt),this.Gt=null)}Is(t,s,i){if(i||(this.Js(),this.Fs(0)),!this.Ts())return void(this.Es||(this.Es=this.gt.Ms((()=>{this.Is(t,s)}))));const h=this.vt.Ps({},!0);this.h.I(o.q._s)!==e.Ds()&&this.$s(),h.last_full_sync_at=this.Ut,h.last_card_updated_at=this.kt;const r=this.vt.Bs(h,!0,i);this.vt.Gs(h,(()=>{b.Hs({url:this.vt.Ks()+"/content_cards/sync",data:h,headers:r,S:(i,e)=>{this.vt.Os(h,i,r)?(this.vt.Qs(),this.Ls(e,t,s),this.Rs(i),"function"==typeof t&&t()):"function"==typeof s&&s()},error:t=>{this.vt.Vs(t,"retrieving content cards"),"function"==typeof s&&s()}})}))}Us(t){t||this.zt();const s=this.Cs(this.Zt);s.sort(((t,s)=>t.pinned&&!s.pinned?-1:s.pinned&&!t.pinned?1:t.updated>s.updated?-1:s.updated>t.updated?1:0));let i=Math.max(this.kt||0,this.Ut||0);return 0===i&&(i=void 0),this.h.I(o.q.ys)===this.kt&&void 0===i&&(i=this.kt),new ContentCards(s,h(i))}Ws(t){return this.yt.ut(t)}$s(){this.Ut=0,this.kt=0,this.h.Xs(o.q.vs),this.h.Xs(o.q.ys)}changeUser(t){t||(this.Zt=[],this.yt.St(new ContentCards(this.Zt.slice(),null)),this.h.Xs(o.q.Yt),this.h.Xs(o.q.$),this.h.Xs(o.q.O),this.h.Xs(o.q.K)),this.$s()}clearData(t){this.Ut=0,this.kt=0,this.Zt=[],this.yt.St(new ContentCards(this.Zt.slice(),null)),t&&(this.h.Xs(o.q.Yt),this.h.Xs(o.q.$),this.h.Xs(o.q.O),this.h.Xs(o.q.K),this.h.Xs(o.q.vs),this.h.Xs(o.q.ys))}Ts(){return!!this.gt.Ys()||(0!==this.gt.Zs()&&this.ti(),!1)}ti(){this.yt.St(new ContentCards([],(new Date).valueOf())),this.h.Xs(o.q.Yt)}}
@@ -1 +1 @@
1
- import g from"./content-cards-provider-factory.js";import e from"../managers/braze-instance.js";export function getCachedContentCards(){if(e.rr())return g.er().Rs(!1)}
1
+ import g from"./content-cards-provider-factory.js";import e from"../managers/braze-instance.js";export function getCachedContentCards(){if(e.rr())return g.er().Us(!1)}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import{logDeprecationWarning as y}from"../util/deprecation-utils.js";export function logContentCardsDisplayed(){if(e.rr())return y("logContentCardsDisplayed","method"),!0}
1
+ import e from"../managers/braze-instance.js";import{logDeprecationWarning as D}from"../util/deprecation-utils.js";export function logContentCardsDisplayed(){if(e.rr())return D("logContentCardsDisplayed","method"),!0}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function requestContentCardsRefresh(r,t){if(e.rr())return g.er().Fs(r,t)}
1
+ import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function requestContentCardsRefresh(r,t){if(e.rr())return g.er().Is(r,t)}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function subscribeToContentCardsUpdates(r){if(!e.rr())return;const t=g.er(),n=t.Hs(r);if(!t.Qt()){const r=e.mr().cr((()=>{t.Fs()}));t.Wt(r)}return n}
1
+ import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function subscribeToContentCardsUpdates(r){if(!e.rr())return;const t=g.er(),n=t.Ws(r);if(!t.Vt()){const r=e.mr().cr((()=>{t.Is()}));t.Xt(r)}return n}
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";import{ContentCards,subscribeToContentCardsUpdates}from"../index.js";import g from"../content-cards-provider-factory.js";import{destroyFeedHtml as z,detectFeedImpressions as T,feedToHtml as N,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as q,refreshFeed as I,registerFeedSubscriptionId as L,updateFeedCards as M}from"../../common/feed-display.js";import{setCardHeight as $}from"../../Card/display/card-display.js";import{setupFeedUI as k}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showContentCards(n,t){if(!e.rr())return;k();let o=!1;null==n&&(n=document.body,o=!0);const a=e.nn(D.tn)||e.nn(D.en)||!1;let i=g.er().Rs(!1);"function"==typeof t&&M(i,t(i.cards.slice()),i.lastUpdated,null,a);const s=N(i,a),f=g.er();(null==i.lastUpdated||(new Date).valueOf()-i.lastUpdated.valueOf()>ContentCards.ur)&&(null==f.Gt()||(new Date).valueOf()-f.Gt()>ContentCards.ur)&&(r.D.info(`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`),I(i,s),f.Kt((new Date).valueOf()));const l=(new Date).valueOf(),c=subscribeToContentCardsUpdates((function(n){const e=s.querySelectorAll(".ab-refresh-button")[0];if(null!=e){let n=500;const t=parseInt(s.getAttribute(q));isNaN(t)?n-=(new Date).valueOf()-l:n-=(new Date).valueOf()-t,setTimeout((function(){e.className=e.className.replace(/fa-spin/g,"")}),Math.max(n,0))}let o=n.cards;"function"==typeof t&&(o=t(o.slice())),M(i,o,n.lastUpdated,s,a)}));L(c,s);const u=function(n){const t=n.querySelectorAll(".ab-feed");let e=null;for(let o=0;o<t.length;o++)t[o].parentNode===n&&(e=t[o]);null!=e?(z(e),e.parentNode.replaceChild(s,e)):n.appendChild(s),setTimeout((function(){s.className=s.className.replace("ab-hide","ab-show")}),0),o&&s.focus(),T(i,s),$(i.cards,n)};var m;null!=n?u(n):window.onload=(m=window.onload,function(){"function"==typeof m&&m(),u(document.body)})}
1
+ import e,{OPTIONS as T}from"../../managers/braze-instance.js";import{ContentCards,subscribeToContentCardsUpdates}from"../index.js";import g from"../content-cards-provider-factory.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{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 showContentCards(n,t){if(!e.rr())return;B();let o=!1;null==n&&(n=document.body,o=!0);const a=e.nn(T.tn)||e.nn(T.en)||!1;let i=g.er().Us(!1);"function"==typeof t&&k(i,t(i.cards.slice()),i.lastUpdated,null,a);const s=I(i,a),f=g.er();(null==i.lastUpdated||(new Date).valueOf()-i.lastUpdated.valueOf()>ContentCards.ur)&&(null==f.Ht()||(new Date).valueOf()-f.Ht()>ContentCards.ur)&&(r.D.info(`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`),M(i,s),f.Qt((new Date).valueOf()));const l=(new Date).valueOf(),c=subscribeToContentCardsUpdates((function(n){const e=s.querySelectorAll(".ab-refresh-button")[0];if(null!=e){let n=500;const t=parseInt(s.getAttribute(L));isNaN(t)?n-=(new Date).valueOf()-l:n-=(new Date).valueOf()-t,setTimeout((function(){e.className=e.className.replace(/fa-spin/g,"")}),Math.max(n,0))}let o=n.cards;"function"==typeof t&&(o=t(o.slice())),k(i,o,n.lastUpdated,s,a)}));$(c,s);const u=function(n){const t=n.querySelectorAll(".ab-feed");let e=null;for(let o=0;o<t.length;o++)t[o].parentNode===n&&(e=t[o]);null!=e?(z(e),e.parentNode.replaceChild(s,e)):n.appendChild(s),setTimeout((function(){s.className=s.className.replace("ab-hide","ab-show")}),0),o&&s.focus(),q(i,s),A(i.cards,n)};var m;null!=n?u(n):window.onload=(m=window.onload,function(){"function"==typeof m&&m(),u(document.body)})}
@@ -1 +1 @@
1
- import B from"../managers/braze-instance.js";import BrazeSdkMetadata from"./braze-sdk-metadata.js";import{isArray as p,validateValueIsFromEnum as K}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function addSdkMetadata(a){if(B.rr()){if(!p(a))return r.D.error("Cannot set SDK metadata because metadata is not an array."),!1;for(const t of a)if(!K(BrazeSdkMetadata,t,"sdkMetadata contained an invalid value.","BrazeSdkMetadata"))return!1;return B.nr().addSdkMetadata(a),!0}}
1
+ import K from"../managers/braze-instance.js";import BrazeSdkMetadata from"./braze-sdk-metadata.js";import{isArray as p,validateValueIsFromEnum as F}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function addSdkMetadata(a){if(K.rr()){if(!p(a))return r.D.error("Cannot set SDK metadata because metadata is not an array."),!1;for(const t of a)if(!F(BrazeSdkMetadata,t,"sdkMetadata contained an invalid value.","BrazeSdkMetadata"))return!1;return K.nr().addSdkMetadata(a),!0}}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import A,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function disableSDK(){null!=e.mr()&&e.mr().requestImmediateDataFlush();const n=new A.ne(null,!0);n.store(o.ae,"This-cookie-will-expire-in-"+n.ie());const a=r.xt.Ft;new r.qt(a,r.D).setItem(a.$t.oe,a.se,!0),e.destroy(!1),e.le(!0)}
1
+ import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import G,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function disableSDK(){null!=e.mr()&&e.mr().requestImmediateDataFlush();const n=new G.ne(null,!0);n.store(o.ae,"This-cookie-will-expire-in-"+n.ie());const a=r.xt.Ft;new r.qt(a,r.D).setItem(a.$t.oe,a.se,!0),e.destroy(!1),e.le(!0)}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import A,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function enableSDK(){new A.ne(null,!0).remove(o.ae);const a=r.xt.Ft;new r.qt(a,r.D).br(a.$t.oe,a.se),e.destroy(!1),e.le(!1)}
1
+ import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import G,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function enableSDK(){new G.ne(null,!0).remove(o.ae);const a=r.xt.Ft;new r.qt(a,r.D).br(a.$t.oe,a.se),e.destroy(!1),e.le(!1)}
@@ -1 +1 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";import e from"../managers/braze-instance.js";import{BRAZE_ACTIONS as J,getDecodedBrazeAction as O}from"../util/braze-actions.js";import{BRAZE_ACTION_URI_REGEX as P,isValidBrazeActionJson as F}from"../util/validation-utils.js";import{WindowUtils as G}from"../util/window-utils.js";import{getUser as H}from"./get-user.js";export function _handleBrazeAction(a,s,i){if(e.rr())if(P.test(a)){const e=O(a);if(!e)return;const s=async e=>{if(!F(e))return void r.D.error(`Decoded Braze Action json is invalid: ${JSON.stringify(e,null,2)}`);const a=e[J.properties.type];if(a===J.types.ue)for(const r of e[J.properties.me])s(r);else{const s=e[J.properties.fe];let i,o;switch(a){case J.types.logCustomEvent:i=await import("./log-custom-event.js"),i.logCustomEvent.apply(null,Array.prototype.slice.call(s));break;case J.types.requestPushPermission:i=await import("../Push/request-push-permission.js"),i.requestPushPermission();break;case J.types.setEmailNotificationSubscriptionType:case J.types.setPushNotificationSubscriptionType:case J.types.setCustomUserAttribute:case J.types.addToSubscriptionGroup:case J.types.removeFromSubscriptionGroup:case J.types.addToCustomAttributeArray:case J.types.removeFromCustomAttributeArray:o=H(),o[a].apply(o,Array.prototype.slice.call(s));break;case J.types.de:case J.types.pe:G.openUri.apply(null,Array.prototype.slice.call(s));break;default:r.D.info(`Ignoring unknown Braze Action: ${a}`)}}};s(e)}else G.openUri(a,i,s)}export function handleBrazeAction(e,r){_handleBrazeAction(e,r)}
1
+ import r from"../../shared-lib/braze-shared-lib.js";import e from"../managers/braze-instance.js";import{BRAZE_ACTIONS as _,getDecodedBrazeAction as J}from"../util/braze-actions.js";import{BRAZE_ACTION_URI_REGEX as O,isValidBrazeActionJson as P}from"../util/validation-utils.js";import{WindowUtils as H}from"../util/window-utils.js";import{getUser as Q}from"./get-user.js";export function _handleBrazeAction(a,s,i){if(e.rr())if(O.test(a)){const e=J(a);if(!e)return;const s=async e=>{if(!P(e))return void r.D.error(`Decoded Braze Action json is invalid: ${JSON.stringify(e,null,2)}`);const a=e[_.properties.type];if(a===_.types.ue)for(const r of e[_.properties.me])s(r);else{const s=e[_.properties.fe];let i,o;switch(a){case _.types.logCustomEvent:i=await import("./log-custom-event.js"),i.logCustomEvent.apply(null,Array.prototype.slice.call(s));break;case _.types.requestPushPermission:i=await import("../Push/request-push-permission.js"),i.requestPushPermission();break;case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:o=Q(),o[a].apply(o,Array.prototype.slice.call(s));break;case _.types.de:case _.types.pe:H.openUri.apply(null,Array.prototype.slice.call(s));break;default:r.D.info(`Ignoring unknown Braze Action: ${a}`)}}};s(e)}else H.openUri(a,i,s)}export function handleBrazeAction(e,r){_handleBrazeAction(e,r)}
@@ -1 +1 @@
1
- import A,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function isDisabled(){return!!new A.ne(null,!0).lr(o.ae)}
1
+ import G,{STORAGE_KEYS as o}from"../managers/storage-manager.js";export function isDisabled(){return!!new G.ne(null,!0).lr(o.ae)}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import s from"../common/event-logger.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";import{validateCustomProperties as W,validateCustomString as X}from"../util/validation-utils.js";export function logCustomEvent(t,o){if(!e.rr())return!1;if(null==t||t.length<=0)return r.D.error(`logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`),!1;if(!X(t,"log custom event","the event name"))return!1;const[n,i]=W(o,"logCustomEvent","eventProperties",`log custom event "${t}"`,"event");if(!n)return!1;if(e.ir().ge(t))return r.D.info(`Custom Event "${t}" is blocklisted, ignoring.`),!1;const m=s.G(r.A.CustomEvent,{n:t,p:i});if(m.S){r.D.info(`Logged custom event "${t}".`);for(const e of m.ve)V.er().je(Q.be,[t,o],e)}return m.S}
1
+ import e from"../managers/braze-instance.js";import s from"../common/event-logger.js";import r from"../../shared-lib/braze-shared-lib.js";import V from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";import{validateCustomProperties as X,validateCustomString as Y}from"../util/validation-utils.js";export function logCustomEvent(t,o){if(!e.rr())return!1;if(null==t||t.length<=0)return r.D.error(`logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`),!1;if(!Y(t,"log custom event","the event name"))return!1;const[n,i]=X(o,"logCustomEvent","eventProperties",`log custom event "${t}"`,"event");if(!n)return!1;if(e.ir().ge(t))return r.D.info(`Custom Event "${t}" is blocklisted, ignoring.`),!1;const m=s.G(r.A.CustomEvent,{n:t,p:i});if(m.S){r.D.info(`Logged custom event "${t}".`);for(const e of m.ve)W.er().je(V.be,[t,o],e)}return m.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import{MAX_PURCHASE_QUANTITY as Z}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";import{validateCustomProperties as W,validateCustomString as X}from"../util/validation-utils.js";import s from"../common/event-logger.js";export function logPurchase(o,i,t,n,D){if(!e.rr())return!1;if(null==t&&(t="USD"),null==n&&(n=1),null==o||o.length<=0)return r.D.error(`logPurchase requires a non-empty productId, got "${o}", ignoring.`),!1;if(!X(o,"log purchase","the purchase name"))return!1;let a=parseFloat(i);if(isNaN(a))return r.D.error(`logPurchase requires a numeric price, got ${i}, ignoring.`),!1;a=a.toFixed(2);const g=parseInt(n);if(isNaN(g))return r.D.error(`logPurchase requires an integer quantity, got ${n}, ignoring.`),!1;if(g<1||g>Z)return r.D.error(`logPurchase requires a quantity >1 and <${Z}, got ${g}, ignoring.`),!1;t=t.toUpperCase();if(-1===["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTC","BTN","BWP","BYR","BZD","CAD","CDF","CHF","CLF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EEK","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LTL","LVL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRO","MTL","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XAG","XAU","XCD","XDR","XOF","XPD","XPF","XPT","YER","ZAR","ZMK","ZMW","ZWL"].indexOf(t))return r.D.error(`logPurchase requires a valid currencyCode, got ${t}, ignoring.`),!1;const[u,P]=W(D,"logPurchase","purchaseProperties",`log purchase "${o}"`,"purchase");if(!u)return!1;if(e.ir().Dr(o))return r.D.info(`Purchase "${o}" is blocklisted, ignoring.`),!1;const R=s.G(r.A.Pr,{pid:o,c:t,p:a,q:g,pr:P});if(R.S){r.D.info(`Logged ${g} purchase${g>1?"s":""} of "${o}" for ${t} ${a}.`);for(const r of R.ve)V.er().je(Q.Rr,[o,D],r)}return R.S}
1
+ import e from"../managers/braze-instance.js";import{MAX_PURCHASE_QUANTITY as Z}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import V from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";import{validateCustomProperties as X,validateCustomString as Y}from"../util/validation-utils.js";import s from"../common/event-logger.js";export function logPurchase(o,i,t,n,D){if(!e.rr())return!1;if(null==t&&(t="USD"),null==n&&(n=1),null==o||o.length<=0)return r.D.error(`logPurchase requires a non-empty productId, got "${o}", ignoring.`),!1;if(!Y(o,"log purchase","the purchase name"))return!1;let a=parseFloat(i);if(isNaN(a))return r.D.error(`logPurchase requires a numeric price, got ${i}, ignoring.`),!1;a=a.toFixed(2);const g=parseInt(n);if(isNaN(g))return r.D.error(`logPurchase requires an integer quantity, got ${n}, ignoring.`),!1;if(g<1||g>Z)return r.D.error(`logPurchase requires a quantity >1 and <${Z}, got ${g}, ignoring.`),!1;t=t.toUpperCase();if(-1===["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTC","BTN","BWP","BYR","BZD","CAD","CDF","CHF","CLF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EEK","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LTL","LVL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRO","MTL","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XAG","XAU","XCD","XDR","XOF","XPD","XPF","XPT","YER","ZAR","ZMK","ZMW","ZWL"].indexOf(t))return r.D.error(`logPurchase requires a valid currencyCode, got ${t}, ignoring.`),!1;const[u,P]=X(D,"logPurchase","purchaseProperties",`log purchase "${o}"`,"purchase");if(!u)return!1;if(e.ir().Dr(o))return r.D.info(`Purchase "${o}" is blocklisted, ignoring.`),!1;const R=s.G(r.A.Pr,{pid:o,c:t,p:a,q:g,pr:P});if(R.S){r.D.info(`Logged ${g} purchase${g>1?"s":""} of "${o}" for ${t} ${a}.`);for(const r of R.ve)W.er().je(V.Rr,[o,D],r)}return R.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function openSession(){if(!e.rr())return;e.mr().openSession();const i=r.xt.Ft,o=new r.qt(i,r.D);o.hr(i.$t.jr,(function(t,n){const s=n.lastClick,c=n.trackingString;r.D.info(`Firing push click trigger from ${c} push click at ${s}`);const g=e.mr().kr(s,c),f=function(){V.er().je(Q.vr,[c],g)};e.mr().zr(f,f),o.br(i.$t.jr,t)})),o.Jt(i.$t.$r,(function(r){e.mr().wr(r)}))}
1
+ import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";import V from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";export function openSession(){if(!e.rr())return;e.mr().openSession();const i=r.xt.Ft,o=new r.qt(i,r.D);o.hr(i.$t.jr,(function(t,n){const s=n.lastClick,c=n.trackingString;r.D.info(`Firing push click trigger from ${c} push click at ${s}`);const g=e.mr().kr(s,c),f=function(){W.er().je(V.vr,[c],g)};e.mr().zr(f,f),o.br(i.$t.jr,t)})),o.Jt(i.$t.$r,(function(r){e.mr().wr(r)}))}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import{validateStandardString as R}from"../util/validation-utils.js";export function setSdkAuthenticationSignature(t){return!!e.rr()&&(!(""===t||!R(t,"set signature","signature",!1))&&(e.ti().setSdkAuthenticationSignature(t),!0))}
1
+ import e from"../managers/braze-instance.js";import{validateStandardString as R}from"../util/validation-utils.js";export function setSdkAuthenticationSignature(t){return!!e.rr()&&(!(""===t||!R(t,"set signature","signature",!1))&&(e.ii().setSdkAuthenticationSignature(t),!0))}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";export function subscribeToSdkAuthenticationFailures(r){if(e.rr())return e.ti().subscribeToSdkAuthenticationFailures(r)}
1
+ import e from"../managers/braze-instance.js";export function subscribeToSdkAuthenticationFailures(r){if(e.rr())return e.ii().subscribeToSdkAuthenticationFailures(r)}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import{keys as Y}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function wipeData(){if(null==e.l())throw new Error("Braze must be initialized before calling methods.");e.l().clearData();const o=Y(r.xt);for(let e=0;e<o.length;e++){const i=o[e],t=r.xt[i];new r.qt(t,r.D).clearData()}if(e.rr())for(const r of e.re())r.clearData(!0)}
1
+ import e from"../managers/braze-instance.js";import{keys as rr}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function wipeData(){if(null==e.l())throw new Error("Braze must be initialized before calling methods.");e.l().clearData();const o=rr(r.xt);for(let e=0;e<o.length;e++){const i=o[e],t=r.xt[i];new r.qt(t,r.D).clearData()}if(e.rr())for(const r of e.re())r.clearData(!0)}
@@ -1 +1 @@
1
- import C from"../common/base-provider.js";import e from"../managers/braze-instance.js";import Feed from"./feed.js";import{newCardFromFeedJson as tt,newCardFromSerializedValue as _}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 C{constructor(t,s){super(),this.h=t,this.Vs=s,this.vt=new u,e.yt(this.vt),this.zt()}zt(){const t=this.h.I(o.q.Ws)||[],s=[];for(let i=0;i<t.length;i++){const e=_(t[i]);null!=e&&s.push(e)}this.Yt=s,this.Xs=w(this.h.I(o.q.Ys))}Zs(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.Yt=s,this._s(),this.Xs=new Date,this.h.B(o.q.Ys,this.Xs)}_s(){const t=[];for(let s=0;s<this.Yt.length;s++)t.push(this.Yt[s].ss());this.h.B(o.q.Ws,t)}ys(t){null!=t&&t.feed&&(this.zt(),this.Zs(t.feed),this.vt.St(new Feed(this.Yt.slice(),this.Xs)))}si(){this.zt();const t=[],s=new Date;for(let i=0;i<this.Yt.length;i++)(null==this.Yt[i].expiresAt||this.Yt[i].expiresAt>=s)&&t.push(this.Yt[i]);return new Feed(t,this.Xs)}Fs(){this.Vs.requestFeedRefresh()}Hs(t){return this.vt.ut(t)}clearData(t){null==t&&(t=!1),this.Yt=[],this.Xs=null,t&&(this.h.Is(o.q.Ws),this.h.Is(o.q.Ys)),this.vt.St(new Feed(this.Yt.slice(),this.Xs))}}
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 +1 @@
1
- import e from"../managers/braze-instance.js";import re from"./feed-provider-factory.js";export function getCachedFeed(){if(e.rr())return re.er().si()}
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 +1 @@
1
- import e from"../managers/braze-instance.js";import re from"./feed-provider-factory.js";export function requestFeedRefresh(){if(e.rr())return re.er().Fs()}
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 +1 @@
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().Hs(r)}
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 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";import{destroyFeedHtml as z,detectFeedImpressions as T,feedToHtml as N,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as q,refreshFeed as I,registerFeedSubscriptionId as L,updateFeedCards as M}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 $}from"../../Card/display/card-display.js";import{setupFeedUI as k}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showFeed(t,n,o){if(!e.rr())return;k();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(D.tn)||e.nn(D.en)||!1;let l=!1;null==t&&(t=document.body,l=!0);let a=!1,f=null;null==n?(f=re.er().si(),M(f,s(f.cards,o),f.lastUpdated,null,i),a=!0):f=new Feed(s(n,o),new Date);const u=N(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.`),I(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(q));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))}M(f,s(t.cards,o),t.lastUpdated,u,i)}));L(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(),T(f,u),$(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";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 +1 @@
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 H}from"../../Core/get-user.js";import{InAppMessage}from"../index.js";import{keys as Y}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 G}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),G.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 Y(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=H();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 Y(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 Y(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";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 +1 @@
1
- import b from"../util/net.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import HtmlMessage from"./models/html-message.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import s from"../common/event-logger.js";import{newInAppMessageFromJson as it}from"./in-app-message-factory.js";import{randomInclusive as lt}from"../util/math.js";import t from"../models/request-result.js";import r from"../../shared-lib/braze-shared-lib.js";import u from"../managers/subscription-manager.js";import ut from"../triggers/models/trigger.js";import{validateValueIsFromEnum as K}from"../util/code-utils.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{containsPushPrimerBrazeAction as pt,containsUnknownBrazeAction as mt,getDecodedBrazeAction as O,ineligibleBrazeActionURLErrorMessage as ct,INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt}from"../util/braze-actions.js";export default class ge{constructor(t,s,i,r){this.jt=t,this.j=s,this.h=i,this.v=r,this.De=new u,e.yt(this.De),this._e=1e3,this.Se=6e4}Be(){return this.De}Ee(t){return this.De.ut(t)}Fe(){return this.Ge}Ne(t){this.Ge=t}qe(e,i){if(!K(InAppMessage.Oe,i,`${i} is not a valid in-app message display failure`,"InAppMessage.DisplayFailures"))return new t;const n={trigger_ids:[e],error_code:i};return s.G(r.A.Pe,n)}G(e,i,n,o){const a=new t;let l;if(e instanceof ControlMessage)l={trigger_ids:[e.triggerId]};else{if(i===r.A.Re||e instanceof HtmlMessage&&i===r.A.He){if(!e.k(o))return r.D.info("This in-app message has already received a click. Ignoring analytics event."),a}else if(i===r.A.Je){if(!e.R())return r.D.info("This in-app message has already received an impression. Ignoring analytics event."),a}l=this.Ke(e)}return null==l?a:(null!=n&&(l.bid=n),s.G(i,l))}Qe(e,i){const n=new t;if(!e.k())return r.D.info("This in-app message button has already received a click. Ignoring analytics event."),n;const o=this.Ke(i);return null==o?n:e.id===InAppMessageButton.Ue?(r.D.info("This in-app message button does not have a tracking id. Not logging event to Braze servers."),n):(null!=e.id&&(o.bid=e.id),s.G(r.A.He,o))}async Ve(t){if(!(t instanceof InAppMessage))return;const e=async t=>{const e=O(t);return mt(e)?ct(gt.We,"In-App Message"):pt(e)?import("../Push/push-manager-factory.js").then((t=>{const e=t.default.Xe();if(null!=e&&!e.Ye())return ct(gt.Ze,"In-App Message")})):void 0},s=t.buttons;let i;for(const t of s)if(t.clickAction===InAppMessage.ClickAction.URI&&P.test(t.uri)&&(i=await e(t.uri),i))return i;return t.clickAction===InAppMessage.ClickAction.URI&&P.test(t.uri)?e(t.uri):void 0}ei(t,e,s,i){let n=this.jt.ii(!1,!1);n=this.jt.As(n),n.template={trigger_id:t.triggerId,trigger_event_type:e},null!=s&&(n.template.data=s.ri());const o=this.jt.qs(n);this.jt.Es(n,(()=>{b.Ms({url:`${this.jt.Ps()}/template/`,data:n,headers:o,S:async e=>{if(!this.jt.$s(n,e,o))return this.qe(t.triggerId,InAppMessage.Oe.ni),void("function"==typeof t.oi&&t.oi());if(this.jt.Bs(),null==e||null==e.templated_message)return void this.qe(t.triggerId,InAppMessage.Oe.ni);const s=e.templated_message;if(s.type!==ut.li.ai)return void this.qe(t.triggerId,InAppMessage.Oe.ui);const i=it(s.data);if(null==i)return void this.qe(t.triggerId,InAppMessage.Oe.ui);let a=await this.Ve(i);if(a)return r.D.error(a),void("function"==typeof t.oi&&t.oi());"function"==typeof t.pi?t.pi(i):this.qe(t.triggerId,InAppMessage.Oe.ni)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.mi>t.ci)this.qe(t.triggerId,InAppMessage.Oe.ni);else{const r=Math.min(t.ci,this.Se),o=this._e;null==i&&(i=o);const a=Math.min(r,lt(o,3*i));n+=`. Retrying in ${a} ms`,setTimeout((()=>{this.ei(t,e,s,a)}),a)}this.jt.Gs(r,n)}})}))}Ke(t){if(null==t.triggerId)return r.D.info("The in-app message has no analytics id. Not logging event to Braze servers."),null;const e={};return null!=t.triggerId&&(e.trigger_ids=[t.triggerId]),e}}
1
+ import b from"../util/net.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import HtmlMessage from"./models/html-message.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import s from"../common/event-logger.js";import{newInAppMessageFromJson as it}from"./in-app-message-factory.js";import{randomInclusive as lt}from"../util/math.js";import t from"../models/request-result.js";import r from"../../shared-lib/braze-shared-lib.js";import u from"../managers/subscription-manager.js";import ut from"../triggers/models/trigger.js";import{validateValueIsFromEnum as F}from"../util/code-utils.js";import{BRAZE_ACTION_URI_REGEX as O}from"../util/validation-utils.js";import{containsPushPrimerBrazeAction as pt,containsUnknownBrazeAction as mt,getDecodedBrazeAction as J,ineligibleBrazeActionURLErrorMessage as ct,INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt}from"../util/braze-actions.js";export default class ge{constructor(t,s,i,r){this.vt=t,this.j=s,this.h=i,this.v=r,this.De=new u,e.jt(this.De),this._e=1e3,this.Se=6e4}Be(){return this.De}Ee(t){return this.De.ut(t)}Fe(){return this.Ge}Ne(t){this.Ge=t}qe(e,i){if(!F(InAppMessage.Oe,i,`${i} is not a valid in-app message display failure`,"InAppMessage.DisplayFailures"))return new t;const n={trigger_ids:[e],error_code:i};return s.G(r.A.Pe,n)}G(e,i,n,o){const a=new t;let l;if(e instanceof ControlMessage)l={trigger_ids:[e.triggerId]};else{if(i===r.A.Re||e instanceof HtmlMessage&&i===r.A.He){if(!e.k(o))return r.D.info("This in-app message has already received a click. Ignoring analytics event."),a}else if(i===r.A.Je){if(!e.R())return r.D.info("This in-app message has already received an impression. Ignoring analytics event."),a}l=this.Ke(e)}return null==l?a:(null!=n&&(l.bid=n),s.G(i,l))}Qe(e,i){const n=new t;if(!e.k())return r.D.info("This in-app message button has already received a click. Ignoring analytics event."),n;const o=this.Ke(i);return null==o?n:e.id===InAppMessageButton.Ue?(r.D.info("This in-app message button does not have a tracking id. Not logging event to Braze servers."),n):(null!=e.id&&(o.bid=e.id),s.G(r.A.He,o))}async Ve(t){if(!(t instanceof InAppMessage))return;const e=async t=>{const e=J(t);return mt(e)?ct(gt.We,"In-App Message"):pt(e)?import("../Push/push-manager-factory.js").then((t=>{const e=t.default.Xe();if(null!=e&&!e.Ye())return ct(gt.Ze,"In-App Message")})):void 0},s=t.buttons;let i;for(const t of s)if(t.clickAction===InAppMessage.ClickAction.URI&&O.test(t.uri)&&(i=await e(t.uri),i))return i;return t.clickAction===InAppMessage.ClickAction.URI&&O.test(t.uri)?e(t.uri):void 0}ni(t,e,s,i){let n=this.vt.li(!1,!1);n=this.vt.Ps(n),n.template={trigger_id:t.triggerId,trigger_event_type:e},null!=s&&(n.template.data=s.ui());const o=this.vt.Bs(n);this.vt.Gs(n,(()=>{b.Hs({url:`${this.vt.Ks()}/template/`,data:n,headers:o,S:async e=>{if(!this.vt.Os(n,e,o))return this.qe(t.triggerId,InAppMessage.Oe.pi),void("function"==typeof t.mi&&t.mi());if(this.vt.Qs(),null==e||null==e.templated_message)return void this.qe(t.triggerId,InAppMessage.Oe.pi);const s=e.templated_message;if(s.type!==ut.gi.ci)return void this.qe(t.triggerId,InAppMessage.Oe.fi);const i=it(s.data);if(null==i)return void this.qe(t.triggerId,InAppMessage.Oe.fi);let a=await this.Ve(i);if(a)return r.D.error(a),void("function"==typeof t.mi&&t.mi());"function"==typeof t.di?t.di(i):this.qe(t.triggerId,InAppMessage.Oe.pi)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.vi>t.yi)this.qe(t.triggerId,InAppMessage.Oe.pi);else{const r=Math.min(t.yi,this.Se),o=this._e;null==i&&(i=o);const a=Math.min(r,lt(o,3*i));n+=`. Retrying in ${a} ms`,setTimeout((()=>{this.ni(t,e,s,a)}),a)}this.vt.Vs(r,n)}})}))}Ke(t){if(null==t.triggerId)return r.D.info("The in-app message has no analytics id. Not logging event to Braze servers."),null;const e={};return null!=t.triggerId&&(e.trigger_ids=[t.triggerId]),e}}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageButtonClick(t,o){if(!e.rr())return!1;if(!(t instanceof InAppMessageButton))return r.D.error("button must be an InAppMessageButton object"),!1;if(!(o instanceof InAppMessage))return r.D.error(rr),!1;const s=pe.m().Qe(t,o);if(s.S)for(let r=0;r<s.ve.length;r++)V.er().je(Q.Ar,[o.triggerId,t.id],s.ve[r]);return s.S}
1
+ import e from"../managers/braze-instance.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as tr}from"../common/constants.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import V from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";export function logInAppMessageButtonClick(t,o){if(!e.rr())return!1;if(!(t instanceof InAppMessageButton))return r.D.error("button must be an InAppMessageButton object"),!1;if(!(o instanceof InAppMessage))return r.D.error(tr),!1;const s=pe.m().Qe(t,o);if(s.S)for(let r=0;r<s.ve.length;r++)W.er().je(V.Ar,[o.triggerId,t.id],s.ve[r]);return s.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageClick(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage))return r.D.error(rr),!1;const s=pe.m().G(o,r.A.Re);if(s)for(let r=0;r<s.ve.length;r++)V.er().je(Q.Ar,[o.triggerId],s.ve[r]);return s.S}
1
+ import e from"../managers/braze-instance.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as tr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";import V from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";export function logInAppMessageClick(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage))return r.D.error(tr),!1;const s=pe.m().G(o,r.A.Re);if(s)for(let r=0;r<s.ve.length;r++)W.er().je(V.Ar,[o.triggerId],s.ve[r]);return s.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import HtmlMessage from"./models/html-message.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import Q from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";export function logInAppMessageHtmlClick(s,t,o){if(!e.rr())return!1;if(!(s instanceof HtmlMessage))return r.D.error("inAppMessage argument to logInAppMessageHtmlClick must be an HtmlMessage object."),!1;let m=r.A.Re;null!=t&&(m=r.A.He);const i=pe.m().G(s,m,t,o);if(i.S)for(let r=0;r<i.ve.length;r++)V.er().je(Q.Ar,[s.triggerId,t],i.ve[r]);return i.S}
1
+ import e from"../managers/braze-instance.js";import HtmlMessage from"./models/html-message.js";import pe from"./in-app-message-manager-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import V from"../triggers/models/trigger-events.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";export function logInAppMessageHtmlClick(s,t,o){if(!e.rr())return!1;if(!(s instanceof HtmlMessage))return r.D.error("inAppMessage argument to logInAppMessageHtmlClick must be an HtmlMessage object."),!1;let m=r.A.Re;null!=t&&(m=r.A.He);const i=pe.m().G(s,m,t,o);if(i.S)for(let r=0;r<i.ve.length;r++)W.er().je(V.Ar,[s.triggerId,t],i.ve[r]);return i.S}
@@ -1 +1 @@
1
- import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as rr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";export function logInAppMessageImpression(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage||o instanceof ControlMessage))return r.D.error(rr),!1;const s=o instanceof ControlMessage?r.A.ro:r.A.Je;return pe.m().G(o,s).S}
1
+ import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import InAppMessage from"./models/in-app-message.js";import pe from"./in-app-message-manager-factory.js";import{MUST_BE_IN_APP_MESSAGE_WARNING as tr}from"../common/constants.js";import r from"../../shared-lib/braze-shared-lib.js";export function logInAppMessageImpression(o){if(!e.rr())return!1;if(!(o instanceof InAppMessage||o instanceof ControlMessage))return r.D.error(tr),!1;const s=o instanceof ControlMessage?r.A.ro:r.A.Je;return pe.m().G(o,s).S}
@@ -1 +1 @@
1
- import InAppMessage from"./in-app-message.js";import u from"../../managers/subscription-manager.js";export default class InAppMessageButton{constructor(s,t,i,r,e,h,n){this.text=s||"",this.backgroundColor=t||InAppMessage.bi.hi,this.textColor=i||InAppMessage.bi.fi,this.borderColor=r||this.backgroundColor,this.clickAction=e||InAppMessage.ClickAction.NONE,this.uri=h,null==n&&(n=InAppMessageButton.Ue),this.id=n,this.nl=!1,this.lt=new u}subscribeToClickedEvent(s){return this.lt.ut(s)}removeSubscription(s){this.lt.removeSubscription(s)}removeAllSubscriptions(){this.lt.removeAllSubscriptions()}k(){return!this.nl&&(this.nl=!0,this.lt.St(),!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.Ue=-1;
1
+ import InAppMessage from"./in-app-message.js";import u from"../../managers/subscription-manager.js";export default class InAppMessageButton{constructor(s,t,i,r,e,h,n){this.text=s||"",this.backgroundColor=t||InAppMessage.ji.bi,this.textColor=i||InAppMessage.ji.ki,this.borderColor=r||this.backgroundColor,this.clickAction=e||InAppMessage.ClickAction.NONE,this.uri=h,null==n&&(n=InAppMessageButton.Ue),this.id=n,this.nl=!1,this.lt=new u}subscribeToClickedEvent(s){return this.lt.ut(s)}removeSubscription(s){this.lt.removeSubscription(s)}removeAllSubscriptions(){this.lt.removeAllSubscriptions()}k(){return!this.nl&&(this.nl=!0,this.lt.St(),!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.Ue=-1;
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";import et from"../../util/browser-detector.js";import{clickElement as ht,supportsPassive as Et}from"../../util/dom-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import u from"../../managers/subscription-manager.js";export default class InAppMessage{constructor(t,s,i,e,h,n,r,o,l,E,T,a,m,c,I,A,N,_,L,d,O,S,D,M,R,b,P,C,U){this.message=t,this.messageAlignment=s||InAppMessage.TextAlignment.CENTER,this.duration=E||5e3,this.slideFrom=i||InAppMessage.SlideFrom.BOTTOM,this.extras=e||{},this.triggerId=h,this.clickAction=n||InAppMessage.ClickAction.NONE,this.uri=r,this.openTarget=o||InAppMessage.OpenTarget.NONE,this.dismissType=l||InAppMessage.DismissType.AUTO_DISMISS,this.icon=T,this.imageUrl=a,this.imageStyle=m||InAppMessage.ImageStyle.TOP,this.iconColor=c||InAppMessage.bi.fi,this.iconBackgroundColor=I||InAppMessage.bi.hi,this.backgroundColor=A||InAppMessage.bi.fi,this.textColor=N||InAppMessage.bi.Ei,this.closeButtonColor=_||InAppMessage.bi.Ti,this.animateIn=L,null==this.animateIn&&(this.animateIn=!0),this.animateOut=d,null==this.animateOut&&(this.animateOut=!0),this.header=O,this.headerAlignment=S||InAppMessage.TextAlignment.CENTER,this.headerTextColor=D||InAppMessage.bi.Ei,this.frameColor=M||InAppMessage.bi.Ii,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ai=!1,this.nl=!1,this.Ni=!1,this.lt=new u,this._i=new u}subscribeToClickedEvent(t){return this.lt.ut(t)}subscribeToDismissedEvent(t){return this._i.ut(t)}removeSubscription(t){this.lt.removeSubscription(t),this._i.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this._i.removeAllSubscriptions()}closeMessage(){this.on(this.mn)}we(){return!0}ll(){return this.we()}an(){return null!=this.htmlId&&this.htmlId.length>4}sn(){return this.an()&&null!=this.css&&this.css.length>0}rn(){if(this.an()&&this.sn())return this.htmlId+"-css"}R(){return!this.Ai&&(this.Ai=!0,!0)}k(){return!this.nl&&(this.nl=!0,this.lt.St(),!0)}J(){return!this.Ni&&(this.Ni=!0,this._i.St(),!0)}Li(t){if(t&&t.parentNode){let s=t.closest(".ab-iam-root");if(null==s&&(s=t),this.we()&&null!=s.parentNode){const t=s.parentNode.classList;t&&t.contains(InAppMessage.di)&&t.remove(InAppMessage.di),document.body.removeEventListener("touchmove",InAppMessage.Oi)}s.className=s.className.replace(InAppMessage.Si,InAppMessage._)}return this.animateOut}on(t,s){if(null==t)return;let i;this.mn=null,i=-1===t.className.indexOf("ab-in-app-message")?t.getElementsByClassName("ab-in-app-message")[0]:t;let e=!1;i&&(e=this.Li(i));const h=document.body;if(null!=h)var n=h.scrollTop;const r=()=>{if(t&&t.parentNode){let s=t.closest(".ab-iam-root");null==s&&(s=t),s.parentNode&&s.parentNode.removeChild(s)}if(null!=this.rn()){const t=document.getElementById(this.rn());t&&t.parentNode&&t.parentNode.removeChild(t)}null!=h&&"Safari"===et.browser&&(h.scrollTop=n),s?s():this.J()};e?setTimeout(r,InAppMessage.Di):r(),this.he&&this.he.focus()}Me(){return document.createTextNode(this.message)}xe(t){let s="";this.message||this.header||!this.we()||(s="Modal Image"),t.setAttribute("alt",s)}static Oi(t){t.targetTouches&&t.targetTouches.length>1||t.target.classList&&t.target.classList.contains("ab-message-text")&&t.target.scrollHeight>t.target.clientHeight||document.querySelector(`.${InAppMessage.di}`)&&t.preventDefault()}Mi(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage.di),document.body.addEventListener("touchmove",InAppMessage.Oi,!!Et()&&{passive:!1})),t.className+=" "+InAppMessage.Si}static Ri(t){if(t.keyCode===at.Pi&&!e.nn(D.Ci)&&document.querySelectorAll(".ab-modal-interactions").length>0){const t=document.getElementsByClassName("ab-html-message");let s=!1;for(let i=0;i<t.length;i++){const e=t[i].contentWindow.document.getElementsByClassName("ab-programmatic-close-button")[0];null!=e&&(ht(e),s=!0)}if(!s){const t=document.querySelectorAll(".ab-modal-interactions > .ab-close-button")[0];null!=t&&ht(t)}}}Ui(){this.gi||e.nn(D.Ci)||(document.addEventListener("keydown",InAppMessage.Ri,!1),e.Hi((()=>{document.removeEventListener("keydown",InAppMessage.Ri)})),this.gi=!0)}}InAppMessage.bi={Ei:4281545523,fi:4294967295,hi:4278219733,Fi:4293914607,Bi:4283782485,Ii:3224580915,Ti:4288387995},InAppMessage.Oe={vi:"hd",Gi:"ias",Wi:"of",ki:"do",ui:"umt",ni:"tf",wi:"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.es={ji:"SLIDEUP",yi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",el:"WEB_HTML",cn:"HTML"},InAppMessage.Di=500,InAppMessage.xi=200,InAppMessage.Si="ab-show",InAppMessage.Ki="ab-hide",InAppMessage.di="ab-pause-scrolling";
1
+ import e,{OPTIONS as T}from"../../managers/braze-instance.js";import et from"../../util/browser-detector.js";import{clickElement as ht,supportsPassive as Et}from"../../util/dom-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import u from"../../managers/subscription-manager.js";export default class InAppMessage{constructor(t,s,i,e,h,n,r,o,l,E,T,a,m,c,I,A,N,_,L,d,O,S,D,M,R,b,P,C,U){this.message=t,this.messageAlignment=s||InAppMessage.TextAlignment.CENTER,this.duration=E||5e3,this.slideFrom=i||InAppMessage.SlideFrom.BOTTOM,this.extras=e||{},this.triggerId=h,this.clickAction=n||InAppMessage.ClickAction.NONE,this.uri=r,this.openTarget=o||InAppMessage.OpenTarget.NONE,this.dismissType=l||InAppMessage.DismissType.AUTO_DISMISS,this.icon=T,this.imageUrl=a,this.imageStyle=m||InAppMessage.ImageStyle.TOP,this.iconColor=c||InAppMessage.ji.ki,this.iconBackgroundColor=I||InAppMessage.ji.bi,this.backgroundColor=A||InAppMessage.ji.ki,this.textColor=N||InAppMessage.ji.Ei,this.closeButtonColor=_||InAppMessage.ji.Ti,this.animateIn=L,null==this.animateIn&&(this.animateIn=!0),this.animateOut=d,null==this.animateOut&&(this.animateOut=!0),this.header=O,this.headerAlignment=S||InAppMessage.TextAlignment.CENTER,this.headerTextColor=D||InAppMessage.ji.Ei,this.frameColor=M||InAppMessage.ji.Ii,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ai=!1,this.nl=!1,this.Ni=!1,this.lt=new u,this._i=new u}subscribeToClickedEvent(t){return this.lt.ut(t)}subscribeToDismissedEvent(t){return this._i.ut(t)}removeSubscription(t){this.lt.removeSubscription(t),this._i.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this._i.removeAllSubscriptions()}closeMessage(){this.on(this.mn)}we(){return!0}ll(){return this.we()}an(){return null!=this.htmlId&&this.htmlId.length>4}sn(){return this.an()&&null!=this.css&&this.css.length>0}rn(){if(this.an()&&this.sn())return this.htmlId+"-css"}R(){return!this.Ai&&(this.Ai=!0,!0)}k(){return!this.nl&&(this.nl=!0,this.lt.St(),!0)}J(){return!this.Ni&&(this.Ni=!0,this._i.St(),!0)}Li(t){if(t&&t.parentNode){let s=t.closest(".ab-iam-root");if(null==s&&(s=t),this.we()&&null!=s.parentNode){const t=s.parentNode.classList;t&&t.contains(InAppMessage.Oi)&&t.remove(InAppMessage.Oi),document.body.removeEventListener("touchmove",InAppMessage.Si)}s.className=s.className.replace(InAppMessage.Di,InAppMessage._)}return this.animateOut}on(t,s){if(null==t)return;let i;this.mn=null,i=-1===t.className.indexOf("ab-in-app-message")?t.getElementsByClassName("ab-in-app-message")[0]:t;let e=!1;i&&(e=this.Li(i));const h=document.body;if(null!=h)var n=h.scrollTop;const r=()=>{if(t&&t.parentNode){let s=t.closest(".ab-iam-root");null==s&&(s=t),s.parentNode&&s.parentNode.removeChild(s)}if(null!=this.rn()){const t=document.getElementById(this.rn());t&&t.parentNode&&t.parentNode.removeChild(t)}null!=h&&"Safari"===et.browser&&(h.scrollTop=n),s?s():this.J()};e?setTimeout(r,InAppMessage.Mi):r(),this.he&&this.he.focus()}Me(){return document.createTextNode(this.message)}xe(t){let s="";this.message||this.header||!this.we()||(s="Modal Image"),t.setAttribute("alt",s)}static Si(t){t.targetTouches&&t.targetTouches.length>1||t.target.classList&&t.target.classList.contains("ab-message-text")&&t.target.scrollHeight>t.target.clientHeight||document.querySelector(`.${InAppMessage.Oi}`)&&t.preventDefault()}Ri(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage.Oi),document.body.addEventListener("touchmove",InAppMessage.Si,!!Et()&&{passive:!1})),t.className+=" "+InAppMessage.Di}static Pi(t){if(t.keyCode===at.Ci&&!e.nn(T.Ui)&&document.querySelectorAll(".ab-modal-interactions").length>0){const t=document.getElementsByClassName("ab-html-message");let s=!1;for(let i=0;i<t.length;i++){const e=t[i].contentWindow.document.getElementsByClassName("ab-programmatic-close-button")[0];null!=e&&(ht(e),s=!0)}if(!s){const t=document.querySelectorAll(".ab-modal-interactions > .ab-close-button")[0];null!=t&&ht(t)}}}Hi(){this.Fi||e.nn(T.Ui)||(document.addEventListener("keydown",InAppMessage.Pi,!1),e.Bi((()=>{document.removeEventListener("keydown",InAppMessage.Pi)})),this.Fi=!0)}}InAppMessage.ji={Ei:4281545523,ki:4294967295,bi:4278219733,Gi:4293914607,Wi:4283782485,Ii:3224580915,Ti:4288387995},InAppMessage.Oe={wi:"hd",xi:"ias",Ki:"of",Yi:"do",fi:"umt",pi:"tf",Xi:"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.es={zi:"SLIDEUP",Vi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",el:"WEB_HTML",cn:"HTML"},InAppMessage.Mi=500,InAppMessage.$i=200,InAppMessage.Di="ab-show",InAppMessage.qi="ab-hide",InAppMessage.Oi="ab-pause-scrolling";
@@ -1 +1 @@
1
- import InAppMessage from"./in-app-message.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,s,n,l,o,u,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,s,n,l,o,u=u||InAppMessage.DismissType.MANUAL,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get ke(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.yi;
1
+ import InAppMessage from"./in-app-message.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,s,n,l,o,u,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,s,n,l,o,u=u||InAppMessage.DismissType.MANUAL,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get ke(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.Vi;
@@ -1 +1 @@
1
- import InAppMessage from"./in-app-message.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,r,d,u,a,p,l,m,c,v,x,g,f,h,I,M){x=x||InAppMessage.bi.Bi,v=v||InAppMessage.bi.Fi,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,r,d,u,a,p,l,null,m,c,v,x,g,f,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get ke(){return InAppMessage.TextAlignment.START}Me(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}Mi(t){const e=t.getElementsByClassName("ab-in-app-message")[0];dt.eo(e,!0,!0)||(this.slideFrom===InAppMessage.SlideFrom.TOP?e.style.top="0px":e.style.bottom="0px"),super.Mi(t)}}SlideUpMessage.es=InAppMessage.es.ji;
1
+ import InAppMessage from"./in-app-message.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,r,d,u,a,p,l,m,c,v,x,g,f,h,I,M){x=x||InAppMessage.ji.Wi,v=v||InAppMessage.ji.Gi,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,r,d,u,a,p,l,null,m,c,v,x,g,f,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get ke(){return InAppMessage.TextAlignment.START}Me(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}Ri(t){const e=t.getElementsByClassName("ab-in-app-message")[0];dt.eo(e,!0,!0)||(this.slideFrom===InAppMessage.SlideFrom.TOP?e.style.top="0px":e.style.bottom="0px"),super.Ri(t)}}SlideUpMessage.es=InAppMessage.es.zi;
@@ -1 +1 @@
1
- export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.pi=s,this.oi=l,this.mi=n,this.ci=i}static fromJson(t,s,l,n,i){return null==t||null==t.trigger_id?null:new ft(t.trigger_id,s,l,n,i)}}
1
+ export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.di=s,this.mi=l,this.vi=n,this.yi=i}static fromJson(t,s,l,n,i){return null==t||null==t.trigger_id?null:new ft(t.trigger_id,s,l,n,i)}}
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../../managers/braze-instance.js";import ControlMessage from"../models/control-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import SlideUpMessage from"../models/slide-up-message.js";import pe from"../in-app-message-manager-factory.js";import se from"../display/get-animation-effect.js";import ce from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as G}from"../../util/window-utils.js";import{isURIJavascriptOrData as j}from"../../util/url-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as ne}from"../../util/color-utils.js";export function showInAppMessage(t,s,o){if(!e.rr())return;if(ss(),null==t)return!1;if(t instanceof ControlMessage)return r.D.info("User received control for a multivariate test, logging to Braze servers."),logInAppMessageImpression(t),!0;if(!(t instanceof InAppMessage))return!1;const i=pe.m();t.Ui();const n=t instanceof HtmlMessage;if(n&&!t.trusted&&!e.tr())return r.D.error('HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.'),i.qe(t.triggerId,InAppMessage.Oe.vi),!1;if(null==s&&(s=document.body),t.we()){if(s.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),i.qe(t.triggerId,InAppMessage.Oe.Gi),!1}if(G.so()){const e=G.io();if(e===le.PORTRAIT&&t.orientation===InAppMessage.Orientation.LANDSCAPE||e===le.LANDSCAPE&&t.orientation===InAppMessage.Orientation.PORTRAIT){const s=e===le.PORTRAIT?"portrait":"landscape",o=t.orientation===InAppMessage.Orientation.PORTRAIT?"portrait":"landscape";return r.D.info(`Not showing ${o} in-app message ${t.message} because the screen is currently ${s}`),i.qe(t.triggerId,InAppMessage.Oe.Wi),!1}}if(!e.tr()){let e=!1;if(t.buttons&&t.buttons.length>0){const s=t.buttons;for(let t=0;t<s.length;t++)if(s[t].clickAction===InAppMessage.ClickAction.URI){const o=s[t].uri;e=j(o)}}else t.clickAction===InAppMessage.ClickAction.URI&&(e=j(t.uri));if(e)return r.D.error('Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.'),i.qe(t.triggerId,InAppMessage.Oe.vi),!1}const a=document.createElement("div");if(a.className="ab-iam-root v3",a.className+=se(t),a.setAttribute("role","complementary"),t.an()&&(a.id=t.htmlId),e.nn(D.no)&&(a.style.zIndex=e.nn(D.no)+1),s.appendChild(a),t.sn()){const s=document.createElement("style");s.innerHTML=t.css,s.id=t.rn(),null!=e.nn(D.ao)&&s.setAttribute("nonce",e.nn(D.ao)),document.getElementsByTagName("head")[0].appendChild(s)}const l=t instanceof SlideUpMessage,m=ce(t,(()=>{import("../../Feed/ui/show-feed.js").then((e=>e.showFeed()))}),(s=>{if(t.we()&&t.ll()){const o=document.createElement("div");if(o.className="ab-page-blocker",t.sn()||(o.style.backgroundColor=ne(t.frameColor)),e.nn(D.no)&&(o.style.zIndex=e.nn(D.no)),a.appendChild(o),!e.nn(D.Ci)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.xi&&(t.on(s),o.stopPropagation())}}a.appendChild(s),s.focus(),t.Mi(a)}else if(l){const e=document.querySelectorAll(".ab-slideup");let o=null;for(let t=e.length-1;t>=0;t--)if(e[t]!==s){o=e[t];break}if(t.slideFrom===InAppMessage.SlideFrom.TOP){let e=0;null!=o&&(e=o.offsetTop+o.offsetHeight),s.style.top=Math.max(e,0)+"px"}else{let e=0;null!=o&&(e=(window.innerHeight||document.documentElement.clientHeight)-o.offsetTop),s.style.bottom=Math.max(e,0)+"px"}}else if(n&&!e.nn(D.Ci)){const e=t;s.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.Pi&&e.closeMessage()}))}logInAppMessageImpression(t),t.dismissType===InAppMessage.DismissType.AUTO_DISMISS&&setTimeout((()=>{a.contains(s)&&t.on(s)}),t.duration),"function"==typeof o&&o()}),e.nn(D.lo),e.nn(D.no),e.nn(D.ao));return(n||l)&&(a.appendChild(m),t.Mi(a)),!0}
1
+ import e,{OPTIONS as T}from"../../managers/braze-instance.js";import ControlMessage from"../models/control-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import SlideUpMessage from"../models/slide-up-message.js";import pe from"../in-app-message-manager-factory.js";import se from"../display/get-animation-effect.js";import ce from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as H}from"../../util/window-utils.js";import{isURIJavascriptOrData as j}from"../../util/url-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as ne}from"../../util/color-utils.js";export function showInAppMessage(t,s,o){if(!e.rr())return;if(ss(),null==t)return!1;if(t instanceof ControlMessage)return r.D.info("User received control for a multivariate test, logging to Braze servers."),logInAppMessageImpression(t),!0;if(!(t instanceof InAppMessage))return!1;const i=pe.m();t.Hi();const n=t instanceof HtmlMessage;if(n&&!t.trusted&&!e.tr())return r.D.error('HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.'),i.qe(t.triggerId,InAppMessage.Oe.wi),!1;if(null==s&&(s=document.body),t.we()){if(s.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),i.qe(t.triggerId,InAppMessage.Oe.xi),!1}if(H.so()){const e=H.io();if(e===le.PORTRAIT&&t.orientation===InAppMessage.Orientation.LANDSCAPE||e===le.LANDSCAPE&&t.orientation===InAppMessage.Orientation.PORTRAIT){const s=e===le.PORTRAIT?"portrait":"landscape",o=t.orientation===InAppMessage.Orientation.PORTRAIT?"portrait":"landscape";return r.D.info(`Not showing ${o} in-app message ${t.message} because the screen is currently ${s}`),i.qe(t.triggerId,InAppMessage.Oe.Ki),!1}}if(!e.tr()){let e=!1;if(t.buttons&&t.buttons.length>0){const s=t.buttons;for(let t=0;t<s.length;t++)if(s[t].clickAction===InAppMessage.ClickAction.URI){const o=s[t].uri;e=j(o)}}else t.clickAction===InAppMessage.ClickAction.URI&&(e=j(t.uri));if(e)return r.D.error('Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.'),i.qe(t.triggerId,InAppMessage.Oe.wi),!1}const a=document.createElement("div");if(a.className="ab-iam-root v3",a.className+=se(t),a.setAttribute("role","complementary"),t.an()&&(a.id=t.htmlId),e.nn(T.no)&&(a.style.zIndex=e.nn(T.no)+1),s.appendChild(a),t.sn()){const s=document.createElement("style");s.innerHTML=t.css,s.id=t.rn(),null!=e.nn(T.ao)&&s.setAttribute("nonce",e.nn(T.ao)),document.getElementsByTagName("head")[0].appendChild(s)}const l=t instanceof SlideUpMessage,m=ce(t,(()=>{import("../../Feed/ui/show-feed.js").then((e=>e.showFeed()))}),(s=>{if(t.we()&&t.ll()){const o=document.createElement("div");if(o.className="ab-page-blocker",t.sn()||(o.style.backgroundColor=ne(t.frameColor)),e.nn(T.no)&&(o.style.zIndex=e.nn(T.no)),a.appendChild(o),!e.nn(T.Ui)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.$i&&(t.on(s),o.stopPropagation())}}a.appendChild(s),s.focus(),t.Ri(a)}else if(l){const e=document.querySelectorAll(".ab-slideup");let o=null;for(let t=e.length-1;t>=0;t--)if(e[t]!==s){o=e[t];break}if(t.slideFrom===InAppMessage.SlideFrom.TOP){let e=0;null!=o&&(e=o.offsetTop+o.offsetHeight),s.style.top=Math.max(e,0)+"px"}else{let e=0;null!=o&&(e=(window.innerHeight||document.documentElement.clientHeight)-o.offsetTop),s.style.bottom=Math.max(e,0)+"px"}}else if(n&&!e.nn(T.Ui)){const e=t;s.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.Ci&&e.closeMessage()}))}logInAppMessageImpression(t),t.dismissType===InAppMessage.DismissType.AUTO_DISMISS&&setTimeout((()=>{a.contains(s)&&t.on(s)}),t.duration),"function"==typeof o&&o()}),e.nn(T.lo),e.nn(T.no),e.nn(T.ao));return(n||l)&&(a.appendChild(m),t.Ri(a)),!0}
@@ -1 +1 @@
1
- import e,{OPTIONS as D}from"../managers/braze-instance.js";import aa from"./push-manager.js";const or={t:!1,pushManager:null,Xe:()=>(or.o(),or.pushManager||(or.pushManager=new aa(e.gr(),e.aa(),e.ce(),e.Ps(),e.nn(D.ea),e.nn(D.na),e.ir(),e.nn(D.ra),e.nn(D.ta),e.l())),or.pushManager),o:()=>{or.t||(e.u(or),or.t=!0)},destroy:()=>{or.pushManager=null,or.t=!1}};export default or;
1
+ import e,{OPTIONS as T}from"../managers/braze-instance.js";import aa from"./push-manager.js";const or={t:!1,pushManager:null,Xe:()=>(or.o(),or.pushManager||(or.pushManager=new aa(e.gr(),e.aa(),e.ce(),e.Ks(),e.nn(T.ea),e.nn(T.na),e.ir(),e.nn(T.ra),e.nn(T.ta),e.l())),or.pushManager),o:()=>{or.t||(e.u(or),or.t=!0)},destroy:()=>{or.pushManager=null,or.t=!1}};export default or;
@@ -1 +1 @@
1
- import{isArray as p,isEqual as ii}from"../util/code-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";import{WindowUtils as G}from"../util/window-utils.js";export default class aa{constructor(i,e,t,s,n,r,o,u,a,h){this.zi=i,this.Vi=e,this.qi=t,this.Yi=s+"/safari/"+e,this.Ji=n||"/service-worker.js",this.Qi=r,this.wt=o,this.Xi=u||!1,this.Zi=a||!1,this.h=h,this.$i="serviceWorker"in navigator&&"undefined"!=typeof ServiceWorkerRegistration&&"showNotification"in ServiceWorkerRegistration.prototype&&"PushManager"in window,this.hn="safari"in window&&"pushNotification"in window.safari&&"function"==typeof window.safari.pushNotification.permission&&"function"==typeof window.safari.pushNotification.requestPermission}dn(){return this.Zi}isPushSupported(){return this.$i||this.hn}isPushBlocked(){const i=this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"denied"===window.Notification.permission,e=this.isPushSupported()&&(!("Notification"in window)||null==window.Notification);return i||e}isPushPermissionGranted(){return this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"granted"===window.Notification.permission}Ye(){return!this.isPushBlocked()&&this.isPushSupported()&&!this.isPushPermissionGranted()}fn(i,e,t,s,n){i.unsubscribe().then((i=>{i?this.pn(e,t,s,n):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof n&&n(!1))})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof n&&n(!1)}))}wn(i,e,t){const s=(i=>{if("string"==typeof i)return i;if(0!==i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))return i.endpoint;let e=i.endpoint;return i.bn&&-1===i.endpoint.indexOf(i.bn)&&(e=i.endpoint+"/"+i.bn),e})(i);let n=null,r=null;if(null!=i.getKey)try{n=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("p256dh")))),r=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("auth"))))}catch(i){if("invalid arguments"!==i.message)throw i}const o=(i=>{let e;return i.options&&(e=i.options.applicationServerKey)&&e.byteLength&&e.byteLength>0?btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_"):null})(i);this.zi.gn(s,t,n,r,o),s&&"function"==typeof e&&e(s,n,r)}yn(){this.zi.vn(!0)}Pn(i,e){this.zi.vn(!1),r.D.info(i),"function"==typeof e&&e(!1)}kn(i,e,t,s){if("default"===e.permission)try{window.safari.pushNotification.requestPermission(this.Yi,i,{api_key:this.Vi,device_id:this.qi.te().id},(e=>{"granted"===e.permission&&this.zi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.kn(i,e,t,s)}))}catch(i){this.Pn("Could not request permission for push: "+i,s)}else"denied"===e.permission?this.Pn("The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",s):"granted"===e.permission&&(r.D.info("Device successfully subscribed to push."),this.wn(e.deviceToken,t,new Date))}Sn(i,e,t){const s=s=>{switch(s){case"granted":return void("function"==typeof i&&i());case"default":return void("function"==typeof e&&e());case"denied":return void("function"==typeof t&&t());default:r.D.error("Received unexpected permission result "+s)}};let n=!1;const o=window.Notification.requestPermission((i=>{n&&s(i)}));o?o.then((i=>{s(i)})):n=!0}pn(i,e,t,s){const n={userVisibleOnly:!0};null!=e&&(n.applicationServerKey=e),i.pushManager.subscribe(n).then((i=>{r.D.info("Device successfully subscribed to push."),this.wn(i,t,new Date)})).catch((i=>{this.isPushBlocked()?(r.D.info("Permission for push notifications was denied."),"function"==typeof s&&s(!1)):r.D.error("Push subscription failed: "+i)}))}Dn(){return this.Xi?navigator.serviceWorker.getRegistration():navigator.serviceWorker.register(this.Ji).then((()=>navigator.serviceWorker.ready.then((i=>(i&&"function"==typeof i.update&&i.update().catch((i=>{r.D.info("ServiceWorker update failed: "+i)})),i)))))}_n(i){this.Xi||(i.unregister(),r.D.info("Service worker successfully unregistered."))}subscribe(i,e){if(this.isPushSupported()){if(this.$i){if(!this.Xi&&null!=window.location){let i=this.Ji;-1===i.indexOf(window.location.host)&&(i=window.location.host+i),-1===i.indexOf(window.location.protocol)&&(i=window.location.protocol+"//"+i);const e=i.substr(0,i.lastIndexOf("/")+1);if(0!==G.Nn().indexOf(e))return void r.D.error("Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from "+window.location.pathname+" but service worker is at "+i+")")}if(this.isPushBlocked())return void this.Pn("Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",e);if(this.wt&&!this.wt.Wn()&&0===this.wt.Os())return r.D.info("Waiting for VAPID key from server config before subscribing to push."),void this.wt.An((()=>{this.subscribe(i,e)}));const t=()=>{r.D.info("Permission for push notifications was denied."),"function"==typeof e&&e(!1)},s=()=>{let i="Permission for push notifications was ignored.";this.isPushBlocked()&&(i+=" The browser has automatically blocked further permission requests for a period (probably 1 week)."),r.D.info(i),"function"==typeof e&&e(!0)},n=this.isPushPermissionGranted(),u=()=>{n||this.zi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.Dn().then((t=>{if(null==t)return r.D.error("No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."),void("function"==typeof e&&e());t.pushManager.getSubscription().then((s=>{let n=null;if(this.wt&&null!=this.wt.Wn()&&(n=r.Un.jn(this.wt.Wn())),s){let u=null,a=null;const h=this.h.I(o.q.xn);if(h&&!p(h)){let i;try{i=ei.Rn(h).Tn}catch(e){i=null}null==i||isNaN(i.getTime())||0===i.getTime()||(u=i,a=new Date(u),a.setMonth(u.getMonth()+6))}null!=n&&s.options&&s.options.applicationServerKey&&s.options.applicationServerKey.byteLength&&s.options.applicationServerKey.byteLength>0&&!ii(n,new Uint8Array(s.options.applicationServerKey))?(s.options.applicationServerKey.byteLength>12?r.D.info("Device was already subscribed to push using a different VAPID provider, creating new subscription."):r.D.info("Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."),this.fn(s,t,n,i,e)):s.expirationTime&&new Date(s.expirationTime)<=(new Date).valueOf()?(r.D.info("Push subscription is expired, creating new subscription."),this.fn(s,t,n,i,e)):h&&p(h)?this.fn(s,t,n,i,e):null==a?(r.D.info("No push subscription creation date found, creating new subscription."),this.fn(s,t,n,i,e)):a<=(new Date).valueOf()?(r.D.info("Push subscription older than 6 months, creating new subscription."),this.fn(s,t,n,i,e)):(r.D.info("Device already subscribed to push, sending existing subscription to backend."),this.wn(s,i,u))}else this.pn(t,n,i,e)})).catch((i=>{r.D.error("Error checking current push subscriptions: "+i)}))})).catch((i=>{r.D.error("ServiceWorker registration failed: "+i)}))};this.Sn(u,s,t)}else if(this.hn){if(null==this.Qi||""===this.Qi)return void r.D.error("You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari");const t=window.safari.pushNotification.permission(this.Qi);this.kn(this.Qi,t,i,e)}}else r.D.info(this.zn)}unsubscribe(i,e){this.isPushSupported()?this.$i?navigator.serviceWorker.getRegistration().then((t=>{t?t.pushManager.getSubscription().then((s=>{s&&(this.yn(),s.unsubscribe().then((s=>{s?(r.D.info("Device successfully unsubscribed from push."),"function"==typeof i&&i()):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof e&&e()),this._n(t)})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof e&&e()})))})).catch((i=>{r.D.error("Error unsubscribing from push: "+i),"function"==typeof e&&e()})):(r.D.info("Device already unsubscribed from push."),"function"==typeof i&&i())})):this.hn&&(this.yn(),r.D.info("Device unsubscribed from push."),"function"==typeof i&&i()):r.D.info(this.zn)}}aa.zn="Push notifications are not supported in this browser.";
1
+ import{isArray as p,isEqual as ii}from"../util/code-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";import{WindowUtils as H}from"../util/window-utils.js";export default class aa{constructor(i,e,t,s,n,r,o,u,a,h){this.Ji=i,this.Qi=e,this.Zi=t,this.hn=s+"/safari/"+e,this.dn=n||"/service-worker.js",this.fn=r,this.gt=o,this.pn=u||!1,this.wn=a||!1,this.h=h,this.bn="serviceWorker"in navigator&&"undefined"!=typeof ServiceWorkerRegistration&&"showNotification"in ServiceWorkerRegistration.prototype&&"PushManager"in window,this.gn="safari"in window&&"pushNotification"in window.safari&&"function"==typeof window.safari.pushNotification.permission&&"function"==typeof window.safari.pushNotification.requestPermission}yn(){return this.wn}isPushSupported(){return this.bn||this.gn}isPushBlocked(){const i=this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"denied"===window.Notification.permission,e=this.isPushSupported()&&(!("Notification"in window)||null==window.Notification);return i||e}isPushPermissionGranted(){return this.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"granted"===window.Notification.permission}Ye(){return!this.isPushBlocked()&&this.isPushSupported()&&!this.isPushPermissionGranted()}vn(i,e,t,s,n){i.unsubscribe().then((i=>{i?this.Pn(e,t,s,n):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof n&&n(!1))})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof n&&n(!1)}))}kn(i,e,t){const s=(i=>{if("string"==typeof i)return i;if(0!==i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))return i.endpoint;let e=i.endpoint;return i.Sn&&-1===i.endpoint.indexOf(i.Sn)&&(e=i.endpoint+"/"+i.Sn),e})(i);let n=null,r=null;if(null!=i.getKey)try{n=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("p256dh")))),r=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("auth"))))}catch(i){if("invalid arguments"!==i.message)throw i}const o=(i=>{let e;return i.options&&(e=i.options.applicationServerKey)&&e.byteLength&&e.byteLength>0?btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_"):null})(i);this.Ji.Dn(s,t,n,r,o),s&&"function"==typeof e&&e(s,n,r)}_n(){this.Ji.Nn(!0)}Wn(i,e){this.Ji.Nn(!1),r.D.info(i),"function"==typeof e&&e(!1)}An(i,e,t,s){if("default"===e.permission)try{window.safari.pushNotification.requestPermission(this.hn,i,{api_key:this.Qi,device_id:this.Zi.te().id},(e=>{"granted"===e.permission&&this.Ji.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.An(i,e,t,s)}))}catch(i){this.Wn("Could not request permission for push: "+i,s)}else"denied"===e.permission?this.Wn("The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",s):"granted"===e.permission&&(r.D.info("Device successfully subscribed to push."),this.kn(e.deviceToken,t,new Date))}jn(i,e,t){const s=s=>{switch(s){case"granted":return void("function"==typeof i&&i());case"default":return void("function"==typeof e&&e());case"denied":return void("function"==typeof t&&t());default:r.D.error("Received unexpected permission result "+s)}};let n=!1;const o=window.Notification.requestPermission((i=>{n&&s(i)}));o?o.then((i=>{s(i)})):n=!0}Pn(i,e,t,s){const n={userVisibleOnly:!0};null!=e&&(n.applicationServerKey=e),i.pushManager.subscribe(n).then((i=>{r.D.info("Device successfully subscribed to push."),this.kn(i,t,new Date)})).catch((i=>{this.isPushBlocked()?(r.D.info("Permission for push notifications was denied."),"function"==typeof s&&s(!1)):r.D.error("Push subscription failed: "+i)}))}Un(){return this.pn?navigator.serviceWorker.getRegistration():navigator.serviceWorker.register(this.dn).then((()=>navigator.serviceWorker.ready.then((i=>(i&&"function"==typeof i.update&&i.update().catch((i=>{r.D.info("ServiceWorker update failed: "+i)})),i)))))}xn(i){this.pn||(i.unregister(),r.D.info("Service worker successfully unregistered."))}subscribe(i,e){if(this.isPushSupported()){if(this.bn){if(!this.pn&&null!=window.location){let i=this.dn;-1===i.indexOf(window.location.host)&&(i=window.location.host+i),-1===i.indexOf(window.location.protocol)&&(i=window.location.protocol+"//"+i);const e=i.substr(0,i.lastIndexOf("/")+1);if(0!==H.Tn().indexOf(e))return void r.D.error("Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from "+window.location.pathname+" but service worker is at "+i+")")}if(this.isPushBlocked())return void this.Wn("Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",e);if(this.gt&&!this.gt.Rn()&&0===this.gt.Zs())return r.D.info("Waiting for VAPID key from server config before subscribing to push."),void this.gt.zn((()=>{this.subscribe(i,e)}));const t=()=>{r.D.info("Permission for push notifications was denied."),"function"==typeof e&&e(!1)},s=()=>{let i="Permission for push notifications was ignored.";this.isPushBlocked()&&(i+=" The browser has automatically blocked further permission requests for a period (probably 1 week)."),r.D.info(i),"function"==typeof e&&e(!0)},n=this.isPushPermissionGranted(),u=()=>{n||this.Ji.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.Un().then((t=>{if(null==t)return r.D.error("No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."),void("function"==typeof e&&e());t.pushManager.getSubscription().then((s=>{let n=null;if(this.gt&&null!=this.gt.Rn()&&(n=r.Vn.In(this.gt.Rn())),s){let u=null,a=null;const h=this.h.I(o.q.qn);if(h&&!p(h)){let i;try{i=ei.En(h).Cn}catch(e){i=null}null==i||isNaN(i.getTime())||0===i.getTime()||(u=i,a=new Date(u),a.setMonth(u.getMonth()+6))}null!=n&&s.options&&s.options.applicationServerKey&&s.options.applicationServerKey.byteLength&&s.options.applicationServerKey.byteLength>0&&!ii(n,new Uint8Array(s.options.applicationServerKey))?(s.options.applicationServerKey.byteLength>12?r.D.info("Device was already subscribed to push using a different VAPID provider, creating new subscription."):r.D.info("Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."),this.vn(s,t,n,i,e)):s.expirationTime&&new Date(s.expirationTime)<=(new Date).valueOf()?(r.D.info("Push subscription is expired, creating new subscription."),this.vn(s,t,n,i,e)):h&&p(h)?this.vn(s,t,n,i,e):null==a?(r.D.info("No push subscription creation date found, creating new subscription."),this.vn(s,t,n,i,e)):a<=(new Date).valueOf()?(r.D.info("Push subscription older than 6 months, creating new subscription."),this.vn(s,t,n,i,e)):(r.D.info("Device already subscribed to push, sending existing subscription to backend."),this.kn(s,i,u))}else this.Pn(t,n,i,e)})).catch((i=>{r.D.error("Error checking current push subscriptions: "+i)}))})).catch((i=>{r.D.error("ServiceWorker registration failed: "+i)}))};this.jn(u,s,t)}else if(this.gn){if(null==this.fn||""===this.fn)return void r.D.error("You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari");const t=window.safari.pushNotification.permission(this.fn);this.An(this.fn,t,i,e)}}else r.D.info(this.Bn)}unsubscribe(i,e){this.isPushSupported()?this.bn?navigator.serviceWorker.getRegistration().then((t=>{t?t.pushManager.getSubscription().then((s=>{s&&(this._n(),s.unsubscribe().then((s=>{s?(r.D.info("Device successfully unsubscribed from push."),"function"==typeof i&&i()):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof e&&e()),this.xn(t)})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof e&&e()})))})).catch((i=>{r.D.error("Error unsubscribing from push: "+i),"function"==typeof e&&e()})):(r.D.info("Device already unsubscribed from push."),"function"==typeof i&&i())})):this.gn&&(this._n(),r.D.info("Device unsubscribed from push."),"function"==typeof i&&i()):r.D.info(this.Bn)}}aa.Bn="Push notifications are not supported in this browser.";
@@ -1 +1 @@
1
- import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.wt=t,this.h=s}getUserId(){const t=this.h._r(o.Cr.Ur);if(null==t)return null;let s=t.Ir,i=U(s);if(i>User.ee){for(;i>User.ee;)s=s.slice(0,s.length-1),i=U(s);t.Ir=s,this.h.Lr(o.Cr.Ur,t)}return s}Br(t){const s=null==this.getUserId();this.h.Lr(o.Cr.Ur,new _t(t)),s&&this.h.Er(t)}setCustomUserAttribute(t,s){if(this.wt.Gr(t))return r.D.info('Custom Attribute "'+t+'" is blocklisted, ignoring.'),!1;const i={};return i[t]=s,this.Hr(User.Jr,i,!0)}Hr(t,s,i,e){const u=this.h.Kr(this.getUserId(),t,s);return!e&&u&&r.D.info(`Logged${i?" custom":""} attribute ${t} with value ${s}`),u}gn(t,s,i,e,u){this.Hr("push_token",t,!1,!0),this.Hr("custom_push_public_key",i,!1,!0),this.Hr("custom_push_user_auth",e,!1,!0),this.Hr("custom_push_vapid_public_key",u,!1,!0);const h=r.xt.Ft,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.xn,l.ss()),n.setItem(h.$t.Mr,h.se,!0)}vn(t){if(this.Hr("push_token",null,!1,!0),this.Hr("custom_push_public_key",null,!1,!0),this.Hr("custom_push_user_auth",null,!1,!0),this.Hr("custom_push_vapid_public_key",null,!1,!0),t){const t=r.xt.Ft,s=new r.qt(t,r.D);this.h.B(o.q.xn,!1),s.setItem(t.$t.Mr,t.se,!1)}}}
1
+ import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.gt=t,this.h=s}getUserId(){const t=this.h._r(o.Cr.Ur);if(null==t)return null;let s=t.Ir,i=U(s);if(i>User.ee){for(;i>User.ee;)s=s.slice(0,s.length-1),i=U(s);t.Ir=s,this.h.Lr(o.Cr.Ur,t)}return s}Br(t){const s=null==this.getUserId();this.h.Lr(o.Cr.Ur,new _t(t)),s&&this.h.Er(t)}setCustomUserAttribute(t,s){if(this.gt.Gr(t))return r.D.info('Custom Attribute "'+t+'" is blocklisted, ignoring.'),!1;const i={};return i[t]=s,this.Hr(User.Jr,i,!0)}Hr(t,s,i,e){const u=this.h.Kr(this.getUserId(),t,s);return!e&&u&&r.D.info(`Logged${i?" custom":""} attribute ${t} with value ${s}`),u}Dn(t,s,i,e,u){this.Hr("push_token",t,!1,!0),this.Hr("custom_push_public_key",i,!1,!0),this.Hr("custom_push_user_auth",e,!1,!0),this.Hr("custom_push_vapid_public_key",u,!1,!0);const h=r.xt.Ft,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.qn,l.ss()),n.setItem(h.$t.Mr,h.se,!0)}Nn(t){if(this.Hr("push_token",null,!1,!0),this.Hr("custom_push_public_key",null,!1,!0),this.Hr("custom_push_user_auth",null,!1,!0),this.Hr("custom_push_vapid_public_key",null,!1,!0),t){const t=r.xt.Ft,s=new r.qt(t,r.D);this.h.B(o.q.qn,!1),s.setItem(t.$t.Mr,t.se,!1)}}}