!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=18)}([function(e,t,n){"use strict";function r(){return Function("return this")()}function o(){return"3.2.8"}function i(){return!!r().safari&&navigator.userAgent.indexOf("Safari")>-1}function a(){return-1!==navigator.userAgent.indexOf("Opera")||-1!==navigator.userAgent.indexOf("OPR")}function s(){return navigator.serviceWorker&&"PushManager"in window&&"Notification"in window}function u(){return i()&&"PC"===h()||s()}function c(){return i()?k.BROWSER_TYPE_SAFARI:~navigator.userAgent.toLowerCase().indexOf("firefox")?k.BROWSER_TYPE_FF:k.BROWSER_TYPE_CHROME}function l(){var e=navigator.userAgent,t=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[],n=null;return/trident/i.test(t[1])?(n=/\brv[ :]+(\d+)/g.exec(e)||[],"IE "+(n[1]||"")):"Chrome"===t[1]&&null!==(n=e.match(/\bOPR\/(\d+)/))?"Opera "+n[1]:(t=t[2]?[t[1],t[2]]:[navigator.appName,navigator.appVersion,"-?"],n=e.match(/version\/([.\d]+)/i),null!==n&&t.splice(1,1,n[1]),t.join(" "))}function f(e){for(var t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new Uint8Array(r.length),i=0;r.length>i;++i)o[i]=r.charCodeAt(i);return o}function h(){var e=navigator.userAgent;return e.match(/Android/i)||e.match(/webOS/i)||e.match(/iPhone/i)||e.match(/iPad/i)||e.match(/iPod/i)||e.match(/BlackBerry/i)||e.match(/Windows Phone/i)?"Phone":"PC"}function p(e){for(var t="0123456789abcdef",n="",r=0;32>r;r++){var o=e.length-r-1,i=0;0>o||(i=e.charCodeAt(o)),n+=t.substr(i%t.length,1)}return n}function d(e,t){return t=_()||t||E(),e+"_"+p(t)}function _(){return localStorage.getItem(k.KEY_FAKE_PUSH_TOKEN)}function E(){var e=g();return localStorage.setItem(k.KEY_FAKE_PUSH_TOKEN,e),e}function g(e){e=e||32;for(var t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;e>r;r++)t+=n.charAt(Math.floor(Math.random()*n.length));return t}function v(e){return e?e.subscriptionId?e.subscriptionId:12===c()?e.endpoint:e.endpoint.split("/").pop()||"":""}function y(e,t){return e?new Promise(function(e){M.keyValue.get(k.KEY_FCM_SUBSCRIPTION).then(function(n){e(n&&n[t]||"")}).catch(function(){e("")})}):Promise.resolve("")}function b(e,t){var n=e&&e.getKey&&e.getKey(t);return n?btoa(String.fromCharCode.apply(String,new Uint8Array(n))):""}function m(e){return b(e,"auth")}function I(e){return b(e,"p256dh")}function O(e,t){var n="cp";i()||!e||~e.indexOf(".")||(n=e+".api");var r="https://"+(t||""||n+".pushwoosh.com")+"/json/1.3/";return new Promise(function(e){M.keyValue.get(k.KEY_API_BASE_URL).then(function(t){void 0===t&&(t=null),e(t||r)}).catch(function(){e(r)})})}function P(){for(var e,t=function(){},n=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],o=22,i=r(),a=i.console=i.console||{};o--;)e=n[o],a[e]||(a[e]=t)}function S(){var e=r();!T()&&u()&&(e.Promise=function(){return{then:function(){},catch:function(){}}})}function T(){return"Promise"in r()}function w(){"history"in r()&&history.pushState?history.pushState(null,"","#"):location.hash="#"}function A(e){return isNaN(e)?20:(e=Math.round(e),Math.min(60,0>e?20:e))}function N(e){var t=C(e,[]);return!t.userId||"user_id"!==t.userId&&!1!=!!t.userId||delete t.userId,t}function R(e){M.keyValue.get(k.KEY_INTERNAL_EVENTS).then(function(t){void 0===t&&(t={}),0===Object.keys(t).length&&M.keyValue.set(k.KEY_INTERNAL_EVENTS,{});var n=(new Date).setHours(0,0,0,0),r=t[e.event];if(!r||n>r){M.keyValue.extend(k.KEY_INTERNAL_EVENTS,(a={},a[e.event]=n,a));var o=new XMLHttpRequest,i=D({application:"DD275-06947"},e);o.open("POST","https://cp.pushwoosh.com/json/1.3/postEvent",!0),o.setRequestHeader("Content-Type","text/plain;charset=UTF-8"),o.send(JSON.stringify({request:i}))}var a})}var D=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},C=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(e);r.length>o;o++)0>t.indexOf(r[o])&&(n[r[o]]=e[r[o]]);return n};Object.defineProperty(t,"__esModule",{value:!0});var M=n(2),k=n(1);t.getGlobal=r,t.getVersion=o,t.isSafariBrowser=i,t.isOperaBrowser=a,t.canUseServiceWorkers=s,t.isSupportSDK=u,t.getBrowserType=c,t.getBrowserVersion=l,t.urlB64ToUint8Array=f,t.getDeviceName=h,t.createUUID=p,t.generateHwid=d,t.getFakePushToken=_,t.generateFakePushToken=E,t.getPushToken=v,t.getFcmKey=y,t.getAuthToken=m,t.getPublicKey=I,t.getPushwooshUrl=O,t.patchConsole=P,t.patchPromise=S,t.canUsePromise=T,t.clearLocationHash=w,t.prepareDuration=A,t.validateParams=N,t.sendInternalPostEvent=R},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_SERVICE_WORKER_URL="pushwoosh-service-worker.js",t.PERIOD_SEND_APP_OPEN=36e5,t.PERIOD_GOAL_EVENT=864e5,t.DEFAULT_NOTIFICATION_TITLE="Pushwoosh notification",t.DEFAULT_NOTIFICATION_IMAGE="https://cp.pushwoosh.com/img/logo-medium.png",t.DEFAULT_NOTIFICATION_URL="/",t.KEY_API_PARAMS="API_PARAMS",t.KEY_INIT_PARAMS="INIT_PARAMS",t.KEY_SDK_VERSION="SDK_VERSION",t.KEY_WORKER_VERSION="WORKER_VERSION",t.KEY_LAST_SENT_APP_OPEN="LAST_SENT_APP_OPEN",t.KEY_LAST_OPEN_MESSAGE="LAST_OPEN_MESSAGE",t.KEY_API_BASE_URL="API_BASE_URL",t.KEY_SHOW_SUBSCRIBE_WIDGET="WIDGET_SHOWED",t.KEY_CLICK_SUBSCRIBE_WIDGET="WIDGET_CLICKED",t.KEY_DELAYED_EVENT="DELAYED_EVENT",t.KEY_COMMUNICATION_ENABLED="COMMUNICATION_ENABLED",t.KEY_DEVICE_DATA_REMOVED="DEVICE_DATA_REMOVED",t.KEY_INTERNAL_EVENTS="INTERNAL_EVENTS",t.KEY_FAKE_PUSH_TOKEN="fakePushToken",t.KEY_DEVICE_REGISTRATION_STATUS="deviceRegistrationStatus",t.KEY_SAFARI_PREVIOUS_PERMISSION="safariPreviousPermission",t.MANUAL_SET_LOGGER_LEVEL="PW_SET_LOGGER_LEVEL",t.DEVICE_REGISTRATION_STATUS_REGISTERED="registered",t.DEVICE_REGISTRATION_STATUS_UNREGISTERED="unregistered",t.KEY_SENDER_ID="GCM_SENDER_ID",t.KEY_FCM_SUBSCRIPTION="FCM_SUBSCRIPTION",t.PERMISSION_DENIED="denied",t.PERMISSION_GRANTED="granted",t.PERMISSION_PROMPT="default",t.BROWSER_TYPE_SAFARI=10,t.BROWSER_TYPE_CHROME=11,t.BROWSER_TYPE_FF=12,t.EVENT_ON_READY="onReady",t.EVENT_ON_SUBSCRIBE="onSubscribe",t.EVENT_ON_UNSUBSCRIBE="onUnsubscribe",t.EVENT_ON_REGISTER="onRegister",t.EVENT_ON_PERMISSION_PROMPT="onPermissionPrompt",t.EVENT_ON_PERMISSION_DENIED="onPermissionDenied",t.EVENT_ON_PERMISSION_GRANTED="onPermissionGranted",t.EVENT_ON_SW_INIT_ERROR="onSWInitError",t.EVENT_ON_PUSH_DELIVERY="onPushDelivery",t.EVENT_ON_NOTIFICATION_CLICK="onNotificationClick",t.EVENT_ON_NOTIFICATION_CLOSE="onNotificationClose",t.EVENT_ON_CHANGE_COMMUNICATION_ENABLED="onChangeCommunicationEnabled",t.EVENT_SHOW_SUBSCRIBE_BUTTON="showSubscribeButton",t.EVENT_CLICK_SUBSCRIBE_BUTTON="clickSubscribeButton",t.EVENT_GDPR_CONSENT="GDPRConsent",t.EVENT_GDPR_DELETE="GDPRDelete"},function(e,t,n){"use strict";function r(e){console.info("onversionchange",e)}function o(){return f||(f=new Promise(function(e,t){var n=indexedDB.open("PUSHWOOSH_SDK_STORE",6);n.onsuccess=function(t){var n=t.target.result;n.onversionchange=r,e(n)},n.onerror=function(){return t(n.error)},n.onupgradeneeded=function(e){var t=e.target.result;t.onversionchange=r,t.objectStoreNames.contains(h)||t.createObjectStore(h,{keyPath:"key"});var n={keyPath:"id",autoIncrement:!0},o={unique:!1};if(!t.objectStoreNames.contains(p)){var i=t.createObjectStore(p,n);i.createIndex("environment","environment",o),i.createIndex("date","date",o),i.createIndex("type","type",o)}if(!t.objectStoreNames.contains(d)){t.createObjectStore(d,n).createIndex("date","date",o)}}})),f}function i(e){return o().then(function(t){return new Promise(function(n,r){return e(t,n,r)})})}var a=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),s=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&a[3]>n[1])){u.label=n[1];break}if(6===n[0]&&a[1]>u.label){u.label=a[1],a=n;break}if(a&&a[2]>u.label){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s},l=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(e);r.length>o;o++)0>t.indexOf(r[o])&&(n[r[o]]=e[r[o]]);return n};Object.defineProperty(t,"__esModule",{value:!0});var f,h="keyValue",p="logs",d="messages",_=function(){function e(){}return e.prototype._add=function(e){var t=this;return i(function(n,r,o){var i=n.transaction([t.name],"readwrite").objectStore(t.name).add(e);i.onsuccess=function(){r(e)},i.onerror=function(){o(i.error)}}).then(function(e){return t.getAll().then(function(n){if(Array.isArray(n)){var r=n.map(function(e){return e.id}).sort(function(e,t){return e==t?0:t>e?1:-1});if(r.length>t.maxItems)return Promise.all(r.slice(t.maxItems).map(function(e){return t.delete(e)})).then(function(){return e})}return e})})},e.prototype.delete=function(e){var t=this;return i(function(n,r,o){var i=n.transaction([t.name],"readwrite").objectStore(t.name).delete(e);i.onsuccess=function(){r(i.result)},i.onerror=function(){o(i.error)}})},e.prototype.getAll=function(){var e=this;return i(function(t,n,r){var o=[],i=t.transaction(e.name).objectStore(e.name).openCursor();i.onsuccess=function(e){var t=e.target.result;t?(o.push(t.value),t.continue()):n(o)},i.onerror=function(){r(i.error)}})},e}();t.LogBase=_;var E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name=p,t.maxItems=100,t.environment="undefined"!=typeof self&&self.registration?"worker":"browser",t}return a(t,e),t.prototype.add=function(e,t,n){var r={type:e,environment:this.environment,message:""+t,date:new Date};return t instanceof Error&&(r.stack=t.stack),n&&(r.additional=n),this._add(r)},t}(_);t.LogLog=E;var g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name=d,t.maxItems=25,t}return a(t,e),t.prototype.add=function(e){return this._add(s({},e,{date:new Date}))},t}(_);t.LogMessage=g,t.keyValue=function(e){return{get:function(t){return i(function(n,r,o){var i=n.transaction(e).objectStore(e).get(t);i.onsuccess=function(){var e=i.result;r(e&&e.value)},i.onerror=function(){o(i.error)}})},getAll:function(){return i(function(t,n,r){var o={},i=t.transaction(e).objectStore(e).openCursor();i.onsuccess=function(e){var t=e.target.result;t?(o[t.key]=t.value.value,t.continue()):n(o)},i.onerror=function(){r(i.error)}})},extend:function(e,t){return u(this,void 0,void 0,function(){var n,r;return c(this,function(o){switch(o.label){case 0:return[4,this.get(e)];case 1:return n=o.sent(),r=l(t,[]),[4,this.set(e,s({},n,r))];case 2:return o.sent(),[2]}})})},set:function(t,n){return i(function(r,o,i){var a=r.transaction([e],"readwrite").objectStore(e).put({key:t,value:n});a.onsuccess=function(){o(t)},a.onerror=function(){i(a.error)}})}}}(h),t.log=new E,t.message=new g},function(e,t,n){"use strict";function r(e){var t=Error(e);throw c.write("error",t,"logAndThrowError"),t}function o(e,t){var n=Error(e);c.write("error",n,"logAndRejectError"),t(n)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=n(0),s={error:1,info:2,debug:3},u=3;a.patchConsole();var c={setLevel:function(e){s[e]||(e="error"),u=s[e]},write:function(e,t,n){return"error"===e?this.error(t):this.info(t),i.log.add(e,t,n)}};Object.keys(s).forEach(function(e){var t=s[e];c[e]=function(){for(var n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];t>u||(console.groupCollapsed(e),console.info.apply(console,[""].concat(n)),console.trace("trace"),console.groupEnd())}}),t.logAndThrowError=r,t.logAndRejectError=o,t.default=c},function(e,t,n){"use strict";var r=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&a[3]>n[1])){u.label=n[1];break}if(6===n[0]&&a[1]>u.label){u.label=a[1],a=n;break}if(a&&a[2]>u.label){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s};Object.defineProperty(t,"__esModule",{value:!0});var a=n(1),s=n(0),u=n(2),c=n(3);t.default=function(){function e(e,t,n){this.doPushwooshApiMethod=e,this.apiParams=t,this.lastOpenMessage=n,this.timezone=60*-(new Date).getTimezoneOffset()}return Object.defineProperty(e.prototype,"params",{get:function(){return console.error('Property "Pushwoosh.api.params" will be deprecated in next minor version. Instead, use the async method "Pushwoosh.api.getParams()"'),s.sendInternalPostEvent({hwid:this.apiParams.hwid,userId:this.apiParams.userId,device_type:this.apiParams.deviceType,event:"API Params",attributes:{app_code:this.apiParams.applicationCode,device_type:this.apiParams.deviceType,url:this.apiParams.applicationCode+" - "+(location?location.href:"none")}}),this.apiParams},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSafari",{get:function(){return s.isSafariBrowser()},enumerable:!0,configurable:!0}),e.prototype.getParams=function(){return o(this,void 0,void 0,function(){var e,t,n,o,s;return i(this,function(i){switch(i.label){case 0:return[4,u.keyValue.getAll()];case 1:return e=i.sent(),t=a.KEY_API_PARAMS,n=e[t],o=a.KEY_INIT_PARAMS,s=e[o],[2,r({},n,s)]}})})},e.prototype.callAPI=function(e,t){return o(this,void 0,void 0,function(){var n,o,l,f,h,p,d,_,E,g;return i(this,function(i){switch(i.label){case 0:return[4,this.getParams()];case 1:return n=i.sent(),[4,u.keyValue.get(a.KEY_DEVICE_DATA_REMOVED)];case 2:return(o=i.sent())?(c.default.error("Device data has been removed"),[2]):(l=n.hwid,f=void 0===l?"":l,h=n.applicationCode,p=void 0===h?"":h,d=n.userId,_=void 0===d?"":d,this.isSafari&&!f?[2]:(E=t&&t.userId,g={hwid:f,application:p,userId:E||_||f,device_type:n.deviceType,v:s.getVersion()},[2,this.doPushwooshApiMethod(e,r({},t,g))]))}})})},e.prototype.registerDevice=function(){return o(this,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return[4,this.getParams()];case 1:if(e=r.sent(),!e.pushToken||this.isSafari)return[2];r.label=2;case 2:return r.trys.push([2,5,,6]),[4,u.keyValue.get(a.KEY_COMMUNICATION_ENABLED)];case 3:return t=0!==r.sent(),t?[4,this.callAPI("registerDevice",{push_token:e.pushToken,public_key:e.publicKey,auth_token:e.authToken,fcm_token:e.fcmToken,fcm_push_set:e.fcmPushSet,language:e.tags.Language,timezone:this.timezone,device_model:e.tags["Device Model"]})]:(c.default.error("Communication is disabled"),[2]);case 4:return r.sent(),localStorage.setItem(a.KEY_DEVICE_REGISTRATION_STATUS,a.DEVICE_REGISTRATION_STATUS_REGISTERED),[3,6];case 5:return n=r.sent(),c.logAndThrowError(n),[3,6];case 6:return[2]}})})},e.prototype.unregisterDevice=function(){return o(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:if(this.isSafari)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.callAPI("unregisterDevice")];case 2:return t.sent(),localStorage.setItem(a.KEY_DEVICE_REGISTRATION_STATUS,a.DEVICE_REGISTRATION_STATUS_UNREGISTERED),[3,4];case 3:return e=t.sent(),c.logAndThrowError(e),[3,4];case 4:return[2]}})})},e.prototype.registerUser=function(e){return o(this,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,this.getParams()];case 1:return t=r.sent(),t.userId&&e?(n={timezone:this.timezone,userId:e||t.userId},[4,u.keyValue.extend(a.KEY_INIT_PARAMS,s.validateParams(n))]):[2];case 2:return r.sent(),this.callAPI("registerUser",n),[2]}})})},e.prototype.applicationOpen=function(){return o(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getParams()];case 1:return e=t.sent(),this.callAPI("applicationOpen",{push_token:e.pushToken,timezone:this.timezone}),[2]}})})},e.prototype.setTags=function(e){return this.callAPI("setTags",{tags:e})},e.prototype.getTags=function(){return this.callAPI("getTags")},e.prototype.pushStat=function(e){return this.callAPI("pushStat",{hash:e})},e.prototype.messageDeliveryEvent=function(e){return this.callAPI("messageDeliveryEvent",{hash:e})},e.prototype.postEvent=function(e,t){var n=this.lastOpenMessage,o=new Date,i=o.getTime(),a=Math.floor(i/1e3),s=a-o.getTimezoneOffset()/60*3600;if(n.expiry>Date.now()){if(t.msgHash)return Promise.reject("attribute msgHash already defined");t=r({},t,{msgHash:n.messageHash})}return this.callAPI("postEvent",{event:e,attributes:t,timestampUTC:a,timestampCurrent:s})},e.prototype.triggerEvent=function(e,t){return o(this,void 0,void 0,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return t?[4,u.keyValue.get(t)]:[3,2];case 1:return r=o.sent(),[3,3];case 2:r=null,o.label=3;case 3:return n=r,t&&n?[2]:[4,this.callAPI("triggerEvent",e)];case 4:return o.sent(),t&&u.keyValue.set(t,1),[2]}})})},e}()},,,,,,,,,,,,,,function(e,t,n){"use strict";function r(e){return h(this,void 0,void 0,function(){var t;return p(this,function(n){switch(n.label){case 0:return[4,self.clients.matchAll()];case 1:return t=n.sent(),t.forEach(function(t){t.postMessage(e)}),[2]}})})}function o(e,t){return h(this,void 0,void 0,function(){var n;return p(this,function(r){switch(r.label){case 0:if("string"!=typeof e)return[3,4];r.label=1;case 1:return r.trys.push([1,2,,4]),[2,JSON.parse(e)];case 2:return n=r.sent(),[4,g.default.write("error",n,"Error occurred during json parsing")];case 3:return r.sent(),[3,4];case 4:return[2,void 0===e&&void 0!==t?t:e]}})})}function i(e,t){return h(this,void 0,void 0,function(){var n,r,i,a;return p(this,function(s){switch(s.label){case 0:return[4,e.data.json()];case 1:return n=s.sent(),r=n.data||n,[4,o(r.buttons,[])];case 2:return i=s.sent(),[4,o(r.u,{})];case 3:return a=s.sent(),[2,{title:r.header||t.defaultNotificationTitle||_.DEFAULT_NOTIFICATION_TITLE,body:r.body,buttons:i,customData:a,icon:r.i||t.defaultNotificationImage||_.DEFAULT_NOTIFICATION_IMAGE,image:r.image||"",messageHash:r.p||"",campaignCode:r.pwcid||"",duration:E.prepareDuration(r.duration),openUrl:r.l||_.DEFAULT_NOTIFICATION_URL}]}})})}function a(e){return h(this,void 0,void 0,function(){var t,n,o,a,s,u;return p(this,function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),[4,d.keyValue.get(_.KEY_INIT_PARAMS)];case 1:return t=c.sent(),[4,i(e,t)];case 2:return n=c.sent(),g.default.setLevel(t.logLevel),[4,g.default.write("info",JSON.stringify(n),"onPush")];case 3:return c.sent(),o=n.messageHash,a=new y.default(n),s=b.getListeners("onPush"),[4,s.reduce(function(e,t){return e.then(function(){return t(a)})},Promise.resolve())];case 4:return c.sent(),[2,Promise.all([a.show(),o&&b.initApi().then(function(){return b.api.messageDeliveryEvent(o)}),d.message.add(f({},a._forLog(),{payload:n})),r({type:_.EVENT_ON_PUSH_DELIVERY,payload:n})])];case 5:return u=c.sent(),[2,d.message.add({error:""+u,stack:u.stack,payload:e.data.text()})];case 6:return[2]}})})}function s(e){return h(this,void 0,void 0,function(){var t,n,r,i,a,s;return p(this,function(u){switch(u.label){case 0:return t=e.notification,n=void 0===t?{}:t,r=n.data,[4,o(n.tag,{})];case 1:return i=u.sent(),a="",e.action&&Array.isArray(r.buttons)?(s=r.buttons.find(function(t){return t.action===e.action})||{},a=s.url):a=i.url,[2,{requireInteraction:n.requireInteraction,title:n.title,body:n.body,icon:n.icon,buttons:r.buttons,duration:r.duration,image:r.image,code:r.code,campaignCode:r.campaignCode,messageHash:i.messageHash,customData:i.customData,openUrl:i.url,tag:n.tag,url:a}]}})})}function u(e){return h(this,void 0,void 0,function(){var t,n,o,i,a;return p(this,function(u){switch(u.label){case 0:return[4,s(e)];case 1:return t=u.sent(),n=t.messageHash,o=t.url,i=t.code,i&&m.push(i),e.notification.close(),a={type:_.EVENT_ON_NOTIFICATION_CLICK,payload:t},o?[4,e.waitUntil(self.clients.matchAll({type:"window"}).then(function(e){return c(e,o,a)}))]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2,Promise.all([b.initApi().then(function(){return b.api.pushStat(n)}),d.keyValue.set(_.KEY_LAST_OPEN_MESSAGE,{url:o,messageHash:n,expiry:Date.now()+_.PERIOD_GOAL_EVENT}),r(a)])]}})})}function c(e,t,n){return h(this,void 0,void 0,function(){var r,o;return p(this,function(i){switch(i.label){case 0:for(r=e.length-1;r>-1;--r)if(o=e[r],(t===o.url||"/"===t)&&"focus"in o)return o.focus(),[2];return self.clients.openWindow?[4,d.keyValue.set(_.KEY_DELAYED_EVENT,n)]:[3,2];case 1:return i.sent(),[2,self.clients.openWindow(t)];case 2:return[2]}})})}function l(e){return h(this,void 0,void 0,function(){var t,n,o;return p(this,function(i){switch(i.label){case 0:return[4,s(e)];case 1:return t=i.sent(),(n=t.code,e.notification.close(),n)?0>(o=m.indexOf(n))?[2,r({type:_.EVENT_ON_NOTIFICATION_CLOSE,payload:t})]:(m.splice(o,1),[2]):[2]}})})}var f=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},h=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},p=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&a[3]>n[1])){u.label=n[1];break}if(6===n[0]&&a[1]>u.label){u.label=a[1],a=n;break}if(a&&a[2]>u.label){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s};Object.defineProperty(t,"__esModule",{value:!0});var d=n(2),_=n(1),E=n(0),g=n(3),v=n(19),y=n(21),b=self.Pushwoosh=new v.default,m=[];self.addEventListener("install",function(e){e.waitUntil(Promise.all([d.keyValue.set(_.KEY_WORKER_VERSION,E.getVersion()),g.default.write("info","install")]).then(function(){return self.skipWaiting()}))}),self.addEventListener("activate",function(e){e.waitUntil(Promise.all([g.default.write("info","activate")]).then(function(){return self.clients.claim()}))}),self.addEventListener("push",function(e){e.waitUntil(Promise.resolve(self.clients.claim()).then(function(){return a(e).catch(function(e){return console.log(e)})}))}),self.addEventListener("notificationclick",function(e){e.waitUntil(Promise.resolve(self.clients.claim()).then(function(){return u(e).catch(function(e){return console.log(e)})}))}),self.addEventListener("notificationclose",function(e){e.waitUntil(l(e).catch(function(e){return console.log(e)}))})},function(e,t,n){"use strict";var r=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&a[3]>n[1])){u.label=n[1];break}if(6===n[0]&&a[1]>u.label){u.label=a[1],a=n;break}if(a&&a[2]>u.label){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s};Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),s=n(1),u=n(4),c=n(20);t.default=function(){function e(){this._listeners={}}return e.prototype.push=function(e){Array.isArray(e)&&"onPush"===e[0]&&"function"==typeof e[1]&&(this._listeners[e[0]]||(this._listeners[e[0]]=[]),this._listeners[e[0]].push(e[1]))},e.prototype.getListeners=function(e){return this._listeners[e]||[]},e.prototype.initApi=function(){return o(this,void 0,void 0,function(){var e,t,n,o,l,f;return i(this,function(i){switch(i.label){case 0:return[4,a.keyValue.getAll()];case 1:return e=i.sent(),t=e[s.KEY_INIT_PARAMS],n=e[s.KEY_LAST_OPEN_MESSAGE]||{},o=e[s.KEY_API_PARAMS],l=r({},o,{deviceType:t.deviceType,deviceModel:t.tags["Device Model"],applicationCode:t.applicationCode,language:t.tags.Language,pushwooshApiUrl:t.pushwooshApiUrl}),t.userId&&(l.userId=t.userId),f=c.default(t.applicationCode,t.pushwooshApiUrl),this.api=new u.default(f,l,n),[2]}})})},e}()},function(e,t,n){"use strict";function r(e,t){return function(n,r){return new Promise(function(a,s){i.getPushwooshUrl(e,t).then(function(e){try{var t=""+e+n,i={request:r};fetch(t,{method:"post",headers:{"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify(i)}).then(function(e){e.ok?e.json().then(function(e){200!=e.status_code?o.logAndRejectError("Error occurred during the "+n+" call to Pushwoosh: "+e.status_message,s):(o.default.write("apirequest",n+" call with arguments: "+JSON.stringify(r)+" to Pushwoosh has been successful. Result: "+JSON.stringify(e.response),"createDoApiFetch"),a(e.response))}):o.logAndRejectError(e.statusText||"response not ok",s)})}catch(e){o.logAndRejectError("Exception while "+n+" the device: "+e,s)}})})}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(3),i=n(0);t.default=r},function(e,t,n){"use strict";var r=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&a[3]>n[1])){u.label=n[1];break}if(6===n[0]&&a[1]>u.label){u.label=a[1],a=n;break}if(a&&a[2]>u.label){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){function e(e){this._canceled=!1,this._origMess=e,this._changedMess=r({},e)}return Object.defineProperty(e.prototype,"title",{get:function(){return this._changedMess.title},set:function(e){this._changedMess.title=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._changedMess.body||""},set:function(e){this._changedMess.body=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"icon",{get:function(){return this._changedMess.icon},set:function(e){this._changedMess.icon=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"openUrl",{get:function(){return this._changedMess.openUrl},set:function(e){this._changedMess.openUrl=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._changedMess.duration},set:function(e){this._changedMess.duration=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"messageHash",{get:function(){return this._changedMess.messageHash},set:function(e){this._changedMess.messageHash=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"customData",{get:function(){return this._changedMess.customData},set:function(e){this._changedMess.customData=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"campaignCode",{get:function(){return this._changedMess.campaignCode},set:function(e){this._changedMess.campaignCode=e},enumerable:!0,configurable:!0}),e.prototype.show=function(){return o(this,void 0,void 0,function(){var e,t,n,r,o,a=this;return i(this,function(i){switch(i.label){case 0:return this._canceled?[3,3]:(e="notificationCode-"+Date.now(),t=this._changedMess.image,n=this._changedMess.buttons,n&&Array.isArray(n)&&n.forEach(function(e,t){e.action="action-"+t}),r={body:this.body,icon:this.icon,requireInteraction:0===this.duration||this.duration>20,tag:JSON.stringify({url:this.openUrl,messageHash:this.messageHash,customData:this.customData}),data:{code:e,buttons:n,duration:this.duration,image:t,campaignCode:this.campaignCode},actions:n,image:t},[4,self.registration.showNotification(this.title,r)]);case 1:return i.sent(),[4,self.registration.getNotifications()];case 2:o=i.sent(),o.forEach(function(t){t.data&&t.data.code===e&&a.duration&&setTimeout(function(){return t.close()},1e3*a.duration)}),i.label=3;case 3:return[2]}})})},e.prototype.cancel=function(){this._canceled=!0},e.prototype._forLog=function(){return{orig:this._origMess,changed:this._changedMess,canceled:this._canceled}},e}()}]);