@braze/web-sdk 4.0.6 → 4.1.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 (82) hide show
  1. package/index.d.ts +18 -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/guid.js +1 -1
  7. package/shared-lib/indexed-db-adapter.js +1 -1
  8. package/shared-lib/logger.js +1 -1
  9. package/shared-lib/supported-options.js +1 -1
  10. package/src/Card/display/card-display.js +1 -1
  11. package/src/Card/index.js +1 -1
  12. package/src/Card/log-content-card-impressions.js +1 -0
  13. package/src/Card/models/captioned-image.js +1 -1
  14. package/src/Card/models/card.js +1 -1
  15. package/src/Card/models/classic-card.js +1 -1
  16. package/src/Card/models/control-card.js +1 -1
  17. package/src/Card/util/card-factory.js +1 -1
  18. package/src/ContentCards/content-cards-provider.js +1 -1
  19. package/src/ContentCards/get-cached-content-cards.js +1 -1
  20. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  21. package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -1
  22. package/src/ContentCards/ui/show-content-cards.js +1 -1
  23. package/src/Core/disable-sdk.js +1 -1
  24. package/src/Core/enable-sdk.js +1 -1
  25. package/src/Core/open-session.js +1 -1
  26. package/src/Core/wipe-data.js +1 -1
  27. package/src/Feed/feed-provider.js +1 -1
  28. package/src/Feed/get-cached-feed.js +1 -1
  29. package/src/Feed/request-feed-refresh.js +1 -1
  30. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  31. package/src/Feed/ui/show-feed.js +1 -1
  32. package/src/InAppMessage/display/in-app-message-to-html.js +1 -1
  33. package/src/InAppMessage/in-app-message-manager.js +1 -1
  34. package/src/InAppMessage/models/html-message.js +1 -1
  35. package/src/InAppMessage/models/in-app-message-button.js +1 -1
  36. package/src/InAppMessage/models/in-app-message.js +1 -1
  37. package/src/InAppMessage/models/modal-message.js +1 -1
  38. package/src/InAppMessage/models/slide-up-message.js +1 -1
  39. package/src/InAppMessage/models/templated-in-app-message.js +1 -1
  40. package/src/InAppMessage/ui/show-in-app-message.js +1 -1
  41. package/src/Push/push-manager-factory.js +1 -1
  42. package/src/Push/push-manager.js +1 -1
  43. package/src/User/user-manager.js +1 -1
  44. package/src/User/user.js +1 -1
  45. package/src/common/base-feed.js +1 -1
  46. package/src/common/base-provider.js +1 -1
  47. package/src/common/feed-display.js +1 -1
  48. package/src/l10n/l10n-manager-factory.js +1 -1
  49. package/src/managers/auth-manager.js +1 -1
  50. package/src/managers/braze-instance.js +1 -1
  51. package/src/managers/device-manager.js +1 -1
  52. package/src/managers/network-manager.js +1 -1
  53. package/src/managers/server-config-manager.js +1 -1
  54. package/src/managers/session-manager.js +1 -1
  55. package/src/managers/storage-manager-factory.js +1 -1
  56. package/src/managers/storage-manager.js +1 -1
  57. package/src/managers/subscription-manager.js +1 -1
  58. package/src/models/backend-errors.js +1 -1
  59. package/src/models/braze-event.js +1 -1
  60. package/src/models/device.js +1 -1
  61. package/src/models/identifier.js +1 -1
  62. package/src/models/push-token.js +1 -1
  63. package/src/models/server-config.js +1 -1
  64. package/src/request-controller.js +1 -1
  65. package/src/triggers/models/filter-set.js +1 -1
  66. package/src/triggers/models/filter.js +1 -1
  67. package/src/triggers/models/in-app-message-click-data.js +1 -1
  68. package/src/triggers/models/push-click-data.js +1 -1
  69. package/src/triggers/models/trigger-condition.js +1 -1
  70. package/src/triggers/models/trigger.js +1 -1
  71. package/src/triggers/triggers-provider-factory.js +1 -1
  72. package/src/triggers/triggers-provider.js +1 -1
  73. package/src/ui/js/attach-css.js +1 -1
  74. package/src/ui/js/load-font-awesome.js +1 -1
  75. package/src/util/base-device-parser.js +1 -1
  76. package/src/util/browser-detector.js +1 -1
  77. package/src/util/client-hints-parser.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/window-utils.js +1 -1
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v4.0.6
2
+ * Type definitions for @braze/web-sdk v4.1.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
@@ -1768,6 +1768,21 @@
1768
1768
  forContentCards?: boolean
1769
1769
  ): boolean;
1770
1770
 
1771
+ /**
1772
+ * A convenience method to log that the user saw the given Content Cards. This method is equivalent to
1773
+ * calling [`logCardImpressions` method with `forContentCards` param set to true.
1774
+ * This is done automatically when you use Braze's display module and should only be called
1775
+ * if you're bypassing that and manually building the DOM for displaying content cards in
1776
+ * your own code.
1777
+ *
1778
+ * @param contentCards - array of `Card` objects that received impressions
1779
+ *
1780
+ * @returns Whether or not the event was successfully logged (to be flushed later).
1781
+ */
1782
+ export function logContentCardImpressions(
1783
+ contentCards: Card[],
1784
+ ): boolean;
1785
+
1771
1786
  /**
1772
1787
  * @deprecated This method has been deprecated and is currently a no-op.
1773
1788
  */
@@ -1905,7 +1920,7 @@
1905
1920
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
1906
1921
  *
1907
1922
  * ```
1908
- * self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.0/service-worker.js');
1923
+ * self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.1/service-worker.js');
1909
1924
  * ```
1910
1925
  *
1911
1926
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -2219,7 +2234,7 @@
2219
2234
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2220
2235
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2221
2236
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2222
- * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.0/service-worker.js');` or by including the content
2237
+ * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.1/service-worker.js');` or by including the content
2223
2238
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2224
2239
  */
2225
2240
  manageServiceWorkerExternally?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "4.0.6",
