@braze/web-sdk
Advanced tools
Comparing version 4.2.1 to 4.3.0
{ | ||
"name": "@braze/web-sdk", | ||
"version": "4.2.1", | ||
"version": "4.3.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={bn:je,A:ve,qr:De,it:Be,qt:Ae,xt:Ae.ep,D:Ge,zo: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={bn:je,A:ve,qr:De,it:Be,qt:Ae,xt:Ae.ep,D:Ge,Uo:Oe};export default r; |
@@ -1,1 +0,1 @@ | ||
const ve={CustomEvent:"ce",Pr:"p",Sl:"pc",oc:"ca",Ra:"i",qs:"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",En:"inc",An:"add",Un:"rem",Sn:"set",Cl:"sgu"},De={Fr:"feed_displayed",ac:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes}; | ||
const ve={CustomEvent:"ce",Pr:"p",Kl:"pc",oc:"ca",Ra:"i",qs:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",ph:"ss",nh:"se",Je:"si",Re:"sc",He:"sbc",Pe:"sfe",ro:"iec",xl:"lr",Ul:"uae",U:"ci",F:"cc",Gl:"lcaa",Bl:"lcar",En:"inc",An:"add",Un:"rem",Sn:"set",Jl:"sgu"},De={Fr:"feed_displayed",ac:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes}; |
@@ -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.$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:{jl:"data",jr:"pushClicks",pu:"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:{Wl:"data",jr:"pushClicks",pu:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",Kn:"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.2.1)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.2.1)";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.3.0)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.3.0)";null!=Ge.nd?Ge.nd(o):console.error(o)}}};export default Ge; |
@@ -1,1 +0,1 @@ | ||
import{attachInAppMessageCSS as nt}from"../../ui/js/iam-css.js";import et from"../../util/browser-detector.js";import{logInAppMessageHtmlClick}from"../log-in-app-message-html-click.js";import{getUser as Q}from"../../Core/get-user.js";import{InAppMessage}from"../index.js";import{keys as rr}from"../../util/code-utils.js";import{OperatingSystems as ot}from"../../util/device-constants.js";import{parseQueryStringKeyValues as st}from"../../util/url-utils.js";import{WindowUtils as H}from"../../util/window-utils.js";export default function rt(t,n,e,o,s,r){const i=document.createElement("iframe");i.setAttribute("title","Modal Message"),s&&(i.style.zIndex=s+1);const u=n=>{const e=n.getAttribute("href"),s=n.onclick;return r=>{if(null!=s&&"function"==typeof s&&!1===s())return;let u=st(e).abButtonId;if(null!=u&&""!==u||(u=n.getAttribute("id")),null!=e&&""!==e&&0!==e.indexOf("#")){const s="blank"===(n.getAttribute("target")||"").toLowerCase().replace("_",""),c=o||t.openTarget===InAppMessage.OpenTarget.BLANK||s,a=()=>{logInAppMessageHtmlClick(t,u,e),H.openUri(e,c,r)};c?a():t.on(i,a)}else logInAppMessageHtmlClick(t,u,e);return r.stopPropagation(),!1}},c=(t,n,e)=>{const o=`([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,s=t.match(new RegExp(o));if(s){const e=`${s[1]}.setAttribute("nonce", "${n}")`;return`${t.slice(0,s.index+s[0].length)};${e};${t.slice(s.index+s[0].length)}`}return null};if(i.onload=()=>{let o=null;if(null!=r){o=document.createElement("html"),o.innerHTML=t.message;const n=o.getElementsByTagName("style");for(let t=0;t<n.length;t++)n[t].setAttribute("nonce",r);const e=o.getElementsByTagName("script");for(let t=0;t<e.length;t++){e[t].setAttribute("nonce",r),e[t].innerHTML=e[t].innerHTML.replace(/<style>/g,`<style nonce='${r}'>`);const n=c(e[t].innerHTML,r,"script");n&&(e[t].innerHTML=n);const o=c(e[t].innerHTML,r,"style");o&&(e[t].innerHTML=o)}}i.contentWindow.focus(),i.contentWindow.document.write(o?o.innerHTML:t.message);const s=i.contentWindow.document.getElementsByTagName("head")[0];if(null!=s){if(nt(s),t.sn()){const n=document.createElement("style");n.innerHTML=t.css,n.id=t.rn(),null!=r&&n.setAttribute("nonce",r),s.appendChild(n)}const n=i.contentWindow.document.createElement("base");n.setAttribute("target","_parent"),s.appendChild(n)}const a=i.contentWindow.document.getElementsByTagName("title");a.length>0&&i.setAttribute("title",a[0].textContent);const l={closeMessage:function(){t.on(i)},logClick:function(){const n=[t,...arguments];logInAppMessageHtmlClick.apply(t,Array.prototype.slice.call(n))},display:{},web:{}},requestPushPermission=function(){return function(){const t=arguments;import("../../Push/request-push-permission.js").then((n=>{n.requestPushPermission.apply(null,Array.prototype.slice.call(t))}))}},m={requestImmediateDataFlush:async function(){const t=arguments,n=await import("../../Core/request-immediate-data-flush.js");n.requestImmediateDataFlush.apply(null,Array.prototype.slice.call(t))},logCustomEvent:async function(){const t=arguments,n=await import("../../Core/log-custom-event.js");n.logCustomEvent.apply(null,Array.prototype.slice.call(t))},logPurchase:async function(){const t=arguments,n=await import("../../Core/log-purchase.js");n.logPurchase.apply(null,Array.prototype.slice.call(t))},unregisterPush:async function(){const t=arguments,n=await import("../../Push/unregister-push.js");n.unregisterPush.apply(null,Array.prototype.slice.call(t))},requestPushPermission:requestPushPermission()},f=function(t){return function(){m[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of rr(m))l[t]=f(t);const p=["setFirstName","setLastName","setEmail","setGender","setDateOfBirth","setCountry","setHomeCity","setEmailNotificationSubscriptionType","setLanguage","addAlias","setPushNotificationSubscriptionType","setPhoneNumber","setCustomUserAttribute","addToCustomAttributeArray","removeFromCustomAttributeArray","incrementCustomUserAttribute","setCustomLocationAttribute","addToSubscriptionGroup","removeFromSubscriptionGroup"],d=function(t){return function(){const n=Q();n[t].apply(n,Array.prototype.slice.call(arguments))}},y={};for(let t=0;t<p.length;t++)y[p[t]]=d(p[t]);l.getUser=function(){return y};const b={showFeed:n},g=function(n){return function(){const e=arguments;t.on(i,(function(){b[n].apply(null,Array.prototype.slice.call(e))}))}};for(const t of rr(b))l.display[t]=g(t);const h={registerAppboyPushMessages:requestPushPermission()},A=function(t){return function(){h[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of rr(h))l.web[t]=A(t);if(i.contentWindow.appboyBridge=l,i.contentWindow.brazeBridge=l,t.un!==InAppMessage.es.cn){const t=i.contentWindow.document.getElementsByTagName("a");for(let n=0;n<t.length;n++)t[n].onclick=u(t[n]);const n=i.contentWindow.document.getElementsByTagName("button");for(let t=0;t<n.length;t++)n[t].onclick=u(n[t])}const j=i.contentWindow.document.body;if(null!=j){t.an()&&(j.id=t.htmlId);const n=document.createElement("hidden");n.onclick=l.closeMessage,n.className="ab-programmatic-close-button",j.appendChild(n)}i.contentWindow.dispatchEvent(new CustomEvent("ab.BridgeReady")),-1!==i.className.indexOf("ab-start-hidden")&&(i.className=i.className.replace("ab-start-hidden",""),e(i)),document.activeElement!==i&&i.focus()},i.className="ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions",et.OS===ot.ln){const n=document.createElement("div");return n.className="ab-ios-scroll-wrapper",n.appendChild(i),t.mn=n,n}return t.mn=i,i} | ||
import{attachInAppMessageCSS as nt}from"../../ui/js/iam-css.js";import et from"../../util/browser-detector.js";import{logInAppMessageHtmlClick}from"../log-in-app-message-html-click.js";import{getUser as Q}from"../../Core/get-user.js";import{InAppMessage}from"../index.js";import{keys as rr}from"../../util/code-utils.js";import{OperatingSystems as ot}from"../../util/device-constants.js";import{parseQueryStringKeyValues as st}from"../../util/url-utils.js";import{WindowUtils as H}from"../../util/window-utils.js";export default function rt(t,n,e,o,s,r){const i=document.createElement("iframe");i.setAttribute("title","Modal Message"),s&&(i.style.zIndex=s+1);const u=n=>{const e=n.getAttribute("href"),s=n.onclick;return r=>{if(null!=s&&"function"==typeof s&&!1===s())return;let u=st(e).abButtonId;if(null!=u&&""!==u||(u=n.getAttribute("id")),null!=e&&""!==e&&0!==e.indexOf("#")){const s="blank"===(n.getAttribute("target")||"").toLowerCase().replace("_",""),c=o||t.openTarget===InAppMessage.OpenTarget.BLANK||s,a=()=>{logInAppMessageHtmlClick(t,u,e),H.openUri(e,c,r)};c?a():t.on(i,a)}else logInAppMessageHtmlClick(t,u,e);return r.stopPropagation(),!1}},c=(t,n,e)=>{const o=`([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,s=t.match(new RegExp(o));if(s){const e=`${s[1]}.setAttribute("nonce", "${n}")`;return`${t.slice(0,s.index+s[0].length)};${e};${t.slice(s.index+s[0].length)}`}return null};if(i.onload=()=>{let o=null;if(null!=r){o=document.createElement("html"),o.innerHTML=t.message;const n=o.getElementsByTagName("style");for(let t=0;t<n.length;t++)n[t].setAttribute("nonce",r);const e=o.getElementsByTagName("script");for(let t=0;t<e.length;t++){e[t].setAttribute("nonce",r),e[t].innerHTML=e[t].innerHTML.replace(/<style>/g,`<style nonce='${r}'>`);const n=c(e[t].innerHTML,r,"script");n&&(e[t].innerHTML=n);const o=c(e[t].innerHTML,r,"style");o&&(e[t].innerHTML=o)}}i.contentWindow.focus(),i.contentWindow.document.write(o?o.innerHTML:t.message);const s=i.contentWindow.document.getElementsByTagName("head")[0];if(null!=s){if(nt(s),t.sn()){const n=document.createElement("style");n.innerHTML=t.css,n.id=t.rn(),null!=r&&n.setAttribute("nonce",r),s.appendChild(n)}const n=i.contentWindow.document.createElement("base");n.setAttribute("target","_parent"),s.appendChild(n)}const a=i.contentWindow.document.getElementsByTagName("title");a.length>0&&i.setAttribute("title",a[0].textContent);const l={closeMessage:function(){t.on(i)},logClick:function(){const n=[t,...arguments];logInAppMessageHtmlClick.apply(t,Array.prototype.slice.call(n))},display:{},web:{}},requestPushPermission=function(){return function(){const t=arguments;import("../../Push/request-push-permission.js").then((n=>{n.requestPushPermission.apply(null,Array.prototype.slice.call(t))}))}},m={requestImmediateDataFlush:async function(){const t=arguments,n=await import("../../Core/request-immediate-data-flush.js");n.requestImmediateDataFlush.apply(null,Array.prototype.slice.call(t))},logCustomEvent:async function(){const t=arguments,n=await import("../../Core/log-custom-event.js");n.logCustomEvent.apply(null,Array.prototype.slice.call(t))},logPurchase:async function(){const t=arguments,n=await import("../../Core/log-purchase.js");n.logPurchase.apply(null,Array.prototype.slice.call(t))},unregisterPush:async function(){const t=arguments,n=await import("../../Push/unregister-push.js");n.unregisterPush.apply(null,Array.prototype.slice.call(t))},requestPushPermission:requestPushPermission(),changeUser:async function(){const t=arguments,n=await import("../../Core/change-user.js");n.changeUser.apply(null,Array.prototype.slice.call(t))}},f=function(t){return function(){m[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of rr(m))l[t]=f(t);const p=["setFirstName","setLastName","setEmail","setGender","setDateOfBirth","setCountry","setHomeCity","setEmailNotificationSubscriptionType","setLanguage","addAlias","setPushNotificationSubscriptionType","setPhoneNumber","setCustomUserAttribute","addToCustomAttributeArray","removeFromCustomAttributeArray","incrementCustomUserAttribute","setCustomLocationAttribute","addToSubscriptionGroup","removeFromSubscriptionGroup"],d=function(t){return function(){const n=Q();n[t].apply(n,Array.prototype.slice.call(arguments))}},y={};for(let t=0;t<p.length;t++)y[p[t]]=d(p[t]);l.getUser=function(){return y};const b={showFeed:n},g=function(n){return function(){const e=arguments;t.on(i,(function(){b[n].apply(null,Array.prototype.slice.call(e))}))}};for(const t of rr(b))l.display[t]=g(t);const h={registerAppboyPushMessages:requestPushPermission()},A=function(t){return function(){h[t].apply(null,Array.prototype.slice.call(arguments))}};for(const t of rr(h))l.web[t]=A(t);if(i.contentWindow.appboyBridge=l,i.contentWindow.brazeBridge=l,t.un!==InAppMessage.es.cn){const t=i.contentWindow.document.getElementsByTagName("a");for(let n=0;n<t.length;n++)t[n].onclick=u(t[n]);const n=i.contentWindow.document.getElementsByTagName("button");for(let t=0;t<n.length;t++)n[t].onclick=u(n[t])}const j=i.contentWindow.document.body;if(null!=j){t.an()&&(j.id=t.htmlId);const n=document.createElement("hidden");n.onclick=l.closeMessage,n.className="ab-programmatic-close-button",j.appendChild(n)}i.contentWindow.dispatchEvent(new CustomEvent("ab.BridgeReady")),-1!==i.className.indexOf("ab-start-hidden")&&(i.className=i.className.replace("ab-start-hidden",""),e(i)),document.activeElement!==i&&i.focus()},i.className="ab-in-app-message ab-start-hidden ab-html-message ab-modal-interactions",et.OS===ot.ln){const n=document.createElement("div");return n.className="ab-ios-scroll-wrapper",n.appendChild(i),t.mn=n,n}return t.mn=i,i} |
@@ -1,1 +0,1 @@ | ||
import St from"./auth-manager.js";import y 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 rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import{logDeprecationWarning as D}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Ot from"../request-controller.js";import Ct from"./server-config-manager.js";import Lt from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import G,{STORAGE_KEYS as o}from"./storage-manager.js";import Pt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as W}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 H}from"../util/window-utils.js";const T={Rn:"allowCrawlerActivity",Wn:"baseUrl",Vn:"noCookies",Yn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Xn:"enableLogging",Zn:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",ho:"minimumIntervalBetweenTriggerActionsInSeconds",po:"sessionTimeoutInSeconds",Eo:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",jn:"localization",ao:"contentSecurityNonce",_o:"enableHtmlInAppMessages",Io:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Ui:"requireExplicitInAppMessageDismissal",Ao:"doNotLoadFontAwesome",So:"sdkFlavor"};class Rt{constructor(){this.No=!1,this.wo=!1,this.To=new u,this.Oo=new u,this.vo={},this.Co=[],this.Lo=[],this.De=[],this.Po="4.2.1"}Ro(t){this.To.ut(t)}Bi(t){this.Oo.ut(t)}initialize(t,i){if(this.Mo())return r.D.info("Braze has already been initialized with an API key."),!0;this.vo=i||{};let s=this.nn(T.Xn);const e=st(H.hn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.vo,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(T.Wn);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.yo=n,et.Do&&!this.nn(T.Rn))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.wo=!0,!1;const a=this.nn(Rt.Vn)||!1;if(this.h=Pt.jo(t,a),new G.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.wo=!0,!1;for(const t of rr(this.vo))-1===At(r.zo).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(T.So)){const t=this.nn(T.So);-1!==h.indexOf(t)?this.Uo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.zo.Yn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)F(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.gt=new Ct(this.h),this.v=new bt(this.gt,this.h),this.j=new Lt(this.h,this.v,this.gt,this.nn(T.po));const c=new u;return this.Bo=new St(this.h,this.nn(T.Zn),c),this.jt(c),this.vt=new wt(this.Qi,this.h,this.Bo,this.v,this.j,this.gt,this.Ji,this.yo,this.Po,this.Uo,this.nn(T.Eo)),this.si=new Ot(this.Ji,this.yo,this.j,this.Qi,this.v,this.gt,this.h,(t=>{if(this.Mo())for(const i of this.re())i.Rs(t)}),this.Bo,this.vt),this.si.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(T.Wn)}" with API key "${this.Ji}".`),null!=this.nn(T._o)&&D("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),W.init(),this.To.St(this.vo),this.No=!0,!0}destroy(t){if(r.D.destroy(),this.Mo()){this.Oo.St(),this.Oo.removeAllSubscriptions();for(const t of this.Co)t.destroy();this.Co=[];for(const t of this.Lo)t.clearData(!1);this.Lo=[],this.removeAllSubscriptions(),this.De=[],this.si.destroy(),this.si=null,this.Bo=null,this.Qi=null,this.vt=null,this.gt=null,this.j=null,this.v=null,this.vo={},this.Uo=void 0,this.No=!1,this.wo=!1,t&&(this.h=null)}}rr(){if(this.Wo())return!1;if(!this.Mo())throw new Error("Braze must be initialized before calling methods.");return!0}ea(){return this.Ji}ii(){return this.Bo}Ks(){return this.yo}ce(){return this.Qi}nr(){return this.vt}nn(t){return this.vo[t]}re(){return this.Lo}mr(){return this.si}ir(){return this.gt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.si)return new User(this.v,this.si)}p(){return this.v}tr(){return!0===this.nn(T.Io)||!0===this.nn(T._o)}u(t){let i=!1;for(const s of this.Co)s===t&&(i=!0);i||this.Co.push(t)}ar(t){let i=!1;for(const s of this.Lo)s.constructor===t.constructor&&(i=!0);t instanceof y&&!i&&this.Lo.push(t)}jt(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.wo=t}Mo(){return this.No}Wo(){return this.wo}Ds(){return this.Po}}const e=new Rt;export{e as default,Rt as BrazeSdkInstance,T as OPTIONS}; | ||
import St from"./auth-manager.js";import y 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 rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import{logDeprecationWarning as D}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Ot from"../request-controller.js";import Ct from"./server-config-manager.js";import Lt from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import G,{STORAGE_KEYS as o}from"./storage-manager.js";import Pt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as W}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 H}from"../util/window-utils.js";const T={Rn:"allowCrawlerActivity",Wn:"baseUrl",Vn:"noCookies",Yn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Xn:"enableLogging",Zn:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",ho:"minimumIntervalBetweenTriggerActionsInSeconds",po:"sessionTimeoutInSeconds",Eo:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",jn:"localization",ao:"contentSecurityNonce",_o:"enableHtmlInAppMessages",Io:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Ui:"requireExplicitInAppMessageDismissal",Ao:"doNotLoadFontAwesome",So:"sdkFlavor"};class Rt{constructor(){this.No=!1,this.wo=!1,this.To=new u,this.Oo=new u,this.vo={},this.Co=[],this.Lo=[],this.De=[],this.Po="4.3.0"}Ro(t){this.To.ut(t)}Bi(t){this.Oo.ut(t)}initialize(t,i){if(this.Mo())return r.D.info("Braze has already been initialized with an API key."),!0;this.vo=i||{};let s=this.nn(T.Xn);const e=st(H.hn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.vo,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(T.Wn);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;!1===/^https?:/.test(n)&&(n=`https://${n}`);let a=n;if(n=document.createElement("a"),n.href=a,"/"===n.pathname&&(n=`${n}api/v3`),this.yo=n.toString(),et.Do&&!this.nn(T.Rn))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.wo=!0,!1;const h=this.nn(Rt.Vn)||!1;if(this.h=Pt.jo(t,h),new G.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.wo=!0,!1;for(const t of rr(this.vo))-1===At(r.Uo).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const l=["mparticle","wordpress","tealium"];if(null!=this.nn(T.So)){const t=this.nn(T.So);-1!==l.indexOf(t)?this.zo=t:r.D.error("Invalid sdk flavor passed: "+t)}let c=this.nn(r.Uo.Yn);if(null!=c)if(p(c)){const t=[];for(let i=0;i<c.length;i++)F(DeviceProperties,c[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(c[i]);c=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),c=null;this.Qi=new It(this.h,c),this.gt=new Ct(this.h),this.v=new bt(this.gt,this.h),this.j=new Lt(this.h,this.v,this.gt,this.nn(T.po));const m=new u;return this.Bo=new St(this.h,this.nn(T.Zn),m),this.jt(m),this.vt=new wt(this.Qi,this.h,this.Bo,this.v,this.j,this.gt,this.Ji,this.yo,this.Po,this.zo,this.nn(T.Eo)),this.si=new Ot(this.Ji,this.yo,this.j,this.Qi,this.v,this.gt,this.h,(t=>{if(this.Mo())for(const i of this.re())i.Rs(t)}),this.Bo,this.vt),this.si.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(T.Wn)}" with API key "${this.Ji}".`),null!=this.nn(T._o)&&D("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),W.init(),this.To.St(this.vo),this.No=!0,!0}destroy(t){if(r.D.destroy(),this.Mo()){this.Oo.St(),this.Oo.removeAllSubscriptions();for(const t of this.Co)t.destroy();this.Co=[];for(const t of this.Lo)t.clearData(!1);this.Lo=[],this.removeAllSubscriptions(),this.De=[],this.si.destroy(),this.si=null,this.Bo=null,this.Qi=null,this.vt=null,this.gt=null,this.j=null,this.v=null,this.vo={},this.zo=void 0,this.No=!1,this.wo=!1,t&&(this.h=null)}}rr(){if(this.Wo())return!1;if(!this.Mo())throw new Error("Braze must be initialized before calling methods.");return!0}ea(){return this.Ji}ii(){return this.Bo}Ks(){return this.yo}ce(){return this.Qi}nr(){return this.vt}nn(t){return this.vo[t]}re(){return this.Lo}mr(){return this.si}ir(){return this.gt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.si)return new User(this.v,this.si)}p(){return this.v}tr(){return!0===this.nn(T.Io)||!0===this.nn(T._o)}u(t){let i=!1;for(const s of this.Co)s===t&&(i=!0);i||this.Co.push(t)}ar(t){let i=!1;for(const s of this.Lo)s.constructor===t.constructor&&(i=!0);t instanceof y&&!i&&this.Lo.push(t)}jt(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.wo=t}Mo(){return this.No}Wo(){return this.wo}Ds(){return this.Po}}const e=new Rt;export{e as default,Rt as BrazeSdkInstance,T as OPTIONS}; |
@@ -1,1 +0,1 @@ | ||
import qt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as Dt}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.Bo=s,this.v=i,this.j=r,this.gt=o,this.Ji=n,this.yo=a,this.Po=h,this.Uo=u,this.Xo=c,this.$o=["npm"]}Ps(t,e){const s=this.Qi.te(),i=s.li(),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.Vo())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Po,this.Uo&&(t.sdk_flavor=this.Uo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}Os(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Bo.Pn();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.Bo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.sa(t.events,t.attributes),this.Bo.Mn(s),!1}if(n){let i=n;switch(i){case qt.oa:const o="Received successful response with empty body.";return s.G(r.A.qs,{e:o}),r.D.info(o),!1;case qt.ha:const n="Received successful response with invalid JSON";return s.G(r.A.qs,{e:n+": "+e.response}),r.D.info(n),!1;case qt.ua:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.yo}`;break;case qt.ca:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case qt.la:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}fa(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}ma(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.ni(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.li(),this.Bo.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.Bo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.sa(h,u),l=this.Ps(l,!0),c){c=this.Ps(c,!1);const t={requestData:c,headers:this.Bs(c)};r.push(t)}if(l&&!this.fa(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Bs(l)};return r.push(f),r}sa(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=Dt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.pa(t)}Vs(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})}ni(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.gt.Zs()},{respond_with:i}}Bs(t,e,s){const i=[["X-Braze-Api-Key",this.Ji]];let r=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(i.push(["X-Braze-TriggersRequest","true"]),r=!0),null!=t.respond_with&&t.respond_with.feed&&(i.push(["X-Braze-FeedRequest","true"]),r=!0),e){i.push(["X-Braze-ContentCardsRequest","true"]);let t=this.h.I(o.q.As);t&&s||(t=0,this.h.B(o.q.As,t)),i.push(["BRAZE-SYNC-RETRY-COUNT",t.toString()]),r=!0}if(r&&i.push(["X-Braze-DataRequest","true"]),this.Bo.Gn()){const t=this.Bo.Hn();null!=t&&i.push(["X-Braze-Auth-Signature",t])}return i}Gs(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Qs(){this.Bo.Qs()}Ks(){return this.yo}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.push(e)}} | ||
import qt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as Dt}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.Bo=s,this.v=i,this.j=r,this.gt=o,this.Ji=n,this.yo=a,this.Po=h,this.zo=u,this.Xo=c,this.$o=["npm"]}Ps(t,e){const s=this.Qi.te(),i=s.li(),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.Vo())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Po,this.zo&&(t.sdk_flavor=this.zo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}Os(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Bo.Pn();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.Bo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.sa(t.events,t.attributes),this.Bo.Mn(s),!1}if(n){let i=n;switch(i){case qt.oa:const o="Received successful response with empty body.";return s.G(r.A.qs,{e:o}),r.D.info(o),!1;case qt.ha:const n="Received successful response with invalid JSON";return s.G(r.A.qs,{e:n+": "+e.response}),r.D.info(n),!1;case qt.ua:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.yo}`;break;case qt.ca:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case qt.la:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}fa(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}ma(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.ni(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.li(),this.Bo.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.Bo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.sa(h,u),l=this.Ps(l,!0),c){c=this.Ps(c,!1);const t={requestData:c,headers:this.Bs(c)};r.push(t)}if(l&&!this.fa(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Bs(l)};return r.push(f),r}sa(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=Dt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.pa(t)}Vs(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})}ni(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.gt.Zs()},{respond_with:i}}Bs(t,e,s){const i=[["X-Braze-Api-Key",this.Ji]];let r=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(i.push(["X-Braze-TriggersRequest","true"]),r=!0),null!=t.respond_with&&t.respond_with.feed&&(i.push(["X-Braze-FeedRequest","true"]),r=!0),e){i.push(["X-Braze-ContentCardsRequest","true"]);let t=this.h.I(o.q.As);t&&s||(t=0,this.h.B(o.q.As,t)),i.push(["BRAZE-SYNC-RETRY-COUNT",t.toString()]),r=!0}if(r&&i.push(["X-Braze-DataRequest","true"]),this.Bo.Gn()){const t=this.Bo.Hn();null!=t&&i.push(["X-Braze-Auth-Signature",t])}return i}Gs(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Qs(){this.Bo.Qs()}Ks(){return this.yo}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.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 Ct{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.yn(t):new jt}return this.ih}Zs(){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.fn()!==t.oh&&(e=!0);let i=!1;null!=t.uh.enabled&&this.Ys()!==t.uh.enabled&&(i=!0),this.ih=t,this.h.B(o.q.nh,t.ss()),e&&this.sh.St(),i&&this.eh.St()}}}dn(t){let s=this.sh.ut(t);return this.ah&&this.sh.removeSubscription(this.ah),this.ah=s,s}Ms(t){return this.eh.ut(t)}ge(t){return-1!==this.rh().gh.indexOf(t)}hu(t){return-1!==this.rh().mh.indexOf(t)}Dr(t){return-1!==this.rh().fh.indexOf(t)}dh(){return this.rh().ph}fn(){return this.rh().oh}Ys(){return this.rh().uh.enabled||!1}} | ||
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import Ft from"../models/server-config.js";import s from"../common/event-logger.js";import r from"../../shared-lib/braze-shared-lib.js";export default class Ct{constructor(t){this.h=t,this.tl=new u,this.sl=new u,this.il=new u,this.rl=null}hl(){if(null==this.rl){const t=this.h.I(o.q.ol);this.rl=null!=t?Ft.yn(t):new Ft}return this.rl}Zs(){return this.hl().ul}al(t){if(null!=t&&null!=t.config){const e=t.config;if(e.time>this.hl().ul){const t=new Ft(e.time,e.events_blacklist,e.attributes_blacklist,e.purchases_blacklist,e.messaging_session_timeout,e.vapid_public_key,e.content_cards,e.feature_flags);let s=!1;null!=t.gl&&this.fn()!==t.gl&&(s=!0);let i=!1;null!=t.ml.enabled&&this.Ys()!==t.ml.enabled&&(i=!0);let r=!1;null!=t.cl.enabled&&this.fl()!==t.cl.enabled&&(r=!0),this.rl=t,this.h.B(o.q.ol,t.ss()),s&&this.tl.St(),i&&this.sl.St(),r&&this.il.St()}}}dn(t){let e=this.tl.ut(t);return this.bl&&this.tl.removeSubscription(this.bl),this.bl=e,e}Ms(t){return this.sl.ut(t)}dl(t){return this.il.ut(t)}ge(t){return-1!==this.hl().vl.indexOf(t)}hu(t){return-1!==this.hl().wl.indexOf(t)}Dr(t){return-1!==this.hl().Cl.indexOf(t)}Fl(){return this.hl().jl}fn(){return this.hl().gl}Ys(){return this.hl().ml.enabled||!1}fl(){return this.hl().cl.enabled&&null==this.Tl()?(s.G(r.A.qs,{e:"Missing feature flag refresh_rate_limit."}),!1):this.hl().cl.enabled||!1}Tl(){return this.hl().cl.El}} |
@@ -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 Lt{constructor(s,t,e,i){this.h=s,this.v=t,this.gt=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.eu,{d:l(s-t.xh)})}Vo(){const s=this.h.tu(o.iu.Dh);return null==s?null:s.eu}Eh(){const s=(new Date).valueOf(),t=this.gt.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.tu(o.iu.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.eu)),this.h.ru(o.iu.Dh,n);return null==this.h.I(o.q.Ch)&&this.h.B(o.q.Ch,s),n.eu}return e._h=s,e.Nh=t,this.h.ru(o.iu.Dh,e),e.eu}kh(){const s=this.h.tu(o.iu.Dh);null!=s&&(this.h.qh(o.iu.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 Lt{constructor(s,t,e,i){this.h=s,this.v=t,this.gt=e,this.sh=1e3,i=parseFloat(i),isNaN(i)&&(i=1800),i<this.sh/1e3&&(r.D.info("Specified session timeout of "+i+"s is too small, using the minimum session timeout of "+this.sh/1e3+"s instead."),i=this.sh/1e3),this.eh=i}ih(s,t){return new ue(this.v.getUserId(),r.A.nh,s,t.eu,{d:l(s-t.rh)})}Vo(){const s=this.h.tu(o.iu.oh);return null==s?null:s.eu}hh(){const s=(new Date).valueOf(),t=this.gt.Fl(),e=this.h.I(o.q.lh);if(null!=e&&null==t)return!1;const i=null==e||s-e>1e3*t;return i&&this.h.B(o.q.lh,s),i}uh(s,t){return null==t||!(s-t.rh<this.sh)&&t.ah<s}mo(){const s=(new Date).valueOf(),t=s+1e3*this.eh,e=this.h.tu(o.iu.oh);if(this.uh(s,e)){let i="Generating session start event with time "+s;if(null!=e){let s=e.mh;s-e.rh<this.sh&&(s=e.rh+this.dh),this.h.fh(this.ih(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.fh(new ue(this.v.getUserId(),r.A.ph,s,n.eu)),this.h.ru(o.iu.oh,n);return null==this.h.I(o.q.lh)&&this.h.B(o.q.lh,s),n.eu}return e.mh=s,e.ah=t,this.h.ru(o.iu.oh,e),e.eu}gh(){const s=this.h.tu(o.iu.oh);null!=s&&(this.h.wh(o.iu.oh),this.h.fh(this.ih((new Date).valueOf(),s)))}} |
@@ -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 rr,validateValueIsFromEnum as F,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={iu:{su:"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",gn:"ab.storage.pushToken",ei:"ab.storage.newsFeed",hi:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",ba:"ab.storage.triggers",Ia:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Yt:"ab.storage.cc",vs:"ab.storage.ccLastFullSync",ys:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ka:"ab.storage.lastDisplayedTriggerTimesById",Ya:"ab.storage.lastDisplayedTriggerTime",Da:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature",As:"ab.storage.brazeSyncRetryCount",_s:"ab.storage.sdkVersion"},ae:"ab.optOut"};export default class G{constructor(t,e){this.Ga=t,this.Na=e}ru(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.Ga.store(t,s)}va(t){const e=this.tu(t);null!=e&&(e._h=(new Date).valueOf(),this.ru(t,e))}tu(t){return _t.yn(this.Ga.lr(t))}qh(t){this.Ga.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.Ma(t[s])?e.push(ue.yn(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.qs,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}Xs(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=rr(STORAGE_KEYS.iu),e=rr(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ga.remove(STORAGE_KEYS.iu[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}ya(t){return t||STORAGE_KEYS.q.Oa}pa(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.ya(t[User._n]);for(let r in t)r===User._n||null!=e[s]&&null!=e[s][r]||this.mu(t[User._n],r,t[r])}mu(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.ya(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User._n]=t)),e===User.lu){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)}Ua(){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}ou(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.ya(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User._n]=t,this.pa(r))}const s=this.tu(STORAGE_KEYS.iu.Dh);let r=null;null!=s&&(r=s.eu);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)}}Ba(){return this.Na.Fa}}G.wa=class{constructor(t){this.Ji=t,this.Fa=et.La()?3:10}Pa(t){return t+"."+this.Ji}store(t,e){const s={v:e};try{return localStorage.setItem(this.Pa(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.Pa(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.Pa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};G.ne=class{constructor(t,e){this.Ji=t,this.xa=this.Ja(),this.ka=576e3,this.Va=!!e}Pa(t){return null!=this.Ji?t+"."+this.Ji:t}Ja(){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.ka*1e3),t.getFullYear()}za(){const t=At(STORAGE_KEYS.iu),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.Qa(t)}}}store(t,e){this.za();const s=new Date;s.setTime(s.getTime()+60*this.ka*1e3);const o="expires="+s.toUTCString(),n="domain="+this.xa;let i;i=this.Va?e:encodeURIComponent(JSON.stringify(e));const a=this.Pa(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.Pa(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.Va?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.Qa(this.Pa(t))}Qa(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.xa;document.cookie=s,document.cookie=s+";path=/"}};G._a=class{constructor(){this.Ha={},this.Wa=5242880,this.Fa=3}store(t,e){const s={value:e},o=this.Xa(e);return o>this.Wa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Wa),!1):(this.Ha[t]=s,!0)}Xa(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.Ha[t];return null==e?null:e.value}remove(t){this.Ha[t]=null}};G.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new G.ne(t)),s&&this.Za.push(new G.wa(t)),this.Za.push(new G._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 rr,validateValueIsFromEnum as F,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={iu:{su:"ab.storage.userId",Go:"ab.storage.deviceId",oh:"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",gn:"ab.storage.pushToken",ei:"ab.storage.newsFeed",hi:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",ol:"ab.storage.serverConfig",ba:"ab.storage.triggers",Ia:"ab.storage.triggers.ts",lh:"ab.storage.messagingSessionStart",Yt:"ab.storage.cc",vs:"ab.storage.ccLastFullSync",ys:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ka:"ab.storage.lastDisplayedTriggerTimesById",Ya:"ab.storage.lastDisplayedTriggerTime",Da:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature",As:"ab.storage.brazeSyncRetryCount",_s:"ab.storage.sdkVersion"},ae:"ab.optOut"};export default class G{constructor(t,e){this.Ga=t,this.Na=e}ru(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.Ga.store(t,s)}va(t){const e=this.tu(t);null!=e&&(e.mh=(new Date).valueOf(),this.ru(t,e))}tu(t){return _t.yn(this.Ga.lr(t))}wh(t){this.Ga.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)}fh(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.Ma(t[s])?e.push(ue.yn(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.qs,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}Xs(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=rr(STORAGE_KEYS.iu),e=rr(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ga.remove(STORAGE_KEYS.iu[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}ya(t){return t||STORAGE_KEYS.q.Oa}pa(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.ya(t[User._n]);for(let r in t)r===User._n||null!=e[s]&&null!=e[s][r]||this.mu(t[User._n],r,t[r])}mu(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.ya(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User._n]=t)),e===User.lu){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)}Ua(){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}ou(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.ya(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User._n]=t,this.pa(r))}const s=this.tu(STORAGE_KEYS.iu.oh);let r=null;null!=s&&(r=s.eu);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.fh(s)}}Ba(){return this.Na.Fa}}G.wa=class{constructor(t){this.Ji=t,this.Fa=et.La()?3:10}Pa(t){return t+"."+this.Ji}store(t,e){const s={v:e};try{return localStorage.setItem(this.Pa(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.Pa(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.Pa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};G.ne=class{constructor(t,e){this.Ji=t,this.xa=this.Ja(),this.ka=576e3,this.Va=!!e}Pa(t){return null!=this.Ji?t+"."+this.Ji:t}Ja(){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.ka*1e3),t.getFullYear()}za(){const t=At(STORAGE_KEYS.iu),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.Qa(t)}}}store(t,e){this.za();const s=new Date;s.setTime(s.getTime()+60*this.ka*1e3);const o="expires="+s.toUTCString(),n="domain="+this.xa;let i;i=this.Va?e:encodeURIComponent(JSON.stringify(e));const a=this.Pa(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.Pa(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.Va?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.Qa(this.Pa(t))}Qa(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.xa;document.cookie=s,document.cookie=s+";path=/"}};G._a=class{constructor(){this.Ha={},this.Wa=5242880,this.Fa=3}store(t,e){const s={value:e},o=this.Xa(e);return o>this.Wa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Wa),!1):(this.Ha[t]=s,!0)}Xa(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.Ha[t];return null==e?null:e.value}remove(t){this.Ha[t]=null}};G.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new G.ne(t)),s&&this.Za.push(new G.wa(t)),this.Za.push(new G._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)}}; |
@@ -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}li(){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 Ma(t){return null!=t&&Jt(t)&&null!=t.t&&""!==t.t}static yn(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 Jt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Jt(s),this.sessionId=r,this.data=e}li(){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 Ma(t){return null!=t&&jt(t)&&null!=t.t&&""!==t.t}static yn(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}} |
@@ -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.it.nt()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.eu=t,this.xh=s,this._h=(new Date).valueOf(),this.Nh=e}ss(){return{g:this.eu,e:this.Nh,c:this.xh,l:this._h}}static yn(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.eu=t,this.rh=s,this.mh=(new Date).valueOf(),this.ah=e}ss(){return{g:this.eu,e:this.ah,c:this.rh,l:this.mh}}static yn(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e.mh=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.wn=i||null,this.publicKey=l||null,this.tl=s||null,this.oh=u||null}ss(){return{e:this.endpoint,c:this.wn,p:this.publicKey,u:this.tl,v:this.oh}}static yn(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.wn=i||null,this.publicKey=l||null,this.zl=s||null,this.gl=u||null}ss(){return{e:this.endpoint,c:this.wn,p:this.publicKey,u:this.zl,v:this.gl}}static yn(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.2.1",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static yn(t){let s=t.l;return"4.2.1"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}} | ||
export default class Ft{constructor(t,s,i,h,l,e,r,u){this.ul=t||0,this.vl=s||[],this.wl=i||[],this.Cl=h||[],this.jl=l,null!=l&&""!==l||(this.jl=null),this.gl=e||null,this.ml=r||{},this.cl=u||{}}ss(){return{s:"4.3.0",l:this.ul,e:this.vl,a:this.wl,p:this.Cl,m:this.jl,v:this.gl,c:this.ml,f:this.cl}}static yn(t){let s=t.l;return"4.3.0"!==t.s&&(s=0),new Ft(s,t.e,t.a,t.p,t.m,t.v,t.c,t.f)}} |
@@ -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";import ht from"./Push/utils/push-utils.js";export default class Ot{constructor(t,s,i,e,n,l,h,o,r,a){this.Ji=t,this.yo=s,this.sl=0,this.il=h.Ba(),this.hl=null,this.j=i,this.Qi=e,this.v=n,this.gt=l,this.h=h,this.Bo=r,this.vt=a,this.ol=o,this.rl=new u,this.ul=50}al(t,s){return!t&&!s&&this.Bo.Qn()>=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}ml(t,s,i,e,n,l,h){null==i&&(i=!0),i&&this.dl();const u=this.h.Ca(),a=this.h.Ua();let c=!1;const m=(t,s)=>{let h=!1;b.Hs({url:this.yo+"/data/",data:t,headers:s,S:i=>{null!=t.respond_with&&t.respond_with.triggers&&(this.sl=Math.max(this.sl-1,0)),this.vt.Os(t,i,s)?(this.Bo.Qs(),this.gt.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.Vo())),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.vt.sa(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}}})},d=this.cl(u),f=s||d;if(this.al(h,d))return void r.D.info("Declining to flush data due to 50 consecutive authentication failures");if(i&&!this.vt.fa(u,a,t,f))return this.gl(),void("function"==typeof l&&l(!0));const g=this.vt.ma(t,f,u,a);f&&this.sl++;let p=!1;if(g)for(const t of g)this.vt.Gs(t.requestData,(()=>m(t.requestData,t.headers))),p=!0;this.Bo.Gn()&&i&&!p?this.gl():d&&(r.D.info("Invoking new session subscriptions"),this.rl.St())}bl(){return this.sl>0}gl(t){this.kl||(null==t&&(t=1e3*this.il),this.dl(),this.wl=setTimeout((()=>{if(document.hidden){const t="visibilitychange",s=()=>{document.hidden||(document.removeEventListener(t,s,!1),this.ml())};document.addEventListener(t,s,!1)}else this.ml()}),t),this.hl=t)}dl(){null!=this.wl&&(clearTimeout(this.wl),this.wl=null)}initialize(){this.kl=!1,this.gl()}destroy(){this.rl.removeAllSubscriptions(),this.Bo.On(),this.dl(),this.kl=!0,this.ml(null,null,!1),this.wl=null}cr(t){return this.rl.ut(t)}openSession(){const t=this.j.Vo()!==this.j.mo();t&&(this.h.va(o.iu.Go),this.h.va(o.iu.su)),this.ml(null,!1,null,null,null),this.$n(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.kl)return;const s=t.default.aa();if(null!=s&&(ht.isPushPermissionGranted()||ht.isPushBlocked())){const t=()=>{s.Er()?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.gn);(null==s||s)&&t()},n=r.xt.Ft;new r.qt(n,r.D).hr(n.$t.pu,i,e)}}))}changeUser(t,s,i){const e=this.v.getUserId();if(e!==t){this.j.kh(),null!=e&&this.ml(null,!1,null,null,null),this.v.uu(t),i?this.Bo.setSdkAuthenticationSignature(i):this.Bo.Ln();for(let t=0;t<s.length;t++)s[t].changeUser(null==e);null!=e&&this.h.Xs(o.q.P),this.h.Xs(o.q.Ho),this.openSession(),r.D.info('Changed user to "'+t+'".')}else{let s="Doing nothing.";i&&this.Bo.Hn()!==i&&(this.Bo.setSdkAuthenticationSignature(i),s="Updated SDK authentication signature"),r.D.info(`Current user is already ${t}. ${s}`)}}requestImmediateDataFlush(t){this.dl(),this.j.mo(),this.ml(null,null,null,null,null,t,!0)}requestFeedRefresh(){this.j.mo(),this.ml(!0)}zr(t,s){this.j.mo(),r.D.info("Requesting explicit trigger refresh."),this.ml(null,!0,null,t,s)}Nn(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}In(i,e,n){if(this.gt.hu(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})}$n(){const t=r.xt.Ft;new r.qt(t,r.D).setItem(t.$t.jl,1,{baseUrl:this.yo,data:{api_key:this.Ji,device_id:this.Qi.te().id},userId:this.v.getUserId(),sdkAuthEnabled:this.Bo.Gn()})}wr(t){for(const s of t)if(s.api_key===this.Ji)this.vt.sa(s.events,s.attributes);else{const t=r.xt.Ft;new r.qt(t,r.D).setItem(t.$t.$r,r.it.nt(),s)}}Fn(i,e,n){if(this.gt.hu(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)}Tn(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";import ht from"./Push/utils/push-utils.js";export default class Ot{constructor(t,s,i,e,n,l,h,o,r,a){this.Ji=t,this.yo=s,this.kl=0,this.yl=h.Ba(),this.Sl=null,this.j=i,this.Qi=e,this.v=n,this.gt=l,this.h=h,this.Bo=r,this.vt=a,this.$l=o,this.Al=new u,this._l=50}ql(t,s){return!t&&!s&&this.Bo.Qn()>=this._l}Dl(t){let s=this.j.hh();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.ph&&t&&(s=!0)}}return s}Ll(t,s,i,e,n,l,h){null==i&&(i=!0),i&&this.Pl();const u=this.h.Ca(),a=this.h.Ua();let c=!1;const m=(t,s)=>{let h=!1;b.Hs({url:this.yo+"/data/",data:t,headers:s,S:i=>{null!=t.respond_with&&t.respond_with.triggers&&(this.kl=Math.max(this.kl-1,0)),this.vt.Os(t,i,s)?(this.Bo.Qs(),this.gt.al(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.Vo())),this.$l(i),"function"==typeof e&&e())):i.auth_error&&(h=!0)},error:()=>{null!=t.respond_with&&t.respond_with.triggers&&(this.kl=Math.max(this.kl-1,0)),this.vt.sa(t.events,t.attributes),"function"==typeof n&&n()},Rl:t=>{if("function"==typeof l&&l(t),i&&!c){if(t&&!h)this.Ml();else{let t=this.Sl;(null==t||t<1e3*this.yl)&&(t=1e3*this.yl),this.Ml(Math.min(3e5,lt(1e3*this.yl,3*t)))}c=!0}}})},d=this.Dl(u),f=s||d;if(this.ql(h,d))return void r.D.info("Declining to flush data due to 50 consecutive authentication failures");if(i&&!this.vt.fa(u,a,t,f))return this.Ml(),void("function"==typeof l&&l(!0));const g=this.vt.ma(t,f,u,a);f&&this.kl++;let p=!1;if(g)for(const t of g)this.vt.Gs(t.requestData,(()=>m(t.requestData,t.headers))),p=!0;this.Bo.Gn()&&i&&!p?this.Ml():d&&(r.D.info("Invoking new session subscriptions"),this.Al.St())}Il(){return this.kl>0}Ml(t){this.Nl||(null==t&&(t=1e3*this.yl),this.Pl(),this.Ol=setTimeout((()=>{if(document.hidden){const t="visibilitychange",s=()=>{document.hidden||(document.removeEventListener(t,s,!1),this.Ll())};document.addEventListener(t,s,!1)}else this.Ll()}),t),this.Sl=t)}Pl(){null!=this.Ol&&(clearTimeout(this.Ol),this.Ol=null)}initialize(){this.Nl=!1,this.Ml()}destroy(){this.Al.removeAllSubscriptions(),this.Bo.On(),this.Pl(),this.Nl=!0,this.Ll(null,null,!1),this.Ol=null}cr(t){return this.Al.ut(t)}openSession(){const t=this.j.Vo()!==this.j.mo();t&&(this.h.va(o.iu.Go),this.h.va(o.iu.su)),this.Ll(null,!1,null,null,null),this.$n(),t&&import("./Push/push-manager-factory.js").then((t=>{if(this.Nl)return;const s=t.default.aa();if(null!=s&&(ht.isPushPermissionGranted()||ht.isPushBlocked())){const t=()=>{s.Er()?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.gn);(null==s||s)&&t()},n=r.xt.Ft;new r.qt(n,r.D).hr(n.$t.pu,i,e)}}))}changeUser(t,s,i){const e=this.v.getUserId();if(e!==t){this.j.gh(),null!=e&&this.Ll(null,!1,null,null,null),this.v.uu(t),i?this.Bo.setSdkAuthenticationSignature(i):this.Bo.Ln();for(let t=0;t<s.length;t++)s[t].changeUser(null==e);null!=e&&this.h.Xs(o.q.P),this.h.Xs(o.q.Ho),this.openSession(),r.D.info('Changed user to "'+t+'".')}else{let s="Doing nothing.";i&&this.Bo.Hn()!==i&&(this.Bo.setSdkAuthenticationSignature(i),s="Updated SDK authentication signature"),r.D.info(`Current user is already ${t}. ${s}`)}}requestImmediateDataFlush(t){this.Pl(),this.j.mo(),this.Ll(null,null,null,null,null,t,!0)}requestFeedRefresh(){this.j.mo(),this.Ll(!0)}zr(t,s){this.j.mo(),r.D.info("Requesting explicit trigger refresh."),this.Ll(null,!0,null,t,s)}Nn(t,i){const e=r.A.Ul,n={a:t,l:i},l=s.G(e,n);return l&&r.D.info(`Logged alias ${t} with label ${i}`),l}In(i,e,n){if(this.gt.hu(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.xl,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.Kl,t,i,{cid:s})}$n(){const t=r.xt.Ft;new r.qt(t,r.D).setItem(t.$t.Wl,1,{baseUrl:this.yo,data:{api_key:this.Ji,device_id:this.Qi.te().id},userId:this.v.getUserId(),sdkAuthEnabled:this.Bo.Gn()})}wr(t){for(const s of t)if(s.api_key===this.Ji)this.vt.sa(s.events,s.attributes);else{const t=r.xt.Ft;new r.qt(t,r.D).setItem(t.$t.$r,r.it.nt(),s)}}Fn(i,e,n){if(this.gt.hu(i))return r.D.info(`Custom Attribute "${i}" is blocklisted, ignoring.`),new t;let l,h;return null===e&&null===n?(l=r.A.Bl,h={key:i}):(l=r.A.Gl,h={key:i,latitude:e,longitude:n}),s.G(l,h)}Tn(t,i){const e={group_id:t,status:i};return s.G(r.A.Jl,e)}} |
@@ -1,1 +0,1 @@ | ||
export default class xt{constructor(t){this.xl=t}zl(t){return null==this.xl||this.xl===t[0]}static fromJson(t){return new xt(t?t.event_name:null)}ss(){return this.xl}} | ||
export default class xt{constructor(t){this.Hl=t}Ql(t){return null==this.Hl||this.Hl===t[0]}static fromJson(t){return new xt(t?t.event_name:null)}ss(){return this.Hl}} |
@@ -1,1 +0,1 @@ | ||
import Bt from"./filter-set.js";export default class Mt{constructor(t,s){this.xl=t,this.Bl=s}zl(t){if(null==this.xl||null==this.Bl)return!1;const s=t[0],r=t[1];return s===this.xl&&this.Bl.zl(r)}static fromJson(t){return new Mt(t?t.event_name:null,t?Bt.fromJson(t.property_filters):null)}ss(){return{e:this.xl,pf:this.Bl.ss()}}} | ||
import Bt from"./filter-set.js";export default class Mt{constructor(t,s){this.Hl=t,this.Vl=s}Ql(t){if(null==this.Hl||null==this.Vl)return!1;const s=t[0],r=t[1];return s===this.Hl&&this.Vl.Ql(r)}static fromJson(t){return new Mt(t?t.event_name:null,t?Bt.fromJson(t.property_filters):null)}ss(){return{e:this.Hl,pf:this.Vl.ss()}}} |
@@ -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 yn(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.yn(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}Ql(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].Ql(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 yn(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.yn(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 yn(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.Xl=t,this.Yl=s,this.comparator=e,this.Zl=i,this.Yl===kt.Th.Eh&&this.comparator!==kt._h.Ah&&this.comparator!==kt._h.yh&&this.comparator!==kt._h.Sh&&this.comparator!==kt._h.Nh&&(this.Zl=h(this.Zl))}Ql(t){let s=null;switch(null!=t&&(s=t[this.Xl]),this.comparator){case kt._h.Mh:return null!=s&&s.valueOf()===this.Zl.valueOf();case kt._h.Rh:return null==s||s.valueOf()!==this.Zl.valueOf();case kt._h.Hh:return typeof s==typeof this.Zl&&s>this.Zl;case kt._h.Ah:return this.Yl===kt.Th.Eh?null!=s&&yt(s)&&Ht(s)<=this.Zl:typeof s==typeof this.Zl&&s>=this.Zl;case kt._h.Lh:return typeof s==typeof this.Zl&&s<this.Zl;case kt._h.yh:return this.Yl===kt.Th.Eh?null!=s&&yt(s)&&Ht(s)>=this.Zl:typeof s==typeof this.Zl&&s<=this.Zl;case kt._h.Ih:return null!=s&&"string"==typeof s&&typeof s==typeof this.Zl&&null!=s.match(this.Zl);case kt._h.Oh:return null!=s;case kt._h.Uh:return null==s;case kt._h.Sh:return null!=s&&yt(s)&&Ut(s)<this.Zl;case kt._h.Nh:return null!=s&&yt(s)&&Ut(s)>this.Zl;case kt._h.Dh:return null==s||typeof s!=typeof this.Zl||"string"!=typeof s||null==s.match(this.Zl)}return!1}static fromJson(t){return new kt(t.property_key,t.property_type,t.comparator,t.property_value)}ss(){let t=this.Zl;return yt(this.Zl)&&(t=l(t.valueOf())),{k:this.Xl,t:this.Yl,c:this.comparator,v:t}}static yn(t){return new kt(t.k,t.t,t.c,t.v)}}kt._h={Mh:1,Rh:2,Hh:3,Ah:4,Lh:5,yh:6,Ih:10,Oh:11,Uh:12,Sh:15,Nh:16,Dh:17},kt.Th={Qh:"boolean",Xh:"number",Bh:"string",Eh:"date"}; |
@@ -1,1 +0,1 @@ | ||
import Ft from"./trigger-condition.js";export default class Gt{constructor(t,i){this.Wl=t,this.Yl=i}zl(t){if(null==this.Wl)return!1;const i=Ft.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 Gt(t?t.id:null,t?t.buttons:null)}ss(){return this.Wl}} | ||
import Gt from"./trigger-condition.js";export default class Kt{constructor(t,i){this.fu=t,this.cu=i}Ql(t){if(null==this.fu)return!1;const i=Gt.au(t[0],this.fu);if(!i)return!1;let r=null==this.cu||0===this.cu.length;if(null!=this.cu)for(let i=0;i<this.cu.length;i++)if(this.cu[i]===t[1]){r=!0;break}return i&&r}static fromJson(t){return new Kt(t?t.id:null,t?t.buttons:null)}ss(){return this.fu}} |
@@ -1,1 +0,1 @@ | ||
export default class Kt{constructor(t){this.productId=t}zl(t){return null==this.productId||t[0]===this.productId}static fromJson(t){return new Kt(t?t.product_id:null)}ss(){return this.productId}} | ||
export default class Qt{constructor(t){this.productId=t}Ql(t){return null==this.productId||t[0]===this.productId}static fromJson(t){return new Qt(t?t.product_id:null)}ss(){return this.productId}} |
@@ -1,1 +0,1 @@ | ||
import Bt from"./filter-set.js";export default class Qt{constructor(t,s){this.productId=t,this.Bl=s}zl(t){if(null==this.productId||null==this.Bl)return!1;const s=t[0],i=t[1];return s===this.productId&&this.Bl.zl(i)}static fromJson(t){return new Qt(t?t.product_id:null,t?Bt.fromJson(t.property_filters):null)}ss(){return{id:this.productId,pf:this.Bl.ss()}}} | ||
import Bt from"./filter-set.js";export default class Vt{constructor(t,s){this.productId=t,this.Vl=s}Ql(t){if(null==this.productId||null==this.Vl)return!1;const s=t[0],i=t[1];return s===this.productId&&this.Vl.Ql(i)}static fromJson(t){return new Vt(t?t.product_id:null,t?Bt.fromJson(t.property_filters):null)}ss(){return{id:this.productId,pf:this.Vl.ss()}}} |
@@ -1,1 +0,1 @@ | ||
import Ft from"./trigger-condition.js";export default class Wt{constructor(t){this.Wl=t}zl(t){return null==this.Wl||Ft.Zl(t[0],this.Wl)}static fromJson(t){return new Wt(t?t.campaign_id:null)}ss(){return this.Wl}} | ||
import Gt from"./trigger-condition.js";export default class Wt{constructor(t){this.fu=t}Ql(t){return null==this.fu||Gt.au(t[0],this.fu)}static fromJson(t){return new Wt(t?t.campaign_id:null)}ss(){return this.fu}} |
@@ -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 Gt from"./in-app-message-click-data.js";import Kt from"./purchase-data.js";import Qt from"./purchase-property-data.js";import Wt from"./push-click-data.js";import V from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Ft{constructor(e,t){this.type=e,this.data=t}qa(e,t){return Ft.$a[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 Ft.ec.OPEN:r=null;break;case Ft.ec.Rr:r=Kt.fromJson(e.data);break;case Ft.ec.tc:r=Qt.fromJson(e.data);break;case Ft.ec.vr:r=Wt.fromJson(e.data);break;case Ft.ec.be:r=xt.fromJson(e.data);break;case Ft.ec.rc:r=Mt.fromJson(e.data);break;case Ft.ec.Ar:r=Gt.fromJson(e.data);break;case Ft.ec.ks:r=null}return new Ft(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static yn(e){let t,r;switch(e.t){case Ft.ec.OPEN:t=null;break;case Ft.ec.Rr:t=new Kt(e.d);break;case Ft.ec.tc:r=e.d||{},t=new Qt(r.id,Bt.yn(r.pf||[]));break;case Ft.ec.vr:t=new Wt(e.d);break;case Ft.ec.be:t=new xt(e.d);break;case Ft.ec.rc:r=e.d||{},t=new Mt(r.e,Bt.yn(r.pf||[]));break;case Ft.ec.Ar:t=new Gt(e.d);break;case Ft.ec.ks:t=null}return new Ft(e.t,t)}}Ft.ec={OPEN:"open",Rr:"purchase",tc:"purchase_property",vr:"push_click",be:"custom_event",rc:"custom_event_property",Ar:"iam_click",ks:"test"},Ft.$a={},Ft.$a[Ft.ec.OPEN]=V.OPEN,Ft.$a[Ft.ec.Rr]=V.Rr,Ft.$a[Ft.ec.tc]=V.Rr,Ft.$a[Ft.ec.vr]=V.vr,Ft.$a[Ft.ec.be]=V.be,Ft.$a[Ft.ec.rc]=V.be,Ft.$a[Ft.ec.Ar]=V.Ar,Ft.$a[Ft.ec.ks]=V.ks; | ||
import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Kt from"./in-app-message-click-data.js";import Qt from"./purchase-data.js";import Vt from"./purchase-property-data.js";import Wt from"./push-click-data.js";import V from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Gt{constructor(e,t){this.type=e,this.data=t}qa(e,t){return Gt.$a[this.type]===e&&(null==this.data||this.data.Ql(t))}static au(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 Gt.ec.OPEN:r=null;break;case Gt.ec.Rr:r=Qt.fromJson(e.data);break;case Gt.ec.tc:r=Vt.fromJson(e.data);break;case Gt.ec.vr:r=Wt.fromJson(e.data);break;case Gt.ec.be:r=xt.fromJson(e.data);break;case Gt.ec.rc:r=Mt.fromJson(e.data);break;case Gt.ec.Ar:r=Kt.fromJson(e.data);break;case Gt.ec.ks:r=null}return new Gt(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static yn(e){let t,r;switch(e.t){case Gt.ec.OPEN:t=null;break;case Gt.ec.Rr:t=new Qt(e.d);break;case Gt.ec.tc:r=e.d||{},t=new Vt(r.id,Bt.yn(r.pf||[]));break;case Gt.ec.vr:t=new Wt(e.d);break;case Gt.ec.be:t=new xt(e.d);break;case Gt.ec.rc:r=e.d||{},t=new Mt(r.e,Bt.yn(r.pf||[]));break;case Gt.ec.Ar:t=new Kt(e.d);break;case Gt.ec.ks:t=null}return new Gt(e.t,t)}}Gt.ec={OPEN:"open",Rr:"purchase",tc:"purchase_property",vr:"push_click",be:"custom_event",rc:"custom_event_property",Ar:"iam_click",ks:"test"},Gt.$a={},Gt.$a[Gt.ec.OPEN]=V.OPEN,Gt.$a[Gt.ec.Rr]=V.Rr,Gt.$a[Gt.ec.tc]=V.Rr,Gt.$a[Gt.ec.vr]=V.vr,Gt.$a[Gt.ec.be]=V.be,Gt.$a[Gt.ec.rc]=V.be,Gt.$a[Gt.ec.Ar]=V.Ar,Gt.$a[Gt.ec.ks]=V.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 Ft from"./trigger-condition.js";import{validateValueIsFromEnum as F}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.vi=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.vi||i<this.vi;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.vi}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Ft.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 F(ut.gi,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.vi,ss:this.Ih,ld:this.$h}}static yn(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Ft.yn(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.gi={mi:"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 Gt from"./trigger-condition.js";import{validateValueIsFromEnum as F}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.Ph=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.bh=n||0,null==a&&(a=1e3*(this.bh+30)),this.vi=a,this.data=o,null==h&&(h=ut.jh),this.$h=h,this.xh=u,this.Ch=d||null}Fh(t){return null==this.Ch||this.$h!==ut.jh&&t-this.Ch>=1e3*this.$h}Jh(t){this.Ch=t}Vh(t){const i=t+1e3*this.bh;return Math.max(i-(new Date).valueOf(),0)}kh(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.vi||i<this.vi;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.vi}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Gt.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 F(ut.gi,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.Ph.length;i++)t.push(this.Ph[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.bh,r:this.$h,tm:this.vi,ss:this.xh,ld:this.Ch}}static yn(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Gt.yn(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.jh=-1,ut.gi={mi:"inapp",qh:"templated_iam"}; |
@@ -1,1 +0,1 @@ | ||
import y 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 F}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 V from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends y{constructor(t,i,s,e,r){super(),this.Oh=t,this.yt=i,this.h=s,this.si=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.Ya)||this.Vh,this.Xh=this.h.I(o.q.Da)||this.Xh,this.Yh=this.h.I(o.q.Ka)||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.Ia)||0;const t=this.h.I(o.q.ba)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.yn(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.di);if(n>0){let t,e;h.push(o),null!=o.og&&(t=o.og),null!=o.ng&&ue.Ma(o.ng)&&(e=ue.yn(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.di,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.Da,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.ba,t),this.h.B(o.q.Ia,this.eg)}gg(){(this.h.I(o.q.Ia)||0)>this.eg?this.Zh():this.ig()}Rs(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].qa(V.ks,null)){i=!0;break}null!=h&&this.sg.push(h)}ii(this.Yh,s)||(this.Yh=s,this.h.B(o.q.Ka,this.Yh)),ii(this.Xh,e)||(this.Xh=e,this.h.B(o.q.Da,this.Xh)),this.ag(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(V.ks)),this.je(V.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.gi.mi&&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.yt.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.gi.Rh?this.Uh.qe(t.id,InAppMessage.Oe.ui):this.Uh.qe(t.id,InAppMessage.Oe.Yi)},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.Yi),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.gi.mi: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.ci);break}let l=this.Uh.Ve(h);if(l){r.D.error(l),n();break}o(h);break;case ut.gi.Rh:const a=ft.fromJson(t.data,o,n,i,t.vi);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.ci);break}this.Uh.Ze(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.ci)}}je(t,i,s){if(!F(V,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.si.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].qa(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.Xs(o.q.ba),!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.Xs(o.q.Ya),this.h.Xs(o.q.Ka),this.h.Xs(o.q.Da)}}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===V.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.di=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.Da,this.Xh)}cg(t,i){this.ig(),t.Bh(i),this.Vh=i,this.h.B(o.q.Ya,i),this.Yh[t.id]=i,this.h.B(o.q.Ka,this.Yh)}} | ||
import y 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 F}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 V from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends y{constructor(t,i,s,e,r){super(),this.Wh=t,this.yt=i,this.h=s,this.si=e,this.Gh=r,this.Kh=[],this.Yh=[],this.Zh=null,this.tg={},this.ig={},this.sg(),this.eg()}hg(){this.Zh=this.h.I(o.q.Ya)||this.Zh,this.tg=this.h.I(o.q.Da)||this.tg,this.ig=this.h.I(o.q.Ka)||this.ig;for(let t=0;t<this.og.length;t++){const i=this.og[t];null!=this.ig[i.id]&&i.Jh(this.ig[i.id])}}sg(){this.ng=this.h.I(o.q.Ia)||0;const t=this.h.I(o.q.ba)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.yn(t[s]));this.og=i,this.hg()}eg(){const t=this,i=function(i,s,e,r,h){return function(){t.lg(i,s,e,r,h)}},s={};for(let t=0;t<this.og.length;t++)s[this.og[t].id]=this.og[t];let e=!1;for(let t=0;t<this.og.length;t++){const r=this.og[t];if(null!=this.tg[r.id]){const t=this.tg[r.id],h=[];for(let e=0;e<t.length;e++){const o=t[e],n=r.Vh(o.di);if(n>0){let t,e;h.push(o),null!=o.ag&&(t=o.ag),null!=o.gg&&ue.Ma(o.gg)&&(e=ue.yn(o.gg));const l=[];if(p(o.fg))for(let t=0;t<o.fg.length;t++){const i=s[o.fg[t]];null!=i&&l.push(i)}this.Yh.push(setTimeout(i(r,o.di,t,e,l),n))}}this.tg[r.id].length>h.length&&(this.tg[r.id]=h,e=!0,0===this.tg[r.id].length&&delete this.tg[r.id])}}e&&this.h.B(o.q.Da,this.tg)}cg(){const t=[];for(let i=0;i<this.og.length;i++)t.push(this.og[i].ss());this.ng=(new Date).valueOf(),this.h.B(o.q.ba,t),this.h.B(o.q.Ia,this.ng)}ug(){(this.h.I(o.q.Ia)||0)>this.ng?this.sg():this.hg()}Rs(t){let i=!1;if(null!=t&&t.triggers){this.hg();const s={},e={};this.og=[];for(let r=0;r<t.triggers.length;r++){const h=ut.fromJson(t.triggers[r]);null!=this.ig[h.id]&&(h.Jh(this.ig[h.id]),s[h.id]=this.ig[h.id]),null!=this.tg[h.id]&&(e[h.id]=this.tg[h.id]);for(let t=0;t<h.Ph.length;t++)if(h.Ph[t].qa(V.ks,null)){i=!0;break}null!=h&&this.og.push(h)}ii(this.ig,s)||(this.ig=s,this.h.B(o.q.Ka,this.ig)),ii(this.tg,e)||(this.tg=e,this.h.B(o.q.Da,this.tg)),this.cg(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(V.ks)),this.je(V.OPEN);const h=this.Kh;this.Kh=[];for(let t=0;t<h.length;t++)this.je.apply(this,h[t])}}async lg(t,i,s,e,h){const o=e=>{this.hg();const h=(new Date).valueOf();if(!t.kh(i))return!1===navigator.onLine&&t.type===ut.gi.mi&&e.imageUrl?(r.D.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.Gh.qe(t.id,InAppMessage.Oe.Ki)):void(t.Fh(h)&&this.dg(t,h,s)?(this.yt.St([e]),this.mg(t,h)):r.D.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===ut.gi.qh?this.Gh.qe(t.id,InAppMessage.Oe.ui):this.Gh.qe(t.id,InAppMessage.Oe.Yi)},n=()=>{this.hg();const o=h.pop();if(null!=o)if(this.pg(o,i,s,e,h),o.kh(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.Gh.qe(o.id,InAppMessage.Oe.Yi),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.bh-((new Date).valueOf()-i);n>0?this.Yh.push(setTimeout((()=>{this.lg(o,i,s,e,h)}),n)):this.lg(o,i,s,e,h)}};switch(t.type){case ut.gi.mi:const h=it(t.data);if(null==h){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Gh.qe(t.id,InAppMessage.Oe.ci);break}let l=this.Gh.Ve(h);if(l){r.D.error(l),n();break}o(h);break;case ut.gi.qh:const a=ft.fromJson(t.data,o,n,i,t.vi);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Gh.qe(t.id,InAppMessage.Oe.ci);break}this.Gh.Ze(a,s,e);break;default:r.D.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.Gh.qe(t.id,InAppMessage.Oe.ci)}}je(t,i,s){if(!F(V,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.si.Il())return r.D.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.Kh.push(arguments);this.ug();const e=(new Date).valueOf(),h=e-this.Zh;let o=!0,n=!0;const l=[];for(let s=0;s<this.og.length;s++){const r=this.og[s],h=e+1e3*r.bh;if(r.Fh(h)&&(null==r.startTime||r.startTime<=e)&&(null==r.endTime||r.endTime>=e)){let s=!1;for(let e=0;e<r.Ph.length;e++)if(r.Ph[e].qa(t,i)){s=!0;break}s&&(o=!1,this.dg(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.pg(a,e,t,s,l),0===a.bh?this.lg(a,e,t,s,l):this.Yh.push(setTimeout((()=>{this.lg(a,e,t,s,l)}),1e3*a.bh)))}changeUser(t){if(this.og=[],this.h.Xs(o.q.ba),!t){this.Kh=[],this.Zh=null,this.ig={},this.tg={};for(let t=0;t<this.Yh.length;t++)clearTimeout(this.Yh[t]);this.Yh=[],this.h.Xs(o.q.Ya),this.h.Xs(o.q.Ka),this.h.Xs(o.q.Da)}}clearData(){this.og=[],this.Zh=null,this.ig={},this.tg={};for(let t=0;t<this.Yh.length;t++)clearTimeout(this.Yh[t]);this.Yh=[]}dg(t,i,s){if(null==this.Zh)return!0;if(s===V.ks)return r.D.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.xh;return null==e&&(e=this.Wh),i-this.Zh>=1e3*e}pg(t,i,s,e,r){this.hg(),this.tg[t.id]=this.tg[t.id]||[];const h={};let n;h.di=i,h.ag=s,null!=e&&(n=e.ss()),h.gg=n;const l=[];for(let t=0;t<r.length;t++)l.push(r[t].id);h.fg=l,this.tg[t.id].push(h),this.h.B(o.q.Da,this.tg)}mg(t,i){this.hg(),t.Jh(i),this.Zh=i,this.h.B(o.q.Ya,i),this.ig[t.id]=i,this.h.B(o.q.Ka,this.ig)}} |
@@ -1,1 +0,1 @@ | ||
import e,{OPTIONS as T}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.2.1".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(T.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}} | ||
import e,{OPTIONS as T}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.3.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(T.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}} |
@@ -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.Do=si.Sg(this.userAgent)}bg(){return this.browser!==ri.vg||this.version>8}La(){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.Sg=new t,this.userAgent=navigator.userAgent,this.browser=this.Sg.tf(),this.version=this.Sg.ef(),this.Ko().then((t=>this.OS=t)),this.language=(navigator.userLanguage||navigator.language||navigator.browserLanguage||navigator.systemLanguage||"").toLowerCase(),this.Do=si.bg(this.userAgent)}vg(){return this.browser!==ri.yg||this.version>8}La(){return this.browser===ri.Bg}qo(){return this.OS||null}Ko(){return this.OS?Promise.resolve(this.OS):this.Sg.Ko(si.Og).then((t=>(this.OS=t,t)))}static bg(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.Og=[{string:navigator.platform,if:"Win",identity:ot.Pg},{string:navigator.platform,if:"Mac",identity:ot.kg},{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.xg},{string:navigator.userAgent,if:["Android"],identity:ot.xg},{string:navigator.platform,if:"Linux",identity:"Linux"}];const et=new si;export{et as default,si as BrowserDetector}; |
@@ -1,1 +0,1 @@ | ||
import Zt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Zt{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 Zt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Zt{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.yg&&r.push(t[s]);return new RegExp("("+r.join("|")+")","i")}ic(){return this.userAgentData.getHighEntropyValues?this.userAgentData.getHighEntropyValues(["platform"]):Promise.reject()}} |
@@ -1,1 +0,1 @@ | ||
import et from"./browser-detector.js";export function isTransparent(r){return r=parseInt(r),!isNaN(r)&&(4278190080&r)>>>24==0}export function toRgba(r,t){if(r=parseInt(r),isNaN(r))return"";t=parseFloat(t),isNaN(t)&&(t=1);const n=255&(r>>>=0),e=(65280&r)>>>8,o=(16711680&r)>>>16,a=((4278190080&r)>>>24)/255;return et.bg()?"rgba("+[o,e,n,a*t].join(",")+")":"rgb("+[o,e,n].join(",")+")"}export function toRgb(r){if(r=parseInt(r),isNaN(r))return"";return"rgb("+[(16711680&(r>>>=0))>>>16,(65280&r)>>>8,255&r].join(",")+")"} | ||
import et from"./browser-detector.js";export function isTransparent(r){return r=parseInt(r),!isNaN(r)&&(4278190080&r)>>>24==0}export function toRgba(r,t){if(r=parseInt(r),isNaN(r))return"";t=parseFloat(t),isNaN(t)&&(t=1);const n=255&(r>>>=0),e=(65280&r)>>>8,o=(16711680&r)>>>16,a=((4278190080&r)>>>24)/255;return et.vg()?"rgba("+[o,e,n,a*t].join(",")+")":"rgb("+[o,e,n].join(",")+")"}export function toRgb(r){if(r=parseInt(r),isNaN(r))return"";return"rgb("+[(16711680&(r>>>=0))>>>16,(65280&r)>>>8,255&r].join(",")+")"} |
@@ -1,1 +0,1 @@ | ||
export const Browsers={rE:"Chrome",eE:"Edge",vg:"Internet Explorer",EE:"Opera",yg:"Safari",oE:"Firefox"};export const OperatingSystems={Og:"Android",ln:"iOS",Bg:"Mac",mg:"Windows"}; | ||
export const Browsers={rE:"Chrome",eE:"Edge",yg:"Internet Explorer",EE:"Opera",Bg:"Safari",oE:"Firefox"};export const OperatingSystems={xg:"Android",ln:"iOS",kg:"Mac",Pg:"Windows"}; |
@@ -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={cu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",et:"right"};export function supportsPassive(){if(null==DOMUtils.cu){DOMUtils.cu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.cu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.cu}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} | ||
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={wu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",et:"right"};export function supportsPassive(){if(null==DOMUtils.wu){DOMUtils.wu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.wu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.wu}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 @@ | ||
import r from"../../shared-lib/braze-shared-lib.js";import qt from"../models/backend-errors.js";const b={Hs:t=>{let e,o;try{const n=()=>{r.D.error("This browser does not have any supported ajax options!")};if(window.XMLHttpRequest?(e=new XMLHttpRequest,e||n()):n(),null!=e){const r=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.fl&&t.fl(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.S){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const n={error:""===e.responseText?qt.oa:qt.ha,response:e.responseText};t.S(n,r)}o&&t.S(o,r)}"function"==typeof t.fl&&t.fl(!0)}else r()},e.onerror=()=>{r()},e.ontimeout=()=>{r()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const n=t.headers||[];for(const t of n)e.setRequestHeader(t[0],t[1]);e.send(o)}}catch(t){r.D.error(`Network request error: ${t.message}`)}}};export const readResponseHeaders=t=>{let e={};const o=t.toString().split("\r\n");if(!o)return e;let r,n;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),n=t.slice(t.indexOf(":")+1).trim(),e[r]=n);return e};export default b; | ||
import r from"../../shared-lib/braze-shared-lib.js";import qt from"../models/backend-errors.js";const b={Hs:t=>{let e,o;try{const n=()=>{r.D.error("This browser does not have any supported ajax options!")};if(window.XMLHttpRequest?(e=new XMLHttpRequest,e||n()):n(),null!=e){const r=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.Rl&&t.Rl(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.S){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const n={error:""===e.responseText?qt.oa:qt.ha,response:e.responseText};t.S(n,r)}o&&t.S(o,r)}"function"==typeof t.Rl&&t.Rl(!0)}else r()},e.onerror=()=>{r()},e.ontimeout=()=>{r()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const n=t.headers||[];for(const t of n)e.setRequestHeader(t[0],t[1]);e.send(o)}}catch(t){r.D.error(`Network request error: ${t.message}`)}}};export const readResponseHeaders=t=>{let e={};const o=t.toString().split("\r\n");if(!o)return e;let r,n;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),n=t.slice(t.indexOf(":")+1).trim(),e[r]=n);return e};export default b; |
@@ -1,1 +0,1 @@ | ||
import Zt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Zt{constructor(){super(),this.au=ni.du(navigator.userAgent||"")}tf(){return this.au[0]||"Unknown Browser"}ef(){return this.au[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 du(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 Zt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Zt{constructor(){super(),this.du=ni.gu(navigator.userAgent||"")}tf(){return this.du[0]||"Unknown Browser"}ef(){return this.du[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.kg&&navigator.maxTouchPoints>1&&(i=ot.ln),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static gu(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.yg,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.Bg&&(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.Bg&&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.yg),"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 @@ | ||
import{isArray as p,isDate as yt,isObject as Jt,keys as rr}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!Jt(e))return _validatePropertyType(e);for(const r of rr(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=Jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(_.properties.type in e))return!1;switch(e[_.properties.type]){case _.types.ue:if(_.properties.me in e)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.de:case _.types.pe:if(_.properties.fe in e)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){let t=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==e.toString()||(t=!0)})),t} | ||
import{isArray as p,isDate as yt,isObject as jt,keys as rr}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!jt(e))return _validatePropertyType(e);for(const r of rr(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(_.properties.type in e))return!1;switch(e[_.properties.type]){case _.types.ue:if(_.properties.me in e)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.de:case _.types.pe:if(_.properties.fe in e)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){let t=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==e.toString()||(t=!0)})),t} |
Sorry, the diff of this file is too big to display
341118
2042