@braze/web-sdk
Advanced tools
Comparing version 4.0.6 to 4.1.0
{ | ||
"name": "@braze/web-sdk", | ||
"version": "4.0.6", | ||
"version": "4.1.0", | ||
"description": "Braze SDK for web sites and other JS platforms.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,1 +0,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; | ||
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 +0,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; | ||
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 +0,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}; | ||
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 +0,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; | ||
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 +0,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}}; | ||
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 +0,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; | ||
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 +0,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"}; | ||
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 +0,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} | ||
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} |
@@ -1,1 +0,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*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"; |
@@ -1,1 +0,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}} | ||
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 +0,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; | ||
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 +0,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}} | ||
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 +0,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}} | ||
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 +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.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} | ||
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 +0,1 @@ | ||
import{ControlCard}from"../Card/index.js";export const FEED_ANIMATION_DURATION=500;export default class x{constructor(e,r){this.cards=e,this.lastUpdated=r}getUnreadCardCount(){let e=0;for(const r of this.cards)r.viewed||r instanceof ControlCard||e++;return e}dr(){throw new Error("Must be implemented in a subclass")}logCardImpressions(){throw new Error("Must be implemented in subclass")}logCardClick(){throw new Error("Must be implemented in subclass")}sr(){throw new Error("Must be implemented in subclass")}}x.ur=6e4,x.Si=500,x.uo=1e4; | ||
import{ControlCard}from"../Card/index.js";export const FEED_ANIMATION_DURATION=500;export default class x{constructor(e,r){this.cards=e,this.lastUpdated=r}getUnreadCardCount(){let e=0;for(const r of this.cards)r.viewed||r instanceof ControlCard||e++;return e}dr(){throw new Error("Must be implemented in a subclass")}logCardImpressions(){throw new Error("Must be implemented in subclass")}logCardClick(){throw new Error("Must be implemented in subclass")}sr(){throw new Error("Must be implemented in subclass")}}x.ur=6e4,x.Di=500,x.uo=1e4; |
@@ -1,1 +0,1 @@ | ||
export default class C{constructor(){}_s(){}changeUser(a){}clearData(){}} | ||
export default class C{constructor(){}ys(){}changeUser(a){}clearData(){}} |
@@ -1,1 +0,1 @@ | ||
import x from"./base-feed.js";import{bottomHadImpression as de,getCardId as fe,impressOnBottom as be,impressOnTop as ye,markCardAsRead as Fe,topHadImpression as Te}from"../Card/display/card-display.js";import{bottomIsInView as he,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as xe}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as at}from"../util/key-codes.js";import Ee from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt,ineligibleBrazeActionURLErrorMessage as ct,getDecodedBrazeAction as O,containsUnknownBrazeAction as mt}from"../util/braze-actions.js";export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE="data-last-requested-refresh";export const _SUBSCRIPTION_ID_DATA_ATTRIBUTE="data-update-subscription-id";export function destroyFeedHtml(e){e&&(e.className=e.className.replace("ab-show","ab-hide"),setTimeout((()=>{e&&e.parentNode&&e.parentNode.removeChild(e)}),x.Si));const t=e.getAttribute("data-update-subscription-id");null!=t&&removeSubscription(t)}export function _generateFeedBody(e,t){const o=document.createElement("div");if(o.className="ab-feed-body",o.setAttribute("aria-label","Feed"),o.setAttribute("role","feed"),null==e.lastUpdated){const e=document.createElement("div");e.className="ab-no-cards-message";const t=document.createElement("i");t.className="fa fa-spinner fa-spin fa-4x ab-initial-spinner",e.appendChild(t),o.appendChild(e)}else{let s=!1;const logCardClick=t=>{e.logCardClick(t)};for(const n of e.cards){const a=n instanceof ControlCard;!a||e.dr()?(o.appendChild(xe(n,logCardClick,t)),s=s||!a):r.D.error("Received a control card for a legacy news feed. Control cards are only supported with content cards.")}if(!s){const e=document.createElement("div");e.className="ab-no-cards-message",e.innerHTML=Ee.m().get("NO_CARDS_MESSAGE"),e.setAttribute("role","article"),o.appendChild(e)}}return o}export function detectFeedImpressions(e,t){if(null!=t){const o=[],r=t.querySelectorAll(".ab-card");e.do||(e.do={});for(let t=0;t<r.length;t++){const s=fe(r[t]);if(e.do[s])continue;let n=Te(r[t]),a=de(r[t]);const i=n,d=a,f=_e(r[t]),c=he(r[t]);if(!n&&f&&(n=!0,ye(r[t])),!a&&c&&(a=!0,be(r[t])),n&&a){if(f||c||Fe(r[t]),i&&d)continue;for(const t of e.cards)if(t.id===s){e.do[t.id]=!0,o.push(t);break}}}o.length>0&&e.logCardImpressions(o)}}export function refreshFeed(e,t){t.setAttribute("aria-busy","true");const o=t.querySelectorAll(".ab-refresh-button")[0];null!=o&&(o.className+=" fa-spin");const r=(new Date).valueOf().toString();t.setAttribute("data-last-requested-refresh",r),setTimeout((()=>{if(t.getAttribute("data-last-requested-refresh")===r){const e=t.querySelectorAll(".fa-spin");for(let t=0;t<e.length;t++)e[t].className=e[t].className.replace(/fa-spin/g,"");const o=t.querySelectorAll(".ab-initial-spinner")[0];if(null!=o){const e=document.createElement("span");e.innerHTML=Ee.m().get("FEED_TIMEOUT_MESSAGE"),o.parentNode.appendChild(e),o.parentNode.removeChild(o)}"true"===t.getAttribute("aria-busy")&&t.setAttribute("aria-busy","false")}}),x.uo),e.sr()}export function feedToHtml(e,t){const o=document.createElement("div");o.className="ab-feed ab-hide ab-effect-slide",o.setAttribute("role","dialog"),o.setAttribute("aria-label","Feed"),o.setAttribute("tabindex","-1");const r=document.createElement("div");r.className="ab-feed-buttons-wrapper",r.setAttribute("role","group"),o.appendChild(r);const s=document.createElement("i");s.className="fa fa-times ab-close-button",s.setAttribute("aria-label","Close Feed"),s.setAttribute("tabindex","0"),s.setAttribute("role","button");const n=e=>{destroyFeedHtml(o),e.stopPropagation()};s.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||n(e)})),s.onclick=n;const a=document.createElement("i");a.className="fa fa-refresh ab-refresh-button",null==e.lastUpdated&&(a.className+=" fa-spin"),a.setAttribute("aria-label","Refresh Feed"),a.setAttribute("tabindex","0"),a.setAttribute("role","button");const i=t=>{refreshFeed(e,o),t.stopPropagation()};return a.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||i(e)})),a.onclick=i,r.appendChild(a),r.appendChild(s),o.appendChild(_generateFeedBody(e,t)),o.onscroll=()=>{detectFeedImpressions(e,o)},o}export function updateFeedCards(e,t,o,s,n){if(!p(t))return;const a=[];for(const e of t)if(e instanceof Card){if(e.url&&P.test(e.url)){let t=O(e.url);if(mt(t)){r.D.error(ct(gt.We,"Content Card"));continue}}a.push(e)}if(e.cards=a,e.lastUpdated=o,null!=s)if(s.setAttribute("aria-busy","false"),null==e.lastUpdated)destroyFeedHtml(s);else{const t=s.querySelectorAll(".ab-feed-body")[0];if(null!=t){const o=_generateFeedBody(e,n);t.parentNode.replaceChild(o,t),detectFeedImpressions(e,o.parentNode)}}}export function registerFeedSubscriptionId(e,t){t.setAttribute("data-update-subscription-id",e)} | ||
import x from"./base-feed.js";import{bottomHadImpression as de,getCardId as fe,impressOnBottom as be,impressOnTop as ye,markCardAsRead as Fe,topHadImpression as Te}from"../Card/display/card-display.js";import{bottomIsInView as he,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as xe}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as at}from"../util/key-codes.js";import Ee from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as P}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as gt,ineligibleBrazeActionURLErrorMessage as ct,getDecodedBrazeAction as O,containsUnknownBrazeAction as mt}from"../util/braze-actions.js";export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE="data-last-requested-refresh";export const _SUBSCRIPTION_ID_DATA_ATTRIBUTE="data-update-subscription-id";export function destroyFeedHtml(e){e&&(e.className=e.className.replace("ab-show","ab-hide"),setTimeout((()=>{e&&e.parentNode&&e.parentNode.removeChild(e)}),x.Di));const t=e.getAttribute("data-update-subscription-id");null!=t&&removeSubscription(t)}export function _generateFeedBody(e,t){const o=document.createElement("div");if(o.className="ab-feed-body",o.setAttribute("aria-label","Feed"),o.setAttribute("role","feed"),null==e.lastUpdated){const e=document.createElement("div");e.className="ab-no-cards-message";const t=document.createElement("i");t.className="fa fa-spinner fa-spin fa-4x ab-initial-spinner",e.appendChild(t),o.appendChild(e)}else{let s=!1;const logCardClick=t=>{e.logCardClick(t)};for(const n of e.cards){const a=n instanceof ControlCard;!a||e.dr()?(o.appendChild(xe(n,logCardClick,t)),s=s||!a):r.D.error("Received a control card for a legacy news feed. Control cards are only supported with content cards.")}if(!s){const e=document.createElement("div");e.className="ab-no-cards-message",e.innerHTML=Ee.m().get("NO_CARDS_MESSAGE"),e.setAttribute("role","article"),o.appendChild(e)}}return o}export function detectFeedImpressions(e,t){if(null!=t){const o=[],r=t.querySelectorAll(".ab-card");e.do||(e.do={});for(let t=0;t<r.length;t++){const s=fe(r[t]);if(e.do[s])continue;let n=Te(r[t]),a=de(r[t]);const i=n,d=a,f=_e(r[t]),c=he(r[t]);if(!n&&f&&(n=!0,ye(r[t])),!a&&c&&(a=!0,be(r[t])),n&&a){if(f||c||Fe(r[t]),i&&d)continue;for(const t of e.cards)if(t.id===s){e.do[t.id]=!0,o.push(t);break}}}o.length>0&&e.logCardImpressions(o)}}export function refreshFeed(e,t){t.setAttribute("aria-busy","true");const o=t.querySelectorAll(".ab-refresh-button")[0];null!=o&&(o.className+=" fa-spin");const r=(new Date).valueOf().toString();t.setAttribute("data-last-requested-refresh",r),setTimeout((()=>{if(t.getAttribute("data-last-requested-refresh")===r){const e=t.querySelectorAll(".fa-spin");for(let t=0;t<e.length;t++)e[t].className=e[t].className.replace(/fa-spin/g,"");const o=t.querySelectorAll(".ab-initial-spinner")[0];if(null!=o){const e=document.createElement("span");e.innerHTML=Ee.m().get("FEED_TIMEOUT_MESSAGE"),o.parentNode.appendChild(e),o.parentNode.removeChild(o)}"true"===t.getAttribute("aria-busy")&&t.setAttribute("aria-busy","false")}}),x.uo),e.sr()}export function feedToHtml(e,t){const o=document.createElement("div");o.className="ab-feed ab-hide ab-effect-slide",o.setAttribute("role","dialog"),o.setAttribute("aria-label","Feed"),o.setAttribute("tabindex","-1");const r=document.createElement("div");r.className="ab-feed-buttons-wrapper",r.setAttribute("role","group"),o.appendChild(r);const s=document.createElement("i");s.className="fa fa-times ab-close-button",s.setAttribute("aria-label","Close Feed"),s.setAttribute("tabindex","0"),s.setAttribute("role","button");const n=e=>{destroyFeedHtml(o),e.stopPropagation()};s.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||n(e)})),s.onclick=n;const a=document.createElement("i");a.className="fa fa-refresh ab-refresh-button",null==e.lastUpdated&&(a.className+=" fa-spin"),a.setAttribute("aria-label","Refresh Feed"),a.setAttribute("tabindex","0"),a.setAttribute("role","button");const i=t=>{refreshFeed(e,o),t.stopPropagation()};return a.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||i(e)})),a.onclick=i,r.appendChild(a),r.appendChild(s),o.appendChild(_generateFeedBody(e,t)),o.onscroll=()=>{detectFeedImpressions(e,o)},o}export function updateFeedCards(e,t,o,s,n){if(!p(t))return;const a=[];for(const e of t)if(e instanceof Card){if(e.url&&P.test(e.url)){let t=O(e.url);if(mt(t)){r.D.error(ct(gt.We,"Content Card"));continue}}a.push(e)}if(e.cards=a,e.lastUpdated=o,null!=s)if(s.setAttribute("aria-busy","false"),null==e.lastUpdated)destroyFeedHtml(s);else{const t=s.querySelectorAll(".ab-feed-body")[0];if(null!=t){const o=_generateFeedBody(e,n);t.parentNode.replaceChild(o,t),detectFeedImpressions(e,o.parentNode)}}}export function registerFeedSubscriptionId(e,t){t.setAttribute("data-update-subscription-id",e)} |
@@ -1,1 +0,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)}} | ||
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 +0,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)} | ||
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 +0,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)} | ||
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 +0,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} | ||
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 +0,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)})} | ||
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 +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.Ft.xt;new r.qt(a,r.D).setItem(a.Pt.oe,a.se,!0),e.destroy(!1),e.le(!0)} | ||
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 +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 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)} | ||
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 +0,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)}))} | ||
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 +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.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)} | ||
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 +0,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))}} | ||
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 +0,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()} | ||
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 +0,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()} | ||
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 +0,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)} | ||
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 +0,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)})} | ||
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 +0,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} | ||
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 +0,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}} | ||
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 +0,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; | ||
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 +0,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; | ||
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 +0,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"; | ||
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 +0,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; | ||
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 +0,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; | ||
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 +0,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)}} | ||
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 +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.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} | ||
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 +0,1 @@ | ||
import e,{OPTIONS as D}from"../managers/braze-instance.js";import et from"../util/browser-detector.js";import er from"./l10n-manager.js";const Ee={t:!1,i:null,m:()=>{if(Ee.o(),!Ee.i){let r=et.language,t=!1;e.nn(D.zn)&&(r=e.nn(D.zn),t=!0),Ee.i=new er(r,t)}return Ee.i},o:()=>{Ee.t||(e.u(Ee),Ee.t=!0)},destroy:()=>{Ee.i=null,Ee.t=!1}};export default Ee; | ||
import e,{OPTIONS as D}from"../managers/braze-instance.js";import et from"../util/browser-detector.js";import er from"./l10n-manager.js";const Ee={t:!1,i:null,m:()=>{if(Ee.o(),!Ee.i){let r=et.language,t=!1;e.nn(D.Mn)&&(r=e.nn(D.Mn),t=!0),Ee.i=new er(r,t)}return Ee.i},o:()=>{Ee.t||(e.u(Ee),Ee.t=!0)},destroy:()=>{Ee.i=null,Ee.t=!1}};export default Ee; |
@@ -1,1 +0,1 @@ | ||
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import r from"../../shared-lib/braze-shared-lib.js";export default class St{constructor(t,i,s){this.h=t,this.Fn=i||!1,this.xn=s,this.Tn=new u,this.qn=0,this.Bn=1}Gn(){return this.Fn}Hn(){return this.h.I(o.q.Jn)}setSdkAuthenticationSignature(t){const i=this.Hn();this.h.B(o.q.Jn,t);const s=r.Ft.xt;new r.qt(s,r.D).setItem(s.Pt.Kn,this.Bn,t),i!==t&&this.Es()}Ln(){this.h.$s(o.q.Jn);const t=r.Ft.xt;new r.qt(t,r.D).br(t.Pt.Kn,this.Bn)}subscribeToSdkAuthenticationFailures(t){return this.xn.Et(t)}Mn(t){this.xn.Nt(t)}On(){this.Tn.removeAllSubscriptions()}Qn(){this.qn+=1}Rn(){return this.qn}Es(){this.qn=0}} | ||
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import r from"../../shared-lib/braze-shared-lib.js";export default class St{constructor(t,i,s){this.h=t,this.Fn=i||!1,this.qn=s,this.Bn=new u,this.Gn=0,this.Hn=1}Jn(){return this.Fn}Kn(){return this.h.I(o.q.Ln)}setSdkAuthenticationSignature(t){const i=this.Kn();this.h.B(o.q.Ln,t);const s=r.xt.Ft;new r.qt(s,r.D).setItem(s.$t.On,this.Hn,t),i!==t&&this.Bs()}Qn(){this.h.Is(o.q.Ln);const t=r.xt.Ft;new r.qt(t,r.D).br(t.$t.On,this.Hn)}subscribeToSdkAuthenticationFailures(t){return this.qn.ut(t)}Vn(t){this.qn.St(t)}Xn(){this.Bn.removeAllSubscriptions()}Yn(){this.Gn+=1}Zn(){return this.Gn}Bs(){this.Gn=0}} |
@@ -1,1 +0,1 @@ | ||
import St from"./auth-manager.js";import C from"../common/base-provider.js";import et from"../util/browser-detector.js";import It from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import{logDeprecationWarning as y}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Tt from"../request-controller.js";import Ot from"./server-config-manager.js";import Ct from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import A,{STORAGE_KEYS as o}from"./storage-manager.js";import Lt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";import bt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as G}from"../util/window-utils.js";const D={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",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",bi:"requireExplicitInAppMessageDismissal",So:"doNotLoadFontAwesome",No:"sdkFlavor"};class Pt{constructor(){this.wo=!1,this.To=!1,this.Oo=new u,this.vo=new u,this.Co={},this.Lo=[],this.Po=[],this.De=[],this.Ro="4.0.6"}Mo(t){this.Oo.Et(t)}Ui(t){this.vo.Et(t)}initialize(t,i){if(this.yo())return r.D.info("Braze has already been initialized with an API key."),!0;this.Co=i||{};let s=this.nn(D.Zn);const e=st(G.kn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.Co,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.ji=t;let n=this.nn(D.$n);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.Do=n,et.jo&&!this.nn(D.Vn))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.To=!0,!1;const a=this.nn(Pt.Yn)||!1;if(this.h=Lt.zo(t,a),new A.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.To=!0,!1;for(const t of Y(this.Co))-1===At(r.Uo).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(D.No)){const t=this.nn(D.No);-1!==h.indexOf(t)?this.Bo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.Uo.Xn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)K(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.xi=new It(this.h,l),this.wt=new Ot(this.h),this.v=new bt(this.wt,this.h),this.j=new Ct(this.h,this.v,this.wt,this.nn(D.Eo));const c=new u;return this.Wo=new St(this.h,this.nn(D.ho),c),this.Ut(c),this.jt=new wt(this.xi,this.h,this.Wo,this.v,this.j,this.wt,this.ji,this.Do,this.Ro,this.Bo,this.nn(D._o)),this.Is=new Tt(this.ji,this.Do,this.j,this.xi,this.v,this.wt,this.h,(t=>{if(this.yo())for(const i of this.re())i._s(t)}),this.Wo,this.jt),this.Is.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(D.$n)}" with API key "${this.ji}".`),null!=this.nn(D.Io)&&y("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),V.init(),this.Oo.Nt(this.Co),this.wo=!0,!0}destroy(t){if(r.D.destroy(),this.yo()){this.vo.Nt(),this.vo.removeAllSubscriptions();for(const t of this.Lo)t.destroy();this.Lo=[];for(const t of this.Po)t.clearData(!1);this.Po=[],this.removeAllSubscriptions(),this.De=[],this.Is.destroy(),this.Is=null,this.Wo=null,this.xi=null,this.jt=null,this.wt=null,this.j=null,this.v=null,this.Co={},this.Bo=void 0,this.wo=!1,this.To=!1,t&&(this.h=null)}}rr(){if(this.Vo())return!1;if(!this.yo())throw new Error("Braze must be initialized before calling methods.");return!0}aa(){return this.ji}ti(){return this.Wo}Js(){return this.Do}ce(){return this.xi}nr(){return this.jt}nn(t){return this.Co[t]}re(){return this.Po}mr(){return this.Is}ir(){return this.wt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.Is)return new User(this.v,this.Is)}p(){return this.v}tr(){return!0===this.nn(D.Ao)||!0===this.nn(D.Io)}u(t){let i=!1;for(const s of this.Lo)s===t&&(i=!0);i||this.Lo.push(t)}ar(t){let i=!1;for(const s of this.Po)s.constructor===t.constructor&&(i=!0);t instanceof C&&!i&&this.Po.push(t)}Ut(t){t instanceof u&&this.De.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.De)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.De)i.removeSubscription(t)}le(t){this.To=t}yo(){return this.wo}Vo(){return this.To}}const e=new Pt;export{e as default,Pt as BrazeSdkInstance,D as OPTIONS}; | ||
import St from"./auth-manager.js";import C from"../common/base-provider.js";import et from"../util/browser-detector.js";import It from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import{logDeprecationWarning as y}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Tt from"../request-controller.js";import Ot from"./server-config-manager.js";import Ct from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import A,{STORAGE_KEYS as o}from"./storage-manager.js";import Lt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as V}from"../triggers/triggers-provider-factory.js";import bt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as G}from"../util/window-utils.js";const D={$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",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Ci:"requireExplicitInAppMessageDismissal",Oo:"doNotLoadFontAwesome",vo:"sdkFlavor"};class Pt{constructor(){this.Co=!1,this.Lo=!1,this.Po=new u,this.Ro=new u,this.Mo={},this.yo=[],this.Do=[],this.De=[],this.jo="4.1.0"}zo(t){this.Po.ut(t)}Hi(t){this.Ro.ut(t)}initialize(t,i){if(this.Uo())return r.D.info("Braze has already been initialized with an API key."),!0;this.Mo=i||{};let s=this.nn(D._o);const e=st(G.Nn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.Mo,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.Vi=t;let n=this.nn(D.ho);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.Bo=n,et.Wo&&!this.nn(D.$n))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.Lo=!0,!1;const a=this.nn(Pt.po)||!1;if(this.h=Lt.Vo(t,a),new A.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.Lo=!0,!1;for(const t of Y(this.Mo))-1===At(r.Go).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(D.vo)){const t=this.nn(D.vo);-1!==h.indexOf(t)?this.Ko=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.Go.Eo);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)K(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.qi=new It(this.h,l),this.wt=new Ot(this.h),this.v=new bt(this.wt,this.h),this.j=new Ct(this.h,this.v,this.wt,this.nn(D.So));const c=new u;return this.Fo=new St(this.h,this.nn(D.Io),c),this.yt(c),this.jt=new wt(this.qi,this.h,this.Fo,this.v,this.j,this.wt,this.Vi,this.Bo,this.jo,this.Ko,this.nn(D.No)),this.Vs=new Tt(this.Vi,this.Bo,this.j,this.qi,this.v,this.wt,this.h,(t=>{if(this.Uo())for(const i of this.re())i.ys(t)}),this.Fo,this.jt),this.Vs.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(D.ho)}" with API key "${this.Vi}".`),null!=this.nn(D.wo)&&y("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),V.init(),this.Po.St(this.Mo),this.Co=!0,!0}destroy(t){if(r.D.destroy(),this.Uo()){this.Ro.St(),this.Ro.removeAllSubscriptions();for(const t of this.yo)t.destroy();this.yo=[];for(const t of this.Do)t.clearData(!1);this.Do=[],this.removeAllSubscriptions(),this.De=[],this.Vs.destroy(),this.Vs=null,this.Fo=null,this.qi=null,this.jt=null,this.wt=null,this.j=null,this.v=null,this.Mo={},this.Ko=void 0,this.Co=!1,this.Lo=!1,t&&(this.h=null)}}rr(){if(this.Ho())return!1;if(!this.Uo())throw new Error("Braze must be initialized before calling methods.");return!0}aa(){return this.Vi}ti(){return this.Fo}Ps(){return this.Bo}ce(){return this.qi}nr(){return this.jt}nn(t){return this.Mo[t]}re(){return this.Do}mr(){return this.Vs}ir(){return this.wt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.Vs)return new User(this.v,this.Vs)}p(){return this.v}tr(){return!0===this.nn(D.To)||!0===this.nn(D.wo)}u(t){let i=!1;for(const s of this.yo)s===t&&(i=!0);i||this.yo.push(t)}ar(t){let i=!1;for(const s of this.Do)s.constructor===t.constructor&&(i=!0);t instanceof C&&!i&&this.Do.push(t)}yt(t){t instanceof u&&this.De.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.De)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.De)i.removeSubscription(t)}le(t){this.Lo=t}Uo(){return this.Co}Ho(){return this.Lo}Ds(){return this.jo}}const e=new Pt;export{e as default,Pt as BrazeSdkInstance,D as OPTIONS}; |
@@ -1,1 +0,1 @@ | ||
import et from"../util/browser-detector.js";import Ie from"../models/device.js";import DeviceProperties from"../Core/device-properties.js";import _t from"../models/identifier.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{values as At}from"../util/code-utils.js";export default class It{constructor(e,t){this.h=e,null==t&&(t=At(DeviceProperties)),this.xo=t}te(){let e=this.h._r(o.Cr.Go);null==e&&(e=new _t(r.nt.et()),this.h.Lr(o.Cr.Go,e));const t=new Ie(e.Ir);for(let e=0;e<this.xo.length;e++){const r=this.xo[e];switch(r){case DeviceProperties.BROWSER:t[r]=et.browser;break;case DeviceProperties.BROWSER_VERSION:t[r]=et.version;break;case DeviceProperties.OS:t[r]=this.Fo();break;case DeviceProperties.RESOLUTION:t[r]=screen.width+"x"+screen.height;break;case DeviceProperties.LANGUAGE:t[r]=et.language;break;case DeviceProperties.TIME_ZONE:t[r]=this.Jo(new Date);break;case DeviceProperties.USER_AGENT:t[r]=et.userAgent}}return t}Fo(){if(et.qo())return et.qo();const e=this.h.I(o.q.Ho);return e&&e.os_version?e.os_version:et.Ko()}Jo(e){if("undefined"!=typeof Intl&&"function"==typeof Intl.DateTimeFormat)try{if("function"==typeof Intl.DateTimeFormat().resolvedOptions){const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(null!=e&&""!==e)return e}}catch(e){r.D.info("Intl.DateTimeFormat threw an error, probably https://bugs.chromium.org/p/chromium/issues/detail?id=811403, falling back to GTM offset: "+e.message)}const t=e.getTimezoneOffset();return this.Qo(t)}Qo(e){const t=parseInt(e/60),r=parseInt(e%60);let s="GMT";return 0!==e&&(s+=e<0?"+":"-",s+=("00"+Math.abs(t)).slice(-2)+":"+("00"+Math.abs(r)).slice(-2)),s}} | ||
import et from"../util/browser-detector.js";import Ie from"../models/device.js";import DeviceProperties from"../Core/device-properties.js";import _t from"../models/identifier.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{values as At}from"../util/code-utils.js";export default class It{constructor(e,t){this.h=e,null==t&&(t=At(DeviceProperties)),this.xo=t}te(){let e=this.h._r(o.Cr.Jo);null==e&&(e=new _t(r.it.nt()),this.h.Lr(o.Cr.Jo,e));const t=new Ie(e.Ir);for(let e=0;e<this.xo.length;e++){const r=this.xo[e];switch(r){case DeviceProperties.BROWSER:t[r]=et.browser;break;case DeviceProperties.BROWSER_VERSION:t[r]=et.version;break;case DeviceProperties.OS:t[r]=this.qo();break;case DeviceProperties.RESOLUTION:t[r]=screen.width+"x"+screen.height;break;case DeviceProperties.LANGUAGE:t[r]=et.language;break;case DeviceProperties.TIME_ZONE:t[r]=this.Qo(new Date);break;case DeviceProperties.USER_AGENT:t[r]=et.userAgent}}return t}qo(){if(et.Xo())return et.Xo();const e=this.h.I(o.q.Yo);return e&&e.os_version?e.os_version:et.Zo()}Qo(e){if("undefined"!=typeof Intl&&"function"==typeof Intl.DateTimeFormat)try{if("function"==typeof Intl.DateTimeFormat().resolvedOptions){const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(null!=e&&""!==e)return e}}catch(e){r.D.info("Intl.DateTimeFormat threw an error, probably https://bugs.chromium.org/p/chromium/issues/detail?id=811403, falling back to GTM offset: "+e.message)}const t=e.getTimezoneOffset();return this.$o(t)}$o(e){const t=parseInt(e/60),r=parseInt(e%60);let s="GMT";return 0!==e&&(s+=e<0?"+":"-",s+=("00"+Math.abs(t)).slice(-2)+":"+("00"+Math.abs(r)).slice(-2)),s}} |
@@ -1,1 +0,1 @@ | ||
import Rt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as qt}from"../util/date-utils.js";import s from"../common/event-logger.js";import{isArray as p,isEqual as ii}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./storage-manager.js";export default class wt{constructor(t,e,s,i,r,o,n,a,h,u,c){this.xi=t,this.h=e,this.Wo=s,this.v=i,this.j=r,this.wt=o,this.ji=n,this.Do=a,this.Ro=h,this.Bo=u,this.Xo=c,this.$o=["npm"]}Ls(t,e){const s=this.xi.te(),i=s.Zs(),r=this.h.I(o.q.Ho);ii(r,i)||(t.device=i),t.api_key=this.ji,t.time=l((new Date).valueOf(),!0);const n=this.h.I(o.q.Yo)||[],a=this.h.I(o.q.Zo)||"";if(this.$o.length>0&&(!ii(n,this.$o)||a!==this.j.sa())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Ro,this.Bo&&(t.sdk_flavor=this.Bo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}qs(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Wo.Qn();const s={errorCode:o.error_code};for(const t of i)p(t)&&"X-Braze-Auth-Signature"===t[0]&&(s.signature=t[1]);t.respond_with&&t.respond_with.user_id?s.userId=t.respond_with.user_id:t.user_id&&(s.userId=t.user_id);const n=o.reason;return n?(s.reason=n,e=`due to ${n}`):e=`with error code ${o.error_code}.`,this.Wo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.ia(t.events,t.attributes),this.Wo.Mn(s),!1}if(n){let i=n;switch(i){case Rt.oa:const o="Received successful response with empty body.";return s.G(r.A.ha,{e:o}),r.D.info(o),!1;case Rt.ua:const n="Received successful response with invalid JSON";return s.G(r.A.ha,{e:n+": "+e.response}),r.D.info(n),!1;case Rt.ca:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.Do}`;break;case Rt.la:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case Rt.fa:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}ma(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}pa(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.Ys(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.Zs(),this.Wo.Gn()){if(n&&!a.user_id){c||(c={},c.events=[]),c.events.push(a);continue}if(o(a.user_id)!==n){h||(h=[]),h.push(a);continue}}t.push(a)}t.length>0&&(l.events=t)}if(i.length>0){const t=[];for(const e of i)this.Wo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.ia(h,u),l=this.Ls(l,!0),c){c=this.Ls(c,!1);const t={requestData:c,headers:this.Ns(c)};r.push(t)}if(l&&!this.ma(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Ns(l)};return r.push(f),r}ia(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=qt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.ba(t)}Ms(t,e){let s="HTTP error ";null!=t&&(s+=t+" "),s+=e,r.D.error(s)}yr(t){return s.G(r.A.Ra,{n:t})}Ys(t,e,s){const i={};t&&(i.feed=!0),e&&(i.triggers=!0);const r=null!=s?s:this.v.getUserId();return r&&(i.user_id=r),i.config={config_time:this.wt.Gs()},{respond_with:i}}Ns(t,e){const s=[["X-Braze-Api-Key",this.ji]];let i=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(s.push(["X-Braze-TriggersRequest","true"]),i=!0),null!=t.respond_with&&t.respond_with.feed&&(s.push(["X-Braze-FeedRequest","true"]),i=!0),e&&(s.push(["X-Braze-ContentCardsRequest","true"]),i=!0),i&&s.push(["X-Braze-DataRequest","true"]),this.Wo.Gn()){const t=this.Wo.Hn();null!=t&&s.push(["X-Braze-Auth-Signature",t])}return s}As(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Es(){this.Wo.Es()}Js(){return this.Do}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.push(e)}} | ||
import Rt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as qt}from"../util/date-utils.js";import s from"../common/event-logger.js";import{isArray as p,isEqual as ii}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./storage-manager.js";export default class wt{constructor(t,e,s,i,r,o,n,a,h,u,c){this.qi=t,this.h=e,this.Fo=s,this.v=i,this.j=r,this.wt=o,this.Vi=n,this.Bo=a,this.jo=h,this.Ko=u,this.sa=c,this.ia=["npm"]}As(t,e){const s=this.qi.te(),i=s.ri(),r=this.h.I(o.q.Yo);ii(r,i)||(t.device=i),t.api_key=this.Vi,t.time=l((new Date).valueOf(),!0);const n=this.h.I(o.q.oa)||[],a=this.h.I(o.q.ha)||"";if(this.ia.length>0&&(!ii(n,this.ia)||a!==this.j.ua())&&(t.sdk_metadata=this.ia),t.sdk_version=this.jo,this.Ko&&(t.sdk_flavor=this.Ko),t.app_version=this.sa,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}$s(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Fo.Yn();const s={errorCode:o.error_code};for(const t of i)p(t)&&"X-Braze-Auth-Signature"===t[0]&&(s.signature=t[1]);t.respond_with&&t.respond_with.user_id?s.userId=t.respond_with.user_id:t.user_id&&(s.userId=t.user_id);const n=o.reason;return n?(s.reason=n,e=`due to ${n}`):e=`with error code ${o.error_code}.`,this.Fo.Jn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.ca(t.events,t.attributes),this.Fo.Vn(s),!1}if(n){let i=n;switch(i){case Rt.la:const o="Received successful response with empty body.";return s.G(r.A.fa,{e:o}),r.D.info(o),!1;case Rt.ma:const n="Received successful response with invalid JSON";return s.G(r.A.fa,{e:n+": "+e.response}),r.D.info(n),!1;case Rt.pa:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.Bo}`;break;case Rt.ba:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case Rt.Ra:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}ga(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}qa(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.ii(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.ri(),this.Fo.Jn()){if(n&&!a.user_id){c||(c={},c.events=[]),c.events.push(a);continue}if(o(a.user_id)!==n){h||(h=[]),h.push(a);continue}}t.push(a)}t.length>0&&(l.events=t)}if(i.length>0){const t=[];for(const e of i)this.Fo.Jn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.ca(h,u),l=this.As(l,!0),c){c=this.As(c,!1);const t={requestData:c,headers:this.qs(c)};r.push(t)}if(l&&!this.ga(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.qs(l)};return r.push(f),r}ca(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=qt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.Aa(t)}Gs(t,e){let s="HTTP error ";null!=t&&(s+=t+" "),s+=e,r.D.error(s)}yr(t){return s.G(r.A.Da,{n:t})}ii(t,e,s){const i={};t&&(i.feed=!0),e&&(i.triggers=!0);const r=null!=s?s:this.v.getUserId();return r&&(i.user_id=r),i.config={config_time:this.wt.Os()},{respond_with:i}}qs(t,e){const s=[["X-Braze-Api-Key",this.Vi]];let i=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(s.push(["X-Braze-TriggersRequest","true"]),i=!0),null!=t.respond_with&&t.respond_with.feed&&(s.push(["X-Braze-FeedRequest","true"]),i=!0),e&&(s.push(["X-Braze-ContentCardsRequest","true"]),i=!0),i&&s.push(["X-Braze-DataRequest","true"]),this.Fo.Jn()){const t=this.Fo.Kn();null!=t&&s.push(["X-Braze-Auth-Signature",t])}return s}Es(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Bs(){this.Fo.Bs()}Ps(){return this.Bo}addSdkMetadata(t){for(const e of t)-1===this.ia.indexOf(e)&&this.ia.push(e)}} |
@@ -1,1 +0,1 @@ | ||
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import jt from"../models/server-config.js";export default class Ot{constructor(t){this.h=t,this.sh=new u,this.eh=new u,this.ih=null}rh(){if(null==this.ih){const t=this.h.I(o.q.nh);this.ih=null!=t?jt.jn(t):new jt}return this.ih}Gs(){return this.rh().hh}lh(t){if(null!=t&&null!=t.config){const s=t.config;if(s.time>this.rh().hh){const t=new jt(s.time,s.events_blacklist,s.attributes_blacklist,s.purchases_blacklist,s.messaging_session_timeout,s.vapid_public_key,s.content_cards);let e=!1;null!=t.oh&&this.Sn()!==t.oh&&(e=!0);let i=!1;null!=t.uh.enabled&&this.Bs()!==t.uh.enabled&&(i=!0),this.ih=t,this.h.B(o.q.nh,t.ss()),e&&this.sh.Nt(),i&&this.eh.Nt()}}}Dn(t){let s=this.sh.Et(t);return this.ah&&this.sh.removeSubscription(this.ah),this.ah=s,s}Rs(t){return this.eh.Et(t)}ge(t){return-1!==this.rh().gh.indexOf(t)}Gr(t){return-1!==this.rh().mh.indexOf(t)}Dr(t){return-1!==this.rh().fh.indexOf(t)}dh(){return this.rh().ph}Sn(){return this.rh().oh}Bs(){return this.rh().uh.enabled||!1}} | ||
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import jt from"../models/server-config.js";export default class Ot{constructor(t){this.h=t,this.sh=new u,this.eh=new u,this.ih=null}rh(){if(null==this.ih){const t=this.h.I(o.q.nh);this.ih=null!=t?jt.Rn(t):new jt}return this.ih}Os(){return this.rh().hh}lh(t){if(null!=t&&null!=t.config){const s=t.config;if(s.time>this.rh().hh){const t=new jt(s.time,s.events_blacklist,s.attributes_blacklist,s.purchases_blacklist,s.messaging_session_timeout,s.vapid_public_key,s.content_cards);let e=!1;null!=t.oh&&this.Wn()!==t.oh&&(e=!0);let i=!1;null!=t.uh.enabled&&this.Ks()!==t.uh.enabled&&(i=!0),this.ih=t,this.h.B(o.q.nh,t.ss()),e&&this.sh.St(),i&&this.eh.St()}}}An(t){let s=this.sh.ut(t);return this.ah&&this.sh.removeSubscription(this.ah),this.ah=s,s}Ns(t){return this.eh.ut(t)}ge(t){return-1!==this.rh().gh.indexOf(t)}Gr(t){return-1!==this.rh().mh.indexOf(t)}Dr(t){return-1!==this.rh().fh.indexOf(t)}dh(){return this.rh().ph}Wn(){return this.rh().oh}Ks(){return this.rh().uh.enabled||!1}} |
@@ -1,1 +0,1 @@ | ||
import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{convertMsToSeconds as l}from"../util/date-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export default class Ct{constructor(s,t,e,i){this.h=s,this.v=t,this.wt=e,this.wh=1e3,i=parseFloat(i),isNaN(i)&&(i=1800),i<this.wh/1e3&&(r.D.info("Specified session timeout of "+i+"s is too small, using the minimum session timeout of "+this.wh/1e3+"s instead."),i=this.wh/1e3),this.Sh=i}jh(s,t){return new ue(this.v.getUserId(),r.A.bh,s,t.Ir,{d:l(s-t.xh)})}sa(){const s=this.h._r(o.Cr.Dh);return null==s?null:s.Ir}Eh(){const s=(new Date).valueOf(),t=this.wt.dh(),e=this.h.I(o.q.Ch);if(null!=e&&null==t)return!1;const i=null==e||s-e>1e3*t;return i&&this.h.B(o.q.Ch,s),i}Gh(s,t){return null==t||!(s-t.xh<this.wh)&&t.Nh<s}mo(){const s=(new Date).valueOf(),t=s+1e3*this.Sh,e=this.h._r(o.Cr.Dh);if(this.Gh(s,e)){let i="Generating session start event with time "+s;if(null!=e){let s=e._h;s-e.xh<this.wh&&(s=e.xh+this.Fh),this.h.Hh(this.jh(s,e)),i+=" (old session ended "+s+")"}i+=". Will expire "+t.valueOf(),r.D.info(i);const n=new _t(r.nt.et(),t);this.h.Hh(new ue(this.v.getUserId(),r.A.Wh,s,n.Ir)),this.h.Lr(o.Cr.Dh,n);return null==this.h.I(o.q.Ch)&&this.h.B(o.q.Ch,s),n.Ir}return e._h=s,e.Nh=t,this.h.Lr(o.Cr.Dh,e),e.Ir}kh(){const s=this.h._r(o.Cr.Dh);null!=s&&(this.h.qh(o.Cr.Dh),this.h.Hh(this.jh((new Date).valueOf(),s)))}} | ||
import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{convertMsToSeconds as l}from"../util/date-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export default class Ct{constructor(s,t,e,i){this.h=s,this.v=t,this.wt=e,this.wh=1e3,i=parseFloat(i),isNaN(i)&&(i=1800),i<this.wh/1e3&&(r.D.info("Specified session timeout of "+i+"s is too small, using the minimum session timeout of "+this.wh/1e3+"s instead."),i=this.wh/1e3),this.Sh=i}jh(s,t){return new ue(this.v.getUserId(),r.A.bh,s,t.Ir,{d:l(s-t.xh)})}ua(){const s=this.h._r(o.Cr.Dh);return null==s?null:s.Ir}Eh(){const s=(new Date).valueOf(),t=this.wt.dh(),e=this.h.I(o.q.Ch);if(null!=e&&null==t)return!1;const i=null==e||s-e>1e3*t;return i&&this.h.B(o.q.Ch,s),i}Gh(s,t){return null==t||!(s-t.xh<this.wh)&&t.Nh<s}mo(){const s=(new Date).valueOf(),t=s+1e3*this.Sh,e=this.h._r(o.Cr.Dh);if(this.Gh(s,e)){let i="Generating session start event with time "+s;if(null!=e){let s=e._h;s-e.xh<this.wh&&(s=e.xh+this.Fh),this.h.Hh(this.jh(s,e)),i+=" (old session ended "+s+")"}i+=". Will expire "+t.valueOf(),r.D.info(i);const n=new _t(r.it.nt(),t);this.h.Hh(new ue(this.v.getUserId(),r.A.Wh,s,n.Ir)),this.h.Lr(o.Cr.Dh,n);return null==this.h.I(o.q.Ch)&&this.h.B(o.q.Ch,s),n.Ir}return e._h=s,e.Nh=t,this.h.Lr(o.Cr.Dh,e),e.Ir}kh(){const s=this.h._r(o.Cr.Dh);null!=s&&(this.h.qh(o.Cr.Dh),this.h.Hh(this.jh((new Date).valueOf(),s)))}} |
@@ -1,1 +0,1 @@ | ||
import A,{STORAGE_KEYS as o}from"./storage-manager.js";import r from"../../shared-lib/braze-shared-lib.js";const Lt={zo:(e,t)=>{let a=!1;try{if(localStorage&&localStorage.getItem)try{localStorage.setItem(o.q.ga,!0),localStorage.getItem(o.q.ga)&&(localStorage.removeItem(o.q.ga),a=!0)}catch(e){if("QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||!(localStorage.length>0))throw e;a=!0}}catch(e){r.D.info("Local Storage not supported!")}const l=Lt.Sa(),c=new A.Ea(e,l&&!t,a);let n=null;return n=a?new A.wa(e):new A._a,new A(c,n)},Sa:()=>navigator.cookieEnabled||"cookie"in document&&(document.cookie.length>0||(document.cookie="test").indexOf.call(document.cookie,"test")>-1)};export default Lt; | ||
import A,{STORAGE_KEYS as o}from"./storage-manager.js";import r from"../../shared-lib/braze-shared-lib.js";const Lt={Vo:(e,t)=>{let a=!1;try{if(localStorage&&localStorage.getItem)try{localStorage.setItem(o.q.Sa,!0),localStorage.getItem(o.q.Sa)&&(localStorage.removeItem(o.q.Sa),a=!0)}catch(e){if("QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||!(localStorage.length>0))throw e;a=!0}}catch(e){r.D.info("Local Storage not supported!")}const l=Lt.Ea(),c=new A.wa(e,l&&!t,a);let n=null;return n=a?new A._a(e):new A.Oa,new A(c,n)},Ea:()=>navigator.cookieEnabled||"cookie"in document&&(document.cookie.length>0||(document.cookie="test").indexOf.call(document.cookie,"test")>-1)};export default Lt; |
@@ -1,1 +0,1 @@ | ||
import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={Cr:{Ur:"ab.storage.userId",Go:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{ga:"ab.test",Ta:"ab.storage.events",Aa:"ab.storage.attributes",Oa:"ab.storage.attributes.anonymous_user",Ho:"ab.storage.device",Yo:"ab.storage.sdk_metadata",Zo:"ab.storage.session_id_for_cached_metadata",Wn:"ab.storage.pushToken",Ks:"ab.storage.newsFeed",Qs:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",Ia:"ab.storage.triggers",Ka:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Wt:"ab.storage.cc",Cs:"ab.storage.ccLastFullSync",ws:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ya:"ab.storage.lastDisplayedTriggerTimesById",Da:"ab.storage.lastDisplayedTriggerTime",Ga:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature"},ae:"ab.optOut"};export default class A{constructor(t,e){this.va=t,this.Na=e}Lr(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.va.store(t,s)}Ma(t){const e=this._r(t);null!=e&&(e._h=(new Date).valueOf(),this.Lr(t,e))}_r(t){return _t.jn(this.va.lr(t))}qh(t){this.va.remove(t)}bo(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Na.lr(STORAGE_KEYS.q.Ta);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Na.store(STORAGE_KEYS.q.Ta,e)}Hh(t){return null!=t&&this.bo([t])}Ca(){let t=this.Na.lr(STORAGE_KEYS.q.Ta);this.Na.remove(STORAGE_KEYS.q.Ta),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.ya(t[s])?e.push(ue.jn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.ha,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}$s(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=Y(STORAGE_KEYS.Cr),e=Y(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.va.remove(STORAGE_KEYS.Cr[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}Ua(t){return t||STORAGE_KEYS.q.Oa}ba(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.Ua(t[User.En]);for(let r in t)r===User.En||null!=e[s]&&null!=e[s][r]||this.Kr(t[User.En],r,t[r])}Kr(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.Ua(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User.En]=t)),e===User.Jr){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Na.store(STORAGE_KEYS.q.Aa,r)}Ba(){const t=this.Na.lr(STORAGE_KEYS.q.Aa);this.Na.remove(STORAGE_KEYS.q.Aa);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}Er(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.Ua(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User.En]=t,this.ba(r))}const s=this._r(STORAGE_KEYS.Cr.Dh);let r=null;null!=s&&(r=s.Ir);const o=this.Ca();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}Fa(){return this.Na.La}}A.wa=class{constructor(t){this.ji=t,this.La=et.Pa()?3:10}xa(t){return t+"."+this.ji}store(t,e){const s={v:e};try{return localStorage.setItem(this.xa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}lr(t){try{const e=JSON.parse(localStorage.getItem(this.xa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.xa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};A.ne=class{constructor(t,e){this.ji=t,this.Ja=this.ka(),this.za=576e3,this.Qa=!!e}xa(t){return null!=this.ji?t+"."+this.ji:t}ka(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.za*1e3),t.getFullYear()}Va(){const t=At(STORAGE_KEYS.Cr),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.ji)&&this.Ha(t)}}}store(t,e){this.Va();const s=new Date;s.setTime(s.getTime()+60*this.za*1e3);const o="expires="+s.toUTCString(),n="domain="+this.Ja;let i;i=this.Qa?e:encodeURIComponent(JSON.stringify(e));const a=this.xa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}lr(t){const e=[],s=this.xa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Qa?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Ha(this.xa(t))}Ha(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.Ja;document.cookie=s,document.cookie=s+";path=/"}};A._a=class{constructor(){this.Wa={},this.Xa=5242880,this.La=3}store(t,e){const s={value:e},o=this.qa(e);return o>this.Xa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Xa),!1):(this.Wa[t]=s,!0)}qa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}lr(t){const e=this.Wa[t];return null==e?null:e.value}remove(t){this.Wa[t]=null}};A.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new A.ne(t)),s&&this.Za.push(new A.wa(t)),this.Za.push(new A._a(t))}store(t,e){let s=!0;for(let r=0;r<this.Za.length;r++)s=this.Za[r].store(t,e)&&s;return s}lr(t){for(let e=0;e<this.Za.length;e++){const s=this.Za[e].lr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Za.length;e++)this.Za[e].remove(t)}}; | ||
import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as Y,validateValueIsFromEnum as K,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={Cr:{Ur:"ab.storage.userId",Jo:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{Sa:"ab.test",Ta:"ab.storage.events",Ia:"ab.storage.attributes",Ka:"ab.storage.attributes.anonymous_user",Yo:"ab.storage.device",oa:"ab.storage.sdk_metadata",ha:"ab.storage.session_id_for_cached_metadata",xn:"ab.storage.pushToken",Ws:"ab.storage.newsFeed",Ys:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",Ya:"ab.storage.triggers",Ga:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Xt:"ab.storage.cc",ws:"ab.storage.ccLastFullSync",Ss:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Na:"ab.storage.lastDisplayedTriggerTimesById",va:"ab.storage.lastDisplayedTriggerTime",Ma:"ab.storage.triggerFireInstancesById",Ln:"ab.storage.signature",Ts:"ab.storage.sdkVersion"},ae:"ab.optOut"};export default class A{constructor(t,e){this.Ca=t,this.ya=e}Lr(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.Ca.store(t,s)}Ua(t){const e=this._r(t);null!=e&&(e._h=(new Date).valueOf(),this.Lr(t,e))}_r(t){return _t.Rn(this.Ca.lr(t))}qh(t){this.Ca.remove(t)}bo(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.ya.lr(STORAGE_KEYS.q.Ta);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.ya.store(STORAGE_KEYS.q.Ta,e)}Hh(t){return null!=t&&this.bo([t])}Ba(){let t=this.ya.lr(STORAGE_KEYS.q.Ta);this.ya.remove(STORAGE_KEYS.q.Ta),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.Fa(t[s])?e.push(ue.Rn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.fa,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.ya.store(t,e)}I(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.ya.lr(t)}Is(t){return!!K(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.ya.remove(t),!0)}clearData(){const t=Y(STORAGE_KEYS.Cr),e=Y(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ca.remove(STORAGE_KEYS.Cr[s])}for(let t=0;t<e.length;t++){const s=e[t];this.ya.remove(STORAGE_KEYS.q[s])}}La(t){return t||STORAGE_KEYS.q.Ka}Aa(t){let e=this.ya.lr(STORAGE_KEYS.q.Ia);null==e&&(e={});const s=this.La(t[User.En]);for(let r in t)r===User.En||null!=e[s]&&null!=e[s][r]||this.Kr(t[User.En],r,t[r])}Kr(t,e,s){let r=this.ya.lr(STORAGE_KEYS.q.Ia);null==r&&(r={});const o=this.La(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User.En]=t)),e===User.Jr){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.ya.store(STORAGE_KEYS.q.Ia,r)}Pa(){const t=this.ya.lr(STORAGE_KEYS.q.Ia);this.ya.remove(STORAGE_KEYS.q.Ia);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}Er(t){const e=this.ya.lr(STORAGE_KEYS.q.Ia);if(null!=e){const s=this.La(null),r=e[s];null!=r&&(e[s]=void 0,this.ya.store(STORAGE_KEYS.q.Ia,e),r[User.En]=t,this.Aa(r))}const s=this._r(STORAGE_KEYS.Cr.Dh);let r=null;null!=s&&(r=s.Ir);const o=this.Ba();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}xa(){return this.ya.Ja}}A._a=class{constructor(t){this.Vi=t,this.Ja=et.ka()?3:10}Va(t){return t+"."+this.Vi}store(t,e){const s={v:e};try{return localStorage.setItem(this.Va(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}lr(t){try{const e=JSON.parse(localStorage.getItem(this.Va(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.Va(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};A.ne=class{constructor(t,e){this.Vi=t,this.za=this.Qa(),this.Ha=576e3,this.Wa=!!e}Va(t){return null!=this.Vi?t+"."+this.Vi:t}Qa(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.Ha*1e3),t.getFullYear()}Xa(){const t=At(STORAGE_KEYS.Cr),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.Vi)&&this.Za(t)}}}store(t,e){this.Xa();const s=new Date;s.setTime(s.getTime()+60*this.Ha*1e3);const o="expires="+s.toUTCString(),n="domain="+this.za;let i;i=this.Wa?e:encodeURIComponent(JSON.stringify(e));const a=this.Va(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}lr(t){const e=[],s=this.Va(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Wa?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Za(this.Va(t))}Za(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.za;document.cookie=s,document.cookie=s+";path=/"}};A.Oa=class{constructor(){this.$a={},this.tl=5242880,this.Ja=3}store(t,e){const s={value:e},o=this.sl(e);return o>this.tl?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.tl),!1):(this.$a[t]=s,!0)}sl(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}lr(t){const e=this.$a[t];return null==e?null:e.value}remove(t){this.$a[t]=null}};A.wa=class{constructor(t,e,s){this.rl=[],e&&this.rl.push(new A.ne(t)),s&&this.rl.push(new A._a(t)),this.rl.push(new A.Oa(t))}store(t,e){let s=!0;for(let r=0;r<this.rl.length;r++)s=this.rl[r].store(t,e)&&s;return s}lr(t){for(let e=0;e<this.rl.length;e++){const s=this.rl[e].lr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.rl.length;e++)this.rl[e].remove(t)}}; |
@@ -1,1 +0,1 @@ | ||
import r from"../../shared-lib/braze-shared-lib.js";export default class u{constructor(){this.De={}}Et(t){if("function"!=typeof t)return null;const i=r.nt.et();return this.De[i]=t,i}removeSubscription(t){delete this.De[t]}removeAllSubscriptions(){this.De={}}Nt(t){const i=[];for(let r in this.De)i.push(this.De[r](t));return i}} | ||
import r from"../../shared-lib/braze-shared-lib.js";export default class u{constructor(){this.De={}}ut(t){if("function"!=typeof t)return null;const i=r.it.nt();return this.De[i]=t,i}removeSubscription(t){delete this.De[t]}removeAllSubscriptions(){this.De={}}St(t){const i=[];for(let r in this.De)i.push(this.De[r](t));return i}} |
@@ -1,1 +0,1 @@ | ||
export default{ca:"invalid_api_key",la:"blacklisted",fa:"no_device_identifier",ua:"invalid_json_response",oa:"empty_response",__:"sdk_auth_error"}; | ||
export default{pa:"invalid_api_key",ba:"blacklisted",Ra:"no_device_identifier",ma:"invalid_json_response",la:"empty_response",__:"sdk_auth_error"}; |
@@ -1,1 +0,1 @@ | ||
import{isObject as Jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Vt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Vt(s),this.sessionId=r,this.data=e}Zs(){const t={name:this.type,time:l(this.time),data:this.data||{},session_id:this.sessionId};return null!=this.userId&&(t.user_id=this.userId),t}ss(){return{u:this.userId,t:this.type,ts:this.time,s:this.sessionId,d:this.data}}static fromJson(t){return new ue(t.user_id,t.name,t.time,t.session_id,t.data)}static ya(t){return null!=t&&Jt(t)&&null!=t.t&&""!==t.t}static jn(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}} | ||
import{isObject as Jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Vt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Vt(s),this.sessionId=r,this.data=e}ri(){const t={name:this.type,time:l(this.time),data:this.data||{},session_id:this.sessionId};return null!=this.userId&&(t.user_id=this.userId),t}ss(){return{u:this.userId,t:this.type,ts:this.time,s:this.sessionId,d:this.data}}static fromJson(t){return new ue(t.user_id,t.name,t.time,t.session_id,t.data)}static Fa(t){return null!=t&&Jt(t)&&null!=t.t&&""!==t.t}static Rn(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}} |
@@ -1,1 +0,1 @@ | ||
import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}Zs(){const s={};return null!=this[DeviceProperties.BROWSER]&&(s.browser=this[DeviceProperties.BROWSER]),null!=this[DeviceProperties.BROWSER_VERSION]&&(s.browser_version=this[DeviceProperties.BROWSER_VERSION]),null!=this[DeviceProperties.OS]&&(s.os_version=this[DeviceProperties.OS]),null!=this[DeviceProperties.RESOLUTION]&&(s.resolution=this[DeviceProperties.RESOLUTION]),null!=this[DeviceProperties.LANGUAGE]&&(s.locale=this[DeviceProperties.LANGUAGE]),null!=this[DeviceProperties.TIME_ZONE]&&(s.time_zone=this[DeviceProperties.TIME_ZONE]),null!=this[DeviceProperties.USER_AGENT]&&(s.user_agent=this[DeviceProperties.USER_AGENT]),s}} | ||
import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}ri(){const s={};return null!=this[DeviceProperties.BROWSER]&&(s.browser=this[DeviceProperties.BROWSER]),null!=this[DeviceProperties.BROWSER_VERSION]&&(s.browser_version=this[DeviceProperties.BROWSER_VERSION]),null!=this[DeviceProperties.OS]&&(s.os_version=this[DeviceProperties.OS]),null!=this[DeviceProperties.RESOLUTION]&&(s.resolution=this[DeviceProperties.RESOLUTION]),null!=this[DeviceProperties.LANGUAGE]&&(s.locale=this[DeviceProperties.LANGUAGE]),null!=this[DeviceProperties.TIME_ZONE]&&(s.time_zone=this[DeviceProperties.TIME_ZONE]),null!=this[DeviceProperties.USER_AGENT]&&(s.user_agent=this[DeviceProperties.USER_AGENT]),s}} |
@@ -1,1 +0,1 @@ | ||
import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.nt.et()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.Ir=t,this.xh=s,this._h=(new Date).valueOf(),this.Nh=e}ss(){return{g:this.Ir,e:this.Nh,c:this.xh,l:this._h}}static jn(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e._h=t.l,e}} | ||
import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.it.nt()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.Ir=t,this.xh=s,this._h=(new Date).valueOf(),this.Nh=e}ss(){return{g:this.Ir,e:this.Nh,c:this.xh,l:this._h}}static Rn(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e._h=t.l,e}} |
@@ -1,1 +0,1 @@ | ||
import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.An=i||null,this.publicKey=l||null,this.tl=s||null,this.oh=u||null}ss(){return{e:this.endpoint,c:this.An,p:this.publicKey,u:this.tl,v:this.oh}}static jn(t){return new ei(t.e,w(t.c),t.p,t.u,t.v)}} | ||
import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.Tn=i||null,this.publicKey=l||null,this.il=s||null,this.oh=u||null}ss(){return{e:this.endpoint,c:this.Tn,p:this.publicKey,u:this.il,v:this.oh}}static Rn(t){return new ei(t.e,w(t.c),t.p,t.u,t.v)}} |
@@ -1,1 +0,1 @@ | ||
export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.0.6",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static jn(t){let s=t.l;return"4.0.6"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}} | ||
export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.1.0",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static Rn(t){let s=t.l;return"4.1.0"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}} |
@@ -1,1 +0,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; | ||
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 +0,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."; | ||
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 +0,1 @@ | ||
import b from"./util/net.js";import ue from"./models/braze-event.js";import s from"./common/event-logger.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{STORAGE_KEYS as o}from"./managers/storage-manager.js";import u from"./managers/subscription-manager.js";export default class Tt{constructor(t,s,i,e,n,l,h,o,r,a){this.ji=t,this.Do=s,this.sl=0,this.il=h.Fa(),this.hl=null,this.j=i,this.xi=e,this.v=n,this.wt=l,this.h=h,this.Wo=r,this.jt=a,this.ol=o,this.rl=new u,this.ul=50}al(t,s){return!t&&!s&&this.Wo.Rn()>=this.ul}cl(t){let s=this.j.Eh();if(t.length>0){const i=this.v.getUserId();for(const e of t){const t=!e.userId&&!i||e.userId===i;e.type===r.A.Wh&&t&&(s=!0)}}return s}dl(t,s,i,e,n,l,h){null==i&&(i=!0),i&&this.ml();const u=this.h.Ca(),a=this.h.Ba();let c=!1;const d=(t,s)=>{let h=!1;b.Fs({url:this.Do+"/data/",data:t,headers:s,S:i=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.jt.qs(t,i,s)?(this.Wo.Es(),this.wt.lh(i),null!=t.respond_with&&t.respond_with.user_id!=this.v.getUserId()||(null!=t.device&&this.h.B(o.q.Ho,t.device),null!=t.sdk_metadata&&(this.h.B(o.q.Yo,t.sdk_metadata),this.h.B(o.q.Zo,this.j.sa())),this.ol(i),"function"==typeof e&&e())):i.auth_error&&(h=!0)},error:()=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.jt.ia(t.events,t.attributes),"function"==typeof n&&n()},fl:t=>{if("function"==typeof l&&l(t),i&&!c){if(t&&!h)this.gl();else{let t=this.hl;(null==t||t<1e3*this.il)&&(t=1e3*this.il),this.gl(Math.min(3e5,lt(1e3*this.il,3*t)))}c=!0}}})},m=this.cl(u),f=s||m;if(this.al(h,m))return void r.D.info("Declining to flush data due to 50 consecutive authentication failures");if(i&&!this.jt.ma(u,a,t,f))return this.gl(),void("function"==typeof l&&l(!0));const g=this.jt.pa(t,f,u,a);f&&this.sl++;let p=!1;if(g)for(const t of g)this.jt.As(t.requestData,(()=>d(t.requestData,t.headers))),p=!0;this.Wo.Gn()&&i&&!p?this.gl():m&&(r.D.info("Invoking new session subscriptions"),this.rl.Nt())}bl(){return this.sl>0}gl(t){this.kl||(null==t&&(t=1e3*this.il),this.ml(),this.wl=setTimeout((()=>{if(document.hidden){const t="visibilitychange",s=()=>{document.hidden||(document.removeEventListener(t,s,!1),this.dl())};document.addEventListener(t,s,!1)}else this.dl()}),t),this.hl=t)}ml(){null!=this.wl&&(clearTimeout(this.wl),this.wl=null)}initialize(){this.kl=!1,this.gl()}destroy(){this.rl.removeAllSubscriptions(),this.Wo.On(),this.ml(),this.kl=!0,this.dl(null,null,!1),this.wl=null}cr(t){return this.rl.Et(t)}openSession(){const t=this.j.sa()!==this.j.mo();t&&(this.h.Ma(o.Cr.Go),this.h.Ma(o.Cr.Ur)),this.dl(null,!1,null,null,null),this.In(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.kl)return;const s=t.default.Xe();if(null!=s&&(s.isPushPermissionGranted()||s.isPushBlocked())){const t=()=>{s.Xi()?r.D.info("Push token maintenance is disabled, not refreshing token for backend."):s.subscribe()},i=(s,i)=>{i&&t()},e=()=>{const s=this.h.I(o.q.Wn);(null==s||s)&&t()},n=r.Ft.xt;new r.qt(n,r.D).hr(n.Pt.Mr,i,e)}}))}changeUser(t,s,i){const e=this.v.getUserId();if(e!==t){this.j.kh(),null!=e&&this.dl(null,!1,null,null,null),this.v.Br(t),i?this.Wo.setSdkAuthenticationSignature(i):this.Wo.Ln();for(let t=0;t<s.length;t++)s[t].changeUser(null==e);null!=e&&this.h.$s(o.q.P),this.h.$s(o.q.Ho),this.openSession(),r.D.info('Changed user to "'+t+'".')}else{let s="Doing nothing.";i&&this.Wo.Hn()!==i&&(this.Wo.setSdkAuthenticationSignature(i),s="Updated SDK authentication signature"),r.D.info(`Current user is already ${t}. ${s}`)}}requestImmediateDataFlush(t){this.ml(),this.j.mo(),this.dl(null,null,null,null,null,t,!0)}requestFeedRefresh(){this.j.mo(),this.dl(!0)}zr(t,s){this.j.mo(),r.D.info("Requesting explicit trigger refresh."),this.dl(null,!0,null,t,s)}Nr(t,i){const e=r.A.yl,n={a:t,l:i},l=s.G(e,n);return l&&r.D.info(`Logged alias ${t} with label ${i}`),l}Or(i,e,n){if(this.wt.Gr(e))return r.D.info(`Custom Attribute "${e}" is blocklisted, ignoring.`),new t;const l={key:e,value:n},h=s.G(i,l);return h&&r.D.info(`Logged custom attribute: ${e} with value: ${n}`),h}setLastKnownLocation(t,i,e,n,l,h){const o={latitude:i,longitude:e};null!=n&&(o.altitude=n),null!=l&&(o.ll_accuracy=l),null!=h&&(o.alt_accuracy=h);const u=s.G(r.A.vl,o,t);return u&&r.D.info(`Set user last known location as ${JSON.stringify(o,null,2)}`),u}kr(t,s){const i=this.j.mo();return new ue(this.v.getUserId(),r.A.Sl,t,i,{cid:s})}In(){const t=r.Ft.xt;new r.qt(t,r.D).setItem(t.Pt.jl,1,{baseUrl:this.Do,data:{api_key:this.ji,device_id:this.xi.te().id},userId:this.v.getUserId(),sdkAuthEnabled:this.Wo.Gn()})}wr(t){for(const s of t)if(s.api_key===this.ji)this.jt.ia(s.events,s.attributes);else{const t=r.Ft.xt;new r.qt(t,r.D).setItem(t.Pt.$r,r.nt.et(),s)}}Xr(i,e,n){if(this.wt.Gr(i))return r.D.info(`Custom Attribute "${i}" is blocklisted, ignoring.`),new t;let l,h;return null===e&&null===n?(l=r.A.$l,h={key:i}):(l=r.A.Al,h={key:i,latitude:e,longitude:n}),s.G(l,h)}Zr(t,i){const e={group_id:t,status:i};return s.G(r.A.Cl,e)}} | ||
import b from"./util/net.js";import ue from"./models/braze-event.js";import s from"./common/event-logger.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{STORAGE_KEYS as o}from"./managers/storage-manager.js";import u from"./managers/subscription-manager.js";export default class Tt{constructor(t,s,i,e,n,l,h,o,r,a){this.Vi=t,this.Bo=s,this.hl=0,this.ol=h.xa(),this.ul=null,this.j=i,this.qi=e,this.v=n,this.wt=l,this.h=h,this.Fo=r,this.jt=a,this.al=o,this.cl=new u,this.dl=50}ml(t,s){return!t&&!s&&this.Fo.Zn()>=this.dl}fl(t){let s=this.j.Eh();if(t.length>0){const i=this.v.getUserId();for(const e of t){const t=!e.userId&&!i||e.userId===i;e.type===r.A.Wh&&t&&(s=!0)}}return s}gl(t,s,i,e,n,l,h){null==i&&(i=!0),i&&this.bl();const u=this.h.Ba(),a=this.h.Pa();let c=!1;const d=(t,s)=>{let h=!1;b.Ms({url:this.Bo+"/data/",data:t,headers:s,S:i=>{null!=t.respond_with&&t.respond_with.triggers&&(this.hl=Math.max(this.hl-1,0)),this.jt.$s(t,i,s)?(this.Fo.Bs(),this.wt.lh(i),null!=t.respond_with&&t.respond_with.user_id!=this.v.getUserId()||(null!=t.device&&this.h.B(o.q.Yo,t.device),null!=t.sdk_metadata&&(this.h.B(o.q.oa,t.sdk_metadata),this.h.B(o.q.ha,this.j.ua())),this.al(i),"function"==typeof e&&e())):i.auth_error&&(h=!0)},error:()=>{null!=t.respond_with&&t.respond_with.triggers&&(this.hl=Math.max(this.hl-1,0)),this.jt.ca(t.events,t.attributes),"function"==typeof n&&n()},kl:t=>{if("function"==typeof l&&l(t),i&&!c){if(t&&!h)this.wl();else{let t=this.ul;(null==t||t<1e3*this.ol)&&(t=1e3*this.ol),this.wl(Math.min(3e5,lt(1e3*this.ol,3*t)))}c=!0}}})},m=this.fl(u),f=s||m;if(this.ml(h,m))return void r.D.info("Declining to flush data due to 50 consecutive authentication failures");if(i&&!this.jt.ga(u,a,t,f))return this.wl(),void("function"==typeof l&&l(!0));const g=this.jt.qa(t,f,u,a);f&&this.hl++;let p=!1;if(g)for(const t of g)this.jt.Es(t.requestData,(()=>d(t.requestData,t.headers))),p=!0;this.Fo.Jn()&&i&&!p?this.wl():m&&(r.D.info("Invoking new session subscriptions"),this.cl.St())}yl(){return this.hl>0}wl(t){this.vl||(null==t&&(t=1e3*this.ol),this.bl(),this.Sl=setTimeout((()=>{if(document.hidden){const t="visibilitychange",s=()=>{document.hidden||(document.removeEventListener(t,s,!1),this.gl())};document.addEventListener(t,s,!1)}else this.gl()}),t),this.ul=t)}bl(){null!=this.Sl&&(clearTimeout(this.Sl),this.Sl=null)}initialize(){this.vl=!1,this.wl()}destroy(){this.cl.removeAllSubscriptions(),this.Fo.Xn(),this.bl(),this.vl=!0,this.gl(null,null,!1),this.Sl=null}cr(t){return this.cl.ut(t)}openSession(){const t=this.j.ua()!==this.j.mo();t&&(this.h.Ua(o.Cr.Jo),this.h.Ua(o.Cr.Ur)),this.gl(null,!1,null,null,null),this.In(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.vl)return;const s=t.default.Xe();if(null!=s&&(s.isPushPermissionGranted()||s.isPushBlocked())){const t=()=>{s.dn()?r.D.info("Push token maintenance is disabled, not refreshing token for backend."):s.subscribe()},i=(s,i)=>{i&&t()},e=()=>{const s=this.h.I(o.q.xn);(null==s||s)&&t()},n=r.xt.Ft;new r.qt(n,r.D).hr(n.$t.Mr,i,e)}}))}changeUser(t,s,i){const e=this.v.getUserId();if(e!==t){this.j.kh(),null!=e&&this.gl(null,!1,null,null,null),this.v.Br(t),i?this.Fo.setSdkAuthenticationSignature(i):this.Fo.Qn();for(let t=0;t<s.length;t++)s[t].changeUser(null==e);null!=e&&this.h.Is(o.q.P),this.h.Is(o.q.Yo),this.openSession(),r.D.info('Changed user to "'+t+'".')}else{let s="Doing nothing.";i&&this.Fo.Kn()!==i&&(this.Fo.setSdkAuthenticationSignature(i),s="Updated SDK authentication signature"),r.D.info(`Current user is already ${t}. ${s}`)}}requestImmediateDataFlush(t){this.bl(),this.j.mo(),this.gl(null,null,null,null,null,t,!0)}requestFeedRefresh(){this.j.mo(),this.gl(!0)}zr(t,s){this.j.mo(),r.D.info("Requesting explicit trigger refresh."),this.gl(null,!0,null,t,s)}Nr(t,i){const e=r.A.jl,n={a:t,l:i},l=s.G(e,n);return l&&r.D.info(`Logged alias ${t} with label ${i}`),l}Or(i,e,n){if(this.wt.Gr(e))return r.D.info(`Custom Attribute "${e}" is blocklisted, ignoring.`),new t;const l={key:e,value:n},h=s.G(i,l);return h&&r.D.info(`Logged custom attribute: ${e} with value: ${n}`),h}setLastKnownLocation(t,i,e,n,l,h){const o={latitude:i,longitude:e};null!=n&&(o.altitude=n),null!=l&&(o.ll_accuracy=l),null!=h&&(o.alt_accuracy=h);const u=s.G(r.A.$l,o,t);return u&&r.D.info(`Set user last known location as ${JSON.stringify(o,null,2)}`),u}kr(t,s){const i=this.j.mo();return new ue(this.v.getUserId(),r.A.Al,t,i,{cid:s})}In(){const t=r.xt.Ft;new r.qt(t,r.D).setItem(t.$t.Cl,1,{baseUrl:this.Bo,data:{api_key:this.Vi,device_id:this.qi.te().id},userId:this.v.getUserId(),sdkAuthEnabled:this.Fo.Jn()})}wr(t){for(const s of t)if(s.api_key===this.Vi)this.jt.ca(s.events,s.attributes);else{const t=r.xt.Ft;new r.qt(t,r.D).setItem(t.$t.$r,r.it.nt(),s)}}Xr(i,e,n){if(this.wt.Gr(i))return r.D.info(`Custom Attribute "${i}" is blocklisted, ignoring.`),new t;let l,h;return null===e&&null===n?(l=r.A.Tl,h={key:i}):(l=r.A._l,h={key:i,latitude:e,longitude:n}),s.G(l,h)}Zr(t,i){const e={group_id:t,status:i};return s.G(r.A.ql,e)}} |
@@ -1,1 +0,1 @@ | ||
import kt from"./filter.js";import{isArray as p}from"../../util/code-utils.js";export default class Bt{constructor(t){this.filters=t}zl(t){let r=!0;for(let e=0;e<this.filters.length;e++){const o=this.filters[e];let s=!1;for(let r=0;r<o.length;r++)if(o[r].zl(t)){s=!0;break}if(!s){r=!1;break}}return r}static fromJson(t){if(null==t||!p(t))return null;const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.fromJson(s[t]));r.push(o)}return new Bt(r)}ss(){const t=[];for(let r=0;r<this.filters.length;r++){const e=this.filters[r],o=[];for(let t=0;t<e.length;t++)o.push(e[t].ss());t.push(o)}return t}static jn(t){const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.jn(s[t]));r.push(o)}return new Bt(r)}} | ||
import kt from"./filter.js";import{isArray as p}from"../../util/code-utils.js";export default class Bt{constructor(t){this.filters=t}zl(t){let r=!0;for(let e=0;e<this.filters.length;e++){const o=this.filters[e];let s=!1;for(let r=0;r<o.length;r++)if(o[r].zl(t)){s=!0;break}if(!s){r=!1;break}}return r}static fromJson(t){if(null==t||!p(t))return null;const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.fromJson(s[t]));r.push(o)}return new Bt(r)}ss(){const t=[];for(let r=0;r<this.filters.length;r++){const e=this.filters[r],o=[];for(let t=0;t<e.length;t++)o.push(e[t].ss());t.push(o)}return t}static Rn(t){const r=[];for(let e=0;e<t.length;e++){const o=[],s=t[e];for(let t=0;t<s.length;t++)o.push(kt.Rn(s[t]));r.push(o)}return new Bt(r)}} |
@@ -1,1 +0,1 @@ | ||
import{isDate as yt}from"../../util/code-utils.js";import{convertMsToSeconds as l,dateFromUnixTimestamp as h,secondsAgo as Ht,secondsInTheFuture as Ut}from"../../util/date-utils.js";export default class kt{constructor(t,s,e,i){this.El=t,this.Tl=s,this.comparator=e,this._l=i,this.Tl===kt.Ml.Nl&&this.comparator!==kt.Hl.Rl&&this.comparator!==kt.Hl.Ll&&this.comparator!==kt.Hl.Il&&this.comparator!==kt.Hl.Ol&&(this._l=h(this._l))}zl(t){let s=null;switch(null!=t&&(s=t[this.El]),this.comparator){case kt.Hl.Ul:return null!=s&&s.valueOf()===this._l.valueOf();case kt.Hl.Dl:return null==s||s.valueOf()!==this._l.valueOf();case kt.Hl.Ql:return typeof s==typeof this._l&&s>this._l;case kt.Hl.Rl:return this.Tl===kt.Ml.Nl?null!=s&&yt(s)&&Ht(s)<=this._l:typeof s==typeof this._l&&s>=this._l;case kt.Hl.Xl:return typeof s==typeof this._l&&s<this._l;case kt.Hl.Ll:return this.Tl===kt.Ml.Nl?null!=s&&yt(s)&&Ht(s)>=this._l:typeof s==typeof this._l&&s<=this._l;case kt.Hl.Gl:return null!=s&&"string"==typeof s&&typeof s==typeof this._l&&null!=s.match(this._l);case kt.Hl.Fl:return null!=s;case kt.Hl.Jl:return null==s;case kt.Hl.Il:return null!=s&&yt(s)&&Ut(s)<this._l;case kt.Hl.Ol:return null!=s&&yt(s)&&Ut(s)>this._l;case kt.Hl.Vl:return null==s||typeof s!=typeof this._l||"string"!=typeof s||null==s.match(this._l)}return!1}static fromJson(t){return new kt(t.property_key,t.property_type,t.comparator,t.property_value)}ss(){let t=this._l;return yt(this._l)&&(t=l(t.valueOf())),{k:this.El,t:this.Tl,c:this.comparator,v:t}}static jn(t){return new kt(t.k,t.t,t.c,t.v)}}kt.Hl={Ul:1,Dl:2,Ql:3,Rl:4,Xl:5,Ll:6,Gl:10,Fl:11,Jl:12,Il:15,Ol:16,Vl:17},kt.Ml={ql:"boolean",Kl:"number",Pl:"string",Nl:"date"}; | ||
import{isDate as yt}from"../../util/code-utils.js";import{convertMsToSeconds as l,dateFromUnixTimestamp as h,secondsAgo as Ht,secondsInTheFuture as Ut}from"../../util/date-utils.js";export default class kt{constructor(t,s,e,i){this.El=t,this.Nl=s,this.comparator=e,this.Ml=i,this.Nl===kt.Hl.Rl&&this.comparator!==kt.Il.Ll&&this.comparator!==kt.Il.Ol&&this.comparator!==kt.Il.Ul&&this.comparator!==kt.Il.Dl&&(this.Ml=h(this.Ml))}zl(t){let s=null;switch(null!=t&&(s=t[this.El]),this.comparator){case kt.Il.Ql:return null!=s&&s.valueOf()===this.Ml.valueOf();case kt.Il.Xl:return null==s||s.valueOf()!==this.Ml.valueOf();case kt.Il.Gl:return typeof s==typeof this.Ml&&s>this.Ml;case kt.Il.Ll:return this.Nl===kt.Hl.Rl?null!=s&&yt(s)&&Ht(s)<=this.Ml:typeof s==typeof this.Ml&&s>=this.Ml;case kt.Il.Fl:return typeof s==typeof this.Ml&&s<this.Ml;case kt.Il.Ol:return this.Nl===kt.Hl.Rl?null!=s&&yt(s)&&Ht(s)>=this.Ml:typeof s==typeof this.Ml&&s<=this.Ml;case kt.Il.Jl:return null!=s&&"string"==typeof s&&typeof s==typeof this.Ml&&null!=s.match(this.Ml);case kt.Il.Vl:return null!=s;case kt.Il.Kl:return null==s;case kt.Il.Ul:return null!=s&&yt(s)&&Ut(s)<this.Ml;case kt.Il.Dl:return null!=s&&yt(s)&&Ut(s)>this.Ml;case kt.Il.Pl:return null==s||typeof s!=typeof this.Ml||"string"!=typeof s||null==s.match(this.Ml)}return!1}static fromJson(t){return new kt(t.property_key,t.property_type,t.comparator,t.property_value)}ss(){let t=this.Ml;return yt(this.Ml)&&(t=l(t.valueOf())),{k:this.El,t:this.Nl,c:this.comparator,v:t}}static Rn(t){return new kt(t.k,t.t,t.c,t.v)}}kt.Il={Ql:1,Xl:2,Gl:3,Ll:4,Fl:5,Ol:6,Jl:10,Vl:11,Kl:12,Ul:15,Dl:16,Pl:17},kt.Hl={Wl:"boolean",Yl:"number",Zl:"string",Rl:"date"}; |
@@ -1,1 +0,1 @@ | ||
import Dt from"./trigger-condition.js";export default class Ft{constructor(t,i){this.Wl=t,this.Yl=i}zl(t){if(null==this.Wl)return!1;const i=Dt.Zl(t[0],this.Wl);if(!i)return!1;let r=null==this.Yl||0===this.Yl.length;if(null!=this.Yl)for(let i=0;i<this.Yl.length;i++)if(this.Yl[i]===t[1]){r=!0;break}return i&&r}static fromJson(t){return new Ft(t?t.id:null,t?t.buttons:null)}ss(){return this.Wl}} | ||
import Dt from"./trigger-condition.js";export default class Ft{constructor(t,i){this.tu=t,this.iu=i}zl(t){if(null==this.tu)return!1;const i=Dt.su(t[0],this.tu);if(!i)return!1;let r=null==this.iu||0===this.iu.length;if(null!=this.iu)for(let i=0;i<this.iu.length;i++)if(this.iu[i]===t[1]){r=!0;break}return i&&r}static fromJson(t){return new Ft(t?t.id:null,t?t.buttons:null)}ss(){return this.tu}} |
@@ -1,1 +0,1 @@ | ||
import Dt from"./trigger-condition.js";export default class Qt{constructor(t){this.Wl=t}zl(t){return null==this.Wl||Dt.Zl(t[0],this.Wl)}static fromJson(t){return new Qt(t?t.campaign_id:null)}ss(){return this.Wl}} | ||
import Dt from"./trigger-condition.js";export default class Qt{constructor(t){this.tu=t}zl(t){return null==this.tu||Dt.su(t[0],this.tu)}static fromJson(t){return new Qt(t?t.campaign_id:null)}ss(){return this.tu}} |
@@ -1,1 +0,1 @@ | ||
import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Ft from"./in-app-message-click-data.js";import Gt from"./purchase-data.js";import Kt from"./purchase-property-data.js";import Qt from"./push-click-data.js";import Q from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Dt{constructor(e,t){this.type=e,this.data=t}$a(e,t){return Dt.ec[this.type]===e&&(null==this.data||this.data.zl(t))}static Zl(e,t){let a=null;try{a=window.atob(e)}catch(t){return r.D.info("Failed to unencode analytics id "+e+": "+t.message),!1}return t===a.split("_")[0]}static fromJson(e){const t=e.type;let r;switch(t){case Dt.tc.OPEN:r=null;break;case Dt.tc.Rr:r=Gt.fromJson(e.data);break;case Dt.tc.rc:r=Kt.fromJson(e.data);break;case Dt.tc.vr:r=Qt.fromJson(e.data);break;case Dt.tc.be:r=xt.fromJson(e.data);break;case Dt.tc.ac:r=Mt.fromJson(e.data);break;case Dt.tc.Ar:r=Ft.fromJson(e.data);break;case Dt.tc.ks:r=null}return new Dt(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static jn(e){let t,r;switch(e.t){case Dt.tc.OPEN:t=null;break;case Dt.tc.Rr:t=new Gt(e.d);break;case Dt.tc.rc:r=e.d||{},t=new Kt(r.id,Bt.jn(r.pf||[]));break;case Dt.tc.vr:t=new Qt(e.d);break;case Dt.tc.be:t=new xt(e.d);break;case Dt.tc.ac:r=e.d||{},t=new Mt(r.e,Bt.jn(r.pf||[]));break;case Dt.tc.Ar:t=new Ft(e.d);break;case Dt.tc.ks:t=null}return new Dt(e.t,t)}}Dt.tc={OPEN:"open",Rr:"purchase",rc:"purchase_property",vr:"push_click",be:"custom_event",ac:"custom_event_property",Ar:"iam_click",ks:"test"},Dt.ec={},Dt.ec[Dt.tc.OPEN]=Q.OPEN,Dt.ec[Dt.tc.Rr]=Q.Rr,Dt.ec[Dt.tc.rc]=Q.Rr,Dt.ec[Dt.tc.vr]=Q.vr,Dt.ec[Dt.tc.be]=Q.be,Dt.ec[Dt.tc.ac]=Q.be,Dt.ec[Dt.tc.Ar]=Q.Ar,Dt.ec[Dt.tc.ks]=Q.ks; | ||
import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Ft from"./in-app-message-click-data.js";import Gt from"./purchase-data.js";import Kt from"./purchase-property-data.js";import Qt from"./push-click-data.js";import Q from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Dt{constructor(e,t){this.type=e,this.data=t}ec(e,t){return Dt.tc[this.type]===e&&(null==this.data||this.data.zl(t))}static su(e,t){let a=null;try{a=window.atob(e)}catch(t){return r.D.info("Failed to unencode analytics id "+e+": "+t.message),!1}return t===a.split("_")[0]}static fromJson(e){const t=e.type;let r;switch(t){case Dt.rc.OPEN:r=null;break;case Dt.rc.Rr:r=Gt.fromJson(e.data);break;case Dt.rc.ac:r=Kt.fromJson(e.data);break;case Dt.rc.vr:r=Qt.fromJson(e.data);break;case Dt.rc.be:r=xt.fromJson(e.data);break;case Dt.rc.sc:r=Mt.fromJson(e.data);break;case Dt.rc.Ar:r=Ft.fromJson(e.data);break;case Dt.rc.ks:r=null}return new Dt(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static Rn(e){let t,r;switch(e.t){case Dt.rc.OPEN:t=null;break;case Dt.rc.Rr:t=new Gt(e.d);break;case Dt.rc.ac:r=e.d||{},t=new Kt(r.id,Bt.Rn(r.pf||[]));break;case Dt.rc.vr:t=new Qt(e.d);break;case Dt.rc.be:t=new xt(e.d);break;case Dt.rc.sc:r=e.d||{},t=new Mt(r.e,Bt.Rn(r.pf||[]));break;case Dt.rc.Ar:t=new Ft(e.d);break;case Dt.rc.ks:t=null}return new Dt(e.t,t)}}Dt.rc={OPEN:"open",Rr:"purchase",ac:"purchase_property",vr:"push_click",be:"custom_event",sc:"custom_event_property",Ar:"iam_click",ks:"test"},Dt.tc={},Dt.tc[Dt.rc.OPEN]=Q.OPEN,Dt.tc[Dt.rc.Rr]=Q.Rr,Dt.tc[Dt.rc.ac]=Q.Rr,Dt.tc[Dt.rc.vr]=Q.vr,Dt.tc[Dt.rc.be]=Q.be,Dt.tc[Dt.rc.sc]=Q.be,Dt.tc[Dt.rc.Ar]=Q.Ar,Dt.tc[Dt.rc.ks]=Q.ks; |
@@ -1,1 +0,1 @@ | ||
import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import Dt from"./trigger-condition.js";import{validateValueIsFromEnum as K}from"../../util/code-utils.js";export default class ut{constructor(t,i,s,e,r,l,o,n,h,a,u,d){this.id=t,this.Th=i||[],void 0===s&&(s=null),this.startTime=s,void 0===e&&(e=null),this.endTime=e,this.priority=r||0,this.type=l,this.Ph=n||0,null==a&&(a=1e3*(this.Ph+30)),this.li=a,this.data=o,null==h&&(h=ut.yh),this.Ah=h,this.Ih=u,this.$h=d||null}Mh(t){return null==this.$h||this.Ah!==ut.yh&&t-this.$h>=1e3*this.Ah}Bh(t){this.$h=t}Jh(t){const i=t+1e3*this.Ph;return Math.max(i-(new Date).valueOf(),0)}Lh(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.li||i<this.li;return s||r.D.info(`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.li}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Dt.fromJson(t.trigger_condition[i]));const e=h(t.start_time),r=h(t.end_time),l=t.priority,o=t.type,n=t.delay,a=t.re_eligibility,u=t.timeout,d=t.data,m=t.min_seconds_since_last_trigger;return K(ut.ri,o,"Could not construct Trigger from server data","Trigger.Types")?new ut(i,s,e,r,l,o,d,n,a,u,m):null}ss(){const t=[];for(let i=0;i<this.Th.length;i++)t.push(this.Th[i].ss());return{i:this.id,c:t,s:this.startTime,e:this.endTime,p:this.priority,t:this.type,da:this.data,d:this.Ph,r:this.Ah,tm:this.li,ss:this.Ih,ld:this.$h}}static jn(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Dt.jn(t.c[s]));return new ut(t.i,i,w(t.s),w(t.e),t.p,t.t,t.da,t.d,t.r,t.tm,t.ss,t.ld)}}ut.yh=-1,ut.ri={ii:"inapp",Rh:"templated_iam"}; | ||
import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import Dt from"./trigger-condition.js";import{validateValueIsFromEnum as K}from"../../util/code-utils.js";export default class ut{constructor(t,i,s,e,r,l,o,n,h,a,u,d){this.id=t,this.Th=i||[],void 0===s&&(s=null),this.startTime=s,void 0===e&&(e=null),this.endTime=e,this.priority=r||0,this.type=l,this.Ph=n||0,null==a&&(a=1e3*(this.Ph+30)),this.ci=a,this.data=o,null==h&&(h=ut.yh),this.Ah=h,this.Ih=u,this.$h=d||null}Mh(t){return null==this.$h||this.Ah!==ut.yh&&t-this.$h>=1e3*this.Ah}Bh(t){this.$h=t}Jh(t){const i=t+1e3*this.Ph;return Math.max(i-(new Date).valueOf(),0)}Lh(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.ci||i<this.ci;return s||r.D.info(`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.ci}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Dt.fromJson(t.trigger_condition[i]));const e=h(t.start_time),r=h(t.end_time),l=t.priority,o=t.type,n=t.delay,a=t.re_eligibility,u=t.timeout,d=t.data,m=t.min_seconds_since_last_trigger;return K(ut.li,o,"Could not construct Trigger from server data","Trigger.Types")?new ut(i,s,e,r,l,o,d,n,a,u,m):null}ss(){const t=[];for(let i=0;i<this.Th.length;i++)t.push(this.Th[i].ss());return{i:this.id,c:t,s:this.startTime,e:this.endTime,p:this.priority,t:this.type,da:this.data,d:this.Ph,r:this.Ah,tm:this.ci,ss:this.Ih,ld:this.$h}}static Rn(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Dt.Rn(t.c[s]));return new ut(t.i,i,w(t.s),w(t.e),t.p,t.t,t.da,t.d,t.r,t.tm,t.ss,t.ld)}}ut.yh=-1,ut.li={ai:"inapp",Rh:"templated_iam"}; |
@@ -1,1 +0,1 @@ | ||
import pe from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as D}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(D.po);TriggersProviderFactory.provider=new ir(null!=r?r:30,pe.m().Be(),e.l(),e.mr(),pe.m()),e.ar(TriggersProviderFactory.provider)}},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}}; | ||
import pe from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as D}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(D.Ao);TriggersProviderFactory.provider=new ir(null!=r?r:30,pe.m().Be(),e.l(),e.mr(),pe.m()),e.ar(TriggersProviderFactory.provider)}},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}}; |
@@ -1,1 +0,1 @@ | ||
import C from"../common/base-provider.js";import{newInAppMessageFromJson as it}from"../InAppMessage/in-app-message-factory.js";import ue from"../models/braze-event.js";import{InAppMessage}from"../InAppMessage/index.js";import{isArray as p,isEqual as ii,validateValueIsFromEnum as K}from"../util/code-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ft from"../InAppMessage/models/templated-in-app-message.js";import ut from"./models/trigger.js";import Q from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends C{constructor(t,i,s,e,r){super(),this.Oh=t,this.vt=i,this.h=s,this.Is=e,this.Uh=r,this.Kh=[],this.Qh=[],this.Vh=null,this.Xh={},this.Yh={},this.Zh(),this.tg()}ig(){this.Vh=this.h.I(o.q.Da)||this.Vh,this.Xh=this.h.I(o.q.Ga)||this.Xh,this.Yh=this.h.I(o.q.Ya)||this.Yh;for(let t=0;t<this.sg.length;t++){const i=this.sg[t];null!=this.Yh[i.id]&&i.Bh(this.Yh[i.id])}}Zh(){this.eg=this.h.I(o.q.Ka)||0;const t=this.h.I(o.q.Ia)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.jn(t[s]));this.sg=i,this.ig()}tg(){const t=this,i=function(i,s,e,r,h){return function(){t.hg(i,s,e,r,h)}},s={};for(let t=0;t<this.sg.length;t++)s[this.sg[t].id]=this.sg[t];let e=!1;for(let t=0;t<this.sg.length;t++){const r=this.sg[t];if(null!=this.Xh[r.id]){const t=this.Xh[r.id],h=[];for(let e=0;e<t.length;e++){const o=t[e],n=r.Jh(o.ai);if(n>0){let t,e;h.push(o),null!=o.og&&(t=o.og),null!=o.ng&&ue.ya(o.ng)&&(e=ue.jn(o.ng));const l=[];if(p(o.lg))for(let t=0;t<o.lg.length;t++){const i=s[o.lg[t]];null!=i&&l.push(i)}this.Qh.push(setTimeout(i(r,o.ai,t,e,l),n))}}this.Xh[r.id].length>h.length&&(this.Xh[r.id]=h,e=!0,0===this.Xh[r.id].length&&delete this.Xh[r.id])}}e&&this.h.B(o.q.Ga,this.Xh)}ag(){const t=[];for(let i=0;i<this.sg.length;i++)t.push(this.sg[i].ss());this.eg=(new Date).valueOf(),this.h.B(o.q.Ia,t),this.h.B(o.q.Ka,this.eg)}gg(){(this.h.I(o.q.Ka)||0)>this.eg?this.Zh():this.ig()}_s(t){let i=!1;if(null!=t&&t.triggers){this.ig();const s={},e={};this.sg=[];for(let r=0;r<t.triggers.length;r++){const h=ut.fromJson(t.triggers[r]);null!=this.Yh[h.id]&&(h.Bh(this.Yh[h.id]),s[h.id]=this.Yh[h.id]),null!=this.Xh[h.id]&&(e[h.id]=this.Xh[h.id]);for(let t=0;t<h.Th.length;t++)if(h.Th[t].$a(Q.ks,null)){i=!0;break}null!=h&&this.sg.push(h)}ii(this.Yh,s)||(this.Yh=s,this.h.B(o.q.Ya,this.Yh)),ii(this.Xh,e)||(this.Xh=e,this.h.B(o.q.Ga,this.Xh)),this.ag(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(Q.ks)),this.je(Q.OPEN);const h=this.Kh;this.Kh=[];for(let t=0;t<h.length;t++)this.je.apply(this,h[t])}}async hg(t,i,s,e,h){const o=e=>{this.ig();const h=(new Date).valueOf();if(!t.Lh(i))return!1===navigator.onLine&&t.type===ut.ri.ii&&e.imageUrl?(r.D.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.Uh.qe(t.id,InAppMessage.Oe.Bi)):void(t.Mh(h)&&this.fg(t,h,s)?(this.vt.Nt([e]),this.cg(t,h)):r.D.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===ut.ri.Rh?this.Uh.qe(t.id,InAppMessage.Oe.ei):this.Uh.qe(t.id,InAppMessage.Oe.vi)},n=()=>{this.ig();const o=h.pop();if(null!=o)if(this.ug(o,i,s,e,h),o.Lh(i)){let t=`Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;h.length>0&&(t+=" Continuing to fall back."),r.D.info(t),this.Uh.qe(o.id,InAppMessage.Oe.vi),n()}else{r.D.info(`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`);const n=1e3*o.Ph-((new Date).valueOf()-i);n>0?this.Qh.push(setTimeout((()=>{this.hg(o,i,s,e,h)}),n)):this.hg(o,i,s,e,h)}};switch(t.type){case ut.ri.ii:const h=it(t.data);if(null==h){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ni);break}let l=await this.Uh.Ve(h);if(l){r.D.error(l),n();break}o(h);break;case ut.ri.Rh:const a=ft.fromJson(t.data,o,n,i,t.li);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ni);break}this.Uh.Xs(a,s,e);break;default:r.D.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ni)}}je(t,i,s){if(!K(Q,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.Is.bl())return r.D.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.Kh.push(arguments);this.gg();const e=(new Date).valueOf(),h=e-this.Vh;let o=!0,n=!0;const l=[];for(let s=0;s<this.sg.length;s++){const r=this.sg[s],h=e+1e3*r.Ph;if(r.Mh(h)&&(null==r.startTime||r.startTime<=e)&&(null==r.endTime||r.endTime>=e)){let s=!1;for(let e=0;e<r.Th.length;e++)if(r.Th[e].$a(t,i)){s=!0;break}s&&(o=!1,this.fg(r,h,t)&&(n=!1,l.push(r)))}}if(o)return void r.D.info(`Trigger event ${t} did not match any trigger conditions.`);if(n)return void r.D.info(`Ignoring ${t} trigger event because a trigger was displayed ${h/1e3}s ago.`);l.sort(((t,i)=>t.priority-i.priority));const a=l.pop();null!=a&&(r.D.info(`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`),this.ug(a,e,t,s,l),0===a.Ph?this.hg(a,e,t,s,l):this.Qh.push(setTimeout((()=>{this.hg(a,e,t,s,l)}),1e3*a.Ph)))}changeUser(t){if(this.sg=[],this.h.$s(o.q.Ia),!t){this.Kh=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[],this.h.$s(o.q.Da),this.h.$s(o.q.Ya),this.h.$s(o.q.Ga)}}clearData(){this.sg=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[]}fg(t,i,s){if(null==this.Vh)return!0;if(s===Q.ks)return r.D.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.Ih;return null==e&&(e=this.Oh),i-this.Vh>=1e3*e}ug(t,i,s,e,r){this.ig(),this.Xh[t.id]=this.Xh[t.id]||[];const h={};let n;h.ai=i,h.og=s,null!=e&&(n=e.ss()),h.ng=n;const l=[];for(let t=0;t<r.length;t++)l.push(r[t].id);h.lg=l,this.Xh[t.id].push(h),this.h.B(o.q.Ga,this.Xh)}cg(t,i){this.ig(),t.Bh(i),this.Vh=i,this.h.B(o.q.Da,i),this.Yh[t.id]=i,this.h.B(o.q.Ya,this.Yh)}} | ||
import C from"../common/base-provider.js";import{newInAppMessageFromJson as it}from"../InAppMessage/in-app-message-factory.js";import ue from"../models/braze-event.js";import{InAppMessage}from"../InAppMessage/index.js";import{isArray as p,isEqual as ii,validateValueIsFromEnum as K}from"../util/code-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ft from"../InAppMessage/models/templated-in-app-message.js";import ut from"./models/trigger.js";import Q from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends C{constructor(t,i,s,e,r){super(),this.Oh=t,this.vt=i,this.h=s,this.Vs=e,this.Uh=r,this.Kh=[],this.Qh=[],this.Vh=null,this.Xh={},this.Yh={},this.Zh(),this.tg()}ig(){this.Vh=this.h.I(o.q.va)||this.Vh,this.Xh=this.h.I(o.q.Ma)||this.Xh,this.Yh=this.h.I(o.q.Na)||this.Yh;for(let t=0;t<this.sg.length;t++){const i=this.sg[t];null!=this.Yh[i.id]&&i.Bh(this.Yh[i.id])}}Zh(){this.eg=this.h.I(o.q.Ga)||0;const t=this.h.I(o.q.Ya)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.Rn(t[s]));this.sg=i,this.ig()}tg(){const t=this,i=function(i,s,e,r,h){return function(){t.hg(i,s,e,r,h)}},s={};for(let t=0;t<this.sg.length;t++)s[this.sg[t].id]=this.sg[t];let e=!1;for(let t=0;t<this.sg.length;t++){const r=this.sg[t];if(null!=this.Xh[r.id]){const t=this.Xh[r.id],h=[];for(let e=0;e<t.length;e++){const o=t[e],n=r.Jh(o.mi);if(n>0){let t,e;h.push(o),null!=o.og&&(t=o.og),null!=o.ng&&ue.Fa(o.ng)&&(e=ue.Rn(o.ng));const l=[];if(p(o.lg))for(let t=0;t<o.lg.length;t++){const i=s[o.lg[t]];null!=i&&l.push(i)}this.Qh.push(setTimeout(i(r,o.mi,t,e,l),n))}}this.Xh[r.id].length>h.length&&(this.Xh[r.id]=h,e=!0,0===this.Xh[r.id].length&&delete this.Xh[r.id])}}e&&this.h.B(o.q.Ma,this.Xh)}ag(){const t=[];for(let i=0;i<this.sg.length;i++)t.push(this.sg[i].ss());this.eg=(new Date).valueOf(),this.h.B(o.q.Ya,t),this.h.B(o.q.Ga,this.eg)}gg(){(this.h.I(o.q.Ga)||0)>this.eg?this.Zh():this.ig()}ys(t){let i=!1;if(null!=t&&t.triggers){this.ig();const s={},e={};this.sg=[];for(let r=0;r<t.triggers.length;r++){const h=ut.fromJson(t.triggers[r]);null!=this.Yh[h.id]&&(h.Bh(this.Yh[h.id]),s[h.id]=this.Yh[h.id]),null!=this.Xh[h.id]&&(e[h.id]=this.Xh[h.id]);for(let t=0;t<h.Th.length;t++)if(h.Th[t].ec(Q.ks,null)){i=!0;break}null!=h&&this.sg.push(h)}ii(this.Yh,s)||(this.Yh=s,this.h.B(o.q.Na,this.Yh)),ii(this.Xh,e)||(this.Xh=e,this.h.B(o.q.Ma,this.Xh)),this.ag(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(Q.ks)),this.je(Q.OPEN);const h=this.Kh;this.Kh=[];for(let t=0;t<h.length;t++)this.je.apply(this,h[t])}}async hg(t,i,s,e,h){const o=e=>{this.ig();const h=(new Date).valueOf();if(!t.Lh(i))return!1===navigator.onLine&&t.type===ut.li.ai&&e.imageUrl?(r.D.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.Uh.qe(t.id,InAppMessage.Oe.ki)):void(t.Mh(h)&&this.fg(t,h,s)?(this.vt.St([e]),this.cg(t,h)):r.D.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===ut.li.Rh?this.Uh.qe(t.id,InAppMessage.Oe.ni):this.Uh.qe(t.id,InAppMessage.Oe.wi)},n=()=>{this.ig();const o=h.pop();if(null!=o)if(this.ug(o,i,s,e,h),o.Lh(i)){let t=`Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;h.length>0&&(t+=" Continuing to fall back."),r.D.info(t),this.Uh.qe(o.id,InAppMessage.Oe.wi),n()}else{r.D.info(`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`);const n=1e3*o.Ph-((new Date).valueOf()-i);n>0?this.Qh.push(setTimeout((()=>{this.hg(o,i,s,e,h)}),n)):this.hg(o,i,s,e,h)}};switch(t.type){case ut.li.ai:const h=it(t.data);if(null==h){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ui);break}let l=await this.Uh.Ve(h);if(l){r.D.error(l),n();break}o(h);break;case ut.li.Rh:const a=ft.fromJson(t.data,o,n,i,t.ci);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ui);break}this.Uh.ei(a,s,e);break;default:r.D.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ui)}}je(t,i,s){if(!K(Q,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.Vs.yl())return r.D.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.Kh.push(arguments);this.gg();const e=(new Date).valueOf(),h=e-this.Vh;let o=!0,n=!0;const l=[];for(let s=0;s<this.sg.length;s++){const r=this.sg[s],h=e+1e3*r.Ph;if(r.Mh(h)&&(null==r.startTime||r.startTime<=e)&&(null==r.endTime||r.endTime>=e)){let s=!1;for(let e=0;e<r.Th.length;e++)if(r.Th[e].ec(t,i)){s=!0;break}s&&(o=!1,this.fg(r,h,t)&&(n=!1,l.push(r)))}}if(o)return void r.D.info(`Trigger event ${t} did not match any trigger conditions.`);if(n)return void r.D.info(`Ignoring ${t} trigger event because a trigger was displayed ${h/1e3}s ago.`);l.sort(((t,i)=>t.priority-i.priority));const a=l.pop();null!=a&&(r.D.info(`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`),this.ug(a,e,t,s,l),0===a.Ph?this.hg(a,e,t,s,l):this.Qh.push(setTimeout((()=>{this.hg(a,e,t,s,l)}),1e3*a.Ph)))}changeUser(t){if(this.sg=[],this.h.Is(o.q.Ya),!t){this.Kh=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[],this.h.Is(o.q.va),this.h.Is(o.q.Na),this.h.Is(o.q.Ma)}}clearData(){this.sg=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[]}fg(t,i,s){if(null==this.Vh)return!0;if(s===Q.ks)return r.D.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.Ih;return null==e&&(e=this.Oh),i-this.Vh>=1e3*e}ug(t,i,s,e,r){this.ig(),this.Xh[t.id]=this.Xh[t.id]||[];const h={};let n;h.mi=i,h.og=s,null!=e&&(n=e.ss()),h.ng=n;const l=[];for(let t=0;t<r.length;t++)l.push(r[t].id);h.lg=l,this.Xh[t.id].push(h),this.h.B(o.q.Ma,this.Xh)}cg(t,i){this.ig(),t.Bh(i),this.Vh=i,this.h.B(o.q.va,i),this.Yh[t.id]=i,this.h.B(o.q.Na,this.Yh)}} |
@@ -1,1 +0,1 @@ | ||
import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.0.6".replace(/\./g,"-")}`,a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(D.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}} | ||
import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.1.0".replace(/\./g,"-")}`,a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(D.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}} |
@@ -1,1 +0,1 @@ | ||
import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function loadFontAwesome(){if(e.nn(D.So))return;const t="https://use.fontawesome.com/7f85a56ba4.css";if(!(null!==document.querySelector('link[rel=stylesheet][href="'+t+'"]'))){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.getElementsByTagName("head")[0].appendChild(e)}} | ||
import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function loadFontAwesome(){if(e.nn(D.Oo))return;const t="https://use.fontawesome.com/7f85a56ba4.css";if(!(null!==document.querySelector('link[rel=stylesheet][href="'+t+'"]'))){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.getElementsByTagName("head")[0].appendChild(e)}} |
@@ -1,1 +0,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)}}} | ||
import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.wt=t,this.h=s}getUserId(){const t=this.h._r(o.Cr.Ur);if(null==t)return null;let s=t.Ir,i=U(s);if(i>User.ee){for(;i>User.ee;)s=s.slice(0,s.length-1),i=U(s);t.Ir=s,this.h.Lr(o.Cr.Ur,t)}return s}Br(t){const s=null==this.getUserId();this.h.Lr(o.Cr.Ur,new _t(t)),s&&this.h.Er(t)}setCustomUserAttribute(t,s){if(this.wt.Gr(t))return r.D.info('Custom Attribute "'+t+'" is blocklisted, ignoring.'),!1;const i={};return i[t]=s,this.Hr(User.Jr,i,!0)}Hr(t,s,i,e){const u=this.h.Kr(this.getUserId(),t,s);return!e&&u&&r.D.info(`Logged${i?" custom":""} attribute ${t} with value ${s}`),u}gn(t,s,i,e,u){this.Hr("push_token",t,!1,!0),this.Hr("custom_push_public_key",i,!1,!0),this.Hr("custom_push_user_auth",e,!1,!0),this.Hr("custom_push_vapid_public_key",u,!1,!0);const h=r.xt.Ft,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.xn,l.ss()),n.setItem(h.$t.Mr,h.se,!0)}vn(t){if(this.Hr("push_token",null,!1,!0),this.Hr("custom_push_public_key",null,!1,!0),this.Hr("custom_push_user_auth",null,!1,!0),this.Hr("custom_push_vapid_public_key",null,!1,!0),t){const t=r.xt.Ft,s=new r.qt(t,r.D);this.h.B(o.q.xn,!1),s.setItem(t.$t.Mr,t.se,!1)}}} |
@@ -1,1 +0,1 @@ | ||
import{isArray as p,isDate as yt,validateValueIsFromEnum as K}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"../util/date-utils.js";import{isValidEmail as vt,validateCustomString as X,validateStandardString as R}from"../util/validation-utils.js";export default class User{constructor(t,e){this.v=t,this.Is=e}getUserId(t){null==t&&r.D.error("getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"),"function"==typeof t&&t(this.v.getUserId())}addAlias(t,e){return!R(t,"add alias","the alias",!1)||t.length<=0?(r.D.error("addAlias requires a non-empty alias"),!1):!R(e,"add alias","the label",!1)||e.length<=0?(r.D.error("addAlias requires a non-empty label"),!1):this.Is.Nr(t,e).S}setFirstName(t){return!!R(t,"set first name","the firstName",!0)&&this.v.Hr("first_name",t)}setLastName(t){return!!R(t,"set last name","the lastName",!0)&&this.v.Hr("last_name",t)}setEmail(t){return null===t||vt(t)?this.v.Hr("email",t):(r.D.error(`Cannot set email address - "${t}" did not pass RFC-5322 validation.`),!1)}setGender(t){return"string"==typeof t&&(t=t.toLowerCase()),!(null!==t&&!K(User.Genders,t,`Gender "${t}" is not a valid gender.`,"User.Genders"))&&this.v.Hr("gender",t)}setDateOfBirth(t,e,s){return null===t&&null===e&&null===s?this.v.Hr("dob",null):(t=parseInt(t),e=parseInt(e),s=parseInt(s),isNaN(t)||isNaN(e)||isNaN(s)||e>12||e<1||s>31||s<1?(r.D.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):this.v.Hr("dob",`${t}-${e}-${s}`))}setCountry(t){return!!R(t,"set country","the country",!0)&&this.v.Hr("country",t)}setHomeCity(t){return!!R(t,"set home city","the homeCity",!0)&&this.v.Hr("home_city",t)}setLanguage(t){return!!R(t,"set language","the language",!0)&&this.v.Hr("language",t)}setEmailNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Email notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Hr("email_subscribe",t)}setPushNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Push notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Hr("push_subscribe",t)}setPhoneNumber(t){return!!R(t,"set phone number","the phoneNumber",!0)&&(null===t||t.match(User.Sr)?this.v.Hr("phone",t):(r.D.error(`Cannot set phone number - "${t}" did not pass validation.`),!1))}setLastKnownLocation(t,e,s,i,n){return null==t||null==e?(r.D.error("Cannot set last-known location - latitude and longitude are required."),!1):(t=parseFloat(t),e=parseFloat(e),null!=s&&(s=parseFloat(s)),null!=i&&(i=parseFloat(i)),null!=n&&(n=parseFloat(n)),isNaN(t)||isNaN(e)||null!=s&&isNaN(s)||null!=i&&isNaN(i)||null!=n&&isNaN(n)?(r.D.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):t>90||t<-90||e>180||e<-180?(r.D.error("Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."),!1):null!=s&&s<0||null!=n&&n<0?(r.D.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.Is.setLastKnownLocation(this.v.getUserId(),t,e,i,s,n).S)}setCustomUserAttribute(t,e){if(!X(t,"set custom user attribute","the given key"))return!1;const s=typeof e,i=yt(e),n=p(e);if("number"!==s&&"boolean"!==s&&!i&&!n&&null!==e&&!X(e,`set custom user attribute "${t}"`,"the given value"))return!1;if(i&&(e=Nt(e)),n){for(let s=0;s<e.length;s++){const r=e[s];if(!X(r,`set custom user attribute "${t}"`,"the element in the given array"))return!1}return this.Is.Or(r.A.Vr,t,e).S}return this.v.setCustomUserAttribute(t,e)}addToCustomAttributeArray(t,e){return!!X(t,"add to custom user attribute array","the given key")&&(!(null!=e&&!X(e,"add to custom user attribute array","the given value"))&&this.Is.Or(r.A.Wr,t,e).S)}removeFromCustomAttributeArray(t,e){return!!X(t,"remove from custom user attribute array","the given key")&&(!(null!=e&&!X(e,"remove from custom user attribute array","the given value"))&&this.Is.Or(r.A.Yr,t,e).S)}incrementCustomUserAttribute(t,e){if(!X(t,"increment custom user attribute","the given key"))return!1;null==e&&(e=1);const s=parseInt(e);return isNaN(s)||s!==parseFloat(e)?(r.D.error(`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`),!1):this.Is.Or(r.A.Qr,t,s).S}setCustomLocationAttribute(t,e,s){return!!X(t,"set custom location attribute","the given key")&&((null!==e||null!==s)&&(e=parseFloat(e),s=parseFloat(s),isNaN(e)||e>90||e<-90||isNaN(s)||s>180||s<-180)?(r.D.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal."),!1):this.Is.Xr(t,e,s).S)}addToSubscriptionGroup(t){return!R(t,"add user to subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Is.Zr(t,User.Cn.SUBSCRIBED).S}removeFromSubscriptionGroup(t){return!R(t,"remove user from subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Is.Zr(t,User.Cn.UNSUBSCRIBED).S}fn(t,e,s,r,i){this.v.fn(t,e,s,r,i),this.Is.In()}wn(t){this.v.wn(t)}}User.Sr=/^[0-9 .\\(\\)\\+\\-]+$/,User.Genders={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},User.NotificationSubscriptionTypes={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.Cn={SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.En="user_id",User.Jr="custom",User.ee=997; | ||
import{isArray as p,isDate as yt,validateValueIsFromEnum as K}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"../util/date-utils.js";import{isValidEmail as vt,validateCustomString as X,validateStandardString as R}from"../util/validation-utils.js";export default class User{constructor(t,e){this.v=t,this.Vs=e}getUserId(t){null==t&&r.D.error("getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"),"function"==typeof t&&t(this.v.getUserId())}addAlias(t,e){return!R(t,"add alias","the alias",!1)||t.length<=0?(r.D.error("addAlias requires a non-empty alias"),!1):!R(e,"add alias","the label",!1)||e.length<=0?(r.D.error("addAlias requires a non-empty label"),!1):this.Vs.Nr(t,e).S}setFirstName(t){return!!R(t,"set first name","the firstName",!0)&&this.v.Hr("first_name",t)}setLastName(t){return!!R(t,"set last name","the lastName",!0)&&this.v.Hr("last_name",t)}setEmail(t){return null===t||vt(t)?this.v.Hr("email",t):(r.D.error(`Cannot set email address - "${t}" did not pass RFC-5322 validation.`),!1)}setGender(t){return"string"==typeof t&&(t=t.toLowerCase()),!(null!==t&&!K(User.Genders,t,`Gender "${t}" is not a valid gender.`,"User.Genders"))&&this.v.Hr("gender",t)}setDateOfBirth(t,e,s){return null===t&&null===e&&null===s?this.v.Hr("dob",null):(t=parseInt(t),e=parseInt(e),s=parseInt(s),isNaN(t)||isNaN(e)||isNaN(s)||e>12||e<1||s>31||s<1?(r.D.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):this.v.Hr("dob",`${t}-${e}-${s}`))}setCountry(t){return!!R(t,"set country","the country",!0)&&this.v.Hr("country",t)}setHomeCity(t){return!!R(t,"set home city","the homeCity",!0)&&this.v.Hr("home_city",t)}setLanguage(t){return!!R(t,"set language","the language",!0)&&this.v.Hr("language",t)}setEmailNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Email notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Hr("email_subscribe",t)}setPushNotificationSubscriptionType(t){return!!K(User.NotificationSubscriptionTypes,t,`Push notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.Hr("push_subscribe",t)}setPhoneNumber(t){return!!R(t,"set phone number","the phoneNumber",!0)&&(null===t||t.match(User.Sr)?this.v.Hr("phone",t):(r.D.error(`Cannot set phone number - "${t}" did not pass validation.`),!1))}setLastKnownLocation(t,e,s,i,n){return null==t||null==e?(r.D.error("Cannot set last-known location - latitude and longitude are required."),!1):(t=parseFloat(t),e=parseFloat(e),null!=s&&(s=parseFloat(s)),null!=i&&(i=parseFloat(i)),null!=n&&(n=parseFloat(n)),isNaN(t)||isNaN(e)||null!=s&&isNaN(s)||null!=i&&isNaN(i)||null!=n&&isNaN(n)?(r.D.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):t>90||t<-90||e>180||e<-180?(r.D.error("Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."),!1):null!=s&&s<0||null!=n&&n<0?(r.D.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.Vs.setLastKnownLocation(this.v.getUserId(),t,e,i,s,n).S)}setCustomUserAttribute(t,e){if(!X(t,"set custom user attribute","the given key"))return!1;const s=typeof e,i=yt(e),n=p(e);if("number"!==s&&"boolean"!==s&&!i&&!n&&null!==e&&!X(e,`set custom user attribute "${t}"`,"the given value"))return!1;if(i&&(e=Nt(e)),n){for(let s=0;s<e.length;s++){const r=e[s];if(!X(r,`set custom user attribute "${t}"`,"the element in the given array"))return!1}return this.Vs.Or(r.A.Vr,t,e).S}return this.v.setCustomUserAttribute(t,e)}addToCustomAttributeArray(t,e){return!!X(t,"add to custom user attribute array","the given key")&&(!(null!=e&&!X(e,"add to custom user attribute array","the given value"))&&this.Vs.Or(r.A.Wr,t,e).S)}removeFromCustomAttributeArray(t,e){return!!X(t,"remove from custom user attribute array","the given key")&&(!(null!=e&&!X(e,"remove from custom user attribute array","the given value"))&&this.Vs.Or(r.A.Yr,t,e).S)}incrementCustomUserAttribute(t,e){if(!X(t,"increment custom user attribute","the given key"))return!1;null==e&&(e=1);const s=parseInt(e);return isNaN(s)||s!==parseFloat(e)?(r.D.error(`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`),!1):this.Vs.Or(r.A.Qr,t,s).S}setCustomLocationAttribute(t,e,s){return!!X(t,"set custom location attribute","the given key")&&((null!==e||null!==s)&&(e=parseFloat(e),s=parseFloat(s),isNaN(e)||e>90||e<-90||isNaN(s)||s>180||s<-180)?(r.D.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal."),!1):this.Vs.Xr(t,e,s).S)}addToSubscriptionGroup(t){return!R(t,"add user to subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Vs.Zr(t,User.Cn.SUBSCRIBED).S}removeFromSubscriptionGroup(t){return!R(t,"remove user from subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):this.Vs.Zr(t,User.Cn.UNSUBSCRIBED).S}gn(t,e,s,r,i){this.v.gn(t,e,s,r,i),this.Vs.In()}vn(t){this.v.vn(t)}}User.Sr=/^[0-9 .\\(\\)\\+\\-]+$/,User.Genders={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},User.NotificationSubscriptionTypes={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.Cn={SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.En="user_id",User.Jr="custom",User.ee=997; |
@@ -1,1 +0,1 @@ | ||
import{isArray as p}from"./code-utils.js";export default class Yt{constructor(){}tf(){}ef(){}Ko(t){}static rf(t,e){if(t&&e)if(t=t.toLowerCase(),p(e.if)){for(let r=0;r<e.if.length;r++)if(-1!==t.indexOf(e.if[r].toLowerCase()))return e.identity}else if(-1!==t.indexOf(e.if.toLowerCase()))return e.identity}} | ||
import{isArray as p}from"./code-utils.js";export default class Yt{constructor(){}tf(){}ef(){}Zo(t){}static rf(t,e){if(t&&e)if(t=t.toLowerCase(),p(e.if)){for(let r=0;r<e.if.length;r++)if(-1!==t.indexOf(e.if[r].toLowerCase()))return e.identity}else if(-1!==t.indexOf(e.if.toLowerCase()))return e.identity}} |
@@ -1,1 +0,1 @@ | ||
import ti from"./client-hints-parser.js";import ni from"./user-agent-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";class si{constructor(){const t=navigator.userAgentData?ti:ni;this.dg=new t,this.userAgent=navigator.userAgent,this.browser=this.dg.tf(),this.version=this.dg.ef(),this.Ko().then((t=>this.OS=t)),this.language=(navigator.userLanguage||navigator.language||navigator.browserLanguage||navigator.systemLanguage||"").toLowerCase(),this.jo=si.Sg(this.userAgent)}bg(){return this.browser!==ri.vg||this.version>8}Pa(){return this.browser===ri.yg}qo(){return this.OS||null}Ko(){return this.OS?Promise.resolve(this.OS):this.dg.Ko(si.pg).then((t=>(this.OS=t,t)))}static Sg(t){t=t.toLowerCase();const i=["googlebot","bingbot","slurp","duckduckbot","baiduspider","yandex","facebookexternalhit","sogou","ia_archiver","https://github.com/prerender/prerender","aolbuild","bingpreview","msnbot","adsbot","mediapartners-google","teoma"];for(let n=0;n<i.length;n++)if(-1!==t.indexOf(i[n]))return!0;return!1}}si.pg=[{string:navigator.platform,if:"Win",identity:ot.mg},{string:navigator.platform,if:"Mac",identity:ot.Bg},{string:navigator.platform,if:"BlackBerry",identity:"BlackBerry"},{string:navigator.platform,if:"FreeBSD",identity:"FreeBSD"},{string:navigator.platform,if:"OpenBSD",identity:"OpenBSD"},{string:navigator.platform,if:"Nintendo",identity:"Nintendo"},{string:navigator.platform,if:"SunOS",identity:"SunOS"},{string:navigator.platform,if:"PlayStation",identity:"PlayStation"},{string:navigator.platform,if:"X11",identity:"X11"},{string:navigator.userAgent,if:["iPhone","iPad","iPod"],identity:ot.ln},{string:navigator.platform,if:"Pike v",identity:ot.ln},{string:navigator.userAgent,if:["Web0S"],identity:"WebOS"},{string:navigator.platform,if:["Linux armv7l","Android"],identity:ot.Og},{string:navigator.userAgent,if:["Android"],identity:ot.Og},{string:navigator.platform,if:"Linux",identity:"Linux"}];const et=new si;export{et as default,si as BrowserDetector}; | ||
import ti from"./client-hints-parser.js";import ni from"./user-agent-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";class si{constructor(){const t=navigator.userAgentData?ti:ni;this.dg=new t,this.userAgent=navigator.userAgent,this.browser=this.dg.tf(),this.version=this.dg.ef(),this.Zo().then((t=>this.OS=t)),this.language=(navigator.userLanguage||navigator.language||navigator.browserLanguage||navigator.systemLanguage||"").toLowerCase(),this.Wo=si.Sg(this.userAgent)}bg(){return this.browser!==ri.vg||this.version>8}ka(){return this.browser===ri.yg}Xo(){return this.OS||null}Zo(){return this.OS?Promise.resolve(this.OS):this.dg.Zo(si.pg).then((t=>(this.OS=t,t)))}static Sg(t){t=t.toLowerCase();const i=["googlebot","bingbot","slurp","duckduckbot","baiduspider","yandex","facebookexternalhit","sogou","ia_archiver","https://github.com/prerender/prerender","aolbuild","bingpreview","msnbot","adsbot","mediapartners-google","teoma"];for(let n=0;n<i.length;n++)if(-1!==t.indexOf(i[n]))return!0;return!1}}si.pg=[{string:navigator.platform,if:"Win",identity:ot.mg},{string:navigator.platform,if:"Mac",identity:ot.Bg},{string:navigator.platform,if:"BlackBerry",identity:"BlackBerry"},{string:navigator.platform,if:"FreeBSD",identity:"FreeBSD"},{string:navigator.platform,if:"OpenBSD",identity:"OpenBSD"},{string:navigator.platform,if:"Nintendo",identity:"Nintendo"},{string:navigator.platform,if:"SunOS",identity:"SunOS"},{string:navigator.platform,if:"PlayStation",identity:"PlayStation"},{string:navigator.platform,if:"X11",identity:"X11"},{string:navigator.userAgent,if:["iPhone","iPad","iPod"],identity:ot.ln},{string:navigator.platform,if:"Pike v",identity:ot.ln},{string:navigator.userAgent,if:["Web0S"],identity:"WebOS"},{string:navigator.platform,if:["Linux armv7l","Android"],identity:ot.Og},{string:navigator.userAgent,if:["Android"],identity:ot.Og},{string:navigator.platform,if:"Linux",identity:"Linux"}];const et=new si;export{et as default,si as BrowserDetector}; |
@@ -1,1 +0,1 @@ | ||
import Yt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Yt{constructor(){if(super(),this.userAgentData=navigator.userAgentData,this.userAgentData){const t=this.sc();this.browser=t.browser||"Unknown Browser",this.version=t.version||"Unknown Version"}}tf(){return this.browser}ef(){return this.version}Ko(t){if(this.OS)return Promise.resolve(this.OS);const r=r=>{for(let s=0;s<t.length;s++){const e=ti.rf(r,t[s]);if(e)return this.OS=e,this.OS}return r};return this.userAgentData.platform?Promise.resolve(r(this.userAgentData.platform)):this.ic().then((t=>r(t.platform))).catch((()=>navigator.platform))}sc(){const t={},r=this.userAgentData.brands;if(r&&r.length)for(const s of r){const r=this.nc(ri),e=s.brand.match(r);if(e&&e.length>0){t.browser=e[0],t.version=s.version;break}}return t}nc(t){const r=[];for(const s in t)t[s]!==ri.vg&&r.push(t[s]);return new RegExp("("+r.join("|")+")","i")}ic(){return this.userAgentData.getHighEntropyValues?this.userAgentData.getHighEntropyValues(["platform"]):Promise.reject()}} | ||
import Yt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Yt{constructor(){if(super(),this.userAgentData=navigator.userAgentData,this.userAgentData){const t=this.ic();this.browser=t.browser||"Unknown Browser",this.version=t.version||"Unknown Version"}}tf(){return this.browser}ef(){return this.version}Zo(t){if(this.OS)return Promise.resolve(this.OS);const r=r=>{for(let s=0;s<t.length;s++){const e=ti.rf(r,t[s]);if(e)return this.OS=e,this.OS}return r};return this.userAgentData.platform?Promise.resolve(r(this.userAgentData.platform)):this.nc().then((t=>r(t.platform))).catch((()=>navigator.platform))}ic(){const t={},r=this.userAgentData.brands;if(r&&r.length)for(const s of r){const r=this.oc(ri),e=s.brand.match(r);if(e&&e.length>0){t.browser=e[0],t.version=s.version;break}}return t}oc(t){const r=[];for(const s in t)t[s]!==ri.vg&&r.push(t[s]);return new RegExp("("+r.join("|")+")","i")}nc(){return this.userAgentData.getHighEntropyValues?this.userAgentData.getHighEntropyValues(["platform"]):Promise.reject()}} |
@@ -1,1 +0,1 @@ | ||
export function _isInView(t,n,e,s){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={tu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",at:"right"};export function supportsPassive(){if(null==DOMUtils.tu){DOMUtils.tu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.tu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.tu}export function addPassiveEventListener(t,n,e){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.eo(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.eo(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,u=i-o.touches[0].clientY;Math.abs(l)>Math.abs(u)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.ot||l<0&&n===DIRECTIONS.at)&&e(o),s=null,i=null):Math.abs(u)>=25&&((u>0&&n===DIRECTIONS.Te&&t.scrollTop===t.scrollHeight-t.offsetHeight||u<0&&n===DIRECTIONS.$e&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i} | ||
export function _isInView(t,n,e,s){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={nu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",et:"right"};export function supportsPassive(){if(null==DOMUtils.nu){DOMUtils.nu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.nu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.nu}export function addPassiveEventListener(t,n,e){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.eo(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.eo(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,u=i-o.touches[0].clientY;Math.abs(l)>Math.abs(u)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.ot||l<0&&n===DIRECTIONS.et)&&e(o),s=null,i=null):Math.abs(u)>=25&&((u>0&&n===DIRECTIONS.Te&&t.scrollTop===t.scrollHeight-t.offsetHeight||u<0&&n===DIRECTIONS.$e&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i} |
@@ -1,1 +0,1 @@ | ||
export const KeyCodes={fo:32,oo:9,co:13,Ri:27}; | ||
export const KeyCodes={fo:32,oo:9,co:13,Pi:27}; |
@@ -1,1 +0,1 @@ | ||
import r from"../../shared-lib/braze-shared-lib.js";import Rt from"../models/backend-errors.js";const b={Fs:e=>{let t,o,n=!1;try{if(window.XMLHttpRequest&&(t=new XMLHttpRequest)&&void 0!==t.withCredentials||("undefined"!=typeof XDomainRequest?(t=new XDomainRequest,t.async=!0,n=!0):r.D.error("This browser does not have any supported ajax options!")),null!=t){const s=()=>{"function"==typeof e.error&&e.error(t.status),"function"==typeof e.fl&&e.fl(!1)};if(t.onload=()=>{let o=!1;if(n)o=!0;else{if(4!==t.readyState)return;o=t.status>=200&&t.status<300||304===t.status}if(o){if("function"==typeof e.S){let o;try{o=JSON.parse(t.responseText)}catch(o){const n={error:""===t.responseText?Rt.oa:Rt.ua,response:t.responseText};e.S(n)}o&&e.S(o)}"function"==typeof e.fl&&e.fl(!0)}else s()},t.onerror=()=>{s()},t.ontimeout=()=>{s()},o=JSON.stringify(e.data),n)t.onprogress=()=>{},t.open("post",e.url);else{t.open("POST",e.url,!0),t.setRequestHeader("Content-type","application/json"),t.setRequestHeader("X-Requested-With","XMLHttpRequest");const o=e.headers||[];for(let e=0;e<o.length;e++)t.setRequestHeader(o[e][0],o[e][1])}t.send(o)}}catch(e){r.D.error(`Network request error: ${e.message}`)}}};export default b; | ||
import r from"../../shared-lib/braze-shared-lib.js";import Rt from"../models/backend-errors.js";const b={Ms:e=>{let t,o,n=!1;try{if(window.XMLHttpRequest&&(t=new XMLHttpRequest)&&void 0!==t.withCredentials||("undefined"!=typeof XDomainRequest?(t=new XDomainRequest,t.async=!0,n=!0):r.D.error("This browser does not have any supported ajax options!")),null!=t){const s=()=>{"function"==typeof e.error&&e.error(t.status),"function"==typeof e.kl&&e.kl(!1)};if(t.onload=()=>{let o=!1;if(n)o=!0;else{if(4!==t.readyState)return;o=t.status>=200&&t.status<300||304===t.status}if(o){if("function"==typeof e.S){let o;try{o=JSON.parse(t.responseText)}catch(o){const n={error:""===t.responseText?Rt.la:Rt.ma,response:t.responseText};e.S(n)}o&&e.S(o)}"function"==typeof e.kl&&e.kl(!0)}else s()},t.onerror=()=>{s()},t.ontimeout=()=>{s()},o=JSON.stringify(e.data),n)t.onprogress=()=>{},t.open("post",e.url);else{t.open("POST",e.url,!0),t.setRequestHeader("Content-type","application/json"),t.setRequestHeader("X-Requested-With","XMLHttpRequest");const o=e.headers||[];for(let e=0;e<o.length;e++)t.setRequestHeader(o[e][0],o[e][1])}t.send(o)}}catch(e){r.D.error(`Network request error: ${e.message}`)}}};export default b; |
@@ -1,1 +0,1 @@ | ||
import Yt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Yt{constructor(){super(),this.eu=ni.nu(navigator.userAgent||"")}tf(){return this.eu[0]||"Unknown Browser"}ef(){return this.eu[1]||"Unknown Version"}Ko(r){for(let e=0;e<r.length;e++){let n=r[e].string,i=ni.rf(n,r[e]);if(i)return i===ot.Bg&&navigator.maxTouchPoints>1&&(i=ot.ln),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static nu(r){let e,n=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(/trident/i.test(n[1]))return e=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[ri.vg,e[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(n[1]===ri.rE&&(e=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("OPR",ri.EE),e[0]=e[0].replace("EdgA",ri.eE),"Edg"===e[0]&&(e[0]=ri.eE),[e[0],e[1]];if(n[1]===ri.yg&&(e=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("EdgiOS",ri.eE),[e[0],e[1]];if(n=n[2]?[n[1],n[2]]:[null,null],n[0]===ri.yg&&null!=(e=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&n.splice(1,1,e[1]),null!=(e=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&n.splice(1,1,e[2]),n[0]===ri.EE&&null!=(e=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",e[1]||""];if(n[0]){const r=n[0].toLowerCase();"msie"===r&&(n[0]=ri.vg),"crios"===r&&(n[0]=ri.rE),"tizen"===r&&(n[0]="Samsung Smart TV",n[1]=null),"samsungbrowser"===r&&(n[0]="Samsung Browser")}return n}} | ||
import Yt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Yt{constructor(){super(),this.eu=ni.ou(navigator.userAgent||"")}tf(){return this.eu[0]||"Unknown Browser"}ef(){return this.eu[1]||"Unknown Version"}Zo(r){for(let e=0;e<r.length;e++){let n=r[e].string,i=ni.rf(n,r[e]);if(i)return i===ot.Bg&&navigator.maxTouchPoints>1&&(i=ot.ln),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static ou(r){let e,n=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(/trident/i.test(n[1]))return e=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[ri.vg,e[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(n[1]===ri.rE&&(e=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("OPR",ri.EE),e[0]=e[0].replace("EdgA",ri.eE),"Edg"===e[0]&&(e[0]=ri.eE),[e[0],e[1]];if(n[1]===ri.yg&&(e=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("EdgiOS",ri.eE),[e[0],e[1]];if(n=n[2]?[n[1],n[2]]:[null,null],n[0]===ri.yg&&null!=(e=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&n.splice(1,1,e[1]),null!=(e=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&n.splice(1,1,e[2]),n[0]===ri.EE&&null!=(e=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",e[1]||""];if(n[0]){const r=n[0].toLowerCase();"msie"===r&&(n[0]=ri.vg),"crios"===r&&(n[0]=ri.rE),"tizen"===r&&(n[0]="Samsung Smart TV",n[1]=null),"samsungbrowser"===r&&(n[0]="Samsung Browser")}return n}} |
@@ -1,1 +0,1 @@ | ||
export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,kn:_getCurrentUrl}; | ||
export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,Nn:_getCurrentUrl}; |
Sorry, the diff of this file is too big to display
339444
169
2041