3
+ "version": "4.1.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={Nn:je,A:ve,qr:De,nt:Be,qt:Ae,Ft:Ae.ep,D:Ge,Uo: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={Un:je,A:ve,qr:De,it:Be,qt:Ae,xt:Ae.ep,D:Ge,Go:Oe};export default r;
@@ -1 +1 @@
1
- const je={_n: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={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 +1 @@
1
- const ve={CustomEvent:"ce",Pr:"p",Sl:"pc",oc:"ca",Ra:"i",ha:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Je:"si",Re:"sc",He:"sbc",Pe:"sfe",ro:"iec",vl:"lr",yl:"uae",U:"ci",F:"cc",Al:"lcaa",$l:"lcar",Qr:"inc",Wr:"add",Yr:"rem",Vr:"set",Cl:"sgu"},De={Fr:"feed_displayed",cc:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
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 +1 @@
1
- const Be={et:()=>{const t=t=>{const e=(Math.random().toString(16)+"000000000").substr(2,8);return t?"-"+e.substr(0,4)+"-"+e.substr(4,4):e};return t()+t(!0)+t(!0)+t()}};export default Be;
1
+ const Be={nt:()=>{const t=t=>{const e=(Math.random().toString(16)+"000000000").substr(2,8);return t?"-"+e.substr(0,4)+"-"+e.substr(4,4):e};return t()+t(!0)+t(!0)+t()}};export default Be;
@@ -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.Pt)o.ed.Pt.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.Pt[t])&&e.createObjectStore(o.ed.Pt[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.Pt)this.ed.Pt.hasOwnProperty(e)&&this.ed.Pt[e]!==this.ed.Pt.oe&&t.push(this.ed.Pt[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={xt:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,Pt:{jl:"data",jr:"pushClicks",Mr:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",Kn:"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",On:"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.0.6)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.0.6)";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.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 +1 @@
1
- export default{Vn:"allowCrawlerActivity",$n:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ra:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ta:"manageServiceWorkerExternally",po:"minimumIntervalBetweenTriggerActionsInSeconds",Eo:"sessionTimeoutInSeconds",_o:"appVersion",ea:"serviceWorkerLocation",na:"safariWebsitePushId",zn:"localization",ao:"contentSecurityNonce",Io:"enableHtmlInAppMessages",Ao:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",bi:"requireExplicitInAppMessageDismissal",So:"doNotLoadFontAwesome",No:"sdkFlavor",tn:"openCardsInNewTab"};
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 +1 @@
1
- import{createCloseButton as i}from"../../util/component-utils.js";import{detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import{logCardDismissal}from"../index.js";import r from"../../../shared-lib/braze-shared-lib.js";export const TOP_IMPRESSION_DATA_ATTRIBUTE="data-ab-had-top-impression";export const BOTTOM_IMPRESSION_DATA_ATTRIBUTE="data-ab-had-bottom-impression";export function topHadImpression(t){return null!=t&&!!t.getAttribute("data-ab-had-top-impression")}export function impressOnTop(t){null!=t&&t.setAttribute("data-ab-had-top-impression",!0)}export function bottomHadImpression(t){return null!=t&&!!t.getAttribute("data-ab-had-bottom-impression")}export function impressOnBottom(t){null!=t&&t.setAttribute("data-ab-had-bottom-impression",!0)}export function markCardAsRead(t){if(null!=t){const o=t.querySelectorAll(".ab-unread-indicator")[0];null!=o&&(o.className+=" read")}}export function getCardId(t){return t.getAttribute("data-ab-card-id")}export function _setImageAltText(t,o){let a="";t.title||t.description||(a="Feed Image"),o.setAttribute("alt",a)}export function setCardHeight(t,o){const a=o.querySelectorAll(".ab-image-area");let e,n=0;a.length>0&&(n=a[0].offsetWidth);for(const o of t)if(e=o.X,e&&o.imageUrl&&!isNaN(o.aspectRatio)){const t=n/o.aspectRatio;t&&(e.style.height=`${t}px`)}}export function cardToHtml(t,logCardClick,o){const a=document.createElement("div");a.className="ab-card ab-effect-card "+t.Y,a.setAttribute("data-ab-card-id",t.id),a.setAttribute("role","article"),a.setAttribute("tabindex","0");const e=t.url&&""!==t.url,n=n=>(markCardAsRead(a),e&&(logCardClick(t),m(t.url,n,o)),!1);if(t.pinned){const t=document.createElement("div");t.className="ab-pinned-indicator";const o=document.createElement("i");o.className="fa fa-star",t.appendChild(o),a.appendChild(t)}if(t.imageUrl&&""!==t.imageUrl){const o=document.createElement("div");o.className="ab-image-area";const i=document.createElement("img");if(i.setAttribute("src",t.imageUrl),i.onload=()=>{a.style.height="auto"},_setImageAltText(t,i),o.appendChild(i),a.className+=" with-image",e&&!t.Z){const e=document.createElement("a");e.setAttribute("href",t.url),e.onclick=n,e.appendChild(o),a.appendChild(e)}else a.appendChild(o)}const s=document.createElement("div");if(s.className="ab-card-body",t.dismissible){t.tt=()=>logCardDismissal(t);const o=i("Dismiss Card",void 0,t.dismissCard.bind(t));a.appendChild(o),d(s,c.ot,(t=>{a.className+=" ab-swiped-left",o.onclick(t)})),d(s,c.at,(t=>{a.className+=" ab-swiped-right",o.onclick(t)}))}const u=t.title&&""!==t.title;if(u){const o=document.createElement("h1");if(o.className="ab-title",o.id=r.nt.et(),a.setAttribute("aria-labelledby",o.id),e){const a=document.createElement("a");a.setAttribute("href",t.url),a.onclick=n,a.appendChild(document.createTextNode(t.title)),o.appendChild(a)}else o.appendChild(document.createTextNode(t.title));s.appendChild(o)}const p=document.createElement("div");if(p.className=u?"ab-description":"ab-description ab-no-title",p.id=r.nt.et(),a.setAttribute("aria-describedby",p.id),p.appendChild(document.createTextNode(t.description)),e){const o=document.createElement("div");o.className="ab-url-area";const a=document.createElement("a");a.setAttribute("href",t.url),a.appendChild(document.createTextNode(t.linkText)),a.onclick=n,o.appendChild(a),p.appendChild(o)}s.appendChild(p),a.appendChild(s);const b=document.createElement("div");return b.className="ab-unread-indicator",t.viewed&&(b.className+=" read"),a.appendChild(b),t.X=a,a}
1
+ import{createCloseButton as i}from"../../util/component-utils.js";import{detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import{logCardDismissal}from"../index.js";import r from"../../../shared-lib/braze-shared-lib.js";export const TOP_IMPRESSION_DATA_ATTRIBUTE="data-ab-had-top-impression";export const BOTTOM_IMPRESSION_DATA_ATTRIBUTE="data-ab-had-bottom-impression";export function topHadImpression(t){return null!=t&&!!t.getAttribute("data-ab-had-top-impression")}export function impressOnTop(t){null!=t&&t.setAttribute("data-ab-had-top-impression",!0)}export function bottomHadImpression(t){return null!=t&&!!t.getAttribute("data-ab-had-bottom-impression")}export function impressOnBottom(t){null!=t&&t.setAttribute("data-ab-had-bottom-impression",!0)}export function markCardAsRead(t){if(null!=t){const o=t.querySelectorAll(".ab-unread-indicator")[0];null!=o&&(o.className+=" read")}}export function getCardId(t){return t.getAttribute("data-ab-card-id")}export function _setImageAltText(t,o){let a="";t.title||t.description||(a="Feed Image"),o.setAttribute("alt",a)}export function setCardHeight(t,o){const a=o.querySelectorAll(".ab-image-area");let e,n=0;a.length>0&&(n=a[0].offsetWidth);for(const o of t)if(e=o.X,e&&o.imageUrl&&!isNaN(o.aspectRatio)){const t=n/o.aspectRatio;t&&(e.style.height=`${t}px`)}}export function cardToHtml(t,logCardClick,o){const a=document.createElement("div");a.className="ab-card ab-effect-card "+t.Y,a.setAttribute("data-ab-card-id",t.id),a.setAttribute("role","article"),a.setAttribute("tabindex","0");const e=t.url&&""!==t.url,n=n=>(markCardAsRead(a),e&&(logCardClick(t),m(t.url,n,o)),!1);if(t.pinned){const t=document.createElement("div");t.className="ab-pinned-indicator";const o=document.createElement("i");o.className="fa fa-star",t.appendChild(o),a.appendChild(t)}if(t.imageUrl&&""!==t.imageUrl){const o=document.createElement("div");o.className="ab-image-area";const i=document.createElement("img");if(i.setAttribute("src",t.imageUrl),i.onload=()=>{a.style.height="auto"},_setImageAltText(t,i),o.appendChild(i),a.className+=" with-image",e&&!t.Z){const e=document.createElement("a");e.setAttribute("href",t.url),e.onclick=n,e.appendChild(o),a.appendChild(e)}else a.appendChild(o)}const s=document.createElement("div");if(s.className="ab-card-body",t.dismissible){t.tt=()=>logCardDismissal(t);const o=i("Dismiss Card",void 0,t.dismissCard.bind(t));a.appendChild(o),d(s,c.ot,(t=>{a.className+=" ab-swiped-left",o.onclick(t)})),d(s,c.et,(t=>{a.className+=" ab-swiped-right",o.onclick(t)}))}const u=t.title&&""!==t.title;if(u){const o=document.createElement("h1");if(o.className="ab-title",o.id=r.it.nt(),a.setAttribute("aria-labelledby",o.id),e){const a=document.createElement("a");a.setAttribute("href",t.url),a.onclick=n,a.appendChild(document.createTextNode(t.title)),o.appendChild(a)}else o.appendChild(document.createTextNode(t.title));s.appendChild(o)}const p=document.createElement("div");if(p.className=u?"ab-description":"ab-description ab-no-title",p.id=r.it.nt(),a.setAttribute("aria-describedby",p.id),p.appendChild(document.createTextNode(t.description)),e){const o=document.createElement("div");o.className="ab-url-area";const a=document.createElement("a");a.setAttribute("href",t.url),a.appendChild(document.createTextNode(t.linkText)),a.onclick=n,o.appendChild(a),p.appendChild(o)}s.appendChild(p),a.appendChild(s);const b=document.createElement("div");return b.className="ab-unread-indicator",t.viewed&&(b.className+=" read"),a.appendChild(b),t.X=a,a}
package/src/Card/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./models/index.js";export{logCardClick}from"./log-card-click.js";export{logCardDismissal}from"./log-card-dismissal.js";export{logCardImpressions}from"./log-card-impressions.js";
1
+ export*from"./models/index.js";export{logCardClick}from"./log-card-click.js";export{logCardDismissal}from"./log-card-dismissal.js";export{logCardImpressions}from"./log-card-impressions.js";export{logContentCardImpressions}from"./log-content-card-impressions.js";
@@ -0,0 +1 @@
1
+ import{logCardImpressions}from"./log-card-impressions.js";export function logContentCardImpressions(o){return logCardImpressions(o,!0)}
@@ -1 +1 @@
1
- import Card from"./card.js";export default class CaptionedImage extends Card{constructor(t,s,i,h,e,r,a,o,c,n,d,p,u,l,m,f){super(t,s,i,h,e,r,a,o,c,n,d,p,u,l,m,f),this.Y="ab-captioned-image",this.Z=!0}ss(){const t={};return t[Card.hs.ts]=Card.es.st,t[Card.hs.ns]=this.id,t[Card.hs.ls]=this.viewed,t[Card.hs.it]=this.title,t[Card.hs.os]=this.imageUrl,t[Card.hs.ht]=this.description,t[Card.hs.us]=this.updated,t[Card.hs.cs]=this.created,t[Card.hs.ds]=this.categories,t[Card.hs.ps]=this.expiresAt,t[Card.hs.URL]=this.url,t[Card.hs.bs]=this.linkText,t[Card.hs.fs]=this.aspectRatio,t[Card.hs.xs]=this.extras,t[Card.hs.js]=this.pinned,t[Card.hs.zs]=this.dismissible,t[Card.hs.gs]=this.clicked,t[Card.hs.ks]=this.test,t}}
1
+ import Card from"./card.js";export default class CaptionedImage extends Card{constructor(t,s,i,h,e,r,a,o,c,n,d,p,u,l,m,f){super(t,s,i,h,e,r,a,o,c,n,d,p,u,l,m,f),this.Y="ab-captioned-image",this.Z=!0}ss(){const t={};return t[Card.hs.ts]=Card.es.st,t[Card.hs.ns]=this.id,t[Card.hs.ls]=this.viewed,t[Card.hs.ht]=this.title,t[Card.hs.os]=this.imageUrl,t[Card.hs.rt]=this.description,t[Card.hs.us]=this.updated,t[Card.hs.cs]=this.created,t[Card.hs.ds]=this.categories,t[Card.hs.ps]=this.expiresAt,t[Card.hs.URL]=this.url,t[Card.hs.bs]=this.linkText,t[Card.hs.fs]=this.aspectRatio,t[Card.hs.xs]=this.extras,t[Card.hs.js]=this.pinned,t[Card.hs.zs]=this.dismissible,t[Card.hs.gs]=this.clicked,t[Card.hs.ks]=this.test,t}}
@@ -1 +1 @@
1
- import{convertMsToSeconds as l,dateFromUnixTimestamp as h}from"../../util/date-utils.js";import{FEED_ANIMATION_DURATION as E}from"../../common/constants.js";import u from"../../managers/subscription-manager.js";export default class Card{constructor(t,i,s,n,l,h,e,r,E,u,T,o,I,a,N,S){this.id=t,this.viewed=i||!1,this.title=s||"",this.imageUrl=n,this.description=l||"",this.created=h||null,this.updated=e||null,this.categories=r||[],this.expiresAt=E||null,this.url=u,this.linkText=T,o=parseFloat(o),this.aspectRatio=isNaN(o)?null:o,this.extras=I,this.pinned=a||!1,this.dismissible=N||!1,this.dismissed=!1,this.clicked=S||!1,this.test=!1,this.lt=null,this.rt=null}subscribeToClickedEvent(t){return this.ut().Et(t)}subscribeToDismissedEvent(t){return this.Tt().Et(t)}removeSubscription(t){this.ut().removeSubscription(t),this.Tt().removeSubscription(t)}removeAllSubscriptions(){this.ut().removeAllSubscriptions(),this.Tt().removeAllSubscriptions()}dismissCard(){if(this.dismissible&&!this.dismissed){this.tt&&this.tt(this);var t=this.X;t&&(t.style.height=t.offsetHeight+"px",t.className=t.className+" ab-hide",setTimeout((function(){t&&t.parentNode&&(t.style.height="0",t.style.margin="0",setTimeout((function(){t&&t.parentNode&&t.parentNode.removeChild(t)}),Card.It))}),E))}}ut(){return null==this.lt&&(this.lt=new u),this.lt}Tt(){return null==this.rt&&(this.rt=new u),this.rt}R(){this.viewed=!0}k(){this.viewed=!0,this.clicked=!0,this.ut().Nt()}J(){return!(!this.dismissible||this.dismissed)&&(this.dismissed=!0,this.Tt().Nt(),!0)}St(t){if(null==t||t[Card.ct.ns]!==this.id)return!0;if(t[Card.ct.At])return!1;if(null!=t[Card.ct.us]&&null!=this.updated&&t[Card.ct.us]<l(this.updated.valueOf()))return!0;if(t[Card.ct.ls]&&!this.viewed&&(this.viewed=!0),t[Card.ct.gs]&&!this.clicked&&(this.clicked=t[Card.ct.gs]),null!=t[Card.ct.it]&&(this.title=t[Card.ct.it]),null!=t[Card.ct.os]&&(this.imageUrl=t[Card.ct.os]),null!=t[Card.ct.ht]&&(this.description=t[Card.ct.ht]),null!=t[Card.ct.us]){const i=h(t[Card.ct.us]);null!=i&&(this.updated=i)}if(null!=t[Card.ct.ps]){let i;i=t[Card.ct.ps]===Card.Dt?null:h(t[Card.ct.ps]),this.expiresAt=i}if(null!=t[Card.ct.URL]&&(this.url=t[Card.ct.URL]),null!=t[Card.ct.bs]&&(this.linkText=t[Card.ct.bs]),null!=t[Card.ct.fs]){const i=parseFloat(t[Card.ct.fs]);this.aspectRatio=isNaN(i)?null:i}return null!=t[Card.ct.xs]&&(this.extras=t[Card.ct.xs]),null!=t[Card.ct.js]&&(this.pinned=t[Card.ct.js]),null!=t[Card.ct.zs]&&(this.dismissible=t[Card.ct.zs]),null!=t[Card.ct.ks]&&(this.test=t[Card.ct.ks]),!0}}Card.Dt=-1,Card.es={st:"captioned_image",Ct:"text_announcement",dt:"short_news",rs:"banner_image",Rt:"control"},Card.ct={ns:"id",ls:"v",zs:"db",At:"r",us:"ca",js:"p",ps:"ea",xs:"e",ts:"tp",os:"i",it:"tt",ht:"ds",URL:"u",bs:"dm",fs:"ar",gs:"cl",ks:"t"},Card.hs={ns:"id",ls:"v",zs:"db",cs:"cr",us:"ca",js:"p",ds:"t",ps:"ea",xs:"e",ts:"tp",os:"i",it:"tt",ht:"ds",URL:"u",bs:"dm",fs:"ar",gs:"cl",ks:"s"},Card._t={Lt:"ADVERTISING",Ot:"ANNOUNCEMENTS",bt:"NEWS",ft:"SOCIAL"},Card.It=400;
1
+ import{convertMsToSeconds as l,dateFromUnixTimestamp as h}from"../../util/date-utils.js";import{FEED_ANIMATION_DURATION as E}from"../../common/constants.js";import u from"../../managers/subscription-manager.js";export default class Card{constructor(t,i,s,n,l,h,e,r,E,u,T,o,I,a,N,S){this.id=t,this.viewed=i||!1,this.title=s||"",this.imageUrl=n,this.description=l||"",this.created=h||null,this.updated=e||null,this.categories=r||[],this.expiresAt=E||null,this.url=u,this.linkText=T,o=parseFloat(o),this.aspectRatio=isNaN(o)?null:o,this.extras=I,this.pinned=a||!1,this.dismissible=N||!1,this.dismissed=!1,this.clicked=S||!1,this.test=!1,this.lt=null,this.Et=null}subscribeToClickedEvent(t){return this.Tt().ut(t)}subscribeToDismissedEvent(t){return this.It().ut(t)}removeSubscription(t){this.Tt().removeSubscription(t),this.It().removeSubscription(t)}removeAllSubscriptions(){this.Tt().removeAllSubscriptions(),this.It().removeAllSubscriptions()}dismissCard(){if(this.dismissible&&!this.dismissed){this.tt&&this.tt(this);var t=this.X;t&&(t.style.height=t.offsetHeight+"px",t.className=t.className+" ab-hide",setTimeout((function(){t&&t.parentNode&&(t.style.height="0",t.style.margin="0",setTimeout((function(){t&&t.parentNode&&t.parentNode.removeChild(t)}),Card.Nt))}),E))}}Tt(){return null==this.lt&&(this.lt=new u),this.lt}It(){return null==this.Et&&(this.Et=new u),this.Et}R(){this.viewed=!0}k(){this.viewed=!0,this.clicked=!0,this.Tt().St()}J(){return!(!this.dismissible||this.dismissed)&&(this.dismissed=!0,this.It().St(),!0)}ct(t){if(null==t||t[Card.At.ns]!==this.id)return!0;if(t[Card.At.Dt])return!1;if(null!=t[Card.At.us]&&null!=this.updated&&t[Card.At.us]<l(this.updated.valueOf()))return!0;if(t[Card.At.ls]&&!this.viewed&&(this.viewed=!0),t[Card.At.gs]&&!this.clicked&&(this.clicked=t[Card.At.gs]),null!=t[Card.At.ht]&&(this.title=t[Card.At.ht]),null!=t[Card.At.os]&&(this.imageUrl=t[Card.At.os]),null!=t[Card.At.rt]&&(this.description=t[Card.At.rt]),null!=t[Card.At.us]){const i=h(t[Card.At.us]);null!=i&&(this.updated=i)}if(null!=t[Card.At.ps]){let i;i=t[Card.At.ps]===Card.Ct?null:h(t[Card.At.ps]),this.expiresAt=i}if(null!=t[Card.At.URL]&&(this.url=t[Card.At.URL]),null!=t[Card.At.bs]&&(this.linkText=t[Card.At.bs]),null!=t[Card.At.fs]){const i=parseFloat(t[Card.At.fs]);this.aspectRatio=isNaN(i)?null:i}return null!=t[Card.At.xs]&&(this.extras=t[Card.At.xs]),null!=t[Card.At.js]&&(this.pinned=t[Card.At.js]),null!=t[Card.At.zs]&&(this.dismissible=t[Card.At.zs]),null!=t[Card.At.ks]&&(this.test=t[Card.At.ks]),!0}}Card.Ct=-1,Card.es={st:"captioned_image",dt:"text_announcement",Rt:"short_news",rs:"banner_image",_t:"control"},Card.At={ns:"id",ls:"v",zs:"db",Dt:"r",us:"ca",js:"p",ps:"ea",xs:"e",ts:"tp",os:"i",ht:"tt",rt:"ds",URL:"u",bs:"dm",fs:"ar",gs:"cl",ks:"t"},Card.hs={ns:"id",ls:"v",zs:"db",cs:"cr",us:"ca",js:"p",ds:"t",ps:"ea",xs:"e",ts:"tp",os:"i",ht:"tt",rt:"ds",URL:"u",bs:"dm",fs:"ar",gs:"cl",ks:"s"},Card.Lt={Ot:"ADVERTISING",bt:"ANNOUNCEMENTS",ft:"NEWS",Pt:"SOCIAL"},Card.Nt=400;
@@ -1 +1 @@
1
- import Card from"./card.js";export default class ClassicCard extends Card{constructor(s,t,i,h,r,c,e,a,o,d,l,n,u,p,f,m){super(s,t,i,h,r,c,e,a,o,d,l,n,u,p,f,m),this.Y="ab-classic-card",this.Z=!0}ss(){const s={};return s[Card.hs.ts]=Card.es.dt,s[Card.hs.ns]=this.id,s[Card.hs.ls]=this.viewed,s[Card.hs.it]=this.title,s[Card.hs.os]=this.imageUrl,s[Card.hs.ht]=this.description,s[Card.hs.us]=this.updated,s[Card.hs.cs]=this.created,s[Card.hs.ds]=this.categories,s[Card.hs.ps]=this.expiresAt,s[Card.hs.URL]=this.url,s[Card.hs.bs]=this.linkText,s[Card.hs.fs]=this.aspectRatio,s[Card.hs.xs]=this.extras,s[Card.hs.js]=this.pinned,s[Card.hs.zs]=this.dismissible,s[Card.hs.gs]=this.clicked,s[Card.hs.ks]=this.test,s}}
1
+ import Card from"./card.js";export default class ClassicCard extends Card{constructor(s,t,i,h,r,c,e,a,o,d,l,n,u,p,f,m){super(s,t,i,h,r,c,e,a,o,d,l,n,u,p,f,m),this.Y="ab-classic-card",this.Z=!0}ss(){const s={};return s[Card.hs.ts]=Card.es.Rt,s[Card.hs.ns]=this.id,s[Card.hs.ls]=this.viewed,s[Card.hs.ht]=this.title,s[Card.hs.os]=this.imageUrl,s[Card.hs.rt]=this.description,s[Card.hs.us]=this.updated,s[Card.hs.cs]=this.created,s[Card.hs.ds]=this.categories,s[Card.hs.ps]=this.expiresAt,s[Card.hs.URL]=this.url,s[Card.hs.bs]=this.linkText,s[Card.hs.fs]=this.aspectRatio,s[Card.hs.xs]=this.extras,s[Card.hs.js]=this.pinned,s[Card.hs.zs]=this.dismissible,s[Card.hs.gs]=this.clicked,s[Card.hs.ks]=this.test,s}}
@@ -1 +1 @@
1
- import Card from"./card.js";export default class ControlCard extends Card{constructor(l,t,s,n,u,i){super(l,t,null,null,null,null,s,null,n,null,null,null,u,i,null),this.Y="ab-control-card",this.Z=!1}ss(){const l={};return l[Card.hs.ts]=Card.es.Rt,l[Card.hs.ns]=this.id,l[Card.hs.ls]=this.viewed,l[Card.hs.us]=this.updated,l[Card.hs.ps]=this.expiresAt,l[Card.hs.xs]=this.extras,l[Card.hs.js]=this.pinned,l[Card.hs.ks]=this.test,l}}
1
+ import Card from"./card.js";export default class ControlCard extends Card{constructor(l,t,s,n,u,i){super(l,t,null,null,null,null,s,null,n,null,null,null,u,i,null),this.Y="ab-control-card",this.Z=!1}ss(){const l={};return l[Card.hs.ts]=Card.es._t,l[Card.hs.ns]=this.id,l[Card.hs.ls]=this.viewed,l[Card.hs.us]=this.updated,l[Card.hs.ps]=this.expiresAt,l[Card.hs.xs]=this.extras,l[Card.hs.js]=this.pinned,l[Card.hs.ks]=this.test,l}}
@@ -1 +1 @@
1
- import{Card,Banner,CaptionedImage,ClassicCard,ControlCard}from"../index.js";import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export function newCard(e,n,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x,F){let b;if(n===Card.es.Ct||n===Card.es.dt)b=new ClassicCard(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.st)b=new CaptionedImage(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.rs)b=new Banner(e,t,i,u,d,a,s,w,f,m,C,p,c,x);else{if(n!==Card.es.Rt)return r.D.error("Ignoring card with unknown type "+n),null;b=new ControlCard(e,t,d,s,C,p)}return F&&(b.test=F),b}export function newCardFromContentCardsJson(e){if(e[Card.ct.At])return null;const n=e[Card.ct.ns],r=e[Card.ct.ts],t=e[Card.ct.ls],o=e[Card.ct.it],i=e[Card.ct.os],l=e[Card.ct.ht],u=h(e[Card.ct.us]),d=u;let a;a=e[Card.ct.ps]===Card.Dt?null:h(e[Card.ct.ps]);return newCard(n,r,t,o,i,l,d,u,null,a,e[Card.ct.URL],e[Card.ct.bs],e[Card.ct.fs],e[Card.ct.xs],e[Card.ct.js],e[Card.ct.zs],e[Card.ct.gs],e[Card.ct.ks]||!1)}export function newCardFromFeedJson(e){return newCard(e.id,e.type,e.viewed,e.title,e.image,e.description,h(e.created),h(e.updated),e.categories,h(e.expires_at),e.url,e.domain,e.aspect_ratio,e.extras,!1,!1)}export function newCardFromSerializedValue(e){return newCard(e[Card.hs.ns],e[Card.hs.ts],e[Card.hs.ls],e[Card.hs.it],e[Card.hs.os],e[Card.hs.ht],w(e[Card.hs.cs]),w(e[Card.hs.us]),e[Card.hs.ds],w(e[Card.hs.ps]),e[Card.hs.URL],e[Card.hs.bs],e[Card.hs.fs],e[Card.hs.xs],e[Card.hs.js],e[Card.hs.zs],e[Card.hs.gs],e[Card.hs.ks]||!1)||void 0}
1
+ import{Card,Banner,CaptionedImage,ClassicCard,ControlCard}from"../index.js";import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export function newCard(e,n,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x,F){let b;if(n===Card.es.dt||n===Card.es.Rt)b=new ClassicCard(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.st)b=new CaptionedImage(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.rs)b=new Banner(e,t,i,u,d,a,s,w,f,m,C,p,c,x);else{if(n!==Card.es._t)return r.D.error("Ignoring card with unknown type "+n),null;b=new ControlCard(e,t,d,s,C,p)}return F&&(b.test=F),b}export function newCardFromContentCardsJson(e){if(e[Card.At.Dt])return null;const n=e[Card.At.ns],r=e[Card.At.ts],t=e[Card.At.ls],o=e[Card.At.ht],i=e[Card.At.os],l=e[Card.At.rt],u=h(e[Card.At.us]),d=u;let a;a=e[Card.At.ps]===Card.Ct?null:h(e[Card.At.ps]);return newCard(n,r,t,o,i,l,d,u,null,a,e[Card.At.URL],e[Card.At.bs],e[Card.At.fs],e[Card.At.xs],e[Card.At.js],e[Card.At.zs],e[Card.At.gs],e[Card.At.ks]||!1)}export function newCardFromFeedJson(e){return newCard(e.id,e.type,e.viewed,e.title,e.image,e.description,h(e.created),h(e.updated),e.categories,h(e.expires_at),e.url,e.domain,e.aspect_ratio,e.extras,!1,!1)}export function newCardFromSerializedValue(e){return newCard(e[Card.hs.ns],e[Card.hs.ts],e[Card.hs.ls],e[Card.hs.ht],e[Card.hs.os],e[Card.hs.rt],w(e[Card.hs.cs]),w(e[Card.hs.us]),e[Card.hs.ds],w(e[Card.hs.ps]),e[Card.hs.URL],e[Card.hs.bs],e[Card.hs.fs],e[Card.hs.xs],e[Card.hs.js],e[Card.hs.zs],e[Card.hs.gs],e[Card.hs.ks]||!1)||void 0}
@@ -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.Ut(this.vt),this.yt=0,this.kt=0,this.zt();const o=r.Ft.xt;new r.qt(o,r.D).Jt(o.Pt.Mt,(t=>{this.$t(t)}))}Bt(){return this.Gt}Ht(t){this.Gt=t}Kt(){return this.Qt}Vt(t){this.Qt=t}zt(){const t=this.h.I(o.q.Wt)||[],s=[];for(let i=0;i<t.length;i++){const e=_(t[i]);null!=e&&s.push(e)}this.Xt=this.Yt(this.Zt(s,!1)),this.yt=this.h.I(o.q.Cs)||this.yt,this.kt=this.h.I(o.q.ws)||this.kt}vs(t,s,i,e){let h;if(s){h=[];for(const t of this.Xt)t.test&&h.push(t)}else h=this.Xt.slice();for(let i=0;i<t.length;i++){const e=t[i];let r=null;for(let t=0;t<this.Xt.length;t++)if(e.id===this.Xt[t].id){r=this.Xt[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.St(e))for(let t=0;t<h.length;t++)if(e.id===h[t].id){h.splice(t,1);break}}}this.Xt=this.Yt(this.Zt(h,s)),this.Ss(),this.yt=i||0,this.h.B(o.q.Cs,this.yt),this.kt=e||0,this.h.B(o.q.ws,this.kt)}_s(t){if(this.Us()&&null!=t&&t.cards){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.Nt(this.ys(!0))}}$t(t){if(!this.Us())return;this.zt();const s=this.Xt.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.Xt.length;t++)if(i.id===this.Xt[t].id){h=this.Xt[t];break}if(null==h){const t=S(i);null!=t&&s.push(t)}else{if(!h.St(i))for(let t=0;t<s.length;t++)if(i.id===s[t].id){s.splice(t,1);break}}}this.Xt=this.Yt(this.Zt(s,!1)),this.Ss(),this.vt.Nt(this.ys(!0))}Zt(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}Yt(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}Ss(){const t=[];for(let s=0;s<this.Xt.length;s++)t.push(this.Xt[s].ss());this.h.B(o.q.Wt,t)}Ts(t,s){if(!this.Us())return void(this.Ds||(this.Ds=this.wt.Rs((()=>{this.Ts(t,s)}))));const i=this.jt.Ls({},!0);i.last_full_sync_at=this.yt,i.last_card_updated_at=this.kt;const e=this.jt.Ns(i,!0);this.jt.As(i,(()=>{b.Fs({url:this.jt.Js()+"/content_cards/sync",data:i,headers:e,S:h=>{this.jt.qs(i,h,e)?(this.jt.Es(),this._s(h),"function"==typeof t&&t()):"function"==typeof s&&s()},error:t=>{this.jt.Ms(t,"retrieving content cards"),"function"==typeof s&&s()}})}))}ys(t){t||this.zt();const s=this.Yt(this.Xt);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.yt||0);return 0===i&&(i=void 0),this.h.I(o.q.ws)===this.kt&&void 0===i&&(i=this.kt),new ContentCards(s,h(i))}Ps(t){return this.vt.Et(t)}changeUser(t){t||(this.Xt=[],this.vt.Nt(new ContentCards(this.Xt.slice(),null)),this.h.$s(o.q.Wt),this.h.$s(o.q.$),this.h.$s(o.q.O),this.h.$s(o.q.K)),this.yt=0,this.kt=0,this.h.$s(o.q.Cs),this.h.$s(o.q.ws)}clearData(t){this.yt=0,this.kt=0,this.Xt=[],this.vt.Nt(new ContentCards(this.Xt.slice(),null)),t&&(this.h.$s(o.q.Wt),this.h.$s(o.q.$),this.h.$s(o.q.O),this.h.$s(o.q.K),this.h.$s(o.q.Cs),this.h.$s(o.q.ws))}Us(){return!!this.wt.Bs()||(0!==this.wt.Gs()&&this.Hs(),!1)}Hs(){this.vt.Nt(new ContentCards([],(new Date).valueOf())),this.h.$s(o.q.Wt)}}
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 +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().ys(!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 +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().Ts(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().Fs(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.Ps(r);if(!t.Kt()){const r=e.mr().cr((()=>{t.Ts()}));t.Vt(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.Hs(r);if(!t.Qt()){const r=e.mr().cr((()=>{t.Fs()}));t.Wt(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().ys(!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.Bt()||(new Date).valueOf()-f.Bt()>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.Ht((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 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 +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.Ft.xt;new r.qt(a,r.D).setItem(a.Pt.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 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 +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.Ft.xt;new r.qt(a,r.D).br(a.Pt.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 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 +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.Ft.xt,o=new r.qt(i,r.D);o.hr(i.Pt.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.Pt.jr,t)})),o.Jt(i.Pt.$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 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 +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.Ft);for(let e=0;e<o.length;e++){const i=o[e],t=r.Ft[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 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 +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.Is=s,this.vt=new u,e.Ut(this.vt),this.zt()}zt(){const t=this.h.I(o.q.Ks)||[],s=[];for(let i=0;i<t.length;i++){const e=_(t[i]);null!=e&&s.push(e)}this.Xt=s,this.Os=w(this.h.I(o.q.Qs))}Vs(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.Xt=s,this.Ss(),this.Os=new Date,this.h.B(o.q.Qs,this.Os)}Ss(){const t=[];for(let s=0;s<this.Xt.length;s++)t.push(this.Xt[s].ss());this.h.B(o.q.Ks,t)}_s(t){null!=t&&t.feed&&(this.zt(),this.Vs(t.feed),this.vt.Nt(new Feed(this.Xt.slice(),this.Os)))}Ws(){this.zt();const t=[],s=new Date;for(let i=0;i<this.Xt.length;i++)(null==this.Xt[i].expiresAt||this.Xt[i].expiresAt>=s)&&t.push(this.Xt[i]);return new Feed(t,this.Os)}Ts(){this.Is.requestFeedRefresh()}Ps(t){return this.vt.Et(t)}clearData(t){null==t&&(t=!1),this.Xt=[],this.Os=null,t&&(this.h.$s(o.q.Ks),this.h.$s(o.q.Qs)),this.vt.Nt(new Feed(this.Xt.slice(),this.Os))}}
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 +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().Ws()}
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 +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().Ts()}
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 +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().Ps(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().Hs(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().Ws(),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 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 +1 @@
1
- import{addPassiveEventListener as oe,buildSvg as ae,detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{createCloseButton as i}from"../../util/component-utils.js";import{isTransparent as ie,toRgba as ne}from"../../util/color-utils.js";import FullScreenMessage from"../models/full-screen-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import ModalMessage from"../models/modal-message.js";import SlideUpMessage from"../models/slide-up-message.js";import{logInAppMessageClick}from"../log-in-app-message-click.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import rt from"./html-message-to-html.js";import me from"./modal-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export default function ce(e,o,s,t,a,n){if(e.he=document.activeElement,e instanceof HtmlMessage)return rt(e,o,s,t,a,n);const l=function(e,o,s,t,a){const n=document.createElement("div");n.className="ab-in-app-message ab-start-hidden ab-background",a&&(n.style.zIndex=a+1),e.we()&&(n.className+=" ab-modal-interactions",n.setAttribute("tabindex","-1")),e.sn()||(n.style.color=ne(e.textColor),n.style.backgroundColor=ne(e.backgroundColor),ie(e.backgroundColor)&&(n.className+=" ab-no-shadow"));const c=()=>{-1!==n.className.indexOf("ab-start-hidden")&&(n.className=n.className.replace("ab-start-hidden",""),s(n))};e.imageStyle===InAppMessage.ImageStyle.GRAPHIC&&(n.className+=" graphic"),e.orientation===InAppMessage.Orientation.LANDSCAPE&&(n.className+=" landscape"),0===e.buttons.length&&(e.clickAction!==InAppMessage.ClickAction.NONE&&(n.className+=" ab-clickable"),n.onclick=s=>(e.on(n,(()=>{logInAppMessageClick(e),e.clickAction===InAppMessage.ClickAction.URI?m(e.uri,s,t||e.openTarget===InAppMessage.OpenTarget.BLANK):e.clickAction===InAppMessage.ClickAction.NEWS_FEED&&o()})),s.stopPropagation(),!1));const l=i("Close Message",e.sn()?void 0:ne(e.closeButtonColor),(()=>{e.on(n)}));n.appendChild(l),a&&(l.style.zIndex=a+2);const d=document.createElement("div");d.className="ab-message-text";const u=(e.messageAlignment||e.ke).toLowerCase();d.className+=" "+u+"-aligned";let b=!1;const f=document.createElement("div");if(f.className="ab-image-area",e.imageUrl){if(e.cropType===InAppMessage.CropType.CENTER_CROP){const o=document.createElement("span");o.className="ab-center-cropped-img",o.style.backgroundImage="url("+e.imageUrl+")",o.setAttribute("role","img"),o.setAttribute("aria-label","Modal Image"),e.xe(o),f.appendChild(o)}else{const o=document.createElement("img");o.setAttribute("src",e.imageUrl),e.xe(o),b=!0,o.onload=c,setTimeout(c,1e3),f.appendChild(o)}n.appendChild(f),d.className+=" ab-with-image"}else if(e.icon){f.className+=" ab-icon-area";const o=document.createElement("span");o.className="ab-icon",e.sn()||(o.style.backgroundColor=ne(e.iconBackgroundColor),o.style.color=ne(e.iconColor));const s=document.createElement("i");s.className="fa",s.appendChild(document.createTextNode(e.icon)),s.setAttribute("aria-hidden",!0),o.appendChild(s),f.appendChild(o),n.appendChild(f),d.className+=" ab-with-icon"}if(oe(d,"touchstart",(function(){})),e.header&&e.header.length>0){const o=document.createElement("h1");o.className="ab-message-header",e.ze=r.nt.et(),o.id=e.ze;const s=(e.headerAlignment||InAppMessage.TextAlignment.CENTER).toLowerCase();o.className+=" "+s+"-aligned",e.sn()||(o.style.color=ne(e.headerTextColor)),o.appendChild(document.createTextNode(e.header)),d.appendChild(o)}return d.appendChild(e.Me()),n.appendChild(d),b||c(),e.mn=n,n}(e,o,s,t,a);if(e instanceof FullScreenMessage||e instanceof ModalMessage){const s=e instanceof FullScreenMessage?"ab-fullscreen":"ab-modal";l.className+=` ${s} ab-centered`,me.Ce(e,o,l,t),me.Le(l),me.Ie(e.ze,l)}else if(e instanceof SlideUpMessage){l.className+=" ab-slideup";const o=l.getElementsByClassName("ab-close-button")[0];if(null!=o){const s=ae("0 0 11.38 19.44","M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",e.sn()?void 0:ne(e.closeButtonColor));s.setAttribute("class","ab-chevron"),o.appendChild(s)}let s,t;d(l,c.ot,(e=>{l.className+=" ab-swiped-left",o.onclick(e)})),d(l,c.at,(e=>{l.className+=" ab-swiped-right",o.onclick(e)})),e.slideFrom===InAppMessage.SlideFrom.TOP?(s=c.Te,t=" ab-swiped-up"):(s=c.$e,t=" ab-swiped-down"),d(l,s,(e=>{l.className+=t,o.onclick(e)}))}return l}
1
+ import{addPassiveEventListener as oe,buildSvg as ae,detectSwipe as d,DIRECTIONS as c}from"../../util/dom-utils.js";import{createCloseButton as i}from"../../util/component-utils.js";import{isTransparent as ie,toRgba as ne}from"../../util/color-utils.js";import FullScreenMessage from"../models/full-screen-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import ModalMessage from"../models/modal-message.js";import SlideUpMessage from"../models/slide-up-message.js";import{logInAppMessageClick}from"../log-in-app-message-click.js";import{_handleBrazeAction as m}from"../../Core/handle-braze-action.js";import rt from"./html-message-to-html.js";import me from"./modal-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export default function ce(e,o,s,t,a,n){if(e.he=document.activeElement,e instanceof HtmlMessage)return rt(e,o,s,t,a,n);const l=function(e,o,s,t,a){const n=document.createElement("div");n.className="ab-in-app-message ab-start-hidden ab-background",a&&(n.style.zIndex=a+1),e.we()&&(n.className+=" ab-modal-interactions",n.setAttribute("tabindex","-1")),e.sn()||(n.style.color=ne(e.textColor),n.style.backgroundColor=ne(e.backgroundColor),ie(e.backgroundColor)&&(n.className+=" ab-no-shadow"));const c=()=>{-1!==n.className.indexOf("ab-start-hidden")&&(n.className=n.className.replace("ab-start-hidden",""),s(n))};e.imageStyle===InAppMessage.ImageStyle.GRAPHIC&&(n.className+=" graphic"),e.orientation===InAppMessage.Orientation.LANDSCAPE&&(n.className+=" landscape"),0===e.buttons.length&&(e.clickAction!==InAppMessage.ClickAction.NONE&&(n.className+=" ab-clickable"),n.onclick=s=>(e.on(n,(()=>{logInAppMessageClick(e),e.clickAction===InAppMessage.ClickAction.URI?m(e.uri,s,t||e.openTarget===InAppMessage.OpenTarget.BLANK):e.clickAction===InAppMessage.ClickAction.NEWS_FEED&&o()})),s.stopPropagation(),!1));const l=i("Close Message",e.sn()?void 0:ne(e.closeButtonColor),(()=>{e.on(n)}));n.appendChild(l),a&&(l.style.zIndex=a+2);const d=document.createElement("div");d.className="ab-message-text";const u=(e.messageAlignment||e.ke).toLowerCase();d.className+=" "+u+"-aligned";let b=!1;const f=document.createElement("div");if(f.className="ab-image-area",e.imageUrl){if(e.cropType===InAppMessage.CropType.CENTER_CROP){const o=document.createElement("span");o.className="ab-center-cropped-img",o.style.backgroundImage="url("+e.imageUrl+")",o.setAttribute("role","img"),o.setAttribute("aria-label","Modal Image"),e.xe(o),f.appendChild(o)}else{const o=document.createElement("img");o.setAttribute("src",e.imageUrl),e.xe(o),b=!0,o.onload=c,setTimeout(c,1e3),f.appendChild(o)}n.appendChild(f),d.className+=" ab-with-image"}else if(e.icon){f.className+=" ab-icon-area";const o=document.createElement("span");o.className="ab-icon",e.sn()||(o.style.backgroundColor=ne(e.iconBackgroundColor),o.style.color=ne(e.iconColor));const s=document.createElement("i");s.className="fa",s.appendChild(document.createTextNode(e.icon)),s.setAttribute("aria-hidden",!0),o.appendChild(s),f.appendChild(o),n.appendChild(f),d.className+=" ab-with-icon"}if(oe(d,"touchstart",(function(){})),e.header&&e.header.length>0){const o=document.createElement("h1");o.className="ab-message-header",e.ze=r.it.nt(),o.id=e.ze;const s=(e.headerAlignment||InAppMessage.TextAlignment.CENTER).toLowerCase();o.className+=" "+s+"-aligned",e.sn()||(o.style.color=ne(e.headerTextColor)),o.appendChild(document.createTextNode(e.header)),d.appendChild(o)}return d.appendChild(e.Me()),n.appendChild(d),b||c(),e.mn=n,n}(e,o,s,t,a);if(e instanceof FullScreenMessage||e instanceof ModalMessage){const s=e instanceof FullScreenMessage?"ab-fullscreen":"ab-modal";l.className+=` ${s} ab-centered`,me.Ce(e,o,l,t),me.Le(l),me.Ie(e.ze,l)}else if(e instanceof SlideUpMessage){l.className+=" ab-slideup";const o=l.getElementsByClassName("ab-close-button")[0];if(null!=o){const s=ae("0 0 11.38 19.44","M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",e.sn()?void 0:ne(e.closeButtonColor));s.setAttribute("class","ab-chevron"),o.appendChild(s)}let s,t;d(l,c.ot,(e=>{l.className+=" ab-swiped-left",o.onclick(e)})),d(l,c.et,(e=>{l.className+=" ab-swiped-right",o.onclick(e)})),e.slideFrom===InAppMessage.SlideFrom.TOP?(s=c.Te,t=" ab-swiped-up"):(s=c.$e,t=" ab-swiped-down"),d(l,s,(e=>{l.className+=t,o.onclick(e)}))}return l}
@@ -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.Ut(this.De),this._e=1e3,this.Se=6e4}Be(){return this.De}Ee(t){return this.De.Et(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}Xs(t,e,s,i){let n=this.jt.Ys(!1,!1);n=this.jt.Ls(n),n.template={trigger_id:t.triggerId,trigger_event_type:e},null!=s&&(n.template.data=s.Zs());const o=this.jt.Ns(n);this.jt.As(n,(()=>{b.Fs({url:`${this.jt.Js()}/template/`,data:n,headers:o,S:async e=>{if(!this.jt.qs(n,e,o))return this.qe(t.triggerId,InAppMessage.Oe.ei),void("function"==typeof t.si&&t.si());if(this.jt.Es(),null==e||null==e.templated_message)return void this.qe(t.triggerId,InAppMessage.Oe.ei);const s=e.templated_message;if(s.type!==ut.ri.ii)return void this.qe(t.triggerId,InAppMessage.Oe.ni);const i=it(s.data);if(null==i)return void this.qe(t.triggerId,InAppMessage.Oe.ni);let a=await this.Ve(i);if(a)return r.D.error(a),void("function"==typeof t.si&&t.si());"function"==typeof t.oi?t.oi(i):this.qe(t.triggerId,InAppMessage.Oe.ei)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.ai>t.li)this.qe(t.triggerId,InAppMessage.Oe.ei);else{const r=Math.min(t.li,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.Xs(t,e,s,a)}),a)}this.jt.Ms(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 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 +1 @@
1
- import InAppMessage from"./in-app-message.js";export default class HtmlMessage extends InAppMessage{constructor(l,e,n,u,s,a,t,i,r,o,m){u=u||InAppMessage.DismissType.MANUAL,null!=l&&l.length>0&&l.indexOf('"ab-in-app-message ab-html-message ab-email-capture"')>0&&l.indexOf('"ab-in-app-message ab-show ab-modal ab-effect-modal"')>0&&(a=!0,t=!0),super(l,null,null,e,n,null,null,null,u,s,null,null,null,null,null,null,null,null,a,t,null,null,null,i,void 0,void 0,void 0,r,o),this.messageFields=m}ll(){return!1}k(l){if(this.un===InAppMessage.es.el){if(this.nl)return!1;this.nl=!0}return this.lt.Nt(l),!0}}HtmlMessage.es=InAppMessage.es.el;
1
+ import InAppMessage from"./in-app-message.js";export default class HtmlMessage extends InAppMessage{constructor(l,e,n,u,s,a,t,i,r,o,m){u=u||InAppMessage.DismissType.MANUAL,null!=l&&l.length>0&&l.indexOf('"ab-in-app-message ab-html-message ab-email-capture"')>0&&l.indexOf('"ab-in-app-message ab-show ab-modal ab-effect-modal"')>0&&(a=!0,t=!0),super(l,null,null,e,n,null,null,null,u,s,null,null,null,null,null,null,null,null,a,t,null,null,null,i,void 0,void 0,void 0,r,o),this.messageFields=m}ll(){return!1}k(l){if(this.un===InAppMessage.es.el){if(this.nl)return!1;this.nl=!0}return this.lt.St(l),!0}}HtmlMessage.es=InAppMessage.es.el;
@@ -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.ci.hi,this.textColor=i||InAppMessage.ci.mi,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.Et(s)}removeSubscription(s){this.lt.removeSubscription(s)}removeAllSubscriptions(){this.lt.removeAllSubscriptions()}k(){return!this.nl&&(this.nl=!0,this.lt.Nt(),!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.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 +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.ci.mi,this.iconBackgroundColor=I||InAppMessage.ci.hi,this.backgroundColor=A||InAppMessage.ci.mi,this.textColor=N||InAppMessage.ci.Ei,this.closeButtonColor=_||InAppMessage.ci.ui,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.ci.Ei,this.frameColor=M||InAppMessage.ci.Ti,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ii=!1,this.nl=!1,this.Ai=!1,this.lt=new u,this.Ni=new u}subscribeToClickedEvent(t){return this.lt.Et(t)}subscribeToDismissedEvent(t){return this.Ni.Et(t)}removeSubscription(t){this.lt.removeSubscription(t),this.Ni.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this.Ni.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.Ii&&(this.Ii=!0,!0)}k(){return!this.nl&&(this.nl=!0,this.lt.Nt(),!0)}J(){return!this.Ai&&(this.Ai=!0,this.Ni.Nt(),!0)}_i(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.Li)&&t.remove(InAppMessage.Li),document.body.removeEventListener("touchmove",InAppMessage.di)}s.className=s.className.replace(InAppMessage.Oi,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._i(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.Si):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 di(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.Li}`)&&t.preventDefault()}Di(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage.Li),document.body.addEventListener("touchmove",InAppMessage.di,!!Et()&&{passive:!1})),t.className+=" "+InAppMessage.Oi}static Mi(t){if(t.keyCode===at.Ri&&!e.nn(D.bi)&&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)}}}Pi(){this.Ci||e.nn(D.bi)||(document.addEventListener("keydown",InAppMessage.Mi,!1),e.Ui((()=>{document.removeEventListener("keydown",InAppMessage.Mi)})),this.Ci=!0)}}InAppMessage.ci={Ei:4281545523,mi:4294967295,hi:4278219733,pi:4293914607,fi:4283782485,Ti:3224580915,ui:4288387995},InAppMessage.Oe={gi:"hd",Hi:"ias",Fi:"of",Bi:"do",ni:"umt",ei:"tf",vi:"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={Gi:"SLIDEUP",Wi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",el:"WEB_HTML",cn:"HTML"},InAppMessage.Si=500,InAppMessage.ki=200,InAppMessage.Oi="ab-show",InAppMessage.wi="ab-hide",InAppMessage.Li="ab-pause-scrolling";
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 +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.Wi;
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 +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.ci.fi,v=v||InAppMessage.ci.pi,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}Di(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.Di(t)}}SlideUpMessage.es=InAppMessage.es.Gi;
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 +1 @@
1
- export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.oi=s,this.si=l,this.ai=n,this.li=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.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 +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.Pi();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.gi),!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.Hi),!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.Fi),!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.gi),!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.bi)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.ki&&(t.on(s),o.stopPropagation())}}a.appendChild(s),s.focus(),t.Di(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.bi)){const e=t;s.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.Ri&&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.Di(a)),!0}
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 +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.Js(),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 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 +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,h,a){this.yi=i,this.ji=e,this.xi=t,this.zi=s+"/safari/"+e,this.Vi=n||"/service-worker.js",this.qi=r,this.wt=o,this.Yi=u||!1,this.Ji=h||!1,this.h=a,this.Ki="serviceWorker"in navigator&&"undefined"!=typeof ServiceWorkerRegistration&&"showNotification"in ServiceWorkerRegistration.prototype&&"PushManager"in window,this.Qi="safari"in window&&"pushNotification"in window.safari&&"function"==typeof window.safari.pushNotification.permission&&"function"==typeof window.safari.pushNotification.requestPermission}Xi(){return this.Ji}isPushSupported(){return this.Ki||this.Qi}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()}Zi(i,e,t,s,n){i.unsubscribe().then((i=>{i?this.$i(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)}))}hn(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.dn&&-1===i.endpoint.indexOf(i.dn)&&(e=i.endpoint+"/"+i.dn),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.yi.fn(s,t,n,r,o),s&&"function"==typeof e&&e(s,n,r)}pn(){this.yi.wn(!0)}bn(i,e){this.yi.wn(!1),r.D.info(i),"function"==typeof e&&e(!1)}gn(i,e,t,s){if("default"===e.permission)try{window.safari.pushNotification.requestPermission(this.zi,i,{api_key:this.ji,device_id:this.xi.te().id},(e=>{"granted"===e.permission&&this.yi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.gn(i,e,t,s)}))}catch(i){this.bn("Could not request permission for push: "+i,s)}else"denied"===e.permission?this.bn("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.hn(e.deviceToken,t,new Date))}yn(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}$i(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.hn(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)}))}vn(){return this.Yi?navigator.serviceWorker.getRegistration():navigator.serviceWorker.register(this.Vi).then((()=>navigator.serviceWorker.ready.then((i=>(i&&"function"==typeof i.update&&i.update().catch((i=>{r.D.info("ServiceWorker update failed: "+i)})),i)))))}Pn(i){this.Yi||(i.unregister(),r.D.info("Service worker successfully unregistered."))}subscribe(i,e){if(this.isPushSupported()){if(this.Ki){if(!this.Yi&&null!=window.location){let i=this.Vi;-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.kn().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.bn("Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",e);if(this.wt&&!this.wt.Sn()&&0===this.wt.Gs())return r.D.info("Waiting for VAPID key from server config before subscribing to push."),void this.wt.Dn((()=>{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.yi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.vn().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.Sn()&&(n=r.Nn._n(this.wt.Sn())),s){let u=null,h=null;const a=this.h.I(o.q.Wn);if(a&&!p(a)){let i;try{i=ei.jn(a).An}catch(e){i=null}null==i||isNaN(i.getTime())||0===i.getTime()||(u=i,h=new Date(u),h.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.Zi(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.Zi(s,t,n,i,e)):a&&p(a)?this.Zi(s,t,n,i,e):null==h?(r.D.info("No push subscription creation date found, creating new subscription."),this.Zi(s,t,n,i,e)):h<=(new Date).valueOf()?(r.D.info("Push subscription older than 6 months, creating new subscription."),this.Zi(s,t,n,i,e)):(r.D.info("Device already subscribed to push, sending existing subscription to backend."),this.hn(s,i,u))}else this.$i(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.yn(u,s,t)}else if(this.Qi){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.gn(this.qi,t,i,e)}}else r.D.info(this.Un)}unsubscribe(i,e){this.isPushSupported()?this.Ki?navigator.serviceWorker.getRegistration().then((t=>{t&&t.pushManager.getSubscription().then((s=>{s&&(this.pn(),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.Pn(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()}))})):this.Qi&&(this.pn(),r.D.info("Device unsubscribed from push."),"function"==typeof i&&i()):r.D.info(this.Un)}}aa.Un="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 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 +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}fn(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.Ft.xt,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.Wn,l.ss()),n.setItem(h.Pt.Mr,h.se,!0)}wn(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.Ft.xt,s=new r.qt(t,r.D);this.h.B(o.q.Wn,!1),s.setItem(t.Pt.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.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)}}}