@braze/web-sdk 4.0.6 → 4.1.0

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