(()=>{"use strict";var e={4744:e=>{var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?d((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function o(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function r(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function a(e,t,i){var o={};return i.isMergeableObject(e)&&r(e).forEach((function(t){o[t]=n(e[t],i)})),r(t).forEach((function(r){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(s(e,r)&&i.isMergeableObject(t[r])?o[r]=function(e,t){if(!t.customMerge)return d;var i=t.customMerge(e);return"function"==typeof i?i:d}(r,i)(e[r],t[r],i):o[r]=n(t[r],i))})),o}function d(e,i,r){(r=r||{}).arrayMerge=r.arrayMerge||o,r.isMergeableObject=r.isMergeableObject||t,r.cloneUnlessOtherwiseSpecified=n;var s=Array.isArray(i);return s===Array.isArray(e)?s?r.arrayMerge(e,i,r):a(e,i,r):n(i,r)}d.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return d(e,i,t)}),{})};var c=d;e.exports=c},3110:(e,t,i)=>{i.r(t),i.d(t,{default:()=>c,detectIncognito:()=>l});var n={d:(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},o={};n.d(o,{A:()=>d,k:()=>a});var r=function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},s=function(e,t){var i,n,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(d){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(s=0)),s;)try{if(i=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]s(void 0,void 0,void 0,(function*(){c.default.debug("The alert is being added for the subscriber."),g.addAlert(e);const n=(0,l.detectBrowser)(),o=(0,u.addQueryParamsToUrl)(`${p.env.__SUBSCRIBER_API_ENDPOINT__}/alerts`,{swv:p.env.__WORKER_VERSION__,bv:n.version}),r={method:"POST",body:JSON.stringify(Object.assign(Object.assign({},e),{device_token_hash:t,site_id:i})),retries:2},s=yield(0,d.sendHttpRequest)(o,r);s.ok||(yield(0,b.throwDexterAPIError)(s,"Couldn't add alert.",{url:o,options:r})),c.default.debug("The alert has been added for the subscriber.")}));t.getAlerts=({subscriberId:e,siteId:t,options:i={}})=>s(void 0,void 0,void 0,(function*(){c.default.debug("The alert is being retrieved for the subscriber.");const n=(0,l.detectBrowser)(),o=(0,u.addQueryParamsToUrl)(`${p.env.__SUBSCRIBER_API_ENDPOINT__}/alerts`,{swv:p.env.__WORKER_VERSION__,bv:n.version,device_token_hash:e,site_id:t,type:i.type,product_id:i.productId,variant_id:i.variantId});try{const e=yield(0,d.sendHttpRequest)(o,{retries:2});if(!e.ok)return c.default.debug("Response not ok:",e),null;const t=yield e.json();return(null==t?void 0:t.error_code)||!1===Array.isArray(null==t?void 0:t.data)?(c.default.debug("Error retrieving the alert response.",t),null):t.data}catch(e){return c.default.debug("Error occurred:",e),null}finally{c.default.debug("The alert has been retrieved for the subscriber.")}}))},5971:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getGeoInfo=t.getAppData=void 0;const r=i(2381),s=o(i(6920)),a=i(5967),d=i(9933),c=i(561);t.getAppData=({appId:e,source:t="sdk",version:i=1})=>n(void 0,void 0,void 0,(function*(){if(!e)throw new s.default({message:s.default.ERROR_MESSAGE.InvalidAppId,name:s.default.ERROR_NAME.InvalidAppId});const n=(0,d.addQueryParamsToUrl)(`${c.env.__CDN_SERVER_HOST__}/v${i}/sdk-app-data/${e}`,{source:t,sdkv:c.env.__SDK_VERSION__,swv:c.env.__WORKER_VERSION__}),o=yield(0,r.sendHttpRequest)(n,{retries:4});if(!o.ok){const e=yield o.json();throw new Error(`${e.message||"Something went wrong"}`)}const l=yield o.json();return(0,a.isObject)(l)?l:null})),t.getGeoInfo=(()=>{let e=null;return({isEu:t})=>n(void 0,void 0,void 0,(function*(){if(e)return e;const i=(0,d.addQueryParamsToUrl)(`${c.env.__SERVER_HOST__}/geo-details`,{sdkv:c.env.__SDK_VERSION__,swv:c.env.__WORKER_VERSION__});try{const n=yield(0,r.sendHttpRequest)(i,{retries:3});if(!n.ok)return{};const o=yield n.json(),s=(0,a.isObject)(o)?o:{};return(0,a.isEmptyObject)(s)||(s.ipaddress=(0,a.replaceLastNumberFromIpToZero)(t,s.ipaddress)),e=s,s}catch(e){return{}}}))})()},9707:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeAttributes=t.setAttributes=t.addAttributes=t.getAttributes=void 0;const d=i(6280),c=i(9933),l=i(2381),u=i(5967),g=r(i(3271)),p=i(5298),b=i(3502),f=i(561),m=a(i(1762)),v=e=>s(void 0,void 0,void 0,(function*(){const t=yield(0,p.getSubscriberDataFromStorageOrAPI)(e);return(null==t?void 0:t.attributes)&&(0,u.isObject)(t.attributes)?t.attributes:{}}));t.getAttributes=e=>s(void 0,void 0,void 0,(function*(){m.default.debug("The attributes are being retrieved from the subscriber.");const t=yield v(e);return m.default.debug("The attributes has been retrieved for the subscriber."),t}));t.addAttributes=(e,t)=>s(void 0,void 0,void 0,(function*(){m.default.debug("The attributes are being added to the subscriber."),g.addAttributes(t);const i=yield v(e);if((({subscriberAttributes:e,attributes:t})=>{if((0,u.isEmptyObject)(e))return!1;let i=!0;for(const n in t)if(t[n]!==e[n]){i=!1;break}return i})({subscriberAttributes:i,attributes:t}))return;const n=(0,d.detectBrowser)(),o=(0,c.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}/attributes`,{swv:f.env.__WORKER_VERSION__,bv:n.version}),r={method:"PUT",body:JSON.stringify(t),retries:2},s=yield(0,l.sendHttpRequest)(o,r);s.ok||(yield(0,p.throwDexterAPIError)(s,"Couldn't add attributes.",{url:o,options:r})),m.default.debug("The attributes has been added to the subscriber."),(0,b.updateSubscriberDataToStorage)({attributes:Object.assign({},i,t)})}));t.setAttributes=(e,t)=>s(void 0,void 0,void 0,(function*(){m.default.debug("The attributes are being set to the subscriber."),g.addAttributes(t);if((({subscriberAttributes:e,attributes:t})=>{if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0})({subscriberAttributes:yield v(e),attributes:t}))return;const i=(0,d.detectBrowser)(),n=(0,c.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}/attributes`,{swv:f.env.__WORKER_VERSION__,bv:i.version}),o={method:"POST",body:JSON.stringify(t),retries:2},r=yield(0,l.sendHttpRequest)(n,o);r.ok||(yield(0,p.throwDexterAPIError)(r,"Couldn't set attributes.",{url:n,options:o})),m.default.debug("The attributes has been set to the subscriber."),(0,b.updateSubscriberDataToStorage)({attributes:t})}));t.removeAttributes=(e,t=[])=>s(void 0,void 0,void 0,(function*(){if(m.default.debug("The attributes are being removed from the subscriber."),!1===Array.isArray(t))throw new Error("The attribute names must be provided as an array.");const i=yield v(e);if(!(({attributeNames:e,subscriberAttributes:t})=>{if((0,u.isEmptyObject)(t))return!1;if(0===e.length)return!0;for(const i of e)if((0,u.hasOwn)(t,i))return!0;return!1})({subscriberAttributes:i,attributeNames:t}))return;const n=(0,d.detectBrowser)(),o=(0,c.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}/attributes`,{swv:f.env.__WORKER_VERSION__,bv:n.version}),r={method:"DELETE",body:JSON.stringify(t),retries:2},s=yield(0,l.sendHttpRequest)(o,r);s.ok||(yield(0,p.throwDexterAPIError)(s,"Couldn't remove attributes.",{url:o,options:r})),m.default.debug("The attributes has been removed from the subscriber.");let a={};t.length>0&&(a=(0,u.omit)(i,t)),(0,b.updateSubscriberDataToStorage)({attributes:a})}))},2610:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendErrorLog=void 0;const r=i(2381),s=i(6280),a=o(i(1762)),d=i(561),c=o(i(6920));t.sendErrorLog=(e="sdk",t,i)=>n(void 0,void 0,void 0,(function*(){var n,o;try{a.default.debug(t,t.details);const l=[c.default.ERROR_NAME.InvalidAppId,c.default.ERROR_NAME.UnsubscribedFailedFromWorker,c.default.ERROR_NAME.NotPushEngagePayload,c.default.ERROR_NAME.PayloadLessInvalidNotificationPayload,c.default.ERROR_NAME.InvalidNotificationPayload,c.default.ERROR_NAME.PushPayloadParseError,c.default.ERROR_NAME.OfflineError,c.default.ERROR_NAME.OpenNotificationUrlFailed,c.default.ERROR_NAME.SendOptInAnalyticsError,c.default.ERROR_NAME.QuotaExceededError,c.default.ERROR_NAME.DisabledPushSubscriptionError,c.default.ERROR_NAME.UnknownError,c.default.ERROR_NAME.SDKInitOptionsNotFound,"NS_ERROR_FILE_CORRUPTED","NS_ERROR_STORAGE_CONSTRAINT","NS_ERROR_FILE_NO_DEVICE_SPACE","NS_ERROR_STORAGE_IOERR","NS_ERROR_NOT_INITIALIZED",c.default.ERROR_NAME.LocalStorageNotAvailable,c.default.ERROR_NAME.SubscriptionAlreadyInitialized,c.default.ERROR_NAME.SubscriberIdNotFoundInDb],u=[];if(l.includes(t.name)||u.includes(t.type||""))return;const g=`${d.env.__LOG_API_ENDPOINT__}/logs`,p=Object.assign({sdk:d.env.__SDK_VERSION__,bw:(0,s.detectBrowser)(),app:"service-worker"===e?"new-service-worker":"web-sdk",name:t.name,data:t.details||{},message:t.message,stacktrace:(null===(n=t.stack)||void 0===n?void 0:n.toString())||(null===(o=(new Error).stack)||void 0===o?void 0:o.toString()),type:t.type,url:location.href},i);yield(0,r.sendHttpRequest)(g,{method:"POST",body:JSON.stringify(p),mode:"no-cors"})}catch(e){a.default.error("Error occurred while sending error logs",e)}}))},4897:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendGoal=void 0;const r=i(6280),s=i(9933),a=i(2381),d=i(5967),c=i(561),l=i(5298),u=o(i(1762));t.sendGoal=({goal:e,siteId:t,subscriberId:i})=>n(void 0,void 0,void 0,(function*(){if(u.default.debug("The goal is being sent for the subscriber."),!(0,d.isObject)(e))throw new Error("Goal must be an object.");const n=(0,r.detectBrowser)(),o=(0,s.addQueryParamsToUrl)(`${c.env.__SUBSCRIBER_API_ENDPOINT__}/goals`,{swv:c.env.__WORKER_VERSION__,bv:n.version}),g={method:"POST",body:JSON.stringify(Object.assign(Object.assign({},e),{site_id:t,device_token_hash:i})),retries:3},p=yield(0,a.sendHttpRequest)(o,g);p.ok||(yield(0,l.throwDexterAPIError)(p,"Couldn't send goal.",{url:o,options:g})),u.default.debug("The goal has been sent for the subscriber.")}))},5298:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSubscriberDataFromStorageOrAPI=t.throwDexterAPIError=void 0;const r=i(2381),s=o(i(1762)),a=i(6280),d=i(3502),c=i(9933),l=i(5967),u=i(561),g=o(i(6920)),p=o(i(612));t.throwDexterAPIError=(e,t,i)=>n(void 0,void 0,void 0,(function*(){var n,o;const r=t||"Something went wrong.";let a={},d="";try{const t=yield e.json();t&&t.error&&(d=`${(0,l.capitalizeFirstLetter)((null===(n=t.error)||void 0===n?void 0:n.message)||t.error_message)}.`,a=(null===(o=t.error)||void 0===o?void 0:o.details)||{})}catch(e){s.default.debug("Failed to parse json response",e)}throw new g.default({details:{details:i,resDetails:a,resMessage:d},message:r,type:g.default.ERROR_TYPE.DexterServerError})}));t.getSubscriberDataFromStorageOrAPI=e=>n(void 0,void 0,void 0,(function*(){try{yield p.default.acquireLock("getSubscriberDataFromStorageOrAPI");const t=(0,d.getSubscriberDataFromStorage)();if(t)return t;const i=(0,a.detectBrowser)(),n=(0,c.addQueryParamsToUrl)(`${u.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${e}`,{swv:u.env.__WORKER_VERSION__,bv:i.version}),o=yield(0,r.sendHttpRequest)(n,{retries:3});if(!o.ok)return s.default.debug("Response not ok:",o),null;const g=yield o.json();if(null==g?void 0:g.error_code)return s.default.debug("response of error:",g),null;if((0,l.isEmptyObject)(null==g?void 0:g.data))return null;const b=(e=>Object.assign(Object.assign({},e),{attributes:e.attributes||{},segments:e.segments||[],trigger_status:(0,l.isUndefined)(e.trigger_status)?1:e.trigger_status}))(null==g?void 0:g.data);return(0,d.addSubscriberDataToStorage)(b),s.default.debug("The subscriber data is stored in the storage."),b}catch(e){return s.default.debug("Error occurred:",e),null}finally{p.default.releaseLock("getSubscriberDataFromStorageOrAPI")}}))},4449:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchPayloadNotifications=t.sendNotificationViewedReferAnalytics=t.fetchPayloadLessNotifications=t.sendNotificationClickedAnalytics=t.sendNotificationViewedAnalytics=void 0;const r=i(9933),s=i(6280),a=i(7641),d=i(2381),c=o(i(6920)),l=i(561),u=i(5298);t.sendNotificationViewedAnalytics=({tag:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,s.detectBrowser)(),i=(0,r.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/view`,{tag:e,swv:l.env.__WORKER_VERSION__,bv:t.version,tz:(0,a.getTimezoneOffset)()}),n={retries:3},o=yield(0,d.sendHttpRequest)(i,n);o.ok||(yield(0,u.throwDexterAPIError)(o,"Couldn't send notification view analytics.",{options:n,url:i}))}));t.sendNotificationClickedAnalytics=({tag:e,action:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,s.detectBrowser)(),n=(0,r.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/click`,{tag:e,action:t,swv:l.env.__WORKER_VERSION__,bv:i.version,tz:(0,a.getTimezoneOffset)()}),o={retries:3},c=yield(0,d.sendHttpRequest)(n,o);c.ok||(yield(0,u.throwDexterAPIError)(c,"Couldn't send notification click analytics to server.",{url:n,options:o}))}));t.fetchPayloadLessNotifications=e=>n(void 0,void 0,void 0,(function*(){const t=(0,s.detectBrowser)(),i=(0,r.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification`,{swv:l.env.__WORKER_VERSION__,device_token_hash:e,bv:t.version}),n=yield(0,d.sendHttpRequest)(i,{retries:3});if(!n.ok)throw new c.default({message:`Failed to fetch push payload for subscriber id ${e} with status ${n.status}.`,name:c.default.ERROR_NAME.PayloadLessFetchError,details:{status:n.status,url:n.url,origin:self.location.href}});let o;try{o=yield n.json()}catch(e){throw new c.default({message:`Parsing of the notification payload failed, ${e.message}`,name:c.default.ERROR_NAME.PayloadLessParseError,details:{status:n.status,url:n.url}})}if(Array.isArray(o)&&o.length)return o;throw new c.default({message:`Received empty/invalid payload less notification from subscriber id ${e}.`,name:c.default.ERROR_NAME.PayloadLessInvalidNotificationPayload,details:{responseData:o,url:n.url,status:n.status}})}));t.sendNotificationViewedReferAnalytics=({tag:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,r.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/view/refer`,{tag:e}),i={retries:2},n=yield(0,d.sendHttpRequest)(t,i);n.ok||(yield(0,u.throwDexterAPIError)(n,"Couldn't send notification view refer analytics to server.",{url:t,options:i}))}));t.fetchPayloadNotifications=({tag:e,postback:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,s.detectBrowser)(),n=(0,r.addQueryParamsToUrl)(`${l.env.__ANALYTICS_API_ENDPOINT__}/notification/fetch`,{tag:e,swv:l.env.__WORKER_VERSION__,bv:i.version}),o=yield(0,d.sendHttpRequest)(n,{method:"POST",body:JSON.stringify({tag:e,postback:t}),retries:3});if(!o.ok)throw new c.default({message:`Failed to fetch push payload for tag ${e} with status ${o.status}.`,name:c.default.ERROR_NAME.PushPayloadFetchError,details:{status:o.status,url:o.url,origin:self.location.href}});let a;try{a=yield o.json()}catch(e){throw new c.default({message:`Parsing of the notification payload failed, ${e.message}`,name:c.default.ERROR_NAME.NotificationParseError,details:{status:o.status,url:o.url}})}if(Array.isArray(null==a?void 0:a.data)&&a.data.length)return a.data;throw new c.default({message:`Received empty/invalid response from tag ${e}.`,name:c.default.ERROR_NAME.InvalidNotificationPayload,details:{responseData:a,url:o.url,status:o.status}})}))},3876:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendOptInAnalytics=void 0;const r=i(2381),s=i(561),a=o(i(6920));t.sendOptInAnalytics=e=>n(void 0,void 0,void 0,(function*(){const t={Data:e,PartitionKey:"optin_analytics"},i=s.env.__OPT_IN_ANALYTICS_API_ENDPOINT__;try{if(!(yield(0,r.sendHttpRequest)(i,{method:"PUT",body:JSON.stringify(t),retries:3})).ok)throw new Error("Couldn't send opt-in analytics event.")}catch(e){throw new a.default({message:e.message,name:a.default.ERROR_NAME.SendOptInAnalyticsError,details:{body:t,requestUrl:i}})}}))},7340:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setProfileIdToSubscriber=void 0;const d=i(2381),c=a(i(1762)),l=i(6280),u=i(3502),g=i(9933),p=r(i(6592)),b=i(5298),f=i(561);t.setProfileIdToSubscriber=({profileId:e,siteId:t,subscriberId:i})=>s(void 0,void 0,void 0,(function*(){c.default.debug("The profile id is being set for the subscriber."),p.profileId(e);const n=yield(0,b.getSubscriberDataFromStorageOrAPI)(i);if((null==n?void 0:n.profile_id)===e)return void c.default.debug("The profile id is already set for the subscriber.");const o=(0,l.detectBrowser)(),r={device_token_hash:i,profile_id:e,site_id:t},s=(0,g.addQueryParamsToUrl)(`${f.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/profile-id/add`,{swv:f.env.__WORKER_VERSION__,bv:o.version}),a={method:"POST",body:JSON.stringify(r),retries:2},m=yield(0,d.sendHttpRequest)(s,a);m.ok||(yield(0,b.throwDexterAPIError)(m,"Couldn't set profile id to subscriber.",{url:s,options:a})),c.default.debug("The profile id has been set for the subscriber."),(0,u.updateSubscriberDataToStorage)({profile_id:e})}))},1409:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addSegmentWithDurationToSubscriber=t.removeSegmentFromSubscriber=t.addSegmentToSubscriber=void 0;const d=i(2381),c=a(i(1762)),l=i(6280),u=i(3502),g=i(9933),p=i(5967),b=r(i(5133)),f=i(5298),m=i(561),v=(e,t)=>{let i=!0;for(let n=0;ns(void 0,void 0,void 0,(function*(){const t=yield(0,f.getSubscriberDataFromStorageOrAPI)(e);return(null==t?void 0:t.segments)&&Array.isArray(t.segments)?t.segments:[]}));t.addSegmentToSubscriber=({segment:e,siteId:t,subscriberId:i})=>s(void 0,void 0,void 0,(function*(){b.segment(e);const n=Array.isArray(e)?e:[e],o=yield _(i);if(v(o,n))return void c.default.debug(`The subscriber has already been added to the segment: ${n}.`);const r=(0,l.detectBrowser)(),s={device_token_hash:i,segment:(0,p.uniqueArray)(n),site_id:t},a=(0,g.addQueryParamsToUrl)(`${m.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/segments/add`,{swv:m.env.__WORKER_VERSION__,bv:r.version}),h={method:"POST",body:JSON.stringify(s),retries:2},y=yield(0,d.sendHttpRequest)(a,h);y.ok||(yield(0,f.throwDexterAPIError)(y,"Couldn't add the subscriber to the segment.",{url:a,options:h})),c.default.debug(`The subscriber has been added to the segment: ${n}.`),(0,u.updateSubscriberDataToStorage)({segments:(0,p.uniqueArray)([...o,...n])})}));t.removeSegmentFromSubscriber=({segment:e,siteId:t,subscriberId:i})=>s(void 0,void 0,void 0,(function*(){b.segment(e);const n=Array.isArray(e)?e:[e],o=yield _(i);if(!v(o,n))return void c.default.debug(`The subscriber does not belong to the segment: ${n}.`);const r=(0,l.detectBrowser)(),s={device_token_hash:i,segment:(0,p.uniqueArray)(n),site_id:t},a=(0,g.addQueryParamsToUrl)(`${m.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/segments/remove`,{swv:m.env.__WORKER_VERSION__,bv:r.version}),h={method:"POST",body:JSON.stringify(s),retries:2},y=yield(0,d.sendHttpRequest)(a,h);y.ok||(yield(0,f.throwDexterAPIError)(y,"Couldn't remove the subscriber from the segment.",{url:a,options:h}));const w=o.filter((e=>!n.includes(e)));c.default.debug(`The subscriber has been removed from the segment: ${n}.`),(0,u.updateSubscriberDataToStorage)({segments:w})}));t.addSegmentWithDurationToSubscriber=({segment:e,siteId:t,subscriberId:i})=>s(void 0,void 0,void 0,(function*(){b.segmentWithDuration(e);const n=Array.isArray(e)?e:[e],o=n.map((e=>e.name)),r=yield _(i),s=(0,l.detectBrowser)(),a={device_token_hash:i,segments:n,site_id:t},v=(0,g.addQueryParamsToUrl)(`${m.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/dynamicSegments/add`,{swv:m.env.__WORKER_VERSION__,bv:s.version}),h={method:"POST",body:JSON.stringify(a),retries:2},y=yield(0,d.sendHttpRequest)(v,h);y.ok||(yield(0,f.throwDexterAPIError)(y,"Couldn't add the subscriber to the segment.",{url:v,options:h})),c.default.debug(`The subscriber has been added to the segment with the specified duration: ${o}.`),(0,u.updateSubscriberDataToStorage)({segments:(0,p.uniqueArray)([...r,...o])})}))},1950:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getCartItems=t.getProductByTitle=t.isUrlReachable=void 0;const r=i(2381),s=o(i(1762)),a=i(5967);t.isUrlReachable=e=>n(void 0,void 0,void 0,(function*(){return!!(yield(0,r.sendHttpRequest)(e)).ok}));t.getProductByTitle=e=>n(void 0,void 0,void 0,(function*(){const t=yield(0,r.sendHttpRequest)(`/products/${e}.js`,{retries:1});if(!t.ok)return s.default.debug("Response not ok to get products:",t),null;try{const e=yield t.json();return(0,a.isObject)(e)?e:null}catch(e){return s.default.debug("Error occurred:",e),null}}));t.getCartItems=()=>n(void 0,void 0,void 0,(function*(){const e=yield(0,r.sendHttpRequest)("/cart.js",{retries:1});if(!e.ok)return s.default.debug("Response not ok to get cart items:",e),[];try{const t=yield e.json();if(!(0,a.isObject)(t))return[];const{items:i}=t;return Array.isArray(i)?i:[]}catch(e){return s.default.debug("Error occurred:",e),[]}}))},2044:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logout=t.identify=t.updateAutomatedNotificationStatus=t.updateSubscriberStatus=t.syncSubscriberData=t.upsertSubscriberDataToSite=t.getSubscriberData=void 0;const d=i(2381),c=i(7641),l=a(i(1762)),u=i(3502),g=i(9933),p=i(5967),b=i(5298),f=i(6280),m=a(i(6920)),v=i(561),_=r(i(5548)),h=e=>{const t={geobytestimezone:(null==e?void 0:e.timezone)||(0,c.getTimezoneName)()||(0,c.getTimezoneOffset)()};if(!e)return t;return["country","internet","region","code","city","fqcn","ipaddress"].forEach((i=>{e[i]&&(t[`geobytes${i}`]=e[i])})),t},y=()=>s(void 0,void 0,void 0,(function*(){var e;const t=`${v.env.__TABOOLA_API_ENDPOINT__}/json/pushengage1-new/user.sync?app.type=web&app.apikey=${v.env.__TABOOLA_API_KEY__}`;try{const i=yield(0,d.sendHttpRequest)(t);if(i.ok&&200===i.status){const t=yield i.json();return(null===(e=null==t?void 0:t.user)||void 0===e?void 0:e.id)||null}return null}catch(e){return l.default.debug("Error occurred during getting taboola ads user id:",e),null}}));t.getSubscriberData=e=>s(void 0,void 0,void 0,(function*(){let t=null;try{t=yield(0,b.getSubscriberDataFromStorageOrAPI)(e)}catch(e){l.default.debug("Error occurred:",e)}return t}));t.upsertSubscriberDataToSite=({browserInfo:e,site:t,subscription:i,options:n={},subscriberId:o})=>s(void 0,void 0,void 0,(function*(){var r,s;const a=h(n.geoInfo),c={subscription:i,site_id:t.site_id,browser_info:{device_type:e.name,browser_version:e.version.toString(),user_agent:e.userAgent,language:e.language,total_scr_width_height:e.screen,available_scr_width_height:e.availableScreen,colour_resolution:e.pixelDepth,host:e.host,device:e.device,pe_ref_url:e.referrer||e.href},geo_info:a,subscription_url:e.href,token_refresh:null!==(r=n.tokenRefresh)&&void 0!==r&&r};if(n.isPublisherSettingEnabled)try{const e=yield y();e&&(c.tid=e)}catch(e){l.default.debug("Couldn't get Taboola Ads User ID",e)}n.widgetOptInType?c.widget_optin_type=n.widgetOptInType:n.optInType&&(c.optin_type=n.optInType);let u="subscriber/add",p="POST";o&&(u="subscriber/upgrade",p="PUT",c.device_token_hash=o);const f=(0,g.addQueryParamsToUrl)(`${v.env.__SUBSCRIBER_API_ENDPOINT__}/${u}`,{bv:e.version,swv:v.env.__WORKER_VERSION__}),_={method:p,body:JSON.stringify(c),retries:4},w=yield(0,d.sendHttpRequest)(f,_);let S;w.ok||(yield(0,b.throwDexterAPIError)(w,"Couldn't add subscriber.",{url:f,options:_}));try{S=yield w.json()}catch(e){throw new m.default({message:"Error parsing response from add subscriber.",name:m.default.ERROR_NAME.SubscriberAdditionServerError})}if(S.error_code)throw new m.default({message:`Couldn't add subscriber. Error code: ${S.error_code}.`,name:m.default.ERROR_NAME.SubscriberAdditionServerError});if(!(null===(s=S.data)||void 0===s?void 0:s.subscriber_hash))throw new m.default({message:"Couldn't add subscriber. Subscriber hash is not available.",name:m.default.ERROR_NAME.SubscriberHashNotAvailableServerError});return S.data.subscriber_hash}));t.syncSubscriberData=({browserInfo:e,geoInfo:t,subscriberId:i,isPublisherSettingEnabled:n})=>s(void 0,void 0,void 0,(function*(){const o=yield(0,b.getSubscriberDataFromStorageOrAPI)(i);if(!o)return;const r=navigator.userAgent,s=(null==t?void 0:t.timezone)||(0,c.getTimezoneName)()||(0,c.getTimezoneOffset)(),a={};let f=!1;if(o.user_agent!==r&&(a.browser_info={user_agent:r,browser_version:e.version.toString(),device_type:e.name,language:e.language,total_scr_width_height:e.screen,available_scr_width_height:e.availableScreen,colour_resolution:e.pixelDepth,device:e.device}),!t||o.city===t.city&&o.timezone===s&&o.country===t.country&&o.state===t.state||(a.geo_info=h(t),f=!0),n&&(!o.tid||f)){const e=yield y();a.tid=e}if((0,p.isEmptyObject)(a))return void l.default.debug("The subscriber data is up to date.");const m=(0,g.addQueryParamsToUrl)(`${v.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${i}`,{swv:v.env.__WORKER_VERSION__,bv:e.version});if((yield(0,d.sendHttpRequest)(m,{method:"PUT",body:JSON.stringify(a),retries:2})).ok){const i={timezone:s,city:null==t?void 0:t.city,country:null==t?void 0:t.country,state:null==t?void 0:t.region,user_agent:r,device_type:e.name,device:e.device};a.tid&&(i.tid=a.tid),(0,u.updateSubscriberDataToStorage)(i),l.default.debug("The subscriber data has been updated in the storage.")}}));t.updateSubscriberStatus=({status:e,subscriberId:t,siteId:i})=>s(void 0,void 0,void 0,(function*(){const n=(0,f.detectBrowser)(),o=(0,g.addQueryParamsToUrl)(`${v.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/updatesubscriberstatus`,{swv:v.env.__WORKER_VERSION__,bv:n.version}),r={method:"POST",body:JSON.stringify({IsUnSubscribed:"unsubscribe"===e?1:0,device_token_hash:t,site_id:i}),retries:3},s=yield(0,d.sendHttpRequest)(o,r);s.ok||(yield(0,b.throwDexterAPIError)(s,"Couldn't update subscriber status.",{url:o,options:r}))}));t.updateAutomatedNotificationStatus=({status:e,subscriberId:t,siteId:i})=>s(void 0,void 0,void 0,(function*(){const n="disabled"===e?0:1,o=yield(0,b.getSubscriberDataFromStorageOrAPI)(t);if((null==o?void 0:o.trigger_status)===n)return;const r=(0,f.detectBrowser)(),s=(0,g.addQueryParamsToUrl)(`${v.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/updatetriggerstatus`,{swv:v.env.__WORKER_VERSION__,bv:r.version}),a={method:"POST",body:JSON.stringify({triggerStatus:n,device_token_hash:t,site_id:i}),retries:2},c=yield(0,d.sendHttpRequest)(s,a);c.ok||(yield(0,b.throwDexterAPIError)(c,"Couldn't update automated Notification status.",{url:s,options:a})),(0,u.updateSubscriberDataToStorage)({trigger_status:n})}));t.identify=({subscriberFields:e,subscriberId:t})=>s(void 0,void 0,void 0,(function*(){_.identify(e);const i=(e=>{const t={};for(const i in e)"profile_id"===i&&(t[i]=e[i].toString());return Object.assign(Object.assign({},e),t)})(e),n=yield(0,b.getSubscriberDataFromStorageOrAPI)(t);if(!n||(({subscriberData:e,subscriberFields:t})=>{if((0,p.isEmptyObject)(t))return!1;let i=!0;for(const n in t)if(t[n]!==e[n]){i=!1;break}return i})({subscriberData:n,subscriberFields:i}))return;const o=(0,f.detectBrowser)(),r=(0,g.addQueryParamsToUrl)(`${v.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${t}`,{swv:v.env.__WORKER_VERSION__,bv:o.version}),s={method:"PUT",body:JSON.stringify(i),retries:2},a=yield(0,d.sendHttpRequest)(r,s);a.ok||(yield(0,b.throwDexterAPIError)(a,"Couldn't update subscriber fields.",{url:r,options:s})),l.default.debug("The subscriber fields have been updated for the subscriber."),(0,u.updateSubscriberDataToStorage)(i)}));t.logout=({subscriberFieldNames:e=[],subscriberId:t})=>s(void 0,void 0,void 0,(function*(){let i;i=Array.isArray(e)&&!e.length?["first_name","last_name","email","phone","gender","dob","profile_id"]:e,_.logout(i);const n=yield(0,b.getSubscriberDataFromStorageOrAPI)(t);if(!n||!(({subscriberFieldNames:e,subscriberData:t})=>{for(const i of e)if((0,p.hasOwn)(t,i))return!0;return!1})({subscriberData:n,subscriberFieldNames:i}))return;const o=(0,f.detectBrowser)(),r=(0,g.addQueryParamsToUrl)(`${v.env.__SUBSCRIBER_API_ENDPOINT__}/subscriber/${t}/fields`,{swv:v.env.__WORKER_VERSION__,bv:o.version}),s={method:"DELETE",body:JSON.stringify(i),retries:2},a=yield(0,d.sendHttpRequest)(r,s);a.ok||(yield(0,b.throwDexterAPIError)(a,"Couldn't remove subscriber fields.",{url:r,options:s})),l.default.debug("The subscriber fields have been removed from the subscriber."),(0,u.deleteSubscriberFieldsFromStorage)(i)}))},8076:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendTriggerEvent=void 0;const d=i(2381),c=r(i(860)),l=i(561),u=a(i(1762)),g=i(7641);t.sendTriggerEvent=({trigger:e,subscriberId:t,siteId:i})=>s(void 0,void 0,void 0,(function*(){u.default.debug("The trigger event is being sent for the subscriber."),c.sendTriggerEvent(e);const n=l.env.__TRIGGER_API_ENDPOINT__;if(!(yield(0,d.sendHttpRequest)(n,{method:"PUT",body:JSON.stringify({Data:Object.assign(Object.assign({},e),{site_id:i,device_token_hash:t,timezone:(0,g.getTimezoneOffset)()}),PartitionKey:t})})).ok)throw new Error("Couldn't send trigger event.");u.default.debug("The trigger event has been sent for the subscriber.")}))},1654:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addAlert=void 0;const n=i(5967);t.addAlert=e=>{if(!(0,n.isObject)(e))throw new Error("Alert must be an object.");if("inventory"!==e.type&&"price_drop"!==e.type)throw new Error("Alert type must be either inventory or price_drop.");if(!e.product_id)throw new Error("Product ID is required.");if(!e.price)throw new Error("Price is required.");if("number"!=typeof e.price&&"string"!=typeof e.price)throw new Error("Price must be a number.");if(e.alert_price&&"number"!=typeof e.alert_price&&"string"!=typeof e.alert_price)throw new Error("Alert price must be a number.");if(e.availability&&"inStock"!==e.availability&&"outOfStock"!==e.availability)throw new Error("Availability must be either inStock or outOfStock.")}},3271:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addAttributes=void 0;const n=i(5967);t.addAttributes=e=>{if(!(0,n.isObject)(e))throw new Error("Attributes must be an object.");if((0,n.isEmptyObject)(e))throw new Error("Attributes must not be empty.")}},6592:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.profileId=void 0;t.profileId=e=>{if(!e)throw new Error("Profile ID is required.");if("string"!=typeof e)throw new Error("Profile ID must be a string.")}},5133:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.segmentWithDuration=t.segment=void 0;const n=i(1119);function o(e){if(!(e=>{const t=(0,n.getAppData)().segments.map((e=>e.segment_name));return"string"==typeof e?t.includes(e):e.some((e=>t.includes(e)))})(e))throw new Error("This segment does not belong to your site. Please check the spelling and the uppercase and lowercase letters of the name.")}t.segment=e=>{if(!e)throw new Error("Segment is required.");const t=Array.isArray(e)?e:[e];if(0===t.length)throw new Error("Segment is required.");for(let e=0;e{if(!e)throw new Error("Payload is required. It should be an object or an array of objects.");if(Array.isArray(e)&&0===e.length)throw new Error('At least one item should be available in the payload. The payload must include the "name" and "duration" keys, e.g., [{ name: \'segmentName\', duration: 10 }].');const t=Array.isArray(e)?e:[e];for(let e=0;ee.name)))}},5548:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logout=t.identify=void 0;const n=i(5967),o=i(561);t.identify=e=>{if(!e)throw new Error("Payload is required. The payload should be in object format, e.g., {key: value}.");if(!(0,n.isObject)(e))throw new Error("Payload must be an object.");if((0,n.isEmptyObject)(e))throw new Error("Payload must have at least one key.");for(const t in e){if("string"!=typeof t)throw new Error("Key must be a string.");if(!o.validSubscriberFields.includes(t)){let e="";throw o.validSubscriberFields.forEach(((t,i)=>{e=i===o.validSubscriberFields.length-1?`${e}, and ${t}`:e?`${e}, ${t}`:t})),new Error(`Key ${t} is not valid. Valid keys are ${e}.`)}}for(const t in e){const i=e[t];if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)throw new Error("Value must be a string, number, or boolean.")}};t.logout=e=>{if(!e)throw new Error("Subscriber field names are required.");if(!Array.isArray(e))throw new Error("Subscriber field names must be an array.");for(const t of e){if("string"!=typeof t)throw new Error("Subscriber field name must be a string.");if(!o.validSubscriberFields.includes(t)){let e="";throw o.validSubscriberFields.forEach(((t,i)=>{e=i===o.validSubscriberFields.length-1?`${e}, and ${t}`:e?`${e}, ${t}`:t})),new Error(`Subscriber field name ${t} is not valid. Valid names are ${e}.`)}}}},860:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sendTriggerEvent=void 0;const n=i(5967);t.sendTriggerEvent=e=>{if(!(0,n.isObject)(e))throw new Error("Trigger event must be an object.");if(!e.campaign_name)throw new Error("Trigger event must have a campaign name.");if(!e.event_name)throw new Error("Trigger event must have a event name.")}},1119:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKInitOptions=t.getAppData=t.setSDKInitOptions=t.setAppData=void 0;const i=new class{set appData(e){this._appData=e}get appData(){if(!this._appData)throw new Error("appData has not been set yet.");return this._appData}set sdkInitOptions(e){this._sdkInitOptions=e}get sdkInitOptions(){if(!this._sdkInitOptions)throw new Error("sdkInitOptions has not been set yet.");return this._sdkInitOptions}};t.setAppData=function(e){i.appData=e},t.setSDKInitOptions=function(e){i.sdkInitOptions=e},t.getAppData=function(){return i.appData},t.getSDKInitOptions=function(){return i.sdkInitOptions}},561:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logDisplayEnabledKey=t.validSubscriberFields=t.skipQueryParamsInWorkerPathSiteIds=t.brandName=t.quieterUIPermissionImage=t.env=t.workerMessengerCommand=t.database=t.defaultMinStorageDuration=t.poweredByReferralUrl=t.pushEngageHomePageUrl=t.defaultNotificationTitle=t.defaultNotificationTag=t.loadingIcon=t.bellPlusIcon=t.bellCheckIcon=t.bellCircleIcon=t.bellRingIcon=t.bellBadgeIcon=t.bellSettingIcon=t.closeIcon=t.bellIcon=t.defaultServiceWorkerSetting=t.widgetOptInType=t.optInTypes=t.storageName=void 0,t.storageName="PushEngageSDK",t.optInTypes={bell:3,floatingBar:2,largeSafari:6,largeSafariWithSegments:8,safari:1,singleStep:4,sleekOptInBox:9},t.widgetOptInType=127,t.defaultServiceWorkerSetting={scope:!0,workerStatus:!0,worker:"service-worker.js",keepMultipleSubscriptions:!1},t.bellIcon='\n\n\n',t.closeIcon='\n\n',t.bellSettingIcon='',t.bellBadgeIcon='',t.bellRingIcon='',t.bellCircleIcon='',t.bellCheckIcon='',t.bellPlusIcon='',t.loadingIcon='',t.defaultNotificationTag="welcome_notification",t.defaultNotificationTitle="Click to see updates",t.pushEngageHomePageUrl="https://www.pushengage.com/",t.poweredByReferralUrl=`${t.pushEngageHomePageUrl}?utm_medium=referral&utm_campaign=powered_by&utm_source=pushengage_sdk`,t.defaultMinStorageDuration=7,t.database={name:"PushEngageSDK",stores:[{name:"ids",keyPath:"id"},{name:"failedViewedNotificationTags",keyPath:"id"},{name:"failedClickedNotificationTags",keyPath:"id"}],version:1},t.workerMessengerCommand={ampSubscriptionState:"amp-web-push-subscription-state",ampSubscribe:"amp-web-push-subscribe",ampUnsubscribe:"amp-web-push-unsubscribe"},t.env={__CDN_SERVER_HOST__:"https://clientcdn.pushengage.com",__SERVER_HOST__:"https://web-sdk.pushengage.com",__SAFARI_WEB_PUSH_PACKAGE_URL__:"https://safari.pushengage.com",__SUBSCRIBER_API_ENDPOINT__:"https://clients-api.pushengage.com/p/v1",__ANALYTICS_API_ENDPOINT__:"https://noti-analytics.pushengage.com/p/v1",__LOG_API_ENDPOINT__:"https://notify.pushengage.com/v1",__DOMAIN_NAME__:"pushengage.com",__OPT_IN_ANALYTICS_API_ENDPOINT__:"https://oeqepmcz7a.execute-api.us-east-1.amazonaws.com/beta/streams/optin/records",__SDK_VERSION__:"3.0.52",__WORKER_VERSION__:"3.0.52",__TABOOLA_API_ENDPOINT__:"https://api.taboola.com/1.2",__TABOOLA_API_KEY__:"a460a30141a022c6dc01526bba996da108798fd0",__TRIGGER_API_ENDPOINT__:"https://m4xrk918t5.execute-api.us-east-1.amazonaws.com/beta/streams/production_triggers/records",__STATIC_STORAGE_ENDPOINT__:"https://assetscdn.pushengage.com"},t.quieterUIPermissionImage={firefox:`${t.env.__STATIC_STORAGE_ENDPOINT__}/react-dashboard/design/reminder-firefox.png`,chrome:`${t.env.__STATIC_STORAGE_ENDPOINT__}/react-dashboard/design/reminder-chrome.png`},t.brandName="PushEngage",t.skipQueryParamsInWorkerPathSiteIds=[60413],t.validSubscriberFields=["first_name","last_name","email","phone","gender","dob","language","profile_id","country","city","state","zip"],t.logDisplayEnabledKey="pushengage-log-display-enabled"},8553:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.transformSettings=t.transformServiceWorker=t.upgradeLegacyStorageData=t.validateRequiredSettings=void 0;const o=n(i(6920)),r=i(561),s=i(5967),a=i(3502),d=i(1119),c=i(6947),l=i(6485),u=i(7641),g=i(6347);t.validateRequiredSettings=({appData:e,sdkInitOptions:t})=>{const{optin_settings:i,vapid_key:n,gcm_options:r,privacy_settings:s,sub_analytics:a,service_worker:d,reset_notification_permission_popup:c,subscription_management_widget:l}=e.siteSettings;if(!(i&&n&&d&&r&&s&&a&&c&&l))throw new o.default({message:"Required setting are missing.",name:o.default.ERROR_NAME.RequiredSettingsMissing,details:{optin_settings:!!i,vapid_key:!!n,service_worker:!!d,gcm_options:!!r,privacy_settings:!!s,sub_analytics:!!a,reset_notification_permission_popup:!!c,subscription_management_widget:!!l,siteId:e.site.site_id}});if(!e.site)throw new o.default({message:"Site data is missing.",name:o.default.ERROR_NAME.SiteDataMissing,details:{appId:t.appId}})};t.upgradeLegacyStorageData=()=>{var e,t,i;const n=(0,d.getAppData)(),o=n.siteSettings.optin_settings,p=(0,l.getDataFromCookies)("peclosed"),b=(0,l.getDataFromCookies)("PushSubscriberStatus"),f=(0,l.getDataFromLocalStorage)("PushSubscriberHash"),m=(0,l.getDataFromLocalStorage)("PushSubscriberID"),v=["PushSubscriberHash","PushSubscriberID","PeSubData","PushSegments","PushBeforeSubData","PushSubscribeWidgetClosed","PushPersonalNotificationStatus","PushOptinReminder"];if((0,s.isNull)(p)&&!m&&!f&&!b)return;const _={},h=(0,g.getActiveOptInTypes)(o),y=(0,g.getSubscriptionOptIns)(o);let w=!0;for(let e=0;e{const e=(0,l.getDataFromLocalStorage)("PushBrowseStorageData"),t=(0,l.getDataFromLocalStorage)("PushCartStorageData"),i=(0,l.getDataFromLocalStorage)("pushPriceDropStorageData"),n=(0,l.getDataFromLocalStorage)("pushInventoryStorageData"),o={};if(e){const t=(0,s.convertStringToArray)(`${e}`).map((e=>(0,s.toInteger)(e)));o.browseVariantIds=t}if(t){const e=(0,s.convertStringToArray)(`${t}`).map((e=>(0,s.toInteger)(e)));o.cartVariantIds=e}if(i){const e=(0,s.convertStringToArray)(`${i}`).map((e=>(0,s.toInteger)(e)));o.priceDropVariantIds=e}if(n){const e=(0,s.convertStringToArray)(`${n}`).map((e=>(0,s.toInteger)(e)));o.backInStockVariantIds=e}return o})();return(0,s.isEmptyObject)(o)||(_.shopify=o),(0,l.setDataToLocalStorage)(r.storageName,_),(0,l.deleteDataFromLocalStorage)(v),void(0,l.deleteDataFromCookies)(["peclosed","PushSubscriberStatus"])}if("DENIED"===b){const e=(0,c.getNotificationPermission)({safariWebPushId:null===(i=n.siteSettings.safari_options)||void 0===i?void 0:i.push_id}),t=!(!w||"denied"!==e);return _.denied={data:{isSubDomain:!t,status:!0},expiresAt:(0,u.getUnixTime)(1)},(0,l.setDataToLocalStorage)(r.storageName,_),(0,l.deleteDataFromLocalStorage)(v),void(0,l.deleteDataFromCookies)(["peclosed"])}const S=(0,a.getParsedStorageData)("PushBeforeSubData"),I={};for(const e in S)if(e.includes("close_optin_id_")){const t=e.split("close_optin_id_")[1],i=S[e];I[t]={data:!0,expiresAt:i.max_age||(0,u.getUnixTime)(7)}}"CLOSED"===b&&h.length>0&&y.forEach((e=>{I[e.optin_type]={data:!0,expiresAt:(0,u.getUnixTime)(e.cookie_duration||7)}})),(0,s.isEmptyObject)(I)||(_.optInClosed=I,(0,l.setDataToLocalStorage)(r.storageName,_),(0,l.deleteDataFromLocalStorage)(v),(0,l.deleteDataFromCookies)(["peclosed","PushSubscriberStatus"]))};t.transformServiceWorker=({serviceWorkerSetting:e,sdkInitOptions:t,customSubDomainSetting:i,site:n})=>{const o=function(){var n,o,a,d,c,l,u,g,p,b,f,m,v,_;if(t.isSubscriptionOnSubDomain&&!i)return r.defaultServiceWorkerSetting;let{scope:h,workerStatus:y,worker:w,keepMultipleSubscriptions:S}=e;return t.isShopifySite&&(w="/apps/pushengage/service-worker.js",h=!1),(0,s.isUndefined)(window.pathvars)||(w=null!==(o=null===(n=window.pathvars)||void 0===n?void 0:n.worker)&&void 0!==o?o:w,y=null!==(d=null===(a=window.pathvars)||void 0===a?void 0:a.workerStatus)&&void 0!==d?d:y,h=null!==(l=null===(c=window.pathvars)||void 0===c?void 0:c.scope)&&void 0!==l?l:h),(0,s.isObject)(t.serviceWorker)&&(w=null!==(g=null===(u=t.serviceWorker)||void 0===u?void 0:u.path)&&void 0!==g?g:w,y=null!==(b=null===(p=t.serviceWorker)||void 0===p?void 0:p.status)&&void 0!==b?b:y,h=null!==(m=null===(f=t.serviceWorker)||void 0===f?void 0:f.scope)&&void 0!==m?m:h,S=null!==(_=null===(v=t.serviceWorker)||void 0===v?void 0:v.keepMultipleSubscriptions)&&void 0!==_?_:S),{scope:h,workerStatus:y,worker:w,keepMultipleSubscriptions:S}}();if(!r.skipQueryParamsInWorkerPathSiteIds.includes(n.site_id)){const{worker:e}=o,i=`v=${r.env.__WORKER_VERSION__}&appId=${t.appId}`;o.worker=e.includes("?")?`${e}&${i}`:`${e}?${i}`}return o};t.transformSettings=({appData:e,sdkInitOptions:i})=>{e.siteSettings.service_worker=(0,t.transformServiceWorker)({sdkInitOptions:i,serviceWorkerSetting:e.siteSettings.service_worker,customSubDomainSetting:e.siteSettings.custom_url,site:e.site})}},9735:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(1340),s=o(i(1762)),a=i(2610),d=o(i(6920)),c=i(7008),l=i(5471),u=i(2033),g=i(3101),p=i(8350),b=i(5872),f=i(4986),m=i(8919),v=i(2143),_=i(3044),h=i(5971),y=i(5967),w=i(1119),S=i(8553),I=i(4970);n(void 0,void 0,void 0,(function*(){try{const e=window.__PushEngageSDKInitOptions;if(!e)throw new d.default({message:"Initialization options have not been provided.",name:d.default.ERROR_NAME.SDKInitOptionsNotFound,details:{url:location.href}});let t;(0,w.setSDKInitOptions)(e);try{t=yield(0,h.getAppData)({appId:e.appId})}catch(e){return void s.default.error(e.message)}if(!t||(0,y.isEmptyObject)(t)){const e="App data is not available.";return void s.default.error(e)}(0,S.validateRequiredSettings)({appData:t,sdkInitOptions:e}),(0,S.transformSettings)({appData:t,sdkInitOptions:e}),(0,w.setAppData)(t),yield(0,r.isDOMContentLoaded)(),(0,S.upgradeLegacyStorageData)(),(0,l.addClickEventListenerForHandleSubscription)(),(0,c.addMessageEventListener)(),(0,p.addEventListenerForUnsubscribeWidget)(),(0,b.addEventListenerForSubscriberRecoveryWidget)(),(0,f.addEventListenerForAddSegment)(),(0,m.addEventListenerForShopifyCampaign)(),(0,v.addEventListenerForSubscriptionManagementWidget)(),(0,_.processFailedAnalytics)(),(0,I.syncDatabase)();const i=window.PushEngage,n=window._peq;(0,u.initializeSDK)({commands:i,legacyCommands:n}),yield(0,g.initializeSubscription)({triggerFrom:"onInit"}),s.default.debug("The subscription process has been completed on page load.")}catch(e){s.default.error(e.message),(0,a.sendErrorLog)("sdk",e,{url:location.href})}}))},6920:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class i extends Error{constructor({message:e,name:t="AppError",details:i={},type:n="Error"}){super(e),this.details=i,this.name=t,this.type=n}}i.ERROR_NAME={InvalidAppId:"InvalidAppId",UnsubscribedFailedFromWorker:"UnsubscribedFailedFromWorker",NotPushEngagePayload:"NotPushEngagePayload",PayloadLessInvalidNotificationPayload:"PayloadLessInvalidNotificationPayload",InvalidNotificationPayload:"InvalidNotificationPayload",PushPayloadParseError:"PushPayloadParseError",OfflineError:"OfflineError",OpenNotificationUrlFailed:"OpenNotificationUrlFailed",SendOptInAnalyticsError:"SendOptInAnalyticsError",QuotaExceededError:"QuotaExceededError",DisabledPushSubscriptionError:"DisabledPushSubscriptionError",IndexedDBOpenError:"IndexedDBOpenError",UnknownError:"UnknownError",PayloadLessFetchError:"PayloadLessFetchError",PayloadLessParseError:"PayloadLessParseError",PushPayloadFetchError:"PushPayloadFetchError",NotificationParseError:"NotificationParseError",RequiredSettingsMissing:"RequiredSettingsMissing",SiteDataMissing:"SiteDataMissing",HttpRequestError:"HttpRequestError",UserNotSubscribed:"UserNotSubscribed",ServiceWorkerNotFound:"ServiceWorkerNotFound",ServiceWorkerNotRegistering:"ServiceWorkerNotRegistering",SDKInitOptionsNotFound:"SDKInitOptionsNotFound",RequestPermissionNotSupported:"RequestPermissionNotSupported",SubscriberAdditionServerError:"SubscriberAdditionServerError",SubscriberHashNotAvailableServerError:"SubscriberHashNotAvailableServerError",LocalStorageNotAvailable:"LocalStorageNotAvailable",SubscriptionAlreadyInitialized:"SubscriptionAlreadyInitialized",SubscriberIdNotFoundInDb:"SubscriberIdNotFoundInDb"},i.ERROR_TYPE={IndexedDBError:"IndexedDBError",DexterServerError:"DexterServerError"},i.ERROR_MESSAGE={InvalidAppId:"AppId is not defined.",UserNotSubscribed:"User is not subscribed."},t.default=i},6347:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.doSubscriptionManagementWidgetRulesPass=t.isSubscriptionManagementWidgetHasContent=t.triggerCampaignTypesAvailability=t.isServiceWorkerAvailable=t.getSegmentNamesFromRules=t.isServiceWorkerAvailabilityEnabled=t.getSubDomainSubscriptionUrl=t.canSubscribeViaServiceWorker=t.filterSubscriptionOptInsByRules=t.isSatisfyingSubscriptionRules=t.getSubscriptionOptIns=t.getActiveOptInTypes=t.isDeviceSatisfyingDeviceRules=t.isCountrySatisfyingCountryRules=t.isUrlSatisfyingUrlRules=void 0;const s=i(6280),a=i(9933),d=r(i(5967)),c=i(2919),l=i(561),u=i(1382),g=i(5967);t.isUrlSatisfyingUrlRules=(e,t=location.href)=>{const{include:i,exclude:n}=e;let o=!0;i&&(o=!!((0,g.isEmptyArray)(i.contains)&&(0,g.isEmptyArray)(i.start)&&(0,g.isEmptyArray)(i.exact))||(0,u.isUrlSatisfyingRules)(i,t));let r=!0;return n&&(r=!!((0,g.isEmptyArray)(n.contains)&&(0,g.isEmptyArray)(n.start)&&(0,g.isEmptyArray)(n.exact))||!(0,u.isUrlSatisfyingRules)(n,t)),o&&r};t.isCountrySatisfyingCountryRules=(e,t)=>{const{include_countries:i,exclude_countries:n}=e;let o=!0;(null==i?void 0:i.length)&&(o=i.some((e=>e.toLowerCase()===t.toLowerCase())));let r=!0;return(null==n?void 0:n.length)&&(r=!n.some((e=>e.toLowerCase()===t.toLowerCase()))),o&&r};t.isDeviceSatisfyingDeviceRules=(e,t)=>{const{include_devices:i,exclude_devices:n}=e;let o=!0;i&&i.length&&(o=i.some((e=>e.toLowerCase()===t.toLowerCase())));let r=!0;return n&&n.length&&(r=!n.some((e=>e.toLowerCase()===t.toLowerCase()))),o&&r};t.getActiveOptInTypes=e=>{const t=(0,a.detectSiteType)();return d.get(e,`activeOptin.${t}.types`)||[]};t.getSubscriptionOptIns=e=>{const t=e.optins;if(!t)return[];const i=(0,s.detectDeviceType)(),n=(0,a.detectSiteType)(),o=[];for(const e in t){const r=t[e],s=d.get(r,`${i}.${n}`);s&&o.push(s)}return o};t.isSatisfyingSubscriptionRules=(e,i)=>{if(!e)return!0;const n=i.country||"",o=(0,t.isCountrySatisfyingCountryRules)(e,n),r=(0,t.isUrlSatisfyingUrlRules)(e,location.href);return!(!o||!r)};t.filterSubscriptionOptInsByRules=(e,i,n)=>{const o=(0,t.getActiveOptInTypes)(e),r=(0,t.getSubscriptionOptIns)(e);if(!o.length||!r.length)return[];const s=i?[]:o;if(i)for(let e=0;e{const t=(0,a.detectSiteType)(),{name:i,version:n}=(0,s.detectBrowser)();return"Safari"===i&&n<=15||"http"!==t&&!!e};t.getSubDomainSubscriptionUrl=({customSubDomainSetting:e,siteSubDomain:t})=>e?{url:e.url,type:e.type}:{url:`https://${t}.${l.env.__DOMAIN_NAME__}/`,type:"window"};t.isServiceWorkerAvailabilityEnabled=e=>(0,t.getSubscriptionOptIns)(e).some((e=>e.optin_sw_support));t.getSegmentNamesFromRules=e=>{const i=[];if(!e)return i;const n=location.href;return e.forEach((e=>{e.add_segment_on_page_load&&e.segment_criteria&&(0,t.isUrlSatisfyingUrlRules)({include:e.segment_criteria.include,exclude:e.segment_criteria.exclude},n)&&i.push(e.segment_name)})),i};t.isServiceWorkerAvailable=({optInSetting:e})=>{let i=!0;return(0,t.getSubscriptionOptIns)(e).length&&(i=(0,t.isServiceWorkerAvailabilityEnabled)(e)),i};t.triggerCampaignTypesAvailability=({browseAbandonments:e,cartAbandonments:t,priceDropAlerts:i,backInStockAlerts:n,customTriggerCampaigns:o})=>{const r=e.filter((e=>"active"===e.status)),s=t.filter((e=>"active"===e.status)),a=i.filter((e=>"active"===e.status)),d=n.filter((e=>"active"===e.status)),c=o.filter((e=>"active"===e.status));return{hasBrowseAbandonment:!!r.length,hasCartAbandonment:!!s.length,hasPriceDropAlert:!!a.length,hasBackInStockAlert:!!d.length,hasCustomTriggerCampaign:!!c.length}};t.isSubscriptionManagementWidgetHasContent=({widgetSettings:e,permission:t})=>!!e.enabled&&("granted"!==t||!!(e.segment_preference.enabled||e.unsubscribe_options.enabled||e.personal_notification_options.enabled));t.doSubscriptionManagementWidgetRulesPass=({widgetSettings:e,geoInfo:i,deviceType:n})=>{if(!e.trigger_button.enabled)return!1;if(!e.trigger_button.rules.enabled)return!0;const o=e.trigger_button.rules;if(!(0,t.isCountrySatisfyingCountryRules)({include_countries:o.include_countries,exclude_countries:o.exclude_countries},i.country||""))return!1;if(!(0,t.isUrlSatisfyingUrlRules)({include:o.include,exclude:o.exclude},location.href))return!1;return!!(0,t.isDeviceSatisfyingDeviceRules)({include_devices:o.include_devices,exclude_devices:o.exclude_devices},n)}},1:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.processNotificationPermission=t.handlePostSubscriptionUpsert=t.processNotificationPermissionClosedData=t.processNotificationPermissionDeniedData=t.processSubscriptionData=void 0;const r=i(2044),s=i(3502),a=o(i(1762)),d=i(6280),c=i(3876),l=i(561),u=i(1409),g=i(9933),p=i(5967),b=i(5971),f=i(8380),m=i(7730),v=i(1119);t.processSubscriptionData=({subscription:e,options:t={}})=>n(void 0,void 0,void 0,(function*(){const i=(0,v.getAppData)(),{gcm_options:n,vapid_key:o,privacy_settings:c,publisher_settings:l,safari_options:g}=i.siteSettings,p=i.site;let f;f="deviceToken"in e?{endpoint:e.deviceToken,project_id:g.push_id}:Object.assign(Object.assign(Object.assign({},e),n),{vapid_public_key:o.public_key});const m=(0,d.getBrowserInfo)(),_=yield(0,b.getGeoInfo)({isEu:p.is_eu}),h=(0,s.getOldSubscriberIdFromStorage)(),y=yield(0,r.upsertSubscriberDataToSite)({browserInfo:m,site:p,subscription:f,options:{geoInfo:c.geoLocationEnabled?_:void 0,optInType:t.optInType,tokenRefresh:t.tokenRefresh,isPublisherSettingEnabled:null==l?void 0:l.enabled,widgetOptInType:t.widgetOptInType},subscriberId:h}),{segment:w}=t;if(w){if((Array.isArray(w)?w:[w]).length)try{yield(0,u.addSegmentToSubscriber)({segment:w,subscriberId:y,siteId:p.site_id})}catch(e){a.default.warn(e)}}return y}));t.processNotificationPermissionDeniedData=({optInType:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,v.getAppData)(),i={optin_type:e,site_id:t.site.site_id};e===l.optInTypes.singleStep?Object.assign(i,{block_1:!0,optin_1:!0}):Object.assign(i,{allow_1:!0,optin_1:!0,block_2:!0,optin_2:!0}),yield(0,c.sendOptInAnalytics)(i)}));function _({subscriberId:e,subscription:t,isSubDomain:i}){return n(this,void 0,void 0,(function*(){const n=(0,v.getAppData)();(0,s.storeSubscriptionDataInStorage)({isSubDomain:i,subscriberId:e,subscription:t});try{yield(0,f.syncSubscriberData)({subscriberId:e,appId:n.site.site_key})}catch(e){a.default.debug("Failed to sync subscriber data to DB.",e)}if(!0!==i&&!n.siteSettings.service_worker.keepMultipleSubscriptions){const e=(0,s.getParsedStorageData)(l.storageName);e.endpoint&&(yield(0,m.unsubscribeFromPushSubscription)(e.endpoint))}}))}t.processNotificationPermissionClosedData=({optInType:e})=>n(void 0,void 0,void 0,(function*(){const t=(0,v.getAppData)(),i={optin_type:e,site_id:t.site.site_id};e===l.optInTypes.singleStep?Object.assign(i,{close_1:!0,optin_1:!0}):Object.assign(i,{allow_1:!0,optin_1:!0,close_2:!0,optin_2:!0}),yield(0,c.sendOptInAnalytics)(i)})),t.handlePostSubscriptionUpsert=_;t.processNotificationPermission=({permissionData:e,optInType:i,options:o={}})=>n(void 0,void 0,void 0,(function*(){var n;a.default.debug("Process notification permission.");const r=(e=>{const t=(0,v.getAppData)(),i=(0,d.detectDeviceType)(),n=(0,g.detectSiteType)(),o=(0,p.get)(t.siteSettings.optin_settings,`optins.${e}.${i}.${n}`);return o?o.cookie_duration:l.defaultMinStorageDuration})(i),c=null!==(n=o.isSubDomain)&&void 0!==n&&n;if("granted"===e.permission&&e.subscription){const n=yield(0,t.processSubscriptionData)({subscription:e.subscription,options:{optInType:i,segment:o.segment,tokenRefresh:o.tokenRefresh,widgetOptInType:o.widgetOptInType}});yield _({isSubDomain:c,subscriberId:n,subscription:e.subscription}),a.default.debug("The subscriber has been added to the site, and the subscriber data has been sent to PushEngage and stored in storage.")}else"denied"===e.permission?(yield(0,t.processNotificationPermissionDeniedData)({optInType:i}),(0,s.storeSubscriptionDeniedDataInStorage)({storageDuration:r,isSubDomain:c}),a.default.debug("The current permission status is denied, and the opt-in impression analytics have been sent to PushEngage and the status has been stored in storage.")):(yield(0,t.processNotificationPermissionClosedData)({optInType:i}),o.widgetOptInType||(0,s.storeOptInCloseDataInStorage)({optInType:i,storageDuration:r}),a.default.debug("The current permission status is default(clicked on X or, auto closed), and the opt-in impression analytics have been sent to PushEngage and the status has been stored in storage."))}))},1658:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.handleMessageUnsubscribeState=t.handleMessageSubscribeState=t.handleMessageSubscriptionState=t.handleNotificationOpenUrl=t.handleNotificationClick=t.showDefaultNotification=t.showNotification=t.formatNotifications=t.parseOrFetchNotifications=t.isValidPushPayload=t.getNotificationUrlAndUserAction=t.broadcastReply=t.checkAndUpdateNotificationInDbByKey=t.processFailedAnalytics=t.getAppId=void 0;const r=i(6280),s=i(7730),a=o(i(1762)),d=i(5967),c=i(5971),l=i(2044),u=i(561),g=o(i(6920)),p=i(8380),b=i(1340),f=i(4449),m=i(2610),v=i(9933);t.getAppId=()=>n(void 0,void 0,void 0,(function*(){let e=(0,v.getValueFromUrlByKey)("appId",location.href)||null;if(e)return e;try{e=yield(0,p.getAppId)()}catch(t){e=null}return e||(e="undefined"!=typeof PUSHENGAGE_APP_ID?PUSHENGAGE_APP_ID:null,e)}));t.processFailedAnalytics=()=>n(void 0,void 0,void 0,(function*(){try{const e=yield(0,p.getFailedViewedNotificationTags)();for(let t=0;tn(void 0,void 0,void 0,(function*(){try{const i=yield(0,p.getNotificationTagsByKey)(t);if(i.length){const t=(0,b.removeSubscriberIdFromTag)(e);if(i.some((e=>t===(0,b.removeSubscriberIdFromTag)(e))))return!0}yield(0,p.updateNotificationTagByKey)(e,t)}catch(e){a.default.error(`Error while checking and updating notification tag in db, ${e.message}`)}return!1}));t.broadcastReply=(e,t)=>n(void 0,void 0,void 0,(function*(){const i=yield self.clients.matchAll();for(let n=0;n{let i="action3",n=(0,d.isObject)(e)?null==e?void 0:e.url:e,o=null;return t&&(o=(0,d.safeParse)(t)),"action1"==(null==o?void 0:o.action)?(i="action1",n=o.action_url||n):"action2"==(null==o?void 0:o.action)&&(i="action2",n=o.action_url||n),{userAction:i,notificationUrl:n||"/"}};t.isValidPushPayload=e=>!!(e&&Array.isArray(e)&&e.length&&e[0].options&&e[0].options.tag);t.parseOrFetchNotifications=e=>n(void 0,void 0,void 0,(function*(){var i,n,o;if(!(null==e?void 0:e.data)){const e=yield(0,t.getAppId)();if(!e)throw new g.default({message:"The AppId is not present in the service worker, so it cannot fetch notifications.",name:"AppIdNotFound"});const i=yield(0,p.getSubscriberIdByAppId)(e);if(!i)throw new g.default({message:"The subscriber id is not available in the database.",name:g.default.ERROR_NAME.SubscriberIdNotFoundInDb});return yield(0,f.fetchPayloadLessNotifications)(i)}let r;try{r=e.data.json()}catch(t){throw new g.default({message:`Parsing of the push payload failed, ${e.data.text()}.`,name:"PushPayloadParseError",details:{worker:self.location.href}})}if(!(0,t.isValidPushPayload)(r))throw new g.default({message:"Valid JSON but not PushEngage payload.",name:"NotPushEngagePayload",details:{payload:r,worker:self.location.href}});const s=r[0];if(!(null===(i=s.options)||void 0===i?void 0:i.tag)||(!(a=s.options).customData||!a.customData.refetch))return[s];var a;return yield(0,f.fetchPayloadNotifications)({tag:s.options.tag,postback:(null===(o=null===(n=s.options)||void 0===n?void 0:n.customData)||void 0===o?void 0:o.postback)||""})}));t.formatNotifications=e=>e.map((e=>{const{tag:t,data:i,actions:n}=e.options||{},o=t?t.toString():"",r=[];return n&&Array.isArray(n)&&n.forEach((function(e){e.icon||r.push((0,d.omit)(e,["icon"]))})),Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{tag:(0,b.removeSubscriberIdFromTag)(o),actions:r.length?r:void 0,data:{originalTag:o,url:i||""}})})}));t.showNotification=({title:e,notificationOptions:i})=>n(void 0,void 0,void 0,(function*(){var o;if("granted"===Notification.permission){if((null==i?void 0:i.tag)&&i.tag.includes(u.defaultNotificationTag))return self.registration.showNotification(e,i);if(yield self.registration.showNotification(e,i),(null==i?void 0:i.viewUrl)&&(null==i?void 0:i.tag))try{yield(0,f.sendNotificationViewedReferAnalytics)({tag:(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.originalTag)||i.tag}),a.default.info("Response from view refer analytics")}catch(e){a.default.info(`Failed response from view refer analytics, ${e.name}`)}if(null==i?void 0:i.tag)try{yield(({notificationOptions:e})=>n(void 0,void 0,void 0,(function*(){var i;if(yield(0,t.processFailedAnalytics)(),!(null==e?void 0:e.tag))return;const n=(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.originalTag)||(null==e?void 0:e.tag);if(!(yield(0,t.checkAndUpdateNotificationInDbByKey)(n,"viewedNotificationTags")))try{yield(0,f.sendNotificationViewedAnalytics)({tag:n}),a.default.info("Response from viewed analytics")}catch(e){if(a.default.info(`Failed response from viewed analytics, ${e.name}`),!1===navigator.onLine)try{yield(0,p.addFailedViewedNotificationTag)({tag:n})}catch(e){a.default.error(`Failed to add failed viewed notification tag to db, ${e.message}`)}else(0,m.sendErrorLog)("service-worker",e,{tag:n,name:"viewCountTrackingFailed",data:{tag:n}})}})))({notificationOptions:i})}catch(e){a.default.info(`Failed to handle notification view, ${e.name}`)}}}));t.showDefaultNotification=()=>n(void 0,void 0,void 0,(function*(){const e=yield(0,t.getAppId)(),i={notificationOptions:{data:{url:"/",originalTag:u.defaultNotificationTag},tag:u.defaultNotificationTag,requireInteraction:!1},title:u.defaultNotificationTitle};if(!e)return a.default.debug("AppId is not present in the service worker URL."),void(yield(0,t.showNotification)(i));let n=null;try{n=yield(0,c.getAppData)({source:"service-worker",appId:e})}catch(e){return a.default.info(`${e.message}`),void(yield(0,t.showNotification)(i))}if(!n)throw yield(0,t.showNotification)(i),new g.default({name:"AppDataEmpty",message:"App data is not available.",details:{appId:e,worker:self.location.href}});const o=n.siteSettings.default_notification;if(!o)throw yield(0,t.showNotification)(i),new g.default({name:"DefaultNotificationSettingNotFound",message:"Default notification setting is not available.",details:{appId:e,worker:self.location.href}});const r=n.site,s={body:o.default_notification_message,icon:r.site_image,tag:`${u.defaultNotificationTag}${r.site_id}`,data:{url:o.default_notification_url,originalTag:u.defaultNotificationTag},requireInteraction:!1};yield(0,t.showNotification)({notificationOptions:s,title:o.default_notification_title})}));t.handleNotificationClick=({notificationOptions:e,userAction:i})=>n(void 0,void 0,void 0,(function*(){var n;if(!e.tag||e.tag.includes(u.defaultNotificationTag)||"user_visible_auto_notification"===e.tag)return;const o=(null===(n=e.data)||void 0===n?void 0:n.originalTag)||e.tag;if(!(yield(0,t.checkAndUpdateNotificationInDbByKey)(o,"clickedNotificationTags")))try{yield(0,f.sendNotificationClickedAnalytics)({tag:o,action:i}),a.default.info("Response from clicked analytics")}catch(e){if(a.default.info(`Failed response from clicked analytics, ${e.name}`),!1===navigator.onLine)try{yield(0,p.addFailedClickedNotificationTag)({tag:o,action:i})}catch(e){a.default.error(`Failed to add failed clicked notification tag to db, ${e.message}`)}else(0,m.sendErrorLog)("service-worker",e,{tag:o,name:"clickCountTrackingFailed",action:i,data:{tag:o,action:i}})}}));t.handleNotificationOpenUrl=e=>n(void 0,void 0,void 0,(function*(){const t=yield self.clients.matchAll({type:"window"});for(let i=0;in(void 0,void 0,void 0,(function*(){const e=yield self.registration.pushManager.getSubscription();if(!e)return void(yield(0,t.broadcastReply)(u.workerMessengerCommand.ampSubscriptionState,!1));const i=yield self.registration.pushManager.permissionState(e.options);yield(0,t.broadcastReply)(u.workerMessengerCommand.ampSubscriptionState,"granted"===i)}));t.handleMessageSubscribeState=()=>n(void 0,void 0,void 0,(function*(){const e=yield(0,t.getAppId)();if(!e)throw new g.default({name:"AppIdNotFound",message:"AppId is not present in the service worker URL",details:{appId:e,worker:self.location.href}});let i;try{i=yield(0,c.getAppData)({appId:e,source:"service-worker-amp"})}catch(t){throw new g.default({name:"InvalidAppId",message:t.message,details:{appId:e,worker:self.location.href}})}if(!i)throw new g.default({name:"AppDataEmpty",message:"App data is not available.",details:{appId:e,worker:self.location.href}});const{gcm_options:n,privacy_settings:o,vapid_key:b}=i.siteSettings,f=i.site.site_id;if(!b)throw new g.default({name:"VAPIDSettingNotFound",message:"VAPID setting is not available.",details:{appId:e,siteId:f}});if(!n)throw new g.default({name:"GCMSettingNotFound",message:"GCM setting is not available.",details:{appId:e,siteId:f}});let m;try{m=yield(0,s.subscribeToPushNotificationFromWorker)(b.public_key)}catch(t){throw new g.default({name:t.name||"AMPSubscribeFailed",message:`Failed to subscribe to push notifications, ${t.message}`,details:{appId:e,siteId:f}})}let v,_="";try{_=yield self.clients.matchAll({includeUncontrolled:!0,type:"window"}).then((e=>0===e.length?"":e[0].url))}catch(e){(0,d.noop)()}o.geoLocationEnabled&&(v=yield(0,c.getGeoInfo)({isEu:i.site.is_eu}));const h=(0,r.getBrowserInfo)("worker"),y={browserInfo:Object.assign(Object.assign({},h),{href:_}),site:i.site,subscription:Object.assign(Object.assign({},m),{project_id:n.project_id,vapid_public_key:b.public_key}),options:{geoInfo:v,optInType:u.optInTypes.singleStep},subscriberId:null};try{const t=yield(0,p.getSubscriberIdByAppId)(e);y.subscriberId=t}catch(e){a.default.debug("Failed to get subscriber ID from DB.",e)}let w;try{w=yield(0,l.upsertSubscriberDataToSite)(y),a.default.debug("Subscription added."),yield(0,t.broadcastReply)(u.workerMessengerCommand.ampSubscribe,null)}catch(e){throw new g.default({name:"AddSubscriptionFailed",message:`Failed to adding subscription, ${e.message}`,details:{data:y}})}try{yield(0,p.syncSubscriberData)({subscriberId:w,appId:e})}catch(e){a.default.debug("Failed to sync subscriber data to DB.",e)}}));t.handleMessageUnsubscribeState=()=>n(void 0,void 0,void 0,(function*(){const e=yield self.registration.pushManager.getSubscription();if(e)try{yield e.unsubscribe(),a.default.debug("Subscription unsubscribed."),yield(0,t.broadcastReply)(u.workerMessengerCommand.ampUnsubscribe,null)}catch(e){throw new g.default({message:`Failed unsubscribe to push notifications, ${e.message}.`,name:"UnsubscribedFailedFromWorker",details:{worker:self.location.href}})}}))},7429:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getLegacySDKShopifyCheckoutOrderIds=t.getImageUrlsFromCartItem=t.getImageUrlsFromProduct=t.getImageUrlsFromVariant=t.filterVariantFromVariantId=t.getSelectedVariantId=t.getPageType=t.convertPriceToFloat=void 0;const o=i(5967),r=i(6485),s=i(1950),a=({imageUrl:e,width:t,height:i})=>n(void 0,void 0,void 0,(function*(){let n=(({url:e,width:t,height:i})=>{const n=[".png",".jpg",".jpeg",".gif",".webp"];if(!e.includes("cdn.shopify.com"))return e;for(const o of n)if(e.includes(o))return e.replace(o,`_${t}x${i}${o}`);return e})({width:t,height:i,url:e});var o;0!==(o=n).indexOf("https:")&&0!==o.indexOf("http:")&&(o="https:"+o),n=o;if(yield(0,s.isUrlReachable)(n))return n}));t.convertPriceToFloat=e=>parseFloat(""+e/100).toFixed(2);t.getPageType=()=>{var e,t,i;return null===(i=null===(t=null===(e=window.ShopifyAnalytics)||void 0===e?void 0:e.meta)||void 0===t?void 0:t.page)||void 0===i?void 0:i.pageType};t.getSelectedVariantId=()=>{var e,t;return null===(t=null===(e=window.ShopifyAnalytics)||void 0===e?void 0:e.meta)||void 0===t?void 0:t.selectedVariantId};t.filterVariantFromVariantId=(e,t)=>{var i,n;return t?null===(n=e.variants)||void 0===n?void 0:n.find((e=>e.id===(0,o.toInteger)(t))):null===(i=e.variants)||void 0===i?void 0:i[0]};t.getImageUrlsFromVariant=e=>n(void 0,void 0,void 0,(function*(){var t;const i=null===(t=null==e?void 0:e.featured_image)||void 0===t?void 0:t.src;if(!i||"string"!=typeof i)return{};const[n,o]=yield Promise.all([a({imageUrl:i,width:364,height:180}),a({imageUrl:i,width:192,height:192})]);return{largeImageUrl:n,imageUrl:o}}));t.getImageUrlsFromProduct=e=>n(void 0,void 0,void 0,(function*(){const t=e.featured_image;if(!t||"string"!=typeof t)return{};const[i,n]=yield Promise.all([a({imageUrl:t,width:364,height:180}),a({imageUrl:t,width:192,height:192})]);return{largeImageUrl:i,imageUrl:n}}));t.getImageUrlsFromCartItem=e=>n(void 0,void 0,void 0,(function*(){const t=e.image;if(!t||"string"!=typeof t)return{};const[i,n]=yield Promise.all([a({imageUrl:t,width:364,height:180}),a({imageUrl:t,width:192,height:192})]);return{largeImageUrl:i,imageUrl:n}}));t.getLegacySDKShopifyCheckoutOrderIds=()=>{const e=(0,r.getDataFromLocalStorage)("PushCheckoutStorageData");let t=[];return e&&(t=(0,o.convertStringToArray)(`${e}`).map((e=>String(e)))),t}},662:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.unsubscribeSubscription=t.getUserSubscriptionState=t.evaluateUserSubscriptionState=t.isAllSubscriptionOptInClosed=t.subscriptionNeedToBeResubscribed=t.resubscribeSubscription=void 0;const d=r(i(3502)),c=r(i(7730)),l=i(6947),u=i(6280),g=i(561),p=a(i(1762)),b=i(2044),f=i(3502),m=i(6347),v=({error:e,optInSetting:t})=>["ServiceWorkerNotRegistering","ServiceWorkerNotFound","DisabledPushSubscriptionError"].includes(e.name)&&(0,m.isServiceWorkerAvailable)({optInSetting:t});t.resubscribeSubscription=({vapidSetting:e,serviceWorkerSetting:t,safariWebPushPackageSetting:i})=>s(void 0,void 0,void 0,(function*(){if("granted"!==(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id}))throw new Error("Notification permission is not granted, so it is not possible to obtain the subscription.");const{name:n}=(0,u.detectBrowser)(),o=(0,u.detectDeviceType)();if("Safari"===n&&!(0,l.hasSupportForPushApiInSafari)()){if(!i)throw new Error("Safari Web Push Package is not configured.");const e=c.getSafariSubscription(i.push_id);if("granted"===e.permission)return e;throw new Error("Safari Notification permission is not granted, so it is not possible to obtain the subscription.")}const r=d.getSubscriberIdFromStorage();let s;r&&(s=yield(0,b.getSubscriberData)(r));const a={vapidPublicKey:e.public_key};let g;if(t.workerStatus&&(a.options={scope:t.scope?"/":void 0},a.scriptURL=t.worker),"Firefox"===n&&"mobile"===o){if(s&&s.vapid_public_key!==e.public_key)throw new Error("The applicationServerKey has changed, so it's not possible to resubscribe.");const t=yield c.getPushSubscription({scriptURL:a.scriptURL,options:a.options});if(!t)throw new Error("Subscription not found.");g=t}else if(s&&s.vapid_public_key!==e.public_key)yield c.unsubscribeFromPushSubscription(),g=yield c.subscribeToPushNotification(a);else try{g=yield c.subscribeToPushNotification(a)}catch(e){if("InvalidStateError"!==e.name)throw e;yield c.unsubscribeFromPushSubscription(),g=yield c.subscribeToPushNotification(a)}return g}));t.subscriptionNeedToBeResubscribed=({vapidSetting:e,serviceWorkerSetting:i,safariWebPushPackageSetting:n})=>s(void 0,void 0,void 0,(function*(){if("granted"!==(0,l.getNotificationPermission)({safariWebPushId:null==n?void 0:n.push_id}))return;const o=d.getParsedStorageData(g.storageName),r=yield(0,t.resubscribeSubscription)({vapidSetting:e,serviceWorkerSetting:i,safariWebPushPackageSetting:n});return r&&(!o.id||(r.endpoint||r.deviceToken)!==o.endpoint)?r:void 0}));t.isAllSubscriptionOptInClosed=e=>{const t=(0,m.getActiveOptInTypes)(e);return!(!t.length||!d.isSubscriptionOptInClosed(t))};t.evaluateUserSubscriptionState=({optInSetting:e,vapidSetting:i,serviceWorkerSetting:n,safariWebPushPackageSetting:o})=>s(void 0,void 0,void 0,(function*(){if(d.isSubscriptionUnsubscribed({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})}))return{state:"unsubscribed"};try{const e=yield(0,t.subscriptionNeedToBeResubscribed)({vapidSetting:i,serviceWorkerSetting:n,safariWebPushPackageSetting:o});if(e)return{subscription:e,state:"resubscribe"}}catch(t){if(v({error:t,optInSetting:e}))throw t;!1===d.isSubscriptionOnSubDomain()&&d.clearOldSubscriptionDataFromStorage(),p.default.debug(t)}if(d.isSubscriptionDenied({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})}))return{state:"denied"};if(d.hasSubscriptionDataInStorage({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})})){if(d.isSubscriptionValidForSite()){const e=d.getSubscriberIdFromStorage(),t=yield(0,b.getSubscriberData)(e);if(t&&1!==t.has_unsubscribed)return{state:"subscribed"}}d.clearOldSubscriptionDataFromStorage();try{const e=yield(0,t.subscriptionNeedToBeResubscribed)({vapidSetting:i,serviceWorkerSetting:n,safariWebPushPackageSetting:o});if(e)return{subscription:e,state:"resubscribe"}}catch(t){if(v({error:t,optInSetting:e}))throw t;p.default.debug(t)}}return(0,t.isAllSubscriptionOptInClosed)(e)?{state:"closed"}:(d.clearOldSubscriptionDataFromStorage(),{state:"default"})}));t.getUserSubscriptionState=({optInSetting:e,safariWebPushPackageSetting:i})=>s(void 0,void 0,void 0,(function*(){if(d.isSubscriptionUnsubscribed({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id})}))return"unsubscribed";if(d.isSubscriptionDenied({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id})}))return"denied";if(d.hasSubscriptionDataInStorage({notificationPermission:(0,l.getNotificationPermission)({safariWebPushId:null==i?void 0:i.push_id})})){if(d.isSubscriptionValidForSite()){const e=d.getSubscriberIdFromStorage(),t=yield(0,b.getSubscriberData)(e);if(t&&1!==t.has_unsubscribed)return"subscribed"}return d.clearOldSubscriptionDataFromStorage(),"default"}return(0,t.isAllSubscriptionOptInClosed)(e)?"closed":(d.clearOldSubscriptionDataFromStorage(),"default")}));t.unsubscribeSubscription=({siteId:e,subscriberId:t})=>s(void 0,void 0,void 0,(function*(){var i;yield(0,b.updateSubscriberStatus)({siteId:e,subscriberId:t,status:"unsubscribe"});const n=d.getParsedStorageData(g.storageName);(0,f.storeSubscriptionUnsubscribedDataInStorage)(null===(i=n.isSubDomain)||void 0===i||i);const{name:o}=(0,u.detectBrowser)();if(("Safari"!==o||(0,l.hasSupportForPushApiInSafari)())&&!n.isSubDomain)try{yield c.unsubscribeFromPushSubscription()}catch(e){p.default.debug("Error occurred during unsubscription.",e)}}))},5967:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.generateRandomAlphanumeric=t.validateAndCleanData=t.debounce=t.replaceLastNumberFromIpToZero=t.keepLastMaxElements=t.convertStringToArray=t.delay=t.capitalizeFirstLetter=t.uniqueArray=t.isNull=t.isUndefined=t.isWorker=t.toInteger=t.addStyleToPage=t.addScriptToPage=t.isEmptyArray=t.isEmptyObject=t.omit=t.get=t.isObject=t.removeArrayItem=t.safeStringify=t.safeParse=t.hasOwn=t.noop=void 0;const n=i(8693);t.noop=()=>{};t.hasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);t.safeParse=e=>{let t=null;try{t=JSON.parse(e)}catch(e){(0,n.logDebug)(e)}return t};t.safeStringify=e=>{let t=null;try{t=JSON.stringify(e)}catch(e){(0,n.logDebug)(e)}return t};t.removeArrayItem=(e,t)=>{const i=e.indexOf(t);return i>-1&&e.splice(i,1),e};t.isObject=e=>"[object Object]"===Object.prototype.toString.call(e);t.get=(e,t,i)=>{const n=Array.isArray(t)?t:t.split(".");let o=e;for(const e of n){if(null==o)return i;o=o[e]}return void 0===o?i:o};t.omit=(e,t)=>{const i=Object.assign({},e);for(const e of t){const t=Array.isArray(e)?e:[e];let n=i,o=t[0];for(let e=0;e!(0,t.isObject)(e)||0===Object.keys(e).length;t.isEmptyArray=e=>!Array.isArray(e)||0===e.length;t.addScriptToPage=(...e)=>{e.forEach((e=>{try{const t=document.createElement("script");t.src=e,t.async=!0,t.type="text/javascript",document.head.appendChild(t)}catch(t){throw new Error(`Invalid script URL: ${e}`)}}))};t.addStyleToPage=(...e)=>{e.forEach((e=>{try{const t=document.createElement("link");t.rel="stylesheet",t.href=e,t.type="text/css",document.head.appendChild(t)}catch(t){throw new Error(`Invalid style URL: ${e}`)}}))};t.toInteger=e=>{if("string"!=typeof e&&"number"!=typeof e)return 0;e=String(e).trim();const t=parseInt(e,10);return isNaN(t)?0:t};t.isWorker=()=>self instanceof ServiceWorkerGlobalScope;t.isUndefined=e=>void 0===e;t.isNull=e=>null===e;t.uniqueArray=e=>Array.from(new Set(e));t.capitalizeFirstLetter=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;t.delay=e=>new Promise((t=>setTimeout(t,e)));t.convertStringToArray=(e,t=",")=>e.split(t);t.keepLastMaxElements=(e,t)=>e.length>t?e.slice(-t):e;t.replaceLastNumberFromIpToZero=(e,t)=>{if(!e||!t)return t;const i=t.includes(".")?".":":",n=t.split(i);return n[n.length-1]="0",n.join(i)},t.debounce=function(e,t){let i=null;return(...n)=>{null!==i&&clearTimeout(i),i=setTimeout((()=>{i=null,e(...n)}),t)}},t.validateAndCleanData=function e(t,i){if("object"!=typeof t||null===t||Array.isArray(t))return{};const n={};for(const o in i)if(Object.prototype.hasOwnProperty.call(t,o)){const r=i[o];if("object"!=typeof r||Array.isArray(r)){if("string"==typeof r)if(r.startsWith("array.")){const e=r.split(".")[1];if(Array.isArray(t[o]))if(0===t[o].length)n[o]=t[o];else{const i=t[o].filter((t=>"null"===e?null===t:typeof t===e));i.length>0&&(n[o]=i)}}else("null"===r&&null===t[o]||"array"===r&&Array.isArray(t[o])||typeof t[o]===r)&&(n[o]=t[o])}else{const i=e(t[o],r);(Object.keys(i).length>0||"object"==typeof t[o]&&!Array.isArray(t[o]))&&(n[o]=i)}}return n},t.generateRandomAlphanumeric=function(e=5){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let n=0;n{Object.defineProperty(t,"__esModule",{value:!0}),t.getChromiumStatus=t.getBrowserInfo=t.detectDeviceType=t.isPrivateBrowser=t.detectBrowser=t.isBrowser=void 0;const n=i(3110);t.isBrowser=()=>"undefined"!=typeof window&&void 0!==window.document;t.detectBrowser=(e=navigator.userAgent)=>{var t,i,n,o,r,s,a,d,c,l,u;let g="Unknown",p="";return/Firefox\/\d/.test(e)?(g="Firefox",p=(null===(t=e.match(/Firefox\/(\d+)/))||void 0===t?void 0:t[1])||""):/OPR\/\d/.test(e)?(g="Opera",p=(null===(i=e.match(/OPR\/(\d+)/))||void 0===i?void 0:i[1])||""):/Edg\/\d/.test(e)?(g="Edge",p=(null===(n=e.match(/Edg\/(\d+)/))||void 0===n?void 0:n[1])||""):/Edge\/\d/.test(e)?(g="Edge",p=(null===(o=e.match(/Edge\/(\d+)/))||void 0===o?void 0:o[1])||""):/EdgA\/\d/.test(e)?(g="Edge",p=(null===(r=e.match(/EdgA\/(\d+)/))||void 0===r?void 0:r[1])||""):/UCBrowser\//.test(e)?(g="Ucbrowser",p=(null===(s=e.match(/UCBrowser\/(\d+)/))||void 0===s?void 0:s[1])||""):/SamsungBrowser\//.test(e)?(g="Samsung",p=(null===(a=e.match(/SamsungBrowser\/(\d+)/))||void 0===a?void 0:a[1])||""):/YaBrowser\//.test(e)?(g="Yandex",p=(null===(d=e.match(/YaBrowser\/(\d+)/))||void 0===d?void 0:d[1])||""):/Chrome\//.test(e)?(g="Chrome",p=(null===(c=e.match(/Chrome\/(\d+)/))||void 0===c?void 0:c[1])||""):/Version\//.test(e)?(g="Safari",p=(null===(l=e.match(/Version\/(\d+)/))||void 0===l?void 0:l[1])||""):/MSIE|Trident/.test(e)&&(g="IE",p=(null===(u=e.match(/(?:MSIE |rv:)(\d+)/))||void 0===u?void 0:u[1])||""),p=p.replace(/[^\d.]/g,"").split(".")[0],{name:g,version:Number(p)}};t.isPrivateBrowser=function(){return new Promise((e=>{(0,n.detectIncognito)().then((t=>{e(t.isPrivate)})).catch((t=>{console.debug(t),e(!1)}))}))};t.detectDeviceType=(e=navigator.userAgent)=>/Mobi/.test(e)?"mobile":"desktop";t.getBrowserInfo=(e="sdk")=>{const{name:i,version:n}=(0,t.detectBrowser)(),o={name:i,version:n,language:navigator.language.split("-")[0],device:(0,t.detectDeviceType)(),userAgent:navigator.userAgent};return"worker"===e?Object.assign(o,{host:self.location.host,href:self.location.href,referrer:self.location.origin}):Object.assign(o,{availableScreen:`${screen.availWidth}*${screen.availHeight}`,host:location.host,href:location.href,pixelDepth:screen.pixelDepth,referrer:document.referrer,screen:`${screen.width}*${screen.height}`}),o};t.getChromiumStatus=()=>{const e=Boolean(window.chrome),t=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return e&&t?{isChromium:!0,version:Number(t[2])}:{isChromium:!1,version:0}}},6485:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteDataFromLocalStorage=t.getDataFromLocalStorage=t.setDataToLocalStorage=t.deleteDataFromCookies=t.setDataToCookies=t.getDataFromCookies=void 0;const o=i(8693),r=n(i(6920)),s="undefined"!=typeof document&&void 0!==document.cookie;function a(){try{return"localStorage"in window&&null!==window.localStorage&&"setItem"in localStorage&&"getItem"in localStorage&&"removeItem"in localStorage}catch(e){return!1}}t.getDataFromCookies=e=>{if(!s)return(0,o.logDebug)("Cookie storage is not available"),null;const t=document.cookie.split(";");for(let i=0;i{if(!s)return void(0,o.logDebug)("Cookie storage is not available");const n=new Date;n.setDate(n.getDate()+i);const r="object"==typeof t?JSON.stringify(t):t,a=encodeURIComponent(r)+"; expires="+n.toUTCString();document.cookie=e+"="+a+"; path=/"};t.deleteDataFromCookies=e=>{if(!s)return void(0,o.logDebug)("Cookie storage is not available");(Array.isArray(e)?e:[e]).forEach((e=>{(0,t.getDataFromCookies)(e)&&(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`)}))};t.setDataToLocalStorage=(e,t)=>{if(!a())throw new r.default({message:"Local storage is not available",name:r.default.ERROR_NAME.LocalStorageNotAvailable});const i="object"==typeof t?JSON.stringify(t):t;localStorage.setItem(e,i)};t.getDataFromLocalStorage=e=>{if(!a())throw new r.default({message:"Local storage is not available",name:r.default.ERROR_NAME.LocalStorageNotAvailable});const t=localStorage.getItem(e);return t||null};t.deleteDataFromLocalStorage=e=>{if(!a())throw new r.default({message:"Local storage is not available",name:r.default.ERROR_NAME.LocalStorageNotAvailable});Array.isArray(e)?e.forEach((e=>{localStorage.removeItem(e)})):localStorage.removeItem(e)}},7641:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getUnixTime=t.getTimezoneName=t.getTimezoneOffset=void 0;t.getTimezoneOffset=()=>{const e=(new Date).getTimezoneOffset(),t=e>0?"-":"+",i=Math.floor(Math.abs(e)/60),n=Math.abs(e)%60;return`${t}${("0"+i).slice(-2)}:${("0"+n).slice(-2)}`};t.getTimezoneName=()=>{var e;let t="";if("function"==typeof(null===(e=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat())||void 0===e?void 0:e.resolvedOptions)){const e=Intl.DateTimeFormat().resolvedOptions();t=(null==e?void 0:e.timeZone)||""}return t};t.getUnixTime=e=>(e?new Date(Date.now()+24*e*60*60*1e3):new Date).getTime()},7628:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.richEditorHasNoValue=t.stripTagsAndDecodeEntity=t.addCSSProperties=t.clearBodyContent=t.getElementById=t.getScrollPercentage=t.addContentAfterBody=t.removeElement=void 0;t.removeElement=e=>{var t;if("string"==typeof e){const i=document.getElementById(e);i&&(null===(t=i.parentNode)||void 0===t||t.removeChild(i))}else Array.isArray(e)&&e.forEach((e=>{var t;const i=document.getElementById(e);i&&(null===(t=i.parentNode)||void 0===t||t.removeChild(i))}))};t.addContentAfterBody=e=>{const t=document.querySelector("body");if(!t)throw new Error("Can't find body element");Array.isArray(e)?e.forEach((e=>{t.insertAdjacentHTML("beforeend",e)})):t.insertAdjacentHTML("beforeend",e)};t.getScrollPercentage=()=>{const e=document.documentElement,t=document.body||document.scrollingElement,i=e.scrollTop||t&&t.scrollTop||0,n=e.scrollHeight||t&&t.scrollHeight||0,o=e.clientHeight||0,r=n?(i+o)/n*100:0;return Math.round(r)};t.getElementById=e=>document.getElementById(e);t.clearBodyContent=()=>{const e=document.querySelector("body");e&&(e.innerHTML="")};t.addCSSProperties=(e,t)=>{const i=document.getElementById(e);i&&Object.assign(i.style,t)};t.stripTagsAndDecodeEntity=e=>{if(!e)return;const t=document.createElement("span");return t.innerHTML=e,t.textContent};t.richEditorHasNoValue=e=>{if(!e)return!0;const t=document.createElement("div");t.innerHTML=e;let i=t.textContent||t.innerText;return i=i.replace(/\s+/g,""),0===i.length}},9272:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(8693);t.default=(()=>{const e={},t=(t,i)=>{const n=e[t];n&&(e[t]=i?n.filter((e=>e.cb!==i)):[])};return{on:(t,i,n={})=>{e[t]||(e[t]=[]),e[t].push({cb:i,options:n})},trigger:(i,o)=>{const r=e[i];if(r)for(const e of r){try{const t=e.cb(o);t instanceof Promise&&t.catch((e=>{(0,n.logDebug)(e)}))}catch(e){(0,n.logDebug)(e)}e.options.once&&t(i,e.cb)}},remove:t}})()},8693:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logDebug=void 0;t.logDebug=e=>{console.debug("PushEngage:",e)}},2381:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__rest||function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);onew Promise((t=>setTimeout(t,e)));t.sendHttpRequest=(e,t={})=>n(void 0,void 0,void 0,(function*(){const{retryDelay:i=1e3,retries:n=0,skipRetryStatusCodes:r=[400,404,403,422]}=t,d=o(t,["retryDelay","retries","skipRetryStatusCodes"]);let c;d.body&&(d.headers||(d.headers={"Content-Type":"application/json"}));let l=0;for(;l=n)break;if(r.includes(c.status))break;yield a(t)}catch(i){if(l>=n){if("TypeError"===i.name&&"Failed to fetch"===i.message&&!navigator.onLine)throw new s.default({message:"Browser is offline. Request not sent.",name:s.default.ERROR_NAME.OfflineError,details:{fetchOptions:d,requestUrl:e}});throw new s.default({message:i.message,name:i.name||s.default.ERROR_NAME.HttpRequestError,details:{fetchOptions:d,requestUrl:e}})}yield a(t)}l++}if(!c)throw new s.default({message:"Request failed and no response was received.",name:s.default.ERROR_NAME.HttpRequestError,details:{fetchOptions:d,requestUrl:e}});return c}))},4719:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteObject=t.upsertObject=t.getObjects=t.getObject=t.openDB=void 0;const r=o(i(6920));t.openDB=(e,t,i)=>n(void 0,void 0,void 0,(function*(){if(!indexedDB)throw new Error("indexedDB is not supported");try{const n=indexedDB.open(e,t);n.onupgradeneeded=()=>{!function(e,t){t.forEach((t=>{var i;e.objectStoreNames.contains(t.name)||e.createObjectStore(t.name,{keyPath:t.keyPath,autoIncrement:null!==(i=t.autoIncrement)&&void 0!==i&&i})}))}(n.result,i)};const o=yield function(e){return new Promise(((t,i)=>{e.onerror=()=>i(e.error),e.onsuccess=()=>t(e.result)}))}(n);return o}catch(e){throw new r.default({message:`Failed to open indexedDB, ${e.message}`,name:e.message.includes("indexedDB.open")?r.default.ERROR_NAME.IndexedDBOpenError:void 0,type:r.default.ERROR_TYPE.IndexedDBError})}}));t.getObject=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const n=new Promise(((n,o)=>{const r=e.transaction(t,"readonly");r.onerror=()=>o(r.error);const s=r.objectStore(t).get(i);s.onerror=()=>o(s.error),s.onsuccess=()=>n(s.result)}));return yield n}catch(e){throw new r.default({message:`Failed to retrieve the specified object, ${e.message}.`,type:r.default.ERROR_TYPE.IndexedDBError,details:{key:i,storeName:t}})}}));t.getObjects=(e,t)=>n(void 0,void 0,void 0,(function*(){try{const i=new Promise(((i,n)=>{const o=e.transaction(t,"readonly"),r=o.objectStore(t);if(o.onerror=()=>n(o.error),r.getAll){const e=r.getAll();e.onerror=()=>n(e.error),e.onsuccess=()=>i(e.result)}else{const e=[],t=r.openCursor();t.onerror=()=>n(t.error),t.onsuccess=t=>{const n=t.target.result;n?(e.push(n.value),n.continue()):i(e)}}}));return yield i}catch(e){throw new r.default({message:`Failed to retrieve the objects, ${e.message}.`,type:r.default.ERROR_TYPE.IndexedDBError,details:{storeName:t}})}}));t.upsertObject=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const n=new Promise(((n,o)=>{const r=e.transaction(t,"readwrite");r.onerror=()=>o(r.error);const s=r.objectStore(t).put(i);s.onerror=()=>o(s.error),s.onsuccess=()=>n(void 0)}));yield n}catch(e){throw new r.default({message:`Failed to upsert object, ${e.message}.`,type:r.default.ERROR_TYPE.IndexedDBError,details:{object:i,storeName:t}})}}));t.deleteObject=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const n=new Promise(((n,o)=>{const r=e.transaction(t,"readwrite");r.onerror=()=>o(r.error);const s=r.objectStore(t).delete(i);s.onerror=()=>o(s.error),s.onsuccess=()=>n(void 0)}));yield n}catch(e){throw new r.default({message:`Failed to delete object, ${e.message}.`,type:r.default.ERROR_TYPE.IndexedDBError,details:{storeName:t,key:i}})}}))},612:function(e,t){var i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=e=>new Promise((t=>setTimeout(t,e)));const o=new class{constructor(){this._locks={}}acquireLock(e,t=200){return i(this,void 0,void 0,(function*(){for(;this._locks[e];)yield n(t);return this._locks[e]=!0,!0}))}releaseLock(e){delete this._locks[e]}isLocked(e){return!!this._locks[e]}};t.default=o},1762:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(561);function o(...e){if("undefined"==typeof document||"undefined"==typeof window||!new URLSearchParams(window.location.search).has(n.logDisplayEnabledKey))return;if(function(){if("undefined"==typeof document)return;const e=document.getElementById("pushengage-debug-container");if(e)return e;const t=document.querySelector("body");if(t){const e=`\n
\n
\n
PushEngage Log
\n\n
\n ${n.closeIcon}\n
\n
\n\n
\n This log is displayed because the ‘${n.logDisplayEnabledKey}’ query parameter is\n available in the URL.\n
\n
\n \n `;t.insertAdjacentHTML("beforeend",e);const i=document.getElementById("pushengage-debug-container");if(i){const e=document.getElementById("pushengage-debug-container-close");return null==e||e.addEventListener("click",(()=>{const e=document.getElementById("pushengage-debug-container");null==e||e.remove()})),i}}}()){const t=document.getElementById("pushengage-debug-container-content");e.forEach((e=>{let i="";i=e instanceof Error?`${e.name}:${e.message}`:"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?JSON.stringify(e):e,null==t||t.insertAdjacentHTML("beforeend",`
${i}
`)}))}}const r={debug:(...e)=>{let t="undefined"==typeof window;"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&sessionStorage.getItem(`${n.storageName}Debug`)&&(t=!0),t&&console.debug("PushEngage:",...e),o(...e)},info:(...e)=>{console.info("PushEngage:",...e),o(...e)},warn:(...e)=>{console.warn("PushEngage:",...e),o(...e)},error:(...e)=>{console.error("PushEngage:",...e),o(...e)}};t.default=r},6917:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=new class{constructor(){this._stores={}}_resolveKeyPath(e){return e.split(".").reduce(((e,t)=>null===e||void 0===e[t]?null:e[t]),this._stores)}get(e){return this._resolveKeyPath(e)}set(e,t){const i=e.split("."),n=i.pop();i.reduce(((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t])),this._stores)[n]=t}delete(e){const t=e.split("."),i=t.pop();if(!i)return;delete t.reduce(((e,t)=>e[t]?e[t]:{}),this._stores)[i]}clearStore(){this._stores={}}};t.default=i},9933:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSubdomainFromUrl=t.detectSiteType=t.detectProtocol=t.isLocalhost=t.getQueryParamsFromUrl=t.addQueryParamsToUrl=t.safeDecodeURIComponent=t.getValueFromUrlByKey=t.getUrlObject=void 0;t.getUrlObject=e=>{var t;const i=e=>{if("function"!=typeof e||"URL"!==e.name)return!1;let t;try{t=new e("http://example.com")}catch(e){return!1}return"search"in t&&"searchParams"in t&&"origin"in t&&"host"in t};if(i(URL))try{return new URL(e)}catch(e){return null}else try{const n=document.createElement("iframe");document.body.appendChild(n);const o=null===(t=n.contentWindow)||void 0===t?void 0:t.URL;return document.body.removeChild(n),i(o)?new o(e):null}catch(e){return null}};t.getValueFromUrlByKey=(e,i)=>{try{const n=(0,t.getUrlObject)(i);if(!n)return;const o=new URLSearchParams(n.search).get(e);return o||void 0}catch(e){return}};t.safeDecodeURIComponent=(e,t=0)=>{const i=String(e).split(/(%(?:d0|d1)%.{2})/);let n="";for(let e=0,o=i.length;e{const n=(0,t.getUrlObject)(e);return n?(Object.keys(i).forEach((e=>{void 0!==i[e]&&n.searchParams.append(e,i[e])})),n.toString()):e};t.getQueryParamsFromUrl=e=>{const t={},i=e.indexOf("?");if(-1!==i){const n=e.substring(i+1).split("&");for(let e=0;e{const e=location.hostname;return Boolean("localhost"===e||"[::1]"===e||e.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))};t.detectProtocol=e=>{if(!e)return location.protocol.slice(0,-1);const t=e.match(/^(\w+):\/\//);return t?t[1]:"http"};t.detectSiteType=()=>(0,t.isLocalhost)()?"https":(0,t.detectProtocol)();t.getSubdomainFromUrl=e=>{try{const i=(0,t.getUrlObject)(e);if(!i)return null;const n=i.hostname.split(".");return n.length>=3?n[0]:null}catch(e){return null}}},5471:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addClickEventListenerForHandleSubscription=void 0;const r=o(i(1762)),s=i(2610),a=i(3101),d=i(6347),c=i(1119);t.addClickEventListenerForHandleSubscription=()=>{const e=(0,c.getAppData)(),t=e.siteSettings.optin_subscription_trigger;if(!t)return;let i=!1;document.body.addEventListener("click",(o=>n(void 0,void 0,void 0,(function*(){try{if(i)return;i=!0;const n=o.target;let s=t.selectors;if(s=s.map((e=>e.replace(/[ ]/gi,".").replace(/^[.#]/,""))),n&&"closest"in n)for(let t=0,i=s.length;t{const e=(0,u.getAppData)();window.addEventListener("message",(t=>n(void 0,void 0,void 0,(function*(){try{const i=t.data;if("PushEngage"!==i.source||i.siteId!==e.site.site_id)return;if(d.default.debug("The message has been received from the subdomain."),"error"in i)return void r.default.trigger("notificationPermissionReceivedFromSubDomain",{error:i.error});const n=g.default.get("subscriptionOnSubdomain")||{},o=n.optInType;if(!o)throw new a.default({message:"Opt-in type is not available.",type:"NotFoundException",details:{siteId:e.site.site_id}});if("prompt"in i)return void r.default.trigger("permissionPrompt",{optInType:n.widgetOptInType||o,prompt:"native",state:"displayed"});r.default.trigger("permissionPrompt",{optInType:n.widgetOptInType||o,prompt:"native",state:"granted"===i.permission?"allow":"close"}),yield(0,s.processNotificationPermission)({optInType:o,permissionData:{permission:i.permission,subscription:i.subscription},options:{isSubDomain:!0,tokenRefresh:i.tokenRefresh,segment:n.segment,widgetOptInType:n.widgetOptInType}}),r.default.trigger("notificationPermissionReceivedFromSubDomain",{permission:i.permission});const u="default"===i.permission&&(0,l.isAllSubscriptionOptInClosed)(e.siteSettings.optin_settings)?"denied":i.permission;r.default.trigger("notificationPermissionReceived",{permission:u,subscriberId:(0,c.getSubscriberIdFromStorage)()||void 0,isPermissionChanged:!0})}catch(e){d.default.debug(e),r.default.trigger("notificationPermissionReceivedFromSubDomain",{error:{message:e.message,name:e.name,type:e.type}})}}))))}},3044:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.processFailedAnalytics=void 0;const n=i(1658);t.processFailedAnalytics=()=>{(0,n.processFailedAnalytics)()}},9964:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.configSchema=t.isPushNotificationSupported=t.handlePushEvent=void 0;const o=n(i(1762)),r=i(6947),s=i(6280);t.handlePushEvent=(...e)=>{for(let t=0;tnew Promise((e=>{(0,r.isPushNotificationSupported)()&&(0,s.isBrowser)()||e(!1),(0,s.isPrivateBrowser)().then((t=>{e(!t)})).catch((()=>e(!0)))}));const a={enabled:"boolean",title:"string",modal_background_color:"string",modal_text_color:"string",allow_text:"string",on_switch_color:"string",off_switch_color:"string",trigger_button:{enabled:"boolean",size:"string",position_x:"string",position_y:"string",offset_top:"number",offset_bottom:"number",icon_background_color:"string",icon_color:"string",icon_type:"string",z_index:"number"},segment_preference:{enabled:"boolean",subscribed_title:"string",exclude_subscribed_segments:"array.string",show_all_subscribed_segment:"boolean",title:"string",segments:"array.string",checkbox_background_color:"string",checkbox_tick_color:"string",default_segment_selection:"boolean"},unsubscribe_options:{enabled:"boolean",confirm_message:"string",ok_text:"string",cancel_text:"string",ok_button_background_color:"string",ok_button_text_color:"string",cancel_button_background_color:"string",cancel_button_text_color:"string"},personal_notification_options:{enabled:"boolean",label:"string"}};t.configSchema={subscriptionManagementWidget:a,subscription_management_widget:a}},9720:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addSdkEventListeners=void 0;const o=n(i(9272)),r=i(2919),s=i(5967),a=n(i(1762));t.addSdkEventListeners=()=>{o.default.on("notificationPermissionReceived",(e=>{try{const{subscriberId:t,isPermissionChanged:i}=e;if(i&&t){const e=new CustomEvent("PushEngage.onSubscriptionChange",{detail:{subscriber_id:t}});window.dispatchEvent(e)}}catch(e){a.default.error(e.message)}})),o.default.on("permissionPrompt",(e=>{try{const{prompt:t,optInType:i,state:n}=e,o=(0,r.getOptInNameByType)(i)||(0,r.getWidgetOptInNameByType)(i);switch(n){case"allow":{const e=new CustomEvent("PushEngage.permissionPrompt.allow",{detail:{prompt:t,name:o}});window.dispatchEvent(e);break}case"close":{const e=new CustomEvent("PushEngage.permissionPrompt.close",{detail:{prompt:t,name:o}});window.dispatchEvent(e);break}case"displayed":{const e=new CustomEvent("PushEngage.permissionPrompt.displayed",{detail:{prompt:t,name:o}});window.dispatchEvent(e);break}}}catch(e){a.default.error(e.message)}})),"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",(e=>{const t=e.data;if(t&&(0,s.isObject)(t))switch(t.eventName){case"PushEngage.notification.displayed":case"PushEngage.notification.click":case"PushEngage.notification.close":window.dispatchEvent(new CustomEvent(t.eventName,{detail:t.data}))}}))}},7910:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.showNotification=t.logout=t.identify=t.updateAppConfig=t.debug=t.showPermissionPrompt=t.removeSubscriptionManagementWidget=t.showSubscriptionManagementWidget=t.automatedNotification=t.getPermission=t.unsubscribe=t.showNativePermissionPrompt=t.addAlert=t.sendTriggerEvent=t.sendGoal=t.removeAttributes=t.setAttributes=t.addAttributes=t.getAttributes=t.getSubscriber=t.getSubscriberId=t.setProfileId=t.removeSegment=t.addSegmentWithDuration=t.addSegment=void 0;const d=a(i(4744)),c=a(i(1762)),l=i(3502),u=r(i(2044)),g=r(i(3101)),p=r(i(9707)),b=r(i(1409)),f=i(7340),m=r(i(4897)),v=r(i(8076)),_=r(i(8630)),h=a(i(9272)),y=i(6347),w=a(i(6920)),S=i(5967),I=i(662),P=r(i(2143)),O=i(1119),E=i(5971),k=i(561),A=i(9964);function D(e){c.default.debug(`Initialize the ${e} method.`)}t.addSegment=e=>{D("addSegment");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));b.addSegmentToSubscriber({segment:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Subscriber added to the segment successfully."}))).catch(n)}))};t.addSegmentWithDuration=e=>{D("addSegmentWithDuration");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));b.addSegmentWithDurationToSubscriber({segment:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Subscriber added to the segment successfully."}))).catch(n)}))};t.removeSegment=e=>{D("removeSegment");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));b.removeSegmentFromSubscriber({segment:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Subscriber removed from the segment successfully."}))).catch(n)}))};t.setProfileId=e=>{D("setProfileId");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));(0,f.setProfileIdToSubscriber)({profileId:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Profile ID set successfully"}))).catch(n)}))};t.getSubscriberId=()=>(D("getSubscriberId"),new Promise((e=>{e((0,l.getSubscriberIdFromStorage)())})));t.getSubscriber=()=>(D("getSubscriber"),new Promise(((e,t)=>{const i=(0,l.getSubscriberIdFromStorage)();if(!i)return t(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));const n={subscriber_id:i};u.getSubscriberData(i).then((t=>{e(Object.assign(Object.assign({},n),(e=>{if(!e)return{};const t=(0,S.omit)(e,["vapid_public_key","user_agent","device_type","trigger_status","ts_created","host","has_unsubscribed"]);return Object.assign(Object.assign({},t),{browser:e.device_type,automated_notification:!!e.trigger_status,subscription_at:e.ts_created,attributes:e.attributes||{},segments:e.segments||[]})})(t)))})).catch(t)})));t.getAttributes=()=>(D("getAttributes"),new Promise(((e,t)=>{const i=(0,l.getSubscriberIdFromStorage)();if(!i)return t(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.getAttributes(i).then(e).catch(t)})));t.addAttributes=e=>(D("addAttributes"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.addAttributes(n,e).then((()=>t({message:"Attributes added successfully."}))).catch(i)})));t.setAttributes=e=>(D("setAttributes"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.setAttributes(n,e).then((()=>t({message:"Attributes replaced successfully."}))).catch(i)})));t.removeAttributes=e=>(D("removeAttributes"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));p.removeAttributes(n,e).then((()=>t({message:"Attribute removed successfully."}))).catch(i)})));t.sendGoal=e=>{D("sendGoal");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));m.sendGoal({goal:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:"Goal sent successfully."}))).catch(n)}))};t.sendTriggerEvent=e=>{D("sendTriggerEvent");const t=(0,O.getAppData)(),i=(0,y.triggerCampaignTypesAvailability)({browseAbandonments:t.browseAbandonments,cartAbandonments:t.cartAbandonments,priceDropAlerts:t.priceDropAlerts,backInStockAlerts:t.backInStockAlerts,customTriggerCampaigns:t.customTriggerCampaigns});return new Promise(((n,o)=>{const r=(0,l.getSubscriberIdFromStorage)();if(!r)return o(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));if(!i.hasBrowseAbandonment&&!i.hasCartAbandonment&&!i.hasCustomTriggerCampaign)return o(new Error("Trigger campaign is not enabled in your site."));const s=[...t.browseAbandonments,...t.cartAbandonments,...t.customTriggerCampaigns].find((t=>"active"===t.status&&t.campaign_name===e.campaign_name));return s?e.event_name!==s.start_event&&e.event_name!==s.stop_event?o(new Error(`The event_name is invalid. It should be either '${s.start_event}' or '${s.stop_event}'.`)):void v.sendTriggerEvent({trigger:e,subscriberId:r,siteId:t.site.site_id}).then((()=>n({message:"Trigger event send successfully."}))).catch(o):o(new Error("The campaign_name is invalid. It cannot be found in our system."))}))};t.addAlert=e=>{D("addAlert");const t=(0,O.getAppData)(),i=(0,y.triggerCampaignTypesAvailability)({browseAbandonments:t.browseAbandonments,cartAbandonments:t.cartAbandonments,priceDropAlerts:t.priceDropAlerts,backInStockAlerts:t.backInStockAlerts,customTriggerCampaigns:t.customTriggerCampaigns});return new Promise(((n,o)=>{const r=(0,l.getSubscriberIdFromStorage)();return r?i.hasPriceDropAlert||i.hasBackInStockAlert?void _.addAlert({alert:e,subscriberId:r,siteId:t.site.site_id}).then((()=>n({message:("price_drop"===e.type?"Price Drop":"Back in Stock")+" alert send successfully."}))).catch(o):o(new Error("Alert campaign is not enabled in your site.")):o(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}))}))};t.showNativePermissionPrompt=e=>s(void 0,void 0,void 0,(function*(){D("showNativePermissionPrompt");const i=(0,O.getAppData)();return new Promise(((n,o)=>{const r=e=>s(void 0,void 0,void 0,(function*(){try{const{permission:i,subscriberId:o,isPermissionChanged:r}=e,s={is_permission_changed:r||!1,permission:i};if(o){const e=yield(0,t.getSubscriber)();s.subscriber_id=o,s.geo_info={city:e.city,country:e.country,state:e.state}}n(s),c.default.debug("The subscription process has been completed on button click.")}catch(e){c.default.error(e.message)}}));h.default.on("notificationPermissionReceived",r,{once:!0});let a=null==e?void 0:e.isServiceWorkerAvailable;const d=(0,y.getSubscriptionOptIns)(i.siteSettings.optin_settings);(0,S.isUndefined)(a)&&(a=!d.length||(0,y.isServiceWorkerAvailabilityEnabled)(i.siteSettings.optin_settings)),g.initializeSubscription({triggerFrom:"onClick",options:{clickOptions:Object.assign(Object.assign({},e),{isServiceWorkerAvailable:a})}}).then().catch((e=>{h.default.remove("notificationPermissionReceived",r),o(e),c.default.error(e)}))}))}));t.unsubscribe=()=>{D("unsubscribe");const e=(0,O.getAppData)();return new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));(0,I.unsubscribeSubscription)({subscriberId:n,siteId:e.site.site_id}).then((()=>{h.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0}),t({message:"User is unsubscribed successfully."})})).catch(i)}))};t.getPermission=()=>s(void 0,void 0,void 0,(function*(){D("getPermission");const e=(0,O.getAppData)(),{optin_settings:t,safari_options:i}=e.siteSettings,n=yield(0,I.getUserSubscriptionState)({optInSetting:t,safariWebPushPackageSetting:i});return"subscribed"===n?Promise.resolve("granted"):"default"===n?Promise.resolve("default"):Promise.resolve("denied")}));t.automatedNotification=({status:e})=>{D("automatedNotification");const t=(0,O.getAppData)();return new Promise(((i,n)=>{const o=(0,l.getSubscriberIdFromStorage)();if(!o)return n(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));u.updateAutomatedNotificationStatus({status:e,subscriberId:o,siteId:t.site.site_id}).then((()=>i({message:`Automated notification ${e} successfully.`}))).catch(n)}))};t.showSubscriptionManagementWidget=()=>s(void 0,void 0,void 0,(function*(){return D("showSubscriptionManagementWidget"),new Promise(((e,t)=>{P.showSubscriptionManagementWidget().then((t=>e({message:t}))).catch(t)}))}));t.removeSubscriptionManagementWidget=()=>s(void 0,void 0,void 0,(function*(){return D("removeSubscriptionManagementWidget"),new Promise(((e,t)=>{P.removeSubscriptionManagementWidget().then((t=>e({message:t}))).catch(t)}))}));t.showPermissionPrompt=()=>s(void 0,void 0,void 0,(function*(){D("showPermissionPrompt");const e=(0,O.getAppData)(),t=yield(0,E.getGeoInfo)({isEu:e.site.is_eu});return new Promise(((e,i)=>{const n=i=>{try{const{permission:n,subscriberId:o,isPermissionChanged:r}=i,s={permission:n,is_permission_changed:r||!1};"granted"===n&&o&&(s.subscriber_id=o,s.geo_info={country:t.country,state:t.state,city:t.city}),e(s),c.default.debug("The subscription process has been completed by showPermissionPrompt.")}catch(e){c.default.error(e.message)}};h.default.on("notificationPermissionReceived",n,{once:!0}),g.initializeSubscription({triggerFrom:"onInit",options:{initOptions:{forceInit:!0}}}).then().catch((e=>{h.default.remove("notificationPermissionReceived",n),i(e),c.default.error(e)}))}))}));t.debug=e=>{const t=`${k.storageName}Debug`;e||void 0===e?sessionStorage.setItem(t,"true"):sessionStorage.removeItem(t)};t.updateAppConfig=e=>{if(D("updateAppConfig"),!(0,S.isObject)(e))return;const t=(0,O.getAppData)(),i=(0,S.validateAndCleanData)(e,A.configSchema),n=i.subscriptionManagementWidget||i.subscription_management_widget;if(n){const e=t.siteSettings.subscription_management_widget;t.siteSettings.subscription_management_widget=d.default.all([e,n],{arrayMerge:(e,t)=>t})}};t.identify=e=>(D("identify"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));u.identify({subscriberId:n,subscriberFields:e}).then((()=>t({message:"Subscriber fields updated successfully."}))).catch(i)})));t.logout=e=>(D("logout"),new Promise(((t,i)=>{const n=(0,l.getSubscriberIdFromStorage)();if(!n)return i(new w.default({message:w.default.ERROR_MESSAGE.UserNotSubscribed,name:w.default.ERROR_NAME.UserNotSubscribed}));u.logout({subscriberId:n,subscriberFieldNames:e}).then((()=>t({message:"Subscriber fields removed successfully."}))).catch(i)})));t.showNotification=(e=k.defaultNotificationTitle,t)=>s(void 0,void 0,void 0,(function*(){if(D("showNotification"),"granted"!==Notification.permission)throw new w.default({message:"Notification permission is not granted",name:"NotificationPermissionError"});const i=yield navigator.serviceWorker.getRegistrations();if(0===i.length)throw new w.default({message:"The service worker is not registered.",name:"ServiceWorkerNotRegistered"});const[n]=i;try{const i=(0,S.generateRandomAlphanumeric)(7),o=`${k.defaultNotificationTag}-${i}`;return yield n.showNotification(e,Object.assign({tag:o,requireInteraction:!0},t)),{message:"Notification shown successfully."}}catch(e){throw new w.default({message:e.message,name:"ShowNotificationError"})}}))},4065:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getV1SDKMethods=void 0;t.getV1SDKMethods=()=>({subscribe:(e,t)=>{window._peq=window._peq||[],window._peq.push(["init",e,t])},isSubscribed:e=>{window._peq=window._peq||[],window._peq.push(["is-subscribed",e])},addSubscriberToSegment:(e,t)=>{window._peq=window._peq||[],window._peq.push(["add-to-segment",e,t])},removeSubscriberFromSegment:(e,t)=>{window._peq=window._peq||[],window._peq.push(["remove-to-segment",e,t])},addProfileId:(e,t)=>{window._peq=window._peq||[],window._peq.push(["add-to-profile",e,t])},addSubscriberToDynamicSegment:(e,t,i)=>{window._peq=window._peq||[],window._peq.push(["add-to-dynamic-segment",e,t,i])},addSegmentsInStorage:()=>{}})},3446:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logout=t.identify=t.removeSubscriptionManagementWidget=t.showSubscriptionManagementWidget=t.isSubscribed=t.initializeSubscription=t.initializeSubscriptionCallback=t.getPermission=t.unsubscribe=t.showNativePermissionPrompt=t.getSubscriber=t.sendGoal=t.addAlert=t.sendTriggerEvent=t.removeAttributes=t.setAttributes=t.addAttributes=t.getAttributes=t.setProfileId=t.removeSegment=t.addSegmentWithDuration=t.addSegment=void 0;const d=r(i(7910)),c=a(i(1762)),l=i(3502),u=a(i(9272)),g=i(662),p=i(2044),b=i(5967),f=i(9933),m=i(1119),v=e=>{const t={};if("UserNotSubscribed"===e.name)Object.assign(t,{statuscode:22,message:e.message});else{const i={statuscode:0,message:e.message};e.details&&Object.assign(i,{details:e.details}),Object.assign(t,i)}return t},_=e=>"function"==typeof e||(c.default.warn("Callback is not a function"),!1),h=(e,t)=>{const i={};if("granted"===e){const e=(0,l.getSubscriberIdFromStorage)(),n={};t.country&&(n.country=t.country),t.state&&(n.state=t.state),t.city&&(n.city=t.city);const o={subscriber_hash:e,subscriber_id:e};(0,b.isEmptyObject)(n)||Object.assign(o,{geoInfo:n,geo_info:n}),Object.assign(i,{statuscode:1,data:o,message:"User subscribed successfully.",status:"SUBSCRIBED",subscriber_hash:e})}else"denied"===e?Object.assign(i,{statuscode:2,status:"DENIED",message:"User denied push notification."}):"closed"===e?Object.assign(i,{statuscode:3,status:"CLOSED",message:"User closed subscription Opt-in."}):Object.assign(i,{statuscode:22,status:"DEFAULT",message:"User is not subscribed."});return i};function y(e){c.default.debug(`Initialize the ${e} v2 method.`)}t.addSegment=({segment:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("addSegment");const i={};try{const t=yield d.addSegment(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.addSegmentWithDuration=({segment:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("addSegmentWithDuration");const i={};try{const t=yield d.addSegmentWithDuration(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.removeSegment=({segment:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("removeSegment");const i={};try{const t=yield d.removeSegment(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.setProfileId=({profileId:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("setProfileId");const i={};try{const t=yield d.setProfileId(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.getAttributes=e=>s(void 0,void 0,void 0,(function*(){y("getAttributes");const t={};try{const e=yield d.getAttributes();Object.assign(t,{statuscode:1,data:e})}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)}));t.addAttributes=({attributes:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("addAttributes");const i={};try{const t=yield d.addAttributes(e),n=(0,l.getSubscriberIdFromStorage)(),o=yield(0,p.getSubscriberData)(n);Object.assign(i,Object.assign({statuscode:1,data:(null==o?void 0:o.attributes)||{}},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.setAttributes=({attributes:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("setAttributes");const i={};try{const t=yield d.setAttributes(e),n=(0,l.getSubscriberIdFromStorage)(),o=yield(0,p.getSubscriberData)(n);Object.assign(i,Object.assign({statuscode:1,data:(null==o?void 0:o.attributes)||{}},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.removeAttributes=({attributeNames:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("removeAttributes");const i={};try{const t=yield d.removeAttributes(e),n=(0,l.getSubscriberIdFromStorage)(),o=yield(0,p.getSubscriberData)(n);Object.assign(i,Object.assign({statuscode:1,data:(null==o?void 0:o.attributes)||{}},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.sendTriggerEvent=({trigger:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("sendTriggerEvent");const i={};try{const t=yield d.sendTriggerEvent(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.addAlert=({alert:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("addAlert");const i={};try{const t=yield d.addAlert(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.sendGoal=({goal:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("sendGoal");const i={};try{const t=yield d.sendGoal(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.getSubscriber=({options:e,callback:t})=>s(void 0,void 0,void 0,(function*(){var i;y("getSubscriber");const n={};try{const t=yield d.getSubscriber(),o=Object.assign(Object.assign({},t),{subscriber_hash:t.subscriber_id});if(o.device&&(o.device_type=o.browser),o.subscription_at&&(o.ts_created=o.subscription_at),o.subscription_url&&(o.host=null===(i=(0,f.getUrlObject)(o.subscription_url))||void 0===i?void 0:i.host),e&&(null==e?void 0:e.fields)&&Array.isArray(e.fields)&&e.fields.length>0){const t={};e.fields.forEach((e=>{o[e]&&(t[e]=o[e])})),Object.assign(n,{statuscode:1,data:t})}else Object.assign(n,{statuscode:1,data:o})}catch(e){Object.assign(n,v(e))}t&&_(t)&&t(n)}));t.showNativePermissionPrompt=({segment:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("showNativePermissionPrompt");const i={};try{const t=yield d.showNativePermissionPrompt({segment:e});let n={};t.subscriber_id&&(n=yield d.getSubscriber());const o=h(t.permission,{city:n.city,country:n.country,state:n.state});Object.assign(i,o)}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.unsubscribe=({callback:e})=>s(void 0,void 0,void 0,(function*(){y("unsubscribe");const t={};try{const e=yield d.unsubscribe();Object.assign(t,Object.assign({statuscode:1},e))}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)}));t.getPermission=({callback:e})=>s(void 0,void 0,void 0,(function*(){y("getPermission");const t=(0,m.getAppData)(),i={};try{let e=yield d.getPermission();(0,g.isAllSubscriptionOptInClosed)(t.siteSettings.optin_settings)&&(e="closed");let n={};"granted"===e&&(n=yield d.getSubscriber());const o=h(e,{city:n.city,country:n.country,state:n.state});Object.assign(i,o)}catch(e){Object.assign(i,v(e))}e&&_(e)&&e(i)}));t.initializeSubscriptionCallback=({callback:e})=>{y("initializeSubscriptionCallback");const t=(0,m.getAppData)();if(!e||!_(e))return;u.default.on("notificationPermissionReceived",(i=>s(void 0,void 0,void 0,(function*(){try{const{permission:n,isPermissionChanged:o,subscriberId:r}=i;if(!o)return;let s=n;(0,g.isAllSubscriptionOptInClosed)(t.siteSettings.optin_settings)&&(s="closed");let a={};r&&(a=yield d.getSubscriber());const c=h(s,{city:a.city,country:a.country,state:a.state});e(c)}catch(e){c.default.error(e.message)}}))),{once:!0})};t.initializeSubscription=({segment:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("initializeSubscription");const i=(0,m.getAppData)(),n={};try{const t=yield d.showPermissionPrompt(),{permission:o,is_permission_changed:r,subscriber_id:s}=t;if("granted"===o&&e&&(Array.isArray(e)||"string"==typeof e))try{yield d.addSegment(e)}catch(e){c.default.error(e.message)}if(!r)return;let a=o;(0,g.isAllSubscriptionOptInClosed)(i.siteSettings.optin_settings)&&(a="closed");let l={};s&&(l=yield d.getSubscriber());const u=h(a,{city:l.city,country:l.country,state:l.state});Object.assign(n,u)}catch(e){Object.assign(n,v(e))}t&&_(t)&&t(n)}));t.isSubscribed=({callback:e})=>s(void 0,void 0,void 0,(function*(){if(y("isSubscribed"),"function"==typeof e)try{const t=yield d.getPermission();e("granted"===t)}catch(e){c.default.error(e.message)}else c.default.warn("Callback is not a function")}));t.showSubscriptionManagementWidget=({callback:e})=>s(void 0,void 0,void 0,(function*(){y("showSubscriptionManagementWidget");const t={};try{const e=yield d.showSubscriptionManagementWidget();Object.assign(t,Object.assign({statuscode:1},e))}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)}));t.removeSubscriptionManagementWidget=({callback:e})=>s(void 0,void 0,void 0,(function*(){y("removeSubscriptionManagementWidget");const t={};try{const e=yield d.removeSubscriptionManagementWidget();Object.assign(t,Object.assign({statuscode:1},e))}catch(e){Object.assign(t,v(e))}e&&_(e)&&e(t)}));t.identify=({subscriberFields:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("identify");const i={};try{const t=yield d.identify(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}));t.logout=({subscriberFieldNames:e,callback:t})=>s(void 0,void 0,void 0,(function*(){y("logout");const i={};try{const t=yield d.logout(e);Object.assign(i,Object.assign({statuscode:1},t))}catch(e){Object.assign(i,v(e))}t&&_(t)&&t(i)}))},2033:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initializeSDK=void 0;const a=s(i(1762)),d=r(i(7910)),c=r(i(3446)),l=i(9720),u=i(4065),g=i(5967),p=i(1119),b=i(9964),f=(e,...t)=>{for(let i=0;iObject.assign(Object.assign({},d),{push:b.handlePushEvent,isPushNotificationSupported:b.isPushNotificationSupported,getInitOptions:p.getSDKInitOptions,getAppConfig:p.getAppData});t.initializeSDK=({commands:e,legacyCommands:t})=>{const i=(0,p.getSDKInitOptions)(),n=m();window.PushEngage=Object.freeze(n),e&&Array.isArray(e)&&(0,b.handlePushEvent)(...e),window._peq=Object.freeze({push:f.bind(null,i)}),t&&Array.isArray(t)&&f(i,...t),(0,g.isUndefined)(window._pe)&&(window._pe=Object.freeze((0,u.getV1SDKMethods)())),(0,l.addSdkEventListeners)()}},4986:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForAddSegment=void 0;const r=o(i(9272)),s=o(i(1762)),a=i(2610),d=i(6347),c=i(1409),l=i(1119);t.addEventListenerForAddSegment=()=>{const e=(0,l.getAppData)(),t=(0,l.getSDKInitOptions)();r.default.on("notificationPermissionReceived",(i=>n(void 0,void 0,void 0,(function*(){try{const{permission:n,subscriberId:o}=i;if("granted"!==n)return;if(!o)throw new Error("The subscriber ID is not available when the notification permission is granted.");let r=(0,d.getSegmentNamesFromRules)(e.segments);if(Array.isArray(t.segment)?r=[...r,...t.segment]:t.segment&&(r=[...r,t.segment]),0===r.length)return;try{yield(0,c.addSegmentToSubscriber)({subscriberId:o,segment:r,siteId:e.site.site_id})}catch(e){s.default.error(e.message)}}catch(t){s.default.error(t.message),(0,a.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},8919:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForShopifyCampaign=void 0;const d=a(i(9272)),c=a(i(1762)),l=i(2610),u=r(i(7429)),g=i(1382),p=i(1950),b=i(3502),f=i(7628),m=i(8076),v=i(4680),_=i(8630),h=i(7641),y=i(5967),w=i(1119),S=i(6347);t.addEventListenerForShopifyCampaign=()=>{const e=(0,w.getAppData)(),t=(0,w.getSDKInitOptions)(),i=(0,S.triggerCampaignTypesAvailability)({browseAbandonments:e.browseAbandonments,cartAbandonments:e.cartAbandonments,priceDropAlerts:e.priceDropAlerts,backInStockAlerts:e.backInStockAlerts,customTriggerCampaigns:e.customTriggerCampaigns});if(!t.isShopifySite)return;const n="pushengage-campaign-alert-widget";let o=!1;const r=t=>s(void 0,void 0,void 0,(function*(){var i,n,o;if(!(null===(i=window.Shopify)||void 0===i?void 0:i.shop))return;const r=(0,b.getShopifyCampaignDataFromStorage)(),s=yield(0,p.getCartItems)();if(0===s.length)return void(0!==(null===(n=null==r?void 0:r.cartVariantIds)||void 0===n?void 0:n.length)&&(yield Promise.all([(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`browseabandonment${e.site.site_id}`,event_name:"add-to-cart"},siteId:e.site.site_id}),(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`cartabandonment${e.site.site_id}`,event_name:"checkout"},siteId:e.site.site_id})]),(0,b.setShopifyCampaignDataToStorage)({cartVariantIds:[],browseVariantIds:[]})));const a=[],d=[];for(let i=0;is(void 0,void 0,void 0,(function*(){if(!e.siteSettings.shopify_options)return;if((0,f.getElementById)(n))return;if("product"!==u.getPageType())return;const o=(0,g.getProductTitleFromUrl)();if(!o)return;const r=yield(0,p.getProductByTitle)(o);if(!r)return;const a=u.getSelectedVariantId(),d=u.filterVariantFromVariantId(r,a);if(!d)return;yield(t=>s(void 0,void 0,void 0,(function*(){const i=(0,b.getShopifyCampaignDataFromStorage)();if(i&&i.nextAlertSyncTime&&i.nextAlertSyncTime>(0,h.getUnixTime)())return void c.default.debug("Syncing alerts from server is not required.");const n=yield(0,_.getAlerts)({subscriberId:t,siteId:e.site.site_id});if(!n)return;const o=[],r=[];n.forEach((e=>{"price_drop"===e.type?o.push((0,y.toInteger)(e.variant_id)):"inventory"===e.type&&r.push((0,y.toInteger)(e.variant_id))})),(0,b.setShopifyCampaignDataToStorage)({priceDropVariantIds:o,backInStockVariantIds:r,nextAlertSyncTime:(0,h.getUnixTime)(1)})})))(t);const m=r.available?"price_drop":"inventory";if(i.hasPriceDropAlert&&"price_drop"===m){(0,v.addCampaignAlertWidget)({alertType:m,alert:e.siteSettings.shopify_options.alert_campaign,site:e.site,variantId:d.id});const i=document.getElementById(`${n}-allow-button`);null==i||i.addEventListener("click",(()=>s(void 0,void 0,void 0,(function*(){try{yield(({variant:t,product:i,subscriberId:n})=>s(void 0,void 0,void 0,(function*(){var o;const r=(0,b.getShopifyCampaignDataFromStorage)();if(null===(o=null==r?void 0:r.priceDropVariantIds)||void 0===o?void 0:o.includes(t.id))return void c.default.debug(`Price Drop Alert campaign has already been processed for variant id ${t.id}.`);const s=yield u.getImageUrlsFromVariant(t);let a=s.largeImageUrl,d=s.imageUrl;if(!a){const e=yield u.getImageUrlsFromProduct(i);a=e.largeImageUrl,d=e.imageUrl}const l={type:"price_drop",product_id:`${i.id}`,link:location.href,price:u.convertPriceToFloat(t.price),variant_id:`${t.id}`,alert_price:u.convertPriceToFloat(t.price),availability:"inStock",title:(0,f.stripTagsAndDecodeEntity)(t.name),image_link:e.site.site_image||d||"",big_image_link:a||""};yield(0,_.addAlert)({subscriberId:n,alert:l,siteId:e.site.site_id}),(0,b.setShopifyCampaignDataToStorage)({priceDropVariantIds:[...(null==r?void 0:r.priceDropVariantIds)||[],t.id]}),c.default.debug(`Price drop alert triggered successfully with variant ids ${t.id}.`)})))({variant:d,product:r,subscriberId:t})}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}else if(i.hasBackInStockAlert&&"inventory"===m){(0,v.addCampaignAlertWidget)({alertType:m,alert:e.siteSettings.shopify_options.alert_campaign,site:e.site,variantId:d.id});const i=document.getElementById(`${n}-allow-button`);null==i||i.addEventListener("click",(()=>s(void 0,void 0,void 0,(function*(){try{yield(({variant:t,product:i,subscriberId:n})=>s(void 0,void 0,void 0,(function*(){var o;const r=(0,b.getShopifyCampaignDataFromStorage)();if(null===(o=null==r?void 0:r.backInStockVariantIds)||void 0===o?void 0:o.includes(t.id))return void c.default.debug(`Back in Stock Alert campaign has already been processed for variant id ${t.id}.`);const s=yield u.getImageUrlsFromVariant(t);let a=s.largeImageUrl,d=s.imageUrl;if(!a){const e=yield u.getImageUrlsFromProduct(i);a=e.largeImageUrl,d=e.imageUrl}const l={type:"inventory",product_id:`${i.id}`,link:location.href,price:u.convertPriceToFloat(t.price),variant_id:`${t.id}`,alert_price:u.convertPriceToFloat(t.price),availability:"outOfStock",title:(0,f.stripTagsAndDecodeEntity)(t.name),image_link:e.site.site_image||d||"",big_image_link:a||""};yield(0,_.addAlert)({subscriberId:n,alert:l,siteId:e.site.site_id}),(0,b.setShopifyCampaignDataToStorage)({backInStockVariantIds:[...(null==r?void 0:r.backInStockVariantIds)||[],t.id]}),c.default.debug(`Back in Stock alert triggered successfully with variant ids ${t.id}.`)})))({variant:d,product:r,subscriberId:t})}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}}));d.default.on("notificationPermissionReceived",(t=>s(void 0,void 0,void 0,(function*(){try{const{permission:d,subscriberId:v}=t;if("granted"!==d)return void(0,f.removeElement)(n);if(!v)throw new Error("The subscriber ID is not available when the notification permission is granted.");i.hasCartAbandonment&&(yield(t=>s(void 0,void 0,void 0,(function*(){var i,n;const o=null===(i=window.Shopify)||void 0===i?void 0:i.checkout;if(!(o&&o.total_price&&o.order_id))return;const r=String(o.order_id),s=(0,b.getShopifyCampaignDataFromStorage)();let a=[...(null==s?void 0:s.checkoutOrderIds)||[]];if(void 0===(null==s?void 0:s.checkoutOrderIds)&&(a=u.getLegacySDKShopifyCheckoutOrderIds()),a.includes(r))c.default.debug(`Cart Abandonment campaign checkout event has already been processed for order id ${r}.`);else if(0!==(null===(n=null==s?void 0:s.cartVariantIds)||void 0===n?void 0:n.length)){yield Promise.all([(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`browseabandonment${e.site.site_id}`,event_name:"add-to-cart"},siteId:e.site.site_id}),(0,m.sendTriggerEvent)({subscriberId:t,trigger:{campaign_name:`cartabandonment${e.site.site_id}`,event_name:"checkout",data:{revenue:o.total_price}},siteId:e.site.site_id})]);const i=200;(0,b.setShopifyCampaignDataToStorage)({cartVariantIds:[],browseVariantIds:[],checkoutOrderIds:(0,y.keepLastMaxElements)([...a,r],i)}),c.default.debug("Cart and Browse Abandonment campaigns cancelled successfully.")}})))(v),yield r(v),(t=>{if(o)return;if(o=!0,"product"!==u.getPageType())return;let i=!1;const n=setInterval((()=>s(void 0,void 0,void 0,(function*(){if(!i){i=!0;try{yield r(t)}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id}),clearInterval(n)}i=!1}}))),2e4)})(v)),i.hasBrowseAbandonment&&(yield(t=>s(void 0,void 0,void 0,(function*(){var i,n;if("product"!==u.getPageType())return;const o=(0,g.getProductTitleFromUrl)();if(!o)return;const r=yield(0,p.getProductByTitle)(o);if(!r)return;const s=u.getSelectedVariantId(),a=u.filterVariantFromVariantId(r,s);if(!a)return;const d=(0,b.getShopifyCampaignDataFromStorage)();if(d&&((null===(i=d.browseVariantIds)||void 0===i?void 0:i.includes(a.id))||(null===(n=d.cartVariantIds)||void 0===n?void 0:n.includes(a.id))))return void c.default.debug(`Browse Abandonment campaign has already been processed for variant id ${a.id}.`);const l=yield u.getImageUrlsFromVariant(a);let v=l.largeImageUrl,_=l.imageUrl;if(!v){const e=yield u.getImageUrlsFromProduct(r);v=e.largeImageUrl,_=e.imageUrl}const h={campaign_name:`browseabandonment${e.site.site_id}`,event_name:"browse",title:{productname:(0,f.stripTagsAndDecodeEntity)(a.name)},message:{price:u.convertPriceToFloat(a.price)},notification_url:{notificationurl:location.href},notification_image:{imageurl:e.site.site_image||_||""},big_image:{bigimageurl:v||""}};yield(0,m.sendTriggerEvent)({subscriberId:t,trigger:h,siteId:e.site.site_id}),(0,b.setShopifyCampaignDataToStorage)({browseVariantIds:[...(null==d?void 0:d.browseVariantIds)||[],a.id]}),c.default.debug(`Browse Abandonment campaign triggered successfully with variant id ${a.id}.`)})))(v)),(i.hasPriceDropAlert||i.hasBackInStockAlert)&&(yield a(v))}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},5872:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForSubscriberRecoveryWidget=void 0;const r=o(i(9272)),s=i(7628),a=o(i(1762)),d=i(2610),c=i(9676),l=i(5967),u=i(3101),g=i(6347),p=i(561),b=i(1119);t.addEventListenerForSubscriberRecoveryWidget=()=>{const e=(0,b.getAppData)(),t="pushengage-subscriber-recovery-widget",{chicklet_settings:i}=e.siteSettings;if(!i)return;const o=()=>n(void 0,void 0,void 0,(function*(){try{(0,s.removeElement)(t),yield(0,u.initializeSubscription)({triggerFrom:"onClick",options:{clickOptions:{widgetOptInType:p.widgetOptInType,isServiceWorkerAvailable:(0,g.isServiceWorkerAvailable)({optInSetting:e.siteSettings.optin_settings})}}}),a.default.debug("The subscription process was completed using the subscriber recovery widget.")}catch(t){a.default.error(t.message),(0,d.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}));r.default.on("notificationPermissionReceived",(r=>n(void 0,void 0,void 0,(function*(){try{const{permission:a}=r,d=(0,s.getElementById)(t);if("denied"!==a)return void(0,s.removeElement)(t);if(!!d)return;i.bell?(yield(0,l.delay)(1e3*i.settings.delay),(i=>{(0,c.addSubscriberRecoveryBellWidgetToPage)({widget:i,site:e.site});const r=(0,s.getElementById)(`${t}-bell`);null==r||r.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){yield o()}))))})(i.bell)):i.button&&(yield(0,l.delay)(1e3*i.settings.delay),(i=>{(0,c.addSubscriberRecoveryButtonWidgetToPage)({widget:i,site:e.site});const r=(0,s.getElementById)(`${t}-button`),a=(0,s.getElementById)(`${t}-close-button`);null==r||r.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){yield o()})))),null==a||a.addEventListener("click",(()=>{(0,s.removeElement)(t)}))})(i.button))}catch(t){a.default.error(t.message),(0,d.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},2143:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionManagementWidget=t.showSubscriptionManagementWidget=t.addEventListenerForSubscriptionManagementWidget=void 0;const r=o(i(9272)),s=i(7628),a=o(i(1762)),d=i(2610),c=i(3341),l=i(6347),u=i(1409),g=i(2044),p=i(3101),b=i(3502),f=i(662),m=i(561),v=i(1119),_=i(5971),h=o(i(612)),y=i(6280);let w=!1;const S=({permission:e,subscriberId:t,widgetId:i,initFrom:o})=>n(void 0,void 0,void 0,(function*(){const b=(0,v.getAppData)();if("granted"===e&&!t)throw new Error("The subscriber ID is not available when the notification permission is granted.");let _=null;"granted"===e&&t&&(_=yield(0,g.getSubscriberData)(t)),(0,c.refreshSubscriptionManagementWidgetView)({widgetId:i,subscriberData:_,initFrom:o,notificationPermission:e}),n(void 0,void 0,void 0,(function*(){const e=()=>{const e=[];return document.querySelectorAll(`#${i}-opt-in-segment input[type="checkbox"]`).forEach((t=>{const i=t;i.checked&&e.push(i.value)})),e},t=`${i}-opt-in-subscribe`,o=(0,s.getElementById)(t),r=document.querySelector(`#${t} input[type="checkbox"]`);null==r||r.addEventListener("click",(t=>n(void 0,void 0,void 0,(function*(){const i=t.target;try{i.disabled=!0,i.checked=!1,null==o||o.classList.add("pushengage-opt-in__switch--spin"),yield(0,p.initializeSubscription)({triggerFrom:"onClick",options:{clickOptions:{widgetOptInType:m.widgetOptInType,segment:e(),isServiceWorkerAvailable:(0,l.isServiceWorkerAvailable)({optInSetting:b.siteSettings.optin_settings})}}}),a.default.debug("The subscription process was completed using the subscription management widget.")}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:b.site.site_id})}}))))})),"granted"===e&&t&&((e=>{n(void 0,void 0,void 0,(function*(){const t=document.querySelectorAll(`#${i}-opt-in-segment input[type="checkbox"]`),o=document.querySelectorAll(`#${i}-opt-in-subscribed-segment input[type="checkbox"]`);Array.from(t).concat(Array.from(o)).forEach((t=>{t.addEventListener("click",(t=>n(void 0,void 0,void 0,(function*(){const i=t.target;i.disabled=!0,yield h.default.acquireLock("handleAddOrRemoveSegmentThroughWidget");try{i.checked?(yield(0,u.addSegmentToSubscriber)({subscriberId:e,segment:i.value,siteId:b.site.site_id}),a.default.debug(`Subscriber added to the "${i.value}" segment successfully.`)):(yield(0,u.removeSegmentFromSubscriber)({subscriberId:e,segment:i.value,siteId:b.site.site_id}),a.default.debug(`Subscriber removed from the "${i.value}" segment successfully.`))}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:b.site.site_id})}h.default.releaseLock("handleAddOrRemoveSegmentThroughWidget"),i.disabled=!1}))))}))}))})(t),(e=>{n(void 0,void 0,void 0,(function*(){const t=document.querySelector(`#${i}-opt-in-auto-notification input[type="checkbox"]`);null==t||t.addEventListener("click",(t=>n(void 0,void 0,void 0,(function*(){const n=t.target,o=n.checked?"enabled":"disabled",r="pushengage-opt-in__switch--spin",c=(0,s.getElementById)(`${i}-opt-in-auto-notification`);n.disabled=!0,n.checked=!n.checked,null==c||c.classList.add(r);try{yield(0,g.updateAutomatedNotificationStatus)({status:o,subscriberId:e,siteId:b.site.site_id}),a.default.debug(`Automated notification ${o} successfully.`)}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:b.site.site_id})}n.disabled=!1,n.checked=!n.checked,null==c||c.classList.remove(r)}))))}))})(t),(e=>{n(void 0,void 0,void 0,(function*(){const t=`${i}-opt-in-unsubscribe`,o=(0,s.getElementById)(t),c=(0,s.getElementById)(`${i}-unsubscribe-allow-button`),l=(0,s.getElementById)(`${i}-unsubscribe-close-button`),u=document.querySelector(`#${t} input[type="checkbox"]`),g=(0,s.getElementById)(`${i}-unsubscribe-popover`),p="pushengage-opt-in__switch--spin",m="pushengage-opt-in__popover--opened";u&&(u.addEventListener("click",(e=>n(void 0,void 0,void 0,(function*(){const t=e.target;t.disabled=!0,t.checked=!0,null==o||o.classList.add(p)})))),null==c||c.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){try{null==g||g.classList.remove(m),yield(0,f.unsubscribeSubscription)({subscriberId:e,siteId:b.site.site_id}),a.default.debug("The subscription was unsubscribed through the subscription management widget."),r.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0})}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:b.site.site_id})}})))),null==l||l.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){null==g||g.classList.remove(m),u&&(u.disabled=!1),null==o||o.classList.remove(p)})))))}))})(t))})),I=({widgetId:e,initFrom:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,v.getAppData)(),{subscription_management_widget:n}=i.siteSettings,o=(0,b.getSubscriberIdFromStorage)(),r=(0,s.getElementById)(e);if(!1===(0,l.isSubscriptionManagementWidgetHasContent)({widgetSettings:n,permission:o?"granted":"denied"}))return(0,s.removeElement)(e),void a.default.debug("The subscription management widget view is removed because the widget is either not enabled or has empty content. id = ",e);r&&(yield S({widgetId:e,initFrom:t,permission:o?"granted":"denied",subscriberId:o||void 0}),a.default.debug("The subscription management widget view is being updated. id = ",e))}));t.addEventListenerForSubscriptionManagementWidget=()=>{const e="pushengage-subscription-management-widget",t=(0,y.detectDeviceType)();r.default.on("notificationPermissionReceived",(i=>n(void 0,void 0,void 0,(function*(){const n=(0,v.getAppData)();try{const{subscription_management_widget:o}=n.siteSettings,r=yield(0,_.getGeoInfo)({isEu:n.site.is_eu}),{permission:d,subscriberId:c}=i;if("denied"!==d&&"granted"!==d)return(0,s.removeElement)(e),void a.default.debug(`The subscription management widget view is removed because the notification permission ${d}.`);if(!1===(0,l.isSubscriptionManagementWidgetHasContent)({widgetSettings:o,permission:d}))return(0,s.removeElement)(e),void a.default.debug("The subscription management widget view is removed because the widget is either not enabled or has empty content.");if(!1===(0,l.doSubscriptionManagementWidgetRulesPass)({geoInfo:r,deviceType:t,widgetSettings:o}))return(0,s.removeElement)(e),void a.default.debug("The subscription management widget view is removed because the display rules.");yield S({permission:d,subscriberId:c,widgetId:e})}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:n.site.site_id})}})))),r.default.on("updateSubscriptionManagementWidgetView",(()=>n(void 0,void 0,void 0,(function*(){const t=(0,v.getAppData)();try{yield I({widgetId:e})}catch(e){a.default.error(e.message),(0,d.sendErrorLog)("sdk",e,{siteId:t.site.site_id})}}))))};t.showSubscriptionManagementWidget=()=>n(void 0,void 0,void 0,(function*(){const e=(0,v.getAppData)(),t="pushengage-subscription-management-widget-api-triggered",{optin_settings:i,safari_options:o,subscription_management_widget:c}=e.siteSettings;if(!c.enabled)throw new Error("Subscription management widget is not enabled.");const u=yield(0,f.getUserSubscriptionState)({optInSetting:i,safariWebPushPackageSetting:o});if("default"===u)throw new Error("Your current notification permission is not granted or denied because the opt-in was not shown.");const g="subscribed"===u?"granted":"denied";if((0,s.getElementById)(t))throw new Error("Opt-in already showing on page.");if(!1===(0,l.isSubscriptionManagementWidgetHasContent)({widgetSettings:c,permission:g}))throw new Error("Opt-in is not applicable to show on the page.");const p=()=>n(void 0,void 0,void 0,(function*(){try{yield I({widgetId:t,initFrom:"api"})}catch(t){a.default.error(t.message),(0,d.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}));return yield S({widgetId:t,permission:g,initFrom:"api",subscriberId:(0,b.getSubscriberIdFromStorage)()||void 0}),w||(r.default.on("updateSubscriptionManagementWidgetView",p),r.default.on("notificationPermissionReceived",p),w=!0),"Opt-in shown successfully on the page."}));t.removeSubscriptionManagementWidget=()=>n(void 0,void 0,void 0,(function*(){const e=(0,v.getAppData)(),{subscription_management_widget:t}=e.siteSettings,i="pushengage-subscription-management-widget-api-triggered";if(!t.enabled)throw new Error("Subscription management widget is not enabled.");if(!(0,s.getElementById)(i))throw new Error("Opt-in not showing on page.");return(0,s.removeElement)(i),"Opt-in removed successfully on the page."}))},6856:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.handleResubscribeSubscription=void 0;const o=i(1);t.handleResubscribeSubscription=({subscription:e})=>n(void 0,void 0,void 0,(function*(){const t=yield(0,o.processSubscriptionData)({subscription:e,options:{tokenRefresh:!0}});yield(0,o.handlePostSubscriptionUpsert)({subscriberId:t,subscription:e,isSubDomain:!1})}))},5075:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notifyPermissionPromptAndGetSubscription=void 0;const r=o(i(1762)),s=i(7730),a=i(6280),d=i(6947),c=i(8642),l=i(9098),u=i(561);t.notifyPermissionPromptAndGetSubscription=({siteSettings:e,site:t})=>n(void 0,void 0,void 0,(function*(){r.default.debug("Requesting the notification permission prompt.");const{service_worker:i,safari_options:o,vapid_key:g,overlay_settings:p,optin_subscription_reminder:b}=e,f={},m=yield n(void 0,void 0,void 0,(function*(){try{"default"===(0,d.getNotificationPermission)({safariWebPushId:null==o?void 0:o.push_id})&&((0,c.addSubscriptionOverlayToPage)({site:t,overlay:p}),(0,l.addSubscriptionReminderPromptToPage)({site:t,reminderPrompt:b,overlay:p}));const{name:e}=(0,a.detectBrowser)();let i;return i="Safari"!==e||(0,d.hasSupportForPushApiInSafari)()?{permission:yield(0,s.requestNotificationPermission)()}:yield(0,s.requestSafariNotificationPermission)(o.push_id,u.env.__SAFARI_WEB_PUSH_PACKAGE_URL__,{app_id:t.site_key}),i}finally{(0,c.removeSubscriptionOverlay)(),(0,l.removeSubscriptionReminderPrompt)()}}));let v;if(r.default.debug(`User permission has been ${m.permission}.`),Object.assign(f,m),"granted"===m.permission){if(m.deviceToken)v=m;else{const e={vapidPublicKey:g.public_key};i.workerStatus&&(e.options={scope:i.scope?"/":void 0},e.scriptURL=i.worker);try{v=yield(0,s.subscribeToPushNotification)(e)}catch(t){if("InvalidStateError"!==t.name)throw t;yield(0,s.unsubscribeFromPushSubscription)(),v=yield(0,s.subscribeToPushNotification)(e)}}f.subscription=v}return f}))},2420:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.addResetNotificationPermissionPopupToPage=void 0;const o=i(7628),r=i(2346),s=i(6947),a=i(1119);t.addResetNotificationPermissionPopupToPage=e=>n(void 0,void 0,void 0,(function*(){const t=(0,a.getAppData)();(0,r.addResetNotificationPermissionPopupViewToPage)(e);const i="pushengage-reset-notification-permission-popup";return new Promise(((e,r)=>{const a=(0,o.getElementById)(`${i}-retry`),d=(0,o.getElementById)(`${i}-close`);if(!d||!a)return r(new Error("Could not find reset notification permission popup buttons"));null==a||a.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){var n;const r=(0,s.getNotificationPermission)({safariWebPushId:null===(n=t.siteSettings.safari_options)||void 0===n?void 0:n.push_id});if("denied"!==r)(0,o.removeElement)(i),e(r);else{const e=(0,o.getElementById)(`${i}-retry-loading`);e&&!e.classList.contains("disabled")&&(e.style.display="block",e.classList.add("disabled"),setTimeout((()=>{e.style.display="none",e.classList.remove("disabled")}),2e3))}})))),null==d||d.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){var n;(0,o.removeElement)(i);const r=(0,s.getNotificationPermission)({safariWebPushId:null===(n=t.siteSettings.safari_options)||void 0===n?void 0:n.push_id});e(r)}))))}))}))},8642:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionOverlay=t.addSubscriptionOverlayToPage=void 0;const n=i(7628),o=i(6280),r=i(8816),s="pushengage-subscription-overlay";t.addSubscriptionOverlayToPage=({overlay:e,site:t})=>{if(!e)return;if("mobile"===(0,o.detectDeviceType)())return;(0,n.getElementById)(s)||(0,r.addSubscriptionOverlayViewToPage)({site:t,overlay:e})};t.removeSubscriptionOverlay=()=>{(0,n.removeElement)(s)}},9098:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeSubscriptionReminderPrompt=t.addSubscriptionReminderPromptToPage=void 0;const n=i(7628),o=i(6280),r=i(1648),s=i(6947),a=i(3502),d=i(7641),c=i(5967),l="pushengage-subscription-reminder-prompt";let u;t.addSubscriptionReminderPromptToPage=({reminderPrompt:e,overlay:t,site:i})=>{const g=(0,o.detectDeviceType)();if(t&&"desktop"===g)return;if(!e)return;if((0,n.getElementById)(l))return;if(!(0,s.isSupportQuieterUI)()||"desktop"!==g)return;const{count:p}=(0,a.getReminderPromptDataFromStorage)()||{};p&&p>=e.max_prompt||(u=setTimeout((()=>{(0,r.addSubscriptionReminderPromptViewToPage)({reminderPrompt:e,site:i}),(0,a.setReminderPromptDataToStorage)();const t=(0,n.getElementById)(`${l}-button`);null==t||t.addEventListener("click",(()=>{(0,n.removeElement)(l),clearTimeout(u)}))}),1e3*(e=>{const{lastShownTime:t}=(0,a.getReminderPromptDataFromStorage)()||{};if(!t)return e.show_after_initial_delay;const i=((0,d.getUnixTime)()-t)/1e3;return(0,c.toInteger)(Math.max(e.show_again_after-i,0).toFixed(0))})(e)))};t.removeSubscriptionReminderPrompt=()=>{(0,n.removeElement)(l),clearTimeout(u)}},8976:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initializeSubscriptionOptInOnClick=t.initializeSubscriptionOptInForSubDomain=t.initializeSubscriptionOptIn=t.handleNotificationPermission=void 0;const d=a(i(6920)),c=i(1),l=i(9744),u=r(i(7628)),g=r(i(3502)),p=a(i(9272)),b=i(6347),f=a(i(1762)),m=i(6947),v=i(561),_=i(662),h=i(3876),y=i(5967),w=i(5075),S=i(2420),I=i(1119),P=a(i(612)),O=a(i(6917));t.handleNotificationPermission=({optInType:e,options:t={}})=>s(void 0,void 0,void 0,(function*(){var i,n,o,r;if(!P.default.isLocked("isNotificationPermissionPending"))try{yield P.default.acquireLock("isNotificationPermissionPending");const s=(0,I.getAppData)(),a=(0,m.isTokenRefresh)({safariWebPushId:null===(i=s.siteSettings.safari_options)||void 0===i?void 0:i.push_id});let d;if("denied"===(0,m.getNotificationPermission)({safariWebPushId:null===(n=s.siteSettings.safari_options)||void 0===n?void 0:n.push_id})){"denied"===(yield(0,S.addResetNotificationPermissionPopupToPage)(s.siteSettings.reset_notification_permission_popup))&&(d={permission:"denied"})}if(!d){"default"===(0,m.getNotificationPermission)({safariWebPushId:null===(o=s.siteSettings.safari_options)||void 0===o?void 0:o.push_id})&&p.default.trigger("permissionPrompt",{optInType:t.widgetOptInType||e,state:"displayed",prompt:"native"}),d=yield(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:s.siteSettings,site:s.site})}p.default.trigger("permissionPrompt",{optInType:t.widgetOptInType||e,prompt:"native",state:"granted"===(0,m.getNotificationPermission)({safariWebPushId:null===(r=s.siteSettings.safari_options)||void 0===r?void 0:r.push_id})?"allow":"close"}),yield(0,c.processNotificationPermission)({permissionData:d,optInType:e,options:{tokenRefresh:a,segment:t.segment,widgetOptInType:t.widgetOptInType}});const l="default"===d.permission&&(0,_.isAllSubscriptionOptInClosed)(s.siteSettings.optin_settings)?"denied":d.permission;p.default.trigger("notificationPermissionReceived",{permission:l,subscriberId:g.getSubscriberIdFromStorage()||void 0,isPermissionChanged:!0})}finally{P.default.releaseLock("isNotificationPermissionPending")}}));const E=()=>s(void 0,void 0,void 0,(function*(){const e=(0,I.getAppData)(),t=(0,b.getSubDomainSubscriptionUrl)({customSubDomainSetting:e.siteSettings.custom_url,siteSubDomain:e.site.site_subdomain});"tab"===t.type?window.open(t.url,"_blank"):window.open(t.url,"_blank","width=800, height=600")}));t.initializeSubscriptionOptIn=({activeSubscriptionOptIns:e})=>s(void 0,void 0,void 0,(function*(){var i;const n=(0,I.getAppData)();f.default.debug("The initialization of the subscription opt-in has begun.");const o=e=>{const i=e.optin_type,o=`pushengage-opt-in-${i}`,r=`pushengage-opt-in-${i}-tooltip`,a=u.getElementById(`pushengage-opt-in-${i}-allow`),c=u.getElementById(`pushengage-opt-in-${i}-close`),l=u.getElementById(`pushengage-opt-in-${i}-powered-by`),m=()=>new Promise(((s,a)=>{f.default.debug('The user clicked on the "Allow" button.'),p.default.trigger("permissionPrompt",{optInType:i,state:"allow",prompt:"html"});const c=(()=>{const e=[];return document.querySelectorAll(`#pushengage-opt-in-${i}__segments input[type="checkbox"]`).forEach((t=>{const i=t;i.checked&&e.push(i.value)})),e})();u.removeElement(o),u.removeElement(r),(0,b.canSubscribeViaServiceWorker)({isServiceWorkerAvailable:!!e.optin_sw_support})?(0,t.handleNotificationPermission)({optInType:i,options:{segment:c}}).then((()=>s())).catch((e=>a(e))):(O.default.set("subscriptionOnSubdomain",Object.assign(Object.assign({},O.default.get("subscriptionOnSubdomain")),{optInType:i,segment:c})),E(),p.default.on("notificationPermissionReceivedFromSubDomain",(e=>{try{const t=e;"error"in t?a(new d.default(Object.assign(Object.assign({},t.error),{details:{site_id:n.site.site_id}}))):s()}catch(e){a(e)}}),{once:!0}))}));return new Promise(((t,b)=>{try{if(!a)return void b(new d.default({message:"Allow button not found",type:"NotFoundException",details:{site:n.site.site_id}}));a.addEventListener("click",(()=>s(void 0,void 0,void 0,(function*(){try{yield m(),t()}catch(e){b(e)}})))),c&&c.addEventListener("click",(()=>s(void 0,void 0,void 0,(function*(){try{yield s(void 0,void 0,void 0,(function*(){f.default.debug('The user clicked on the "Close" button.'),p.default.trigger("permissionPrompt",{optInType:i,state:"close",prompt:"html"}),u.removeElement(o),u.removeElement(r),g.storeOptInCloseDataInStorage({optInType:i,storageDuration:e.cookie_duration}),(0,_.isAllSubscriptionOptInClosed)(n.siteSettings.optin_settings)&&p.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0}),n.siteSettings.sub_analytics.enabled&&(yield(0,h.sendOptInAnalytics)({optin_type:e.optin_type,site_id:n.site.site_id,block_1:!0,optin_1:!0}))})),t()}catch(e){b(e)}})))),l&&l.addEventListener("click",(()=>s(void 0,void 0,void 0,(function*(){window.open(v.poweredByReferralUrl,"_blank")}))))}catch(e){b(e)}}))},r=({optIn:e,isHtmlView:i})=>{const r=()=>s(void 0,void 0,void 0,(function*(){f.default.debug(`Initialized the ${e.optin_name} subscription opt-in.`),i?(p.default.trigger("permissionPrompt",{state:"displayed",prompt:"html",optInType:e.optin_type}),(0,l.addOptInViewToPage)({optIn:e,site:n.site}),yield o(e)):yield(0,t.handleNotificationPermission)({optInType:e.optin_type})}));return new Promise(((t,i)=>{const n=()=>s(void 0,void 0,void 0,(function*(){if(!(u.getScrollPercentage()s(void 0,void 0,void 0,(function*(){try{yield r(),t()}catch(e){i(e)}}))),1e3*e.optin_delay)):"scroll"===e.optin_category&&(f.default.debug(`Initializing the ${e.optin_name} subscription opt-in with a scroll(${e.optin_scroll}%).`),u.getScrollPercentage()>=e.optin_scroll?r().then((()=>t())).catch((e=>i(e))):window.addEventListener("scroll",n));const a=()=>{const t=`pushengage-opt-in-${e.optin_type}`,i=`pushengage-opt-in-${e.optin_type}-tooltip`;u.removeElement(t),u.removeElement(i),window.removeEventListener("scroll",n),o&&clearTimeout(o)};p.default.on("subscriptionInitializedFromClickManager",(()=>{try{a(),t()}catch(e){i(e)}}),{once:!0});const d=n=>{try{const{optInType:i,state:o,prompt:r}=n;if(P.default.isLocked("isNotificationPermissionPending")&&e.optin_type===v.optInTypes.singleStep)return;("allow"===o||"close"===o&&"native"===r)&&i!==e.optin_type&&(a(),t(),p.default.remove("permissionPrompt",d))}catch(e){i(e)}};p.default.on("permissionPrompt",d)}))},a=[],c=e.map((e=>e.optin_type));for(const t of e){if(g.isSubscriptionOptInClosed(t.optin_type))continue;f.default.debug(`Initializing the ${t.optin_name} subscription opt-in.`);const e={};switch(t.optin_type){case v.optInTypes.safari:case v.optInTypes.floatingBar:case v.optInTypes.bell:Object.assign(e,{optIn:t,isHtmlView:!0});break;case v.optInTypes.singleStep:if("denied"===(0,m.getNotificationPermission)({safariWebPushId:null===(i=n.siteSettings.safari_options)||void 0===i?void 0:i.push_id})){const i=1;c.length===i&&Object.assign(e,{optIn:t,isHtmlView:!0})}else(0,m.isUserGestureRequiredForPermissionPrompt)()?c.includes(v.optInTypes.bell)||Object.assign(e,{optIn:t,isHtmlView:!0}):Object.assign(e,{optIn:t});break;case v.optInTypes.largeSafari:case v.optInTypes.largeSafariWithSegments:case v.optInTypes.sleekOptInBox:Object.assign(e,{optIn:t,isHtmlView:!0});break;default:throw new d.default({message:"Opt-in type doesn't exist.",type:"NotFoundException",details:{site:n.site.site_id}})}(0,y.isEmptyObject)(e)||a.push(r(Object.assign({},e)))}yield Promise.all(a)}));t.initializeSubscriptionOptInForSubDomain=()=>{var e;const t=(0,I.getAppData)();if(!window.opener)return f.default.error("Window opener not found."),Promise.resolve();const i=document.referrer||"*",n=(0,m.isTokenRefresh)({safariWebPushId:null===(e=t.siteSettings.safari_options)||void 0===e?void 0:e.push_id}),o=()=>{window.opener.postMessage({source:"PushEngage",prompt:!0,siteId:t.site.site_id},i)},r=()=>new Promise(((e,i)=>{if((0,m.isUserGestureRequiredForPermissionPrompt)()){const n="pushengage-opt-in-intermediate-button",r=u.getElementById(n);if(!r)return void i(new d.default({message:"intermediate allow button not found",type:"NotFoundException",details:{site:t.site.site_id}}));r.style.visibility="visible",r.addEventListener("click",(()=>s(void 0,void 0,void 0,(function*(){o(),(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:t.siteSettings,site:t.site}).then((t=>e(t))).catch((e=>i(e))),r.style.visibility="hidden"}))))}else o(),(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:t.siteSettings,site:t.site}).then((t=>e(t))).catch((e=>i(e)))}));return new Promise((e=>{const a={permission:"default"};let d=!1;window.addEventListener("beforeunload",(function(){return d||(window.opener.postMessage(Object.assign(Object.assign({},a),{source:"PushEngage",siteId:t.site.site_id}),i),d=!0),e()})),s(void 0,void 0,void 0,(function*(){var e;switch((0,m.getNotificationPermission)({safariWebPushId:null===(e=t.siteSettings.safari_options)||void 0===e?void 0:e.push_id})){case"granted":try{return{permission:"granted",subscription:yield(0,_.resubscribeSubscription)({vapidSetting:t.siteSettings.vapid_key,serviceWorkerSetting:v.defaultServiceWorkerSetting,safariWebPushPackageSetting:t.siteSettings.safari_options})}}catch(e){return yield r()}case"denied":{const e=yield(0,S.addResetNotificationPermissionPopupToPage)(t.siteSettings.reset_notification_permission_popup);return"denied"===e?{permission:"denied"}:("default"===e&&o(),yield(0,w.notifyPermissionPromptAndGetSubscription)({siteSettings:t.siteSettings,site:t.site}))}default:return yield r()}})).then((e=>{Object.assign(a,e,{tokenRefresh:n}),window.close()})).catch((e=>{Object.assign(a,{error:{message:e.message,name:e.name,type:e.type}}),window.close()}))}))};t.initializeSubscriptionOptInOnClick=({options:e})=>{const i=(0,I.getAppData)();return new Promise(((n,o)=>{var r;const s=v.optInTypes.singleStep;(0,b.canSubscribeViaServiceWorker)({isServiceWorkerAvailable:null===(r=null==e?void 0:e.isServiceWorkerAvailable)||void 0===r||r})?(0,t.handleNotificationPermission)({optInType:s,options:{segment:null==e?void 0:e.segment,widgetOptInType:null==e?void 0:e.widgetOptInType}}).then(n).catch(o):(O.default.set("subscriptionOnSubdomain",Object.assign(Object.assign({},O.default.get("subscriptionOnSubdomain")),{optInType:s,segment:null==e?void 0:e.segment,widgetOptInType:null==e?void 0:e.widgetOptInType})),E(),p.default.on("notificationPermissionReceivedFromSubDomain",(e=>{try{const t=e;"error"in t?o(new d.default(Object.assign(Object.assign({},t.error),{details:{site_id:i.site.site_id}}))):n()}catch(e){o(e)}}),{once:!0}))}))}},3101:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initializeSubscription=void 0;const r=i(6347),s=i(662),a=o(i(1762)),d=i(6280),c=i(6856),l=i(8976),u=o(i(9272)),g=i(2044),p=i(3502),b=i(6947),f=i(1119),m=i(5971),v=o(i(612)),_=o(i(6917)),h=o(i(6920));t.initializeSubscription=({triggerFrom:e,options:t})=>n(void 0,void 0,void 0,(function*(){const i=(0,f.getAppData)(),o=Object.assign({},(0,f.getSDKInitOptions)());if(o.isSubscriptionOnSubDomain)yield(0,l.initializeSubscriptionOptInForSubDomain)();else{const{optin_settings:f,vapid_key:y,safari_options:w,service_worker:S}=i.siteSettings,{name:I}=(0,d.detectBrowser)();if("Safari"===I&&!(0,b.hasSupportForPushApiInSafari)()&&!w)return void a.default.warn("The Safari web push settings are not configured, Please configure them through the PushEngage app dashboard.");const P=yield(0,s.evaluateUserSubscriptionState)({optInSetting:f,safariWebPushPackageSetting:w,serviceWorkerSetting:S,vapidSetting:y});"onClick"===e?yield(e=>n(void 0,void 0,void 0,(function*(){if(v.default.isLocked("isNotificationPermissionPending"))throw new Error("Notification permission is pending, which means the permission prompt is already being displayed on the screen.");u.default.trigger("subscriptionInitializedFromClickManager",void 0);const{state:n,subscription:o}=e,{privacy_settings:r,publisher_settings:s}=i.siteSettings,b=yield(0,m.getGeoInfo)({isEu:i.site.is_eu});switch(n){case"subscribed":{a.default.debug("User subscription state is subscribed.");const e=(0,p.getSubscriberIdFromStorage)();yield(0,g.syncSubscriberData)({subscriberId:e,browserInfo:(0,d.getBrowserInfo)(),geoInfo:r.geoLocationEnabled?b:void 0,isPublisherSettingEnabled:null==s?void 0:s.enabled}),u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted"});break}case"resubscribe":{a.default.debug("User subscription state is resubscribe."),yield(0,c.handleResubscribeSubscription)({subscription:o});const e=(0,p.getSubscriberIdFromStorage)();u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted",isPermissionChanged:!0});break}default:a.default.debug(`User subscription state is ${n}, showing opt-in.`),yield(0,l.initializeSubscriptionOptInOnClick)({options:null==t?void 0:t.clickOptions})}})))(P):yield(e=>n(void 0,void 0,void 0,(function*(){var n;const{state:s,subscription:b}=e,{optin_settings:f,optin_management_settings:v,optin_subscription_rule:y,privacy_settings:w,publisher_settings:S}=i.siteSettings;switch(s){case"subscribed":{a.default.debug("User subscription state is subscribed.");const e=(0,p.getSubscriberIdFromStorage)(),t=yield(0,m.getGeoInfo)({isEu:i.site.is_eu});yield(0,g.syncSubscriberData)({subscriberId:e,browserInfo:(0,d.getBrowserInfo)(),geoInfo:w.geoLocationEnabled?t:void 0,isPublisherSettingEnabled:null==S?void 0:S.enabled}),u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted"});break}case"resubscribe":{a.default.debug("User subscription state is resubscribe."),yield(0,c.handleResubscribeSubscription)({subscription:b});const e=(0,p.getSubscriberIdFromStorage)();u.default.trigger("notificationPermissionReceived",{subscriberId:e,permission:"granted",isPermissionChanged:!0});break}case"unsubscribed":a.default.debug("User subscription state is unsubscribed."),u.default.trigger("notificationPermissionReceived",{permission:"denied"});break;case"denied":a.default.debug("User subscription state is denied."),u.default.trigger("notificationPermissionReceived",{permission:"denied"});break;case"closed":a.default.debug("Subscription closed: All opt-ins have been closed by the user."),u.default.trigger("notificationPermissionReceived",{permission:"denied"});break;default:{if(a.default.debug("User subscription state is default, showing opt-in."),!0!==(null===(n=null==t?void 0:t.initOptions)||void 0===n?void 0:n.forceInit)&&o.disabledDefaultPrompt)return void a.default.debug("Default prompt is disabled.");const e=yield(0,m.getGeoInfo)({isEu:i.site.is_eu});if(!(0,r.isSatisfyingSubscriptionRules)(v,e))return void a.default.info("No active subscription opt-in is available. Filtering by global rules.");const s=(0,r.filterSubscriptionOptInsByRules)(f,y,e);if(!s.length)return void a.default.info("No active subscription opt-in is available. Filtering by opt-in rules.");if(_.default.get("isSubscriptionInitialized"))throw new h.default({message:"Subscription is already initialized.",name:h.default.ERROR_NAME.SubscriptionAlreadyInitialized});_.default.set("isSubscriptionInitialized",!0),yield(0,l.initializeSubscriptionOptIn)({activeSubscriptionOptIns:s})}}})))(P)}a.default.debug("Subscription initialization completed.")}))},4970:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.syncDatabase=void 0;const r=i(1119),s=o(i(1762)),a=i(8380);t.syncDatabase=()=>{const e=(0,r.getAppData)();n(void 0,void 0,void 0,(function*(){try{yield(0,a.syncAppId)(e.site.site_key)}catch(e){s.default.error(`Error during sync appId to database, ${e.message}`)}}))}},8350:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventListenerForUnsubscribeWidget=void 0;const r=o(i(9272)),s=i(7628),a=i(1642),d=i(662),c=o(i(1762)),l=i(2610),u=i(2044),g=i(6347),p=i(5967),b=i(1119);t.addEventListenerForUnsubscribeWidget=()=>{const e=(0,b.getAppData)(),t="pushengage-unsubscribe-widget",{sub_management_settings:i}=e.siteSettings;if(!i)return;const o=i=>n(void 0,void 0,void 0,(function*(){yield(0,d.unsubscribeSubscription)({subscriberId:i,siteId:e.site.site_id}),c.default.debug("The subscription was unsubscribed through the unsubscribe widget."),yield(0,p.delay)(2e3),(0,s.removeElement)(t),r.default.trigger("notificationPermissionReceived",{permission:"denied",isPermissionChanged:!0})}));r.default.on("notificationPermissionReceived",(r=>n(void 0,void 0,void 0,(function*(){try{const{permission:d,subscriberId:p}=r,b=(0,s.getElementById)(t);if("granted"!==d)return void(0,s.removeElement)(t);if(!p)throw new Error("The subscriber ID is not available when the notification permission is granted.");if(!!b)return;if(!(0,g.isUrlSatisfyingUrlRules)({include:i.settings.rules.include,exclude:i.settings.rules.exclude},location.href))return;if(i.bell){const r=yield(0,u.getSubscriberData)(p);(({widget:i,subscriberId:r,automatedNotification:d})=>{(0,a.addUnsubscribeWidgetBellViewToPage)({widget:i,automatedNotification:d,site:e.site});const g=(0,s.getElementById)(`${t}-unsubscribe-button`),p=(0,s.getElementById)(`${t}-automated-notification`);null==g||g.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){try{const e=(0,s.getElementById)(t);null==e||e.classList.add("pushengage-unsubscribe-widget--hidden"),yield o(r)}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}})))),null==p||p.addEventListener("change",(i=>n(void 0,void 0,void 0,(function*(){try{const n=(0,s.getElementById)(t),o=i.target,a=o.checked,d="pushengage-unsubscribe-widget--automated-notification-enabled";o.disabled=!0,a?null==n||n.classList.add(d):null==n||n.classList.remove(d),yield(0,u.updateAutomatedNotificationStatus)({subscriberId:r,siteId:e.site.site_id,status:a?"enabled":"disabled"}),o.disabled=!1}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))})({subscriberId:p,widget:i.bell,automatedNotification:!!(null==r?void 0:r.trigger_status)})}else i.button&&(({widget:i,subscriberId:r})=>{(0,a.addUnsubscribeWidgetButtonViewToPage)({widget:i,site:e.site});const d=(0,s.getElementById)(`${t}-unsubscribe-title`),u=(0,s.getElementById)(`${t}-action-yes`),g=(0,s.getElementById)(`${t}-action-no`),p=(0,s.getElementById)(`${t}-close-button`);null==d||d.addEventListener("click",(()=>{const e=(0,s.getElementById)(t);null==e||e.classList.remove("pushengage-unsubscribe-widget--initial-state"),null==e||e.classList.add("pushengage-unsubscribe-widget--action-state")})),null==g||g.addEventListener("click",(()=>{const e=(0,s.getElementById)(t);null==e||e.classList.remove("pushengage-unsubscribe-widget--action-state"),null==e||e.classList.add("pushengage-unsubscribe-widget--initial-state")})),null==u||u.addEventListener("click",(()=>n(void 0,void 0,void 0,(function*(){try{const e=(0,s.getElementById)(t);null==e||e.classList.add("pushengage-unsubscribe-widget--final-state"),yield o(r)}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}})))),null==p||p.addEventListener("click",(()=>{(0,s.removeElement)(t)}))})({subscriberId:p,widget:i.button})}catch(t){c.default.error(t.message),(0,l.sendErrorLog)("sdk",t,{siteId:e.site.site_id})}}))))}},1340:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=t.removeSubscriberIdFromTag=t.getColorTheme=t.isHostPushEngageSubDomain=t.getSDKInitOptions=t.isDOMContentLoaded=t.getSDKLoadCount=void 0;const n=i(5967),o=i(561);t.getSDKLoadCount=()=>{const e=window.__PushEngageSdkLoadCount||0;return window.__PushEngageSdkLoadCount=e+1};t.isDOMContentLoaded=()=>new Promise((e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>e())):e()}));t.getSDKInitOptions=(e,t=[])=>{if(!e||!Array.isArray(e))return;let i;for(let t=0;t0){const[e,t]=n;if("init"===e&&"object"==typeof t){i=t;break}}}if(!i)return;if((0,n.isUndefined)(window.dialog_box)||(i.isSubscriptionOnSubDomain=!0),!i.isLegacySDK)return i;if(!Array.isArray(t))return i;let o=!1;for(let e=0;e0){const[e,t]=r;if("init"===e&&(o=!0,("string"==typeof t||Array.isArray(t))&&(i.segment=t)),"config"===e&&"object"==typeof t){const e={};(0,n.isUndefined)(t.worker)||(e.path=t.worker),(0,n.isUndefined)(t.scope)||(e.scope=t.scope),(0,n.isUndefined)(t.workerStatus)||(e.status=t.workerStatus),(0,n.isEmptyObject)(e)||(i.serviceWorker=e)}}}return o?i:Object.assign(Object.assign({},i),{disabledDefaultPrompt:!0})};t.isHostPushEngageSubDomain=e=>`${e}.${o.env.__DOMAIN_NAME__}`===location.host;t.getColorTheme=e=>{const t=e.replace("#","");return(.299*parseInt(t.substring(0,2),16)+.587*parseInt(t.substring(2,4),16)+.114*parseInt(t.substring(4,6),16))/255>.5?"light":"dark"};t.removeSubscriberIdFromTag=e=>{if(!e.includes("-"))return e;const t=e.lastIndexOf("-");return e.substring(0,t)};t.sleep=e=>new Promise((t=>setTimeout(t,e)))},2919:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getWidgetOptInNameByType=t.getOptInNameByType=t.getOptInRuleNameByType=t.getOptInTypeByName=void 0;const i=[{type:1,name:"safari",displayName:"Safari Style Box"},{type:2,name:"floating_bar",displayName:"Floating Bar"},{type:3,name:"bell",displayName:"Bell Placed Bar"},{type:4,name:"single_step",displayName:"Push Single Step Opt-in"},{type:6,name:"large_safari",displayName:"Large Safari Style Box"},{type:8,name:"large_safari_with_segment",displayName:"Large Safari Style with Segment"},{type:9,name:"sleek_opt_in_box",displayName:"Sleek Opt-in Box"}],n=[{type:127,name:"subscription_management_widget",displayName:"Subscriber Recovery/Subscription Management Widget"}];t.getOptInTypeByName=e=>{var t;return null===(t=i.find((t=>t.name===e)))||void 0===t?void 0:t.type};t.getOptInRuleNameByType=e=>{var t;return null===(t=i.find((t=>t.type===e)))||void 0===t?void 0:t.name};t.getOptInNameByType=e=>{var t;return null===(t=i.find((t=>t.type===e)))||void 0===t?void 0:t.displayName};t.getWidgetOptInNameByType=e=>{var t;return null===(t=n.find((t=>t.type===e)))||void 0===t?void 0:t.displayName}},3502:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSubscriptionOnSubDomain=t.setReminderPromptDataToStorage=t.getReminderPromptDataFromStorage=t.setShopifyCampaignDataToStorage=t.getShopifyCampaignDataFromStorage=t.deleteSubscriberFieldsFromStorage=t.deleteSubscriberDataFromStorage=t.updateSubscriberDataToStorage=t.addSubscriberDataToStorage=t.getSubscriberDataFromStorage=t.getOldSubscriberIdFromStorage=t.getSubscriberIdFromStorage=t.storeSubscriptionUnsubscribedDataInStorage=t.storeSubscriptionDeniedDataInStorage=t.storeOptInCloseDataInStorage=t.storeSubscriptionDataInStorage=t.isSubscriptionDenied=t.isSubscriptionUnsubscribed=t.hasSubscriptionDataInStorage=t.isSubscriptionOptInClosed=t.clearOldSubscriptionDataFromStorage=t.isSubscriptionValidForSite=t.isSubscribedInStorage=t.getParsedStorageData=void 0;const n=i(6485),o=i(561),r=i(5967),s=i(7641),a=i(1119),d=i(6280);t.getParsedStorageData=e=>{const t=(0,n.getDataFromLocalStorage)(e);return t&&(0,r.safeParse)(t)||{}};t.isSubscribedInStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return(0,r.isUndefined)(e.isSubscribed)?!!e.id:e.isSubscribed};t.isSubscriptionValidForSite=()=>{const e=(0,t.getParsedStorageData)(o.storageName),i=(0,a.getAppData)().site.site_key;return(0,r.isUndefined)(e.appId)?!!e.id:e.appId==i};t.clearOldSubscriptionDataFromStorage=()=>{let e=(0,t.getParsedStorageData)(o.storageName);e=(0,r.omit)(e,["id","isSubDomain","endpoint","subscriber","appId","isSubscribed"]),(0,r.isEmptyObject)(e)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,e)};t.isSubscriptionOptInClosed=e=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.optInClosed)return!1;const n=i.optInClosed,a=Array.isArray(e)?e:[e];for(let e=0;e{const i=(0,t.getParsedStorageData)(o.storageName),n=i.isSubDomain||"granted"===e;return!!(i.endpoint&&i.id&&(0,t.isSubscribedInStorage)()&&n)};t.isSubscriptionUnsubscribed=({notificationPermission:e})=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.unsubscribed)return!1;const{data:a,expiresAt:d}=i.unsubscribed;return!(d<=(0,s.getUnixTime)())&&(!1===a.isSubDomain&&"granted"!==e?((()=>{let e=(0,t.getParsedStorageData)(o.storageName);e=(0,r.omit)(e,["unsubscribed"]),(0,r.isEmptyObject)(e)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,e),(0,n.deleteDataFromCookies)("PushSubscriberStatus")})(),!1):!0===a.status)};t.isSubscriptionDenied=({notificationPermission:e})=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.denied)return!1;const{data:a,expiresAt:c}=i.denied;if(c<=(0,s.getUnixTime)())return!1;const{name:l}=(0,d.detectBrowser)(),u="serviceWorker"in navigator&&"Notification"in window&&"PushManager"in window;return("Safari"!==l||u)&&!1===a.isSubDomain&&"denied"!==e?((()=>{const e=(0,t.getParsedStorageData)(o.storageName),i=(0,r.omit)(e,["denied"]);(0,r.isEmptyObject)(i)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,i)})(),!1):!0===a.status};t.storeSubscriptionDataInStorage=({subscriberId:e,subscription:t,isSubDomain:i})=>{const r={isSubDomain:i,appId:(0,a.getAppData)().site.site_key,id:e,isSubscribed:!0,endpoint:t.endpoint||t.deviceToken};(0,n.setDataToLocalStorage)(o.storageName,r),(0,n.deleteDataFromCookies)(["PushSubscriberStatus","peclosed"])};t.storeOptInCloseDataInStorage=({optInType:e,storageDuration:i})=>{const r=(0,t.getParsedStorageData)(o.storageName),a={optInClosed:Object.assign(Object.assign({},r.optInClosed),{[e]:{data:!0,expiresAt:(0,s.getUnixTime)(i)}})};(null==r?void 0:r.reminderPrompt)&&(a.reminderPrompt=r.reminderPrompt),(0,n.setDataToLocalStorage)(o.storageName,a)};t.storeSubscriptionDeniedDataInStorage=({isSubDomain:e,storageDuration:i})=>{const r=(0,t.getParsedStorageData)(o.storageName),a={denied:{data:{status:!0,isSubDomain:e},expiresAt:(0,s.getUnixTime)(i)}};r.reminderPrompt&&(a.reminderPrompt=r.reminderPrompt),(0,n.setDataToLocalStorage)(o.storageName,a),(0,n.deleteDataFromCookies)(["PushSubscriberStatus","peclosed"])};t.storeSubscriptionUnsubscribedDataInStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName),r=(e=>({id:e.id,isSubscribed:e.isSubscribed,appId:e.appId}))(i),a=Object.assign(Object.assign({},r),{isSubscribed:!1,unsubscribed:{data:{status:!0,isSubDomain:e},expiresAt:(0,s.getUnixTime)(365)}});i.reminderPrompt&&(a.reminderPrompt=i.reminderPrompt),(0,n.setDataToLocalStorage)(o.storageName,a),(0,n.deleteDataFromCookies)(["PushSubscriberStatus","peclosed"])};t.getSubscriberIdFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.id&&(0,t.isSubscriptionValidForSite)()&&(0,t.isSubscribedInStorage)()?e.id:null};t.getOldSubscriberIdFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.id&&(0,t.isSubscriptionValidForSite)()?e.id:null};t.getSubscriberDataFromStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName).subscriber;return!i||i.expiresAt<=(0,s.getUnixTime)()?null:e?i.data[e]||null:i.data};t.addSubscriberDataToStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName),r=Object.assign(Object.assign({},i),{subscriber:Object.assign(Object.assign({},i.subscriber),{expiresAt:(0,s.getUnixTime)(1),data:e})});(0,n.setDataToLocalStorage)(o.storageName,r)};t.updateSubscriberDataToStorage=e=>{var i,r;const a=(0,t.getParsedStorageData)(o.storageName),d=(null===(i=a.subscriber)||void 0===i?void 0:i.expiresAt)||(0,s.getUnixTime)(1),c=Object.assign(Object.assign({},a),{subscriber:Object.assign(Object.assign({},a.subscriber),{expiresAt:d,data:Object.assign(Object.assign({},null===(r=null==a?void 0:a.subscriber)||void 0===r?void 0:r.data),e)})});(0,n.setDataToLocalStorage)(o.storageName,c)};t.deleteSubscriberDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);if(!e.subscriber)return;const i=(0,r.omit)(e,["subscriber"]);(0,r.isEmptyObject)(e)?(0,n.deleteDataFromLocalStorage)(o.storageName):(0,n.setDataToLocalStorage)(o.storageName,i)};t.deleteSubscriberFieldsFromStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName);if(!i.subscriber||!i.subscriber.data)return;const s=(0,r.omit)(i.subscriber.data,e);(0,n.setDataToLocalStorage)(o.storageName,Object.assign(Object.assign({},i),{subscriber:Object.assign(Object.assign({},i.subscriber),{data:s})}))};t.getShopifyCampaignDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.shopify?e.shopify:null};t.setShopifyCampaignDataToStorage=e=>{const i=(0,t.getParsedStorageData)(o.storageName),r=Object.assign(Object.assign({},i),{shopify:Object.assign(Object.assign({},null==i?void 0:i.shopify),e)});(0,n.setDataToLocalStorage)(o.storageName,r)};t.getReminderPromptDataFromStorage=()=>{const e=(0,t.getParsedStorageData)(o.storageName);return e.reminderPrompt?e.reminderPrompt:null};t.setReminderPromptDataToStorage=()=>{var e;const i=(0,t.getParsedStorageData)(o.storageName),a={reminderPrompt:{count:(0,r.toInteger)(null===(e=i.reminderPrompt)||void 0===e?void 0:e.count)+1,lastShownTime:(0,s.getUnixTime)()}};(null==i?void 0:i.denied)&&(a.denied=i.denied),(null==i?void 0:i.unsubscribed)&&(a.unsubscribed=i.unsubscribed),(null==i?void 0:i.optInClosed)&&(a.optInClosed=i.optInClosed),(0,n.setDataToLocalStorage)(o.storageName,a)};t.isSubscriptionOnSubDomain=()=>(0,t.getParsedStorageData)(o.storageName).isSubDomain},8380:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.syncSubscriberData=t.getSubscriberIdByAppId=t.deleteFailedClickedNotificationTag=t.getFailedClickedNotificationTags=t.addFailedClickedNotificationTag=t.deleteFailedViewedNotificationTag=t.getFailedViewedNotificationTags=t.addFailedViewedNotificationTag=t.getNotificationTagsByKey=t.updateNotificationTagByKey=t.syncAppId=t.getAppId=void 0;const a=i(561),d=r(i(4719)),c=i(5967);t.getAppId=()=>s(void 0,void 0,void 0,(function*(){const e=yield d.openDB(a.database.name,a.database.version,a.database.stores),t=yield d.getObject(e,"ids","appId");return(null==t?void 0:t.appId)||null}));t.syncAppId=e=>s(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.upsertObject(t,"ids",{id:"appId",appId:e})}));t.updateNotificationTagByKey=(e,t)=>s(void 0,void 0,void 0,(function*(){const i=yield d.openDB(a.database.name,a.database.version,a.database.stores),n=yield d.getObject(i,"ids",t),o=(null==n?void 0:n.notificationTags)||[];yield d.upsertObject(i,"ids",{id:t,notificationTags:(0,c.keepLastMaxElements)([...o,e],5)})}));t.getNotificationTagsByKey=e=>s(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores),i=yield d.getObject(t,"ids",e);return i&&i.notificationTags||[]}));t.addFailedViewedNotificationTag=({tag:e})=>s(void 0,void 0,void 0,(function*(){const t="failedViewedNotificationTags",i=yield d.openDB(a.database.name,a.database.version,a.database.stores);(yield d.getObject(i,t,e))||(yield d.upsertObject(i,t,{id:e}))}));t.getFailedViewedNotificationTags=()=>s(void 0,void 0,void 0,(function*(){const e=yield d.openDB(a.database.name,a.database.version,a.database.stores);return yield d.getObjects(e,"failedViewedNotificationTags")}));t.deleteFailedViewedNotificationTag=e=>s(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.deleteObject(t,"failedViewedNotificationTags",e)}));t.addFailedClickedNotificationTag=({tag:e,action:t})=>s(void 0,void 0,void 0,(function*(){const i="failedClickedNotificationTags",n=yield d.openDB(a.database.name,a.database.version,a.database.stores);(yield d.getObject(n,i,e))||(yield d.upsertObject(n,i,{action:t,id:e}))}));t.getFailedClickedNotificationTags=()=>s(void 0,void 0,void 0,(function*(){const e=yield d.openDB(a.database.name,a.database.version,a.database.stores);return yield d.getObjects(e,"failedClickedNotificationTags")}));t.deleteFailedClickedNotificationTag=e=>s(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.deleteObject(t,"failedClickedNotificationTags",e)}));t.getSubscriberIdByAppId=e=>s(void 0,void 0,void 0,(function*(){const t=yield d.openDB(a.database.name,a.database.version,a.database.stores),i=yield d.getObject(t,"ids","subscriberId");return(null==i?void 0:i.appId)===e&&(null==i?void 0:i.subscriberId)||null}));t.syncSubscriberData=({subscriberId:e,appId:t})=>s(void 0,void 0,void 0,(function*(){const i=yield d.openDB(a.database.name,a.database.version,a.database.stores);yield d.upsertObject(i,"ids",{id:"subscriberId",subscriberId:e,appId:t})}))},7730:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function a(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}d((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.subscribeToPushNotificationFromWorker=t.getDeviceTokenFromEndpoint=t.unregisterServiceWorker=t.unsubscribeFromPushSubscription=t.isValidUnsubscription=t.getSafariSubscription=t.getPushSubscription=t.subscribeToPushNotification=t.isServiceWorkerRegistered=t.requestSafariNotificationPermission=t.requestNotificationPermission=void 0;const r=o(i(6920)),s=i(5967),a=o(i(612)),d=e=>{const t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),i=("undefined"!=typeof window?window:self).atob(t),n=new Uint8Array(i.length);for(let e=0;en(void 0,void 0,void 0,(function*(){var i;const n=Object.assign({},t);let o=e;if(!e){const e=yield navigator.serviceWorker.getRegistrations();if(0===e.length)throw new r.default({message:"The service worker is not registered and tries to get a subscription.",name:r.default.ERROR_NAME.ServiceWorkerNotFound});const[t]=e;if(o=null===(i=t.active)||void 0===i?void 0:i.scriptURL,!o)throw new r.default({message:"The service worker scriptURL is missing in the registration object.",name:r.default.ERROR_NAME.ServiceWorkerNotFound});t.scope===`${location.origin}/`&&(n.scope="/")}try{const e=yield navigator.serviceWorker.register(o,n);return(null==n?void 0:n.scope)?yield navigator.serviceWorker.ready:yield(0,s.delay)(500),e}catch(e){throw new r.default({message:e.message,name:r.default.ERROR_NAME.ServiceWorkerNotRegistering})}}));t.requestNotificationPermission=()=>n(void 0,void 0,void 0,(function*(){if(!("Notification"in window))throw new Error("This browser does not support notifications.");if(!("requestPermission"in Notification))throw new r.default({message:"This browser does not support requestPermission.",name:r.default.ERROR_NAME.RequestPermissionNotSupported});const e=yield Notification.requestPermission();return"default"===e&&"denied"===Notification.permission?"denied":e}));t.requestSafariNotificationPermission=(e,t,i)=>new Promise((function(n,o){if(!("safari"in window)||!("pushNotification"in window.safari))return void o(new Error("Safari push notifications are not supported."));const r=window.safari.pushNotification.permission(e);"default"===r.permission?window.safari.pushNotification.requestPermission(t,e,i,(function(e){n(JSON.parse(JSON.stringify(e)))})):n(JSON.parse(JSON.stringify(r)))}));t.isServiceWorkerRegistered=()=>n(void 0,void 0,void 0,(function*(){if(!("serviceWorker"in navigator))return!1;return(yield navigator.serviceWorker.getRegistrations()).length>0}));t.subscribeToPushNotification=({vapidPublicKey:e,scriptURL:t,options:i})=>n(void 0,void 0,void 0,(function*(){try{yield a.default.acquireLock("subscribeToPushNotification");const n={userVisibleOnly:!0,applicationServerKey:d(e)},o=yield c({scriptURL:t,options:i}),s=yield o.pushManager.subscribe(n),l=JSON.parse(JSON.stringify(s));if(!l||!l.endpoint)throw new r.default({message:"Required details are missing in the subscription data.",name:"MissingSubscriptionDetailsError"});return l}catch(e){if("AbortError"===e.name||"NotAllowedError"===e.name||"MissingSubscriptionDetailsError"===e.name)throw new r.default({message:e.message,name:r.default.ERROR_NAME.DisabledPushSubscriptionError});throw e}finally{a.default.releaseLock("subscribeToPushNotification")}}));t.getPushSubscription=({scriptURL:e,options:t})=>n(void 0,void 0,void 0,(function*(){const i=yield c({scriptURL:e,options:t}),n=yield i.pushManager.getSubscription();if(!n)return null;const o=JSON.parse(JSON.stringify(n));return o&&o.endpoint?o:null}));function l(){return"Notification"in window&&"serviceWorker"in navigator&&"PushManager"in window&&"granted"===Notification.permission}t.getSafariSubscription=e=>{const t=window.safari.pushNotification.permission(e);return JSON.parse(JSON.stringify(t))},t.isValidUnsubscription=l;t.unsubscribeFromPushSubscription=e=>n(void 0,void 0,void 0,(function*(){if(!l())return;const t=yield navigator.serviceWorker.getRegistrations();for(let i=0;in(void 0,void 0,void 0,(function*(){const e=yield navigator.serviceWorker.getRegistrations();for(let t=0;t{let t="";return t=e.indexOf("token=")>-1?e.slice(e.search("token=")+6):e.split("/")[e.split("/").length-1],t};t.subscribeToPushNotificationFromWorker=e=>n(void 0,void 0,void 0,(function*(){const t={userVisibleOnly:!0,applicationServerKey:d(e)},i=yield self.registration.pushManager.subscribe(t),n=JSON.parse(JSON.stringify(i));if(!n||!n.endpoint)throw new r.default({message:"Required details are missing in the subscription data.",name:"MissingSubscriptionDetailsError"});return n}))},1382:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getProductTitleFromUrl=t.isUrlSatisfyingRules=void 0;const n=i(9933);t.isUrlSatisfyingRules=(e,t=location.href)=>{const i=new Set([t,`${t}/`,encodeURI(t),(0,n.safeDecodeURIComponent)(t)]);for(const[o,r]of Object.entries(e)){const e=new Set([...r,...r.map((e=>`${e}/`))]);switch(r.forEach((t=>{e.add(`http://${t}`),e.add(`https://${t}`),e.add(`http://${t}/`),e.add(`https://${t}/`),e.add(encodeURI(t)),e.add((0,n.safeDecodeURIComponent)(t))})),o){case"exact":if(Array.from(e).some((e=>i.has(e))))return!0;break;case"contains":if(Array.from(e).some((e=>i.has(e)||t.includes(e))))return!0;break;case"start":if(Array.from(e).some((e=>i.has(e)||t.startsWith(e))))return!0}}return!1};t.getProductTitleFromUrl=(e=location.href)=>{const t=e.split("/products/");if(t.length<2)return;const i=t.pop();if(!i)return;return i.split("?")[0]}},6947:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isTokenRefresh=t.getNotificationPermission=t.isUserGestureRequiredForPermissionPrompt=t.isSupportQuieterUI=t.isPushNotificationSupported=t.supportsVapidPush=t.safariWebPushSupported=t.hasSupportForPushApiInSafari=void 0;const n=i(6280),o=i(9933),r=i(5967);t.hasSupportForPushApiInSafari=()=>{const{name:e}=(0,n.detectBrowser)();return"Safari"===e&&"serviceWorker"in navigator&&"Notification"in window&&"PushManager"in window};t.safariWebPushSupported=()=>{const{name:e,version:t}=(0,n.detectBrowser)();return"Safari"===e&&t>=11&&"Notification"in window&&"safari"in window&&"pushNotification"in window.safari};t.supportsVapidPush=()=>{const{name:e,version:t}=(0,n.detectBrowser)(),i=(0,n.detectDeviceType)(),s=(0,o.detectSiteType)();if("Ucbrowser"===e||"Firefox"===e&&(48===t||49===t)||"Opera"===e&&41===t||"Yandex"===e&&"mobile"===i)return!1;return!!("http"===s&&"Firefox"===e&&t>=50)||"Notification"in window&&"PushManager"in window&&"undefined"!=typeof PushSubscriptionOptions&&(0,r.hasOwn)(PushSubscriptionOptions.prototype,"applicationServerKey")};t.isPushNotificationSupported=()=>(0,t.supportsVapidPush)()||(0,t.safariWebPushSupported)();t.isSupportQuieterUI=()=>{const{name:e,version:t}=(0,n.detectBrowser)(),i=(0,n.detectDeviceType)(),o=(0,n.getChromiumStatus)();return o.isChromium&&o.version>=80||"desktop"===i&&"Firefox"===e&&t>=72};t.isUserGestureRequiredForPermissionPrompt=()=>{const{name:e,version:t}=(0,n.detectBrowser)();return"Firefox"===e&&t>=72||"Safari"===e||"Yandex"===e};t.getNotificationPermission=({safariWebPushId:e})=>{const{name:i}=(0,n.detectBrowser)();if(e&&"Safari"===i&&window.safari&&!(0,t.hasSupportForPushApiInSafari)()){return window.safari.pushNotification.permission(e).permission}return Notification.permission};t.isTokenRefresh=({safariWebPushId:e})=>"granted"===(0,t.getNotificationPermission)({safariWebPushId:e})},6582:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getOptInSegmentView=t.getPoweredByView=t.showPopoverView=t.getStyleForHtmlElement=t.showTooltipView=void 0;const n=i(7628),o=i(561),r=i(5967);t.showTooltipView=({targetId:e,tooltipId:t})=>{const i=(0,n.getElementById)(e),o=(0,n.getElementById)(t);if(!i||!o)return;(0,n.addCSSProperties)(t,{inset:"unset"});const r=i.getBoundingClientRect(),s=window.innerWidth,a=window.innerHeight,d={},c=o.offsetHeight>r.height?r.height/2:o.offsetHeight/2;let l="",u="";const g=r.height>o.offsetHeight?(r.height-o.offsetHeight)/2:0;r.bottom>o.offsetHeight||r.bottom>a-r.bottom?(d.bottom=`${a-r.bottom+g}px`,u="pushengage-opt-in__tooltip__arrow--bottom",r.bottomo.offsetWidth?(d.right=s-(s-document.documentElement.clientWidth)-r.left+14+"px",l="pushengage-opt-in__tooltip__arrow--right"):(d.left=`${r.right+14}px`,l="pushengage-opt-in__tooltip__arrow--left"),(0,n.addCSSProperties)(t,d),o.classList.add("pushengage-opt-in__tooltip--opened",l,u),o.style.setProperty("--tooltip-arrow-offset",`${c}px`)};t.getStyleForHtmlElement=e=>e.replace(/\s+/g," ").trim();t.showPopoverView=({targetId:e,popoverId:t})=>{const i=(0,n.getElementById)(e),o=(0,n.getElementById)(t);if(!i||!o)return;(0,n.addCSSProperties)(t,{inset:"unset"});const r=i.getBoundingClientRect(),s=12,a=window.innerHeight,d=window.innerWidth,c={};o.classList.contains("pushengage-opt-in__popover--beside")?(r.left-s>d-r.right?c.right=`${r.width+s}px`:c.left=`${r.width+s}px`,r.bottom>o.offsetHeight||r.bottom>a-r.bottom?(c.bottom=a-r.bottom+"px",r.bottomd-r.right?c.right=d-r.right+"px":c.left=`${r.left}px`,r.top>a-r.bottom||r.top>o.offsetHeight?(c.bottom=`${a-r.top+s}px`,r.top+se?`
\n Powered by ${o.brandName}\n
`:"";t.getOptInSegmentView=({optIn:e,getCheckboxBodyStyle:t,className:i})=>{let n="";if(Array.isArray(e.optin_segments)&&e.optin_segments.length){const o=e.default_segment_selection?"checked":"";e.optin_segments.forEach(((i,s)=>{n+=`\n
\n \n
\n `})),n=`\n
\n ${n}\n
\n `}return n}},4680:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addCampaignAlertWidget=void 0;const n=i(6582),o=i(561),r=i(7628),s=i(3502);t.addCampaignAlertWidget=({alert:e,alertType:t,site:i,variantId:a})=>{const d=(({alert:e,alertType:t,site:i,variantId:r})=>{var a,d;const c=(0,s.getShopifyCampaignDataFromStorage)();let l="";("price_drop"===t&&(null===(a=null==c?void 0:c.priceDropVariantIds)||void 0===a?void 0:a.includes(r))||"inventory"===t&&(null===(d=null==c?void 0:c.backInStockVariantIds)||void 0===d?void 0:d.includes(r)))&&(l="pushengage-campaign-alert-widget--alert-sent");const u=`visibility: hidden;\n --bell-background-color: ${e.bell_background};\n --bell-color: ${e.bell_color};\n --bell-height: 50px;\n --bell-width: 50px;\n --bell-right: 30px;\n --bell-left: 30px;\n --bell-bottom:50px;\n --text-color: ${e.text_color};\n --allow-button-color: ${"#ffffff"===e.bell_color?e.bell_background:e.bell_color};\n --popover-background-color: #ffffff;\n --popover-color: #0d0d0d;\n`;return`\n \n \n
\n ${o.bellIcon}\n
\n \n\n \n
\n ${e.message[t].before_subscription}\n
\n\n \n ${e.message[t].after_subscription}\n \n\n \n ${e.message[t].allow_btn_txt}\n \n\n ${(0,n.getPoweredByView)({enabled:!i.is_whitelabel,id:"pushengage-campaign-alert-widget-powered-by",className:"pushengage-campaign-alert-widget__powered-by"})}\n \n \n `})({alert:e,alertType:t,site:i,variantId:a});(0,r.addContentAfterBody)(d),(()=>{const e="pushengage-campaign-alert-widget",t=`${e}-opt-in`,i=`${e}-bell`,r=document.getElementById(e),s=document.getElementById(`${e}-bell`),a=document.getElementById(`${e}-allow-button`),d=document.getElementById(`${e}-powered-by`),c=document.getElementById(t);if(!r||!c)return;const l="pushengage-opt-in__popover--opened",u=`${e}--alert-sent`;null==d||d.addEventListener("click",(()=>{window.open(o.poweredByReferralUrl,"_blank")})),null==a||a.addEventListener("click",(()=>{r.classList.add(u),setTimeout((()=>{c.classList.remove(l)}),3e3)})),null==s||s.addEventListener("click",(()=>{c.classList.contains(l)?c.classList.remove(l):(0,n.showPopoverView)({targetId:i,popoverId:t})}))})()}},6399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.attachTooltipEventToBell=t.getBellPlacedBarView=void 0;const n=i(561),o=i(7628),r=i(6582),s=i(6280);t.getBellPlacedBarView=({optIn:e,site:t})=>{const i="pe-bottom-left"===e.placement?"left":"right",o=`visibility: hidden;\n --bell-background-color: ${e.bg};\n --bell-color: ${e.allowBtnBg};\n --bell-height: 50px;\n --bell-width: 50px;\n --bell-right:30px;\n --bell-left:30px;\n --bell-bottom:50px;\n`,s=Array.isArray(e.optin_segments)&&e.optin_segments.length?"":`id="pushengage-opt-in-${e.optin_type}-allow"`;return`\n
\n \n
${n.bellIcon}
\n
\n ${(({optIn:e,site:t})=>{let i="";Array.isArray(e.optin_segments)&&e.optin_segments.length&&(i=`\n \n ${e.optin_allow_btn_txt}\n \n `);const n=`--checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: #ffffff;\n `,o=(0,r.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__bell__tooltip__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`});return`\n \n
${e.optin_title}
\n ${(0,r.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=1?"8px":"0px"),className:"pushengage-opt-in__bell__tooltip__segments"})}\n ${i} ${o}\n \n `})({optIn:e,site:t})}\n \n `};t.attachTooltipEventToBell=({optIn:e,site:t})=>{const i=`pushengage-opt-in-${e.optin_type}-bell`,n=`pushengage-opt-in-${e.optin_type}-tooltip`,a=Array.isArray(e.optin_segments)&&e.optin_segments.length||!t.is_whitelabel,d=(0,o.getElementById)(i),c=(0,o.getElementById)(n);if(!d||!c)return;const l=(0,s.detectDeviceType)(),u="pushengage-opt-in__tooltip--opened";if("desktop"===l){let e=!1,t=!1;d.addEventListener("mouseover",(()=>{t=!0,(0,r.showTooltipView)({tooltipId:n,targetId:i})})),d.addEventListener("mouseleave",(()=>{t=!1,setTimeout((()=>{e||c.classList.remove(u)}),500)})),a&&(d.addEventListener("click",(()=>{c.classList.contains(u)?c.classList.remove(u):(0,r.showTooltipView)({tooltipId:n,targetId:i})})),c.addEventListener("mouseover",(()=>{e=!0})),c.addEventListener("mouseleave",(()=>{setTimeout((()=>{e=!1,t||c.classList.remove(u)}),300)})))}else d.addEventListener("click",(()=>{c.classList.contains(u)?c.classList.remove(u):((0,r.showTooltipView)({tooltipId:n,targetId:i}),a||setTimeout((()=>{c.classList.remove(u)}),1e3))}),{passive:!0})}},5853:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFloatingBarView=void 0;const n=i(6280),o=i(1340),r=i(6582),s=i(561);t.getFloatingBarView=({optIn:e,site:t})=>{const i=(0,o.getColorTheme)(e.bg);let a=(0,n.detectDeviceType)();window.innerWidth<=650&&(a="mobile");const d=`pushengage-opt-in__floating-bar pushengage-opt-in__floating-bar--${e.placement} pushengage-opt-in__floating-bar--${a} pushengage-opt-in__floating-bar--${i}`,c="#ffffff"===e.closeBtnBg?"1px solid #d8d8d8":`1px solid ${e.closeBtnBg}`,l=`visibility: hidden;\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --close-btn-border: ${c};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n --opt-in-width: 100%;\n`;return`\n \n ${"desktop"===a?`\n
\n ${t.site_image?'
\n
\n
':`\n ${s.bellIcon}\n
`}\n\n
\n
${e.optin_title}
\n\n ${(0,r.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:()=>"margin: 14px 17px 0 0",className:"pushengage-opt-in__floating-bar__segments"})}\n
\n \n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n `:`\n
\n ${t.site_image?'
\n
\n
':`\n ${s.bellIcon}\n
`}\n\n
${e.optin_title}
\n \n\n ${(0,r.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__floating-bar__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n `}\n ${(0,r.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__floating-bar__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n `}},4212:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getLargeSafariStyleView=void 0;const n=i(6280),o=i(1340),r=i(6582),s=i(561);t.getLargeSafariStyleView=({optIn:e,site:t})=>{const i=(0,n.detectDeviceType)(),a=`pushengage-opt-in__large-safari-style pushengage-opt-in__large-safari-style--${i} pushengage-opt-in__large-safari-style--${(0,o.getColorTheme)(e.bg)}`;let d;d="desktop"===i&&window.innerWidth>390?"390px":"mobile"===i&&window.innerWidth>360?"360px":`${window.innerWidth}px`;const c="#ffffff"===e.closeBtnBg?"1px solid #d8d8d8":`1px solid ${e.closeBtnBg}`,l=e.checkbox_tick_color===e.bg?e.checkbox_bg:e.checkbox_tick_color,u=`visibility: hidden;\n --opt-in-width: ${d};\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --close-btn-border: ${c};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${l};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n`;return`\n \n
\n ${t.site_image?'
\n
\n
':`\n ${s.bellIcon}\n
`}\n\n
${e.optin_title}
\n \n\n ${(0,r.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__large-safari-style__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n\n ${(0,r.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__large-safari-style__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n `}},6787:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSafariStyleView=void 0;const n=i(1340),o=i(6582),r=i(561);t.getSafariStyleView=({optIn:e,site:t})=>{const i=(0,n.getColorTheme)(e.bg),s=`pushengage-opt-in__safari-style pushengage-opt-in__safari-style--${e.placement} pushengage-opt-in__safari-style--${i}`,a="#ffffff"===e.closeBtnBg?"1px solid #d8d8d8":`1px solid ${e.closeBtnBg}`,d=`visibility: hidden;\n --opt-in-width: ${window.innerWidth>370?370:window.innerWidth}px;\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --close-btn-border: ${a};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n`;return`\n \n
\n ${t.site_image?'
\n
\n
':`\n ${r.bellIcon}\n
`}\n\n
${e.optin_title}
\n \n\n ${(0,o.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__safari-style__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n ${e.optin_close_btn_txt}\n \n \n\n ${(0,o.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__safari-style__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n `}},5755:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSleekOptInBox=void 0;const n=i(561),o=i(1340),r=i(6582);t.getSleekOptInBox=({optIn:e,site:t})=>{const i=(0,o.getColorTheme)(e.bg),s=`pushengage-opt-in__sleek-opt-in-box pushengage-opt-in__sleek-opt-in-box--${e.placement} pushengage-opt-in__sleek-opt-in-box--${i}`,a=`visibility: hidden;\n --opt-in-width: ${window.innerWidth>370?370:window.innerWidth}px;\n --opt-in-background-color: ${e.bg};\n --allow-btn-background-color: ${e.allowBtnBg};\n --close-btn-background-color: ${e.closeBtnBg};\n --opt-in-icon-url: url('${t.site_image}');\n --checkbox-checked-tick-color: ${e.checkbox_tick_color};\n --checkbox-unchecked--color: ${e.checkbox_bg};\n --checkbox-checked-background-color: ${e.bg};\n`;return`\n \n
\n
\n
\n
${n.bellIcon}
\n
${e.site_name}
\n
\n \n ${n.closeIcon}\n
\n
\n\n
\n
${e.optin_title}
\n ${t.site_image?'
\n
\n
':`\n ${n.bellIcon}\n
`}\n \n\n ${(0,r.getOptInSegmentView)({optIn:e,getCheckboxBodyStyle:e=>"margin-top:"+(e>=2?"10px":"0px"),className:"pushengage-opt-in__sleek-opt-in-box__segments"})}\n\n
\n \n ${e.optin_allow_btn_txt}\n
\n \n\n ${(0,r.getPoweredByView)({enabled:!t.is_whitelabel,className:"pushengage-opt-in__sleek-opt-in-box__powered-by",id:`pushengage-opt-in-${e.optin_type}-powered-by`})}\n \n \n `}},9744:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addOptInViewToPage=void 0;const n=i(6787),o=i(4212),r=i(5853),s=i(5755),a=i(6399),d=i(561),c=i(7628),l=i(6280);t.addOptInViewToPage=({optIn:e,site:t})=>{let i;switch(e.optin_type){case d.optInTypes.safari:i=(0,n.getSafariStyleView)({optIn:e,site:t});break;case d.optInTypes.floatingBar:i=(0,r.getFloatingBarView)({optIn:e,site:t});break;case d.optInTypes.bell:i=(0,a.getBellPlacedBarView)({optIn:e,site:t});break;case d.optInTypes.singleStep:i=(0,a.getBellPlacedBarView)({site:t,optIn:Object.assign(e,e.bell)});break;case d.optInTypes.largeSafari:case d.optInTypes.largeSafariWithSegments:i=(0,o.getLargeSafariStyleView)({optIn:e,site:t});break;case d.optInTypes.sleekOptInBox:i=(0,s.getSleekOptInBox)({optIn:e,site:t})}i&&(0,c.addContentAfterBody)(i),e.optin_type!==d.optInTypes.bell&&e.optin_type!==d.optInTypes.singleStep||(0,a.attachTooltipEventToBell)({optIn:e,site:t});if("mobile"===(0,l.detectDeviceType)()&&(e.optin_type===d.optInTypes.largeSafari||e.optin_type===d.optInTypes.largeSafariWithSegments)){const t=document.getElementById(`pushengage-opt-in-${e.optin_type}`);if(t){const{offsetWidth:e,offsetHeight:i}=t,n=(window.innerWidth-e)/2,o=(window.innerHeight-i)/2;n>0?t.style.left=`${n}px`:(t.style.left="0",t.style.right="0"),o>0?t.style.top=`${o}px`:(t.style.top="0",t.style.bottom="0")}}}},2346:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addResetNotificationPermissionPopupViewToPage=void 0;const n=i(1340),o=i(6280),r=i(7628),s=i(6582),a=i(561),d=e=>{const t=(0,n.getColorTheme)(e.background_color),{name:i}=(0,o.detectBrowser)(),d=(0,o.detectDeviceType)(),c="#ffffff"===e.close_button_background_color?"1px solid #d8d8d8":`1px solid ${e.close_button_background_color}`,l=`visibility: hidden;\n --popup-width: ${window.innerWidth>620?580:window.innerWidth-20}px;\n --popup-background-color: ${e.background_color};\n --retry-btn-background-color: ${e.retry_button_background_color};\n --close-btn-background-color: ${e.close_button_background_color};\n --close-btn-border: ${c};\n --instruction-url: url('${(({variants:e,deviceType:t,browserName:i})=>{const n=e.find((e=>e.platform===`${t}-${i.toLowerCase()}`));if(!n){const i=e.find((e=>e.platform===`${t}-chrome`));return null==i?void 0:i.url}return n.url})({deviceType:d,browserName:i,variants:e.variants})}');\n `;return`\n
\n ${(({message:e,variants:t,deviceType:i,browserName:n})=>{const o=t.find((e=>e.platform===`${i}-${n.toLowerCase()}`));let s=e;return(null==o?void 0:o.message)&&(s=(0,r.richEditorHasNoValue)(o.message)?e:o.message),s})({deviceType:d,browserName:i,message:e.message,variants:e.variants})}\n
\n\n
\n
\n
\n\n
\n \n ${a.loadingIcon}\n ${e.retry_button_label}\n
\n \n ${e.close_button_label}\n \n \n `};t.addResetNotificationPermissionPopupViewToPage=e=>{const t=d(e);(0,r.addContentAfterBody)(t)}},9676:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addSubscriberRecoveryBellWidgetToPage=t.addSubscriberRecoveryButtonWidgetToPage=void 0;const n=i(6582),o=i(7628),r=i(561),s=i(1340),a=i(6280);t.addSubscriberRecoveryButtonWidgetToPage=({widget:e,site:t})=>{const i=(({widget:e,site:t})=>{const i=(0,s.getColorTheme)(e.bg),o=(0,a.detectDeviceType)(),d="desktop"===o?e.desktop_position:e.mobile_position,c="desktop"===o?e.desktop_placement:e.mobile_placement,l=`visibility: hidden;\n --widget-background-color: ${e.bg};\n --widget-color: ${e.color};`;return`\n \n
\n
${r.bellIcon}
\n \n ${e.label}\n
\n\n ${(0,n.getPoweredByView)({enabled:!t.is_whitelabel,id:"pushengage-subscriber-recovery-widget-powered-by",className:"pushengage-subscriber-recovery-widget__powered-by"})}\n \n\n \n ${r.closeIcon}\n \n \n `})({widget:e,site:t});(0,o.addContentAfterBody)(i),(()=>{const e="pushengage-subscriber-recovery-widget",t=(0,o.getElementById)(e),i=(0,o.getElementById)(`${e}-powered-by`);t&&t.style.setProperty("--widget-width",`${t.offsetWidth}px`),null==i||i.addEventListener("click",(()=>{window.open(r.poweredByReferralUrl,"_blank")}))})()};t.addSubscriberRecoveryBellWidgetToPage=({widget:e,site:t})=>{const i=(({widget:e,site:t})=>{const i="bl"===e.position?"left":"right",o=`visibility: hidden;\n --bell-background-color: ${e.bg};\n --bell-color: ${e.color};\n --bell-height: 50px;\n --bell-width: 50px;\n --bell-right:30px;\n --bell-left:30px;\n --bell-bottom:50px;\n`;return`\n \n \n
${r.bellIcon}
\n \n\n \n
${e.label}
\n\n ${(0,n.getPoweredByView)({enabled:!t.is_whitelabel,id:"pushengage-subscriber-recovery-widget-powered-by",className:"pushengage-subscriber-recovery-widget__tooltip__powered-by"})}\n \n \n `})({widget:e,site:t});(0,o.addContentAfterBody)(i),(e=>{const t="pushengage-subscriber-recovery-widget",i=`${t}-bell`,s=`${t}-tooltip`,d=(0,o.getElementById)(i),c=(0,o.getElementById)(s),l=(0,o.getElementById)(t),u=(0,o.getElementById)(`${t}-powered-by`);if(!d||!c||!l)return;const g=(0,a.detectDeviceType)(),p="pushengage-opt-in__tooltip--opened",b=!e.is_whitelabel;if("desktop"===g){let e=!1,t=!1;d.addEventListener("mouseover",(()=>{t=!0,(0,n.showTooltipView)({targetId:i,tooltipId:s})})),d.addEventListener("mouseleave",(()=>{t=!1,setTimeout((()=>{e||c.classList.remove(p)}),500)})),b&&(c.addEventListener("mouseleave",(()=>{setTimeout((()=>{e=!1,t||c.classList.remove(p)}),300)})),c.addEventListener("mouseover",(()=>{e=!0})))}else d.addEventListener("click",(()=>{(0,n.showTooltipView)({targetId:i,tooltipId:s}),b||setTimeout((()=>{c.classList.remove(p)}),1e3)}));null==u||u.addEventListener("click",(()=>{window.open(r.poweredByReferralUrl,"_blank")}))})(t)}},3341:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.refreshSubscriptionManagementWidgetView=void 0;const o=i(7628),r=i(1340),s=i(561),a=i(6582),d=i(6280),c=i(5967),l=n(i(9272)),u=i(1119),g=({widget:e,notificationPermission:t,subscriberData:i,site:n,widgetId:o})=>{var d,l,u,g,p,b,f,m,v,_,h,y,w;const S=(0,r.getColorTheme)(e.modal_background_color),I="trigger_button"in e?e.trigger_button:void 0,P=(null==I?void 0:I.z_index)||2147483640;let O=46,E=48;if(null==I?void 0:I.size)switch(I.size){case"small":O=36,E=38;break;case"large":O=56,E=58;break;default:O=46,E=48}const k=`\n --bell-background-color: ${null==I?void 0:I.icon_background_color};\n --bell-color: ${null==I?void 0:I.icon_color};\n --bell-bottom: ${Math.min((null==I?void 0:I.offset_bottom)||0,window.innerHeight-O)}px;\n --bell-top: ${Math.min((null==I?void 0:I.offset_top)||0,window.innerHeight-O)}px;\n --z-index: ${P};\n --bell-height: ${O}px;\n --bell-width: ${E}px;\n`,A=`\n --popover-background-color: ${e.modal_background_color};\n --popover-color: ${e.modal_text_color};\n --opt-in-close-icon-color: ${e.modal_text_color};\n --switch-checked-background-color: ${e.on_switch_color};\n --switch-unchecked-background-color:${e.off_switch_color};\n --z-index: ${P+1};\n`,D="#ffffff"===(null===(d=e.unsubscribe_options)||void 0===d?void 0:d.cancel_button_background_color)?"1px solid #d8d8d8":`1px solid ${null===(l=e.unsubscribe_options)||void 0===l?void 0:l.cancel_button_background_color}`,T=`\n --popover-background-color: ${e.modal_background_color};\n --popover-color: ${e.modal_text_color};\n --allow-btn-background-color: ${null===(u=e.unsubscribe_options)||void 0===u?void 0:u.ok_button_background_color};\n --close-btn-background-color: ${null===(g=e.unsubscribe_options)||void 0===g?void 0:g.cancel_button_background_color};\n --allow-btn-color: ${null===(p=e.unsubscribe_options)||void 0===p?void 0:p.ok_button_text_color};\n --close-btn-color: ${null===(b=e.unsubscribe_options)||void 0===b?void 0:b.cancel_button_text_color};\n --close-btn-border: ${D};\n --z-index: ${P+2};\n`,N=I?"":"pushengage-subscription-management-widget__opt-in--center pushengage-opt-in__popover--opened",R=(null==i?void 0:i.segments)||[],$=(null===(f=e.segment_preference)||void 0===f?void 0:f.exclude_subscribed_segments)||[],j=(null===(m=e.segment_preference)||void 0===m?void 0:m.segments)||[];let x="";if(null===(v=e.segment_preference)||void 0===v?void 0:v.enabled){const i="#ecebee"===e.segment_preference.checkbox_background_color&&"#ffffff"===e.modal_background_color?"#ACB7C8":e.segment_preference.checkbox_background_color,n=`\n --checkbox-checked-tick-color: ${e.segment_preference.checkbox_tick_color};\n --checkbox-unchecked--color: ${i};\n --checkbox-checked-background-color: ${e.modal_background_color};\n `;let r="";if(Array.isArray(R)&&R.length){const t=R.filter((t=>!($.includes(t)||!e.segment_preference.show_all_subscribed_segment&&!j.includes(t)))),i=1==t.length?"flex-basis: 100%;":"";t.forEach(((e,t)=>{r+=`\n =2?"7px":"0px")}"\n >\n \n