@suprsend/web-sdk 1.5.0-beta.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see cdn_bundle.js.LICENSE.txt */
2
- !function(){var t={560:function(t,e,r){var n;!function(o){"use strict";function i(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function a(t,e,r,n,o,a){return i((c=i(i(e,t),i(n,a)))<<(u=o)|c>>>32-u,r);var c,u}function c(t,e,r,n,o,i,c){return a(e&r|~e&n,t,e,o,i,c)}function u(t,e,r,n,o,i,c){return a(e&n|r&~n,t,e,o,i,c)}function s(t,e,r,n,o,i,c){return a(e^r^n,t,e,o,i,c)}function l(t,e,r,n,o,i,c){return a(r^(e|~n),t,e,o,i,c)}function f(t,e){var r,n,o,a,f;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var h=1732584193,p=-271733879,d=-1732584194,v=271733878;for(r=0;r<t.length;r+=16)n=h,o=p,a=d,f=v,h=c(h,p,d,v,t[r],7,-680876936),v=c(v,h,p,d,t[r+1],12,-389564586),d=c(d,v,h,p,t[r+2],17,606105819),p=c(p,d,v,h,t[r+3],22,-1044525330),h=c(h,p,d,v,t[r+4],7,-176418897),v=c(v,h,p,d,t[r+5],12,1200080426),d=c(d,v,h,p,t[r+6],17,-1473231341),p=c(p,d,v,h,t[r+7],22,-45705983),h=c(h,p,d,v,t[r+8],7,1770035416),v=c(v,h,p,d,t[r+9],12,-1958414417),d=c(d,v,h,p,t[r+10],17,-42063),p=c(p,d,v,h,t[r+11],22,-1990404162),h=c(h,p,d,v,t[r+12],7,1804603682),v=c(v,h,p,d,t[r+13],12,-40341101),d=c(d,v,h,p,t[r+14],17,-1502002290),h=u(h,p=c(p,d,v,h,t[r+15],22,1236535329),d,v,t[r+1],5,-165796510),v=u(v,h,p,d,t[r+6],9,-1069501632),d=u(d,v,h,p,t[r+11],14,643717713),p=u(p,d,v,h,t[r],20,-373897302),h=u(h,p,d,v,t[r+5],5,-701558691),v=u(v,h,p,d,t[r+10],9,38016083),d=u(d,v,h,p,t[r+15],14,-660478335),p=u(p,d,v,h,t[r+4],20,-405537848),h=u(h,p,d,v,t[r+9],5,568446438),v=u(v,h,p,d,t[r+14],9,-1019803690),d=u(d,v,h,p,t[r+3],14,-187363961),p=u(p,d,v,h,t[r+8],20,1163531501),h=u(h,p,d,v,t[r+13],5,-1444681467),v=u(v,h,p,d,t[r+2],9,-51403784),d=u(d,v,h,p,t[r+7],14,1735328473),h=s(h,p=u(p,d,v,h,t[r+12],20,-1926607734),d,v,t[r+5],4,-378558),v=s(v,h,p,d,t[r+8],11,-2022574463),d=s(d,v,h,p,t[r+11],16,1839030562),p=s(p,d,v,h,t[r+14],23,-35309556),h=s(h,p,d,v,t[r+1],4,-1530992060),v=s(v,h,p,d,t[r+4],11,1272893353),d=s(d,v,h,p,t[r+7],16,-155497632),p=s(p,d,v,h,t[r+10],23,-1094730640),h=s(h,p,d,v,t[r+13],4,681279174),v=s(v,h,p,d,t[r],11,-358537222),d=s(d,v,h,p,t[r+3],16,-722521979),p=s(p,d,v,h,t[r+6],23,76029189),h=s(h,p,d,v,t[r+9],4,-640364487),v=s(v,h,p,d,t[r+12],11,-421815835),d=s(d,v,h,p,t[r+15],16,530742520),h=l(h,p=s(p,d,v,h,t[r+2],23,-995338651),d,v,t[r],6,-198630844),v=l(v,h,p,d,t[r+7],10,1126891415),d=l(d,v,h,p,t[r+14],15,-1416354905),p=l(p,d,v,h,t[r+5],21,-57434055),h=l(h,p,d,v,t[r+12],6,1700485571),v=l(v,h,p,d,t[r+3],10,-1894986606),d=l(d,v,h,p,t[r+10],15,-1051523),p=l(p,d,v,h,t[r+1],21,-2054922799),h=l(h,p,d,v,t[r+8],6,1873313359),v=l(v,h,p,d,t[r+15],10,-30611744),d=l(d,v,h,p,t[r+6],15,-1560198380),p=l(p,d,v,h,t[r+13],21,1309151649),h=l(h,p,d,v,t[r+4],6,-145523070),v=l(v,h,p,d,t[r+11],10,-1120210379),d=l(d,v,h,p,t[r+2],15,718787259),p=l(p,d,v,h,t[r+9],21,-343485551),h=i(h,n),p=i(p,o),d=i(d,a),v=i(v,f);return[h,p,d,v]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function p(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function d(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function v(t){return unescape(encodeURIComponent(t))}function y(t){return function(t){return h(f(p(t),8*t.length))}(v(t))}function _(t,e){return function(t,e){var r,n,o=p(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=f(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=f(i.concat(p(e)),512+8*e.length),h(f(a.concat(n),640))}(v(t),v(e))}function g(t,e,r){return e?r?_(e,t):d(_(e,t)):r?y(t):d(y(t))}void 0===(n=function(){return g}.call(e,r,e,t))||(t.exports=n)}()},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.0-beta.1","description":"This is sdk used to integrate suprsend functionality in javascript applications","main":"dist/cjs_bundle.js","scripts":{"test":"echo \\"Error: no test specified\\" && exit 1","build":"rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js","publish_sdk":"npm run build && npm publish"},"keywords":["suprsend","suprsend-browser","suprsend-browser-sdk"],"author":"Sivaram Katta","license":"MIT","repository":{"type":"git","url":"https://github.com/suprsend/suprsend-browser.git"},"types":"src/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"^7.18.5","@babel/preset-env":"^7.18.2","babel-loader":"^8.2.5","webpack":"^5.76.0","webpack-cli":"^4.8.0"},"dependencies":{"blueimp-md5":"^2.19.0","mitt":"^3.0.0"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};!function(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return rt},PreferenceOptions:function(){return et},default:function(){return Wt},initialisedAt:function(){return $t}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(560),d=r.n(p);function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(){y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(d=g);var m=p.prototype=f.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==v(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function _(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){_(i,n,o,a,c,"next",t)}function c(t){_(i,n,o,a,c,"throw",t)}a(void 0)}))}}function m(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var w=function(t){return new Uint8Array(m(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function x(t,e,r){return k.apply(this,arguments)}function k(){return k=g(y().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,_=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=d()(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=w(a),f=w(s),t.next=12,crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!0,["sign"]);case 12:return p=t.sent,t.next=15,crypto.subtle.sign("HMAC",p,f);case 15:return v=t.sent,m(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,m(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),k.apply(this,arguments)}function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function S(){S=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==O(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function j(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){P(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function T(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){T(i,n,o,a,c,"next",t)}function c(t){T(i,n,o,a,c,"throw",t)}a(void 0)}))}}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=$(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function $(t,e){if(t){if("string"==typeof t)return C(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?C(t,e):void 0}}function C(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function I(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(I())return localStorage.getItem(t)}function M(t,e){I()&&localStorage.setItem(t,e)}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function D(){var t=navigator.userAgent;for(var e in u){var r,n=N(u[e]);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t.indexOf(o)>=0)return e}}catch(t){n.e(t)}finally{n.f()}}return""}function U(t,e){return R.apply(this,arguments)}function R(){return R=A(S().mark((function t(e,r){var n,o,i,a,c,u=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:"POST",o=(new Date).toGMTString(),i=JSON.stringify(r),t.next=5,x(i,o,"POST");case 5:return a=t.sent,c=a?"".concat(h.env_key,":").concat(a):h.env_key,t.abrupt("return",fetch("".concat(h.api_url,"/").concat(e),{method:n,body:i,headers:{"Content-Type":"application/json",Authorization:c,"x-amz-date":o}}));case 8:case"end":return t.stop()}}),t)}))),R.apply(this,arguments)}function q(){var t=F(e,[]);if(t.length){var r=t.slice(0,h.batch_size);U(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=F(e,[]);r.splice(0,h.batch_size),M(e,JSON.stringify(r)),q()})).catch((function(){z(12e4)}))}else z()}function z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){q()}),t)}var W=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function Y(t,e){var r,n=this;return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r&&clearTimeout(r),r=setTimeout((function(){t.apply(n,i)}),e)}}const J={uuid:function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)}))},epoch_milliseconds:function(){return Math.round(Date.now())},cookie_enabled:function(){return navigator.cookieEnabled},set_cookie:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365,n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/"},get_cookie:function(t){for(var e=t+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},remove_cookie:function(t){document.cookie=t+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},local_storage_enabled:I,get_local_storage_item:G,set_local_storage_item:M,remove_local_storage_item:function(t){I()&&localStorage.removeItem(t)},get_parsed_local_store_data:F,browser:D,browser_version:function(){var t=navigator.userAgent,e=D(),r=s[e];if(!r||!e)return"";var n,o=N(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(i){var a=t.match(i);if(a&&a.length>1)return a[1]}}}catch(t){o.e(t)}finally{o.f()}return""},os:function(){var t=navigator.userAgent;for(var e in l)if(t.indexOf(l[e])>=0)return e;return""},schedule_flush:z,format_props:function(t){var e,r=t.key,n=t.value,o=t.allow_special_tags,i=void 0!==o&&o;if(r instanceof Object){for(var a in e={},r)if(void 0!==r[a]){if(!i&&W(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&W(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=P({},String(r),n)}return e},urlB64ToUint8Array:function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=window.atob(e),n=new Uint8Array(r.length),o=0;o<r.length;++o)n[o]=r.charCodeAt(o);return n},batch_or_call:function(t){if(I()){var r=F(e,[]);null==r||r.push(t),M(e,JSON.stringify(r))}else U(o,t)},has_special_char:W,is_empty:function(t){return Array.isArray(t)?0===t.length:t instanceof Object?0===Object.keys(t).length:["",null,void 0].includes(t)},bulk_call_api:q,is_internal_event:function(t){return Object.values(c).includes(t)},api:U,debounce_by_type:function(t,e,r){var n={};return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=i[0],u=i.slice(1);return"function"==typeof n[c]||(n[c]=Y(t,e,j(j({},r),{},{leading:!0}))),n[c].apply(n,L(u))}}};function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function K(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return V(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?V(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function V(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function H(){H=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==B(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Q(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function X(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var et={OPT_IN:"opt_in",OPT_OUT:"opt_out"},rt={ALL:"all",REQUIRED:"required"},nt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),tt(this,"_update_category_preferences",X(H().mark((function t(){var e,r,o,i,a,c,u=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"",r=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2?u[2]:void 0,i=u.length>3&&void 0!==u[3]?u[3]:{},a="category/".concat(e),t.next=7,n._update_request(r,a,i);case 7:return null!=(c=t.sent)&&c.error?n._emitter.emit("preferences_error",c):(Object.assign(o,c),n._emitter.emit("preferences_updated",n.data)),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)})))),tt(this,"_update_channel_preferences",X(H().mark((function t(){var e,r,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="channel_preference",t.next=4,n._update_request(e,r);case 4:if(null==(o=t.sent)||!o.error){t.next=9;break}n._emitter.emit("preferences_error",o),t.next=12;break;case 9:return t.next=11,n.get_preferences(n._preference_args);case 11:n._emitter.emit("preferences_updated",n.data);case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))),this.ss_instance=e,this._preference_data,this._preference_args,this._emitter=r,this._debounced_update_category_preferences=J.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=J.debounce_by_type(this._update_channel_preferences,h.preference_debounce)}var e,r,n,o,i,a,c,u;return e=t,r=[{key:"_validate_query_params",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};for(var r in t)t[r]&&(e[r]=t[r]);return e}},{key:"_get_request",value:(u=X(H().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n="/v1/subscriber/".concat(this.ss_instance.distinct_id),o=this._validate_query_params(r),i=new URLSearchParams(o).toString(),a=i?"".concat(n,"/").concat(e,"/?").concat(i):"".concat(n,"/").concat(e),c=(new Date).toGMTString(),t.next=9,x("",c,"GET",a);case 9:return u=t.sent,s=u?"".concat(h.env_key,":").concat(u):h.env_key,t.prev=11,t.next=14,fetch("".concat(h.api_url).concat(a),{headers:{"Content-Type":"application/json",Authorization:s,"x-amz-date":c}});case 14:if(!(l=t.sent).ok){t.next=18;break}return f=l.json(),t.abrupt("return",f);case 18:return t.abrupt("return",{error:!0,api_error:!0,status_code:l.status,message:l.statusText,error_obj:null});case 21:return t.prev=21,t.t0=t.catch(11),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 24:case"end":return t.stop()}}),t,this,[[11,21]])}))),function(){return u.apply(this,arguments)})},{key:"_update_request",value:(c=X(H().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="/v1/subscriber/".concat(this.ss_instance.distinct_id),i=this._validate_query_params(n),a=new URLSearchParams(i).toString(),c=a?"".concat(o,"/").concat(r,"/?").concat(a):"".concat(o,"/").concat(r),u=(new Date).toGMTString(),s=JSON.stringify(e),t.next=8,x(s,u,"POST",c);case 8:return l=t.sent,f=l?"".concat(h.env_key,":").concat(l):h.env_key,t.prev=10,t.next=13,fetch("".concat(h.api_url).concat(c),{method:"POST",body:s,headers:{"Content-Type":"application/json",Authorization:f,"x-amz-date":u}});case 13:if(!(p=t.sent).ok){t.next=17;break}return d=p.json(),t.abrupt("return",d);case 17:return t.abrupt("return",{error:!0,api_error:!0,status_code:p.status,message:p.statusText,error_obj:null});case 20:return t.prev=20,t.t0=t.catch(10),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 23:case"end":return t.stop()}}),t,this,[[10,20]])}))),function(t,e,r){return c.apply(this,arguments)})},{key:"data",get:function(){return this._preference_data},set:function(t){this._preference_data=t}},{key:"get_preferences",value:(a=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="full_preference",this._preference_args=e,n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels},t.next=6,this._get_request(r,n);case 6:return null!=(o=t.sent)&&o.error||(this.data=o),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"get_categories",value:(i=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="category",n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels,limit:null==e?void 0:e.limit,offset:null==e?void 0:e.offset},t.next=5,this._get_request(r,n);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"get_category",value:(o=X(H().mark((function t(){var e,r,n,o,i,a=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:"",r=a.length>1&&void 0!==a[1]?a[1]:{},e){t.next=4;break}return t.abrupt("return",{error:!0,message:"Category parameter is missing"});case 4:return n="category/".concat(e),o={tenant_id:null==r?void 0:r.tenant_id,show_opt_out_channels:null==r?void 0:r.show_opt_out_channels},t.next=8,this._get_request(n,o);case 8:return i=t.sent,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get_overall_channel_preferences",value:(n=X(H().mark((function t(){var e;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this._get_request("channel_preference");case 3:return e=t.sent,t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"update_category_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||![et.OPT_IN,et.OPT_OUT].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Category parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var o,i=!1,a=null==n?void 0:n.show_opt_out_channels,c=K(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=K(s.subcategories);try{for(f.s();!(u=f.n()).done;){var h=u.value;if(h.category===e){if(t=h,!h.is_editable)return{error:!0,message:"Category preference is not editable"};if(h.preference!==r){h.preference=r,i=!0,l=!0;break}}}}catch(t){f.e(t)}finally{f.f()}if(l)break}}catch(t){c.e(t)}finally{c.f()}if(!t)return{error:!0,message:"Category is not found"};if(!i)return this.data;var p=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===et.OPT_IN?null:p};return this._debounced_update_category_preferences(e,e,d,t,{tenant_id:null==n?void 0:n.tenant_id,show_opt_out_channels:null==n?void 0:n.show_opt_out_channels}),this.data}},{key:"update_channel_preference_in_category",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!r||!o)return{error:!0,message:r?"Category parameter is missing":"Channel parameter is missing"};if(![et.OPT_IN,et.OPT_OUT].includes(n))return{error:!0,message:"Preference parameter is invalid"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var a,c=!1,u=K(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=K(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=K(p.channels);try{for(v.s();!(d=v.n()).done;){var y=d.value;if(y.channel===r){if(e=y,!y.is_editable)return{error:!0,message:"Channel preference is not editable"};if(y.preference!==n){y.preference=n,n===et.OPT_IN&&(p.preference=et.OPT_IN),c=!0,f=!0;break}}}}catch(t){v.e(t)}finally{v.f()}}if(f)break}}catch(t){h.e(t)}finally{h.f()}if(f)break}}catch(t){u.e(t)}finally{u.f()}if(!t)return{error:!0,message:"Category not found"};if(!e)return{error:!0,message:"Category's Channel not found"};if(!c)return this.data;var _=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===et.OPT_OUT&&n===et.OPT_IN?et.OPT_IN:t.preference,m={preference:g,opt_out_channels:_};return this._debounced_update_category_preferences(o,o,m,t,{tenant_id:null==i?void 0:i.tenant_id,show_opt_out_channels:null==i?void 0:i.show_opt_out_channels}),this.data}},{key:"update_overall_channel_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||![rt.ALL,rt.REQUIRED].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Channel parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var n,o=!1,i=r===rt.REQUIRED,a=K(this.data.channel_preferences);try{for(a.s();!(n=a.n()).done;){var c=n.value;if(c.channel===e&&(t=c,c.is_restricted!==i)){c.is_restricted=i,o=!0;break}}}catch(t){a.e(t)}finally{a.f()}return t?o?(this._debounced_update_channel_preferences(t.channel,{channel_preferences:[t]}),this.data):this.data:{error:!0,message:"Channel data not found"}}}],r&&Z(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const ot=nt;function it(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function at(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach((function(e){ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var st=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ut(this,"_allow_special_char_events",(function(t){return"$email"===t||"$whatsapp"===t||"$sms"===t||(null==t?void 0:t.$webpush)})),this.instance=e,this.preferences=new ot(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){J.batch_or_call(at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;J.api(o,at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t)).then((function(t){if(!t.ok)throw new Error("Error in Fetch")})).catch((function(){e._call_indentity(t)}))}},{key:"_convert_to_number",value:function(t){if(!J.is_empty(t))for(var e in t){var r=Number(t[e]);r?t[e]=r:delete t[e]}return t}},{key:"_validate_email_and_send",value:function(t,e){f.email.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Email ID")}},{key:"_validate_mobile_and_send",value:function(t,e){try{f.mobile.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}catch(t){console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}}},{key:"set",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set_once:r})}},{key:"increment",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=J.format_props({key:t,value:e}),n=this._convert_to_number(r);J.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=J.format_props({key:t,value:e,allow_special_tags:r});J.is_empty(n)||this._call_indentity({$append:n})}},{key:"remove",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._allow_special_char_events(t),o=J.format_props({key:t,value:e,allow_special_tags:n});J.is_empty(o)||(null!=r&&r.flush_immediately?this._call_flush_immediately({$remove:o}):this._call_indentity({$remove:o}))}},{key:"unset",value:function(t){var e;"string"==typeof t?J.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){J.has_special_char(String(t))||e.push(String(t))}))),J.is_empty(e)||this._call_indentity({$unset:e})}},{key:"add_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_email_and_send("$email",t)}},{key:"remove_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$email",t)}},{key:"add_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$sms",t)}},{key:"remove_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$sms",t)}},{key:"add_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$whatsapp",t)}},{key:"remove_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$whatsapp",t)}},{key:"add_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.append({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"})}},{key:"remove_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"},null,{flush_immediately:!0})}}],r&&ct(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=st;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(){ht=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==ft(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function pt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function yt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t,gt=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),yt(this,"_ask_notification_permission",dt(ht().mark((function t(){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Notification.requestPermission();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),yt(this,"_register_sw",(function(){return navigator.serviceWorker.register("/".concat(h.service_worker_file)).then((function(t){r._subscribe_push(t)})).catch((function(t){console.error("SuprSend: Unable to register service worker.",t)}))})),yt(this,"_get_subscription_without_wait",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.serviceWorker.getRegistration();case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.abrupt("return",e.pushManager.getSubscription().then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:case"end":return t.stop()}}),t)})))),yt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),yt(this,"_subscribe_push",function(){var t=dt(ht().mark((function t(e){var n,o;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._ask_notification_permission();case 2:if("granted"!==t.sent){t.next=18;break}return t.next=6,r._get_subscription();case 6:if(t.sent){t.next=18;break}if(h.vapid_key){t.next=11;break}return console.log("SuprSend: Provide vapid key while calling init"),t.abrupt("return");case 11:return n=J.urlB64ToUint8Array(h.vapid_key),t.next=14,e.pushManager.subscribe({applicationServerKey:n,userVisibleOnly:!0});case 14:o=t.sent,r.user.add_webpush(o),t.next=18;break;case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),yt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),yt(this,"is_subscribed",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._get_subscription_without_wait();case 2:return e=t.sent,t.abrupt("return",!!e);case 4:case"end":return t.stop()}}),t)})))),this.instance=e,this.user=new lt(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-$t;e>=h.sw_delay?this._register_sw():(clearTimeout(_t),_t=setTimeout((function(){t._register_sw()}),h.sw_delay-e))}},{key:"update_subscription",value:function(){var t,e,r=this;null===(t=navigator)||void 0===t||null===(e=t.serviceWorker)||void 0===e||e.ready.then((function(t){return t.pushManager.getSubscription()})).then((function(t){t&&r.user.add_webpush(t)}))}},{key:"notification_permission",value:function(){return Notification.permission}}])&&vt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const mt=gt;function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function wt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function xt(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function kt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Tt(t,e)}function St(t){var e=Pt();return function(){var r,n=At(t);if(e){var o=At(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Et(this,r)}}function Et(t,e){if(e&&("object"===bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function jt(t){var e="function"==typeof Map?new Map:void 0;return jt=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Lt(t,arguments,At(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tt(n,t)},jt(t)}function Lt(t,e,r){return Lt=Pt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Tt(o,r.prototype),o},Lt.apply(null,arguments)}function Pt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}var Nt,$t,Ct=function(t){Ot(r,t);var e=St(r);function r(t){var n;return kt(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return xt(r)}(function(t){Ot(r,t);var e=St(r);function r(t){var n;return kt(this,r),(n=e.call(this,t)).name="SuprsendError",n}return xt(r)}(jt(Error)));function It(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map((function(t){t(r)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,r)}))}}}function Gt(t){return Gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gt(t)}function Mt(){Mt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==Gt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Ft(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var zt=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,o,u,s;return r=e,n=[{key:"init",value:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.env=r,o.signing_key=n;var i=J.get_cookie(t);Nt||(Nt={},this._set_custom_config(o)),i||(i=J.uuid(),J.set_cookie(t,i)),Nt.distinct_id=i,this.emitter=It(),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),this.web_push.update_subscription(),e._set_env_properties(),$t||(J.bulk_call_api(),this.track(c.app_launched)),$t=new Date}},{key:"_set_custom_config_property",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e)h[t]=e;else if(r)throw new Ct("Mandatory Key Missing: ".concat(t))}},{key:"_set_custom_config",value:function(t){this._set_custom_config_property("env_key",t.env,!0),this._set_custom_config_property("signing_key",t.signing_key,!0),this._set_custom_config_property("api_url",null==t?void 0:t.api_url),this._set_custom_config_property("vapid_key",null==t?void 0:t.vapid_key),this._set_custom_config_property("service_worker_file",null==t?void 0:t.sw_file_name)}},{key:"set_super_properties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=J.get_parsed_local_store_data(i),r=Ut(Ut({},e),t),n={};for(var o in r)J.has_special_char(o)||(n[o]=r[o]);J.set_local_storage_item(i,JSON.stringify(n)),Nt.env_properties=Ut(Ut({},Nt.env_properties),n)}},{key:"identify",value:function(e){Nt._user_identified||(J.batch_or_call({env:h.env_key,event:"$identify",$insert_id:J.uuid(),$time:J.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:Nt.distinct_id}}),J.set_cookie(t,e),Nt.distinct_id=e,Nt._user_identified=!0,this.web_push.update_subscription(),this.track(c.user_login))}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==t)if(J.is_internal_event(t)||!J.has_special_char(t)){var r=J.get_parsed_local_store_data(i),n=J.format_props({key:e}),o=Ut(Ut(Ut(Ut({},n),Nt.env_properties),r),{},{$current_url:window.location.href});J.batch_or_call({event:String(t),distinct_id:Nt.distinct_id,env:h.env_key,properties:o,$insert_id:J.uuid(),$time:J.epoch_milliseconds()})}else console.log("SuprSend: key cannot start with $ or ss_")}},{key:"purchase_made",value:function(t){this.track(c.purchase_made,t)}},{key:"reset",value:(u=Mt().mark((function r(){var n,o,a,u=arguments;return Mt().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null==(n=u.length>0&&void 0!==u[0]?u[0]:{unsubscribe_push:!0})||!n.unsubscribe_push){r.next=6;break}return r.next=4,this.web_push._get_subscription_without_wait();case 4:(o=r.sent)&&this.user.remove_webpush(o);case 6:this.track(c.user_logout),a=J.uuid(),J.set_cookie(t,a),Nt={distinct_id:a,_user_identified:!1},J.remove_local_storage_item(i),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),e._set_env_properties();case 14:case"end":return r.stop()}}),r,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=u.apply(t,e);function i(t){Ft(o,r,n,i,a,"next",t)}function a(t){Ft(o,r,n,i,a,"throw",t)}i(void 0)}))},function(){return s.apply(this,arguments)})}],o=[{key:"_set_env_properties",value:function(){var t=J.get_local_storage_item(a);t||(t=J.uuid(),J.set_local_storage_item(a,t)),Nt.env_properties={$os:J.os(),$browser:J.browser(),$browser_version:J.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&qt(r.prototype,n),o&&qt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Wt=new zt}(),window.suprsend=n}();
2
+ !function(){var t={560:function(t,e,r){var n;!function(o){"use strict";function i(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function a(t,e,r,n,o,a){return i((c=i(i(e,t),i(n,a)))<<(u=o)|c>>>32-u,r);var c,u}function c(t,e,r,n,o,i,c){return a(e&r|~e&n,t,e,o,i,c)}function u(t,e,r,n,o,i,c){return a(e&n|r&~n,t,e,o,i,c)}function s(t,e,r,n,o,i,c){return a(e^r^n,t,e,o,i,c)}function l(t,e,r,n,o,i,c){return a(r^(e|~n),t,e,o,i,c)}function f(t,e){var r,n,o,a,f;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var h=1732584193,p=-271733879,d=-1732584194,v=271733878;for(r=0;r<t.length;r+=16)n=h,o=p,a=d,f=v,h=c(h,p,d,v,t[r],7,-680876936),v=c(v,h,p,d,t[r+1],12,-389564586),d=c(d,v,h,p,t[r+2],17,606105819),p=c(p,d,v,h,t[r+3],22,-1044525330),h=c(h,p,d,v,t[r+4],7,-176418897),v=c(v,h,p,d,t[r+5],12,1200080426),d=c(d,v,h,p,t[r+6],17,-1473231341),p=c(p,d,v,h,t[r+7],22,-45705983),h=c(h,p,d,v,t[r+8],7,1770035416),v=c(v,h,p,d,t[r+9],12,-1958414417),d=c(d,v,h,p,t[r+10],17,-42063),p=c(p,d,v,h,t[r+11],22,-1990404162),h=c(h,p,d,v,t[r+12],7,1804603682),v=c(v,h,p,d,t[r+13],12,-40341101),d=c(d,v,h,p,t[r+14],17,-1502002290),h=u(h,p=c(p,d,v,h,t[r+15],22,1236535329),d,v,t[r+1],5,-165796510),v=u(v,h,p,d,t[r+6],9,-1069501632),d=u(d,v,h,p,t[r+11],14,643717713),p=u(p,d,v,h,t[r],20,-373897302),h=u(h,p,d,v,t[r+5],5,-701558691),v=u(v,h,p,d,t[r+10],9,38016083),d=u(d,v,h,p,t[r+15],14,-660478335),p=u(p,d,v,h,t[r+4],20,-405537848),h=u(h,p,d,v,t[r+9],5,568446438),v=u(v,h,p,d,t[r+14],9,-1019803690),d=u(d,v,h,p,t[r+3],14,-187363961),p=u(p,d,v,h,t[r+8],20,1163531501),h=u(h,p,d,v,t[r+13],5,-1444681467),v=u(v,h,p,d,t[r+2],9,-51403784),d=u(d,v,h,p,t[r+7],14,1735328473),h=s(h,p=u(p,d,v,h,t[r+12],20,-1926607734),d,v,t[r+5],4,-378558),v=s(v,h,p,d,t[r+8],11,-2022574463),d=s(d,v,h,p,t[r+11],16,1839030562),p=s(p,d,v,h,t[r+14],23,-35309556),h=s(h,p,d,v,t[r+1],4,-1530992060),v=s(v,h,p,d,t[r+4],11,1272893353),d=s(d,v,h,p,t[r+7],16,-155497632),p=s(p,d,v,h,t[r+10],23,-1094730640),h=s(h,p,d,v,t[r+13],4,681279174),v=s(v,h,p,d,t[r],11,-358537222),d=s(d,v,h,p,t[r+3],16,-722521979),p=s(p,d,v,h,t[r+6],23,76029189),h=s(h,p,d,v,t[r+9],4,-640364487),v=s(v,h,p,d,t[r+12],11,-421815835),d=s(d,v,h,p,t[r+15],16,530742520),h=l(h,p=s(p,d,v,h,t[r+2],23,-995338651),d,v,t[r],6,-198630844),v=l(v,h,p,d,t[r+7],10,1126891415),d=l(d,v,h,p,t[r+14],15,-1416354905),p=l(p,d,v,h,t[r+5],21,-57434055),h=l(h,p,d,v,t[r+12],6,1700485571),v=l(v,h,p,d,t[r+3],10,-1894986606),d=l(d,v,h,p,t[r+10],15,-1051523),p=l(p,d,v,h,t[r+1],21,-2054922799),h=l(h,p,d,v,t[r+8],6,1873313359),v=l(v,h,p,d,t[r+15],10,-30611744),d=l(d,v,h,p,t[r+6],15,-1560198380),p=l(p,d,v,h,t[r+13],21,1309151649),h=l(h,p,d,v,t[r+4],6,-145523070),v=l(v,h,p,d,t[r+11],10,-1120210379),d=l(d,v,h,p,t[r+2],15,718787259),p=l(p,d,v,h,t[r+9],21,-343485551),h=i(h,n),p=i(p,o),d=i(d,a),v=i(v,f);return[h,p,d,v]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function p(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function d(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function v(t){return unescape(encodeURIComponent(t))}function y(t){return function(t){return h(f(p(t),8*t.length))}(v(t))}function _(t,e){return function(t,e){var r,n,o=p(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=f(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=f(i.concat(p(e)),512+8*e.length),h(f(a.concat(n),640))}(v(t),v(e))}function g(t,e,r){return e?r?_(e,t):d(_(e,t)):r?y(t):d(y(t))}void 0===(n=function(){return g}.call(e,r,e,t))||(t.exports=n)}()},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.1","description":"This is sdk used to integrate suprsend functionality in javascript applications","main":"dist/cjs_bundle.js","scripts":{"test":"echo \\"Error: no test specified\\" && exit 1","build":"rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js","publish_sdk":"npm run build && npm publish"},"keywords":["suprsend","suprsend-browser","suprsend-browser-sdk"],"author":"Sivaram Katta","license":"MIT","repository":{"type":"git","url":"https://github.com/suprsend/suprsend-browser.git"},"types":"src/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"^7.18.5","@babel/preset-env":"^7.18.2","babel-loader":"^8.2.5","webpack":"^5.76.0","webpack-cli":"^4.8.0"},"dependencies":{"blueimp-md5":"^2.19.0","mitt":"^3.0.0"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};!function(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return rt},PreferenceOptions:function(){return et},default:function(){return Wt},initialisedAt:function(){return $t}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(560),d=r.n(p);function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(){y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(d=g);var m=p.prototype=f.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==v(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function _(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){_(i,n,o,a,c,"next",t)}function c(t){_(i,n,o,a,c,"throw",t)}a(void 0)}))}}function m(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var w=function(t){return new Uint8Array(m(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function x(t,e,r){return k.apply(this,arguments)}function k(){return k=g(y().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,_=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=d()(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=w(a),f=w(s),t.next=12,crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!0,["sign"]);case 12:return p=t.sent,t.next=15,crypto.subtle.sign("HMAC",p,f);case 15:return v=t.sent,m(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,m(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),k.apply(this,arguments)}function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function S(){S=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==O(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function j(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){P(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function T(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){T(i,n,o,a,c,"next",t)}function c(t){T(i,n,o,a,c,"throw",t)}a(void 0)}))}}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=$(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function $(t,e){if(t){if("string"==typeof t)return C(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?C(t,e):void 0}}function C(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function I(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(I())return localStorage.getItem(t)}function M(t,e){I()&&localStorage.setItem(t,e)}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function D(){var t=navigator.userAgent;for(var e in u){var r,n=N(u[e]);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t.indexOf(o)>=0)return e}}catch(t){n.e(t)}finally{n.f()}}return""}function U(t,e){return R.apply(this,arguments)}function R(){return R=A(S().mark((function t(e,r){var n,o,i,a,c,u=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:"POST",o=(new Date).toGMTString(),i=JSON.stringify(r),t.next=5,x(i,o,"POST");case 5:return a=t.sent,c=a?"".concat(h.env_key,":").concat(a):h.env_key,t.abrupt("return",fetch("".concat(h.api_url,"/").concat(e),{method:n,body:i,headers:{"Content-Type":"application/json",Authorization:c,"x-amz-date":o}}));case 8:case"end":return t.stop()}}),t)}))),R.apply(this,arguments)}function q(){var t=F(e,[]);if(t.length){var r=t.slice(0,h.batch_size);U(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=F(e,[]);r.splice(0,h.batch_size),M(e,JSON.stringify(r)),q()})).catch((function(){z(12e4)}))}else z()}function z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){q()}),t)}var W=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function Y(t,e){var r,n=this;return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r&&clearTimeout(r),r=setTimeout((function(){t.apply(n,i)}),e)}}const J={uuid:function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)}))},epoch_milliseconds:function(){return Math.round(Date.now())},cookie_enabled:function(){return navigator.cookieEnabled},set_cookie:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365,n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/"},get_cookie:function(t){for(var e=t+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},remove_cookie:function(t){document.cookie=t+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},local_storage_enabled:I,get_local_storage_item:G,set_local_storage_item:M,remove_local_storage_item:function(t){I()&&localStorage.removeItem(t)},get_parsed_local_store_data:F,browser:D,browser_version:function(){var t=navigator.userAgent,e=D(),r=s[e];if(!r||!e)return"";var n,o=N(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(i){var a=t.match(i);if(a&&a.length>1)return a[1]}}}catch(t){o.e(t)}finally{o.f()}return""},os:function(){var t=navigator.userAgent;for(var e in l)if(t.indexOf(l[e])>=0)return e;return""},schedule_flush:z,format_props:function(t){var e,r=t.key,n=t.value,o=t.allow_special_tags,i=void 0!==o&&o;if(r instanceof Object){for(var a in e={},r)if(void 0!==r[a]){if(!i&&W(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&W(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=P({},String(r),n)}return e},urlB64ToUint8Array:function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=window.atob(e),n=new Uint8Array(r.length),o=0;o<r.length;++o)n[o]=r.charCodeAt(o);return n},batch_or_call:function(t){if(I()){var r=F(e,[]);null==r||r.push(t),M(e,JSON.stringify(r))}else U(o,t)},has_special_char:W,is_empty:function(t){return Array.isArray(t)?0===t.length:t instanceof Object?0===Object.keys(t).length:["",null,void 0].includes(t)},bulk_call_api:q,is_internal_event:function(t){return Object.values(c).includes(t)},api:U,debounce_by_type:function(t,e,r){var n={};return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=i[0],u=i.slice(1);return"function"==typeof n[c]||(n[c]=Y(t,e,j(j({},r),{},{leading:!0}))),n[c].apply(n,L(u))}}};function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function K(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return V(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?V(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function V(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function H(){H=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==B(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Q(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function X(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var et={OPT_IN:"opt_in",OPT_OUT:"opt_out"},rt={ALL:"all",REQUIRED:"required"},nt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),tt(this,"_update_category_preferences",X(H().mark((function t(){var e,r,o,i,a,c,u=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"",r=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2?u[2]:void 0,i=u.length>3&&void 0!==u[3]?u[3]:{},a="category/".concat(e),t.next=7,n._update_request(r,a,i);case 7:return null!=(c=t.sent)&&c.error?n._emitter.emit("preferences_error",c):(Object.assign(o,c),n._emitter.emit("preferences_updated",n.data)),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)})))),tt(this,"_update_channel_preferences",X(H().mark((function t(){var e,r,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="channel_preference",t.next=4,n._update_request(e,r);case 4:if(null==(o=t.sent)||!o.error){t.next=9;break}n._emitter.emit("preferences_error",o),t.next=12;break;case 9:return t.next=11,n.get_preferences(n._preference_args);case 11:n._emitter.emit("preferences_updated",n.data);case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))),this.ss_instance=e,this._preference_data,this._preference_args,this._emitter=r,this._debounced_update_category_preferences=J.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=J.debounce_by_type(this._update_channel_preferences,h.preference_debounce)}var e,r,n,o,i,a,c,u;return e=t,r=[{key:"_validate_query_params",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};for(var r in t)t[r]&&(e[r]=t[r]);return e}},{key:"_get_request",value:(u=X(H().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n="/v1/subscriber/".concat(this.ss_instance.distinct_id),o=this._validate_query_params(r),i=new URLSearchParams(o).toString(),a=i?"".concat(n,"/").concat(e,"/?").concat(i):"".concat(n,"/").concat(e),c=(new Date).toGMTString(),t.next=9,x("",c,"GET",a);case 9:return u=t.sent,s=u?"".concat(h.env_key,":").concat(u):h.env_key,t.prev=11,t.next=14,fetch("".concat(h.api_url).concat(a),{headers:{"Content-Type":"application/json",Authorization:s,"x-amz-date":c}});case 14:if(!(l=t.sent).ok){t.next=18;break}return f=l.json(),t.abrupt("return",f);case 18:return t.abrupt("return",{error:!0,api_error:!0,status_code:l.status,message:l.statusText,error_obj:null});case 21:return t.prev=21,t.t0=t.catch(11),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 24:case"end":return t.stop()}}),t,this,[[11,21]])}))),function(){return u.apply(this,arguments)})},{key:"_update_request",value:(c=X(H().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="/v1/subscriber/".concat(this.ss_instance.distinct_id),i=this._validate_query_params(n),a=new URLSearchParams(i).toString(),c=a?"".concat(o,"/").concat(r,"/?").concat(a):"".concat(o,"/").concat(r),u=(new Date).toGMTString(),s=JSON.stringify(e),t.next=8,x(s,u,"POST",c);case 8:return l=t.sent,f=l?"".concat(h.env_key,":").concat(l):h.env_key,t.prev=10,t.next=13,fetch("".concat(h.api_url).concat(c),{method:"POST",body:s,headers:{"Content-Type":"application/json",Authorization:f,"x-amz-date":u}});case 13:if(!(p=t.sent).ok){t.next=17;break}return d=p.json(),t.abrupt("return",d);case 17:return t.abrupt("return",{error:!0,api_error:!0,status_code:p.status,message:p.statusText,error_obj:null});case 20:return t.prev=20,t.t0=t.catch(10),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 23:case"end":return t.stop()}}),t,this,[[10,20]])}))),function(t,e,r){return c.apply(this,arguments)})},{key:"data",get:function(){return this._preference_data},set:function(t){this._preference_data=t}},{key:"get_preferences",value:(a=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="full_preference",this._preference_args=e,n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels},t.next=6,this._get_request(r,n);case 6:return null!=(o=t.sent)&&o.error||(this.data=o),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"get_categories",value:(i=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="category",n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels,limit:null==e?void 0:e.limit,offset:null==e?void 0:e.offset},t.next=5,this._get_request(r,n);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"get_category",value:(o=X(H().mark((function t(){var e,r,n,o,i,a=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:"",r=a.length>1&&void 0!==a[1]?a[1]:{},e){t.next=4;break}return t.abrupt("return",{error:!0,message:"Category parameter is missing"});case 4:return n="category/".concat(e),o={tenant_id:null==r?void 0:r.tenant_id,show_opt_out_channels:null==r?void 0:r.show_opt_out_channels},t.next=8,this._get_request(n,o);case 8:return i=t.sent,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get_overall_channel_preferences",value:(n=X(H().mark((function t(){var e;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this._get_request("channel_preference");case 3:return e=t.sent,t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"update_category_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||![et.OPT_IN,et.OPT_OUT].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Category parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var o,i=!1,a=null==n?void 0:n.show_opt_out_channels,c=K(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=K(s.subcategories);try{for(f.s();!(u=f.n()).done;){var h=u.value;if(h.category===e){if(t=h,!h.is_editable)return{error:!0,message:"Category preference is not editable"};if(h.preference!==r){h.preference=r,i=!0,l=!0;break}}}}catch(t){f.e(t)}finally{f.f()}if(l)break}}catch(t){c.e(t)}finally{c.f()}if(!t)return{error:!0,message:"Category is not found"};if(!i)return this.data;var p=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===et.OPT_IN?null:p};return this._debounced_update_category_preferences(e,e,d,t,{tenant_id:null==n?void 0:n.tenant_id,show_opt_out_channels:null==n?void 0:n.show_opt_out_channels}),this.data}},{key:"update_channel_preference_in_category",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!r||!o)return{error:!0,message:r?"Category parameter is missing":"Channel parameter is missing"};if(![et.OPT_IN,et.OPT_OUT].includes(n))return{error:!0,message:"Preference parameter is invalid"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var a,c=!1,u=K(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=K(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=K(p.channels);try{for(v.s();!(d=v.n()).done;){var y=d.value;if(y.channel===r){if(e=y,!y.is_editable)return{error:!0,message:"Channel preference is not editable"};if(y.preference!==n){y.preference=n,n===et.OPT_IN&&(p.preference=et.OPT_IN),c=!0,f=!0;break}}}}catch(t){v.e(t)}finally{v.f()}}if(f)break}}catch(t){h.e(t)}finally{h.f()}if(f)break}}catch(t){u.e(t)}finally{u.f()}if(!t)return{error:!0,message:"Category not found"};if(!e)return{error:!0,message:"Category's Channel not found"};if(!c)return this.data;var _=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===et.OPT_OUT&&n===et.OPT_IN?et.OPT_IN:t.preference,m={preference:g,opt_out_channels:_};return this._debounced_update_category_preferences(o,o,m,t,{tenant_id:null==i?void 0:i.tenant_id,show_opt_out_channels:null==i?void 0:i.show_opt_out_channels}),this.data}},{key:"update_overall_channel_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||![rt.ALL,rt.REQUIRED].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Channel parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var n,o=!1,i=r===rt.REQUIRED,a=K(this.data.channel_preferences);try{for(a.s();!(n=a.n()).done;){var c=n.value;if(c.channel===e&&(t=c,c.is_restricted!==i)){c.is_restricted=i,o=!0;break}}}catch(t){a.e(t)}finally{a.f()}return t?o?(this._debounced_update_channel_preferences(t.channel,{channel_preferences:[t]}),this.data):this.data:{error:!0,message:"Channel data not found"}}}],r&&Z(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const ot=nt;function it(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function at(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach((function(e){ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var st=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ut(this,"_allow_special_char_events",(function(t){return"$email"===t||"$whatsapp"===t||"$sms"===t||(null==t?void 0:t.$webpush)})),this.instance=e,this.preferences=new ot(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){J.batch_or_call(at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;J.api(o,at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t)).then((function(t){if(!t.ok)throw new Error("Error in Fetch")})).catch((function(){e._call_indentity(t)}))}},{key:"_convert_to_number",value:function(t){if(!J.is_empty(t))for(var e in t){var r=Number(t[e]);r?t[e]=r:delete t[e]}return t}},{key:"_validate_email_and_send",value:function(t,e){f.email.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Email ID")}},{key:"_validate_mobile_and_send",value:function(t,e){try{f.mobile.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}catch(t){console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}}},{key:"set",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set_once:r})}},{key:"increment",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=J.format_props({key:t,value:e}),n=this._convert_to_number(r);J.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=J.format_props({key:t,value:e,allow_special_tags:r});J.is_empty(n)||this._call_indentity({$append:n})}},{key:"remove",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._allow_special_char_events(t),o=J.format_props({key:t,value:e,allow_special_tags:n});J.is_empty(o)||(null!=r&&r.flush_immediately?this._call_flush_immediately({$remove:o}):this._call_indentity({$remove:o}))}},{key:"unset",value:function(t){var e;"string"==typeof t?J.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){J.has_special_char(String(t))||e.push(String(t))}))),J.is_empty(e)||this._call_indentity({$unset:e})}},{key:"add_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_email_and_send("$email",t)}},{key:"remove_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$email",t)}},{key:"add_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$sms",t)}},{key:"remove_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$sms",t)}},{key:"add_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$whatsapp",t)}},{key:"remove_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$whatsapp",t)}},{key:"add_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.append({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"})}},{key:"remove_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"},null,{flush_immediately:!0})}}],r&&ct(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=st;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(){ht=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==ft(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function pt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function yt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t,gt=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),yt(this,"_ask_notification_permission",dt(ht().mark((function t(){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Notification.requestPermission();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),yt(this,"_register_sw",(function(){return navigator.serviceWorker.register("/".concat(h.service_worker_file)).then((function(t){r._subscribe_push(t)})).catch((function(t){console.error("SuprSend: Unable to register service worker.",t)}))})),yt(this,"_get_subscription_without_wait",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.serviceWorker.getRegistration();case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.abrupt("return",e.pushManager.getSubscription().then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:case"end":return t.stop()}}),t)})))),yt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),yt(this,"_subscribe_push",function(){var t=dt(ht().mark((function t(e){var n,o;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._ask_notification_permission();case 2:if("granted"!==t.sent){t.next=18;break}return t.next=6,r._get_subscription();case 6:if(t.sent){t.next=18;break}if(h.vapid_key){t.next=11;break}return console.log("SuprSend: Provide vapid key while calling init"),t.abrupt("return");case 11:return n=J.urlB64ToUint8Array(h.vapid_key),t.next=14,e.pushManager.subscribe({applicationServerKey:n,userVisibleOnly:!0});case 14:o=t.sent,r.user.add_webpush(o),t.next=18;break;case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),yt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),yt(this,"is_subscribed",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._get_subscription_without_wait();case 2:return e=t.sent,t.abrupt("return",!!e);case 4:case"end":return t.stop()}}),t)})))),this.instance=e,this.user=new lt(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-$t;e>=h.sw_delay?this._register_sw():(clearTimeout(_t),_t=setTimeout((function(){t._register_sw()}),h.sw_delay-e))}},{key:"update_subscription",value:function(){var t,e,r=this;null===(t=navigator)||void 0===t||null===(e=t.serviceWorker)||void 0===e||e.ready.then((function(t){return t.pushManager.getSubscription()})).then((function(t){t&&r.user.add_webpush(t)}))}},{key:"notification_permission",value:function(){return Notification.permission}}])&&vt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const mt=gt;function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function wt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function xt(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function kt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Tt(t,e)}function St(t){var e=Pt();return function(){var r,n=At(t);if(e){var o=At(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Et(this,r)}}function Et(t,e){if(e&&("object"===bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function jt(t){var e="function"==typeof Map?new Map:void 0;return jt=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Lt(t,arguments,At(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tt(n,t)},jt(t)}function Lt(t,e,r){return Lt=Pt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Tt(o,r.prototype),o},Lt.apply(null,arguments)}function Pt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}var Nt,$t,Ct=function(t){Ot(r,t);var e=St(r);function r(t){var n;return kt(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return xt(r)}(function(t){Ot(r,t);var e=St(r);function r(t){var n;return kt(this,r),(n=e.call(this,t)).name="SuprsendError",n}return xt(r)}(jt(Error)));function It(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map((function(t){t(r)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,r)}))}}}function Gt(t){return Gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gt(t)}function Mt(){Mt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==Gt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Ft(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var zt=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,o,u,s;return r=e,n=[{key:"init",value:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.env=r,o.signing_key=n;var i=J.get_cookie(t);Nt||(Nt={},this._set_custom_config(o)),i||(i=J.uuid(),J.set_cookie(t,i)),Nt.distinct_id=i,this.emitter=It(),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),this.web_push.update_subscription(),e._set_env_properties(),$t||(J.bulk_call_api(),this.track(c.app_launched)),$t=new Date}},{key:"_set_custom_config_property",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e)h[t]=e;else if(r)throw new Ct("Mandatory Key Missing: ".concat(t))}},{key:"_set_custom_config",value:function(t){this._set_custom_config_property("env_key",t.env,!0),this._set_custom_config_property("signing_key",t.signing_key,!0),this._set_custom_config_property("api_url",null==t?void 0:t.api_url),this._set_custom_config_property("vapid_key",null==t?void 0:t.vapid_key),this._set_custom_config_property("service_worker_file",null==t?void 0:t.sw_file_name)}},{key:"set_super_properties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=J.get_parsed_local_store_data(i),r=Ut(Ut({},e),t),n={};for(var o in r)J.has_special_char(o)||(n[o]=r[o]);J.set_local_storage_item(i,JSON.stringify(n)),Nt.env_properties=Ut(Ut({},Nt.env_properties),n)}},{key:"identify",value:function(e){Nt._user_identified||(J.batch_or_call({env:h.env_key,event:"$identify",$insert_id:J.uuid(),$time:J.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:Nt.distinct_id}}),J.set_cookie(t,e),Nt.distinct_id=e,Nt._user_identified=!0,this.web_push.update_subscription(),this.track(c.user_login))}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==t)if(J.is_internal_event(t)||!J.has_special_char(t)){var r=J.get_parsed_local_store_data(i),n=J.format_props({key:e}),o=Ut(Ut(Ut(Ut({},n),Nt.env_properties),r),{},{$current_url:window.location.href});J.batch_or_call({event:String(t),distinct_id:Nt.distinct_id,env:h.env_key,properties:o,$insert_id:J.uuid(),$time:J.epoch_milliseconds()})}else console.log("SuprSend: key cannot start with $ or ss_")}},{key:"purchase_made",value:function(t){this.track(c.purchase_made,t)}},{key:"reset",value:(u=Mt().mark((function r(){var n,o,a,u=arguments;return Mt().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null==(n=u.length>0&&void 0!==u[0]?u[0]:{unsubscribe_push:!0})||!n.unsubscribe_push){r.next=6;break}return r.next=4,this.web_push._get_subscription_without_wait();case 4:(o=r.sent)&&this.user.remove_webpush(o);case 6:this.track(c.user_logout),a=J.uuid(),J.set_cookie(t,a),Nt={distinct_id:a,_user_identified:!1},J.remove_local_storage_item(i),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),e._set_env_properties();case 14:case"end":return r.stop()}}),r,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=u.apply(t,e);function i(t){Ft(o,r,n,i,a,"next",t)}function a(t){Ft(o,r,n,i,a,"throw",t)}i(void 0)}))},function(){return s.apply(this,arguments)})}],o=[{key:"_set_env_properties",value:function(){var t=J.get_local_storage_item(a);t||(t=J.uuid(),J.set_local_storage_item(a,t)),Nt.env_properties={$os:J.os(),$browser:J.browser(),$browser_version:J.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&qt(r.prototype,n),o&&qt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Wt=new zt}(),window.suprsend=n}();
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see cjs_bundle.js.LICENSE.txt */
2
- !function(){var t={560:function(t,e,r){var n;!function(o){"use strict";function i(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function a(t,e,r,n,o,a){return i((c=i(i(e,t),i(n,a)))<<(u=o)|c>>>32-u,r);var c,u}function c(t,e,r,n,o,i,c){return a(e&r|~e&n,t,e,o,i,c)}function u(t,e,r,n,o,i,c){return a(e&n|r&~n,t,e,o,i,c)}function s(t,e,r,n,o,i,c){return a(e^r^n,t,e,o,i,c)}function l(t,e,r,n,o,i,c){return a(r^(e|~n),t,e,o,i,c)}function f(t,e){var r,n,o,a,f;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var h=1732584193,p=-271733879,d=-1732584194,v=271733878;for(r=0;r<t.length;r+=16)n=h,o=p,a=d,f=v,h=c(h,p,d,v,t[r],7,-680876936),v=c(v,h,p,d,t[r+1],12,-389564586),d=c(d,v,h,p,t[r+2],17,606105819),p=c(p,d,v,h,t[r+3],22,-1044525330),h=c(h,p,d,v,t[r+4],7,-176418897),v=c(v,h,p,d,t[r+5],12,1200080426),d=c(d,v,h,p,t[r+6],17,-1473231341),p=c(p,d,v,h,t[r+7],22,-45705983),h=c(h,p,d,v,t[r+8],7,1770035416),v=c(v,h,p,d,t[r+9],12,-1958414417),d=c(d,v,h,p,t[r+10],17,-42063),p=c(p,d,v,h,t[r+11],22,-1990404162),h=c(h,p,d,v,t[r+12],7,1804603682),v=c(v,h,p,d,t[r+13],12,-40341101),d=c(d,v,h,p,t[r+14],17,-1502002290),h=u(h,p=c(p,d,v,h,t[r+15],22,1236535329),d,v,t[r+1],5,-165796510),v=u(v,h,p,d,t[r+6],9,-1069501632),d=u(d,v,h,p,t[r+11],14,643717713),p=u(p,d,v,h,t[r],20,-373897302),h=u(h,p,d,v,t[r+5],5,-701558691),v=u(v,h,p,d,t[r+10],9,38016083),d=u(d,v,h,p,t[r+15],14,-660478335),p=u(p,d,v,h,t[r+4],20,-405537848),h=u(h,p,d,v,t[r+9],5,568446438),v=u(v,h,p,d,t[r+14],9,-1019803690),d=u(d,v,h,p,t[r+3],14,-187363961),p=u(p,d,v,h,t[r+8],20,1163531501),h=u(h,p,d,v,t[r+13],5,-1444681467),v=u(v,h,p,d,t[r+2],9,-51403784),d=u(d,v,h,p,t[r+7],14,1735328473),h=s(h,p=u(p,d,v,h,t[r+12],20,-1926607734),d,v,t[r+5],4,-378558),v=s(v,h,p,d,t[r+8],11,-2022574463),d=s(d,v,h,p,t[r+11],16,1839030562),p=s(p,d,v,h,t[r+14],23,-35309556),h=s(h,p,d,v,t[r+1],4,-1530992060),v=s(v,h,p,d,t[r+4],11,1272893353),d=s(d,v,h,p,t[r+7],16,-155497632),p=s(p,d,v,h,t[r+10],23,-1094730640),h=s(h,p,d,v,t[r+13],4,681279174),v=s(v,h,p,d,t[r],11,-358537222),d=s(d,v,h,p,t[r+3],16,-722521979),p=s(p,d,v,h,t[r+6],23,76029189),h=s(h,p,d,v,t[r+9],4,-640364487),v=s(v,h,p,d,t[r+12],11,-421815835),d=s(d,v,h,p,t[r+15],16,530742520),h=l(h,p=s(p,d,v,h,t[r+2],23,-995338651),d,v,t[r],6,-198630844),v=l(v,h,p,d,t[r+7],10,1126891415),d=l(d,v,h,p,t[r+14],15,-1416354905),p=l(p,d,v,h,t[r+5],21,-57434055),h=l(h,p,d,v,t[r+12],6,1700485571),v=l(v,h,p,d,t[r+3],10,-1894986606),d=l(d,v,h,p,t[r+10],15,-1051523),p=l(p,d,v,h,t[r+1],21,-2054922799),h=l(h,p,d,v,t[r+8],6,1873313359),v=l(v,h,p,d,t[r+15],10,-30611744),d=l(d,v,h,p,t[r+6],15,-1560198380),p=l(p,d,v,h,t[r+13],21,1309151649),h=l(h,p,d,v,t[r+4],6,-145523070),v=l(v,h,p,d,t[r+11],10,-1120210379),d=l(d,v,h,p,t[r+2],15,718787259),p=l(p,d,v,h,t[r+9],21,-343485551),h=i(h,n),p=i(p,o),d=i(d,a),v=i(v,f);return[h,p,d,v]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function p(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function d(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function v(t){return unescape(encodeURIComponent(t))}function y(t){return function(t){return h(f(p(t),8*t.length))}(v(t))}function _(t,e){return function(t,e){var r,n,o=p(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=f(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=f(i.concat(p(e)),512+8*e.length),h(f(a.concat(n),640))}(v(t),v(e))}function g(t,e,r){return e?r?_(e,t):d(_(e,t)):r?y(t):d(y(t))}void 0===(n=function(){return g}.call(e,r,e,t))||(t.exports=n)}()},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.0-beta.1","description":"This is sdk used to integrate suprsend functionality in javascript applications","main":"dist/cjs_bundle.js","scripts":{"test":"echo \\"Error: no test specified\\" && exit 1","build":"rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js","publish_sdk":"npm run build && npm publish"},"keywords":["suprsend","suprsend-browser","suprsend-browser-sdk"],"author":"Sivaram Katta","license":"MIT","repository":{"type":"git","url":"https://github.com/suprsend/suprsend-browser.git"},"types":"src/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"^7.18.5","@babel/preset-env":"^7.18.2","babel-loader":"^8.2.5","webpack":"^5.76.0","webpack-cli":"^4.8.0"},"dependencies":{"blueimp-md5":"^2.19.0","mitt":"^3.0.0"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};!function(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return rt},PreferenceOptions:function(){return et},default:function(){return Wt},initialisedAt:function(){return $t}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(560),d=r.n(p);function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(){y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(d=g);var m=p.prototype=f.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==v(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function _(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){_(i,n,o,a,c,"next",t)}function c(t){_(i,n,o,a,c,"throw",t)}a(void 0)}))}}function m(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var w=function(t){return new Uint8Array(m(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function x(t,e,r){return O.apply(this,arguments)}function O(){return O=g(y().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,_=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=d()(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=w(a),f=w(s),t.next=12,crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!0,["sign"]);case 12:return p=t.sent,t.next=15,crypto.subtle.sign("HMAC",p,f);case 15:return v=t.sent,m(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,m(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),O.apply(this,arguments)}function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function S(){S=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==k(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function j(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){P(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function T(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){T(i,n,o,a,c,"next",t)}function c(t){T(i,n,o,a,c,"throw",t)}a(void 0)}))}}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=$(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function $(t,e){if(t){if("string"==typeof t)return C(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?C(t,e):void 0}}function C(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function I(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(I())return localStorage.getItem(t)}function M(t,e){I()&&localStorage.setItem(t,e)}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function D(){var t=navigator.userAgent;for(var e in u){var r,n=N(u[e]);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t.indexOf(o)>=0)return e}}catch(t){n.e(t)}finally{n.f()}}return""}function U(t,e){return R.apply(this,arguments)}function R(){return R=A(S().mark((function t(e,r){var n,o,i,a,c,u=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:"POST",o=(new Date).toGMTString(),i=JSON.stringify(r),t.next=5,x(i,o,"POST");case 5:return a=t.sent,c=a?"".concat(h.env_key,":").concat(a):h.env_key,t.abrupt("return",fetch("".concat(h.api_url,"/").concat(e),{method:n,body:i,headers:{"Content-Type":"application/json",Authorization:c,"x-amz-date":o}}));case 8:case"end":return t.stop()}}),t)}))),R.apply(this,arguments)}function q(){var t=F(e,[]);if(t.length){var r=t.slice(0,h.batch_size);U(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=F(e,[]);r.splice(0,h.batch_size),M(e,JSON.stringify(r)),q()})).catch((function(){z(12e4)}))}else z()}function z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){q()}),t)}var W=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function Y(t,e){var r,n=this;return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r&&clearTimeout(r),r=setTimeout((function(){t.apply(n,i)}),e)}}const J={uuid:function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)}))},epoch_milliseconds:function(){return Math.round(Date.now())},cookie_enabled:function(){return navigator.cookieEnabled},set_cookie:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365,n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/"},get_cookie:function(t){for(var e=t+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},remove_cookie:function(t){document.cookie=t+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},local_storage_enabled:I,get_local_storage_item:G,set_local_storage_item:M,remove_local_storage_item:function(t){I()&&localStorage.removeItem(t)},get_parsed_local_store_data:F,browser:D,browser_version:function(){var t=navigator.userAgent,e=D(),r=s[e];if(!r||!e)return"";var n,o=N(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(i){var a=t.match(i);if(a&&a.length>1)return a[1]}}}catch(t){o.e(t)}finally{o.f()}return""},os:function(){var t=navigator.userAgent;for(var e in l)if(t.indexOf(l[e])>=0)return e;return""},schedule_flush:z,format_props:function(t){var e,r=t.key,n=t.value,o=t.allow_special_tags,i=void 0!==o&&o;if(r instanceof Object){for(var a in e={},r)if(void 0!==r[a]){if(!i&&W(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&W(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=P({},String(r),n)}return e},urlB64ToUint8Array:function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=window.atob(e),n=new Uint8Array(r.length),o=0;o<r.length;++o)n[o]=r.charCodeAt(o);return n},batch_or_call:function(t){if(I()){var r=F(e,[]);null==r||r.push(t),M(e,JSON.stringify(r))}else U(o,t)},has_special_char:W,is_empty:function(t){return Array.isArray(t)?0===t.length:t instanceof Object?0===Object.keys(t).length:["",null,void 0].includes(t)},bulk_call_api:q,is_internal_event:function(t){return Object.values(c).includes(t)},api:U,debounce_by_type:function(t,e,r){var n={};return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=i[0],u=i.slice(1);return"function"==typeof n[c]||(n[c]=Y(t,e,j(j({},r),{},{leading:!0}))),n[c].apply(n,L(u))}}};function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function K(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return V(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?V(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function V(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function H(){H=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==B(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Q(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function X(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var et={OPT_IN:"opt_in",OPT_OUT:"opt_out"},rt={ALL:"all",REQUIRED:"required"},nt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),tt(this,"_update_category_preferences",X(H().mark((function t(){var e,r,o,i,a,c,u=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"",r=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2?u[2]:void 0,i=u.length>3&&void 0!==u[3]?u[3]:{},a="category/".concat(e),t.next=7,n._update_request(r,a,i);case 7:return null!=(c=t.sent)&&c.error?n._emitter.emit("preferences_error",c):(Object.assign(o,c),n._emitter.emit("preferences_updated",n.data)),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)})))),tt(this,"_update_channel_preferences",X(H().mark((function t(){var e,r,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="channel_preference",t.next=4,n._update_request(e,r);case 4:if(null==(o=t.sent)||!o.error){t.next=9;break}n._emitter.emit("preferences_error",o),t.next=12;break;case 9:return t.next=11,n.get_preferences(n._preference_args);case 11:n._emitter.emit("preferences_updated",n.data);case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))),this.ss_instance=e,this._preference_data,this._preference_args,this._emitter=r,this._debounced_update_category_preferences=J.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=J.debounce_by_type(this._update_channel_preferences,h.preference_debounce)}var e,r,n,o,i,a,c,u;return e=t,r=[{key:"_validate_query_params",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};for(var r in t)t[r]&&(e[r]=t[r]);return e}},{key:"_get_request",value:(u=X(H().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n="/v1/subscriber/".concat(this.ss_instance.distinct_id),o=this._validate_query_params(r),i=new URLSearchParams(o).toString(),a=i?"".concat(n,"/").concat(e,"/?").concat(i):"".concat(n,"/").concat(e),c=(new Date).toGMTString(),t.next=9,x("",c,"GET",a);case 9:return u=t.sent,s=u?"".concat(h.env_key,":").concat(u):h.env_key,t.prev=11,t.next=14,fetch("".concat(h.api_url).concat(a),{headers:{"Content-Type":"application/json",Authorization:s,"x-amz-date":c}});case 14:if(!(l=t.sent).ok){t.next=18;break}return f=l.json(),t.abrupt("return",f);case 18:return t.abrupt("return",{error:!0,api_error:!0,status_code:l.status,message:l.statusText,error_obj:null});case 21:return t.prev=21,t.t0=t.catch(11),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 24:case"end":return t.stop()}}),t,this,[[11,21]])}))),function(){return u.apply(this,arguments)})},{key:"_update_request",value:(c=X(H().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="/v1/subscriber/".concat(this.ss_instance.distinct_id),i=this._validate_query_params(n),a=new URLSearchParams(i).toString(),c=a?"".concat(o,"/").concat(r,"/?").concat(a):"".concat(o,"/").concat(r),u=(new Date).toGMTString(),s=JSON.stringify(e),t.next=8,x(s,u,"POST",c);case 8:return l=t.sent,f=l?"".concat(h.env_key,":").concat(l):h.env_key,t.prev=10,t.next=13,fetch("".concat(h.api_url).concat(c),{method:"POST",body:s,headers:{"Content-Type":"application/json",Authorization:f,"x-amz-date":u}});case 13:if(!(p=t.sent).ok){t.next=17;break}return d=p.json(),t.abrupt("return",d);case 17:return t.abrupt("return",{error:!0,api_error:!0,status_code:p.status,message:p.statusText,error_obj:null});case 20:return t.prev=20,t.t0=t.catch(10),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 23:case"end":return t.stop()}}),t,this,[[10,20]])}))),function(t,e,r){return c.apply(this,arguments)})},{key:"data",get:function(){return this._preference_data},set:function(t){this._preference_data=t}},{key:"get_preferences",value:(a=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="full_preference",this._preference_args=e,n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels},t.next=6,this._get_request(r,n);case 6:return null!=(o=t.sent)&&o.error||(this.data=o),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"get_categories",value:(i=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="category",n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels,limit:null==e?void 0:e.limit,offset:null==e?void 0:e.offset},t.next=5,this._get_request(r,n);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"get_category",value:(o=X(H().mark((function t(){var e,r,n,o,i,a=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:"",r=a.length>1&&void 0!==a[1]?a[1]:{},e){t.next=4;break}return t.abrupt("return",{error:!0,message:"Category parameter is missing"});case 4:return n="category/".concat(e),o={tenant_id:null==r?void 0:r.tenant_id,show_opt_out_channels:null==r?void 0:r.show_opt_out_channels},t.next=8,this._get_request(n,o);case 8:return i=t.sent,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get_overall_channel_preferences",value:(n=X(H().mark((function t(){var e;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this._get_request("channel_preference");case 3:return e=t.sent,t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"update_category_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||![et.OPT_IN,et.OPT_OUT].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Category parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var o,i=!1,a=null==n?void 0:n.show_opt_out_channels,c=K(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=K(s.subcategories);try{for(f.s();!(u=f.n()).done;){var h=u.value;if(h.category===e){if(t=h,!h.is_editable)return{error:!0,message:"Category preference is not editable"};if(h.preference!==r){h.preference=r,i=!0,l=!0;break}}}}catch(t){f.e(t)}finally{f.f()}if(l)break}}catch(t){c.e(t)}finally{c.f()}if(!t)return{error:!0,message:"Category is not found"};if(!i)return this.data;var p=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===et.OPT_IN?null:p};return this._debounced_update_category_preferences(e,e,d,t,{tenant_id:null==n?void 0:n.tenant_id,show_opt_out_channels:null==n?void 0:n.show_opt_out_channels}),this.data}},{key:"update_channel_preference_in_category",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!r||!o)return{error:!0,message:r?"Category parameter is missing":"Channel parameter is missing"};if(![et.OPT_IN,et.OPT_OUT].includes(n))return{error:!0,message:"Preference parameter is invalid"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var a,c=!1,u=K(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=K(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=K(p.channels);try{for(v.s();!(d=v.n()).done;){var y=d.value;if(y.channel===r){if(e=y,!y.is_editable)return{error:!0,message:"Channel preference is not editable"};if(y.preference!==n){y.preference=n,n===et.OPT_IN&&(p.preference=et.OPT_IN),c=!0,f=!0;break}}}}catch(t){v.e(t)}finally{v.f()}}if(f)break}}catch(t){h.e(t)}finally{h.f()}if(f)break}}catch(t){u.e(t)}finally{u.f()}if(!t)return{error:!0,message:"Category not found"};if(!e)return{error:!0,message:"Category's Channel not found"};if(!c)return this.data;var _=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===et.OPT_OUT&&n===et.OPT_IN?et.OPT_IN:t.preference,m={preference:g,opt_out_channels:_};return this._debounced_update_category_preferences(o,o,m,t,{tenant_id:null==i?void 0:i.tenant_id,show_opt_out_channels:null==i?void 0:i.show_opt_out_channels}),this.data}},{key:"update_overall_channel_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||![rt.ALL,rt.REQUIRED].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Channel parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var n,o=!1,i=r===rt.REQUIRED,a=K(this.data.channel_preferences);try{for(a.s();!(n=a.n()).done;){var c=n.value;if(c.channel===e&&(t=c,c.is_restricted!==i)){c.is_restricted=i,o=!0;break}}}catch(t){a.e(t)}finally{a.f()}return t?o?(this._debounced_update_channel_preferences(t.channel,{channel_preferences:[t]}),this.data):this.data:{error:!0,message:"Channel data not found"}}}],r&&Z(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const ot=nt;function it(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function at(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach((function(e){ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var st=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ut(this,"_allow_special_char_events",(function(t){return"$email"===t||"$whatsapp"===t||"$sms"===t||(null==t?void 0:t.$webpush)})),this.instance=e,this.preferences=new ot(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){J.batch_or_call(at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;J.api(o,at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t)).then((function(t){if(!t.ok)throw new Error("Error in Fetch")})).catch((function(){e._call_indentity(t)}))}},{key:"_convert_to_number",value:function(t){if(!J.is_empty(t))for(var e in t){var r=Number(t[e]);r?t[e]=r:delete t[e]}return t}},{key:"_validate_email_and_send",value:function(t,e){f.email.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Email ID")}},{key:"_validate_mobile_and_send",value:function(t,e){try{f.mobile.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}catch(t){console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}}},{key:"set",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set_once:r})}},{key:"increment",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=J.format_props({key:t,value:e}),n=this._convert_to_number(r);J.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=J.format_props({key:t,value:e,allow_special_tags:r});J.is_empty(n)||this._call_indentity({$append:n})}},{key:"remove",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._allow_special_char_events(t),o=J.format_props({key:t,value:e,allow_special_tags:n});J.is_empty(o)||(null!=r&&r.flush_immediately?this._call_flush_immediately({$remove:o}):this._call_indentity({$remove:o}))}},{key:"unset",value:function(t){var e;"string"==typeof t?J.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){J.has_special_char(String(t))||e.push(String(t))}))),J.is_empty(e)||this._call_indentity({$unset:e})}},{key:"add_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_email_and_send("$email",t)}},{key:"remove_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$email",t)}},{key:"add_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$sms",t)}},{key:"remove_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$sms",t)}},{key:"add_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$whatsapp",t)}},{key:"remove_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$whatsapp",t)}},{key:"add_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.append({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"})}},{key:"remove_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"},null,{flush_immediately:!0})}}],r&&ct(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=st;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(){ht=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==ft(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function pt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function yt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t,gt=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),yt(this,"_ask_notification_permission",dt(ht().mark((function t(){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Notification.requestPermission();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),yt(this,"_register_sw",(function(){return navigator.serviceWorker.register("/".concat(h.service_worker_file)).then((function(t){r._subscribe_push(t)})).catch((function(t){console.error("SuprSend: Unable to register service worker.",t)}))})),yt(this,"_get_subscription_without_wait",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.serviceWorker.getRegistration();case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.abrupt("return",e.pushManager.getSubscription().then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:case"end":return t.stop()}}),t)})))),yt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),yt(this,"_subscribe_push",function(){var t=dt(ht().mark((function t(e){var n,o;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._ask_notification_permission();case 2:if("granted"!==t.sent){t.next=18;break}return t.next=6,r._get_subscription();case 6:if(t.sent){t.next=18;break}if(h.vapid_key){t.next=11;break}return console.log("SuprSend: Provide vapid key while calling init"),t.abrupt("return");case 11:return n=J.urlB64ToUint8Array(h.vapid_key),t.next=14,e.pushManager.subscribe({applicationServerKey:n,userVisibleOnly:!0});case 14:o=t.sent,r.user.add_webpush(o),t.next=18;break;case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),yt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),yt(this,"is_subscribed",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._get_subscription_without_wait();case 2:return e=t.sent,t.abrupt("return",!!e);case 4:case"end":return t.stop()}}),t)})))),this.instance=e,this.user=new lt(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-$t;e>=h.sw_delay?this._register_sw():(clearTimeout(_t),_t=setTimeout((function(){t._register_sw()}),h.sw_delay-e))}},{key:"update_subscription",value:function(){var t,e,r=this;null===(t=navigator)||void 0===t||null===(e=t.serviceWorker)||void 0===e||e.ready.then((function(t){return t.pushManager.getSubscription()})).then((function(t){t&&r.user.add_webpush(t)}))}},{key:"notification_permission",value:function(){return Notification.permission}}])&&vt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const mt=gt;function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function wt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function xt(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ot(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Tt(t,e)}function St(t){var e=Pt();return function(){var r,n=At(t);if(e){var o=At(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Et(this,r)}}function Et(t,e){if(e&&("object"===bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function jt(t){var e="function"==typeof Map?new Map:void 0;return jt=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Lt(t,arguments,At(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tt(n,t)},jt(t)}function Lt(t,e,r){return Lt=Pt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Tt(o,r.prototype),o},Lt.apply(null,arguments)}function Pt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}var Nt,$t,Ct=function(t){kt(r,t);var e=St(r);function r(t){var n;return Ot(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return xt(r)}(function(t){kt(r,t);var e=St(r);function r(t){var n;return Ot(this,r),(n=e.call(this,t)).name="SuprsendError",n}return xt(r)}(jt(Error)));function It(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map((function(t){t(r)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,r)}))}}}function Gt(t){return Gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gt(t)}function Mt(){Mt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==Gt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Ft(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var zt=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,o,u,s;return r=e,n=[{key:"init",value:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.env=r,o.signing_key=n;var i=J.get_cookie(t);Nt||(Nt={},this._set_custom_config(o)),i||(i=J.uuid(),J.set_cookie(t,i)),Nt.distinct_id=i,this.emitter=It(),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),this.web_push.update_subscription(),e._set_env_properties(),$t||(J.bulk_call_api(),this.track(c.app_launched)),$t=new Date}},{key:"_set_custom_config_property",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e)h[t]=e;else if(r)throw new Ct("Mandatory Key Missing: ".concat(t))}},{key:"_set_custom_config",value:function(t){this._set_custom_config_property("env_key",t.env,!0),this._set_custom_config_property("signing_key",t.signing_key,!0),this._set_custom_config_property("api_url",null==t?void 0:t.api_url),this._set_custom_config_property("vapid_key",null==t?void 0:t.vapid_key),this._set_custom_config_property("service_worker_file",null==t?void 0:t.sw_file_name)}},{key:"set_super_properties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=J.get_parsed_local_store_data(i),r=Ut(Ut({},e),t),n={};for(var o in r)J.has_special_char(o)||(n[o]=r[o]);J.set_local_storage_item(i,JSON.stringify(n)),Nt.env_properties=Ut(Ut({},Nt.env_properties),n)}},{key:"identify",value:function(e){Nt._user_identified||(J.batch_or_call({env:h.env_key,event:"$identify",$insert_id:J.uuid(),$time:J.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:Nt.distinct_id}}),J.set_cookie(t,e),Nt.distinct_id=e,Nt._user_identified=!0,this.web_push.update_subscription(),this.track(c.user_login))}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==t)if(J.is_internal_event(t)||!J.has_special_char(t)){var r=J.get_parsed_local_store_data(i),n=J.format_props({key:e}),o=Ut(Ut(Ut(Ut({},n),Nt.env_properties),r),{},{$current_url:window.location.href});J.batch_or_call({event:String(t),distinct_id:Nt.distinct_id,env:h.env_key,properties:o,$insert_id:J.uuid(),$time:J.epoch_milliseconds()})}else console.log("SuprSend: key cannot start with $ or ss_")}},{key:"purchase_made",value:function(t){this.track(c.purchase_made,t)}},{key:"reset",value:(u=Mt().mark((function r(){var n,o,a,u=arguments;return Mt().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null==(n=u.length>0&&void 0!==u[0]?u[0]:{unsubscribe_push:!0})||!n.unsubscribe_push){r.next=6;break}return r.next=4,this.web_push._get_subscription_without_wait();case 4:(o=r.sent)&&this.user.remove_webpush(o);case 6:this.track(c.user_logout),a=J.uuid(),J.set_cookie(t,a),Nt={distinct_id:a,_user_identified:!1},J.remove_local_storage_item(i),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),e._set_env_properties();case 14:case"end":return r.stop()}}),r,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=u.apply(t,e);function i(t){Ft(o,r,n,i,a,"next",t)}function a(t){Ft(o,r,n,i,a,"throw",t)}i(void 0)}))},function(){return s.apply(this,arguments)})}],o=[{key:"_set_env_properties",value:function(){var t=J.get_local_storage_item(a);t||(t=J.uuid(),J.set_local_storage_item(a,t)),Nt.env_properties={$os:J.os(),$browser:J.browser(),$browser_version:J.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&qt(r.prototype,n),o&&qt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Wt=new zt}();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})}();
2
+ !function(){var t={560:function(t,e,r){var n;!function(o){"use strict";function i(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function a(t,e,r,n,o,a){return i((c=i(i(e,t),i(n,a)))<<(u=o)|c>>>32-u,r);var c,u}function c(t,e,r,n,o,i,c){return a(e&r|~e&n,t,e,o,i,c)}function u(t,e,r,n,o,i,c){return a(e&n|r&~n,t,e,o,i,c)}function s(t,e,r,n,o,i,c){return a(e^r^n,t,e,o,i,c)}function l(t,e,r,n,o,i,c){return a(r^(e|~n),t,e,o,i,c)}function f(t,e){var r,n,o,a,f;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var h=1732584193,p=-271733879,d=-1732584194,v=271733878;for(r=0;r<t.length;r+=16)n=h,o=p,a=d,f=v,h=c(h,p,d,v,t[r],7,-680876936),v=c(v,h,p,d,t[r+1],12,-389564586),d=c(d,v,h,p,t[r+2],17,606105819),p=c(p,d,v,h,t[r+3],22,-1044525330),h=c(h,p,d,v,t[r+4],7,-176418897),v=c(v,h,p,d,t[r+5],12,1200080426),d=c(d,v,h,p,t[r+6],17,-1473231341),p=c(p,d,v,h,t[r+7],22,-45705983),h=c(h,p,d,v,t[r+8],7,1770035416),v=c(v,h,p,d,t[r+9],12,-1958414417),d=c(d,v,h,p,t[r+10],17,-42063),p=c(p,d,v,h,t[r+11],22,-1990404162),h=c(h,p,d,v,t[r+12],7,1804603682),v=c(v,h,p,d,t[r+13],12,-40341101),d=c(d,v,h,p,t[r+14],17,-1502002290),h=u(h,p=c(p,d,v,h,t[r+15],22,1236535329),d,v,t[r+1],5,-165796510),v=u(v,h,p,d,t[r+6],9,-1069501632),d=u(d,v,h,p,t[r+11],14,643717713),p=u(p,d,v,h,t[r],20,-373897302),h=u(h,p,d,v,t[r+5],5,-701558691),v=u(v,h,p,d,t[r+10],9,38016083),d=u(d,v,h,p,t[r+15],14,-660478335),p=u(p,d,v,h,t[r+4],20,-405537848),h=u(h,p,d,v,t[r+9],5,568446438),v=u(v,h,p,d,t[r+14],9,-1019803690),d=u(d,v,h,p,t[r+3],14,-187363961),p=u(p,d,v,h,t[r+8],20,1163531501),h=u(h,p,d,v,t[r+13],5,-1444681467),v=u(v,h,p,d,t[r+2],9,-51403784),d=u(d,v,h,p,t[r+7],14,1735328473),h=s(h,p=u(p,d,v,h,t[r+12],20,-1926607734),d,v,t[r+5],4,-378558),v=s(v,h,p,d,t[r+8],11,-2022574463),d=s(d,v,h,p,t[r+11],16,1839030562),p=s(p,d,v,h,t[r+14],23,-35309556),h=s(h,p,d,v,t[r+1],4,-1530992060),v=s(v,h,p,d,t[r+4],11,1272893353),d=s(d,v,h,p,t[r+7],16,-155497632),p=s(p,d,v,h,t[r+10],23,-1094730640),h=s(h,p,d,v,t[r+13],4,681279174),v=s(v,h,p,d,t[r],11,-358537222),d=s(d,v,h,p,t[r+3],16,-722521979),p=s(p,d,v,h,t[r+6],23,76029189),h=s(h,p,d,v,t[r+9],4,-640364487),v=s(v,h,p,d,t[r+12],11,-421815835),d=s(d,v,h,p,t[r+15],16,530742520),h=l(h,p=s(p,d,v,h,t[r+2],23,-995338651),d,v,t[r],6,-198630844),v=l(v,h,p,d,t[r+7],10,1126891415),d=l(d,v,h,p,t[r+14],15,-1416354905),p=l(p,d,v,h,t[r+5],21,-57434055),h=l(h,p,d,v,t[r+12],6,1700485571),v=l(v,h,p,d,t[r+3],10,-1894986606),d=l(d,v,h,p,t[r+10],15,-1051523),p=l(p,d,v,h,t[r+1],21,-2054922799),h=l(h,p,d,v,t[r+8],6,1873313359),v=l(v,h,p,d,t[r+15],10,-30611744),d=l(d,v,h,p,t[r+6],15,-1560198380),p=l(p,d,v,h,t[r+13],21,1309151649),h=l(h,p,d,v,t[r+4],6,-145523070),v=l(v,h,p,d,t[r+11],10,-1120210379),d=l(d,v,h,p,t[r+2],15,718787259),p=l(p,d,v,h,t[r+9],21,-343485551),h=i(h,n),p=i(p,o),d=i(d,a),v=i(v,f);return[h,p,d,v]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function p(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function d(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function v(t){return unescape(encodeURIComponent(t))}function y(t){return function(t){return h(f(p(t),8*t.length))}(v(t))}function _(t,e){return function(t,e){var r,n,o=p(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=f(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=f(i.concat(p(e)),512+8*e.length),h(f(a.concat(n),640))}(v(t),v(e))}function g(t,e,r){return e?r?_(e,t):d(_(e,t)):r?y(t):d(y(t))}void 0===(n=function(){return g}.call(e,r,e,t))||(t.exports=n)}()},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.1","description":"This is sdk used to integrate suprsend functionality in javascript applications","main":"dist/cjs_bundle.js","scripts":{"test":"echo \\"Error: no test specified\\" && exit 1","build":"rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js","publish_sdk":"npm run build && npm publish"},"keywords":["suprsend","suprsend-browser","suprsend-browser-sdk"],"author":"Sivaram Katta","license":"MIT","repository":{"type":"git","url":"https://github.com/suprsend/suprsend-browser.git"},"types":"src/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"^7.18.5","@babel/preset-env":"^7.18.2","babel-loader":"^8.2.5","webpack":"^5.76.0","webpack-cli":"^4.8.0"},"dependencies":{"blueimp-md5":"^2.19.0","mitt":"^3.0.0"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};!function(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return rt},PreferenceOptions:function(){return et},default:function(){return Wt},initialisedAt:function(){return $t}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(560),d=r.n(p);function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(){y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(d=g);var m=p.prototype=f.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==v(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function _(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){_(i,n,o,a,c,"next",t)}function c(t){_(i,n,o,a,c,"throw",t)}a(void 0)}))}}function m(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var w=function(t){return new Uint8Array(m(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function x(t,e,r){return O.apply(this,arguments)}function O(){return O=g(y().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,_=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=d()(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=w(a),f=w(s),t.next=12,crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!0,["sign"]);case 12:return p=t.sent,t.next=15,crypto.subtle.sign("HMAC",p,f);case 15:return v=t.sent,m(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,m(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),O.apply(this,arguments)}function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function S(){S=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==k(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function j(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){P(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function T(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){T(i,n,o,a,c,"next",t)}function c(t){T(i,n,o,a,c,"throw",t)}a(void 0)}))}}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=$(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function $(t,e){if(t){if("string"==typeof t)return C(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?C(t,e):void 0}}function C(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function I(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(I())return localStorage.getItem(t)}function M(t,e){I()&&localStorage.setItem(t,e)}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function D(){var t=navigator.userAgent;for(var e in u){var r,n=N(u[e]);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t.indexOf(o)>=0)return e}}catch(t){n.e(t)}finally{n.f()}}return""}function U(t,e){return R.apply(this,arguments)}function R(){return R=A(S().mark((function t(e,r){var n,o,i,a,c,u=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:"POST",o=(new Date).toGMTString(),i=JSON.stringify(r),t.next=5,x(i,o,"POST");case 5:return a=t.sent,c=a?"".concat(h.env_key,":").concat(a):h.env_key,t.abrupt("return",fetch("".concat(h.api_url,"/").concat(e),{method:n,body:i,headers:{"Content-Type":"application/json",Authorization:c,"x-amz-date":o}}));case 8:case"end":return t.stop()}}),t)}))),R.apply(this,arguments)}function q(){var t=F(e,[]);if(t.length){var r=t.slice(0,h.batch_size);U(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=F(e,[]);r.splice(0,h.batch_size),M(e,JSON.stringify(r)),q()})).catch((function(){z(12e4)}))}else z()}function z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){q()}),t)}var W=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function Y(t,e){var r,n=this;return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r&&clearTimeout(r),r=setTimeout((function(){t.apply(n,i)}),e)}}const J={uuid:function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)}))},epoch_milliseconds:function(){return Math.round(Date.now())},cookie_enabled:function(){return navigator.cookieEnabled},set_cookie:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365,n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/"},get_cookie:function(t){for(var e=t+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},remove_cookie:function(t){document.cookie=t+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},local_storage_enabled:I,get_local_storage_item:G,set_local_storage_item:M,remove_local_storage_item:function(t){I()&&localStorage.removeItem(t)},get_parsed_local_store_data:F,browser:D,browser_version:function(){var t=navigator.userAgent,e=D(),r=s[e];if(!r||!e)return"";var n,o=N(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(i){var a=t.match(i);if(a&&a.length>1)return a[1]}}}catch(t){o.e(t)}finally{o.f()}return""},os:function(){var t=navigator.userAgent;for(var e in l)if(t.indexOf(l[e])>=0)return e;return""},schedule_flush:z,format_props:function(t){var e,r=t.key,n=t.value,o=t.allow_special_tags,i=void 0!==o&&o;if(r instanceof Object){for(var a in e={},r)if(void 0!==r[a]){if(!i&&W(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&W(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=P({},String(r),n)}return e},urlB64ToUint8Array:function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=window.atob(e),n=new Uint8Array(r.length),o=0;o<r.length;++o)n[o]=r.charCodeAt(o);return n},batch_or_call:function(t){if(I()){var r=F(e,[]);null==r||r.push(t),M(e,JSON.stringify(r))}else U(o,t)},has_special_char:W,is_empty:function(t){return Array.isArray(t)?0===t.length:t instanceof Object?0===Object.keys(t).length:["",null,void 0].includes(t)},bulk_call_api:q,is_internal_event:function(t){return Object.values(c).includes(t)},api:U,debounce_by_type:function(t,e,r){var n={};return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=i[0],u=i.slice(1);return"function"==typeof n[c]||(n[c]=Y(t,e,j(j({},r),{},{leading:!0}))),n[c].apply(n,L(u))}}};function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function K(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return V(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?V(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function V(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function H(){H=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==B(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Q(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function X(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var et={OPT_IN:"opt_in",OPT_OUT:"opt_out"},rt={ALL:"all",REQUIRED:"required"},nt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),tt(this,"_update_category_preferences",X(H().mark((function t(){var e,r,o,i,a,c,u=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"",r=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2?u[2]:void 0,i=u.length>3&&void 0!==u[3]?u[3]:{},a="category/".concat(e),t.next=7,n._update_request(r,a,i);case 7:return null!=(c=t.sent)&&c.error?n._emitter.emit("preferences_error",c):(Object.assign(o,c),n._emitter.emit("preferences_updated",n.data)),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)})))),tt(this,"_update_channel_preferences",X(H().mark((function t(){var e,r,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="channel_preference",t.next=4,n._update_request(e,r);case 4:if(null==(o=t.sent)||!o.error){t.next=9;break}n._emitter.emit("preferences_error",o),t.next=12;break;case 9:return t.next=11,n.get_preferences(n._preference_args);case 11:n._emitter.emit("preferences_updated",n.data);case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))),this.ss_instance=e,this._preference_data,this._preference_args,this._emitter=r,this._debounced_update_category_preferences=J.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=J.debounce_by_type(this._update_channel_preferences,h.preference_debounce)}var e,r,n,o,i,a,c,u;return e=t,r=[{key:"_validate_query_params",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};for(var r in t)t[r]&&(e[r]=t[r]);return e}},{key:"_get_request",value:(u=X(H().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n="/v1/subscriber/".concat(this.ss_instance.distinct_id),o=this._validate_query_params(r),i=new URLSearchParams(o).toString(),a=i?"".concat(n,"/").concat(e,"/?").concat(i):"".concat(n,"/").concat(e),c=(new Date).toGMTString(),t.next=9,x("",c,"GET",a);case 9:return u=t.sent,s=u?"".concat(h.env_key,":").concat(u):h.env_key,t.prev=11,t.next=14,fetch("".concat(h.api_url).concat(a),{headers:{"Content-Type":"application/json",Authorization:s,"x-amz-date":c}});case 14:if(!(l=t.sent).ok){t.next=18;break}return f=l.json(),t.abrupt("return",f);case 18:return t.abrupt("return",{error:!0,api_error:!0,status_code:l.status,message:l.statusText,error_obj:null});case 21:return t.prev=21,t.t0=t.catch(11),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 24:case"end":return t.stop()}}),t,this,[[11,21]])}))),function(){return u.apply(this,arguments)})},{key:"_update_request",value:(c=X(H().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="/v1/subscriber/".concat(this.ss_instance.distinct_id),i=this._validate_query_params(n),a=new URLSearchParams(i).toString(),c=a?"".concat(o,"/").concat(r,"/?").concat(a):"".concat(o,"/").concat(r),u=(new Date).toGMTString(),s=JSON.stringify(e),t.next=8,x(s,u,"POST",c);case 8:return l=t.sent,f=l?"".concat(h.env_key,":").concat(l):h.env_key,t.prev=10,t.next=13,fetch("".concat(h.api_url).concat(c),{method:"POST",body:s,headers:{"Content-Type":"application/json",Authorization:f,"x-amz-date":u}});case 13:if(!(p=t.sent).ok){t.next=17;break}return d=p.json(),t.abrupt("return",d);case 17:return t.abrupt("return",{error:!0,api_error:!0,status_code:p.status,message:p.statusText,error_obj:null});case 20:return t.prev=20,t.t0=t.catch(10),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 23:case"end":return t.stop()}}),t,this,[[10,20]])}))),function(t,e,r){return c.apply(this,arguments)})},{key:"data",get:function(){return this._preference_data},set:function(t){this._preference_data=t}},{key:"get_preferences",value:(a=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="full_preference",this._preference_args=e,n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels},t.next=6,this._get_request(r,n);case 6:return null!=(o=t.sent)&&o.error||(this.data=o),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"get_categories",value:(i=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="category",n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels,limit:null==e?void 0:e.limit,offset:null==e?void 0:e.offset},t.next=5,this._get_request(r,n);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"get_category",value:(o=X(H().mark((function t(){var e,r,n,o,i,a=arguments;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:"",r=a.length>1&&void 0!==a[1]?a[1]:{},e){t.next=4;break}return t.abrupt("return",{error:!0,message:"Category parameter is missing"});case 4:return n="category/".concat(e),o={tenant_id:null==r?void 0:r.tenant_id,show_opt_out_channels:null==r?void 0:r.show_opt_out_channels},t.next=8,this._get_request(n,o);case 8:return i=t.sent,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get_overall_channel_preferences",value:(n=X(H().mark((function t(){var e;return H().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this._get_request("channel_preference");case 3:return e=t.sent,t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"update_category_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||![et.OPT_IN,et.OPT_OUT].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Category parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var o,i=!1,a=null==n?void 0:n.show_opt_out_channels,c=K(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=K(s.subcategories);try{for(f.s();!(u=f.n()).done;){var h=u.value;if(h.category===e){if(t=h,!h.is_editable)return{error:!0,message:"Category preference is not editable"};if(h.preference!==r){h.preference=r,i=!0,l=!0;break}}}}catch(t){f.e(t)}finally{f.f()}if(l)break}}catch(t){c.e(t)}finally{c.f()}if(!t)return{error:!0,message:"Category is not found"};if(!i)return this.data;var p=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===et.OPT_IN?null:p};return this._debounced_update_category_preferences(e,e,d,t,{tenant_id:null==n?void 0:n.tenant_id,show_opt_out_channels:null==n?void 0:n.show_opt_out_channels}),this.data}},{key:"update_channel_preference_in_category",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!r||!o)return{error:!0,message:r?"Category parameter is missing":"Channel parameter is missing"};if(![et.OPT_IN,et.OPT_OUT].includes(n))return{error:!0,message:"Preference parameter is invalid"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var a,c=!1,u=K(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=K(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=K(p.channels);try{for(v.s();!(d=v.n()).done;){var y=d.value;if(y.channel===r){if(e=y,!y.is_editable)return{error:!0,message:"Channel preference is not editable"};if(y.preference!==n){y.preference=n,n===et.OPT_IN&&(p.preference=et.OPT_IN),c=!0,f=!0;break}}}}catch(t){v.e(t)}finally{v.f()}}if(f)break}}catch(t){h.e(t)}finally{h.f()}if(f)break}}catch(t){u.e(t)}finally{u.f()}if(!t)return{error:!0,message:"Category not found"};if(!e)return{error:!0,message:"Category's Channel not found"};if(!c)return this.data;var _=[];t.channels.forEach((function(t){t.preference===et.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===et.OPT_OUT&&n===et.OPT_IN?et.OPT_IN:t.preference,m={preference:g,opt_out_channels:_};return this._debounced_update_category_preferences(o,o,m,t,{tenant_id:null==i?void 0:i.tenant_id,show_opt_out_channels:null==i?void 0:i.show_opt_out_channels}),this.data}},{key:"update_overall_channel_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||![rt.ALL,rt.REQUIRED].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Channel parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var n,o=!1,i=r===rt.REQUIRED,a=K(this.data.channel_preferences);try{for(a.s();!(n=a.n()).done;){var c=n.value;if(c.channel===e&&(t=c,c.is_restricted!==i)){c.is_restricted=i,o=!0;break}}}catch(t){a.e(t)}finally{a.f()}return t?o?(this._debounced_update_channel_preferences(t.channel,{channel_preferences:[t]}),this.data):this.data:{error:!0,message:"Channel data not found"}}}],r&&Z(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const ot=nt;function it(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function at(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach((function(e){ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var st=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ut(this,"_allow_special_char_events",(function(t){return"$email"===t||"$whatsapp"===t||"$sms"===t||(null==t?void 0:t.$webpush)})),this.instance=e,this.preferences=new ot(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){J.batch_or_call(at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;J.api(o,at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t)).then((function(t){if(!t.ok)throw new Error("Error in Fetch")})).catch((function(){e._call_indentity(t)}))}},{key:"_convert_to_number",value:function(t){if(!J.is_empty(t))for(var e in t){var r=Number(t[e]);r?t[e]=r:delete t[e]}return t}},{key:"_validate_email_and_send",value:function(t,e){f.email.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Email ID")}},{key:"_validate_mobile_and_send",value:function(t,e){try{f.mobile.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}catch(t){console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}}},{key:"set",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set_once:r})}},{key:"increment",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=J.format_props({key:t,value:e}),n=this._convert_to_number(r);J.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=J.format_props({key:t,value:e,allow_special_tags:r});J.is_empty(n)||this._call_indentity({$append:n})}},{key:"remove",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._allow_special_char_events(t),o=J.format_props({key:t,value:e,allow_special_tags:n});J.is_empty(o)||(null!=r&&r.flush_immediately?this._call_flush_immediately({$remove:o}):this._call_indentity({$remove:o}))}},{key:"unset",value:function(t){var e;"string"==typeof t?J.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){J.has_special_char(String(t))||e.push(String(t))}))),J.is_empty(e)||this._call_indentity({$unset:e})}},{key:"add_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_email_and_send("$email",t)}},{key:"remove_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$email",t)}},{key:"add_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$sms",t)}},{key:"remove_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$sms",t)}},{key:"add_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$whatsapp",t)}},{key:"remove_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$whatsapp",t)}},{key:"add_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.append({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"})}},{key:"remove_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"},null,{flush_immediately:!0})}}],r&&ct(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=st;function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function ht(){ht=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==ft(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function pt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function yt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t,gt=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),yt(this,"_ask_notification_permission",dt(ht().mark((function t(){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Notification.requestPermission();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),yt(this,"_register_sw",(function(){return navigator.serviceWorker.register("/".concat(h.service_worker_file)).then((function(t){r._subscribe_push(t)})).catch((function(t){console.error("SuprSend: Unable to register service worker.",t)}))})),yt(this,"_get_subscription_without_wait",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.serviceWorker.getRegistration();case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.abrupt("return",e.pushManager.getSubscription().then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:case"end":return t.stop()}}),t)})))),yt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=dt(ht().mark((function t(e){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),yt(this,"_subscribe_push",function(){var t=dt(ht().mark((function t(e){var n,o;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._ask_notification_permission();case 2:if("granted"!==t.sent){t.next=18;break}return t.next=6,r._get_subscription();case 6:if(t.sent){t.next=18;break}if(h.vapid_key){t.next=11;break}return console.log("SuprSend: Provide vapid key while calling init"),t.abrupt("return");case 11:return n=J.urlB64ToUint8Array(h.vapid_key),t.next=14,e.pushManager.subscribe({applicationServerKey:n,userVisibleOnly:!0});case 14:o=t.sent,r.user.add_webpush(o),t.next=18;break;case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),yt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),yt(this,"is_subscribed",dt(ht().mark((function t(){var e;return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._get_subscription_without_wait();case 2:return e=t.sent,t.abrupt("return",!!e);case 4:case"end":return t.stop()}}),t)})))),this.instance=e,this.user=new lt(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-$t;e>=h.sw_delay?this._register_sw():(clearTimeout(_t),_t=setTimeout((function(){t._register_sw()}),h.sw_delay-e))}},{key:"update_subscription",value:function(){var t,e,r=this;null===(t=navigator)||void 0===t||null===(e=t.serviceWorker)||void 0===e||e.ready.then((function(t){return t.pushManager.getSubscription()})).then((function(t){t&&r.user.add_webpush(t)}))}},{key:"notification_permission",value:function(){return Notification.permission}}])&&vt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const mt=gt;function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function wt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function xt(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ot(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Tt(t,e)}function St(t){var e=Pt();return function(){var r,n=At(t);if(e){var o=At(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Et(this,r)}}function Et(t,e){if(e&&("object"===bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function jt(t){var e="function"==typeof Map?new Map:void 0;return jt=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Lt(t,arguments,At(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tt(n,t)},jt(t)}function Lt(t,e,r){return Lt=Pt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Tt(o,r.prototype),o},Lt.apply(null,arguments)}function Pt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}var Nt,$t,Ct=function(t){kt(r,t);var e=St(r);function r(t){var n;return Ot(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return xt(r)}(function(t){kt(r,t);var e=St(r);function r(t){var n;return Ot(this,r),(n=e.call(this,t)).name="SuprsendError",n}return xt(r)}(jt(Error)));function It(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map((function(t){t(r)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,r)}))}}}function Gt(t){return Gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gt(t)}function Mt(){Mt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==Gt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Ft(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var zt=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,o,u,s;return r=e,n=[{key:"init",value:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.env=r,o.signing_key=n;var i=J.get_cookie(t);Nt||(Nt={},this._set_custom_config(o)),i||(i=J.uuid(),J.set_cookie(t,i)),Nt.distinct_id=i,this.emitter=It(),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),this.web_push.update_subscription(),e._set_env_properties(),$t||(J.bulk_call_api(),this.track(c.app_launched)),$t=new Date}},{key:"_set_custom_config_property",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e)h[t]=e;else if(r)throw new Ct("Mandatory Key Missing: ".concat(t))}},{key:"_set_custom_config",value:function(t){this._set_custom_config_property("env_key",t.env,!0),this._set_custom_config_property("signing_key",t.signing_key,!0),this._set_custom_config_property("api_url",null==t?void 0:t.api_url),this._set_custom_config_property("vapid_key",null==t?void 0:t.vapid_key),this._set_custom_config_property("service_worker_file",null==t?void 0:t.sw_file_name)}},{key:"set_super_properties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=J.get_parsed_local_store_data(i),r=Ut(Ut({},e),t),n={};for(var o in r)J.has_special_char(o)||(n[o]=r[o]);J.set_local_storage_item(i,JSON.stringify(n)),Nt.env_properties=Ut(Ut({},Nt.env_properties),n)}},{key:"identify",value:function(e){Nt._user_identified||(J.batch_or_call({env:h.env_key,event:"$identify",$insert_id:J.uuid(),$time:J.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:Nt.distinct_id}}),J.set_cookie(t,e),Nt.distinct_id=e,Nt._user_identified=!0,this.web_push.update_subscription(),this.track(c.user_login))}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==t)if(J.is_internal_event(t)||!J.has_special_char(t)){var r=J.get_parsed_local_store_data(i),n=J.format_props({key:e}),o=Ut(Ut(Ut(Ut({},n),Nt.env_properties),r),{},{$current_url:window.location.href});J.batch_or_call({event:String(t),distinct_id:Nt.distinct_id,env:h.env_key,properties:o,$insert_id:J.uuid(),$time:J.epoch_milliseconds()})}else console.log("SuprSend: key cannot start with $ or ss_")}},{key:"purchase_made",value:function(t){this.track(c.purchase_made,t)}},{key:"reset",value:(u=Mt().mark((function r(){var n,o,a,u=arguments;return Mt().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null==(n=u.length>0&&void 0!==u[0]?u[0]:{unsubscribe_push:!0})||!n.unsubscribe_push){r.next=6;break}return r.next=4,this.web_push._get_subscription_without_wait();case 4:(o=r.sent)&&this.user.remove_webpush(o);case 6:this.track(c.user_logout),a=J.uuid(),J.set_cookie(t,a),Nt={distinct_id:a,_user_identified:!1},J.remove_local_storage_item(i),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),e._set_env_properties();case 14:case"end":return r.stop()}}),r,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=u.apply(t,e);function i(t){Ft(o,r,n,i,a,"next",t)}function a(t){Ft(o,r,n,i,a,"throw",t)}i(void 0)}))},function(){return s.apply(this,arguments)})}],o=[{key:"_set_env_properties",value:function(){var t=J.get_local_storage_item(a);t||(t=J.uuid(),J.set_local_storage_item(a,t)),Nt.env_properties={$os:J.os(),$browser:J.browser(),$browser_version:J.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&qt(r.prototype,n),o&&qt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Wt=new zt}();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/web-sdk",
3
- "version": "1.5.0-beta.1",
3
+ "version": "1.5.1",
4
4
  "description": "This is sdk used to integrate suprsend functionality in javascript applications",
5
5
  "main": "dist/cjs_bundle.js",
6
6
  "scripts": {