cap-hydra-web-sdk 1.7.0 → 1.10.5
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.
- package/README.md +246 -182
- package/dist/index.d.ts +393 -10
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +1 -10
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).WebSDK={})}(this,function(t){"use strict";var n="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},i="URLSearchParams"in n,r="Symbol"in n&&"iterator"in Symbol,e="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in n,s="ArrayBuffer"in n;if(s)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function h(t){var n={next:function(){var n=t.shift();return{done:void 0===n,value:n}}};return r&&(n[Symbol.iterator]=function(){return n}),n}function d(t){this.map={},t instanceof d?t.forEach(function(t,n){this.append(n,t)},this):Array.isArray(t)?t.forEach(function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(n){this.append(n,t[n])},this)}function v(t){if(!t.t)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function l(t){return new Promise(function(n,i){t.onload=function(){n(t.result)},t.onerror=function(){i(t.error)}})}function g(t){var n=new FileReader,i=l(n);return n.readAsArrayBuffer(t),i}function m(t){if(t.slice)return t.slice(0);var n=new Uint8Array(t.byteLength);return n.set(new Uint8Array(t)),n.buffer}function p(){return this.bodyUsed=!1,this.i=function(t){var n;this.bodyUsed=this.bodyUsed,this.o=t,t?"string"==typeof t?this.u=t:e&&Blob.prototype.isPrototypeOf(t)?this.h=t:o&&FormData.prototype.isPrototypeOf(t)?this.l=t:i&&URLSearchParams.prototype.isPrototypeOf(t)?this.u=t.toString():s&&e&&((n=t)&&DataView.prototype.isPrototypeOf(n))?(this.m=m(t.buffer),this.o=new Blob([this.m])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this.m=m(t):this.u=t=Object.prototype.toString.call(t):(this.t=!0,this.u=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this.h&&this.h.type?this.headers.set("content-type",this.h.type):i&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e&&(this.blob=function(){var t=v(this);if(t)return t;if(this.h)return Promise.resolve(this.h);if(this.m)return Promise.resolve(new Blob([this.m]));if(this.l)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this.u]))}),this.arrayBuffer=function(){if(this.m){var t=v(this);return t||(ArrayBuffer.isView(this.m)?Promise.resolve(this.m.buffer.slice(this.m.byteOffset,this.m.byteOffset+this.m.byteLength)):Promise.resolve(this.m))}if(e)return this.blob().then(g);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,n,i,r,e,o=v(this);if(o)return o;if(this.h)return t=this.h,n=new FileReader,i=l(n),r=/charset=([A-Za-z0-9_-]+)/.exec(t.type),e=r?r[1]:"utf-8",n.readAsText(t,e),i;if(this.m)return Promise.resolve(function(t){for(var n=new Uint8Array(t),i=new Array(n.length),r=0;r<n.length;r++)i[r]=String.fromCharCode(n[r]);return i.join("")}(this.m));if(this.l)throw new Error("could not read FormData body as text");return Promise.resolve(this.u)},o&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,n){t=c(t),n=f(n);var i=this.map[t];this.map[t]=i?i+", "+n:n},d.prototype.delete=function(t){delete this.map[c(t)]},d.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},d.prototype.set=function(t,n){this.map[c(t)]=f(n)},d.prototype.forEach=function(t,n){for(var i in this.map)this.map.hasOwnProperty(i)&&t.call(n,this.map[i],i,this)},d.prototype.keys=function(){var t=[];return this.forEach(function(n,i){t.push(i)}),h(t)},d.prototype.values=function(){var t=[];return this.forEach(function(n){t.push(n)}),h(t)},d.prototype.entries=function(){var t=[];return this.forEach(function(n,i){t.push([i,n])}),h(t)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var w=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function y(t,i){if(!(this instanceof y))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,e,o=(i=i||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,i.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t.o||(o=t.o,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=i.credentials||this.credentials||"same-origin",!i.headers&&this.headers||(this.headers=new d(i.headers)),this.method=(r=i.method||this.method||"GET",e=r.toUpperCase(),w.indexOf(e)>-1?e:r),this.mode=i.mode||this.mode||null,this.signal=i.signal||this.signal||function(){if("AbortController"in n)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this.i(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==i.cache&&"no-cache"!==i.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function b(t){var n=new FormData;return t.trim().split("&").forEach(function(t){if(t){var i=t.split("="),r=i.shift().replace(/\+/g," "),e=i.join("=").replace(/\+/g," ");n.append(decodeURIComponent(r),decodeURIComponent(e))}}),n}function E(t,n){if(!(this instanceof E))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(n||(n={}),this.type="default",this.status=void 0===n.status?200:n.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===n.statusText?"":""+n.statusText,this.headers=new d(n.headers),this.url=n.url||"",this.i(t)}y.prototype.clone=function(){return new y(this,{body:this.o})},p.call(y.prototype),p.call(E.prototype),E.prototype.clone=function(){return new E(this.o,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var _=[301,302,303,307,308];E.redirect=function(t,n){if(-1===_.indexOf(n))throw new RangeError("Invalid status code");return new E(null,{status:n,headers:{location:t}})};var I=n.DOMException;try{new I}catch(t){(I=function(t,n){this.message=t,this.name=n;var i=Error(t);this.stack=i.stack}).prototype=Object.create(Error.prototype),I.prototype.constructor=I}function T(t,i){return new Promise(function(r,o){var u=new y(t,i);if(u.signal&&u.signal.aborted)return o(new I("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}if(a.onload=function(){var t,n,i={statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",n=new d,t.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t}).forEach(function(t){var i=t.split(":"),r=i.shift().trim();if(r){var e=i.join(":").trim();try{n.append(r,e)}catch(t){console.warn("Response "+t.message)}}}),n)};0===u.url.indexOf("file://")&&(a.status<200||a.status>599)?i.status=200:i.status=a.status,i.url="responseURL"in a?a.responseURL:i.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;setTimeout(function(){r(new E(e,i))},0)},a.onerror=function(){setTimeout(function(){o(new TypeError("Network request failed"))},0)},a.ontimeout=function(){setTimeout(function(){o(new TypeError("Network request timed out"))},0)},a.onabort=function(){setTimeout(function(){o(new I("Aborted","AbortError"))},0)},a.open(u.method,function(t){try{return""===t&&n.location.href?n.location.href:t}catch(n){return t}}(u.url),!0),"include"===u.credentials?a.withCredentials=!0:"omit"===u.credentials&&(a.withCredentials=!1),"responseType"in a&&(e?a.responseType="blob":s&&(a.responseType="arraybuffer")),i&&"object"==typeof i.headers&&!(i.headers instanceof d||n.Headers&&i.headers instanceof n.Headers)){var v=[];Object.getOwnPropertyNames(i.headers).forEach(function(t){v.push(c(t)),a.setRequestHeader(t,f(i.headers[t]))}),u.headers.forEach(function(t,n){-1===v.indexOf(n)&&a.setRequestHeader(n,t)})}else u.headers.forEach(function(t,n){a.setRequestHeader(n,t)});u.signal&&(u.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&u.signal.removeEventListener("abort",h)}),a.send(void 0===u.o?null:u.o)})}T.polyfill=!0,n.fetch||(n.fetch=T,n.Headers=d,n.Request=y,n.Response=E);var S,A,O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N={};function k(){if(A)return S;A=1;var t=function(t){return t&&t.Math===Math&&t};return S=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof O&&O)||t("object"==typeof S&&S)||function(){return this}()||Function("return this")()}var D,C,x,R,M,U,P,L,F={};function G(){return C?D:(C=1,D=function(t){try{return!!t()}catch(t){return!0}})}function j(){if(R)return x;R=1;var t=G();return x=!t(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})}function V(){if(U)return M;U=1;var t=G();return M=!t(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})}function B(){if(L)return P;L=1;var t=V(),n=Function.prototype.call;return P=t?n.bind(n):function(){return n.apply(n,arguments)},P}var z,H,W,K,q,X,$,Y,J,Q,Z,tt,nt,it,rt,et,ot,st,ut,at,ct,ft,ht,dt,vt,lt,gt,mt,pt,wt,yt,bt,Et,_t,It,Tt,St,At,Ot,Nt,kt,Dt={};function Ct(){if(z)return Dt;z=1;var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,i=n&&!t.call({1:2},1);return Dt.f=i?function(t){var i=n(this,t);return!!i&&i.enumerable}:t,Dt}function xt(){return W?H:(W=1,H=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}})}function Rt(){if(q)return K;q=1;var t=V(),n=Function.prototype,i=n.call,r=t&&n.bind.bind(i,i);return K=t?r:function(t){return function(){return i.apply(t,arguments)}},K}function Mt(){if($)return X;$=1;var t=Rt(),n=t({}.toString),i=t("".slice);return X=function(t){return i(n(t),8,-1)}}function Ut(){if(J)return Y;J=1;var t=Rt(),n=G(),i=Mt(),r=Object,e=t("".split);return Y=n(function(){return!r("z").propertyIsEnumerable(0)})?function(t){return"String"===i(t)?e(t,""):r(t)}:r}function Pt(){return Z?Q:(Z=1,Q=function(t){return null==t})}function Lt(){if(nt)return tt;nt=1;var t=Pt(),n=TypeError;return tt=function(i){if(t(i))throw new n("Can't call method on "+i);return i}}function Ft(){if(rt)return it;rt=1;var t=Ut(),n=Lt();return it=function(i){return t(n(i))}}function Gt(){if(ot)return et;ot=1;var t="object"==typeof document&&document.all;return et=void 0===t&&void 0!==t?function(n){return"function"==typeof n||n===t}:function(t){return"function"==typeof t}}function jt(){if(ut)return st;ut=1;var t=Gt();return st=function(n){return"object"==typeof n?null!==n:t(n)}}function Vt(){if(ct)return at;ct=1;var t=k(),n=Gt();return at=function(i,r){return arguments.length<2?(e=t[i],n(e)?e:void 0):t[i]&&t[i][r];var e},at}function Bt(){if(ht)return ft;ht=1;var t=Rt();return ft=t({}.isPrototypeOf)}function zt(){if(vt)return dt;vt=1;var t=k().navigator,n=t&&t.userAgent;return dt=n?String(n):""}function Ht(){if(gt)return lt;gt=1;var t,n,i=k(),r=zt(),e=i.process,o=i.Deno,s=e&&e.versions||o&&o.version,u=s&&s.v8;return u&&(n=(t=u.split("."))[0]>0&&t[0]<4?1:+(t[0]+t[1])),!n&&r&&(!(t=r.match(/Edge\/(\d+)/))||t[1]>=74)&&(t=r.match(/Chrome\/(\d+)/))&&(n=+t[1]),lt=n}function Wt(){if(pt)return mt;pt=1;var t=Ht(),n=G(),i=k().String;return mt=!!Object.getOwnPropertySymbols&&!n(function(){var n=Symbol("symbol detection");return!i(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&t&&t<41})}function Kt(){if(yt)return wt;yt=1;var t=Wt();return wt=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function qt(){if(Et)return bt;Et=1;var t=Vt(),n=Gt(),i=Bt(),r=Kt(),e=Object;return bt=r?function(t){return"symbol"==typeof t}:function(r){var o=t("Symbol");return n(o)&&i(o.prototype,e(r))}}function Xt(){if(It)return _t;It=1;var t=String;return _t=function(n){try{return t(n)}catch(t){return"Object"}}}function $t(){if(St)return Tt;St=1;var t=Gt(),n=Xt(),i=TypeError;return Tt=function(r){if(t(r))return r;throw new i(n(r)+" is not a function")}}function Yt(){if(Ot)return At;Ot=1;var t=$t(),n=Pt();return At=function(i,r){var e=i[r];return n(e)?void 0:t(e)}}function Jt(){if(kt)return Nt;kt=1;var t=B(),n=Gt(),i=jt(),r=TypeError;return Nt=function(e,o){var s,u;if("string"===o&&n(s=e.toString)&&!i(u=t(s,e)))return u;if(n(s=e.valueOf)&&!i(u=t(s,e)))return u;if("string"!==o&&n(s=e.toString)&&!i(u=t(s,e)))return u;throw new r("Can't convert object to primitive value")}}var Qt,Zt,tn,nn,rn,en,on,sn,un,an,cn,fn,hn,dn,vn,ln,gn,mn,pn,wn,yn,bn,En,_n,In={exports:{}};function Tn(){return Zt?Qt:(Zt=1,Qt=!1)}function Sn(){if(nn)return tn;nn=1;var t=k(),n=Object.defineProperty;return tn=function(i,r){try{n(t,i,{value:r,configurable:!0,writable:!0})}catch(n){t[i]=r}return r}}function An(){if(rn)return In.exports;rn=1;var t=Tn(),n=k(),i=Sn(),r="__core-js_shared__",e=In.exports=n[r]||i(r,{});return(e.versions||(e.versions=[])).push({version:"3.50.0",mode:t?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"}),In.exports}function On(){if(on)return en;on=1;var t=An(),n=Object.create||Object;return en=function(i,r){return t[i]||(t[i]=r||n(null))}}function Nn(){if(un)return sn;un=1;var t=Lt(),n=Object;return sn=function(i){return n(t(i))}}function kn(){if(cn)return an;cn=1;var t=Rt(),n=Nn(),i=t({}.hasOwnProperty);return an=Object.hasOwn||function(t,r){return i(n(t),r)}}function Dn(){if(hn)return fn;hn=1;var t=Rt(),n=0,i=Math.random(),r=t(1.1.toString);return fn=function(t){return"Symbol("+(void 0===t?"":t)+")_"+r(++n+i,36)}}function Cn(){if(vn)return dn;vn=1;var t=k(),n=On(),i=kn(),r=Dn(),e=Wt(),o=Kt(),s=t.Symbol,u=n("wks"),a=o?s.for||s:s&&s.withoutSetter||r;return dn=function(t){return i(u,t)||(u[t]=e&&i(s,t)?s[t]:a("Symbol."+t)),u[t]}}function xn(){if(gn)return ln;gn=1;var t=B(),n=jt(),i=qt(),r=Yt(),e=Jt(),o=Cn(),s=TypeError,u=o("toPrimitive");return ln=function(o,a){if(!n(o)||i(o))return o;var c,f=r(o,u);if(f){if(void 0===a&&(a="default"),c=t(f,o,a),!n(c)||i(c))return c;throw new s("Can't convert object to primitive value")}return void 0===a&&(a="number"),e(o,a)}}function Rn(){if(pn)return mn;pn=1;var t=xn(),n=qt();return mn=function(i){var r=t(i,"string");return n(r)?r:r+""}}function Mn(){if(yn)return wn;yn=1;var t=k(),n=jt(),i=t.document,r=n(i)&&n(i.createElement);return wn=function(t){return r?i.createElement(t):{}}}function Un(){if(En)return bn;En=1;var t=j(),n=G(),i=Mn();return bn=!t&&!n(function(){return 7!==Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a})}function Pn(){if(_n)return F;_n=1;var t=j(),n=B(),i=Ct(),r=xt(),e=Ft(),o=Rn(),s=kn(),u=Un(),a=Object.getOwnPropertyDescriptor;return F.f=t?a:function(t,c){if(t=e(t),c=o(c),u)try{return a(t,c)}catch(t){}if(s(t,c))return r(!n(i.f,t,c),t[c])},F}var Ln,Fn,Gn,jn,Vn,Bn,zn,Hn={};function Wn(){if(Fn)return Ln;Fn=1;var t=j(),n=G();return Ln=t&&n(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})}function Kn(){if(jn)return Gn;jn=1;var t=jt(),n=String,i=TypeError;return Gn=function(r){if(t(r))return r;throw new i(n(r)+" is not an object")}}function qn(){if(Vn)return Hn;Vn=1;var t=j(),n=Un(),i=Wn(),r=Kn(),e=Rn(),o=TypeError,s=Object.defineProperty,u=Object.getOwnPropertyDescriptor,a="enumerable",c="configurable",f="writable";return Hn.f=t?i?function(t,n,i){if(r(t),n=e(n),r(i),"function"==typeof t&&"prototype"===n&&"value"in i&&f in i&&!i[f]){var o=u(t,n);o&&o[f]&&(t[n]=i.value,i={configurable:c in i?i[c]:o[c],enumerable:a in i?i[a]:o[a],writable:!1})}return s(t,n,i)}:s:function(t,i,u){if(r(t),i=e(i),r(u),n)try{return s(t,i,u)}catch(t){}if("get"in u||"set"in u)throw new o("Accessors not supported");return"value"in u&&(t[i]=u.value),t},Hn}function Xn(){if(zn)return Bn;zn=1;var t=j(),n=qn(),i=xt();return Bn=t?function(t,r,e){return n.f(t,r,i(1,e))}:function(t,n,i){return t[n]=i,t}}var $n,Yn,Jn,Qn,Zn,ti,ni,ii,ri,ei,oi,si,ui,ai,ci,fi={exports:{}};function hi(){if(Yn)return $n;Yn=1;var t=j(),n=kn(),i=Function.prototype,r=t&&Object.getOwnPropertyDescriptor,e=n(i,"name"),o=e&&"something"===function(){}.name,s=e&&(!t||t&&r(i,"name").configurable);return $n={EXISTS:e,PROPER:o,CONFIGURABLE:s}}function di(){if(Qn)return Jn;Qn=1;var t=Rt(),n=Gt(),i=An(),r=t(Function.toString);return n(i.inspectSource)||(i.inspectSource=function(t){return r(t)}),Jn=i.inspectSource}function vi(){if(ii)return ni;ii=1;var t=On(),n=Dn(),i=t("keys");return ni=function(t){return i[t]||(i[t]=n(t))}}function li(){return ei?ri:(ei=1,ri={})}function gi(){if(si)return oi;si=1;var t,n,i,r=function(){if(ti)return Zn;ti=1;var t=k(),n=Gt(),i=t.WeakMap;return Zn=n(i)&&/native code/.test(String(i))}(),e=k(),o=jt(),s=Xn(),u=kn(),a=An(),c=vi(),f=li(),h="Object already initialized",d=e.TypeError,v=e.WeakMap;if(r||a.state){var l=a.state||(a.state=new v);l.get=l.get,l.has=l.has,l.set=l.set,t=function(t,n){if(l.has(t))throw new d(h);return n.facade=t,l.set(t,n),n},n=function(t){return l.get(t)||{}},i=function(t){return l.has(t)}}else{var g=c("state");f[g]=!0,t=function(t,n){if(u(t,g))throw new d(h);return n.facade=t,s(t,g,n),n},n=function(t){return u(t,g)?t[g]:{}},i=function(t){return u(t,g)}}return oi={set:t,get:n,has:i,enforce:function(r){return i(r)?n(r):t(r,{})},getterFor:function(t){return function(i){var r;if(!o(i)||(r=n(i)).type!==t)throw new d("Incompatible receiver, "+t+" required");return r}}}}function mi(){if(ui)return fi.exports;ui=1;var t=Rt(),n=G(),i=Gt(),r=kn(),e=j(),o=hi().CONFIGURABLE,s=di(),u=gi(),a=u.enforce,c=u.get,f=String,h=Object.defineProperty,d=t("".slice),v=t("".replace),l=t([].join),g=e&&!n(function(){return 8!==h(function(){},"length",{value:8}).length}),m=String(String).split("String"),p=fi.exports=function(t,n,i){"Symbol("===d(f(n),0,7)&&(n="["+v(f(n),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(n="get "+n),i&&i.setter&&(n="set "+n),(!r(t,"name")||o&&t.name!==n)&&(e?h(t,"name",{value:n,configurable:!0}):t.name=n),g&&i&&r(i,"arity")&&t.length!==i.arity&&h(t,"length",{value:i.arity});try{i&&r(i,"constructor")&&i.constructor?e&&h(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var s=a(t);return r(s,"source")||(s.source=l(m,"string"==typeof n?n:"")),t};return Function.prototype.toString=p(function(){return i(this)&&c(this).source||s(this)},"toString"),fi.exports}function pi(){if(ci)return ai;ci=1;var t=Gt(),n=qn(),i=mi(),r=Sn();return ai=function(e,o,s,u){u||(u={});var a=u.enumerable,c=void 0!==u.name?u.name:o;if(t(s)&&i(s,c,u),u.global)a?e[o]=s:r(o,s);else{try{u.unsafe?e[o]&&(a=!0):delete e[o]}catch(t){}a?e[o]=s:n.f(e,o,{value:s,enumerable:!1,configurable:!u.nonConfigurable,writable:!u.nonWritable})}return e}}var wi,yi,bi,Ei,_i,Ii,Ti,Si,Ai,Oi,Ni,ki,Di,Ci,xi,Ri,Mi,Ui={};function Pi(){if(Ei)return bi;Ei=1;var t=function(){if(yi)return wi;yi=1;var t=Math.ceil,n=Math.floor;return wi=Math.trunc||function(i){var r=+i;return(r>0?n:t)(r)}}();return bi=function(n){var i=+n;return i!=i||0===i?0:t(i)}}function Li(){if(Ii)return _i;Ii=1;var t=Pi(),n=Math.max,i=Math.min;return _i=function(r,e){var o=t(r);return o<0?n(o+e,0):i(o,e)}}function Fi(){if(Si)return Ti;Si=1;var t=Pi(),n=Math.min;return Ti=function(i){var r=t(i);return r>0?n(r,9007199254740991):0}}function Gi(){if(Oi)return Ai;Oi=1;var t=Fi();return Ai=function(n){return t(n.length)}}function ji(){if(ki)return Ni;ki=1;var t=Ft(),n=Li(),i=Gi(),r=function(r){return function(e,o,s){var u=t(e),a=i(u);if(0===a)return!r&&-1;var c,f=n(s,a);if(r&&o!=o){for(;a>f;)if((c=u[f++])!=c)return!0}else for(;a>f;f++)if((r||f in u)&&u[f]===o)return r||f||0;return!r&&-1}};return Ni={includes:r(!0),indexOf:r(!1)}}function Vi(){if(Ci)return Di;Ci=1;var t=Rt(),n=kn(),i=Ft(),r=ji().indexOf,e=li(),o=t([].push);return Di=function(t,s){var u,a=i(t),c=0,f=[];for(u in a)!n(e,u)&&n(a,u)&&o(f,u);for(;s.length>c;)n(a,u=s[c++])&&(~r(f,u)||o(f,u));return f}}function Bi(){return Ri?xi:(Ri=1,xi=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function zi(){if(Mi)return Ui;Mi=1;var t=Vi(),n=Bi().concat("length","prototype");return Ui.f=Object.getOwnPropertyNames||function(i){return t(i,n)},Ui}var Hi,Wi,Ki,qi,Xi,$i,Yi,Ji,Qi,Zi,tr,nr,ir,rr,er,or,sr,ur,ar,cr,fr,hr,dr,vr,lr,gr,mr,pr,wr,yr,br={};function Er(){return Hi||(Hi=1,br.f=Object.getOwnPropertySymbols),br}function _r(){if(Ki)return Wi;Ki=1;var t=Vt(),n=Rt(),i=zi(),r=Er(),e=Kn(),o=n([].concat);return Wi=t("Reflect","ownKeys")||function(t){var n=i.f(e(t)),s=r.f;return s?o(n,s(t)):n}}function Ir(){if(Xi)return qi;Xi=1;var t=kn(),n=_r(),i=Pn(),r=qn();return qi=function(e,o,s){for(var u=n(o),a=r.f,c=i.f,f=0;f<u.length;f++){var h=u[f];t(e,h)||s&&t(s,h)||a(e,h,c(o,h))}}}function Tr(){if(Yi)return $i;Yi=1;var t=G(),n=Gt(),i=/#|\.prototype\./,r=function(i,r){var a=o[e(i)];return a===u||a!==s&&(n(r)?t(r):!!r)},e=r.normalize=function(t){return String(t).replace(i,".").toLowerCase()},o=r.data={},s=r.NATIVE="N",u=r.POLYFILL="P";return $i=r}function Sr(){if(Qi)return Ji;Qi=1;var t=k(),n=Pn().f,i=Xn(),r=pi(),e=Sn(),o=Ir(),s=Tr();return Ji=function(u,a){var c,f,h,d,v,l=u.target,g=u.global,m=u.stat;if(c=g?t:m?t[l]||e(l,{}):t[l]&&t[l].prototype)for(f in a){if(d=a[f],h=u.dontCallGetSet?(v=n(c,f))&&v.value:c[f],!s(g?f:l+(m?".":"#")+f,u.forced)&&void 0!==h){if(typeof d==typeof h)continue;o(d,h)}(u.sham||h&&h.sham)&&i(d,"sham",!0),r(c,f,d,u)}}}function Ar(){if(tr)return Zi;tr=1;var t=Mt();return Zi=Array.isArray||function(n){return"Array"===t(n)}}function Or(){if(ir)return nr;ir=1;var t=TypeError;return nr=function(n){if(n>9007199254740991)throw new t("Maximum allowed index exceeded");return n}}function Nr(){if(er)return rr;er=1;var t=j(),n=qn(),i=xt();return rr=function(r,e,o){t?n.f(r,e,i(0,o)):r[e]=o}}function kr(){if(sr)return or;sr=1;var t=j(),n=Ar(),i=TypeError,r=Object.getOwnPropertyDescriptor,e=t&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();return or=e?function(t,e){if(n(t)&&!r(t,"length").writable)throw new i("Cannot set read only .length");return t.length=e}:function(t,n){return t.length=n}}function Dr(){if(ar)return ur;ar=1;var t={};return t[Cn()("toStringTag")]="z",ur="[object z]"===String(t)}function Cr(){if(fr)return cr;fr=1;var t=Dr(),n=Gt(),i=Mt(),r=Cn()("toStringTag"),e=Object,o="Arguments"===i(function(){return arguments}());return cr=t?i:function(t){var s,u,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(u=function(t,n){try{return t[n]}catch(t){}}(s=e(t),r))?u:o?i(s):"Object"===(a=i(s))&&n(s.callee)?"Arguments":a}}function xr(){if(dr)return hr;dr=1;var t=Rt(),n=G(),i=Gt(),r=Cr(),e=Vt(),o=di(),s=function(){},u=e("Reflect","construct"),a=/^\s*(?:class|function)\b/,c=t(a.exec),f=!a.test(s),h=function(t){if(!i(t))return!1;try{return u(s,[],t),!0}catch(t){return!1}},d=function(t){if(!i(t))return!1;switch(r(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return f||!!c(a,o(t))}catch(t){return!0}};return d.sham=!0,hr=!u||n(function(){var t;return h(h.call)||!h(Object)||!h(function(){t=!0})||t})?d:h}function Rr(){if(lr)return vr;lr=1;var t=Ar(),n=xr(),i=jt(),r=Cn()("species"),e=Array;return vr=function(o){var s;return t(o)&&(s=o.constructor,(n(s)&&(s===e||t(s.prototype))||i(s)&&null===(s=s[r]))&&(s=void 0)),void 0===s?e:s}}function Mr(){if(mr)return gr;mr=1;var t=Rr();return gr=function(n,i){return new(t(n))(0===i?0:i)}}function Ur(){if(wr)return pr;wr=1;var t=G(),n=Cn(),i=Ht(),r=n("species");return pr=function(n){return i>=51||!t(function(){var t=[];return(t.constructor={})[r]=function(){return{foo:1}},1!==t[n](Boolean).foo})}}!function(){if(yr)return N;yr=1;var t=Sr(),n=G(),i=Ar(),r=jt(),e=Nn(),o=Gi(),s=Or(),u=Nr(),a=kr(),c=Mr(),f=Ur(),h=Cn(),d=Ht(),v=h("isConcatSpreadable"),l=d>=51||!n(function(){var t=[];return t[v]=!1,t.concat()[0]!==t}),g=function(t){if(!r(t))return!1;var n=t[v];return void 0!==n?!!n:i(t)};t({target:"Array",proto:!0,arity:1,forced:!l||!f("concat")},{concat:function(t){var n,i,r,f,h,d=e(this),v=c(d,0),l=0;for(n=-1,r=arguments.length;n<r;n++)if(g(h=-1===n?d:arguments[n]))for(f=o(h),s(l+f),i=0;i<f;i++,l++)i in h&&u(v,l,h[i]);else s(l+1),u(v,l++,h);return a(v,l),v}})}();var Pr,Lr,Fr,Gr,jr,Vr,Br,zr={};function Hr(){if(Lr)return Pr;Lr=1;var t=Mt(),n=Rt();return Pr=function(i){if("Function"===t(i))return n(i)}}function Wr(){if(Gr)return Fr;Gr=1;var t=Hr(),n=$t(),i=V(),r=t(t.bind);return Fr=function(t,e){return n(t),void 0===e?t:i?r(t,e):function(){return t.apply(e,arguments)}},Fr}function Kr(){if(Vr)return jr;Vr=1;var t=Wr(),n=Ut(),i=Nn(),r=Gi(),e=Mr(),o=Nr(),s=function(s){var u=1===s,a=2===s,c=3===s,f=4===s,h=6===s,d=7===s,v=5===s||h;return function(l,g,m){for(var p,w,y=i(l),b=n(y),E=r(b),_=t(g,m),I=0,T=0,S=u?e(l,E):a||d?e(l,0):void 0;E>I;I++)if((v||I in b)&&(w=_(p=b[I],I,y),s))if(u)o(S,I,w);else if(w)switch(s){case 3:return!0;case 5:return p;case 6:return I;case 2:o(S,T++,p)}else switch(s){case 4:return!1;case 7:o(S,T++,p)}return h?-1:c||f?f:S}};return jr={forEach:s(0),map:s(1),filter:s(2),some:s(3),every:s(4),find:s(5),findIndex:s(6),filterReject:s(7)}}!function(){if(Br)return zr;Br=1;var t=Sr(),n=Kr().filter;t({target:"Array",proto:!0,forced:!Ur()("filter")},{filter:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}})}();var qr,Xr,$r,Yr,Jr,Qr,Zr,te,ne,ie,re={},ee={};function oe(){if(Xr)return qr;Xr=1;var t=Vi(),n=Bi();return qr=Object.keys||function(i){return t(i,n)}}function se(){if(Jr)return Yr;Jr=1;var t=Vt();return Yr=t("document","documentElement")}function ue(){if(Zr)return Qr;Zr=1;var t,n=Kn(),i=function(){if($r)return ee;$r=1;var t=j(),n=Wn(),i=qn(),r=Kn(),e=Ft(),o=oe();return ee.f=t&&!n?Object.defineProperties:function(t,n){r(t);for(var s,u=e(n),a=o(n),c=a.length,f=0;c>f;)i.f(t,s=a[f++],u[s]);return t},ee}(),r=Bi(),e=li(),o=se(),s=Mn(),u=vi(),a="prototype",c="script",f=u("IE_PROTO"),h=function(){},d=function(t){return"<"+c+">"+t+"</"+c+">"},v=function(t){t.write(d("")),t.close();var n=t.parentWindow.Object;return t=null,n},l=function(){try{t=new ActiveXObject("htmlfile")}catch(t){}var n,i,e;l="undefined"!=typeof document?document.domain&&t?v(t):(i=s("iframe"),e="java"+c+":",i.style.display="none",o.appendChild(i),i.src=String(e),(n=i.contentWindow.document).open(),n.write(d("document.F=Object")),n.close(),n.F):v(t);for(var u=r.length;u--;)delete l[a][r[u]];return l()};return e[f]=!0,Qr=Object.create||function(t,r){var e;return null!==t?(h[a]=n(t),e=new h,h[a]=null,e[f]=t):e=l(),void 0===r?e:i.f(e,r)}}function ae(){if(ne)return te;ne=1;var t=Cn(),n=ue(),i=qn().f,r=t("unscopables"),e=Array.prototype;return void 0===e[r]&&i(e,r,{configurable:!0,value:n(null)}),te=function(t){e[r][t]=!0}}!function(){if(ie)return re;ie=1;var t=Sr(),n=ji().includes,i=G(),r=ae(),e=i(function(){return!Array(1).includes()}),o=i(function(){return[,1].includes(void 0,1)});t({target:"Array",proto:!0,forced:e||o},{includes:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),r("includes")}();var ce,fe,he,de={};function ve(){if(fe)return ce;fe=1;var t=G();return ce=function(n,i){var r=[][n];return!!r&&t(function(){r.call(null,i||function(){return 1},1)})}}!function(){if(he)return de;he=1;var t=Sr(),n=Rt(),i=Ut(),r=Ft(),e=ve(),o=n([].join);t({target:"Array",proto:!0,forced:i!==Object||!e("join",",")},{join:function(t){return o(r(this),void 0===t?",":t)}})}();var le,ge,me,pe={};function we(){if(ge)return le;ge=1;var t=j(),n=Rt(),i=B(),r=G(),e=oe(),o=Er(),s=Ct(),u=Nn(),a=Ut(),c=Object.assign,f=Object.defineProperty,h=n([].concat);return le=!c||r(function(){if(t&&1!==c({b:1},c(f({},"a",{enumerable:!0,get:function(){f(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var n={},i={},r=Symbol("assign detection"),o="abcdefghijklmnopqrst";return n[r]=7,o.split("").forEach(function(t){i[t]=t}),7!==c({},n)[r]||e(c({},i)).join("")!==o})?function(n,r){for(var c=u(n),f=arguments.length,d=1,v=o.f,l=s.f;f>d;)for(var g,m=a(arguments[d++]),p=v?h(e(m),v(m)):e(m),w=p.length,y=0;w>y;)g=p[y++],t&&!i(l,m,g)||(c[g]=m[g]);return c}:c,le}!function(){if(me)return pe;me=1;var t=Sr(),n=we();t({target:"Object",stat:!0,arity:2,forced:Object.assign!==n},{assign:n})}();var ye,be={};!function(){if(ye)return be;ye=1;var t=Sr(),n=Nn(),i=oe();t({target:"Object",stat:!0,forced:G()(function(){i(1)})},{keys:function(t){return i(n(t))}})}();var Ee,_e,Ie,Te={};!function(){if(Ie)return Te;Ie=1;var t=Dr(),n=pi(),i=function(){if(_e)return Ee;_e=1;var t=Dr(),n=Cr();return Ee=t?{}.toString:function(){return"[object "+n(this)+"]"}}();t||n(Object.prototype,"toString",i,{unsafe:!0})}();var Se,Ae,Oe,Ne,ke,De,Ce,xe,Re,Me,Ue,Pe,Le,Fe,Ge,je,Ve,Be,ze,He,We,Ke,qe,Xe,$e,Ye,Je,Qe,Ze,to,no,io,ro,eo,oo,so,uo,ao,co,fo,ho,vo,lo,go,mo,po,wo,yo,bo,Eo,_o,Io,To,So,Ao={};function Oo(){if(Ae)return Se;Ae=1;var t=k(),n=zt(),i=Mt(),r=function(t){return n.slice(0,t.length)===t};return Se=r("Bun/")?"BUN":r("Cloudflare-Workers")?"CLOUDFLARE":r("Deno/")?"DENO":r("Node.js/")?"NODE":t.Bun&&"string"==typeof Bun.version?"BUN":t.Deno&&"object"==typeof Deno.version?"DENO":"process"===i(t.process)?"NODE":t.window&&t.document?"BROWSER":"REST"}function No(){if(Ne)return Oe;Ne=1;var t=Oo();return Oe="NODE"===t}function ko(){if(De)return ke;De=1;var t=k();return ke=t}function Do(){if(Me)return Re;Me=1;var t=jt();return Re=function(n){return t(n)||null===n}}function Co(){if(Pe)return Ue;Pe=1;var t=Do(),n=String,i=TypeError;return Ue=function(r){if(t(r))return r;throw new i("Can't set "+n(r)+" as a prototype")}}function xo(){if(Fe)return Le;Fe=1;var t=function(){if(xe)return Ce;xe=1;var t=Rt(),n=$t();return Ce=function(i,r,e){try{return t(n(Object.getOwnPropertyDescriptor(i,r)[e]))}catch(t){}}}(),n=jt(),i=Lt(),r=Co();return Le=Object.setPrototypeOf||("__proto__"in{}?function(){var e,o=!1,s={};try{(e=t(Object.prototype,"__proto__","set"))(s,[]),o=s instanceof Array}catch(t){}return function(t,s){return i(t),r(s),n(t)?(o?e(t,s):t.__proto__=s,t):t}}():void 0)}function Ro(){if(je)return Ge;je=1;var t=qn().f,n=kn(),i=Cn()("toStringTag");return Ge=function(r,e,o){r&&!o&&(r=r.prototype),r&&!n(r,i)&&t(r,i,{configurable:!0,value:e})}}function Mo(){if(Be)return Ve;Be=1;var t=mi(),n=qn();return Ve=function(i,r,e){return e.get&&t(e.get,r,{getter:!0}),e.set&&t(e.set,r,{setter:!0}),n.f(i,r,e)}}function Uo(){if(He)return ze;He=1;var t=Vt(),n=Mo(),i=Cn(),r=j(),e=i("species");return ze=function(i){var o=t(i);r&&o&&!o[e]&&n(o,e,{configurable:!0,get:function(){return this}})}}function Po(){if(Ke)return We;Ke=1;var t=Bt(),n=TypeError;return We=function(i,r){if(t(r,i))return i;throw new n("Incorrect invocation")}}function Lo(){if(Xe)return qe;Xe=1;var t=xr(),n=Xt(),i=TypeError;return qe=function(r){if(t(r))return r;throw new i(n(r)+" is not a constructor")}}function Fo(){if(Ye)return $e;Ye=1;var t=Kn(),n=Lo(),i=Pt(),r=Cn()("species");return $e=function(e,o){var s,u=t(e).constructor;return void 0===u||i(s=t(u)[r])?o:n(s)}}function Go(){if(Qe)return Je;Qe=1;var t=V(),n=Function.prototype,i=n.apply,r=n.call;return Je="object"==typeof Reflect&&Reflect.apply||(t?r.bind(i):function(){return r.apply(i,arguments)}),Je}function jo(){if(to)return Ze;to=1;var t=Rt();return Ze=t([].slice)}function Vo(){if(io)return no;io=1;var t=TypeError;return no=function(n,i){if(n<i)throw new t("Not enough arguments");return n}}function Bo(){if(eo)return ro;eo=1;var t=zt();return ro=/ipad|iphone|ipod/i.test(t)&&/applewebkit/i.test(t)}function zo(){if(so)return oo;so=1;var t,n,i,r,e=k(),o=Go(),s=Wr(),u=Gt(),a=kn(),c=G(),f=se(),h=jo(),d=Mn(),v=Vo(),l=Bo(),g=No(),m=e.setImmediate,p=e.clearImmediate,w=e.process,y=e.Dispatch,b=e.Function,E=e.MessageChannel,_=e.String,I=0,T={},S="onreadystatechange";c(function(){t=e.location});var A=function(t){if(a(T,t)){var n=T[t];delete T[t],n()}},O=function(t){return function(){A(t)}},N=function(t){A(t.data)},D=function(n){e.postMessage(_(n),t.protocol+"//"+t.host)};return m&&p||(m=function(t){v(arguments.length,1);var i=u(t)?t:b(t),r=h(arguments,1);return T[++I]=function(){o(i,void 0,r)},n(I),I},p=function(t){delete T[t]},g?n=function(t){w.nextTick(O(t))}:y&&y.now?n=function(t){y.now(O(t))}:E&&!l?(r=(i=new E).port2,i.port1.onmessage=N,n=s(r.postMessage,r)):e.addEventListener&&u(e.postMessage)&&!e.importScripts&&t&&"file:"!==t.protocol&&!c(D)?(n=D,e.addEventListener("message",N,!1)):n=S in d("script")?function(t){f.appendChild(d("script"))[S]=function(){f.removeChild(this),A(t)}}:function(t){setTimeout(O(t),0)}),oo={set:m,clear:p}}function Ho(){if(ao)return uo;ao=1;var t=k(),n=j(),i=Object.getOwnPropertyDescriptor;return uo=function(r){if(!n)return t[r];var e=i(t,r);return e&&e.value}}function Wo(){if(fo)return co;fo=1;var t=function(){this.head=null,this.tail=null};return t.prototype={add:function(t){var n={item:t,next:null},i=this.tail;i?i.next=n:this.head=n,this.tail=n},get:function(){var t=this.head;if(t)return null===(this.head=t.next)&&(this.tail=null),t.item}},co=t}function Ko(){if(po)return mo;po=1;var t,n,i,r,e,o=k(),s=Ho(),u=Wr(),a=zo().set,c=Wo(),f=Bo(),h=function(){if(vo)return ho;vo=1;var t=zt();return ho=/ipad|iphone|ipod/i.test(t)&&"undefined"!=typeof Pebble}(),d=function(){if(go)return lo;go=1;var t=zt();return lo=/web0s(?!.*chrome)/i.test(t)}(),v=No(),l=o.MutationObserver||o.WebKitMutationObserver,g=o.document,m=o.process,p=o.Promise,w=s("queueMicrotask");if(!w){var y=new c,b=function(){var n,i;for(v&&(n=m.domain)&&n.exit();i=y.get();)try{i()}catch(n){throw y.head&&t(),n}n&&n.enter()};f||v||d||!l||!g?!h&&p&&p.resolve?((r=p.resolve(void 0)).constructor=p,e=u(r.then,r),t=function(){e(b)}):v?t=function(){m.nextTick(b)}:(a=u(a,o),t=function(){a(b)}):(n=!0,i=g.createTextNode(""),new l(b).observe(i,{characterData:!0}),t=function(){i.data=n=!n}),w=function(n){y.head||t(),y.add(n)}}return mo=w}function qo(){return yo||(yo=1,wo=function(t,n){try{1===arguments.length?console.error(t):console.error(t,n)}catch(t){}}),wo}function Xo(){return Eo?bo:(Eo=1,bo=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}})}function $o(){if(Io)return _o;Io=1;var t=k();return _o=t.Promise}function Yo(){if(So)return To;So=1;var t=k(),n=$o(),i=Gt(),r=Tr(),e=di(),o=Cn(),s=Oo(),u=Tn(),a=Ht(),c=n&&n.prototype,f=o("species"),h=!1,d=i(t.PromiseRejectionEvent),v=r("Promise",function(){var t=e(n),i=t!==String(n);if(!i&&66===a)return!0;if(u&&(!c.catch||!c.finally))return!0;if(!a||a<51||!/native code/.test(t)){var r=new n(function(t){t(1)}),o=function(t){t(function(){},function(){})};if((r.constructor={})[f]=o,!(h=r.then(function(){})instanceof o))return!0}return!(i||"BROWSER"!==s&&"DENO"!==s||d)});return To={CONSTRUCTOR:v,REJECTION_EVENT:d,SUBCLASSING:h}}var Jo,Qo,Zo={};function ts(){if(Jo)return Zo;Jo=1;var t=$t(),n=TypeError,i=function(i){var r,e;this.promise=new i(function(t,i){if(void 0!==r||void 0!==e)throw new n("Bad Promise constructor");r=t,e=i}),this.resolve=t(r),this.reject=t(e)};return Zo.f=function(t){return new i(t)},Zo}var ns,is,rs,es,os,ss,us,as,cs,fs,hs,ds,vs,ls,gs,ms,ps,ws={};function ys(){return is?ns:(is=1,ns=Object.create?Object.create(null):{})}function bs(){if(es)return rs;es=1;var t=Cn(),n=ys(),i=t("iterator"),r=Array.prototype;return rs=function(t){return void 0!==t&&(n.Array===t||r[i]===t)}}function Es(){if(ss)return os;ss=1;var t=Mt(),n=Pt(),i=Yt(),r=Cn()("iterator"),e=Array.prototype;return os=function(o){if(!n(o))return i(o,r)||i(o,"@@iterator")||("Arguments"===t(o)?e[r]:void 0)}}function _s(){if(as)return us;as=1;var t=B(),n=Gt(),i=Kn(),r=Xt(),e=Es(),o=TypeError;return us=function(s,u){var a=arguments.length<2?e(s):u;if(n(a))return i(t(a,s));throw new o(r(s)+" is not iterable")},us}function Is(){if(fs)return cs;fs=1;var t=B(),n=Kn(),i=Yt();return cs=function(r,e,o){var s,u;n(r);try{if(!(s=i(r,"return"))){if("throw"===e)throw o;return o}s=t(s,r)}catch(t){u=!0,s=t}if("throw"===e)throw o;if(u)throw s;return n(s),o}}function Ts(){if(ds)return hs;ds=1;var t=Wr(),n=B(),i=Kn(),r=Xt(),e=bs(),o=Gi(),s=Bt(),u=_s(),a=Es(),c=Is(),f=TypeError,h=function(t,n){this.stopped=t,this.result=n},d=h.prototype;return hs=function(v,l,g){var m,p,w,y,b,E,_,I=g&&g.that,T=!(!g||!g.AS_ENTRIES),S=!(!g||!g.IS_RECORD),A=!(!g||!g.IS_ITERATOR),O=!(!g||!g.INTERRUPTED),N=t(l,I),k=function(t){var n=m;return m=void 0,n&&c(n,"normal"),new h(!0,t)},D=function(t){return T?(i(t),O?N(t[0],t[1],k):N(t[0],t[1])):O?N(t,k):N(t)};if(S)m=v.iterator;else if(A)m=v;else{if(!(p=a(v)))throw new f(r(v)+" is not iterable");if(e(p)){for(w=0,y=o(v);y>w;w++)if((b=D(v[w]))&&s(d,b))return b;return new h(!1)}m=u(v,p)}for(E=S?v.next:m.next;!(_=n(E,m)).done;){var C=_.value;try{b=D(C)}catch(t){if(!m)throw t;c(m,"throw",t)}if("object"==typeof b&&b&&s(d,b))return b}return new h(!1)}}function Ss(){if(ls)return vs;ls=1;var t=Cn()("iterator"),n=!1;try{var i=0,r={next:function(){return{done:!!i++}},return:function(){n=!0}};r[t]=function(){return this},Array.from(r,function(){throw 2})}catch(t){}return vs=function(i,r){try{if(!r&&!n)return!1}catch(t){return!1}var e=!1;try{var o={};o[t]=function(){return{next:function(){return{done:e=!0}}}},i(o)}catch(t){}return e}}function As(){if(ms)return gs;ms=1;var t=$o(),n=Ss(),i=Yo().CONSTRUCTOR;return gs=i||!n(function(n){t.all(n).then(void 0,function(){})})}var Os,Ns={};var ks,Ds={};var Cs,xs={};var Rs,Ms,Us,Ps,Ls={};function Fs(){if(Ms)return Rs;Ms=1;var t=Kn(),n=jt(),i=ts();return Rs=function(r,e){if(t(r),n(e)&&e.constructor===r)return e;var o=i.f(r);return(0,o.resolve)(e),o.promise}}Ps||(Ps=1,function(){if(Qo)return Ao;Qo=1;var t,n,i,r,e=Sr(),o=Tn(),s=No(),u=k(),a=ko(),c=B(),f=pi(),h=xo(),d=Ro(),v=Uo(),l=$t(),g=Gt(),m=jt(),p=Po(),w=Fo(),y=zo().set,b=Ko(),E=qo(),_=Xo(),I=Wo(),T=gi(),S=$o(),A=Yo(),O=ts(),N="Promise",D=A.CONSTRUCTOR,C=A.REJECTION_EVENT,x=A.SUBCLASSING,R=T.getterFor(N),M=T.set,U=S&&S.prototype,P=S,L=U,F=u.TypeError,G=u.document,j=u.process,V=O.f,z=V,H=!!(G&&G.createEvent&&u.dispatchEvent),W="unhandledrejection",K=function(t){var n;return!(!m(t)||!g(n=t.then))&&n},q=function(t,n){var i,r,e,o=n.value,s=1===n.state,u=s?t.ok:t.fail,a=t.resolve,f=t.reject,h=t.domain;try{u?(s||(2===n.rejection&&Q(n),n.rejection=1),!0===u?i=o:(h&&h.enter(),i=u(o),h&&(h.exit(),e=!0)),i===t.promise?f(new F("Promise-chain cycle")):(r=K(i))?c(r,i,a,f):a(i)):f(o)}catch(t){h&&!e&&h.exit(),f(t)}},X=function(t,n){t.notified||(t.notified=!0,b(function(){for(var i,r=t.reactions;i=r.get();)q(i,t);t.notified=!1,n&&!t.rejection&&Y(t)}))},$=function(t,n,i){var r,e;H?((r=G.createEvent("Event")).promise=n,r.reason=i,r.initEvent(t,!1,!0),u.dispatchEvent(r)):r={promise:n,reason:i},!C&&(e=u["on"+t])?e(r):t===W&&E("Unhandled promise rejection",i)},Y=function(t){c(y,u,function(){var n,i=t.facade,r=t.value;if(J(t)&&(n=_(function(){s?j.emit("unhandledRejection",r,i):$(W,i,r)}),t.rejection=s||J(t)?2:1,n.error))throw n.value})},J=function(t){return 1!==t.rejection&&!t.parent},Q=function(t){c(y,u,function(){var n=t.facade;s?j.emit("rejectionHandled",n):$("rejectionhandled",n,t.value)})},Z=function(t,n,i){return function(r){t(n,r,i)}},tt=function(t,n,i){t.done||(t.done=!0,i&&(t=i),t.value=n,t.state=2,X(t,!0))},nt=function(t,n,i){if(!t.done){t.done=!0,i&&(t=i);try{if(t.facade===n)throw new F("Promise can't be resolved itself");var r=K(n);r?b(function(){var i={done:!1};try{c(r,n,Z(nt,i,t),Z(tt,i,t))}catch(n){tt(i,n,t)}}):(t.value=n,t.state=1,X(t,!1))}catch(n){tt({done:!1},n,t)}}};if(D&&(L=(P=function(n){p(this,L),l(n),c(t,this);var i=R(this);try{n(Z(nt,i),Z(tt,i))}catch(t){tt(i,t)}}).prototype,(t=function(t){M(this,{type:N,done:!1,notified:!1,parent:!1,reactions:new I,rejection:!1,state:0,value:null})}).prototype=f(L,"then",function(t,n){var i=R(this),r=V(w(this,P));return i.parent=!0,r.ok=!g(t)||t,r.fail=g(n)&&n,r.domain=s?j.domain:void 0,0===i.state?i.reactions.add(r):b(function(){q(r,i)}),r.promise}),n=function(){var n=new t,i=R(n);this.promise=n,this.resolve=Z(nt,i),this.reject=Z(tt,i)},O.f=V=function(t){return t===P||t===i?new n(t):z(t)},!o&&g(S)&&U!==Object.prototype)){r=U.then,x||f(U,"then",function(t,n){var i=this;return new P(function(t,n){c(r,i,t,n)}).then(t,n)},{unsafe:!0});try{delete U.constructor}catch(t){}h&&h(U,L)}e({global:!0,constructor:!0,wrap:!0,forced:D},{Promise:P}),i=a.Promise,d(P,N,!1,!0),v(N)}(),function(){if(ps)return ws;ps=1;var t=Sr(),n=B(),i=$t(),r=ts(),e=Xo(),o=Ts();t({target:"Promise",stat:!0,forced:As()},{all:function(t){var s=this,u=r.f(s),a=u.resolve,c=u.reject,f=e(function(){var r=i(s.resolve),e=[],u=0,f=1;o(t,function(t){var i=u++,o=!1;f++,n(r,s,t).then(function(t){o||(o=!0,e[i]=t,--f||a(e))},c)}),--f||a(e)});return f.error&&c(f.value),u.promise}})}(),function(){if(Os)return Ns;Os=1;var t=Sr(),n=Tn(),i=Yo().CONSTRUCTOR,r=$o(),e=Vt(),o=Gt(),s=pi(),u=r&&r.prototype;if(t({target:"Promise",proto:!0,forced:i,real:!0},{catch:function(t){return this.then(void 0,t)}}),!n&&o(r)){var a=e("Promise").prototype.catch;u.catch!==a&&s(u,"catch",a,{unsafe:!0})}}(),function(){if(ks)return Ds;ks=1;var t=Sr(),n=B(),i=$t(),r=ts(),e=Xo(),o=Ts();t({target:"Promise",stat:!0,forced:As()},{race:function(t){var s=this,u=r.f(s),a=u.reject,c=e(function(){var r=i(s.resolve);o(t,function(t){n(r,s,t).then(u.resolve,a)})});return c.error&&a(c.value),u.promise}})}(),function(){if(Cs)return xs;Cs=1;var t=Sr(),n=ts();t({target:"Promise",stat:!0,forced:Yo().CONSTRUCTOR},{reject:function(t){var i=n.f(this);return(0,i.reject)(t),i.promise}})}(),function(){if(Us)return Ls;Us=1;var t=Sr(),n=Vt(),i=Tn(),r=$o(),e=Yo().CONSTRUCTOR,o=Fs(),s=n("Promise"),u=i&&!e;t({target:"Promise",stat:!0,forced:i||e},{resolve:function(t){return o(u&&this===s?r:this,t)}})}());var Gs,js,Vs,Bs,zs,Hs,Ws,Ks={};function qs(){return js?Gs:(js=1,Gs={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0})}function Xs(){if(Bs)return Vs;Bs=1;var t=Mn()("span").classList,n=t&&t.constructor&&t.constructor.prototype;return Vs=n===Object.prototype?void 0:n}!function(){if(Ws)return Ks;Ws=1;var t=k(),n=qs(),i=Xs(),r=function(){if(Hs)return zs;Hs=1;var t=Kr().forEach,n=ve()("forEach");return zs=n?[].forEach:function(n){return t(this,n,arguments.length>1?arguments[1]:void 0)},zs}(),e=Xn(),o=function(t){if(t&&t.forEach!==r)try{e(t,"forEach",r)}catch(n){t.forEach=r}};for(var s in n)n[s]&&o(t[s]&&t[s].prototype);o(i)}();var $s=function(t,n){return $s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},$s(t,n)};function Ys(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}$s(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var Js=function(){return Js=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++)for(var e in n=arguments[i])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t},Js.apply(this,arguments)};function Qs(t,n,i,r){return new(i||(i=Promise))(function(e,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}a((r=r.apply(t,n||[])).next())})}function Zs(t,n){var i,r,e,o={label:0,sent:function(){if(1&e[0])throw e[1];return e[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=u(0),s.throw=u(1),s.return=u(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(u){return function(a){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(i=1,r&&(e=2&u[0]?r.return:u[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,u[1])).done)return e;switch(r=0,e&&(u=[2&u[0],e.value]),u[0]){case 0:case 1:e=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(e=o.trys,(e=e.length>0&&e[e.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!e||u[1]>e[0]&&u[1]<e[3])){o.label=u[1];break}if(6===u[0]&&o.label<e[1]){o.label=e[1],e=u;break}if(e&&o.label<e[2]){o.label=e[2],o.ops.push(u);break}e[2]&&o.ops.pop(),o.trys.pop();continue}u=n.call(t,o)}catch(t){u=[6,t],r=0}finally{i=e=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function tu(t){var n="function"==typeof Symbol&&Symbol.iterator,i=n&&t[n],r=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function nu(t,n){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,e,o=i.call(t),s=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){e={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return s}function iu(t,n,i){if(i||2===arguments.length)for(var r,e=0,o=n.length;e<o;e++)!r&&e in n||(r||(r=Array.prototype.slice.call(n,0,e)),r[e]=n[e]);return t.concat(r||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var ru="/api/v1/web/events",eu="/api/v1/web/userEvents",ou="/sdk/v2/config",su="/sdk/v2/visitors",uu="/sdk/v2/visitors",au="/sdk/v2/visitors/merge",cu="/api/v1/websdk/dlr",fu=18e5,hu={STATUSES:{PENDING:"pending"},BATCH_SIZE:50,DEFAULT_RETRY_DELAYS:[6e4,12e4,24e4,48e4,9e5],RETRYABLE_HTTP_CODES:[408,429,500,502,503,504,401],GLOBAL_SUCCESS_CODE:202,PARTIAL_SUCCESS_CODE:201,DLR_SUCCESS_CODE:200},du="/firebase-messaging-sw.js",vu={USER_CONTEXT:"websdk_user_context",VISITOR_ID:"websdk_visitor_id",VISITOR_EXTERNAL_ID:"websdk_visitor_external_id",VISITOR_EXPIRED_AT:"websdk_visitor_expired_at",VISITOR_CONFIG:"websdk_visitor_config",FCM_TOKEN:"websdk_fcm_token",FCM_TOKEN_CREATED_AT:"websdk_fcm_token_created_at",NOTIFICATION_STATE:"websdk_notification_state",SESSION_ID:"websdk_session_id",SESSION_START_TIME:"websdk_session_start_time",LAST_EVENT_TIME:"websdk_last_event_time",LAST_AUTHENTICATED_USER:"websdk_last_authenticated_user",MERGED_USER_ID:"websdk_merged_user_id",PENDING_MERGE:"websdk_pending_merge",SESSION_NUMBER:"websdk_session_number"};function lu(t,n,i){var r=vu[t],e=[];return n&&e.push(n),i&&e.push(i),e.length>0?"".concat(e.join("_"),"_").concat(r):r}var gu="websdk_storage_test",mu="test_value",pu="INIT_ERROR",wu="AUTH_ERROR",yu="NETWORK_ERROR",bu="EVENT_ERROR",Eu="VISITOR_CONFIG_ERROR",_u="WebSDK initialized successfully",Iu="Failed to initialize WebSDK",Tu="WebSDK destroyed successfully",Su="Storage initialization failed",Au="Failed to restore persisted page-path-tracking preference",Ou="Session initialization failed",Nu="Visitor config initialization failed",ku="Event tracker initialization failed",Du="Failed to restore user context",Cu="Failed to sync event tracker context",xu="DLR setup failed",Ru="EventTracker initialized successfully",Mu="EventTracker destroyed successfully",Uu="Failed to track event",Pu="Events sent successfully",Lu="Failed to send events",Fu="Failed to initialize storage:",Gu="Storage test failed:",ju="Storage read/write test failed",Vu="StorageManager destroyed successfully",Bu="Error during storage cleanup:",zu="New session started",Hu="Session continued",Wu="Session expired due to inactivity",Ku="Session ended on user switch (different user login)",qu="Session restored from storage",Xu="Failed to track user signin event",$u="Failed to track user signup event",Yu="Failed to track user update event",Ju="Failed to track user signout event",Qu="Failed to track behavioral event",Zu="VisitorConfigManager initialized successfully",ta="Visitor config fetched successfully",na="Failed to fetch visitor config",ia="Visitor tracking is disabled",ra="Visitor tracking is enabled",ea="Visitor config retrieved from cache",oa="AnonymousVisitorManager initialized successfully",sa="Visitor ID generated successfully",ua="Failed to generate visitor ID",aa="Visitor ID restored from storage",ca="Using cached visitor ID",fa="Visitor updated successfully",ha="Failed to update visitor",da="Visitor merged with user successfully",va="Failed to merge visitor with user",la="Visitor merge skipped",ga="Notification permission denied by user",ma="Notification manager initialized successfully",pa="Failed to initialize notification manager",wa="Notification initialization skipped (disabled or not supported)",ya="Firebase initialized successfully",ba="Failed to initialize Firebase",Ea="FCM token received successfully",_a="FCM token refreshed",Ia="Failed to retrieve FCM token",Ta="Service worker registered successfully",Sa="Failed to register service worker",Aa="DLR events sent successfully",Oa="Failed to send DLR events",Na="web",ka="user_signin",Da="user_update",Ca="user_signout",xa="scroll_depth",Ra=[25,50,75,90],Ma=30,Ua=3e3,Pa={WEBPUSH:"WEBPUSH"},La={WEB:"web"},Fa={ACCOUNT_NOT_EXISTS:2432,ACCOUNT_ID_NOT_PASSED:9999},Ga={ALREADY_MERGED:"1429",VISITOR_NOT_FOUND:"1428"},ja={NOTIFICATION_RECEIVED:"push_notification_received",NOTIFICATION_CLICKED:"push_notification_click",NOTIFICATION_DISMISSED:"push_notification_close"},Va="fcm",Ba="push",za="1.7.0";function Ha(t){return Ha="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},Ha(t)}var Wa,Ka={};!function(){if(Wa)return Ka;Wa=1;var t=Sr(),n=Kr().find,i=ae(),r="find",e=!0;r in[]&&Array(1)[r](function(){e=!1}),t({target:"Array",proto:!0,forced:e},{find:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),i(r)}();var qa,Xa,$a,Ya,Ja,Qa,Za,tc,nc,ic,rc,ec,oc,sc,uc,ac={};function cc(){if(Ja)return Ya;Ja=1;var t=kn(),n=Gt(),i=Nn(),r=vi(),e=function(){if($a)return Xa;$a=1;var t=G();return Xa=!t(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})}(),o=r("IE_PROTO"),s=Object,u=s.prototype;return Ya=e?s.getPrototypeOf:function(r){var e=i(r);if(t(e,o))return e[o];var a=e.constructor;return n(a)&&e instanceof a?a.prototype:e instanceof s?u:null}}function fc(){if(Za)return Qa;Za=1;var t,n,i,r=G(),e=Gt(),o=jt(),s=ue(),u=cc(),a=pi(),c=Cn(),f=Tn(),h=c("iterator"),d=!1;return[].keys&&("next"in(i=[].keys())?(n=u(u(i)))!==Object.prototype&&(t=n):d=!0),!o(t)||r(function(){var n={};return t[h].call(n)!==n})?t={}:f&&(t=s(t)),e(t[h])||a(t,h,function(){return this}),Qa={IteratorPrototype:t,BUGGY_SAFARI_ITERATORS:d}}function hc(){if(nc)return tc;nc=1;var t=fc().IteratorPrototype,n=ue(),i=xt(),r=Ro(),e=ys(),o=function(){return this};return tc=function(s,u,a,c){var f=u+" Iterator";return s.prototype=n(t,{next:i(+!c,a)}),r(s,f,!1,!0),e[f]=o,s}}function dc(){if(rc)return ic;rc=1;var t=Sr(),n=B(),i=Tn(),r=hi(),e=Gt(),o=hc(),s=cc(),u=xo(),a=Ro(),c=Xn(),f=pi(),h=Cn(),d=ys(),v=fc(),l=r.PROPER,g=r.CONFIGURABLE,m=v.IteratorPrototype,p=v.BUGGY_SAFARI_ITERATORS,w=h("iterator"),y="keys",b="values",E="entries",_=function(){return this};return ic=function(r,h,v,I,T,S,A){o(v,h,I);var O,N,k,D=function(t){if(t===T&&U)return U;if(!p&&t&&t in R)return R[t];switch(t){case y:case b:case E:return function(){return new v(this,t)}}return function(){return new v(this)}},C=h+" Iterator",x=!1,R=r.prototype,M=R[w]||R["@@iterator"]||T&&R[T],U=!p&&M||D(T),P="Array"===h&&R.entries||M;if(P&&(O=s(P.call(new r)))!==Object.prototype&&O.next&&(i||s(O)===m||(u?u(O,m):e(O[w])||f(O,w,_)),a(O,C,!0,!0),i&&(d[C]=_)),l&&T===b&&M&&M.name!==b&&(!i&&g?c(R,"name",b):(x=!0,U=function(){return n(M,this)})),T)if(N={values:D(b),keys:S?U:D(y),entries:D(E)},A)for(k in N)(p||x||!(k in R))&&f(R,k,N[k]);else t({target:h,proto:!0,forced:p||x},N);return i&&!A||R[w]===U||f(R,w,U,{name:T}),d[h]=U,N},ic}function vc(){return oc?ec:(oc=1,ec=function(t,n){return{value:t,done:n}})}function lc(){if(uc)return sc;uc=1;var t=Ft(),n=ae(),i=ys(),r=gi(),e=qn().f,o=dc(),s=vc(),u=Tn(),a=j(),c="Array Iterator",f=r.set,h=r.getterFor(c);sc=o(Array,"Array",function(n,i){f(this,{type:c,target:t(n),index:0,kind:i})},function(){var t=h(this),n=t.target,i=t.index++;if(!n||i>=n.length)return t.target=null,s(void 0,!0);switch(t.kind){case"keys":return s(i,!1);case"values":return s(n[i],!1)}return s([i,n[i]],!1)},"values");var d=i.Arguments=i.Array;if(n("keys"),n("values"),n("entries"),!u&&a&&"values"!==d.name)try{e(d,"name",{value:"values"})}catch(t){}return sc}!function(){if(qa)return ac;qa=1;var t=Sr(),n=Hr(),i=ji().indexOf,r=ve(),e=n([].indexOf),o=!!e&&1/e([1],1,-0)<0;t({target:"Array",proto:!0,forced:o||!r("indexOf")},{indexOf:function(t){var n=arguments.length>1?arguments[1]:void 0;return o?e(this,t,n)||0:i(this,t,n)}})}(),lc();var gc,mc={};!function(){if(gc)return mc;gc=1;var t=Sr(),n=Kr().map;t({target:"Array",proto:!0,forced:!Ur()("map")},{map:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}})}();var pc,wc,yc,bc={};function Ec(){if(wc)return pc;wc=1;var t=Xt(),n=TypeError;return pc=function(i,r){if(!delete i[r])throw new n("Cannot delete property "+t(r)+" of "+t(i))}}!function(){if(yc)return bc;yc=1;var t=Sr(),n=Nn(),i=Li(),r=Pi(),e=Gi(),o=kr(),s=Or(),u=Mr(),a=Nr(),c=Ec(),f=Ur()("splice"),h=Math.max,d=Math.min;t({target:"Array",proto:!0,forced:!f},{splice:function(t,f){var v,l,g,m,p,w,y=n(this),b=e(y),E=i(t,b),_=arguments.length;for(0===_?v=l=0:1===_?(v=0,l=b-E):(v=_-2,l=d(h(r(f),0),b-E)),s(b+v-l),g=u(y,l),m=0;m<l;m++)(p=E+m)in y&&a(g,m,y[p]);if(o(g,l),v<l){for(m=E;m<b-l;m++)w=m+v,(p=m+l)in y?y[w]=y[p]:c(y,w);for(m=b;m>b-l+v;m--)c(y,m-1)}else if(v>l)for(m=b-l;m>E;m--)w=m+v-1,(p=m+l-1)in y?y[w]=y[p]:c(y,w);for(m=0;m<v;m++)y[m+E]=arguments[m+2];return o(y,b-l+v),g}})}();var _c,Ic,Tc,Sc,Ac,Oc,Nc,kc,Dc,Cc,xc,Rc,Mc,Uc,Pc,Lc,Fc,Gc,jc={exports:{}},Vc={};function Bc(){if(_c)return Vc;_c=1;var t=Mt(),n=Ft(),i=zi().f,r=jo(),e="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];return Vc.f=function(o){return e&&"Window"===t(o)?function(t){try{return i(t)}catch(t){return r(e)}}(o):i(n(o))},Vc}function zc(){if(Ac)return Sc;Ac=1;var t=G(),n=jt(),i=Mt(),r=function(){if(Tc)return Ic;Tc=1;var t=G();return Ic=t(function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})}(),e=Object.isExtensible,o=t(function(){});return Sc=o||r?function(t){return!!n(t)&&((!r||"ArrayBuffer"!==i(t))&&(!e||e(t)))}:e}function Hc(){if(kc)return jc.exports;kc=1;var t=Sr(),n=Rt(),i=li(),r=jt(),e=kn(),o=qn().f,s=zi(),u=Bc(),a=zc(),c=Dn(),f=function(){if(Nc)return Oc;Nc=1;var t=G();return Oc=!t(function(){return Object.isExtensible(Object.preventExtensions({}))})}(),h=!1,d=c("meta"),v=0,l=function(t){o(t,d,{value:{objectID:"O"+v++,weakData:{}}})},g=jc.exports={enable:function(){g.enable=function(){},h=!0;var i=s.f,r=n([].splice),e={};e[d]=1,i(e).length&&(s.f=function(t){for(var n=i(t),e=0,o=n.length;e<o;e++)if(n[e]===d){r(n,e,1);break}return n},t({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:u.f}))},fastKey:function(t,n){if(!r(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!e(t,d)){if(!a(t))return"F";if(!n)return"E";l(t)}return t[d].objectID},getWeakData:function(t,n){if(!e(t,d)){if(!a(t))return!0;if(!n)return!1;l(t)}return t[d].weakData},onFreeze:function(t){return f&&h&&a(t)&&!e(t,d)&&l(t),t}};return i[d]=!0,jc.exports}function Wc(){if(Cc)return Dc;Cc=1;var t=Gt(),n=jt(),i=xo();return Dc=function(r,e,o){var s,u;return i&&t(s=e.constructor)&&s!==o&&n(u=s.prototype)&&u!==o.prototype&&i(r,u),r}}function Kc(){if(Rc)return xc;Rc=1;var t=Sr(),n=k(),i=Rt(),r=Tr(),e=pi(),o=Hc(),s=Ts(),u=Po(),a=Gt(),c=Pt(),f=jt(),h=G(),d=Ss(),v=Ro(),l=Wc();return xc=function(g,m,p){var w=-1!==g.indexOf("Map"),y=-1!==g.indexOf("Weak"),b=w?"set":"add",E=n[g],_=E&&E.prototype,I=E,T={},S=function(t){var n=i(_[t]);e(_,t,"add"===t?function(t){return n(this,0===t?0:t),this}:"delete"===t?function(t){return!(y&&!f(t))&&n(this,0===t?0:t)}:"get"===t?function(t){return y&&!f(t)?void 0:n(this,0===t?0:t)}:"has"===t?function(t){return!(y&&!f(t))&&n(this,0===t?0:t)}:function(t,i){return n(this,0===t?0:t,i),this})};if(r(g,!a(E)||!(y||_.forEach&&!h(function(){(new E).entries().next()}))))I=p.getConstructor(m,g,w,b),o.enable();else if(r(g,!0)){var A=new I,O=A[b](y?{}:-0,1)!==A,N=h(function(){A.has(1)}),k=d(function(t){new E(t)}),D=!y&&h(function(){for(var t=new E,n=5;n--;)t[b](n,n);return!t.has(-0)});k||((I=m(function(t,n){u(t,_);var i=l(new E,t,I);return c(n)||s(n,i[b],{that:i,AS_ENTRIES:w}),i})).prototype=_,_.constructor=I),(N||D)&&(S("delete"),S("has"),w&&S("get")),(D||O)&&S(b),y&&_.clear&&delete _.clear}return T[g]=I,t({global:!0,constructor:!0,forced:I!==E},T),v(I,g),y||p.setStrong(I,g,w),I}}function qc(){if(Uc)return Mc;Uc=1;var t=pi();return Mc=function(n,i,r){for(var e in i)t(n,e,i[e],r);return n}}function Xc(){if(Lc)return Pc;Lc=1;var t=ue(),n=Mo(),i=qc(),r=Wr(),e=Po(),o=Pt(),s=Ts(),u=dc(),a=vc(),c=Uo(),f=j(),h=Hc().fastKey,d=gi(),v=d.set,l=d.getterFor;return Pc={getConstructor:function(u,a,c,d){var g=u(function(n,i){e(n,m),v(n,{type:a,index:t(null),first:null,last:null,size:0}),f||(n.size=0),o(i)||s(i,n[d],{that:n,AS_ENTRIES:c})}),m=g.prototype,p=l(a),w=function(t,n,i){var r,e,o=p(t),s=y(t,n);return s?s.value=i:(o.last=s={index:e=h(n,!0),key:n,value:i,previous:r=o.last,next:null,removed:!1},o.first||(o.first=s),r&&(r.next=s),f?o.size++:t.size++,"F"!==e&&(o.index[e]=s)),t},y=function(t,n){var i,r=p(t),e=h(n);if("F"!==e)return r.index[e];for(i=r.first;i;i=i.next)if(i.key===n)return i};return i(m,{clear:function(){for(var n=p(this),i=n.first;i;)i.removed=!0,i.previous&&(i.previous=i.previous.next=null),i=i.next;n.first=n.last=null,n.index=t(null),f?n.size=0:this.size=0},delete:function(t){var n=this,i=p(n),r=y(n,t);if(r){var e=r.next,o=r.previous;delete i.index[r.index],r.removed=!0,o&&(o.next=e),e&&(e.previous=o),i.first===r&&(i.first=e),i.last===r&&(i.last=o),f?i.size--:n.size--}return!!r},forEach:function(t){for(var n,i=p(this),e=r(t,arguments.length>1?arguments[1]:void 0);n=n?n.next:i.first;)for(e(n.value,n.key,this);n&&n.removed;)n=n.previous},has:function(t){return!!y(this,t)}}),i(m,c?{get:function(t){var n=y(this,t);return n&&n.value},set:function(t,n){return w(this,0===t?0:t,n)}}:{add:function(t){return w(this,t=0===t?0:t,t)}}),f&&n(m,"size",{configurable:!0,get:function(){return p(this).size}}),g},setStrong:function(t,n,i){var r=n+" Iterator",e=l(n),o=l(r);u(t,n,function(t,n){v(this,{type:r,target:t,state:e(t),kind:n,last:null})},function(){for(var t=o(this),n=t.kind,i=t.last;i&&i.removed;)i=i.previous;return t.target&&(t.last=i=i?i.next:t.state.first)?a("keys"===n?i.key:"values"===n?i.value:[i.key,i.value],!1):(t.target=null,a(void 0,!0))},i?"entries":"values",!i,!0),c(n)}},Pc}Gc||(Gc=1,Fc||(Fc=1,Kc()("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Xc())));var $c,Yc,Jc,Qc,Zc,tf,nf,rf={};function ef(){if(Yc)return $c;Yc=1;var t=Rt();return $c=t(1.1.valueOf)}function of(){if(Qc)return Jc;Qc=1;var t=Cr(),n=String;return Jc=function(i){if("Symbol"===t(i))throw new TypeError("Cannot convert a Symbol value to a string");return n(i)}}function sf(){if(tf)return Zc;tf=1;var t=Pi(),n=of(),i=Lt(),r=RangeError,e=Math.floor;return Zc=function(o){var s=n(i(this)),u="",a=t(o);if(a<0||a===1/0)throw new r("Wrong number of repetitions");for(;a>0;(a=e(a/2))&&(s+=s))a%2&&(u+=s);return u}}!function(){if(nf)return rf;nf=1;var t=Sr(),n=Rt(),i=Pi(),r=ef(),e=sf(),o=G(),s=RangeError,u=String,a=Math.floor,c=n(e),f=n("".slice),h=n(1.1.toFixed),d=function(t,n,i){return 0===n?i:n%2==1?d(t,n-1,i*t):d(t*t,n/2,i)},v=function(t,n,i){for(var r=-1,e=i;++r<6;)e+=n*t[r],t[r]=e%1e7,e=a(e/1e7)},l=function(t,n){for(var i=6,r=0;--i>=0;)r+=t[i],t[i]=a(r/n),r=r%n*1e7},g=function(t){for(var n=6,i="";--n>=0;)if(""!==i||0===n||0!==t[n]){var r=u(t[n]);i=""===i?r:i+c("0",7-r.length)+r}return i};t({target:"Number",proto:!0,forced:o(function(){return"0.000"!==h(8e-5,3)||"1"!==h(.9,0)||"1.25"!==h(1.255,2)||"1000000000000000128"!==h(0xde0b6b3a7640080,0)})||!o(function(){h({})})},{toFixed:function(t){var n,e,o,a,h=r(this),m=i(t),p=[0,0,0,0,0,0],w="",y="0";if(m<0||m>20)throw new s("Incorrect fraction digits");if(h!=h)return"NaN";if(h<=-1e21||h>=1e21)return u(h);if(h<0&&(w="-",h=-h),h>1e-21)if(e=(n=function(t){for(var n=0,i=t;i>=4096;)n+=12,i/=4096;for(;i>=2;)n+=1,i/=2;return n}(h*d(2,69,1))-69)<0?h*d(2,-n,1):h/d(2,n,1),e*=4503599627370496,(n=52-n)>0){for(v(p,0,e),o=m;o>=7;)v(p,1e7,0),o-=7;for(v(p,d(10,o,1),0),o=n-1;o>=23;)l(p,1<<23),o-=23;l(p,1<<o),v(p,1,1),l(p,2),y=g(p)}else v(p,0,e),v(p,1<<-n,0),y=g(p)+c("0",m);return y=m>0?w+((a=y.length)<=m?"0."+c("0",m-a)+y:f(y,0,a-m)+"."+f(y,a-m)):w+y}})}();var uf,af;af||(af=1,uf||(uf=1,Kc()("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Xc())));var cf,ff,hf,df,vf,lf,gf,mf={};function pf(){if(ff)return cf;ff=1;var t=jt(),n=Mt(),i=Cn()("match");return cf=function(r){var e;return t(r)&&(void 0!==(e=r[i])?!!e:"RegExp"===n(r))}}function wf(){if(df)return hf;df=1;var t=pf(),n=TypeError;return hf=function(i){if(t(i))throw new n("The method doesn't accept regular expressions");return i}}function yf(){if(lf)return vf;lf=1;var t=Cn()("match");return vf=function(n){var i=/./;try{"/./"[n](i)}catch(r){try{return i[t]=!1,"/./"[n](i)}catch(t){}}return!1}}!function(){if(gf)return mf;gf=1;var t=Sr(),n=Rt(),i=wf(),r=Lt(),e=of(),o=yf(),s=n("".indexOf);t({target:"String",proto:!0,forced:!o("includes")},{includes:function(t){return!!~s(e(r(this)),e(i(t)),arguments.length>1?arguments[1]:void 0)}})}();var bf,Ef,_f,If={};function Tf(){if(Ef)return bf;Ef=1;var t=Rt(),n=Pi(),i=of(),r=Lt(),e=t("".charAt),o=t("".charCodeAt),s=t("".slice),u=function(t){return function(u,a){var c,f,h=i(r(u)),d=n(a),v=h.length;return d<0||d>=v?t?"":void 0:(c=o(h,d))<55296||c>56319||d+1===v||(f=o(h,d+1))<56320||f>57343?t?e(h,d):c:t?s(h,d,d+2):f-56320+(c-55296<<10)+65536}};return bf={codeAt:u(!1),charAt:u(!0)}}function Sf(){if(_f)return If;_f=1;var t=Tf().charAt,n=of(),i=gi(),r=dc(),e=vc(),o="String Iterator",s=i.set,u=i.getterFor(o);return r(String,"String",function(t){s(this,{type:o,string:n(t),index:0})},function(){var n,i=u(this),r=i.string,o=i.index;return o>=r.length?e(void 0,!0):(n=t(r,o),i.index+=n.length,e(n,!1))}),If}Sf();var Af,Of={};!function(){if(Af)return Of;Af=1;var t=k(),n=qs(),i=Xs(),r=lc(),e=Xn(),o=Ro(),s=Cn()("iterator"),u=r.values,a=function(t,i){if(t){if(t[s]!==u)try{e(t,s,u)}catch(n){t[s]=u}if(o(t,i,!0),n[i])for(var a in r)if(t[a]!==r[a])try{e(t,a,r[a])}catch(n){t[a]=r[a]}}};for(var c in n)a(t[c]&&t[c].prototype,c);a(i,"DOMTokenList")}();var Nf,kf="GamificationManager initialized successfully",Df="Failed to initialize GamificationManager",Cf="GamificationManager destroyed successfully",xf="GamificationManager state cleared",Rf="Gamification disabled — gamificationWriteKey not configured",Mf="GamificationManager refresh triggered",Uf="GamificationManager data resync triggered",Pf="GamificationManager data resync failed",Lf="GamificationManager loaded from cache — API call skipped",Ff="GamificationManager cache miss — fetching from API",Gf="GamificationManager reused cached token — token API call skipped",jf="GamificationManager token cache miss — fetching new token",Vf="GamificationManager got an auth error on campaigns/entry points — invalidating cached token and retrying once",Bf="GamificationManager token refetch is in backoff after repeated failures — skipping network call",zf="GAME_PLAYED",Hf="CAMPAIGN_PLAY",Wf="game_open",Kf="game_viewed",qf="game_played",Xf="game_completed",$f="reward_seen",Yf="content_open",Jf="content_viewed",Qf="LOYALTY",Zf="COMPLETED",th="https://api.customerglu.com",nh=function(t){return"https://api-".concat(t,".customerglu.com")},ih=3e5,rh=18e5,eh="__GLU__CACHE__",oh="__GLU__TOKEN__",sh="__GLU__COUNT_DATE_",uh=16,ah={LOGGED_IN:"loggedIn"},ch={EVENT_NAME:"event_name",REWARD_TYPE:"reward_type",CAMPAIGN_ID:"campaign_id",CAMPAIGN_DETAILS:"campaign_details",REWARD_STATUS:"reward_status",REWARD_USER_ID:"reward_user_id"},fh=1e3,hh=16e3,dh=2e3,vh=3e5,lh="glu_cap_token",gh="glu_page_path_tracking_enabled",mh="/preload",ph=5e3,wh="__GLU__ORIGIN__",yh={};!function(){if(Nf)return yh;Nf=1;var t=j(),n=hi().EXISTS,i=Rt(),r=Mo(),e=Function.prototype,o=i(e.toString),s=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,u=i(s.exec);t&&!n&&r(e,"name",{configurable:!0,get:function(){try{return u(s,o(this))[1]}catch(t){return""}}})}();var bh,Eh,_h,Ih,Th,Sh,Ah,Oh,Nh={};function kh(){if(Eh)return bh;Eh=1;var t=G(),n=Cn(),i=j(),r=Tn(),e=n("iterator");return bh=!t(function(){var t=new URL("b?a=1&b=2&c=3","https://a"),n=t.searchParams,o=new URLSearchParams("a=1&a=2&b=3"),s="";return t.pathname="c%20d",n.forEach(function(t,i){n.delete("b"),s+=i+t}),o.delete("a",2),o.delete("b",void 0),r&&(!t.toJSON||!o.has("a",1)||o.has("a",2)||!o.has("a",void 0)||o.has("b"))||!n.size&&(r||!i)||!n.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==n.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!n[e]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==s||"x"!==new URL("https://x",void 0).host})}function Dh(){if(Ih)return _h;Ih=1;var t=Kn(),n=Is();return _h=function(i,r,e,o){try{return o?r(t(e)[0],e[1]):r(e)}catch(t){n(i,"throw",t)}}}function Ch(){if(Sh)return Th;Sh=1;var t=Wr(),n=B(),i=Nn(),r=Dh(),e=bs(),o=xr(),s=Gi(),u=Nr(),a=kr(),c=_s(),f=Es(),h=Is(),d=Or(),v=Array;return Th=function(l){var g=o(this),m=arguments.length,p=m>1?arguments[1]:void 0,w=void 0!==p;w&&(p=t(p,m>2?arguments[2]:void 0));var y,b,E,_,I,T,S=i(l),A=f(S),O=0;if(!A||this===v&&e(A))for(y=s(S),b=g?new this(y):v(y);y>O;O++)T=w?p(S[O],O):S[O],u(b,O,T);else for(b=g?new this:[],I=(_=c(S,A)).next;!(E=n(I,_)).done;O++){try{d(O)}catch(t){h(_,"throw",t)}T=w?r(_,p,[E.value,O],!0):E.value;try{u(b,O,T)}catch(t){h(_,"throw",t)}}return a(b,O),b},Th}function xh(){if(Oh)return Ah;Oh=1;var t=Rt(),n=2147483647,i=/[^\0-\u007E]/,r=/[.\u3002\uFF0E\uFF61]/g,e="Overflow: input needs wider integers to process",o=RangeError,s=t(r.exec),u=Math.floor,a=String.fromCharCode,c=t("".charCodeAt),f=t([].join),h=t([].push),d=t("".replace),v=t("".split),l=t("".toLowerCase),g=function(t){return t+22+75*(t<26)},m=function(t,n,i){var r=0;for(t=i?u(t/700):t>>1,t+=u(t/n);t>455;)t=u(t/35),r+=36;return u(r+36*t/(t+38))},p=function(t){var i=[];t=function(t){for(var n=[],i=0,r=t.length;i<r;){var e=c(t,i++);if(e>=55296&&e<=56319&&i<r){var o=c(t,i++);56320==(64512&o)?h(n,((1023&e)<<10)+(1023&o)+65536):(h(n,e),i--)}else h(n,e)}return n}(t);var r,s,d=t.length,v=128,l=0,p=72;for(r=0;r<t.length;r++)(s=t[r])<128&&h(i,a(s));var w=i.length,y=w;for(w&&h(i,"-");y<d;){var b=n;for(r=0;r<t.length;r++)(s=t[r])>=v&&s<b&&(b=s);var E=y+1;if(b-v>u((n-l)/E))throw new o(e);for(l+=(b-v)*E,v=b,r=0;r<t.length;r++){if((s=t[r])<v&&++l>n)throw new o(e);if(s===v){for(var _=l,I=36;;){var T=I<=p?1:I>=p+26?26:I-p;if(_<T)break;var S=_-T,A=36-T;h(i,a(g(T+S%A))),_=u(S/A),I+=36}h(i,a(g(_))),p=m(l,E,y===w),l=0,y++}}l++,v++}return f(i,"")};return Ah=function(t){var n,e,o=[],u=v(d(l(t),r,"."),".");for(n=0;n<u.length;n++)e=u[n],h(o,s(i,e)?"xn--"+p(e):e);return f(o,".")}}var Rh,Mh,Uh,Ph,Lh,Fh,Gh,jh,Vh,Bh={};function zh(){if(Uh)return Mh;Uh=1,function(){if(Rh)return Bh;Rh=1;var t=Sr(),n=Rt(),i=Li(),r=RangeError,e=String.fromCharCode,o=String.fromCodePoint,s=n([].join);t({target:"String",stat:!0,arity:1,forced:!!o&&1!==o.length},{fromCodePoint:function(t){for(var n,o=[],u=arguments.length,a=0;u>a;){if(i(n=+arguments[a],1114111)!==n)throw new r(n+" is not a valid code point");o[a++]=n<65536?e(n):e(55296+((n-=65536)>>10),n%1024+56320)}return s(o,"")}})}();var t=Vt(),n=Rt(),i=String.fromCharCode,r=t("String","fromCodePoint"),e=encodeURIComponent,o=parseInt,s=n("".charAt),u=n([].push),a=n("".replace),c=n("".slice),f=n(/./.exec),h="�",d=/^[0-9a-f]+$/i,v=/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDFFF]/g,l=function(t,n){var i=c(t,n,n+2);return f(d,i)?o(i,16):NaN},g=function(t){for(var n=0,i=128;i>0&&0!==(t&i);i>>=1)n++;return n},m=function(t){var n=null,i=t.length;switch(i){case 1:n=t[0];break;case 2:n=(31&t[0])<<6|63&t[1];break;case 3:n=(15&t[0])<<12|(63&t[1])<<6|63&t[2];break;case 4:n=(7&t[0])<<18|(63&t[1])<<12|(63&t[2])<<6|63&t[3]}return null===n||n>1114111||n>=55296&&n<=57343||n<(i>3?65536:i>2?2048:i>1?128:0)?null:n},p=function(t){return 2===t.length?t:h};return Mh={decode:function(t){for(var n=t.length,e="",o=0;o<n;){var a=s(t,o);if("%"===a){if("%"===s(t,o+1)||o+3>n){e+="%",o++;continue}var c=l(t,o+1);if(c!=c){e+=a,o++;continue}o+=2;var f=g(c);if(0===f)a=i(c);else{if(1===f||f>4){e+=h,o++;continue}for(var d=[c],v=1;v<f&&!(++o+3>n||"%"!==s(t,o));){var p=l(t,o+1);if(p!=p||p>191||p<128)break;if(1===v){if(224===c&&p<160)break;if(237===c&&p>159)break;if(240===c&&p<144)break;if(244===c&&p>143)break}u(d,p),o+=2,v++}if(d.length!==f){e+=h;continue}var w=m(d);if(null===w){for(var y=0;y<f;y++)e+=h;o++;continue}a=r(w)}}e+=a,o++}return e},encode:function(t){try{return e(t)}catch(n){return e(a(t,v,p))}}}}function Hh(){if(Lh)return Ph;Lh=1;var t=jo(),n=Math.floor,i=function(r,e){var o=r.length;if(o<8)for(var s,u,a=1;a<o;){for(u=a,s=r[a];u&&e(r[u-1],s)>0;)r[u]=r[--u];u!==a++&&(r[u]=s)}else for(var c=n(o/2),f=i(t(r,0,c),e),h=i(t(r,c),e),d=f.length,v=h.length,l=0,g=0;l<d||g<v;)r[l+g]=l<d&&g<v?e(f[l],h[g])<=0?f[l++]:h[g++]:l<d?f[l++]:h[g++];return r};return Ph=i}function Wh(){if(Gh)return Fh;Gh=1,lc();var t=Sr(),n=k(),i=Ho(),r=B(),e=Rt(),o=j(),s=kh(),u=zh(),a=pi(),c=Mo(),f=qc(),h=Ro(),d=hc(),v=gi(),l=Po(),g=Gt(),m=kn(),p=Wr(),w=Cr(),y=Kn(),b=jt(),E=of(),_=ue(),I=xt(),T=_s(),S=Es(),A=vc(),O=Vo(),N=Cn(),D=Hh(),C=N("iterator"),x="URLSearchParams",R=x+"Iterator",M=v.set,U=v.getterFor(x),P=v.getterFor(R),L=u.decode,F=u.encode,G=i("fetch"),V=i("Request"),z=i("Headers"),H=V&&V.prototype,W=z&&z.prototype,K=n.TypeError,q=e("".charAt),X=e([].join),$=e([].push),Y=e("".replace),J=e([].shift),Q=e([].splice),Z=e("".split),tt=e("".slice),nt=/\+/g,it=function(t){return L(Y(t,nt," "))},rt=/[!'()~]|%20/g,et={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},ot=function(t){return et[t]},st=function(t){return Y(F(t),rt,ot)},ut=d(function(t,n){M(this,{type:R,target:U(t).entries,index:0,kind:n})},x,function(){var t=P(this),n=t.target,i=t.index++;if(!n||i>=n.length)return t.target=null,A(void 0,!0);var r=n[i];switch(t.kind){case"keys":return A(r.key,!1);case"values":return A(r.value,!1)}return A([r.key,r.value],!1)},!0),at=function(t){this.entries=[],this.url=null,void 0!==t&&(b(t)?this.parseObject(t):this.parseQuery("string"==typeof t?"?"===q(t,0)?tt(t,1):t:E(t)))};at.prototype={type:x,bindURL:function(t){this.url=t,this.update()},parseObject:function(t){var n,i,e,o,s,u,a,c=this.entries,f=S(t);if(f)for(i=(n=T(t,f)).next;!(e=r(i,n)).done;){if(s=(o=T(y(e.value))).next,(u=r(s,o)).done||(a=r(s,o)).done||!r(s,o).done)throw new K("Expected sequence with length 2");$(c,{key:E(u.value),value:E(a.value)})}else for(var h in t)m(t,h)&&$(c,{key:h,value:E(t[h])})},parseQuery:function(t){if(t)for(var n,i,r=this.entries,e=Z(t,"&"),o=0;o<e.length;)(n=e[o++]).length&&(i=Z(n,"="),$(r,{key:it(J(i)),value:it(X(i,"="))}))},serialize:function(){for(var t,n=this.entries,i=[],r=0;r<n.length;)t=n[r++],$(i,st(t.key)+"="+st(t.value));return X(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var ct=function(){l(this,ft);var t=M(this,new at(arguments.length>0?arguments[0]:void 0));o||(this.size=t.entries.length)},ft=ct.prototype;if(f(ft,{append:function(t,n){var i=U(this);O(arguments.length,2),$(i.entries,{key:E(t),value:E(n)}),o||this.size++,i.updateURL()},delete:function(t){for(var n=U(this),i=O(arguments.length,1),r=n.entries,e=E(t),s=i<2?void 0:arguments[1],u=void 0===s?s:E(s),a=0;a<r.length;){var c=r[a];c.key!==e||void 0!==u&&c.value!==u?a++:Q(r,a,1)}o||(this.size=r.length),n.updateURL()},get:function(t){var n=U(this).entries;O(arguments.length,1);for(var i=E(t),r=0;r<n.length;r++)if(n[r].key===i)return n[r].value;return null},getAll:function(t){var n=U(this).entries;O(arguments.length,1);for(var i=E(t),r=[],e=0;e<n.length;e++)n[e].key===i&&$(r,n[e].value);return r},has:function(t){for(var n=U(this).entries,i=O(arguments.length,1),r=E(t),e=i<2?void 0:arguments[1],o=void 0===e?e:E(e),s=0;s<n.length;){var u=n[s++];if(u.key===r&&(void 0===o||u.value===o))return!0}return!1},set:function(t,n){var i=U(this);O(arguments.length,2);for(var r,e=i.entries,s=!1,u=E(t),a=E(n),c=0;c<e.length;c++)(r=e[c]).key===u&&(s?Q(e,c--,1):(s=!0,r.value=a));s||$(e,{key:u,value:a}),o||(this.size=e.length),i.updateURL()},sort:function(){var t=U(this);D(t.entries,function(t,n){return t.key>n.key?1:-1}),t.updateURL()},forEach:function(t){for(var n,i=U(this).entries,r=p(t,arguments.length>1?arguments[1]:void 0),e=0;e<i.length;)r((n=i[e++]).value,n.key,this)},keys:function(){return new ut(this,"keys")},values:function(){return new ut(this,"values")},entries:function(){return new ut(this,"entries")}},{enumerable:!0}),a(ft,C,ft.entries,{name:"entries"}),a(ft,"toString",function(){return U(this).serialize()},{enumerable:!0}),o&&c(ft,"size",{get:function(){return U(this).entries.length},configurable:!0,enumerable:!0}),h(ct,x),t({global:!0,constructor:!0,forced:!s},{URLSearchParams:ct}),!s&&g(z)){var ht=e(W.has),dt=e(W.set),vt=function(t){if(b(t)){var n,i=t.body;if(w(i)===x)return n=t.headers?new z(t.headers):new z,ht(n,"content-type")||dt(n,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),_(t,{body:I(0,E(i)),headers:I(0,n)})}return t};if(g(G)&&t({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(t){return G(t,arguments.length>1?vt(arguments[1]):{})}}),g(V)){var lt=function(t){return l(this,H),new V(t,arguments.length>1?vt(arguments[1]):{})};H.constructor=lt,lt.prototype=H,t({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:lt})}}return Fh={URLSearchParams:ct,getState:U}}function Kh(){if(jh)return Nh;jh=1,Sf();var t,n=Sr(),i=j(),r=kh(),e=k(),o=Wr(),s=Rt(),u=pi(),a=Mo(),c=Po(),f=kn(),h=we(),d=Ch(),v=jo(),l=Tf().codeAt,g=xh(),m=zh(),p=of(),w=Ro(),y=Vo(),b=Wh(),E=gi(),_=E.set,I=E.getterFor("URL"),T=b.URLSearchParams,S=b.getState,A=m.decode,O=m.encode,N=e.URL,D=e.TypeError,C=e.parseInt,x=Math.floor,R=Math.pow,M=String.fromCharCode,U=s("".charAt),P=s(/./.exec),L=s([].join),F=s(1.1.toString),G=s([].pop),V=s([].push),B=s("".replace),z=s([].shift),H=s("".split),W=s("".indexOf),K=s("".slice),q=s("".toLowerCase),X=s([].unshift),$="Invalid scheme",Y="Invalid host",J="Invalid port",Q=/[a-z]/i,Z=/[\d+\-.a-z]/i,tt=/\d/,nt=/^0x/i,it=/^[0-7]+$/,rt=/^\d+$/,et=/^[\da-f]+$/i,ot=/[\u0000-\u0020#%/:<>?@[\\\]^|\u007F]/,st=/[\0\t\n\r #/:<>?@[\\\]^|]/,ut=/^[\u0000-\u0020]+/,at=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ct=/[\t\n\r]/g,ft=/[^\u0000-\u007F]/,ht=function(t){return 173===t||847===t||8203===t||12644===t||65279===t||65440===t||t>=4447&&t<=4448||t>=6068&&t<=6069||t>=6155&&t<=6159||t>=8288&&t<=8292||t>=8298&&t<=8303||t>=65024&&t<=65039||t>=917760&&t<=917999},dt=function(t){return 65533===t||t>=55296&&t<=57343||t>=128&&t<=159||t>=8206&&t<=8207||t>=8232&&t<=8233||t>=8234&&t<=8238||t>=8293&&t<=8297||t>=64976&&t<=65007||!(65534&~t)||t>=57344&&t<=63743||t>=983040&&t<=1114109},vt=function(t){return t>=65281&&t<=65374?t-65248:160===t||5760===t||8239===t||8287===t||12288===t||t>=8192&&t<=8202||t<=65535&&W("¨¯´¸˘˙˚˛˜˝ͺ΄΅᾽᾿῀῁῍῎῏῝῞῟῭΅´῾‗‾⁇⁈⁉℀℁℅℆⩴゛゜ﱞﱟﱠﱡﱢﱣﷺﷻ︓︖﹇﹈﹉﹊﹋﹌﹕﹖﹟﹤﹥﹨﹪﹫ﹰﹲﹴﹶﹸﹺﹼﹾ ̄",M(t))>-1?32:t},lt=function(t){var n,i,r,e;if("number"==typeof t){for(n=[],i=0;i<4;i++)X(n,t%256),t=x(t/256);return L(n,".")}if("object"==typeof t){for(n="",r=function(t){for(var n=null,i=1,r=null,e=0,o=0;o<8;o++)0!==t[o]?(e>i&&(n=r,i=e),r=null,e=0):(null===r&&(r=o),++e);return e>i?r:n}(t),i=0;i<8;i++)e&&0===t[i]||(e&&(e=!1),r===i?(n+=i?":":"::",e=!0):(n+=F(t[i],16),i<7&&(n+=":")));return"["+n+"]"}return t},gt={},mt=h({},gt,{" ":1,'"':1,"#":1,"<":1,">":1}),pt=h({},mt,{"'":1}),wt=h({},gt,{" ":1,'"':1,"<":1,">":1,"`":1}),yt=h({},wt,{"#":1,"?":1,"{":1,"}":1,"^":1}),bt=h({},yt,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Et=function(t,n){var i=l(t,0);return i>=32&&i<127&&!f(n,t)?t:"'"===t&&f(n,t)?"%27":O(t)},_t={ftp:21,file:null,http:80,https:443,ws:80,wss:443},It=function(t,n){var i;return 2===t.length&&P(Q,U(t,0))&&(":"===(i=U(t,1))||!n&&"|"===i)},Tt=function(t){var n;return t.length>1&&It(K(t,0,2))&&(2===t.length||"/"===(n=U(t,2))||"\\"===n||"?"===n||"#"===n)},St=function(t){return"."===t||"%2e"===q(t)},At=function(t){return".."===(t=q(t))||"%2e."===t||".%2e"===t||"%2e%2e"===t},Ot={},Nt={},kt={},Dt={},Ct={},xt={},Mt={},Ut={},Pt={},Lt={},Ft={},Gt={},jt={},Vt={},Bt={},zt={},Ht={},Wt={},Kt={},qt={},Xt={},$t=function(t,n,i){var r,e,o,s=p(t);if(n){if(e=this.parse(s))throw new D(e);this.searchParams=null}else{if(void 0!==i&&(r=new $t(i,!0)),e=this.parse(s,null,r))throw new D(e);(o=S(new T)).bindURL(this),this.searchParams=o}};$t.prototype={type:"URL",parse:function(n,i,r){var e,o,s,u,a=this,c=i||Ot,h=0,l="",g=!1,m=!1,w=!1;for(n=p(n),i||(a.scheme="",a.username="",a.password="",a.host=null,a.port=null,a.path=[],a.query=null,a.fragment=null,a.cannotBeABaseURL=!1,n=B(n,ut,""),n=B(n,at,"$1")),n=B(n,ct,""),e=d(n);h<=e.length;){switch(o=e[h],c){case Ot:if(!o||!P(Q,o)){if(i)return $;c=kt;continue}l+=q(o),c=Nt;break;case Nt:if(o&&P(Z,o))l+=q(o);else{if(":"!==o){if(i)return $;l="",c=kt,h=0;continue}if(i&&(a.isSpecial()!==f(_t,l)||"file"===l&&(a.includesCredentials()||null!==a.port)||"file"===a.scheme&&""===a.host))return;if(a.scheme=l,i)return void(a.isSpecial()&&_t[a.scheme]===a.port&&(a.port=null));l="","file"===a.scheme?c=Vt:a.isSpecial()&&r&&r.scheme===a.scheme?c=Dt:a.isSpecial()?c=Ut:"/"===e[h+1]?(c=Ct,h++):(a.cannotBeABaseURL=!0,V(a.path,""),c=Kt)}break;case kt:if(!r||r.cannotBeABaseURL&&"#"!==o)return $;if(r.cannotBeABaseURL&&"#"===o){a.scheme=r.scheme,a.path=v(r.path),a.query=r.query,a.fragment="",a.cannotBeABaseURL=!0,c=Xt;break}c="file"===r.scheme?Vt:xt;continue;case Dt:if("/"!==o||"/"!==e[h+1]){c=xt;continue}c=Pt,h++;break;case Ct:if("/"===o){c=Lt;break}c=Wt;continue;case xt:if(a.scheme=r.scheme,o===t)a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=v(r.path),a.query=r.query;else if("/"===o||"\\"===o&&a.isSpecial())c=Mt;else if("?"===o)a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=v(r.path),a.query="",c=qt;else{if("#"!==o){a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=v(r.path),a.path.length&&a.path.length--,c=Wt;continue}a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=v(r.path),a.query=r.query,a.fragment="",c=Xt}break;case Mt:if(!a.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,c=Wt;continue}c=Lt}else c=Pt;break;case Ut:if(c=Pt,"/"!==o||"/"!==e[h+1])continue;h++;break;case Pt:if("/"!==o&&"\\"!==o){c=Lt;continue}break;case Lt:if("@"===o){g&&(l="%40"+l),g=!0,s=d(l);for(var y=0;y<s.length;y++){var b=s[y];if(":"!==b||w){var E=Et(b,bt);w?a.password+=E:a.username+=E}else w=!0}l=""}else if(o===t||"/"===o||"?"===o||"#"===o||"\\"===o&&a.isSpecial()){if(g&&""===l)return"Invalid authority";h-=d(l).length+1,l="",c=Ft}else l+=o;break;case Ft:case Gt:if(i&&"file"===a.scheme){c=zt;continue}if(":"!==o||m){if(o===t||"/"===o||"?"===o||"#"===o||"\\"===o&&a.isSpecial()){if(a.isSpecial()&&""===l)return Y;if(i&&""===l&&(a.includesCredentials()||null!==a.port))return;if(u=a.parseHost(l))return u;if(l="",c=Ht,i)return;continue}"["===o?m=!0:"]"===o&&(m=!1),l+=o}else{if(""===l)return Y;if(i===Gt)return;if(u=a.parseHost(l))return u;l="",c=jt}break;case jt:if(!P(tt,o)){if(o===t||"/"===o||"?"===o||"#"===o||"\\"===o&&a.isSpecial()||i){if(""!==l){var _=C(l,10);if(_>65535)return J;a.port=a.isSpecial()&&_===_t[a.scheme]?null:_,l=""}if(i)return;c=Ht;continue}return J}l+=o;break;case Vt:if(a.scheme="file",a.host="","/"===o||"\\"===o)c=Bt;else{if(!r||"file"!==r.scheme){c=Wt;continue}switch(o){case t:a.host=r.host,a.path=v(r.path),a.query=r.query;break;case"?":a.host=r.host,a.path=v(r.path),a.query="",c=qt;break;case"#":a.host=r.host,a.path=v(r.path),a.query=r.query,a.fragment="",c=Xt;break;default:a.host=r.host,Tt(L(v(e,h),""))||(a.path=v(r.path),a.shortenPath()),c=Wt;continue}}break;case Bt:if("/"===o||"\\"===o){c=zt;break}r&&"file"===r.scheme&&(a.host=r.host,!Tt(L(v(e,h),""))&&It(r.path[0],!0)&&V(a.path,r.path[0])),c=Wt;continue;case zt:if(o===t||"/"===o||"\\"===o||"?"===o||"#"===o){if(!i&&It(l))c=Wt;else if(""===l){if(a.host="",i)return;c=Ht}else{if(u=a.parseHost(l))return u;if("localhost"===a.host&&(a.host=""),i)return;l="",c=Ht}continue}l+=o;break;case Ht:if(a.isSpecial()){if(c=Wt,"/"!==o&&"\\"!==o)continue}else if(i||"?"!==o)if(i||"#"!==o){if(o!==t&&(c=Wt,"/"!==o))continue}else a.fragment="",c=Xt;else a.query="",c=qt;break;case Wt:if(o===t||"/"===o||"\\"===o&&a.isSpecial()||!i&&("?"===o||"#"===o)){if(At(l)?(a.shortenPath(),"/"===o||"\\"===o&&a.isSpecial()||V(a.path,"")):St(l)?"/"===o||"\\"===o&&a.isSpecial()||V(a.path,""):("file"===a.scheme&&!a.path.length&&It(l)&&(null!==a.host&&""!==a.host&&(a.host=""),l=U(l,0)+":"),V(a.path,l)),l="","file"===a.scheme&&(o===t||"?"===o||"#"===o))for(;a.path.length>1&&""===a.path[0];)z(a.path);"?"===o?(a.query="",c=qt):"#"===o&&(a.fragment="",c=Xt)}else l+=Et(o,yt);break;case Kt:"?"===o?(a.query="",c=qt):"#"===o?(a.fragment="",c=Xt):o!==t&&(a.path[0]+=" "===o?"?"===e[h+1]||"#"===e[h+1]?"%20":" ":Et(o,gt));break;case qt:i||"#"!==o?o!==t&&(a.query+=Et(o,a.isSpecial()?pt:mt)):(a.fragment="",c=Xt);break;case Xt:o!==t&&(a.fragment+=Et(o,wt))}h++}},parseHost:function(t){var n,i,r;if("["===U(t,0)){if("]"!==U(t,t.length-1))return Y;if(n=function(t){var n,i,r,e,o,s,u,a=[0,0,0,0,0,0,0,0],c=0,f=null,h=0,d=function(){return U(t,h)};if(":"===d()){if(":"!==U(t,1))return;h+=2,f=++c}for(;d();){if(8===c)return;if(":"!==d()){for(n=i=0;i<4&&P(et,d());)n=16*n+C(d(),16),h++,i++;if("."===d()){if(0===i)return;if(h-=i,c>6)return;for(r=0;d();){if(e=null,r>0){if(!("."===d()&&r<4))return;h++}if(!P(tt,d()))return;for(;P(tt,d());){if(o=C(d(),10),null===e)e=o;else{if(0===e)return;e=10*e+o}if(e>255)return;h++}a[c]=256*a[c]+e,2!==++r&&4!==r||c++}if(4!==r)return;break}if(":"===d()){if(h++,!d())return}else if(d())return;a[c++]=n}else{if(null!==f)return;h++,f=++c}}if(null!==f)for(s=c-f,c=7;0!==c&&s>0;)u=a[c],a[c--]=a[f+s-1],a[f+--s]=u;else if(8!==c)return;return a}(K(t,1,-1)),!n)return Y;this.host=n}else if(this.isSpecial()){if(t=function(t){if(!P(ft,t))return""===t?null:g(t);var n,i,r,e=d(t),o="";for(n=0;n<e.length;n++){if(i=l(e[n],0),dt(i))return null;ht(i)||(o+=(r=vt(i))===i?e[n]:M(r))}return""===o?null:g(o)}(A(t)),null===t||P(ot,t))return Y;if(function(t){var n,i,r=H(t,".");if(""===r[r.length-1]){if(1===r.length)return!1;r.length--}return n=r[r.length-1],!!P(rt,n)||!!P(nt,n)&&(""===(i=K(n,2))||!!P(et,i))}(t)){if(n=function(t){var n,i,r,e,o,s,u,a=H(t,".");if(a.length&&""===a[a.length-1]&&a.length--,(n=a.length)>4)return null;for(i=[],r=0;r<n;r++){if(""===(e=a[r]))return null;if(o=10,e.length>1&&"0"===U(e,0)&&(o=P(nt,e)?16:8,e=K(e,8===o?1:2)),""===e)s=0;else{if(!P(10===o?rt:8===o?it:et,e))return null;s=C(e,o)}V(i,s)}for(r=0;r<n;r++)if(s=i[r],r===n-1){if(s>=R(256,5-n))return null}else if(s>255)return null;for(u=G(i),r=0;r<i.length;r++)u+=i[r]*R(256,3-r);return u}(t),null===n)return Y;this.host=n}else this.host=t}else{if(P(st,t))return Y;for(n="",i=d(t),r=0;r<i.length;r++)n+=Et(i[r],gt);this.host=n}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return f(_t,this.scheme)},shortenPath:function(){var t=this.path,n=t.length;!n||"file"===this.scheme&&1===n&&It(t[0],!0)||t.length--},serialize:function(){var t=this,n=t.scheme,i=t.username,r=t.password,e=t.host,o=t.port,s=t.path,u=t.query,a=t.fragment,c=n+":";return null!==e?(c+="//",t.includesCredentials()&&(c+=i+(r?":"+r:"")+"@"),c+=lt(e),null!==o&&(c+=":"+o)):"file"===n&&(c+="//"),null===e&&!t.cannotBeABaseURL&&s.length>1&&""===s[0]&&(c+="/."),c+=t.cannotBeABaseURL?s[0]:s.length?"/"+L(s,"/"):"",null!==u&&(c+="?"+u),null!==a&&(c+="#"+a),c},setHref:function(t){var n=this.parse(t);if(n)throw new D(n);this.searchParams.update()},getOrigin:function(){var t=this.scheme,n=this.port;if("blob"===t)try{return new Yt(this.path[0]).origin}catch(t){return"null"}return"file"!==t&&this.isSpecial()?t+"://"+lt(this.host)+(null!==n?":"+n:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(p(t)+":",Ot)},getUsername:function(){return this.username},setUsername:function(t){var n=d(p(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<n.length;i++)this.username+=Et(n[i],bt)}},getPassword:function(){return this.password},setPassword:function(t){var n=d(p(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<n.length;i++)this.password+=Et(n[i],bt)}},getHost:function(){var t=this.host,n=this.port;return null===t?"":null===n?lt(t):lt(t)+":"+n},setHost:function(t){this.cannotBeABaseURL||this.parse(t,Ft)},getHostname:function(){var t=this.host;return null===t?"":lt(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Gt)},getPort:function(){var t=this.port;return null===t?"":p(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""===(t=p(t))?this.port=null:this.parse(t,jt))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+L(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,Ht))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""===(t=p(t))?this.query=null:("?"===U(t,0)&&(t=K(t,1)),this.query="",this.parse(t,qt)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!==(t=p(t))?("#"===U(t,0)&&(t=K(t,1)),this.fragment="",this.parse(t,Xt)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Yt=function(t){var n=c(this,Jt),r=y(arguments.length,1)>1?arguments[1]:void 0,e=_(n,new $t(t,!1,r));i||(n.href=e.serialize(),n.origin=e.getOrigin(),n.protocol=e.getProtocol(),n.username=e.getUsername(),n.password=e.getPassword(),n.host=e.getHost(),n.hostname=e.getHostname(),n.port=e.getPort(),n.pathname=e.getPathname(),n.search=e.getSearch(),n.searchParams=e.getSearchParams(),n.hash=e.getHash())},Jt=Yt.prototype,Qt=function(t,n){return{get:function(){return I(this)[t]()},set:n&&function(t){return I(this)[n](t)},configurable:!0,enumerable:!0}};if(i&&(a(Jt,"href",Qt("serialize","setHref")),a(Jt,"origin",Qt("getOrigin")),a(Jt,"protocol",Qt("getProtocol","setProtocol")),a(Jt,"username",Qt("getUsername","setUsername")),a(Jt,"password",Qt("getPassword","setPassword")),a(Jt,"host",Qt("getHost","setHost")),a(Jt,"hostname",Qt("getHostname","setHostname")),a(Jt,"port",Qt("getPort","setPort")),a(Jt,"pathname",Qt("getPathname","setPathname")),a(Jt,"search",Qt("getSearch","setSearch")),a(Jt,"searchParams",Qt("getSearchParams")),a(Jt,"hash",Qt("getHash","setHash"))),u(Jt,"toJSON",function(){return I(this).serialize()},{enumerable:!0}),u(Jt,"toString",function(){return I(this).serialize()},{enumerable:!0}),N){var Zt=N.createObjectURL,tn=N.revokeObjectURL;Zt&&u(Yt,"createObjectURL",o(Zt,N)),tn&&u(Yt,"revokeObjectURL",o(tn,N))}return w(Yt,"URL"),n({global:!0,constructor:!0,forced:!r,sham:!i},{URL:Yt}),Nh}Vh||(Vh=1,Kh());var qh,Xh,$h,Yh={};function Jh(){if(Xh)return qh;Xh=1;var t=k();return qh=function(n,i){var r=t[n],e=r&&r.prototype;return e&&e[i]}}!function(){if($h)return Yh;$h=1;var t=Sr(),n=B(),i=Jh()("URL","toString");t({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return n(i,this)}})}();var Qh;Qh||(Qh=1,Wh());var Zh,td,nd,id,rd,ed,od,sd,ud,ad,cd,fd={};function hd(){if(td)return Zh;td=1;var t=Kn();return Zh=function(){var n=t(this),i="";return n.hasIndices&&(i+="d"),n.global&&(i+="g"),n.ignoreCase&&(i+="i"),n.multiline&&(i+="m"),n.dotAll&&(i+="s"),n.unicode&&(i+="u"),n.unicodeSets&&(i+="v"),n.sticky&&(i+="y"),i}}function dd(){if(id)return nd;id=1;var t=G(),n=k().RegExp,i=t(function(){var t=n("a","y");return t.lastIndex=2,null!==t.exec("abcd")}),r=i||t(function(){return!n("a","y").sticky}),e=i||t(function(){var t=n("^r","gy");return t.lastIndex=2,null!==t.exec("str")});return nd={BROKEN_CARET:e,MISSED_STICKY:r,UNSUPPORTED_Y:i}}function vd(){if(ed)return rd;ed=1;var t=G(),n=k().RegExp;return rd=t(function(){var t=n(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)})}function ld(){if(sd)return od;sd=1;var t=G(),n=k().RegExp;return od=t(function(){var t=n("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")})}function gd(){if(ad)return ud;ad=1;var t,n,i=B(),r=Rt(),e=of(),o=hd(),s=dd(),u=On(),a=ue(),c=gi().get,f=vd(),h=ld(),d=u("native-string-replace",String.prototype.replace),v=RegExp.prototype.exec,l=v,g=r("".charAt),m=r("".indexOf),p=r("".replace),w=r("".slice),y=(n=/b*/g,i(v,t=/a/,"a"),i(v,n,"a"),0!==t.lastIndex||0!==n.lastIndex),b=s.BROKEN_CARET,E=void 0!==/()??/.exec("")[1],_=function(t,n){for(var i=t.groups=a(null),r=0;r<n.length;r++){var e=n[r];i[e[0]]=t[e[1]]}};return(y||E||b||f||h)&&(l=function(t){var n,r,s,u=this,a=c(u),f=e(t),h=a.raw;if(h)return h.lastIndex=u.lastIndex,n=i(l,h,f),u.lastIndex=h.lastIndex,n&&a.groups&&_(n,a.groups),n;var I=a.groups,T=b&&u.sticky,S=i(o,u),A=u.source,O=0,N=f;if(T){S=p(S,"y",""),-1===m(S,"g")&&(S+="g"),N=w(f,u.lastIndex);var k=u.lastIndex>0&&g(f,u.lastIndex-1);u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==k&&"\r"!==k&&"\u2028"!==k&&"\u2029"!==k)&&(A="(?: (?:"+A+"))",N=" "+N,O++),r=new RegExp("^(?:"+A+")",S)}E&&(r=new RegExp("^"+A+"$(?!\\s)",S)),y&&(s=u.lastIndex);var D=i(v,T?r:u,N);return T?D?(D.input=f,D[0]=w(D[0],O),D.index=u.lastIndex,u.lastIndex+=D[0].length):u.lastIndex=0:y&&D&&(u.lastIndex=u.global?D.index+D[0].length:s),E&&D&&D.length>1&&i(d,D[0],r,function(){for(var t=1;t<arguments.length-2;t++)void 0===arguments[t]&&(D[t]=void 0)}),D&&I&&_(D,I),D}),ud=l}function md(){if(cd)return fd;cd=1;var t=Sr(),n=gd();return t({target:"RegExp",proto:!0,forced:/./.exec!==n},{exec:n}),fd}md();var pd,wd,yd,bd,Ed,_d,Id,Td,Sd,Ad,Od,Nd,kd,Dd={};function Cd(){if(wd)return pd;wd=1,md();var t=B(),n=pi(),i=gd(),r=G(),e=Cn(),o=Xn(),s=e("species"),u=RegExp.prototype;return pd=function(a,c,f,h){var d=e(a),v=!r(function(){var t={};return t[d]=function(){return 7},7!==""[a](t)}),l=v&&!r(function(){var t=!1,n=/a/;if("split"===a){var i={};i[s]=function(){return n},(n={constructor:i,flags:""})[d]=/./[d]}return n.exec=function(){return t=!0,null},n[d](""),!t});if(!v||!l||f){var g=/./[d],m=c(d,""[a],function(n,r,e,o,s){var a=r.exec;return a===i||a===u.exec?v&&!s?{done:!0,value:t(g,r,e,o)}:{done:!0,value:t(n,e,r,o)}:{done:!1}});n(String.prototype,a,m[0]),n(u,d,m[1])}h&&o(u[d],"sham",!0)},pd}function xd(){if(bd)return yd;bd=1;var t=Tf().charAt;return yd=function(n,i,r){return i+(r&&t(n,i).length||1)}}function Rd(){if(_d)return Ed;_d=1;var t=Rt(),n=Nn(),i=Math.floor,r=t("".charAt),e=t("".replace),o=t("".slice),s=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,u=/\$([$&'`]|\d{1,2})/g;return Ed=function(t,a,c,f,h,d){var v=c+t.length,l=f.length,g=u;return void 0!==h&&(h=n(h),g=s),e(d,g,function(n,e){var s;switch(r(e,0)){case"$":return"$";case"&":return t;case"`":return o(a,0,c);case"'":return o(a,v);case"<":s=h[o(e,1,-1)];break;default:var u=+e;if(0===u)return n;if(u>l){var d=i(u/10);return 0===d?n:d<=l?void 0===f[d-1]?r(e,1):f[d-1]+r(e,1):n}s=f[u-1]}return void 0===s?"":s})}}function Md(){if(Ad)return Sd;Ad=1;var t=B(),n=kn(),i=Bt(),r=function(){if(Td)return Id;Td=1;var t=k(),n=G(),i=t.RegExp,r=!n(function(){var t=!0;try{i(".","d")}catch(n){t=!1}var n={},r="",e=t?"dgimsy":"gimsy",o=function(t,i){Object.defineProperty(n,t,{get:function(){return r+=i,!0}})},s={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var u in t&&(s.hasIndices="d"),s)o(u,s[u]);return Object.getOwnPropertyDescriptor(i.prototype,"flags").get.call(n)!==e||r!==e});return Id={correct:r}}(),e=hd(),o=RegExp.prototype;return Sd=r.correct?function(t){return t.flags}:function(s){return r.correct||!i(o,s)||n(s,"flags")?s.flags:t(e,s)}}function Ud(){if(Nd)return Od;Nd=1;var t=B(),n=Kn(),i=Gt(),r=Mt(),e=gd(),o=TypeError;return Od=function(s,u){var a=s.exec;if(i(a)){var c=t(a,s,u);return null!==c&&n(c),c}if("RegExp"===r(s))return t(e,s,u);throw new o("RegExp#exec called on incompatible receiver")}}!function(){if(kd)return Dd;kd=1;var t=Go(),n=B(),i=Rt(),r=Cd(),e=G(),o=Kn(),s=Gt(),u=jt(),a=Pi(),c=Fi(),f=of(),h=Lt(),d=xd(),v=Yt(),l=Rd(),g=Md(),m=Ud(),p=Cn()("replace"),w=Math.max,y=Math.min,b=i([].concat),E=i([].push),_=i("".indexOf),I=i("".slice),T=function(t){return void 0===t?t:String(t)},S="$0"==="a".replace(/./,"$0"),A=!!/./[p]&&""===/./[p]("a","$0");r("replace",function(i,r,e){var S=A?"$":"$0";return[function(t,i){var e=h(this),o=u(t)?v(t,p):void 0;return o?n(o,t,e,i):n(r,f(e),t,i)},function(n,i){var u=o(this),h=f(n),v=s(i);v||(i=f(i));var p=f(g(u));if("string"==typeof i&&!~_(i,S)&&!~_(i,"$<")&&!~_(p,"y")){var A=e(r,u,h,i);if(A.done)return A.value}var O,N=!!~_(p,"g");N&&(O=!!~_(p,"u")||!!~_(p,"v"),u.lastIndex=0);for(var k,D=[];null!==(k=m(u,h))&&(E(D,k),N);){""===f(k[0])&&(u.lastIndex=d(h,c(u.lastIndex),O))}for(var C="",x=0,R=0;R<D.length;R++){for(var M,U=f((k=D[R])[0]),P=w(y(a(k.index),h.length),0),L=[],F=1;F<k.length;F++)E(L,T(k[F]));var G=k.groups;if(v){var j=b([U],L,P,h);void 0!==G&&E(j,G),M=f(t(i,void 0,j))}else M=l(U,h,P,L,G,i);P>=x&&(C+=I(h,x,P)+M,x=P+U.length)}return C+I(h,x)}]},!!e(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")})||!S||A)}();var Pd,Ld={};!function(){if(Pd)return Ld;Pd=1;var t,n=Sr(),i=Hr(),r=Pn().f,e=Fi(),o=of(),s=wf(),u=Lt(),a=yf(),c=Tn(),f=i("".slice),h=Math.min,d=a("startsWith");n({target:"String",proto:!0,forced:!!(c||d||(t=r(String.prototype,"startsWith"),!t||t.writable))&&!d},{startsWith:function(t){var n=o(u(this));s(t);var i=o(t),r=e(h(arguments.length>1?arguments[1]:void 0,n.length));return f(n,r,r+i.length)===i}})}();var Fd,Gd,jd,Vd=function(){function t(t){this.baseUrl=t.baseUrl.replace(/\/$/,"")}return t.prototype.request=function(t){return Qs(this,arguments,void 0,function(t,n){var i,r,e,o,s,u,a,c,f,h,d;return void 0===n&&(n={}),Zs(this,function(v){switch(v.label){case 0:i=n.method,r=void 0===i?"GET":i,e=n.headers,o=void 0===e?{}:e,s=n.body,u=!t||t.startsWith("/")?t:"/".concat(t),a="".concat(this.baseUrl).concat(u),v.label=1;case 1:return v.trys.push([1,6,,7]),c={method:r,headers:Js({"Content-Type":"application/json"},o),body:s?JSON.stringify(s):null},[4,fetch(a,c)];case 2:return(f=v.sent()).ok?[3,4]:[4,f.text()];case 3:throw h=v.sent(),new Error("HTTP ".concat(f.status,": ").concat(f.statusText," - ").concat(h));case 4:return[4,f.json()];case 5:return[2,v.sent()];case 6:throw d=v.sent(),this.handleError(d);case 7:return[2]}})})},t.prototype.handleError=function(t){return t instanceof Error?"AbortError"===t.name?{code:yu,message:"Request timeout",details:t}:t.message.includes("HTTP 401")||t.message.includes("HTTP 403")?{code:wu,message:"Authentication failed",details:t}:(t.message.includes("HTTP"),{code:yu,message:t.message,details:t}):{code:yu,message:"Unknown error: ".concat(String(t)),details:t}},t.prototype.get=function(t){return Qs(this,arguments,void 0,function(t,n){return void 0===n&&(n={}),Zs(this,function(i){return[2,this.request(t,Js(Js({},n),{method:"GET"}))]})})},t.prototype.post=function(t,n){return Qs(this,arguments,void 0,function(t,n,i){return void 0===i&&(i={}),Zs(this,function(r){return[2,this.request(t,Js(Js({},i),{method:"POST",body:n}))]})})},t.prototype.put=function(t,n){return Qs(this,arguments,void 0,function(t,n,i){return void 0===i&&(i={}),Zs(this,function(r){return[2,this.request(t,Js(Js({},i),{method:"PUT",body:n}))]})})},t.prototype.delete=function(t){return Qs(this,arguments,void 0,function(t,n){return void 0===n&&(n={}),Zs(this,function(i){return[2,this.request(t,Js(Js({},n),{method:"DELETE"}))]})})},t}(),Bd="/user/v1/user/sdk",zd="/reward/v1.1/user",Hd="/entrypoints/v1/list",Wd=function(){function t(t,n){this.http=new Vd({baseUrl:t}),this.logger=n}return t.prototype.getToken=function(t,n,i,r,e){return Qs(this,void 0,void 0,function(){var o,s=this;return Zs(this,function(u){return o=Js(Js(Js(Js(Js(Js({writeKey:t,userId:n,userState:i,appType:"WEB",sdkVersion:za},r&&{anonymousId:r}),(null==e?void 0:e.name)&&{name:e.name}),(null==e?void 0:e.email)&&{email:e.email}),(null==e?void 0:e.mobile)&&{mobile:e.mobile}),(null==e?void 0:e.country)&&{country:e.country}),(null==e?void 0:e.customAttributes)&&{customAttributes:e.customAttributes}),[2,this.withRetry(function(){return Qs(s,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return[4,this.http.post("".concat(Bd,"?token=true"),o)];case 1:return[2,t.sent().data.token]}})})},"getToken")]})})},t.prototype.getCampaigns=function(t){return Qs(this,void 0,void 0,function(){var n=this;return Zs(this,function(i){return[2,this.withRetry(function(){return Qs(n,void 0,void 0,function(){var n;return Zs(this,function(i){switch(i.label){case 0:return[4,this.http.get(zd,{headers:{Authorization:"Bearer ".concat(t)}})];case 1:return n=i.sent(),[2,this.normalizeCampaigns(n)]}})})},"getCampaigns")]})})},t.prototype.getEntryPoints=function(t){return Qs(this,void 0,void 0,function(){var n=this;return Zs(this,function(i){return[2,this.withRetry(function(){return Qs(n,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return[4,this.http.get("".concat(Hd,"?consumer=WEB"),{headers:{Authorization:"Bearer ".concat(t)}})];case 1:return[2,n.sent().data]}})})},"getEntryPoints")]})})},t.prototype.normalizeCampaigns=function(t){var n,i,r,e=[],o={};try{for(var s=tu(t.campaigns),u=s.next();!u.done;u=s.next()){var a=u.value;e.push(a.campaignId),o[a.campaignId]=a}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return{allIds:e,byId:o,defaultUrl:t.defaultUrl,base:this.extractBase(t.defaultUrl),loyaltyUrls:null!==(r=t.loyaltyUrls)&&void 0!==r?r:[]}},t.prototype.extractBase=function(t){try{var n=new URL(t);return"".concat(n.protocol,"//").concat(n.host)}catch(t){return""}},t.prototype.isAuthError=function(t){return"object"===Ha(t)&&null!==t&&t.code===wu},t.prototype.withRetry=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:r=function(r){var o,s,u;return Zs(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,5]),o={},[4,t()];case 1:return[2,(o.value=a.sent(),o)];case 2:if(s=a.sent(),i=s,e.logger.warn("".concat(Pf," — ").concat(n," attempt ").concat(r,"/").concat(5),s),e.isAuthError(s))throw s;return r<5?(u=Math.min(fh*Math.pow(2,r-1),hh),[4,new Promise(function(t){return setTimeout(t,u)})]):[3,4];case 3:a.sent(),a.label=4;case 4:return[3,5];case 5:return[2]}})},e=this,o=1,u.label=1;case 1:return o<=5?[5,r(o)]:[3,4];case 2:if("object"===Ha(s=u.sent()))return[2,s.value];u.label=3;case 3:return o++,[3,1];case 4:throw i}})})},t}(),Kd={};function qd(){if(Gd)return Fd;Gd=1;var t=j(),n=G(),i=Rt(),r=cc(),e=oe(),o=Ft(),s=i(Ct().f),u=i([].push),a=t&&n(function(){var t=Object.create(null);return t[2]=2,!s(t,2)}),c=function(n){return function(i){for(var c,f=o(i),h=e(f),d=a&&null===r(f),v=h.length,l=0,g=[];v>l;)c=h[l++],t&&!(d?c in f:s(f,c))||u(g,n?[c,f[c]]:f[c]);return g}};return Fd={entries:c(!0),values:c(!1)}}!function(){if(jd)return Kd;jd=1;var t=Sr(),n=qd().entries;t({target:"Object",stat:!0},{entries:function(t){return n(t)}})}();var Xd={EMBEDDED:"EMBED",POP_UP:"POP_UP",BOTTOM_SHEET:"BOTTOM_SHEET",ICON_BUTTON:"FLOATING",CHAT_BOX:"CHAT_BOX",NATIVE_BANNER:"BANNER"};function $d(t){var n,i=(n=t.container.typeId,Xd[n]);return"EMBED"===i&&"STATIC"===t.content.typeId?"BANNER":i}function Yd(t){return"NATIVE_BANNER"===t.container.typeId||"EMBEDDED"===t.container.typeId?"content":"CAMPAIGN"===t.content.typeId?"game":null}function Jd(t){return t.toFixed(2)}function Qd(t){var n=null==t?void 0:t.campaignId;if("string"==typeof n)return n;if(Array.isArray(n)){var i=n[0];if("string"==typeof i)return i}return null}function Zd(t){var n,i,r=t.content;if("CAMPAIGN"===r.typeId)return null!==(n=r.campaignId)&&void 0!==n?n:Qd(r.conditions);if("NUDGE"===r.typeId||"PROGRAM"===r.typeId)return null!==(i=r.campaignId)&&void 0!==i?i:null;if("STATIC"===r.typeId&&r.action){var e=r.action;if("TOGGLE_CONTAINER_CONTENT"===e.type||"OPEN_CONTAINER_CONTENT"===e.type)return Qd(e.content.conditions)}return null}var tv={LAUNCHER_ICON:"ICON_BUTTON",BOTTOM_SHEET:"BOTTOM_SHEET",POP_UP:"POP_UP",EMBEDDED:"EMBEDDED",CHAT_BOX:"CHAT_BOX",NATIVE_BANNER:"NATIVE_BANNER"};function nv(t){var n,i;if("string"==typeof t.p&&t.p.length>0)return t.p;try{for(var r=tu(Object.entries(t)),e=r.next();!e.done;e=r.next()){var o=nu(e.value,2),s=o[0],u=o[1];if("_id"===s&&"string"==typeof u&&u.length>0)return u}}catch(t){n={error:t}}finally{try{e&&!e.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}function iv(t,n){var i;return Js(Js(Js(Js(Js(Js(Js(Js(Js({typeId:null!==(i=null==t?void 0:t.typeId)&&void 0!==i?i:""},void 0!==n&&{campaignId:n}),void 0!==(null==t?void 0:t.src)&&{src:t.src}),void 0!==(null==t?void 0:t.state)&&{state:t.state}),void 0!==(null==t?void 0:t.action)&&{action:t.action}),void 0!==(null==t?void 0:t.conditions)&&{conditions:t.conditions}),void 0!==(null==t?void 0:t.IWidgetState)&&{IWidgetState:t.IWidgetState}),void 0!==(null==t?void 0:t.widgetCss)&&{widgetCss:t.widgetCss}),void 0!==(null==t?void 0:t.progressBarIcon)&&{progressBarIcon:t.progressBarIcon}),void 0!==(null==t?void 0:t.progressMeterIcon)&&{progressMeterIcon:t.progressMeterIcon})}function rv(t){var n,i,r,e,o=t.web,s=o.container,u=o.content,a=o.conditions,c=u[0],f=null==a?void 0:a.backgroundOpacity,h=null!=f?s.css.replace("{{backgroundOpacity}}",String(f)):s.css,d=null!==(i=null!==(n=null==c?void 0:c.campaignId)&&void 0!==n?n:Qd(null==c?void 0:c.conditions))&&void 0!==i?i:void 0;return Js(Js(Js({id:null!==(r=nv(t))&&void 0!==r?r:""},void 0!==t.name&&{name:t.name}),{container:{typeId:null!==(e=tv[s.typeId])&&void 0!==e?e:s.typeId,css:h,height:s.height,elementHookId:s.elementId},content:iv(c,d)}),void 0!==a&&{conditions:a})}function ev(t){var n,i,r=[],e={};try{for(var o=tu(t),s=o.next();!s.done;s=o.next()){var u=rv(s.value);r.push(u.id),e[u.id]=u}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return{allIds:r,byId:e}}var ov,sv,uv,av={};function cv(){if(sv)return ov;sv=1;var t=Go(),n=Ft(),i=Pi(),r=Gi(),e=ve(),o=Math.min,s=[].lastIndexOf,u=!!s&&1/[1].lastIndexOf(1,-0)<0,a=e("lastIndexOf");return ov=u||!a?function(e){if(u)return t(s,this,arguments)||0;var a=n(this),c=r(a);if(0===c)return-1;var f=c-1;for(arguments.length>1&&(f=o(f,i(arguments[1]))),f<0&&(f=c+f);f>=0;f--)if(f in a&&a[f]===e)return f||0;return-1}:s,ov}!function(){if(uv)return av;uv=1;var t=Sr(),n=cv();t({target:"Array",proto:!0,forced:n!==[].lastIndexOf},{lastIndexOf:n})}();var fv,hv={};!function(){if(fv)return hv;fv=1;var t=Sr(),n=Ar(),i=xr(),r=jt(),e=Li(),o=Gi(),s=Ft(),u=Nr(),a=kr(),c=Cn(),f=Ur(),h=jo(),d=f("slice"),v=c("species"),l=Array,g=Math.max;t({target:"Array",proto:!0,forced:!d},{slice:function(t,c){var f,d,m,p=s(this),w=o(p),y=e(t,w),b=e(void 0===c?w:c,w);if(n(p)&&(f=p.constructor,(i(f)&&(f===l||n(f.prototype))||r(f)&&null===(f=f[v]))&&(f=void 0),f===l||void 0===f))return h(p,y,b);for(d=new(void 0===f?l:f)(g(b-y,0)),m=0;y<b;y++,m++)y in p&&u(d,m,p[y]);return a(d,m),d}})}();var dv,vv,lv,gv={};function mv(){if(vv)return dv;vv=1;var t=qn().f;return dv=function(n,i,r){r in n||t(n,r,{configurable:!0,get:function(){return i[r]},set:function(t){i[r]=t}})}}!function(){if(lv)return gv;lv=1;var t=j(),n=k(),i=Rt(),r=Tr(),e=Wc(),o=Xn(),s=ue(),u=zi().f,a=Bt(),c=pf(),f=of(),h=Md(),d=dd(),v=mv(),l=pi(),g=G(),m=kn(),p=gi().enforce,w=Uo(),y=Cn(),b=vd(),E=ld(),_=y("match"),I=n.RegExp,T=I.prototype,S=n.SyntaxError,A=i(T.exec),O=i("".charAt),N=i("".replace),D=i("".indexOf),C=i("".slice),x=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,R=/a/g,M=/a/g,U=new I(R)!==R,P=d.MISSED_STICKY,L=d.UNSUPPORTED_Y,F=t&&(!U||P||b||E||g(function(){return M[_]=!1,I(R)!==R||I(M)===M||"/a/i"!==String(I(R,"i"))}));if(r("RegExp",F)){for(var V=function(t,n){var i,r,u,d,v,l,g=a(T,this),w=c(t),y=void 0===n,_=[],k=t;if(!g&&w&&y&&t.constructor===V)return t;if((w||a(T,t))&&(t=t.source,y&&(n=h(k))),t=void 0===t?"":f(t),n=void 0===n?"":f(n),k=t,b&&"dotAll"in R&&(r=!!n&&D(n,"s")>-1)&&(n=N(n,/s/g,"")),i=n,P&&"sticky"in R&&(u=!!n&&D(n,"y")>-1)&&L&&(n=N(n,/y/g,"")),E&&(d=function(t){for(var n,i=t.length,r=0,e="",o=[],u=s(null),a=!1,c=!1,f=0,h="";r<i;r++){if("\\"===(n=O(t,r))){if(n+=O(t,++r),!c&&"\\"===O(n,1)){e+="\\x5c";continue}}else if("]"===n)a=!1;else if(!a)switch(!0){case"["===n:a=!0;break;case"("===n:e+=n,A(x,C(t,r+1))?(r+=2,c=!0,f++):"?"!==O(t,r+1)&&f++;continue;case">"===n&&c:if(""===h||m(u,h))throw new S("Invalid capture group name");u[h]=!0,o[o.length]=[h,f],c=!1,h="";continue}c?h+=n:e+=n}for(var d=0;d<o.length;d++)for(var v="\\k<"+o[d][0]+">",l="\\"+o[d][1];D(e,v)>-1;)e=N(e,v,l);return[e,o]}(t),t=d[0],_=d[1]),v=e(I(t,n),g?this:T,V),(r||u||_.length)&&(l=p(v),r&&(l.dotAll=!0,l.raw=V(function(t){for(var n,i=t.length,r=0,e="",o=!1;r<i;r++)"\\"!==(n=O(t,r))?o||"."!==n?("["===n?o=!0:"]"===n&&(o=!1),e+=n):e+="[\\s\\S]":e+=n+O(t,++r);return e}(t),i)),u&&(l.sticky=!0),_.length&&(l.groups=_)),t!==k)try{o(v,"source",""===k?"(?:)":k)}catch(t){}return v},B=u(I),z=0;B.length>z;)v(V,I,B[z++]);T.constructor=V,V.prototype=T,l(n,"RegExp",V,{constructor:!0})}w("RegExp")}();var pv,wv={};!function(){if(pv)return wv;pv=1;var t=hi().PROPER,n=pi(),i=Kn(),r=of(),e=G(),o=Md(),s="toString",u=RegExp.prototype,a=u[s],c=e(function(){return"/a/b"!==a.call({source:"a",flags:"b"})}),f=t&&a.name!==s;(c||f)&&n(u,s,function(){var t=i(this);return"/"+r(t.source)+"/"+r(o(t))},{unsafe:!0})}();var yv,bv={};!function(){if(yv)return bv;yv=1;var t,n=Sr(),i=Hr(),r=Pn().f,e=Fi(),o=of(),s=wf(),u=Lt(),a=yf(),c=Tn(),f=i("".slice),h=Math.min,d=a("endsWith");n({target:"String",proto:!0,forced:!!(c||d||(t=r(String.prototype,"endsWith"),!t||t.writable))&&!d},{endsWith:function(t){var n=o(u(this));s(t);var i=o(t),r=arguments.length>1?arguments[1]:void 0,a=n.length,c=void 0===r?a:h(e(r),a);return f(n,c-i.length,c)===i}})}();var Ev,_v,Iv,Tv,Sv,Av,Ov,Nv={};function kv(){return _v?Ev:(_v=1,Ev="\t\n\v\f\r \u2028\u2029\ufeff")}function Dv(){if(Tv)return Iv;Tv=1;var t=Rt(),n=Lt(),i=of(),r=kv(),e=t("".replace),o=RegExp("^["+r+"]+"),s=RegExp("(^|[^"+r+"])["+r+"]+$"),u=function(t){return function(r){var u=i(n(r));return 1&t&&(u=e(u,o,"")),2&t&&(u=e(u,s,"$1")),u}};return Iv={start:u(1),end:u(2),trim:u(3)}}!function(){if(Ov)return Nv;Ov=1;var t=Sr(),n=Dv().trim,i=function(){if(Av)return Sv;Av=1;var t=hi().PROPER,n=G(),i=kv();return Sv=function(r){return n(function(){return!!i[r]()||"
"!=="
"[r]()||t&&i[r].name!==r})}}();t({target:"String",proto:!0,forced:i("trim")},{trim:function(){return n(this)}})}();var Cv="/*";function xv(t){return t.startsWith("#/")||t.startsWith("#!/")}function Rv(t){try{return decodeURIComponent(t)}catch(n){return t}}function Mv(t){return t.replace(/^\/+|\/+$/g,"").split("/").filter(Boolean).map(Rv)}function Uv(t){try{return new URL(t)}catch(t){return null}}function Pv(t,n){if(n.length>t.length)return-1;t:for(var i=0;i<=t.length-n.length;i++){for(var r=0;r<n.length;r++)if(t[i+r]!==n[r])continue t;return i}return-1}function Lv(t,n){var i=n.endsWith(Cv),r=i?n.slice(0,-2):n;if(""===r)return!1;if("/"===r)return!i&&0===t.length;var e=Mv(r),o=Pv(t,e);return-1!==o&&(!i||o+e.length<t.length)}function Fv(t,n){var i=function(t){var n=t.trim();if("*"===n||n===Cv)return"*";if(""===n)return"";var i=n.replace(/^\/+|\/+$/g,"");return""===i?"/":i}(n);if("*"===i)return!0;var r=t.indexOf("#"),e=-1===r?t:t.slice(0,r),o=-1===r?"":t.slice(r),s=e.replace(/\?.*$/,""),u=function(t){if(!t.startsWith("/"))return null;var n=t.lastIndexOf("/");if(n<=1)return null;var i=t.slice(1,n),r=t.slice(n+1);if(!/[*+?^${}()|[\]\\]/.test(i))return null;try{return new RegExp(i,r)}catch(t){return null}}(n.trim());if(u){var a=xv(o)?s+o:s;return u.test(a)}var c=function(t,n){if(!/^https?:\/\//i.test(t))return null;var i=Uv(n);if(!i)return!1;var r=t.endsWith(Cv),e=Uv(r?t.slice(0,-2):t);if(!e)return!1;if(i.origin!==e.origin)return!1;if(!r)return i.pathname.replace(/\/+$/,"")===e.pathname.replace(/\/+$/,"");var o=Mv(i.pathname),s=Mv(e.pathname),u=Pv(o,s);return 0===u&&u+s.length<o.length}(i,s);if(null!==c)return c;var f=Uv(t);return!!Lv(Mv(f?f.pathname:s),i)||!!xv(o)&&Lv(Mv(o.replace(/^#!?\//,"").replace(/\?.*$/,"")),i)}function Gv(t,n){var i,r;try{for(var e=tu(n),o=e.next();!o.done;o=e.next()){if(Fv(t,o.value))return!0}}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=e.return)&&r.call(e)}finally{if(i)throw i.error}}return!1}function jv(t,n){return"".concat(sh).concat(null!=n?n:"anonymous","_").concat(t)}function Vv(t,n,i,r){return Qs(this,void 0,void 0,function(){var e,o,s;return Zs(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),[4,i.get(jv(t,n))];case 1:return(e=u.sent())?(o=JSON.parse(e),[2,(a=o,"object"===Ha(a)&&null!==a&&"number"==typeof a.count&&"string"==typeof a.date?o:null)]):[2,null];case 2:return s=u.sent(),r.warn("Failed to read entry point count state",{entryPointId:t,error:s}),[2,null];case 3:return[2]}var a})})}function Bv(t,n){var i=t.entryPointId,r=t.userId,e=t.saveDelayMs,o=t.storageManager,s=t.logger,u=t.pendingTimers,a=setTimeout(function(){null==u||u.delete(a),o.set(jv(i,r),JSON.stringify(n)).catch(function(t){s.warn("Failed to persist entry point count state",{entryPointId:i,error:t})})},e);null==u||u.add(a)}function zv(t){var n=t.count,i=t.countState,r=t.now;return i&&r.getDate()===new Date(i.date).getDate()?!(i.count>=n)&&(Bv(t,{count:i.count+1,date:r.toISOString()}),!0):(Bv(t,{count:1,date:r.toISOString()}),!0)}function Hv(t){var n=t.count,i=t.countState,r=t.now;return!(i&&i.count>=n)&&(Bv(t,{count:i?i.count+1:1,date:r.toISOString()}),!0)}function Wv(t,n,i,r,e,o){return Qs(this,void 0,void 0,function(){var s,u,a,c,f,h,d,v,l,g,m,p,w,y;return Zs(this,function(b){switch(b.label){case 0:return null===(s=t.conditions)?[2,!1]:s?(u=s.paths,a=s.showCount,c=s.timeWindow,f=s.isLoggedIn,h=s.backendValidations,d=s.delay,v=new Date,l=null!=o?o:"undefined"!=typeof window?window.location.href:"",f&&!n?[2,!1]:function(t,n){if(!t)return!0;var i=n.valueOf();return i>=new Date(t.start).valueOf()&&i<=new Date(t.end).valueOf()}(c,v)&&function(t,n){var i,r;if(!t)return!0;var e=null!==(i=t.excludePaths)&&void 0!==i?i:[],o=null!==(r=t.includePaths)&&void 0!==r?r:[];return!(e.length&&Gv(n,e)||o.length&&!Gv(n,o))}(u,l)?"INVALID"===h?[2,!1]:a?(g=a.count,m=a.dailyRefresh,p=d?1e3*d:0,[4,Vv(t.id,n,i,r)]):[2,!0]:[2,!1]):[2,!0];case 1:return w=b.sent(),y=Js({entryPointId:t.id,userId:n,count:g,countState:w,now:v,saveDelayMs:p,storageManager:i,logger:r},void 0!==e&&{pendingTimers:e}),[2,m?zv(y):Hv(y)]}})})}var Kv,qv={};!function(){if(Kv)return qv;Kv=1;var t=Sr(),n=qd().values;t({target:"Object",stat:!0},{values:function(t){return n(t)}})}();var Xv={iframe:{className:"__GLU__IFRAME",css:".__GLU__IFRAME{ height: 100%; width: 100%; border: none !important; outline: none; }"},hideScroll:{className:"__GLU_HIDE_SCROLL",css:".__GLU_HIDE_SCROLL::-moz-focus-inner {border: 0;} .__GLU_HIDE_SCROLL::-webkit-scrollbar {width: 0px !important;background: transparent !important;display: none !important;} .__GLU_HIDE_SCROLL {scrollbar-width: none !important;-ms-overflow-style: -ms-autohiding-scrollbar !important;}"},slideUp:{className:"__GLU__SLIDE_UP",css:".__GLU__SLIDE_UP { animation: GLU_SLIDE_UP 300ms ease-out; } @keyframes GLU_SLIDE_UP { from { opacity: 0; transform: translateY(100px); }to { opacity: 1; transform: translateY(0px); }}"},slideDown:{className:"__GLU__SLIDE_DOWN",css:".__GLU__SLIDE_DOWN { animation: GLU_SLIDE_DOWN 300ms ease-out; } @keyframes GLU_SLIDE_DOWN { from { opacity: 1; transform: translateY(0px); }to { opacity: 0; transform: translateY(100px); }}"},slideUpSheet:{className:"__GLU__SLIDE_UP_SHEET",css:".__GLU__SLIDE_UP_SHEET { animation: GLU_SLIDE_UP_SHEET 300ms ease-out; } @keyframes GLU_SLIDE_UP_SHEET { from { transform: translateY(100%); } to { transform: translateY(0px); }}"},slideDownSheet:{className:"__GLU__SLIDE_DOWN_SHEET",css:".__GLU__SLIDE_DOWN_SHEET { animation: GLU_SLIDE_DOWN_SHEET 300ms ease-out forwards; } @keyframes GLU_SLIDE_DOWN_SHEET { from { transform: translateY(0px); } to { transform: translateY(100%); }}"},iconButton:{className:"__GLU__ICON_BUTTON",css:".__GLU__ICON_BUTTON { position: fixed; bottom: 40px; left: 40px; height: 160px; width: 160px; overflow: hidden; z-index: 999;}"},chatBox:{className:"__GLU__CHAT_BOX",css:".__GLU__CHAT_BOX { position: fixed; bottom: 220px; left: 40px; height: 580px; width: 360px; background-color: #fff; border-radius: 24px; overflow-x: hidden; z-index: 9999; }"},popUp:{className:"__GLU__POP_UP",css:".__GLU__POP_UP { max-height: 740px; max-width: 1000px; width: 100%; height:90%; background-color: #fff; border-radius: 12px; z-index: 999999; overflow: hidden;}"},popUpStatic:{className:"__GLU__POP_UP_STATIC",css:".__GLU__POP_UP_STATIC { max-height: 100%; max-width: 100%; background-color: #fff; border-radius: 12px; z-index: 999999; overflow: hidden;}"},backDrop:{className:"__GLU__BACK_DROP",css:".__GLU__BACK_DROP { position: fixed; bottom: 0px; left: 0px; height: 100%; width: 100vw; background-color: rgba(0,0,0,0.2); display: flex; justify-content: center; align-items: center; z-index: 99999;}"},bottomSheet:{className:"__GLU__BOTTOM_SHEET",css:".__GLU__BOTTOM_SHEET { height: 880px; width: 600px; max-width: 100%; max-height: 100%; background-color: #fff; border-radius: 20px 20px 0px 0px; overflow-x: hidden; z-index: 999999; align-self: flex-end}"},bottomSheetStatic:{className:"__GLU__BOTTOM_SHEET_STATIC",css:".__GLU__BOTTOM_SHEET_STATIC { max-width: 100%; max-height: 100%; border-radius: 20px 20px 0px 0px; overflow-x: hidden; z-index: 999999; align-self: flex-end}"},embeddedStatic:{className:"__GLU__EMBEDDED_STATIC",css:".__GLU__EMBEDDED_STATIC { width: 100%; overflow-x: hidden; }"},embedded:{className:"__GLU__EMBEDDED",css:".__GLU__EMBEDDED { width: 100%; height: 100%; overflow-x: hidden; }"}};var $v,Yv={};!function(){if($v)return Yv;$v=1;var t=Sr(),n=Ch();t({target:"Array",stat:!0,forced:!Ss()(function(t){Array.from(t)})},{from:n})}();var Jv,Qv,Zv,tl,nl,il,rl,el,ol,sl,ul,al,cl,fl,hl,dl,vl,ll,gl,ml={};function pl(){return Qv?Jv:(Qv=1,Jv="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView)}function wl(){if(tl)return Zv;tl=1;var t=Pi(),n=Fi(),i=RangeError;return Zv=function(r){if(void 0===r)return 0;var e=t(r),o=n(e);if(e!==o)throw new i("Wrong length or index");return o}}function yl(){if(sl)return ol;sl=1;var t=il?nl:(il=1,nl=Math.sign||function(t){var n=+t;return 0===n||n!=n?n:n<0?-1:1}),n=function(){if(el)return rl;el=1;var t=4503599627370496;return rl=function(n){return n+t-t}}(),i=Math.abs;return ol=function(r,e,o,s){var u=+r,a=i(u),c=t(u);if(a<s)return c*n(a/s/e)*s*e;var f=(1+e/2220446049250313e-31)*a,h=f-(f-a);return h>o||h!=h?c*(1/0):c*h}}function bl(){if(fl)return cl;fl=1;var t=Array,n=Math.abs,i=Math.pow,r=Math.floor,e=Math.log,o=Math.LN2;return cl={pack:function(s,u,a){var c,f,h,d=t(a),v=8*a-u-1,l=(1<<v)-1,g=l>>1,m=23===u?i(2,-24)-i(2,-77):0,p=s<0||0===s&&1/s<0?1:0,w=0;for((s=n(s))!=s||s===1/0?(f=s!=s?1:0,c=l):(c=r(e(s)/o),s*(h=i(2,-c))<1&&(c--,h*=2),(s+=c+g>=1?m/h:m*i(2,1-g))*h>=2&&(c++,h/=2),c+g>=l?(f=0,c=l):c+g>=1?(f=(s*h-1)*i(2,u),c+=g):(f=s*i(2,g-1)*i(2,u),c=0));u>=8;)d[w++]=255&f,f/=256,u-=8;for(c=c<<u|f,v+=u;v>0;)d[w++]=255&c,c/=256,v-=8;return d[w-1]|=128*p,d},unpack:function(t,n){var r,e=t.length,o=8*e-n-1,s=(1<<o)-1,u=s>>1,a=o-7,c=e-1,f=t[c--],h=127&f;for(f>>=7;a>0;)h=256*h+t[c--],a-=8;for(r=h&(1<<-a)-1,h>>=-a,a+=n;a>0;)r=256*r+t[c--],a-=8;if(0===h)h=1-u;else{if(h===s)return r?NaN:f?-1/0:1/0;r+=i(2,n),h-=u}return(f?-1:1)*r*i(2,h-n)}}}function El(){if(dl)return hl;dl=1;var t=Nn(),n=Li(),i=Gi();return hl=[].fill||function(r){for(var e=t(this),o=i(e),s=arguments.length,u=n(s>1?arguments[1]:void 0,o),a=s>2?arguments[2]:void 0,c=void 0===a?o:n(a,o);c>u;)e[u++]=r;return e},hl}function _l(){if(ll)return vl;ll=1;var t=k(),n=Rt(),i=j(),r=pl(),e=hi(),o=Xn(),s=Mo(),u=qc(),a=G(),c=Po(),f=Pi(),h=wl(),d=function(){if(al)return ul;al=1;var t=yl();return ul=Math.fround||function(n){return t(n,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)}}(),v=bl(),l=cc(),g=xo(),m=El(),p=jo(),w=Wc(),y=Ir(),b=Ro(),E=gi(),_=e.PROPER,I=e.CONFIGURABLE,T="ArrayBuffer",S="DataView",A="prototype",O="Wrong index",N=E.getterFor(T),D=E.getterFor(S),C=E.set,x=t[T],R=x,M=R&&R[A],U=t[S],P=U&&U[A],L=Object.prototype,F=t.Array,V=t.RangeError,B=n(m),z=n([].reverse),H=v.pack,W=v.unpack,K=function(t){return[255&t]},q=function(t){return[255&t,t>>8&255]},X=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},$=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},Y=function(t){return H(d(t),23,4)},J=function(t){return H(t,52,8)},Q=function(t,n,i){s(t[A],n,{configurable:!0,get:function(){return i(this)[n]}})},Z=function(t,n,i,r){var e=D(t),o=h(i),s=!!r;if(o+n>e.byteLength)throw new V(O);var u=e.bytes,a=o+e.byteOffset,c=p(u,a,a+n);return s?c:z(c)},tt=function(t,n,i,r,e,o){var s=D(t),u=h(i),a=r(+e),c=!!o;if(u+n>s.byteLength)throw new V(O);for(var f=s.bytes,d=u+s.byteOffset,v=0;v<n;v++)f[d+v]=a[c?v:n-v-1]};if(r){var nt=_&&x.name!==T;a(function(){x(1)})&&a(function(){new x(-1)})&&!a(function(){return new x,new x(1.5),new x(NaN),1!==x.length||nt&&!I})?nt&&I&&o(x,"name",T):((R=function(t){return c(this,M),w(new x(h(t)),this,R)})[A]=M,M.constructor=R,y(R,x)),g&&l(P)!==L&&g(P,L);var it=new U(new R(2)),rt=n(P.setInt8);it.setInt8(0,2147483648),it.setInt8(1,2147483649),!it.getInt8(0)&&it.getInt8(1)||u(P,{setInt8:function(t,n){rt(this,t,n<<24>>24)},setUint8:function(t,n){rt(this,t,n<<24>>24)}},{unsafe:!0})}else M=(R=function(t){c(this,M);var n=h(t);C(this,{type:T,bytes:B(F(n),0),byteLength:n}),i||(this.byteLength=n,this.detached=!1)})[A],P=(U=function(t,n,r){c(this,P),c(t,M);var e=N(t),o=e.byteLength,s=f(n);if(s<0||s>o)throw new V("Wrong offset");if(s+(r=void 0===r?o-s:h(r))>o)throw new V("Wrong length");C(this,{type:S,buffer:t,byteLength:r,byteOffset:s,bytes:e.bytes}),i||(this.buffer=t,this.byteLength=r,this.byteOffset=s)})[A],i&&(Q(R,"byteLength",N),Q(U,"buffer",D),Q(U,"byteLength",D),Q(U,"byteOffset",D)),u(P,{getInt8:function(t){return Z(this,1,t)[0]<<24>>24},getUint8:function(t){return Z(this,1,t)[0]},getInt16:function(t){var n=Z(this,2,t,arguments.length>1&&arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=Z(this,2,t,arguments.length>1&&arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return $(Z(this,4,t,arguments.length>1&&arguments[1]))},getUint32:function(t){return $(Z(this,4,t,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(t){return W(Z(this,4,t,arguments.length>1&&arguments[1]),23)},getFloat64:function(t){return W(Z(this,8,t,arguments.length>1&&arguments[1]),52)},setInt8:function(t,n){tt(this,1,t,K,n)},setUint8:function(t,n){tt(this,1,t,K,n)},setInt16:function(t,n){tt(this,2,t,q,n,arguments.length>2&&arguments[2])},setUint16:function(t,n){tt(this,2,t,q,n,arguments.length>2&&arguments[2])},setInt32:function(t,n){tt(this,4,t,X,n,arguments.length>2&&arguments[2])},setUint32:function(t,n){tt(this,4,t,X,n,arguments.length>2&&arguments[2])},setFloat32:function(t,n){tt(this,4,t,Y,n,arguments.length>2&&arguments[2])},setFloat64:function(t,n){tt(this,8,t,J,n,arguments.length>2&&arguments[2])}});return b(R,T),b(U,S),vl={ArrayBuffer:R,DataView:U}}!function(){if(gl)return ml;gl=1;var t=Sr(),n=k(),i=_l(),r=Uo(),e="ArrayBuffer",o=i[e];t({global:!0,constructor:!0,forced:n[e]!==o},{ArrayBuffer:o}),r(e)}();var Il,Tl={};!function(){if(Il)return Tl;Il=1;var t=Sr(),n=Hr(),i=G(),r=_l(),e=Kn(),o=Li(),s=Fi(),u=r.ArrayBuffer,a=r.DataView,c=a.prototype,f=n(u.prototype.slice),h=n(c.getUint8),d=n(c.setUint8);t({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:i(function(){return!new u(2).slice(1,void 0).byteLength})},{slice:function(t,n){if(f&&void 0===n)return f(e(this),t);for(var i=e(this).byteLength,r=o(t,i),c=o(void 0===n?i:n,i),v=new u(s(c-r)),l=new a(this),g=new a(v),m=0;r<c;)d(g,m++,h(l,r++));return v}})}();var Sl,Al,Ol,Nl,kl,Dl={};!function(){if(kl)return Dl;kl=1;var t=Sr(),n=function(){if(Al)return Sl;Al=1;var t=Rt(),n=Fi(),i=of(),r=sf(),e=Lt(),o=t(r),s=t("".slice),u=Math.ceil,a=function(t){return function(r,a,c){var f=i(e(r)),h=n(a),d=f.length;if(h<=d)return f;var v,l,g=void 0===c?" ":i(c);return""===g?f:((l=o(g,u((v=h-d)/g.length))).length>v&&(l=s(l,0,v)),t?f+l:l+f)}};return Sl={start:a(!1),end:a(!0)}}().start;t({target:"String",proto:!0,forced:function(){if(Nl)return Ol;Nl=1;var t=zt();return Ol=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(t)}()},{padStart:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}})}();var Cl,xl,Rl,Ml,Ul,Pl,Ll,Fl,Gl,jl,Vl,Bl,zl,Hl,Wl,Kl,ql,Xl,$l,Yl,Jl,Ql,Zl={exports:{}};function tg(){if(xl)return Cl;xl=1;var t,n,i,r=pl(),e=j(),o=k(),s=Gt(),u=jt(),a=kn(),c=Cr(),f=Xt(),h=Xn(),d=pi(),v=Mo(),l=Bt(),g=cc(),m=xo(),p=Cn(),w=Dn(),y=gi(),b=y.enforce,E=y.get,_=o.Int8Array,I=_&&_.prototype,T=o.Uint8ClampedArray,S=T&&T.prototype,A=_&&g(_),O=I&&g(I),N=Object.prototype,D=o.TypeError,C=p("toStringTag"),x=w("TYPED_ARRAY_TAG"),R="TypedArrayConstructor",M=r&&!!m&&"Opera"!==c(o.opera),U=!1,P={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},L={BigInt64Array:8,BigUint64Array:8},F=function(t){var n=g(t);if(u(n)){var i=E(n);return i&&a(i,R)?i[R]:F(n)}},G=function(t){if(!u(t))return!1;var n=c(t);return a(P,n)||a(L,n)};for(t in P)(i=(n=o[t])&&n.prototype)?b(i)[R]=n:M=!1;for(t in L)(i=(n=o[t])&&n.prototype)&&(b(i)[R]=n);if((!M||!s(A)||A===Function.prototype)&&(A=function(){throw new D("Incorrect invocation")},M))for(t in P)o[t]&&m(o[t],A);if((!M||!O||O===N)&&(O=A.prototype,M))for(t in P)o[t]&&m(o[t].prototype,O);if(M&&g(S)!==O&&m(S,O),e&&!a(O,C))for(t in U=!0,v(O,C,{configurable:!0,get:function(){return u(this)?this[x]:void 0}}),P)o[t]&&h(o[t].prototype,x,t);return Cl={NATIVE_ARRAY_BUFFER_VIEWS:M,TYPED_ARRAY_TAG:U&&x,aTypedArray:function(t){if(G(t))return t;throw new D("Target is not a typed array")},aTypedArrayConstructor:function(t){if(s(t)&&(!m||l(A,t)))return t;throw new D(f(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,n,i,r){if(e){if(i)for(var s in P){var u=o[s];if(u&&a(u.prototype,t))try{delete u.prototype[t]}catch(i){try{u.prototype[t]=n}catch(t){}}}O[t]&&!i||d(O,t,i?n:M&&I[t]||n,r)}},exportTypedArrayStaticMethod:function(t,n,i){var r,s;if(e){if(m){if(i)for(r in P)if((s=o[r])&&a(s,t))try{delete s[t]}catch(t){}if(A[t]&&!i)return;try{return d(A,t,i?n:M&&A[t]||n)}catch(t){}}for(r in P)!(s=o[r])||s[t]&&!i||d(s,t,n)}},getTypedArrayConstructor:F,isView:function(t){if(!u(t))return!1;var n=c(t);return"DataView"===n||a(P,n)||a(L,n)},isTypedArray:G,TypedArray:A,TypedArrayPrototype:O}}function ng(){if(Pl)return Ul;Pl=1;var t=jt(),n=Math.floor;return Ul=Number.isInteger||function(i){return!t(i)&&isFinite(i)&&n(i)===i}}function ig(){if(Fl)return Ll;Fl=1;var t=Pi(),n=RangeError;return Ll=function(i){var r=t(i);if(r<0)throw new n("The argument can't be less than 0");return r}}function rg(){if(jl)return Gl;jl=1;var t=ig(),n=RangeError;return Gl=function(i,r){var e=t(i);if(e%r)throw new n("Wrong offset");return e}}function eg(){if(Bl)return Vl;Bl=1;var t=Math.floor;return Vl=function(n){var i=+n;if(i!=i||i<=0)return 0;if(i>=255)return 255;var r=t(i);return r+.5<i?r+1:i<r+.5||r%2==0?r:r+1}}function og(){if(Hl)return zl;Hl=1;var t=Cr();return zl=function(n){var i=t(n);return"BigInt64Array"===i||"BigUint64Array"===i}}function sg(){if(Kl)return Wl;Kl=1;var t=xn(),n=TypeError;return Wl=function(i){var r=t(i,"number");if("number"==typeof r)throw new n("Can't convert number to bigint");return BigInt(r)}}function ug(){if(Xl)return ql;Xl=1;var t=Wr(),n=B(),i=$t(),r=Lo(),e=Nn(),o=Gi(),s=_s(),u=Es(),a=bs(),c=og(),f=tg().aTypedArrayConstructor,h=sg();return ql=function(d){var v=r(this),l=arguments.length,g=l>1?arguments[1]:void 0,m=void 0!==g;m&&i(g);var p,w,y,b,E,_,I,T,S=e(d),A=u(S);if(A&&!a(A))for(T=(I=s(S,A)).next,S=[];!(_=n(T,I)).done;)S.push(_.value);for(m&&l>2&&(g=t(g,arguments[2])),w=o(S),y=new(f(v))(w),b=c(y),p=0;w>p;p++)E=m?g(S[p],p):S[p],y[p]=b?h(E):+E;return y},ql}function ag(){if(Yl)return $l;Yl=1;var t=Gi();return $l=function(n,i,r){for(var e=0,o=arguments.length>2?r:t(i),s=new n(o);o>e;)s[e]=i[e++];return s},$l}function cg(){if(Jl)return Zl.exports;Jl=1;var t=Sr(),n=k(),i=B(),r=j(),e=function(){if(Ml)return Rl;Ml=1;var t=k(),n=G(),i=Ss(),r=tg().NATIVE_ARRAY_BUFFER_VIEWS,e=t.ArrayBuffer,o=t.Int8Array;return Rl=!r||!n(function(){o(1)})||!n(function(){new o(-1)})||!i(function(t){new o,new o(null),new o(1.5),new o(t)},!0)||n(function(){return 1!==new o(new e(2),1,void 0).length})}(),o=tg(),s=_l(),u=Po(),a=xt(),c=Xn(),f=ng(),h=wl(),d=rg(),v=eg(),l=Rn(),g=kn(),m=Cr(),p=jt(),w=qt(),y=ue(),b=Bt(),E=xo(),_=zi().f,I=ug(),T=Kr().forEach,S=Uo(),A=Mo(),O=qn(),N=Pn(),D=ag(),C=gi(),x=Wc(),R=C.get,M=C.set,U=C.enforce,P=O.f,L=N.f,F=n.RangeError,V=s.ArrayBuffer,z=V.prototype,H=s.DataView,W=o.NATIVE_ARRAY_BUFFER_VIEWS,K=o.TYPED_ARRAY_TAG,q=o.TypedArray,X=o.TypedArrayPrototype,$=o.isTypedArray,Y="BYTES_PER_ELEMENT",J="Wrong length",Q=function(t,n){A(t,n,{configurable:!0,get:function(){return R(this)[n]}})},Z=function(t){var n;return b(z,t)||"ArrayBuffer"===(n=m(t))||"SharedArrayBuffer"===n},tt=function(t,n){return $(t)&&!w(n)&&n in t&&f(+n)&&n>=0},nt=function(t,n){return n=l(n),tt(t,n)?a(2,t[n]):L(t,n)},it=function(t,n,i){return n=l(n),!(tt(t,n)&&p(i)&&g(i,"value"))||g(i,"get")||g(i,"set")||i.configurable||g(i,"writable")&&!i.writable||g(i,"enumerable")&&!i.enumerable?P(t,n,i):(t[n]=i.value,t)};return r?(W||(N.f=nt,O.f=it,Q(X,"buffer"),Q(X,"byteOffset"),Q(X,"byteLength"),Q(X,"length")),t({target:"Object",stat:!0,forced:!W},{getOwnPropertyDescriptor:nt,defineProperty:it}),Zl.exports=function(r,o,s){var a=r.match(/\d+/)[0]/8,f=r+(s?"Clamped":"")+"Array",l="get"+r,g="set"+r,m=n[f],w=m,b=w&&w.prototype,A={},O=function(t,n){P(t,n,{get:function(){return function(t,n){var i=R(t);return i.view[l](n*a+i.byteOffset,!0)}(this,n)},set:function(t){return function(t,n,i){var r=R(t);r.view[g](n*a+r.byteOffset,s?v(i):i,!0)}(this,n,t)},enumerable:!0})};W?e&&(w=o(function(t,n,r,e){return u(t,b),x(p(n)?Z(n)?void 0!==e?new m(n,d(r,a),e):void 0!==r?new m(n,d(r,a)):new m(n):$(n)?D(w,n):i(I,w,n):new m(h(n)),t,w)}),E&&E(w,q),T(_(m),function(t){t in w||c(w,t,m[t])}),w.prototype=b):(w=o(function(t,n,r,e){u(t,b);var o,s,c,f=0,v=0;if(p(n)){if(!Z(n))return $(n)?D(w,n):i(I,w,n);o=n,v=d(r,a);var l=n.byteLength;if(void 0===e){if(l%a)throw new F(J);if((s=l-v)<0)throw new F(J)}else if((s=h(e)*a)+v>l)throw new F(J);c=s/a}else c=h(n),o=new V(s=c*a);for(M(t,{buffer:o,byteOffset:v,byteLength:s,length:c,view:new H(o)});f<c;)O(t,f++)}),E&&E(w,q),b=w.prototype=y(X)),b.constructor!==w&&c(b,"constructor",w),U(b).TypedArrayConstructor=w,K&&c(b,K,f);var N=w!==m;A[f]=w,t({global:!0,constructor:!0,forced:N,sham:!W},A),Y in w||c(w,Y,a),Y in b||c(b,Y,a),S(f)}):Zl.exports=function(){},Zl.exports}Ql||(Ql=1,cg()("Uint8",function(t){return function(n,i,r){return t(this,n,i,r)}}));var fg,hg,dg,vg={};!function(){if(dg)return vg;dg=1;var t=Rt(),n=tg(),i=function(){if(hg)return fg;hg=1;var t=Nn(),n=Li(),i=Gi(),r=Ec(),e=Math.min;return fg=[].copyWithin||function(o,s){var u=t(this),a=i(u),c=n(o,a),f=n(s,a),h=arguments.length>2?arguments[2]:void 0,d=e((void 0===h?a:n(h,a))-f,a-c),v=1;for(f<c&&c<f+d&&(v=-1,f+=d-1,c+=d-1);d-- >0;)f in u?u[c]=u[f]:r(u,c),c+=v,f+=v;return u},fg}(),r=t(i),e=n.aTypedArray;(0,n.exportTypedArrayMethod)("copyWithin",function(t,n){return r(e(this),t,n,arguments.length>2?arguments[2]:void 0)})}();var lg,gg={};!function(){if(lg)return gg;lg=1;var t=tg(),n=Kr().every,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("every",function(t){return n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var mg,pg={};!function(){if(mg)return pg;mg=1;var t=tg(),n=El(),i=sg(),r=Cr(),e=B(),o=Rt(),s=G(),u=t.aTypedArray,a=t.exportTypedArrayMethod,c=o("".slice);a("fill",function(t){var o=arguments.length;u(this);var s="Big"===c(r(this),0,3)?i(t):+t;return e(n,this,s,o>1?arguments[1]:void 0,o>2?arguments[2]:void 0)},s(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),1!==t}))}();var wg,yg,bg,Eg={};function _g(){if(yg)return wg;yg=1;var t=ag(),n=tg().getTypedArrayConstructor;return wg=function(i,r){return t(n(i),r)}}!function(){if(bg)return Eg;bg=1;var t=tg(),n=Kr().filter,i=_g(),r=t.aTypedArray;(0,t.exportTypedArrayMethod)("filter",function(t){var e=n(r(this),t,arguments.length>1?arguments[1]:void 0);return i(this,e)})}();var Ig,Tg={};!function(){if(Ig)return Tg;Ig=1;var t=tg(),n=Kr().find,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("find",function(t){return n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var Sg,Ag={};!function(){if(Sg)return Ag;Sg=1;var t=tg(),n=Kr().findIndex,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("findIndex",function(t){return n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var Og,Ng={};!function(){if(Og)return Ng;Og=1;var t=tg(),n=Kr().forEach,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("forEach",function(t){n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var kg,Dg={};!function(){if(kg)return Dg;kg=1;var t=tg(),n=ji().includes,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("includes",function(t){return n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var Cg,xg={};!function(){if(Cg)return xg;Cg=1;var t=tg(),n=ji().indexOf,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("indexOf",function(t){return n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var Rg,Mg={};!function(){if(Rg)return Mg;Rg=1;var t=k(),n=G(),i=Rt(),r=tg(),e=lc(),o=Cn()("iterator"),s=t.Uint8Array,u=i(e.values),a=i(e.keys),c=i(e.entries),f=r.aTypedArray,h=r.exportTypedArrayMethod,d=s&&s.prototype,v=!n(function(){d[o].call([1])}),l=!!d&&d.values&&d[o]===d.values&&"values"===d.values.name,g=function(){return u(f(this))};h("entries",function(){return c(f(this))},v),h("keys",function(){return a(f(this))},v),h("values",g,v||!l,{name:"values"}),h(o,g,v||!l,{name:"values"})}();var Ug,Pg={};!function(){if(Ug)return Pg;Ug=1;var t=tg(),n=Rt(),i=t.aTypedArray,r=t.exportTypedArrayMethod,e=n([].join);r("join",function(t){return e(i(this),t)})}();var Lg,Fg={};!function(){if(Lg)return Fg;Lg=1;var t=tg(),n=Go(),i=cv(),r=t.aTypedArray;(0,t.exportTypedArrayMethod)("lastIndexOf",function(t){var e=arguments.length;return n(i,r(this),e>1?[t,arguments[1]]:[t])})}();var Gg,jg={};!function(){if(Gg)return jg;Gg=1;var t=tg(),n=Kr().map,i=_g(),r=t.aTypedArray;(0,t.exportTypedArrayMethod)("map",function(t){var e=n(r(this),t,arguments.length>1?arguments[1]:void 0);return i(this,e)})}();var Vg,Bg,zg,Hg={};function Wg(){if(Bg)return Vg;Bg=1;var t=$t(),n=Nn(),i=Ut(),r=Gi(),e=TypeError,o="Reduce of empty array with no initial value",s=function(s){return function(u,a,c,f){var h=n(u),d=i(h),v=r(h);if(t(a),0===v&&c<2)throw new e(o);var l=s?v-1:0,g=s?-1:1;if(c<2)for(;;){if(l in d){f=d[l],l+=g;break}if(l+=g,s?l<0:v<=l)throw new e(o)}for(;s?l>=0:v>l;l+=g)l in d&&(f=a(f,d[l],l,h));return f}};return Vg={left:s(!1),right:s(!0)}}!function(){if(zg)return Hg;zg=1;var t=tg(),n=Wg().left,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("reduce",function(t){var r=arguments.length;return n(i(this),t,r,r>1?arguments[1]:void 0)})}();var Kg,qg={};!function(){if(Kg)return qg;Kg=1;var t=tg(),n=Wg().right,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("reduceRight",function(t){var r=arguments.length;return n(i(this),t,r,r>1?arguments[1]:void 0)})}();var Xg,$g={};!function(){if(Xg)return $g;Xg=1;var t=tg(),n=t.aTypedArray,i=t.exportTypedArrayMethod,r=Math.floor;i("reverse",function(){for(var t,i=this,e=n(i).length,o=r(e/2),s=0;s<o;)t=i[s],i[s++]=i[--e],i[e]=t;return i})}();var Yg,Jg={};!function(){if(Yg)return Jg;Yg=1;var t=k(),n=B(),i=tg(),r=Gi(),e=rg(),o=Nn(),s=G(),u=t.RangeError,a=t.Int8Array,c=a&&a.prototype,f=c&&c.set,h=i.aTypedArray,d=i.exportTypedArrayMethod,v=!s(function(){var t=new Uint8ClampedArray(2);return n(f,t,{length:1,0:3},1),3!==t[1]}),l=v&&i.NATIVE_ARRAY_BUFFER_VIEWS&&s(function(){var t=new a(2);return t.set(1),t.set("2",1),0!==t[0]||2!==t[1]});d("set",function(t){h(this);var i=e(arguments.length>1?arguments[1]:void 0,1),s=o(t);if(v)return n(f,this,s,i);var a=this.length,c=r(s),d=0;if(c+i>a)throw new u("Wrong length");for(;d<c;)this[i+d]=s[d++]},!v||l)}();var Qg,Zg={};!function(){if(Qg)return Zg;Qg=1;var t=tg(),n=G(),i=jo(),r=t.aTypedArray,e=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("slice",function(t,n){for(var o=i(r(this),t,n),s=e(this),u=0,a=o.length,c=new s(a);a>u;)c[u]=o[u++];return c},n(function(){new Int8Array(1).slice()}))}();var tm,nm={};!function(){if(tm)return nm;tm=1;var t=tg(),n=Kr().some,i=t.aTypedArray;(0,t.exportTypedArrayMethod)("some",function(t){return n(i(this),t,arguments.length>1?arguments[1]:void 0)})}();var im,rm,em,om,sm,um,am,cm={};function fm(){if(rm)return im;rm=1;var t=zt().match(/firefox\/(\d+)/i);return im=!!t&&+t[1]}function hm(){if(om)return em;om=1;var t=zt();return em=/MSIE|Trident/.test(t)}function dm(){if(um)return sm;um=1;var t=zt().match(/AppleWebKit\/(\d+)\./);return sm=!!t&&+t[1]}!function(){if(am)return cm;am=1;var t=k(),n=Hr(),i=G(),r=$t(),e=Hh(),o=tg(),s=fm(),u=hm(),a=Ht(),c=dm(),f=o.aTypedArray,h=o.exportTypedArrayMethod,d=t.Uint16Array,v=d&&n(d.prototype.sort),l=!(!v||i(function(){v(new d(2),null)})&&i(function(){v(new d(2),{})})),g=!!v&&!i(function(){if(a)return a<74;if(s)return s<67;if(u)return!0;if(c)return c<602;var t,n,i=new d(516),r=Array(516);for(t=0;t<516;t++)n=t%4,i[t]=515-t,r[t]=t-2*n+3;for(v(i,function(t,n){return(t/4|0)-(n/4|0)}),t=0;t<516;t++)if(i[t]!==r[t])return!0});h("sort",function(t){return void 0!==t&&r(t),g?v(this,t):e(f(this),function(t){return function(n,i){return void 0!==t?+t(n,i)||0:i!=i?n!=n?0:-1:n!=n?1:0===n&&0===i?1/n>0?1/i>0?0:1:1/i>0?-1:0:n>i?1:n<i?-1:0}}(t))},!g||l)}();var vm,lm={};!function(){if(vm)return lm;vm=1;var t=tg(),n=Fi(),i=Li(),r=t.aTypedArray,e=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("subarray",function(t,o){var s=r(this),u=s.length,a=i(t,u);return new(e(s))(s.buffer,s.byteOffset+a*s.BYTES_PER_ELEMENT,n((void 0===o?u:i(o,u))-a))})}();var gm,mm={};!function(){if(gm)return mm;gm=1;var t=k(),n=Go(),i=tg(),r=G(),e=jo(),o=t.Int8Array,s=i.aTypedArray,u=i.exportTypedArrayMethod,a=[].toLocaleString,c=!!o&&r(function(){a.call(new o(1))});u("toLocaleString",function(){return n(a,c?e(s(this)):s(this),e(arguments))},r(function(){return[1,2].toLocaleString()!==new o([1,2]).toLocaleString()})||!r(function(){o.prototype.toLocaleString.call([1,2])}))}();var pm,wm={};function ym(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();var t="undefined"!=typeof crypto?crypto:null;if(null==t?void 0:t.getRandomValues){var n=new Uint8Array(16);t.getRandomValues(n);var i=new DataView(n.buffer);return i.setUint8(6,15&i.getUint8(6)|64),i.setUint8(8,63&i.getUint8(8)|128),Array.from(n).map(function(t,n){return[4,6,8,10].includes(n)?"-".concat(t.toString(16).padStart(2,"0")):t.toString(16).padStart(2,"0")}).join("")}throw new Error("No cryptographically secure random number generator available")}!function(){if(pm)return wm;pm=1;var t=tg().exportTypedArrayMethod,n=G(),i=k(),r=Rt(),e=i.Uint8Array,o=e&&e.prototype||{},s=[].toString,u=r([].join);n(function(){s.call({})})&&(s=function(){return u(this)});var a=o.toString!==s;t("toString",s,a)}();var bm,Em,_m,Im={};function Tm(){return Em?bm:(Em=1,bm=Object.is||function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n})}!function(){if(_m)return Im;_m=1;var t=B(),n=Cd(),i=Kn(),r=jt(),e=Lt(),o=Tm(),s=of(),u=Yt(),a=Ud();n("search",function(n,c,f){return[function(i){var o=e(this),a=r(i)?u(i,n):void 0;if(a)return t(a,i,o);var c=s(o);return new RegExp(i)[n](c)},function(t){var n=i(this),r=s(t),e=f(c,n,r);if(e.done)return e.value;var u=n.lastIndex;o(u,0)||(n.lastIndex=0);var h=a(n,r);return o(n.lastIndex,u)||(n.lastIndex=u),null===h?-1:h.index}]})}();var Sm,Am={};function Om(t,n){var i;if("undefined"!=typeof URLSearchParams)return new URLSearchParams(t).get(n);var r=new RegExp("[?&]"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"=([^&#]*)"),e=t.match(r);return e?decodeURIComponent(null!==(i=e[1])&&void 0!==i?i:""):null}function Nm(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return"UTC"}}function km(t,n){var i,r={campaignName:Om(i=window.location.search,"utm_campaign")||"",campaignSource:Om(i,"utm_source")||"",campaignMedium:Om(i,"utm_medium")||""};return{libraryName:"cap-hydra-web-sdk",libraryVersion:za,locale:navigator.language||navigator.languages&&navigator.languages[0]||"en-US",userAgent:navigator.userAgent||"",timezone:Nm(),ip:"",campaignName:r.campaignName,campaignSource:r.campaignSource,campaignMedium:r.campaignMedium,pageUrl:window.location.href||"",pagePath:window.location.pathname||"",pageReferrer:document.referrer||"",pageTitle:document.title||"",sessionId:t,lat:n?String(n.latitude):"",long:n?String(n.longitude):""}}function Dm(){try{var t=function(){var t,n;if("undefined"!=typeof navigator&&"userAgentData"in navigator){var i=navigator.userAgentData;if(i&&i.brands)try{for(var r=tu(i.brands),e=r.next();!e.done;e=r.next()){var o=e.value;if(o.brand&&"Chromium"!==o.brand&&!o.brand.startsWith("Not"))return o.brand}}catch(n){t={error:n}}finally{try{e&&!e.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}}return null}();return t||("undefined"!=typeof navigator&&navigator.userAgent?(n=navigator.userAgent).includes("Firefox/")?"Firefox":n.includes("Edg/")?"Edge":n.includes("Chrome/")?"Chrome":n.includes("Safari/")&&!n.includes("Chrome")?"Safari":n.includes("Opera/")||n.includes("OPR/")?"Opera":null:null)}catch(t){return null}var n}function Cm(){try{var t=function(){if("undefined"!=typeof navigator&&"userAgentData"in navigator){var t=navigator.userAgentData;if(t&&t.platform)return t.platform}return null}();return t||("undefined"!=typeof navigator&&navigator.userAgent?(n=navigator.userAgent,null!==(r=null!==(i=function(t){if(!t.includes("Mac OS X"))return null;var n=t.match(/Mac OS X ([\d_]+)/);return(null==n?void 0:n[1])?"macOS ".concat(n[1].replace(/_/g,".")):"macOS"}(n))&&void 0!==i?i:function(t){var n;if(!t.includes("Windows NT"))return null;var i=t.match(/Windows NT ([\d.]+)/);return(null==i?void 0:i[1])?"Windows ".concat(null!==(n={"10.0":"10/11",6.3:"8.1",6.2:"8",6.1:"7"}[i[1]])&&void 0!==n?n:i[1]):"Windows"}(n))&&void 0!==r?r:function(t){var n;return t.includes("iPhone")||t.includes("iPad")?(null==(n=t.match(/OS ([\d_]+)/))?void 0:n[1])?"iOS ".concat(n[1].replace(/_/g,".")):"iOS":t.includes("Android")?(n=t.match(/Android ([\d.]+)/))?"Android ".concat(n[1]):"Android":t.includes("Linux")?"Linux":null}(n)):null)}catch(i){return null}var n,i,r}function xm(){try{if("undefined"!=typeof document&&document.referrer)return function(t){var n;if("undefined"!=typeof URL)try{return new URL(t).hostname}catch(t){return"direct"}var i=t.match(/^https?:\/\/([^/?#]+)/);return i&&null!==(n=i[1])&&void 0!==n?n:"direct"}(document.referrer)}catch(t){}return"direct"}function Rm(t){var n=Dm(),i=Cm(),r=function(){var t;try{if("undefined"!=typeof navigator)return navigator.language||(null===(t=navigator.languages)||void 0===t?void 0:t[0])||"en-US"}catch(t){}return"en-US"}(),e=function(){try{if("undefined"!=typeof Intl)return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch(t){}return"UTC"}(),o=function(){try{if("undefined"!=typeof window&&window.screen)return"".concat(window.screen.width,"x").concat(window.screen.height)}catch(t){}return"0x0"}(),s=function(){try{if("undefined"!=typeof window&&window.location){var t=window.location.search;return{utmSource:Om(t,"utm_source"),utmMedium:Om(t,"utm_medium"),utmCampaign:Om(t,"utm_campaign"),utmTerm:Om(t,"utm_term"),utmContent:Om(t,"utm_content"),adsId:Om(t,"gclid")||Om(t,"fbclid")||Om(t,"msclkid")||Om(t,"ttclid")}}}catch(t){}return{utmSource:null,utmMedium:null,utmCampaign:null,utmTerm:null,utmContent:null,adsId:null}}(),u=xm(),a={sdk_version:za,consent:(null==t?void 0:t.notificationPermissionGranted)?"yes":"no"};return function(t,n,i,r,e,o){n&&(t.browser=n),i&&(t.os_version=i),r&&"en-US"!==r&&(t.locale=r),e&&"UTC"!==e&&(t.timezone=e),o&&"0x0"!==o&&(t.screen_resolution=o)}(a,n,i,r,e,o),function(t,n,i,r){(null==n?void 0:n.appVersion)&&(t.app_version=n.appVersion),(null==n?void 0:n.fcmTokenCreatedAt)&&(t.token_creation_date=n.fcmTokenCreatedAt),i.utmSource&&(t.utm_source=i.utmSource),i.utmMedium&&(t.utm_medium=i.utmMedium),i.utmCampaign&&(t.utm_campaign=i.utmCampaign),i.utmTerm&&(t.utm_term=i.utmTerm),i.utmContent&&(t.utm_content=i.utmContent),i.adsId&&(t.ads_id=i.adsId),r&&"direct"!==r&&(t.initial_referrer=r)}(a,t,s,u),a}!function(){if(Sm)return Am;Sm=1;var t=B(),n=Rt(),i=Cd(),r=Kn(),e=jt(),o=Fi(),s=of(),u=Lt(),a=Yt(),c=xd(),f=Md(),h=Ud(),d=n("".indexOf);i("match",function(n,i,v){return[function(i){var r=u(this),o=e(i)?a(i,n):void 0;if(o)return t(o,i,r);var c=s(r);return new RegExp(i)[n](c)},function(t){var n=r(this),e=s(t),u=v(i,n,e);if(u.done)return u.value;var a=s(f(n));if(!~d(a,"g"))return h(n,e);var l=!!~d(a,"u")||!!~d(a,"v");n.lastIndex=0;for(var g,m=[],p=0;null!==(g=h(n,e));){var w=s(g[0]);m[p]=w,""===w&&(n.lastIndex=c(e,o(n.lastIndex),l)),p++}return 0===p?null:m}]})}();var Mm=3e5,Um=null,Pm=0;function Lm(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return null!==Um&&Date.now()-Pm<Mm?[2,Um]:"undefined"!=typeof navigator&&navigator.geolocation?[2,new Promise(function(t){navigator.geolocation.getCurrentPosition(function(n){Um={latitude:n.coords.latitude,longitude:n.coords.longitude},Pm=Date.now(),t(Um)},function(){return t(null)},{maximumAge:Mm,timeout:2e3,enableHighAccuracy:!1})})]:[2,null]})})}var Fm="__glu_container",Gm="__glu_backdrop";function jm(){return"__GLU__"+ym().replace(/-/g,"")}function Vm(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Bm=function(){function t(t,n){this.rootElement=null,this.closeListener=null,this.isShown=!1,this.supportsPreload=!0,this.preloaded=!1,this.preloadStyleSnapshot=null,this.boundListeners=[],this.customStyles=[],this.destroyed=!1,this.config=t,this.contentElement=n,this.mountDefaultStyleOnce()}return t.prototype.mountDefaultStyleOnce=function(){if("undefined"!=typeof document&&!document.getElementById(t.DEFAULT_STYLE_ID)){var n=this.mountStyle(Object.values(Xv).map(function(t){return t.css}).join(""));null==n||n.setAttribute("id",t.DEFAULT_STYLE_ID)}},t.prototype.bindEvent=function(t,n,i){t.addEventListener(n,i),this.boundListeners.push({target:t,type:n,handler:i})},t.prototype.mountStyle=function(t){if("undefined"==typeof document)return null;var n=document.createElement("style");return n.textContent=t,document.head.appendChild(n),n},t.prototype.addCustomStyle=function(t){if(this.config.css){var n=function(t,n){var i,r,e=t;try{for(var o=tu(Object.entries(n)),s=o.next();!s.done;s=o.next()){var u=nu(s.value,2),a=u[0],c=u[1];e.includes(a)&&(e=e.replace(new RegExp(Vm(a),"g"),c))}}catch(t){i={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return e}(this.config.css,t),i=this.mountStyle(n);i&&this.customStyles.push(i)}},t.prototype.preload=function(){var n,i;if(this.supportsPreload&&!this.preloaded&&!this.isShown&&this.rootElement&&"undefined"!=typeof document){this.preloaded=!0;var r={};try{for(var e=tu(t.PRELOAD_STYLE_KEYS),o=e.next();!o.done;o=e.next()){var s=o.value;r[s]=this.rootElement.style[s]}}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}this.preloadStyleSnapshot=r,Object.assign(this.rootElement.style,t.HIDDEN_STYLE),document.body.appendChild(this.rootElement)}},t.prototype.clearPreloadStyles=function(){var n;this.preloaded&&this.rootElement&&(this.preloaded=!1,Object.assign(this.rootElement.style,null!==(n=this.preloadStyleSnapshot)&&void 0!==n?n:t.CLEARED_STYLE),this.preloadStyleSnapshot=null)},t.prototype.show=function(){this.rootElement&&"undefined"!=typeof document&&(this.clearPreloadStyles(),this.rootElement.parentNode||document.body.appendChild(this.rootElement),this.isShown=!0)},t.prototype.hide=function(){this.isShown=!1,this.rootElement&&this.rootElement.parentNode&&this.rootElement.parentNode.removeChild(this.rootElement)},t.prototype.addCloseListener=function(t){this.closeListener=t},t.prototype.destroy=function(){var t,n,i,r,e;if(!this.destroyed){this.destroyed=!0,this.isShown=!1;try{for(var o=tu(this.boundListeners),s=o.next();!s.done;s=o.next()){var u=s.value,a=u.target,c=u.type,f=u.handler;a.removeEventListener(c,f)}}catch(n){t={error:n}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this.boundListeners.length=0,(null===(e=this.rootElement)||void 0===e?void 0:e.parentNode)&&this.rootElement.parentNode.removeChild(this.rootElement);try{for(var h=tu(this.customStyles),d=h.next();!d.done;d=h.next()){d.value.remove()}}catch(t){i={error:t}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}this.customStyles.length=0,this.closeListener=null,this.onDestroy()}},t.prototype.onDestroy=function(){},t.DEFAULT_STYLE_ID="__glu_default_style",t.PRELOAD_STYLE_KEYS=["position","left","top","visibility","pointerEvents"],t.HIDDEN_STYLE={position:"fixed",left:"-9999px",top:"-9999px",visibility:"hidden",pointerEvents:"none"},t.CLEARED_STYLE={position:"",left:"",top:"",visibility:"",pointerEvents:""},t}(),zm=function(t){function n(n,i){var r,e=t.call(this,n,i)||this;return e.sheetClass=jm(),e.backdropClass=jm(),e.sheetElement=null,e.height=n.height,e.createElement(),e.addCustomStyle(((r={})[Fm]=e.sheetClass,r[Gm]=e.backdropClass,r)),e}return Ys(n,t),n.prototype.createElement=function(){var n=this;if("undefined"!=typeof document){var i=document.createElement("div");i.classList.add(this.backdropClass,Xv.backDrop.className);var r=document.createElement("div"),e="IMG"===this.contentElement.tagName;r.classList.add(this.sheetClass,e?Xv.bottomSheetStatic.className:Xv.bottomSheet.className,Xv.hideScroll.className),r.style.height=this.height,r.appendChild(this.contentElement),this.bindEvent(r,"click",function(t){return t.stopPropagation()}),i.appendChild(r),this.bindEvent(i,"click",function(t){var i;t.stopPropagation(),t.preventDefault(),null===(i=n.closeListener)||void 0===i||i.call(n)}),this.bindEvent(i,"animationend",function(){n.isShown||t.prototype.hide.call(n)}),this.rootElement=i,this.sheetElement=r}},n.prototype.show=function(){this.sheetElement&&(this.sheetElement.classList.remove(Xv.slideDownSheet.className),this.sheetElement.classList.add(Xv.slideUpSheet.className),t.prototype.show.call(this))},n.prototype.hide=function(){this.sheetElement&&(this.sheetElement.classList.remove(Xv.slideUpSheet.className),this.sheetElement.classList.add(Xv.slideDownSheet.className),this.isShown=!1)},n}(Bm),Hm=function(t){function n(n,i){var r,e=t.call(this,n,i)||this;return e.instanceClass=jm(),e.createElement(),e.addCustomStyle(((r={})[Fm]=e.instanceClass,r)),e}return Ys(n,t),n.prototype.createElement=function(){var n=this;if("undefined"!=typeof document){var i=document.createElement("div");i.appendChild(this.contentElement),i.classList.add(Xv.chatBox.className,this.instanceClass),this.bindEvent(i,"animationend",function(){n.isShown||t.prototype.hide.call(n)}),this.rootElement=i}},n.prototype.show=function(){this.rootElement&&(this.rootElement.classList.remove(Xv.slideDown.className),this.rootElement.classList.add(Xv.slideUp.className),t.prototype.show.call(this))},n.prototype.hide=function(){this.rootElement&&(this.rootElement.classList.remove(Xv.slideUp.className),this.rootElement.classList.add(Xv.slideDown.className),this.isShown=!1)},n}(Bm),Wm=[],Km=!1,qm=null;function Xm(t){"undefined"!=typeof document&&(Km||((qm||(qm=new MutationObserver(function(){var t,n;try{for(var i=tu(iu([],nu(Wm),!1)),r=i.next();!r.done;r=i.next()){var e=r.value;try{e()}catch(t){console.error("[gamification] DOM observer callback failed",t)}}}catch(n){t={error:n}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}})),qm).observe(document.body,{childList:!0,subtree:!0}),Km=!0),Wm.includes(t)||Wm.push(t))}function $m(t){0===(Wm=Wm.filter(function(n){return n!==t})).length&&Km&&qm&&(qm.disconnect(),qm=null,Km=!1)}var Ym=function(t){function n(n,i){var r,e=t.call(this,n,i)||this;return e.supportsPreload=!1,e.instanceClass=jm(),e.isObserverRunning=!1,e.showOnceHookPresent=function(){if(e.isObserverRunning&&"undefined"!=typeof document&&e.rootElement){var t=document.querySelector("#".concat(e.hookId));t&&(t.innerHTML="",t.append(e.rootElement),e.isShown=!0,$m(e.showOnceHookPresent),e.isObserverRunning=!1)}},e.hookId=n.elementHookId,e.createElement(),e.addCustomStyle(((r={})[Fm]=e.instanceClass,r)),e}return Ys(n,t),n.prototype.createElement=function(){if("undefined"!=typeof document){var t=document.createElement("div");t.appendChild(this.contentElement);var n="IMG"===this.contentElement.tagName;t.classList.add(this.instanceClass,n?Xv.embeddedStatic.className:Xv.embedded.className),this.rootElement=t}},n.prototype.show=function(){if("undefined"!=typeof document&&this.rootElement){var t=document.querySelector("#".concat(this.hookId));if(t)return t.innerHTML="",t.append(this.rootElement),void(this.isShown=!0);this.isObserverRunning||(Xm(this.showOnceHookPresent),this.isObserverRunning=!0)}},n.prototype.hide=function(){var t;null===(t=this.rootElement)||void 0===t||t.remove(),this.isShown=!1,this.isObserverRunning&&($m(this.showOnceHookPresent),this.isObserverRunning=!1)},n.prototype.onDestroy=function(){this.isObserverRunning&&($m(this.showOnceHookPresent),this.isObserverRunning=!1)},n}(Bm),Jm=function(t){function n(n,i){var r,e=t.call(this,n,i)||this;return e.instanceClass=jm(),e.createElement(),e.addCustomStyle(((r={})[Fm]=e.instanceClass,r)),e}return Ys(n,t),n.prototype.createElement=function(){if("undefined"!=typeof document){var t=document.createElement("div");t.appendChild(this.contentElement),t.classList.add(Xv.iconButton.className,this.instanceClass),this.rootElement=t}},n.prototype.show=function(){this.rootElement&&(this.rootElement.classList.remove(Xv.slideDown.className),this.rootElement.classList.add(Xv.slideUp.className),t.prototype.show.call(this))},n.prototype.hide=function(){this.rootElement&&(this.rootElement.classList.remove(Xv.slideUp.className),this.rootElement.classList.add(Xv.slideDown.className),t.prototype.hide.call(this))},n}(Bm),Qm=function(t){function n(n,i){var r,e=t.call(this,n,i)||this;return e.supportsPreload=!1,e.instanceClass=jm(),e.isObserverRunning=!1,e.showOnceHookPresent=function(){if(e.isObserverRunning&&"undefined"!=typeof document&&e.rootElement){var t=document.querySelector("#".concat(e.hookId));t&&(t.innerHTML="",t.append(e.rootElement),e.isShown=!0,$m(e.showOnceHookPresent),e.isObserverRunning=!1)}},e.hookId=n.elementHookId,e.contentElement.classList.add(e.instanceClass),e.rootElement=e.contentElement,e.addCustomStyle(((r={})[Fm]=e.instanceClass,r)),e}return Ys(n,t),n.prototype.show=function(){if("undefined"!=typeof document&&this.rootElement){var t=document.querySelector("#".concat(this.hookId));if(t)return t.innerHTML="",t.append(this.rootElement),void(this.isShown=!0);this.isObserverRunning||(Xm(this.showOnceHookPresent),this.isObserverRunning=!0)}},n.prototype.hide=function(){var t;null===(t=this.rootElement)||void 0===t||t.remove(),this.isShown=!1,this.isObserverRunning&&($m(this.showOnceHookPresent),this.isObserverRunning=!1)},n.prototype.onDestroy=function(){this.isObserverRunning&&($m(this.showOnceHookPresent),this.isObserverRunning=!1)},n}(Bm),Zm=function(t){function n(n,i){var r,e=t.call(this,n,i)||this;return e.popupClass=jm(),e.backdropClass=jm(),e.popupElement=null,e.createElement(),e.addCustomStyle(((r={})[Fm]=e.popupClass,r[Gm]=e.backdropClass,r)),e}return Ys(n,t),n.prototype.createElement=function(){var n=this;if("undefined"!=typeof document){var i=document.createElement("div");i.classList.add(this.backdropClass,Xv.backDrop.className);var r=document.createElement("div"),e="IMG"===this.contentElement.tagName;r.classList.add(this.popupClass,e?Xv.popUpStatic.className:Xv.popUp.className,Xv.hideScroll.className),r.appendChild(this.contentElement),this.bindEvent(r,"click",function(t){return t.stopPropagation()}),i.appendChild(r),this.bindEvent(i,"click",function(t){var i;t.stopPropagation(),t.preventDefault(),null===(i=n.closeListener)||void 0===i||i.call(n)}),this.bindEvent(i,"animationend",function(){n.isShown||t.prototype.hide.call(n)}),this.rootElement=i,this.popupElement=r}},n.prototype.show=function(){this.popupElement&&(this.popupElement.classList.remove(Xv.slideDown.className),this.popupElement.classList.add(Xv.slideUp.className),t.prototype.show.call(this))},n.prototype.hide=function(){this.popupElement&&(this.popupElement.classList.remove(Xv.slideUp.className),this.popupElement.classList.add(Xv.slideDown.className),this.isShown=!1)},n}(Bm);var tp=function(){function t(n){var i=this;this.sdkEventListener=null,this.boundListeners=[],this.headStyles=[],this.destroyed=!1,this.messageListener=function(t,n){var r,e,o="CLOSE_FRAME_CONTENT"===n.action.type?{target:"GLU_SDK",action:{type:"CLOSE_CONTAINER_CONTENT"}}:n;i.element instanceof HTMLIFrameElement&&t===i.element.contentWindow?null===(r=i.sdkEventListener)||void 0===r||r.call(i,o):"UPDATE_CONTENT_STATE"===o.action.type?i.sendMessageToContent(o.action):"CLOSE_CONTAINER_CONTENT"===o.action.type&&i.sendMessageToContent({type:"UPDATE_CONTENT_STATE",data:null!==(e=o.action.data)&&void 0!==e?e:{}})},this.config=n,t.listeners.push(this.messageListener),t.isListening||t.installWindowListener()}return t.prototype.bindEvent=function(t,n,i,r){t.addEventListener(n,i,r),this.boundListeners.push({target:t,type:n,handler:i})},t.prototype.addHeadStyle=function(t){if("undefined"!=typeof document){var n=document.createElement("style");n.textContent=t,document.head.appendChild(n),this.headStyles.push(n)}},t.prototype.destroy=function(){var n,i,r,e;if(!this.destroyed){this.destroyed=!0,t.removeListener(this.messageListener);try{for(var o=tu(this.boundListeners),s=o.next();!s.done;s=o.next()){var u=s.value,a=u.target,c=u.type,f=u.handler;a.removeEventListener(c,f)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this.boundListeners.length=0;try{for(var h=tu(this.headStyles),d=h.next();!d.done;d=h.next()){d.value.remove()}}catch(t){r={error:t}}finally{try{d&&!d.done&&(e=h.return)&&e.call(h)}finally{if(r)throw r.error}}this.headStyles.length=0,this.sdkEventListener=null,this.onDestroy()}},t.prototype.onDestroy=function(){},t.removeListener=function(n){t.listeners=t.listeners.filter(function(t){return t!==n}),0===t.listeners.length&&t.windowListener&&"undefined"!=typeof window&&(window.removeEventListener("message",t.windowListener),t.windowListener=null,t.isListening=!1)},t.parseSdkEvent=function(t){var n=t;if("string"==typeof n)try{var i=JSON.parse(n);if("ANALYTICS"===i.eventName)return{target:"GLU_SDK",action:{type:"ANALYTICS",data:i.data}};n=i}catch(t){return null}return n&&"object"===Ha(n)&&"GLU_SDK"===n.target?n:null},t.dispatchToListeners=function(n,i){var r,e;try{for(var o=tu(t.listeners),s=o.next();!s.done;s=o.next()){var u=s.value;try{u(n,i)}catch(t){}}}catch(t){r={error:t}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(r)throw r.error}}},t.installWindowListener=function(){if("undefined"!=typeof window){var n=function(n){var i=t.parseSdkEvent(n.data);i&&(t.dispatchToListeners(n.source,i),n.stopPropagation())};window.addEventListener("message",n),t.windowListener=n,t.isListening=!0}},t.prototype.urlModifier=function(t,n){var i=t.includes("?")?"&":"?";return i+="source=JS_SDK",(null==n?void 0:n.token)&&(i+="&token=".concat(this.config.token)),this.config.isEmbedded&&(i+="&isEmbedded=true"),this.config.userId||(i+="¬LoggedIn=true"),encodeURI(t+i)},t.prototype.listen=function(t){this.sdkEventListener=t},t.prototype.sendMessageToContent=function(t){var n={target:"GLU_SDK",action:t};if(this.element instanceof HTMLIFrameElement){var i=this.element.contentWindow;i&&"function"==typeof i.postMessage&&i.postMessage(n,"*")}},t.listeners=[],t.isListening=!1,t.windowListener=null,t}(),np=["https://img.icons8.com/ios-filled/24/000000/rocket.png","https://img.icons8.com/ios-filled/24/000000/gift.png","https://img.icons8.com/ios-filled/24/000000/money.png"],ip=function(t){function n(n,i){var r=t.call(this,i)||this;if(r.data=n,r.campaignId=r.extractCampaignId(),!r.campaignId)throw new Error("ACCEPT_GUARD content missing conditions.campaignId");if(!r.config.allCampaignsMap.byId[r.campaignId])throw new Error("ACCEPT_GUARD: campaign ".concat(r.campaignId," not present in campaign map"));return r.createElement(),r}return Ys(n,t),n.prototype.extractCampaignId=function(){var t,n=null===(t=this.data.conditions)||void 0===t?void 0:t.campaignId;return"string"==typeof n?n:Array.isArray(n)&&void 0!==n[0]?String(n[0]):""},n.prototype.createElement=function(){var t,n,i,r,e,o=this,s="display: flex; justify-content: center; align-items: center;",u="background-color: #fff; text-align: center; padding: 30px 20px; max-width: 400px; width: 100%; margin: 10px;",a="background-color: #e0f7fa; border-radius: 50%; padding: 15px; margin: 0 auto 20px; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;",c="width: 60px; height: 60px;",f="font-size: 22px; font-weight: bold; color: #333; margin: 20px 0;",h="list-style: none; padding: 0; margin: 0 0 20px; text-align: left;",d="display: flex; align-items: center; margin-bottom: 15px; font-size: 16px;",v="margin-right: 10px;",l="background-color: #6c63ff; color: #fff; border: none; border-radius: 25px; padding: 12px 25px; font-size: 16px; cursor: pointer; width: 80%; margin: 0 auto 10px;",g="background: none; border: none; color: #888; font-size: 14px; cursor: pointer; margin-top: 5px;",m=document.createElement("div");m.style.cssText=s;var p=document.createElement("div");p.style.cssText=u;var w=document.createElement("div");w.style.cssText=a;var y=document.createElement("img");y.src="https://img.icons8.com/color/96/000000/fire-element.png",y.style.cssText=c,w.appendChild(y);var b=document.createElement("h1");b.innerText="Can you complete a 7-day earning streak?",b.style.cssText=f;var E=document.createElement("ul");E.style.cssText=h;var _=[{icon:null!==(i=np[0])&&void 0!==i?i:"",text:"Start a streak anytime until [DATE HERE] by earning at least $1"},{icon:null!==(r=np[1])&&void 0!==r?r:"",text:"Claim a bonus reward for each streak day"},{icon:null!==(e=np[2])&&void 0!==e?e:"",text:"Complete a 7-day streak and earn an additional up to $50 reward"}];try{for(var I=tu(_),T=I.next();!T.done;T=I.next()){var S=T.value,A=document.createElement("li");A.style.cssText=d;var O=document.createElement("img");O.src=S.icon,O.style.cssText=v;var N=document.createElement("span");N.innerText=S.text,A.appendChild(O),A.appendChild(N),E.appendChild(A)}}catch(n){t={error:n}}finally{try{T&&!T.done&&(n=I.return)&&n.call(I)}finally{if(t)throw t.error}}var k=document.createElement("button");k.innerText="Earn to start your streak",k.style.cssText=l,this.bindEvent(k,"click",function(){o.accept()});var D=document.createElement("button");D.innerText="Not now",D.style.cssText=g,this.bindEvent(D,"click",function(){var t;null===(t=o.sdkEventListener)||void 0===t||t.call(o,{target:"GLU_SDK",action:{type:"CLOSE_CONTAINER_CONTENT"}})}),p.appendChild(w),p.appendChild(b),p.appendChild(E),p.appendChild(k),p.appendChild(D),m.appendChild(p),this.element=m},n.prototype.accept=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,fetch("https://api.customerglu.com/reward/v1.1/user/program/accept",{method:"POST",headers:{authorization:"Bearer ".concat(this.config.token),"content-type":"application/json"},body:JSON.stringify({campaignId:this.campaignId,choice:"accept"})})];case 1:if(!(t=e.sent()).ok)throw new Error("Accept failed with status ".concat(t.status));return n={target:"GLU_SDK",action:{type:"TOGGLE_CONTAINER_CONTENT",id:jm(),content:{typeId:"CAMPAIGN",conditions:{campaignId:[this.campaignId]}},container:{typeId:"POP_UP",css:".__glu_container { \n background-color: #000; \n border-radius: 0px;\n max-width: none;\n max-height: none;\n height: 100vh;\n width: 100vw;\n } \n .__glu_backdrop { background-color: rgba(0,0,0,0.5); \n background-color: rgba(0,0,0,0.5); \n }",height:"",elementHookId:""}}},null===(r=this.sdkEventListener)||void 0===r||r.call(this,n),[3,3];case 2:return i=e.sent(),console.error("[gamification] ACCEPT_GUARD accept failed",i),[3,3];case 3:return[2]}})})},n}(tp);function rp(t,n){var i=document.createElement("iframe");if(i.classList.add(Xv.iframe.className),i.style.height="100%",i.style.width="100%",i.style.display="block",i.setAttribute("fetchpriority","high"),n){var r=performance.now();i.addEventListener("load",function(){return n(performance.now()-r)},{once:!0})}return i.src=t,i}var ep,op=function(t){function n(n,i){var r=t.call(this,i)||this,e=r.resolveUrl(n);return r.element=rp(r.urlModifier(e),i.onLoad),r}return Ys(n,t),n.prototype.resolveUrl=function(t){var n,i,r,e=null!==(r=t.conditions)&&void 0!==r?r:{};if(0===Object.keys(e).length){if(t.campaignId)if(f=this.config.allCampaignsMap.byId[t.campaignId])return f.url;throw new Error("CAMPAIGN content has no conditions")}var o=this.config.allCampaignsMap,s=o.allIds,u=o.byId;try{for(var a=tu(s),c=a.next();!c.done;c=a.next()){var f;if((f=u[c.value])&&this.campaignMatches(f,e))return f.url}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}throw new Error("CAMPAIGN_NOT_FOUND")},n.prototype.campaignMatches=function(t,n){var i,r,e;try{for(var o=tu(Object.keys(n)),s=o.next();!s.done;s=o.next()){var u=s.value,a=n[u],c=t[u],f=null===(e=t.banner)||void 0===e?void 0:e[u];if("string"==typeof a){if(a!==c&&a!==f)return!1}else{if(!Array.isArray(a))return!1;if(!a.includes(c)&&!a.includes(f))return!1}}}catch(t){i={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return!0},n}(tp),sp=function(t){function n(n,i){var r=t.call(this,i)||this;r.actionId=jm(),r.data=n;var e=r.lookupCampaign();if(!(null==e?void 0:e.banner))throw new Error("DYNAMIC content requires a campaign with banner state");return r.bannerData=e.banner,r.createElement(),r}return Ys(n,t),n.prototype.lookupCampaign=function(){var t,n=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==n?void 0:n.type)){var i=null===(t=n.content.conditions)||void 0===t?void 0:t.campaignId,r="";if("string"==typeof i?r=i:Array.isArray(i)&&void 0!==i[0]&&(r=String(i[0])),r)return this.config.allCampaignsMap.byId[r]}},n.prototype.createElement=function(){var t,n,i=this,r=this.bannerData,e=null!==(t=this.data.state)&&void 0!==t?t:{},o=r.userCampaignStatus,s=null!==(n=e[o])&&void 0!==n?n:{title:"",body:""},u=r.stepCompleted,a=r.activityCount,c=r.totalCampaignParticipants,f=r.activityExpiry,h=Math.floor(Date.now()/1e3),d=Math.max(0,f-h),v=Math.floor(d/3600),l=Math.floor(d%3600/60),g="".concat(v,"h").concat(l.toString().padStart(2,"0"),"m"),m=document.createElement("div");m.className="element";var p=document.createElement("div");p.className="progress-text-container";var w=document.createElement("div");w.setAttribute("class","progress-container");var y="http://www.w3.org/2000/svg",b=document.createElementNS(y,"svg");b.setAttribute("class","progress-circle"),b.setAttribute("viewBox","0 0 36 36");var E=document.createElementNS(y,"path");E.setAttribute("class","progress-bg"),E.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831");var _=document.createElementNS(y,"path");_.setAttribute("class","progress"),_.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831");var I=a>0?u/a*100:0;_.setAttribute("stroke-dasharray","".concat(I,", 100")),_.setAttribute("stroke-linecap",0===u?"butt":"round"),b.appendChild(E),b.appendChild(_);var T=document.createElement("div");T.setAttribute("class","inner-content");var S=document.createElement("div");S.setAttribute("class","primary-icon-container");var A=document.createElement("img");A.setAttribute("class","icon-image"),A.setAttribute("src","https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/b4194687-57e6-4272-83d5-b7867053408d.svg"),S.appendChild(A),T.appendChild(S),w.appendChild(b),w.appendChild(T);var O=document.createElement("p");O.setAttribute("class","progress-text"),O.innerText="".concat(u,"/").concat(a),p.appendChild(w),p.appendChild(O),m.appendChild(p);var N=document.createElement("img");N.setAttribute("class","smaller-icon"),N.setAttribute("src","https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/c7d4d74e-c9ef-4ba1-8646-277c2ba2e91d.svg"),w.appendChild(N);var k=document.createElement("div");if(k.className="time-title-body-container",m.appendChild(k),"completed"!==o){var D=document.createElement("div");D.className="icon-text-container";var C=document.createElement("img");C.className="icon-container",C.src="pristine"===o?"https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/2ca387f9-60b5-40bb-af78-272d81a73021.svg":"https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/9406d009-5604-4e13-a03b-4e24a7ca4264.svg",D.appendChild(C);var x=document.createElement("p");x.className="timer-text",x.innerText="pristine"===o?"".concat(c," users currently streaking"):g,D.appendChild(x),k.appendChild(D)}var R=document.createElement("div");R.className="title-body-container";var M=document.createElement("p");M.className="title-text",M.innerText=s.title,R.appendChild(M);var U=document.createElement("p");U.className="body-text",U.innerText=s.body,R.appendChild(U),k.appendChild(R);var P=document.createElement("div");P.className="right-icon-container";var L=document.createElement("img");L.className="right-icon",L.src="https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/5ca637bd-2b75-4996-a3aa-14e58b60c07e.svg",P.appendChild(L),m.appendChild(P),this.addHeadStyle(this.buildStylesheet(u===a)),this.bindEvent(m,"click",function(t){t.stopPropagation(),t.preventDefault(),i.handleClick()}),this.element=m},n.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener)if(this.bannerData.checkAccepted&&this.bannerData.accepted){var n=Js(Js({},t),{id:this.actionId});this.sdkEventListener({target:"GLU_SDK",action:n})}else{var i={target:"GLU_SDK",action:Js(Js({},t),{id:this.actionId,content:Js(Js({},t.content),{typeId:"ACCEPT_GUARD"}),container:Js(Js({},t.container),{typeId:"BOTTOM_SHEET",css:".__glu_container {\n background-color: #fff;\n height: 57vh\n }\n .__glu_backdrop {\n background-color: rgba(0,0,0,0.5);\n }"})})};this.sdkEventListener(i)}},n.prototype.buildStylesheet=function(t){return"\n *{ margin: 0; padding: 0; box-sizing: border-box; }\n body{ font-family: 'Poppins', sans-serif; }\n .element { border-radius: 8px; width: 100%; padding: 8px 0; align-items: stretch; background-color: white; display: flex; }\n .progress-text-container{ display: flex; flex-direction: column; align-items: center; width: 20%; }\n .progress-container { align-items: center; display: flex; flex-direction: column; width: 80%; position: relative; }\n .progress-bg { fill: none; stroke: #d3d3d3; stroke-width: 3; }\n .progress { fill: none; stroke: #FF0099; stroke-width: 3; transition: stroke-dasharray 0.3s ease; }\n .inner-content { height: 63%; width: 63%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; background-color: #E9F2F9; border-radius: 50%; }\n .primary-icon-container { height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; }\n .icon-image{ height: 70%; width: 70%; }\n .smaller-icon { display: ".concat(t?"block":"none","; position: absolute; bottom: 9%; width: 31%; right: 0%; border-radius: 50%; background-color: white; padding: 1px; }\n .progress-text { margin: 0; font-size: 12px; font-weight: 400; color: #757575; }\n .time-title-body-container { max-height: 100%; display: flex; gap: 8px; flex-direction: column; justify-content: center; width: 65%; }\n .icon-text-container { display: flex; border: 1px solid #D8D8D8; border-radius: 4px; gap: 4px; padding: 2px 4px; width: fit-content; align-items: center; }\n .icon-container { width: 12px; height: 12px; }\n .timer-text { margin: 0px; font-size: 12px; font-weight: 600; }\n .title-body-container { display: flex; gap: 8px; flex-direction: column; }\n .title-text { margin: 0; font-size: 16px; font-weight: 600; }\n .body-text { margin: 0; font-size: 12px; font-weight: 400; color: #757575; }\n .right-icon-container { display: flex; justify-content: center; align-items: center; width: 15%; }\n .right-icon { width: 20px; height: 20px; }\n ")},n}(tp),up=function(t){function n(n,i){var r=t.call(this,i)||this;r.actionId=jm(),r.data=n;var e=r.lookupCampaign();return r.createElement(e),r}return Ys(n,t),n.prototype.lookupCampaign=function(){var t,n=this.data.campaignId;if(n)return this.config.allCampaignsMap.byId[n];var i=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==i?void 0:i.type)){var r=null===(t=i.content.conditions)||void 0===t?void 0:t.campaignId,e="";return"string"==typeof r?e=r:Array.isArray(r)&&void 0!==r[0]&&(e=String(r[0])),e?this.config.allCampaignsMap.byId[e]:void 0}},n.prototype.createElement=function(t){var n,i,r,e,o,s,u,a,c,f=this,h=null==t?void 0:t.banner,d=null!==(n=null==h?void 0:h.stepCompleted)&&void 0!==n?n:0,v=null!==(i=null==h?void 0:h.activityCount)&&void 0!==i?i:0,l=null!==(r=null==h?void 0:h.userCampaignStatus)&&void 0!==r?r:"pristine",g=this.findWidgetState(d,l),m=null!==(e=null==g?void 0:g.title)&&void 0!==e?e:"",p=null!==(o=null==g?void 0:g.body)&&void 0!==o?o:"",w=null!==(u=null===(s=null==g?void 0:g.progressBar)||void 0===s?void 0:s.progressRewardText)&&void 0!==u?u:"",y=null!==(c=null!==(a=this.data.progressBarIcon)&&void 0!==a?a:this.data.src)&&void 0!==c?c:"",b=v>0?Math.round(d/v*100):0;this.data.widgetCss&&this.addHeadStyle(this.data.widgetCss);var E=document.createElement("div");E.className="banner-container";var _=document.createElement("div");_.className="header-progressbar-container";var I=document.createElement("div");I.className="header-container";var T=document.createElement("p");T.className="heading-text",T.innerHTML=m;var S=document.createElement("p");S.className="body-text",S.textContent=p,I.appendChild(T),I.appendChild(S);var A=document.createElement("div");A.className="progressbar-parent-container";var O=document.createElement("span");O.className="progressbar-text",O.textContent=w;var N=document.createElement("div");N.className="progressbar-container";var k=document.createElement("div");k.className="total-progress";var D=document.createElement("div");D.className="completed-progress",D.style.width="".concat(b,"%"),N.appendChild(k),N.appendChild(D),A.appendChild(O),A.appendChild(N),_.appendChild(I),_.appendChild(A);var C=document.createElement("div");if(C.className="right-icon-container",y){var x=document.createElement("img");x.src=y,x.style.width="48px",x.style.height="48px",C.appendChild(x)}E.appendChild(_),E.appendChild(C),this.bindEvent(E,"click",function(t){t.stopPropagation(),t.preventDefault(),f.handleClick()}),this.element=E},n.prototype.findWidgetState=function(t,n){var i,r,e=this.data.IWidgetState;if(null==e?void 0:e.length)return null!==(r=null!==(i=e.find(function(i){return i.step===t&&i.state===n}))&&void 0!==i?i:e.find(function(n){return n.step===t}))&&void 0!==r?r:e[0]},n.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener){var n={target:"GLU_SDK",action:Js(Js({},t),{id:this.actionId})};this.sdkEventListener(n)}},n}(tp),ap={};!function(){if(ep)return ap;ep=1;var t=Sr(),n=Rt(),i=$t(),r=Nn(),e=Gi(),o=Ec(),s=of(),u=G(),a=Hh(),c=ve(),f=fm(),h=hm(),d=Ht(),v=dm(),l=[],g=n(l.sort),m=n(l.push),p=u(function(){l.sort(void 0)}),w=u(function(){l.sort(null)}),y=c("sort"),b=!u(function(){if(d)return d<70;if(!(f&&f>3)){if(h)return!0;if(v)return v<603;var t,n,i,r,e="";for(t=65;t<76;t++){switch(n=String.fromCharCode(t),t){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(r=0;r<47;r++)l.push({k:n+r,v:i})}for(l.sort(function(t,n){return n.v-t.v}),r=0;r<l.length;r++)n=l[r].k.charAt(0),e.charAt(e.length-1)!==n&&(e+=n);return"DGBEFHACIJK"!==e}});t({target:"Array",proto:!0,forced:p||!w||!y||!b},{sort:function(t){void 0!==t&&i(t);var n=r(this);if(b)return void 0===t?g(n):g(n,t);var u,c,f=[],h=e(n);for(c=0;c<h;c++)c in n&&m(f,n[c]);for(a(f,function(t){return function(n,i){if(void 0===i)return-1;if(void 0===n)return 1;if(void 0!==t)return+t(n,i)||0;var r=s(n),e=s(i);return r===e?0:r>e?1:-1}}(t)),u=e(f),c=0;c<u;)n[c]=f[c++];for(;c<h;)o(n,c++);return n}})}();var cp=function(t){function n(n,i){var r=t.call(this,i)||this;r.actionId=jm(),r.data=n;var e=r.lookupCampaign();return r.createElement(e),r}return Ys(n,t),n.prototype.lookupCampaign=function(){var t,n=this.data.campaignId;if(n)return this.config.allCampaignsMap.byId[n];var i=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==i?void 0:i.type)){var r=null===(t=i.content.conditions)||void 0===t?void 0:t.campaignId,e="";return"string"==typeof r?e=r:Array.isArray(r)&&void 0!==r[0]&&(e=String(r[0])),e?this.config.allCampaignsMap.byId[e]:void 0}},n.prototype.buildHeaderImage=function(t){if(!t)return null;var n=document.createElement("div");n.className="image-container-ms2";var i=document.createElement("img");return i.className="header-image",i.src=t,n.appendChild(i),n},n.prototype.buildProgressBar=function(t,n){var i=document.createElement("div");i.className="progressbar-wrapper-ms2";var r=document.createElement("div");r.className="progressbar-container-ms2";var e=document.createElement("div");e.className="total-progress-ms2";var o=document.createElement("div");o.className="completed-progress-ms2",o.style.width="".concat(t,"%"),r.appendChild(e),r.appendChild(o);var s=document.createElement("div");s.className="progressbar-text-container-ms2";var u=document.createElement("span");return u.className="progressbar-text-ms2",u.textContent=n,s.appendChild(u),i.appendChild(r),i.appendChild(s),i},n.prototype.buildStepCircle=function(t,n){var i=document.createElement("div");i.className="step";var r=document.createElement("div");r.className=n?"circle completed":"circle";var e=document.createElement("span");return e.className=n?"amount completed":"amount",e.textContent=t,r.appendChild(e),i.appendChild(r),i},n.prototype.buildStepLabel=function(t,n,i){var r=document.createElement("div"),e="label inactive";return n?e="label completed":i&&(e="label current"),r.className=e,r.textContent=t,r},n.prototype.buildStepRows=function(t,n,i){var r=this,e=document.createElement("div");e.className="steps-container";var o=document.createElement("div");return o.className="labels-container",n.forEach(function(s,u){var a,c,f,h,d,v=null!==(a=t.find(function(t){return t.step===s&&"pristine"===t.state}))&&void 0!==a?a:t.find(function(t){return t.step===s}),l=null!==(f=null===(c=null==v?void 0:v.progressBar)||void 0===c?void 0:c.progressRewardText)&&void 0!==f?f:"",g=null!==(d=null===(h=null==v?void 0:v.progressBar)||void 0===h?void 0:h.progressLabel)&&void 0!==d?d:"",m=s<i,p=s===i;if(e.appendChild(r.buildStepCircle(l,m||p)),u<n.length-1){var w=document.createElement("div");w.className=m?"connector completed":"connector",e.appendChild(w)}o.appendChild(r.buildStepLabel(g,m,p))}),[e,o]},n.prototype.buildCtaButton=function(t){var n=this,i=document.createElement("div");i.className="button-container";var r=document.createElement("button");return r.className="view-rewards-button",r.textContent=t,this.bindEvent(r,"click",function(t){t.stopPropagation(),t.preventDefault(),n.handleClick()}),i.appendChild(r),i},n.prototype.createElement=function(t){var n,i,r,e,o,s,u,a,c,f,h=this,d=null==t?void 0:t.banner,v=null!==(n=null==d?void 0:d.stepCompleted)&&void 0!==n?n:0,l=null!==(i=null==d?void 0:d.activityCount)&&void 0!==i?i:0,g=null!==(r=null==d?void 0:d.userCampaignStatus)&&void 0!==r?r:"pristine",m=null!==(e=this.data.IWidgetState)&&void 0!==e?e:[],p=this.findWidgetState(v,g,m),w=l>0?Math.round(v/l*100):0;this.data.widgetCss&&this.addHeadStyle(this.data.widgetCss);var y=document.createElement("div");y.className="card-container-ms2";var b=document.createElement("div");b.className="banner-container-ms2";var E=null!==(u=null!==(s=null!==(o=null==p?void 0:p.headerImage)&&void 0!==o?o:this.data.progressMeterIcon)&&void 0!==s?s:this.data.src)&&void 0!==u?u:"",_=this.buildHeaderImage(E);_&&b.appendChild(_);var I=document.createElement("div");I.className="header-progressbar-container-ms2";var T=document.createElement("div");T.className="heading-container-ms2";var S=document.createElement("p");S.className="heading-text-ms2",S.innerHTML=null!==(a=null==p?void 0:p.title)&&void 0!==a?a:"",T.appendChild(S),I.appendChild(T),I.appendChild(this.buildProgressBar(w,null!==(f=null===(c=null==p?void 0:p.progressMeter)||void 0===c?void 0:c.completedText)&&void 0!==f?f:""));var A=iu([],nu(new Set(m.map(function(t){return t.step}))),!1).sort(function(t,n){return t-n});if(A.length>0){var O=nu(this.buildStepRows(m,A,v),2),N=O[0],k=O[1];I.appendChild(N),I.appendChild(k)}(null==p?void 0:p.ctaText)&&I.appendChild(this.buildCtaButton(p.ctaText)),b.appendChild(I),y.appendChild(b),this.bindEvent(y,"click",function(t){t.stopPropagation(),t.preventDefault(),h.handleClick()}),this.element=y},n.prototype.findWidgetState=function(t,n,i){var r,e;return null!==(e=null!==(r=i.find(function(i){return i.step===t&&i.state===n}))&&void 0!==r?r:i.find(function(n){return n.step===t}))&&void 0!==e?e:i[0]},n.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener){var n={target:"GLU_SDK",action:Js(Js({},t),{id:this.actionId})};this.sdkEventListener(n)}},n}(tp),fp=function(t){function n(n,i){var r=t.call(this,i)||this;r.actionId=jm(),r.isExpanded=!0,r.data=n;var e=r.lookupCampaign();return r.createElement(e),r}return Ys(n,t),n.prototype.lookupCampaign=function(){var t,n=this.data.campaignId;if(n)return this.config.allCampaignsMap.byId[n];var i=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==i?void 0:i.type)){var r=null===(t=i.content.conditions)||void 0===t?void 0:t.campaignId,e="";return"string"==typeof r?e=r:Array.isArray(r)&&void 0!==r[0]&&(e=String(r[0])),e?this.config.allCampaignsMap.byId[e]:void 0}},n.prototype.buildHeader=function(t,n){var i=document.createElement("div");i.className="header-container-ms3";var r=document.createElement("div");if(r.className="header-content-ms3",n){var e=document.createElement("span");e.className="progress-badge-ms3",e.textContent=n,r.appendChild(e)}var o=document.createElement("p");if(o.className="heading-ms3",o.innerHTML=t,r.appendChild(o),i.appendChild(r),this.data.progressBarIcon){var s=document.createElement("img");s.className="dropdown-icon-ms3",s.src=this.data.progressBarIcon,i.appendChild(s)}return i},n.prototype.buildStepDiv=function(t,n,i,r){var e=document.createElement("div");e.className="step-ms3";var o=document.createElement("div"),s="circle-ms3";n?s+=" completed":i&&(s+=" current"),o.className=s;var u=document.createElement("span");if(u.className=i?"amount-ms3 current":"amount-ms3",u.textContent=t,o.appendChild(u),e.appendChild(o),r){var a=document.createElement("div");a.className=n?"connector-ms3 completed":"connector-ms3";var c=document.createElement("div");c.className="connector-progress-ms3",a.appendChild(c),e.appendChild(a)}return e},n.prototype.buildStepsContainer=function(t,n,i){var r=this,e=document.createElement("div");return e.className="steps-container-ms3",n.forEach(function(o,s){var u,a,c,f=null!==(u=t.find(function(t){return t.step===o&&"pristine"===t.state}))&&void 0!==u?u:t.find(function(t){return t.step===o}),h=null!==(c=null===(a=null==f?void 0:f.progressBar)||void 0===a?void 0:a.progressRewardText)&&void 0!==c?c:"",d=o<i,v=o===i;e.appendChild(r.buildStepDiv(h,d,v,s<n.length-1))}),e},n.prototype.buildCtaButton=function(t){var n=this,i=document.createElement("div");i.className="button-container-ms3";var r=document.createElement("button");r.className="action-button-ms3",r.textContent=t,this.bindEvent(r,"click",function(t){t.stopPropagation(),t.preventDefault(),n.handleClick()});var e=document.createElement("div");return e.className="shine-effect",i.appendChild(r),i.appendChild(e),i},n.prototype.createElement=function(t){var n,i,r,e,o=this,s=null==t?void 0:t.banner,u=null!==(n=null==s?void 0:s.stepCompleted)&&void 0!==n?n:0,a=null!==(i=null==s?void 0:s.userCampaignStatus)&&void 0!==i?i:"pristine",c=null!==(r=this.data.IWidgetState)&&void 0!==r?r:[],f=this.findWidgetState(u,a,c);this.data.widgetCss&&this.addHeadStyle(this.data.widgetCss);var h=document.createElement("div");h.className="content-container-ms3";var d=document.createElement("div");d.className="main-content-ms3";var v=iu([],nu(new Set(c.map(function(t){return t.step}))),!1).sort(function(t,n){return t-n});if(v.length>0&&d.appendChild(this.buildStepsContainer(c,v,u)),null==f?void 0:f.body){var l=document.createElement("p");l.className="description-ms3",l.textContent=f.body,d.appendChild(l)}(null==f?void 0:f.ctaText)&&d.appendChild(this.buildCtaButton(f.ctaText)),h.appendChild(d);var g=this.buildHeader(null!==(e=null==f?void 0:f.title)&&void 0!==e?e:"",null==f?void 0:f.badgeTag);this.bindEvent(g,"click",function(t){t.stopPropagation(),o.isExpanded=!o.isExpanded,h.classList.toggle("hidden",!o.isExpanded)});var m=document.createElement("div");m.className="banner-container-ms3",m.appendChild(g),m.appendChild(h);var p=document.createElement("div");p.className="card-container-ms3",p.appendChild(m),this.element=p},n.prototype.findWidgetState=function(t,n,i){var r,e;return null!==(e=null!==(r=i.find(function(i){return i.step===t&&i.state===n}))&&void 0!==r?r:i.find(function(n){return n.step===t}))&&void 0!==e?e:i[0]},n.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener){var n={target:"GLU_SDK",action:Js(Js({},t),{id:this.actionId})};this.sdkEventListener(n)}},n}(tp),hp=function(t){function n(n,i){var r=t.call(this,i)||this;if(!n.url)throw new Error("NUDGE content missing `url`");return r.element=rp(r.urlModifier(n.url),i.onLoad),r}return Ys(n,t),n}(tp),dp=function(t){function n(n,i){var r=t.call(this,i)||this;if(!n.campaignId)throw new Error("PROGRAM content missing `campaignId`");var e="".concat(r.config.allCampaignsMap.base,"/program/?campaignId=").concat(n.campaignId);return r.element=rp(r.urlModifier(e,{token:!0}),i.onLoad),r}return Ys(n,t),n}(tp),vp=function(t){function n(n,i){var r=t.call(this,i)||this;if(!n.rewardUserId)throw new Error("REWARD content missing `rewardUserId`");var e="".concat(r.config.allCampaignsMap.base,"/reward/?rewardUserId=").concat(n.rewardUserId);return r.element=rp(r.urlModifier(e,{token:!0}),i.onLoad),r}return Ys(n,t),n}(tp),lp=function(t){function n(n,i){var r=t.call(this,i)||this;if(r.actionId=jm(),r.data=n,r.shouldGateOnCampaign()){var e=r.extractGatedCampaignId();return e&&r.config.allCampaignsMap.byId[e]&&r.createElement(),r}return r.createElement(),r}return Ys(n,t),n.prototype.shouldGateOnCampaign=function(){var t,n,i,r=this.data.action;return!(!r||"TOGGLE_CONTAINER_CONTENT"!==r.type)&&("CAMPAIGN"===(null===(t=r.content)||void 0===t?void 0:t.typeId)&&void 0!==(null===(i=null===(n=r.content)||void 0===n?void 0:n.conditions)||void 0===i?void 0:i.campaignId))},n.prototype.extractGatedCampaignId=function(){var t,n;if("TOGGLE_CONTAINER_CONTENT"!==(null===(t=this.data.action)||void 0===t?void 0:t.type))return null;var i=null===(n=this.data.action.content.conditions)||void 0===n?void 0:n.campaignId;return"string"==typeof i?i:Array.isArray(i)&&void 0!==i[0]?String(i[0]):null},n.prototype.createElement=function(){var t=this;if(!this.data.src)throw new Error("STATIC content missing `src`");var n=document.createElement("img");n.style.maxWidth="100%",n.style.maxHeight="100%",n.style.display="block",n.style.cursor="pointer";var i=this.config.onLoad;if(i){var r=performance.now();this.bindEvent(n,"load",function(){return i(performance.now()-r)},{once:!0})}n.src=this.data.src,this.bindEvent(n,"click",function(n){n.stopPropagation(),n.preventDefault();var i=t.data.action;if(i&&t.sdkEventListener){var r={target:"GLU_SDK",action:"TOGGLE_CONTAINER_CONTENT"===i.type?Js(Js({},i),{id:t.actionId}):i};t.sdkEventListener(r)}}),this.element=n},n}(tp),gp=function(t){function n(n,i){var r=t.call(this,i)||this;return r.element=rp(r.urlModifier(r.config.allCampaignsMap.defaultUrl),i.onLoad),r}return Ys(n,t),n}(tp);var mp=function(){function t(t,n){var i=this;this.sdkEventListener=null,this.closeListener=null,this.entryPoint=t,this.onOpen=n.onOpen;var r=Js(Js({},n),{isEmbedded:"EMBEDDED"===t.container.typeId});if(this.content=function(t,n){var i=t.content;switch(i.typeId){case"CAMPAIGN":return new op(i,n);case"WALLET":return new gp(i,n);case"NUDGE":return new hp(i,n);case"PROGRAM":return new dp(i,n);case"REWARD":return new vp(i,n);case"STATIC":return new lp(i,n);case"DYNAMIC":return new sp(i,n);case"DYNAMIC_MULTISTEP_1":return new up(i,n);case"DYNAMIC_MULTISTEP_2":return new cp(i,n);case"DYNAMIC_MULTISTEP_3":return new fp(i,n);case"ACCEPT_GUARD":return new ip(i,n);default:var r=i.typeId;throw new Error("Unknown content typeId: ".concat(String(r)))}}(t,r),!this.content.element)throw new Error("Content ".concat(t.content.typeId," did not produce an element"));this.container=function(t,n){var i=t.container,r={typeId:i.typeId,css:i.css};switch(i.typeId){case"ICON_BUTTON":return new Jm(r,n);case"CHAT_BOX":return new Hm(r,n);case"POP_UP":return new Zm(r,n);case"BOTTOM_SHEET":return new zm(Js(Js({},r),{height:i.height}),n);case"NATIVE_BANNER":return new Qm(Js(Js({},r),{elementHookId:i.elementHookId}),n);case"EMBEDDED":return new Ym(Js(Js({},r),{elementHookId:i.elementHookId}),n);default:var e=i.typeId;throw new Error("Unknown container typeId: ".concat(String(e)))}}(t,this.content.element),this.content.listen(function(t){var n;return null===(n=i.sdkEventListener)||void 0===n?void 0:n.call(i,t)}),this.container.addCloseListener(function(){var t;return null===(t=i.closeListener)||void 0===t?void 0:t.call(i)})}return Object.defineProperty(t.prototype,"containerTypeId",{get:function(){return this.entryPoint.container.typeId},enumerable:!1,configurable:!0}),t.prototype.addEventListener=function(t){this.sdkEventListener=t},t.prototype.addCloseEventListener=function(t){this.closeListener=t},t.prototype.open=function(){var t;this.container.show(),null===(t=this.onOpen)||void 0===t||t.call(this,this.entryPoint)},t.prototype.preload=function(){this.container.preload()},t.prototype.close=function(){this.container.hide()},t.prototype.toggle=function(){this.isOpen()?this.close():this.open()},t.prototype.isOpen=function(){return this.container.isShown},t.prototype.sendMessage=function(t){this.content.sendMessageToContent(t)},t.prototype.destroy=function(){this.container.destroy(),this.content.destroy(),this.sdkEventListener=null,this.closeListener=null,this.onOpen=void 0},t}(),pp=function(){function t(){}return t.prototype.render=function(t,n,i){var r,e;if("undefined"!=typeof document){document.querySelectorAll("[data-glu-loyalty]").forEach(function(t){t.remove()});try{for(var o=tu(t),s=o.next();!s.done;s=o.next()){var u=s.value,a=document.getElementById(u.embedId);a&&this.injectIframe(a,this.buildUrl(u.url,n),u.embedId,i)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(r)throw r.error}}}},t.prototype.buildUrl=function(t,n){if(!n)return t;var i=t.includes("?")?"&":"?";return"".concat(t).concat(i,"capToken=").concat(encodeURIComponent(n))},t.prototype.injectIframe=function(t,n,i,r){var e,o=document.createElement("iframe"),s=null==r?void 0:r.onLoad;if(s){var u=performance.now();o.addEventListener("load",function(){return s(i,performance.now()-u)},{once:!0})}o.src=n,o.setAttribute("data-glu-loyalty",i),o.style.cssText="border:none;width:100%;height:100%;",t.appendChild(o),null===(e=null==r?void 0:r.onOpen)||void 0===e||e.call(r,i)},t}(),wp=function(){function t(t,n,i,r,e){this.initialized=!1,this.userId=null,this.userAttributes=void 0,this.token=null,this.allCampaignsMap=null,this.entryPointMap=null,this.instances=new Map,this.dataDump=null,this.analyticsListener=null,this.lastSyncTimestamp=0,this.spaListenerCleanup=null,this.visibilityListenerCleanup=null,this.capToken=null,this.loyaltyRenderer=new pp,this.pagePathTrackingEnabled=!0,this.manualScreenName=null,this.pagePathTrackingExplicitlySet=!1,this.tokenRefetchInFlight=null,this.authFailureCount=0,this.authBackoffUntil=0,this.pendingTimers=new Set,this.initGeneration=0,this.syncGeneration=0,this.preconnectedOrigins=new Set,this.swPreloaded=!1,this.trackingState=new Map,this.ephemeralEntryPointIds=new Set,this.adHocEntryPointIds=new Set,this.writeKey=t,this.logger=i,this.storageManager=r,this.apiClient=new Wd(n,i),this.trackEvent=e}return t.prototype.initialize=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s,u,a,c,f,h,d,v,l;return Zs(this,function(g){switch(g.label){case 0:this.initialized&&(this.logger.info("GamificationManager re-initializing for new user",{userId:t}),this.clean()),this.logger.info("GamificationManager initializing",{userId:t}),i=++this.initGeneration,g.label=1;case 1:return g.trys.push([1,7,,8]),this.userId=t,this.userAttributes=n,this.preconnectFromCachedOrigin(),[4,Promise.all([this.storageManager.get(lh),this.loadFromCache(t)])];case 2:return r=nu.apply(void 0,[g.sent(),2]),e=r[0],o=r[1],i!==this.initGeneration?[2]:(e&&(this.capToken=e),o?(this.logger.info(Lf,{campaigns:null!==(a=null===(u=this.allCampaignsMap)||void 0===u?void 0:u.allIds.length)&&void 0!==a?a:0,entryPoints:null!==(f=null===(c=this.entryPointMap)||void 0===c?void 0:c.allIds.length)&&void 0!==f?f:0}),[3,5]):[3,3]);case 3:return this.logger.info(Ff),[4,this.fetchAndCache(t,n,i)];case 4:if(!g.sent())return[2];g.label=5;case 5:return this.preloadEntryPoints(),this.initialized=!0,this.logger.info(kf,{campaigns:null!==(d=null===(h=this.allCampaignsMap)||void 0===h?void 0:h.allIds.length)&&void 0!==d?d:0,entryPoints:null!==(l=null===(v=this.entryPointMap)||void 0===v?void 0:v.allIds.length)&&void 0!==l?l:0}),[4,this.refresh()];case 6:return g.sent(),i!==this.initGeneration?[2]:(this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks()),this.registerSpaListener(),this.registerVisibilityListener(),[3,8]);case 7:return s=g.sent(),this.logger.error(Df,s),[3,8];case 8:return[2]}})})},t.prototype.getCampaignsMap=function(){return this.allCampaignsMap},t.prototype.getEntryPointMap=function(){return this.entryPointMap},t.prototype.getToken=function(){return this.token},t.prototype.setCapToken=function(t){this.capToken=t,this.storageManager.set(lh,t).catch(function(){}),this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks())},t.prototype.getCapToken=function(){return this.capToken},t.prototype.enablePagePathTracking=function(t){this.pagePathTrackingEnabled=t,this.pagePathTrackingExplicitlySet=!0,this.storageManager.set(gh,String(t)).catch(function(){}),this.refresh()},t.prototype.restorePersistedPagePathTracking=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:return[4,this.storageManager.get(gh)];case 1:return null===(t=n.sent())||this.pagePathTrackingExplicitlySet||(this.pagePathTrackingEnabled="true"===t),[2]}})})},t.prototype.onScreenChanged=function(t){this.manualScreenName=t,this.pagePathTrackingEnabled||this.handleScreenChange()},t.prototype.setAnalyticsListener=function(t){this.analyticsListener=t},t.prototype.openEntryPoint=function(t){if(this.initialized){var n=this.getOrCreateInstance(t);null==n||n.open()}},t.prototype.closeEntryPoint=function(t){var n;this.initialized&&(null===(n=this.instances.get(t))||void 0===n||n.close())},t.prototype.clean=function(){var t,n,i,r,e,o;this.logger.info(xf),this.initGeneration++,this.syncGeneration++,null===(e=this.spaListenerCleanup)||void 0===e||e.call(this),this.spaListenerCleanup=null,null===(o=this.visibilityListenerCleanup)||void 0===o||o.call(this),this.visibilityListenerCleanup=null,this.lastSyncTimestamp=0;try{for(var s=tu(this.pendingTimers),u=s.next();!u.done;u=s.next()){var a=u.value;clearTimeout(a)}}catch(n){t={error:n}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}this.pendingTimers.clear();try{for(var c=tu(this.instances.values()),f=c.next();!f.done;f=c.next()){var h=f.value;h.isOpen()&&h.close(),h.destroy()}}catch(t){i={error:t}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(i)throw i.error}}this.instances.clear(),this.trackingState.clear(),this.ephemeralEntryPointIds.clear(),this.adHocEntryPointIds.clear(),this.userId&&(this.storageManager.remove(this.cacheKey(this.userId)).catch(function(){}),this.storageManager.remove(this.tokenCacheKey(this.userId)).catch(function(){})),this.userId=null,this.userAttributes=void 0,this.token=null,this.tokenRefetchInFlight=null,this.authFailureCount=0,this.authBackoffUntil=0,this.allCampaignsMap=null,this.entryPointMap=null,this.dataDump=null,this.capToken=null,this.storageManager.remove(lh).catch(function(){}),this.initialized=!1},t.prototype.destroy=function(){this.clean(),this.logger.info(Cf)},Object.defineProperty(t.prototype,"loyaltyUrls",{get:function(){var t,n;return null!==(n=null===(t=this.allCampaignsMap)||void 0===t?void 0:t.loyaltyUrls)&&void 0!==n?n:[]},enumerable:!1,configurable:!0}),t.prototype.resolveCurrentPath=function(){var t;return this.pagePathTrackingEnabled?"undefined"!=typeof window?window.location.href:"":null!==(t=this.manualScreenName)&&void 0!==t?t:""},t.prototype.refresh=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c,f;return Zs(this,function(h){switch(h.label){case 0:if(!this.entryPointMap)return[2];t=this.resolveCurrentPath(),this.logger.info(Mf,{entryPoints:this.entryPointMap.allIds.length,url:t}),n={},i=this.entryPointMap,r=this.initGeneration,h.label=1;case 1:h.trys.push([1,6,7,8]),e=tu(iu([],nu(i.allIds),!1)),o=e.next(),h.label=2;case 2:return o.done?[3,5]:(s=o.value,r!==this.initGeneration?[2]:(u=i.byId[s])?[4,this.refreshEntryPoint(u,n)]:[3,4]);case 3:h.sent(),h.label=4;case 4:return o=e.next(),[3,2];case 5:return[3,8];case 6:return a=h.sent(),c={error:a},[3,8];case 7:try{o&&!o.done&&(f=e.return)&&f.call(e)}finally{if(c)throw c.error}return[7];case 8:return[2]}})})},t.prototype.refreshEntryPoint=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s,u,a=this;return Zs(this,function(c){switch(c.label){case 0:return(i=null===(s=t.conditions)||void 0===s?void 0:s.singleOpenName)&&n[i]?[2]:this.isCampaignCompleted(t)?((null==(r=this.instances.get(t.id))?void 0:r.isOpen())&&r.close(),[2]):[4,Wv(t,this.userId,this.storageManager,this.logger,this.pendingTimers,this.resolveCurrentPath())];case 1:return c.sent()?(i&&(n[i]=!0),(e=null===(u=t.conditions)||void 0===u?void 0:u.delay)?(o=setTimeout(function(){a.pendingTimers.delete(o),a.openInstance(t)},1e3*e),this.pendingTimers.add(o)):this.openInstance(t),[2]):((null==(r=this.instances.get(t.id))?void 0:r.isOpen())&&r.close(),[2])}})})},t.prototype.openInstance=function(t){var n=this.getOrCreateInstance(t.id);null==n||n.open()},t.prototype.preloadEntryPoints=function(){var t,n;if(this.entryPointMap){this.preconnectToCampaignOrigin(),this.preloadServiceWorker();try{for(var i=tu(this.entryPointMap.allIds),r=i.next();!r.done;r=i.next()){var e=r.value;if(!this.instances.has(e)){var o=this.entryPointMap.byId[e];if(o&&!this.isCampaignCompleted(o)){var s=this.getOrCreateInstance(e);null==s||s.preload()}}}}catch(n){t={error:n}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},t.prototype.preconnectToCampaignOrigin=function(t){var n,i=null!=t?t:null===(n=this.allCampaignsMap)||void 0===n?void 0:n.base;if("undefined"!=typeof document&&i&&!this.preconnectedOrigins.has(i)){this.preconnectedOrigins.add(i);var r=document.createElement("link");r.rel="preconnect",r.href=i,document.head.appendChild(r)}},t.prototype.preconnectFromCachedOrigin=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.storageManager.get(wh)];case 1:return(t=n.sent())&&this.preconnectToCampaignOrigin(t),[3,3];case 2:return n.sent(),[3,3];case 3:return[2]}})})},t.prototype.preloadServiceWorker=function(){var t,n=this;if("undefined"!=typeof document&&(null===(t=this.allCampaignsMap)||void 0===t?void 0:t.base)&&!this.swPreloaded){this.swPreloaded=!0;var i="".concat(this.allCampaignsMap.base).concat(mh),r=document.createElement("iframe");r.setAttribute("aria-hidden","true"),r.setAttribute("sandbox","allow-scripts allow-same-origin"),r.style.cssText="position:absolute;left:-9999px;top:-9999px;width:1px;height:1px;border:0;",r.setAttribute("fetchpriority","low");var e=function(){r.remove(),clearTimeout(o),n.pendingTimers.delete(o)};r.addEventListener("load",function(){return e()},{once:!0});var o=setTimeout(function(){return e()},ph);this.pendingTimers.add(o),r.src=i,document.body.appendChild(r)}},t.prototype.getOrCreateInstance=function(t){var n,i=this,r=this.instances.get(t);if(r)return r;var e=null===(n=this.entryPointMap)||void 0===n?void 0:n.byId[t];if(!(e&&this.token&&this.allCampaignsMap&&this.userId))return null;var o=this.token,s=this.userId;try{var u=function(){var n,r;return null!==(r=null===(n=i.entryPointMap)||void 0===n?void 0:n.byId[t])&&void 0!==r?r:e},a=new mp(e,{userId:s,token:o,allCampaignsMap:this.allCampaignsMap,onOpen:function(){return i.trackEntryPointOpen(u())},onLoad:function(t){return i.trackEntryPointLoaded(u(),t)}});return a.addEventListener(function(n){return i.handleSdkEvent(n,t)}),a.addCloseEventListener(function(){return a.close()}),this.instances.set(t,a),a}catch(n){return this.logger.warn("Failed to construct entry point instance",{entryPointId:t,error:n}),null}},t.prototype.trackEntryPointOpen=function(t){var n,i,r=this,e=Yd(t);if(e&&this.userId){if(this.markOpened(t.id),"game"===e){var o=Zd(t),s={campaign_id:o,game_type:this.lookupGameType(o),entry_surface:null!==(n=$d(t))&&void 0!==n?n:"",embed_id:t.container.elementHookId,entry_point_id:this.resolveTrackingEntryPointId(t,o),entry_point_location:"undefined"!=typeof window?window.location.href:""};this.trackEvent(Wf,s)}else{s={page_id:t.container.elementHookId,content_surface:null!==(i=$d(t))&&void 0!==i?i:""};this.trackEvent(Yf,s)}this.fireViewedIfReady(t.id,function(n){return r.buildViewedAttributes(t,e,n)},e)}},t.prototype.trackEntryPointLoaded=function(t,n){var i=this;this.logger.debug("Campaign iframe loaded in ".concat(n.toFixed(2),"ms"),{entryPointId:t.id,campaignId:Zd(t)});var r=Yd(t);r&&(this.markLoaded(t.id,n),this.fireViewedIfReady(t.id,function(n){return i.buildViewedAttributes(t,r,n)},r))},t.prototype.buildViewedAttributes=function(t,n,i){var r;if("game"===n){var e=Zd(t);return{campaign_id:e,game_type:this.lookupGameType(e),load_time_ms:Jd(i)}}return{page_id:t.container.elementHookId,content_surface:null!==(r=$d(t))&&void 0!==r?r:"",load_time_ms:Jd(i)}},t.prototype.lookupGameType=function(t){var n,i,r;return t&&null!==(r=null===(i=null===(n=this.allCampaignsMap)||void 0===n?void 0:n.byId[t])||void 0===i?void 0:i.type)&&void 0!==r?r:null},t.prototype.resolveTrackingEntryPointId=function(t,n){var i;if(!this.ephemeralEntryPointIds.has(t.id)||!n||!this.entryPointMap)return t.id;var r=this.entryPointMap,e=r.allIds.map(function(t){return r.byId[t]}).find(function(i){return void 0!==i&&i.id!==t.id&&Zd(i)===n});return null!==(i=null==e?void 0:e.id)&&void 0!==i?i:t.id},t.prototype.handleInboundAnalyticsEvent=function(t,n){var i=this;return this.matchesAnalyticsEventName(t,Hf)?(this.trackGamePlayed(n),void this.trackRewardSeenIfPresent(t)):this.matchesAnalyticsEventName(t,zf)?(this.trackGameCompleted(n),this.trackRewardSeenIfPresent(t),void Qs(i,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.resyncData()];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}})})):void this.trackRewardSeenIfPresent(t)},t.prototype.matchesAnalyticsEventName=function(t,n){return"object"===Ha(t)&&null!==t&&t[ch.EVENT_NAME]===n},t.prototype.trackGamePlayed=function(t){var n,i=null===(n=this.instances.get(t))||void 0===n?void 0:n.entryPoint;if(i&&"CAMPAIGN"===i.content.typeId&&this.userId){this.getOrCreateTrackingState(t).playedAt=Date.now();var r=Zd(i),e={campaign_id:r,game_type:this.lookupGameType(r)};this.trackEvent(qf,e)}},t.prototype.trackGameCompleted=function(t){var n,i,r=null===(n=this.instances.get(t))||void 0===n?void 0:n.entryPoint;if(r&&"CAMPAIGN"===r.content.typeId&&this.userId){var e=null===(i=this.trackingState.get(t))||void 0===i?void 0:i.playedAt,o=void 0!==e?Date.now()-e:0,s=Zd(r),u={campaign_id:s,game_type:this.lookupGameType(s),total_time_ms:Jd(o)};this.trackEvent(Xf,u)}},t.prototype.trackRewardSeenIfPresent=function(t){if("object"===Ha(t)&&null!==t){var n=t[ch.CAMPAIGN_DETAILS];if("object"===Ha(n)&&null!==n){var i=n,r=i[ch.REWARD_STATUS];"string"==typeof r&&r.split("-").includes("SEEN")&&this.trackRewardSeen(i)}}},t.prototype.trackRewardSeen=function(t){if(this.userId){var n={reward_id:this.readStringField(t,ch.REWARD_USER_ID),campaign_id:this.readStringField(t,ch.CAMPAIGN_ID),reward_type:this.readStringField(t,ch.REWARD_TYPE)};this.trackEvent($f,n)}},t.prototype.readStringField=function(t,n){var i=t[n];return void 0===i?null:"string"==typeof i?i:(this.logger.warn("Expected a string field in analytics payload",{field:n,value:i}),null)},t.prototype.trackLoyaltyOpen=function(t){var n=this;if(this.userId){var i=this.loyaltyStateKey(t);this.markOpened(i);var r={page_id:t,content_surface:Qf};this.trackEvent(Yf,r),this.fireViewedIfReady(i,function(i){return n.buildLoyaltyViewedAttributes(t,i)},"content")}},t.prototype.trackLoyaltyLoaded=function(t,n){var i=this,r=this.loyaltyStateKey(t);this.markLoaded(r,n),this.fireViewedIfReady(r,function(n){return i.buildLoyaltyViewedAttributes(t,n)},"content")},t.prototype.buildLoyaltyViewedAttributes=function(t,n){return{page_id:t,content_surface:Qf,load_time_ms:Jd(n)}},t.prototype.loyaltyStateKey=function(t){return"loyalty:".concat(t)},t.prototype.loyaltyCallbacks=function(){var t=this;return{onOpen:function(n){return t.trackLoyaltyOpen(n)},onLoad:function(n,i){return t.trackLoyaltyLoaded(n,i)}}},t.prototype.markOpened=function(t){this.getOrCreateTrackingState(t).opened=!0},t.prototype.markLoaded=function(t,n){this.getOrCreateTrackingState(t).loadTimeMs=n},t.prototype.getOrCreateTrackingState=function(t){var n=this.trackingState.get(t);return n||(n={opened:!1,viewedFired:!1},this.trackingState.set(t,n)),n},t.prototype.fireViewedIfReady=function(t,n,i){var r=this.trackingState.get(t);r&&!r.viewedFired&&r.opened&&void 0!==r.loadTimeMs&&this.userId&&(r.viewedFired=!0,this.trackEvent("game"===i?Kf:Jf,n(r.loadTimeMs)))},t.prototype.handleSdkEvent=function(t,n){var i,r,e,o;if(this.initialized&&t&&"GLU_SDK"===t.target&&t.action){var s=t.action;switch(s.type){case"TOGGLE_CONTAINER_CONTENT":this.handleToggle(s);break;case"OPEN_CONTAINER_CONTENT":this.handleOpen(s);break;case"CLOSE_CONTAINER_CONTENT":null===(i=this.instances.get(n))||void 0===i||i.close(),this.ephemeralEntryPointIds.delete(n)&&this.trackingState.delete(n),s.data&&(this.dataDump=s.data);break;case"REQUEST_STATE":null===(r=this.instances.get(n))||void 0===r||r.sendMessage({type:"UPDATE_CONTENT_STATE",data:null!==(e=this.dataDump)&&void 0!==e?e:{}});break;case"LOGIN":"undefined"!=typeof window&&(window.location.href=s.data.url);break;case"REDIRECT":this.handleRedirect(s);break;case"ANALYTICS":null===(o=this.analyticsListener)||void 0===o||o.call(this,s.data),this.handleInboundAnalyticsEvent(s.data,n);break;case"REFRESH":this.refresh()}}},t.prototype.handleToggle=function(t){var n=this.instances.get(t.id);if(n)n.toggle();else{var i={id:t.id,container:t.container,content:t.content};this.registerAdHocEntryPoint(i),this.openInstance(i)}t.data&&(this.dataDump=t.data)},t.prototype.handleOpen=function(t){var n={id:jm(),container:t.container,content:t.content};this.ephemeralEntryPointIds.add(n.id),this.registerAdHocEntryPoint(n),this.openInstance(n),t.data&&(this.dataDump=t.data)},t.prototype.handleRedirect=function(t){if("undefined"!=typeof window){var n=t.data.url;this.userId&&(n+=n.includes("?")?"&":"?",n+="userId=".concat(this.userId)),t.data.openInNewTab?window.open(n):window.location.href=n}},t.prototype.registerAdHocEntryPoint=function(t){this.entryPointMap&&(this.adHocEntryPointIds.add(t.id),this.entryPointMap.byId[t.id]||(this.entryPointMap.allIds.push(t.id),this.entryPointMap.byId[t.id]=t))},t.prototype.closeAdHocEntryPoints=function(){var t,n;if(0!==this.adHocEntryPointIds.size){try{for(var i=tu(this.adHocEntryPointIds),r=i.next();!r.done;r=i.next()){var e=r.value,o=this.instances.get(e);if(o&&(o.isOpen()&&o.close(),o.destroy(),this.instances.delete(e)),this.trackingState.delete(e),this.ephemeralEntryPointIds.delete(e),this.entryPointMap){delete this.entryPointMap.byId[e];var s=this.entryPointMap.allIds.indexOf(e);-1!==s&&this.entryPointMap.allIds.splice(s,1)}}}catch(n){t={error:n}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}this.adHocEntryPointIds.clear()}},t.prototype.cacheKey=function(t){return eh+t},t.prototype.tokenCacheKey=function(t){return oh+t},t.prototype.loadTokenFromCache=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.storageManager.get(this.tokenCacheKey(t))];case 1:return(n=r.sent())?(i=JSON.parse(n),Date.now()-i.timestamp>=rh?[2,null]:[2,i.token]):[2,null];case 2:return r.sent(),[2,null];case 3:return[2]}})})},t.prototype.saveTokenToCache=function(t,n){return Qs(this,void 0,void 0,function(){var i,r;return Zs(this,function(e){switch(e.label){case 0:i={token:n,timestamp:Date.now()},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.storageManager.set(this.tokenCacheKey(t),JSON.stringify(i))];case 2:return e.sent(),[3,4];case 3:return r=e.sent(),this.logger.warn("Failed to persist gamification token cache",{error:r}),[3,4];case 4:return[2]}})})},t.prototype.getOrFetchToken=function(t,n){return Qs(this,void 0,void 0,function(){var i,r;return Zs(this,function(e){switch(e.label){case 0:return[4,this.loadTokenFromCache(t)];case 1:return(i=e.sent())?(this.logger.info(Gf),[2,i]):(this.logger.info(jf),[4,this.apiClient.getToken(this.writeKey,t,ah.LOGGED_IN,void 0,n)]);case 2:return r=e.sent(),[4,this.saveTokenToCache(t,r)];case 3:return e.sent(),[2,r]}})})},t.prototype.isAuthError=function(t){return"object"===Ha(t)&&null!==t&&t.code===wu},t.prototype.ensureFreshToken=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e;return Zs(this,function(o){switch(o.label){case 0:if(this.tokenRefetchInFlight)return[2,this.tokenRefetchInFlight];if(Date.now()<this.authBackoffUntil)throw this.logger.warn(Bf,{retryInMs:this.authBackoffUntil-Date.now()}),new Error("Gamification token refetch is in backoff after repeated failures");n=this.refetchToken(t,this.userAttributes),this.tokenRefetchInFlight=n,o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,n];case 2:return i=o.sent(),this.authFailureCount=0,this.authBackoffUntil=0,[2,i];case 3:throw r=o.sent(),this.authFailureCount+=1,e=Math.min(dh*Math.pow(2,this.authFailureCount-1),vh),this.authBackoffUntil=Date.now()+e,r;case 4:return this.tokenRefetchInFlight=null,[7];case 5:return[2]}})})},t.prototype.refetchToken=function(t,n){return Qs(this,void 0,void 0,function(){var i;return Zs(this,function(r){switch(r.label){case 0:return[4,this.storageManager.remove(this.tokenCacheKey(t)).catch(function(){})];case 1:return r.sent(),[4,this.apiClient.getToken(this.writeKey,t,ah.LOGGED_IN,void 0,n)];case 2:return i=r.sent(),this.userId!==t?[3,4]:[4,this.saveTokenToCache(t,i)];case 3:r.sent(),this.token=i,r.label=4;case 4:return[2,i]}})})},t.prototype.fetchCampaignsAndEntryPoints=function(t,n){return Qs(this,void 0,void 0,function(){var i,r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,Promise.all([this.apiClient.getCampaigns(n),this.apiClient.getEntryPoints(n)])];case 1:return[2,e.sent()];case 2:if(i=e.sent(),!this.isAuthError(i))throw i;return this.logger.warn(Vf),[4,this.ensureFreshToken(t)];case 3:return r=e.sent(),[2,Promise.all([this.apiClient.getCampaigns(r),this.apiClient.getEntryPoints(r)])];case 4:return[2]}})})},t.prototype.loadFromCache=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.storageManager.get(this.cacheKey(t))];case 1:return(n=r.sent())?(i=JSON.parse(n),Date.now()-i.timestamp>=ih?[2,!1]:(this.token=i.token,this.allCampaignsMap=i.allCampaignsMap,this.entryPointMap=i.entryPointMap,this.lastSyncTimestamp=i.timestamp,[2,!0])):[2,!1];case 2:return r.sent(),[2,!1];case 3:return[2]}})})},t.prototype.saveToCache=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:if(!(this.userId&&this.token&&this.allCampaignsMap&&this.entryPointMap))return[2];t={token:this.token,allCampaignsMap:this.allCampaignsMap,entryPointMap:this.entryPointMap,timestamp:this.lastSyncTimestamp},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.storageManager.set(this.cacheKey(this.userId),JSON.stringify(t))];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),this.logger.warn("Failed to persist gamification cache",{error:n}),[3,4];case 4:return this.allCampaignsMap.base&&this.storageManager.set(wh,this.allCampaignsMap.base).catch(function(){}),[2]}})})},t.prototype.handleScreenChange=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.closeAdHocEntryPoints(),this.isDataStale()?[4,this.resyncData()]:[3,2];case 1:return t.sent(),[3,3];case 2:this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks()),t.label=3;case 3:return this.refresh(),[2]}})})},t.prototype.isDataStale=function(){return Date.now()-this.lastSyncTimestamp>=ih},t.prototype.resyncData=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:if(t=this.token,n=this.userId,!t||!n)return[2];i=++this.syncGeneration,this.logger.info(Uf),u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.fetchCampaignsAndEntryPoints(n,t)];case 2:return r=nu.apply(void 0,[u.sent(),2]),e=r[0],o=r[1],i!==this.syncGeneration?[2]:(this.allCampaignsMap=e,this.entryPointMap=ev(o),this.lastSyncTimestamp=Date.now(),this.preloadEntryPoints(),[4,this.saveToCache()]);case 3:return u.sent(),this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks()),[3,5];case 4:return s=u.sent(),this.logger.error(Pf,s),[3,5];case 5:return[2]}})})},t.prototype.fetchAndCache=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:return[4,this.getOrFetchToken(t,n)];case 1:return r=u.sent(),i!==this.initGeneration?[2,!1]:(this.token=r,[4,this.fetchCampaignsAndEntryPoints(t,r)]);case 2:return e=nu.apply(void 0,[u.sent(),2]),o=e[0],s=e[1],i!==this.initGeneration?[2,!1]:(this.allCampaignsMap=o,this.entryPointMap=ev(s),this.lastSyncTimestamp=Date.now(),this.saveToCache(),[2,i===this.initGeneration])}})})},t.prototype.isCampaignCompleted=function(t){var n,i,r,e=Zd(t);if(!e||!this.allCampaignsMap)return!1;var o=this.allCampaignsMap.byId[e];if(!o)return!1;var s=Zf;return(null===(n=o.status)||void 0===n?void 0:n.toUpperCase())===s||(null===(r=null===(i=o.banner)||void 0===i?void 0:i.userCampaignStatus)||void 0===r?void 0:r.toUpperCase())===s},t.prototype.registerSpaListener=function(){var t=this;if("undefined"!=typeof window&&"undefined"!=typeof document){var n=window.location.href,i=null,r=new MutationObserver(function(){var r=window.location.href;if(r!==n){if(n=r,!t.pagePathTrackingEnabled)return;i&&clearTimeout(i),i=setTimeout(function(){t.handleScreenChange()},uh)}});r.observe(document.body,{childList:!0,subtree:!0}),this.spaListenerCleanup=function(){r.disconnect(),i&&clearTimeout(i)}}},t.prototype.registerVisibilityListener=function(){var t=this;if("undefined"!=typeof document){var n=function(){return Qs(t,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return"visible"===document.visibilityState&&this.isDataStale()?[4,this.resyncData()]:[3,2];case 1:t.sent(),this.refresh(),t.label=2;case 2:return[2]}})})};document.addEventListener("visibilitychange",n),this.visibilityListenerCleanup=function(){document.removeEventListener("visibilitychange",n)}}},t}(),yp=function(){function t(t,n,i,r,e){this.httpClient=new Vd(t),this.logger=n,this.accountId=i,this.orgId=r,this.source=e}return t.prototype.sendEvents=function(t,n,i,r,e,o){return Qs(this,void 0,void 0,function(){var s,u,a,c,f,h,d,v;return Zs(this,function(l){switch(l.label){case 0:if(!n&&!i&&!r)throw new Error("Either visitorId, visitorExternalId, or userId must be provided for event tracking");if(!o)throw new Error("Session ID is required for event tracking");return u=(s=!!n||!!i)&&r?"identified":s?"anonymous":"user-only",this.logger.info("Sending events",{eventCount:t.length,trackingMode:u,hasVisitor:s,hasUser:!!r,sessionId:o}),[4,Lm()];case 1:a=l.sent(),c=km(o,a),f={request_id:ym(),context:c,events:t},n?f.visitor={identifierName:"id",identifierValue:n}:i&&(f.visitor={identifierName:"externalId",identifierValue:i}),r&&e&&(f.user={identifierName:e,identifierValue:r}),l.label=2;case 2:return l.trys.push([2,4,,5]),h={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source,"X-CAP-API-AUTH-ENTITY-ID":this.orgId},[4,this.httpClient.post(ru,f,{headers:h})];case 3:return d=l.sent(),this.logger.info(Pu,{requestId:f.request_id,eventCount:t.length,trackingMode:u,success:d.status.success}),[2,d];case 4:throw v=l.sent(),this.logger.error(Lu,{requestId:f.request_id,eventCount:t.length,trackingMode:u,error:v}),v;case 5:return[2]}})})},t.prototype.getVisitorConfig=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o;return Zs(this,function(s){switch(s.label){case 0:this.logger.info("Fetching visitor config",{orgId:t}),s.label=1;case 1:return s.trys.push([1,3,,4]),n={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":Pa.WEBPUSH},[4,this.httpClient.get(ou,{headers:n})];case 2:return i=s.sent(),this.logger.info(ta,{isEnabled:null===(e=i.data)||void 0===e?void 0:e.visitorTrackingEnabled,warningCount:(null===(o=i.warnings)||void 0===o?void 0:o.length)||0}),[2,i];case 3:throw r=s.sent(),this.logger.error(na,r),r;case 4:return[2]}})})},t.prototype.createVisitor=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:this.logger.info("Creating anonymous visitor",{orgId:t,profileCount:n.profiles.length,hasExtendedFields:!!n.extendedFields}),u.label=1;case 1:if(u.trys.push([1,3,,4]),!n.profiles||0===n.profiles.length)throw new Error("At least one profile is required");return i={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-SOURCE-NAME":this.source,"X-CAP-ORG-ACCOUNT-ID":this.accountId},[4,this.httpClient.post(su,n,{headers:i})];case 2:return r=u.sent(),this.logger.info(sa,{visitorId:null===(o=r.data)||void 0===o?void 0:o.id,warningCount:(null===(s=r.warnings)||void 0===s?void 0:s.length)||0}),[2,r];case 3:throw e=u.sent(),this.logger.error(ua,{error:e,accountId:this.accountId}),e;case 4:return[2]}})})},t.prototype.updateVisitor=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e,o,s,u,a;return Zs(this,function(c){switch(c.label){case 0:this.logger.info("Updating visitor",{orgId:t,visitorId:n,profileCount:i.profiles.length,hasExtendedFields:!!i.extendedFields}),c.label=1;case 1:if(c.trys.push([1,3,,4]),!i.profiles||0===i.profiles.length)throw new Error("At least one profile is required");if(!n||""===n.trim())throw new Error("Visitor ID is required for update");return r={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-SOURCE-NAME":this.source,"X-CAP-ORG-ACCOUNT-ID":this.accountId},e="".concat(uu,"?identifierType=visitorId&identifierValue=").concat(encodeURIComponent(n)),[4,this.httpClient.put(e,i,{headers:r})];case 2:return o=c.sent(),this.logger.info(fa,{visitorId:null===(u=o.data)||void 0===u?void 0:u.id,warningCount:(null===(a=o.warnings)||void 0===a?void 0:a.length)||0}),[2,o];case 3:throw s=c.sent(),this.logger.error(ha,{error:s,visitorId:n,accountId:this.accountId}),s;case 4:return[2]}})})},t.prototype.buildMergeIdentifiers=function(t,n,i){var r=[];return t&&r.push({type:"email",value:t}),n&&r.push({type:"mobile",value:n}),i&&r.push({type:"externalId",value:i}),r},t.prototype.handleMergeResponse=function(t,n){var i,r=this;if(t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){r.logger.warn("Visitor merge warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0){var e=t.errors[0],o=e.code,s=e.message,u=String(o);if(u===Ga.ALREADY_MERGED)return void this.logger.info("Visitor already merged, treating as success",{visitorId:n});if(u===Ga.VISITOR_NOT_FOUND)throw this.logger.warn("Visitor not found, merge cannot proceed",{visitorId:n}),new bp(u,s);throw new Error("Merge API error: [".concat(u,"] ").concat(s))}if(202!==(null===(i=t.status)||void 0===i?void 0:i.code))throw new Error("Unexpected merge API response");this.logger.info(da,{visitorId:n,statusCode:t.status.code,message:t.status.message})},t.prototype.mergeVisitor=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e,o,s,u,a,c,f,h,d,v,l,g,m,p,w,y,b,E,_,I,T,S;return Zs(this,function(A){switch(A.label){case 0:if(r=i.firstName,e=i.lastName,o=i.email,s=i.mobile,u=i.fcmToken,a=i.channelType,c=i.subscribed,f=void 0===c||c,h=i.fields,d=i.extendedFields,v=i.externalId,l=i.sessionId,g=void 0===l?"":l,!o&&!s&&!v)throw new Error("At least one identifier (email, mobile, or externalId) is required for visitor merge");if(!t&&!n)throw new Error("Either visitorId or visitorExternalId is required for visitor merge");return this.logger.info("Merging visitor with user",{visitorId:t,visitorExternalId:n,hasEmail:!!o,hasMobile:!!s,hasExternalId:!!v,hasFcmToken:!!u}),m=this.buildMergeIdentifiers(o,s,v),p=a||La.WEB,w=[],u&&w.push({type:p,value:u,primary:!0,verified:!0,subscribed:f}),S={visitor:t?{identifierName:"id",identifierValue:t}:{identifierName:"externalId",identifierValue:n},user:{profiles:[{firstName:r,lastName:e,identifiers:m,commChannels:w,fields:h||{}}],extendedFields:d||{}}},b=km,E=[g],[4,Lm()];case 1:S.context=b.apply(void 0,E.concat([A.sent()])),y=S,A.label=2;case 2:return A.trys.push([2,4,,5]),_={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source},[4,this.httpClient.post(au,y,{headers:_})];case 3:return I=A.sent(),this.handleMergeResponse(I,t),[3,5];case 4:if((T=A.sent())instanceof bp)throw T;throw this.logger.error(va,{visitorId:t,error:T}),T;case 5:return[2]}})})},t.prototype.buildUserEventsRequest=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e;return Zs(this,function(o){switch(o.label){case 0:return[4,Lm()];case 1:return r=o.sent(),e=km(i,r),[2,{request_id:ym(),context:Js(Js({},e),{os_name:Na}),events:[{name:t,eventExternalId:ym(),eventDateTime:(new Date).toISOString(),attributes:n}]}]}})})},t.prototype.sendUserEvents=function(t,n,i,r,e){return Qs(this,void 0,void 0,function(){var o,s,u,a,c;return Zs(this,function(f){switch(f.label){case 0:n?t.visitor={identifierName:"id",identifierValue:n}:i&&(t.visitor={identifierName:"externalId",identifierValue:i}),r&&e&&(t.user={identifierName:e,identifierValue:r}),this.logger.info("Sending user event",{eventName:null===(u=t.events[0])||void 0===u?void 0:u.name,requestId:t.request_id,hasVisitor:!!t.visitor,hasUser:!!t.user}),f.label=1;case 1:return f.trys.push([1,3,,4]),o={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source,"X-CAP-API-AUTH-ENTITY-ID":this.orgId},[4,this.httpClient.post(eu,t,{headers:o})];case 2:return f.sent(),this.logger.info("User event sent successfully",{eventName:null===(a=t.events[0])||void 0===a?void 0:a.name,requestId:t.request_id}),[3,4];case 3:throw s=f.sent(),this.logger.error("Failed to send user event",{eventName:null===(c=t.events[0])||void 0===c?void 0:c.name,requestId:t.request_id,error:s}),s;case 4:return[2]}})})},t.prototype.sendDLR=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o;return Zs(this,function(s){switch(s.label){case 0:this.logger.info("Sending DLR events",{eventCount:t.events.length,requestId:t.request_id,cuid:null===(e=t.user)||void 0===e?void 0:e.identifierValue,visitorId:null===(o=t.visitor)||void 0===o?void 0:o.identifierValue}),s.label=1;case 1:return s.trys.push([1,3,,4]),n={"x-cap-api-auth-org-id":this.orgId,"x-cap-request-id":t.request_id},[4,this.httpClient.post(cu,t,{headers:n})];case 2:return i=s.sent(),this.logger.info(Aa,{requestId:t.request_id,eventCount:t.events.length,success:i.status.success}),[2,i];case 3:throw r=s.sent(),this.logger.error(Oa,{requestId:t.request_id,eventCount:t.events.length,error:r}),r;case 4:return[2]}})})},t}(),bp=function(t){function n(n,i){var r=t.call(this,i)||this;return r.name="MergeNonRetryableError",r.code=n,r}return Ys(n,t),n}(Error);var Ep;Ep||(Ep=1,Sr()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991}));var _p,Ip,Tp,Sp={};!function(){if(Tp)return Sp;Tp=1;var t=Sr(),n=function(){if(Ip)return _p;Ip=1;var t=k(),n=G(),i=Rt(),r=of(),e=Dv().trim,o=kv(),s=t.parseInt,u=t.Symbol,a=u&&u.iterator,c=/^[+-]?0x/i,f=i(c.exec),h=8!==s(o+"08")||22!==s(o+"0x16")||a&&!n(function(){s(Object(a))});return _p=h?function(t,n){var i=e(r(t));return s(i,n>>>0||(f(c,i)?16:10))}:s}();t({global:!0,forced:parseInt!==n},{parseInt:n})}();var Ap,Op=function(){function t(t,n,i){void 0===t&&(t="WebSDK"),void 0===n&&(n=2),void 0===i&&(i="data"),this.db=null,this.dbName=t,this.version=n,this.storeName=i,this.eventsStoreName="events"}return t.prototype.openDB=function(){return Qs(this,void 0,void 0,function(){var t=this;return Zs(this,function(n){return this.db?[2,this.db]:[2,new Promise(function(n,i){var r=indexedDB.open(t.dbName,t.version);r.onerror=function(){return i(r.error)},r.onsuccess=function(){t.db=r.result,n(t.db)},r.onupgradeneeded=function(n){var i=n.target.result;if(i.objectStoreNames.contains(t.storeName)||i.createObjectStore(t.storeName),!i.objectStoreNames.contains(t.eventsStoreName)){var r=i.createObjectStore(t.eventsStoreName,{keyPath:"id"});r.createIndex("timestamp","timestamp",{unique:!1}),r.createIndex("status","status",{unique:!1})}}})]})})},t.prototype.getItem=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,e){var o=n.transaction([i.storeName],"readonly").objectStore(i.storeName).get(t);o.onerror=function(){return e(o.error)},o.onsuccess=function(){var t=o.result;r(null==t?null:"string"==typeof t?t:"object"===Ha(t)?JSON.stringify(t):String(t))}})]}})})},t.prototype.setItem=function(t,n){return Qs(this,void 0,void 0,function(){var i,r=this;return Zs(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,o){var s=i.transaction([r.storeName],"readwrite").objectStore(r.storeName).put(n,t);s.onerror=function(){return o(s.error)},s.onsuccess=function(){return e()}})]}})})},t.prototype.removeItem=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,e){var o=n.transaction([i.storeName],"readwrite").objectStore(i.storeName).delete(t);o.onerror=function(){return e(o.error)},o.onsuccess=function(){return r()}})]}})})},t.prototype.clear=function(){return Qs(this,void 0,void 0,function(){var t,n=this;return Zs(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return t=i.sent(),[2,new Promise(function(i,r){var e=t.transaction([n.storeName],"readwrite").objectStore(n.storeName).clear();e.onerror=function(){return r(e.error)},e.onsuccess=function(){return i()}})]}})})},t.prototype.close=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return this.db&&(this.db.close(),this.db=null),[2]})})},t.prototype.addEvent=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,e){var o=n.transaction([i.eventsStoreName],"readwrite").objectStore(i.eventsStoreName).add(t);o.onerror=function(){return e(o.error)},o.onsuccess=function(){return r()}})]}})})},t.prototype.getOldestPendingEvents=function(t){return Qs(this,arguments,void 0,function(t,n){var i,r=this;return void 0===n&&(n=50),Zs(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,o){var s=i.transaction([r.eventsStoreName],"readonly").objectStore(r.eventsStoreName).index("timestamp").openCursor(),u=[],a=0;s.onerror=function(){return o(s.error)},s.onsuccess=function(i){var r=i.target.result;if(r&&a<n){var o=r.value;"pending"===o.status&&o.accountId===t&&(u.push(o),a++),r.continue()}else e(u)}})]}})})},t.prototype.updateEventStatus=function(t,n,i,r){return Qs(this,void 0,void 0,function(){var e,o=this;return Zs(this,function(s){switch(s.label){case 0:return[4,this.openDB()];case 1:return e=s.sent(),[2,new Promise(function(s,u){var a=e.transaction([o.eventsStoreName],"readwrite").objectStore(o.eventsStoreName),c=a.get(t);c.onerror=function(){return u(c.error)},c.onsuccess=function(){var e=c.result;if(e){e.status=n,e.lastAttempt=Date.now(),i&&(e.error=i),void 0!==r&&(e.attempts=r);var o=a.put(e);o.onerror=function(){return u(o.error)},o.onsuccess=function(){return s()}}else u(new Error("Event with id ".concat(t," not found")))}})]}})})},t.prototype.removeEvents=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,e){var o=n.transaction([i.eventsStoreName],"readwrite").objectStore(i.eventsStoreName),s=0,u=t.length;0!==u?t.forEach(function(t){var n=o.delete(t);n.onerror=function(){return e(n.error)},n.onsuccess=function(){++s===u&&r()}}):r()})]}})})},t.prototype.recoverOrphanedEvents=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,e){var o=n.transaction([i.eventsStoreName],"readwrite").objectStore(i.eventsStoreName).openCursor(),s=0;o.onerror=function(){return e(o.error)},o.onsuccess=function(n){var i=n.target.result;if(i){var e=i.value;if("processing"===e.status&&e.accountId===t)e.status="failed",e.lastAttempt=Date.now(),e.error="Recovered from orphaned processing state",i.update(e).onsuccess=function(){s++};i.continue()}else r(s)}})]}})})},t.prototype.getPendingEventCount=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,e){var o=n.transaction([i.eventsStoreName],"readonly").objectStore(i.eventsStoreName).openCursor(),s=0;o.onerror=function(){return e(o.error)},o.onsuccess=function(n){var i=n.target.result;if(i){var e=i.value;"pending"===e.status&&e.accountId===t&&s++,i.continue()}else r(s)}})]}})})},t.prototype.getRetryableEvents=function(t){return Qs(this,arguments,void 0,function(t,n){var i,r=this;return void 0===n&&(n=5),Zs(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,o){var s=i.transaction([r.eventsStoreName],"readonly").objectStore(r.eventsStoreName).openCursor(),u=[];s.onerror=function(){return o(s.error)},s.onsuccess=function(i){var r=i.target.result;if(r){var o=r.value;"failed"===o.status&&o.attempts<=n&&o.accountId===t&&u.push(o),r.continue()}else e(u)}})]}})})},t}(),Np=function(){function t(t,n,i,r,e){if(this.currentAccountId=null,this.currentCuid=null,this.currentUserIdentifierType=null,this.currentVisitorId=null,this.currentVisitorExternalId=null,this.getSessionInfo=null,this.isProcessing=!1,this.processingPromise=null,this.paused=!1,this.apiClient=t,this.logger=n,this.BATCH_SIZE=e||hu.BATCH_SIZE,this.RETRY_DELAYS=r||hu.DEFAULT_RETRY_DELAYS,i&&"getIndexedDBAdapter"in i){var o=i.getIndexedDBAdapter();o?(n.info("EventQueue: Reusing existing IndexedDB adapter from StorageManager"),this.storage=o):(n.warn("EventQueue: StorageManager has no IndexedDB adapter, creating new one"),this.storage=new Op)}else i?(n.info("EventQueue: Using provided IndexedDBStorage"),this.storage=i):(n.warn("EventQueue: No storage provided, creating new IndexedDBStorage"),this.storage=new Op)}return t.prototype.init=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.logger.info("Initializing EventQueue"),[4,this.processQueueIfIdle()];case 1:return t.sent(),this.logger.info("EventQueue initialized successfully"),[2]}})})},t.prototype.setUserContext=function(t,n,i){return Qs(this,void 0,void 0,function(){var r;return Zs(this,function(e){switch(e.label){case 0:return this.currentAccountId=t,this.currentCuid=n||null,this.currentUserIdentifierType=i||null,this.logger.debug("EventQueue user context set",{accountId:t,cuid:n,userIdentifierType:i}),[4,this.storage.recoverOrphanedEvents(t)];case 1:return(r=e.sent())>0&&this.logger.info("Recovered ".concat(r," orphaned processing events for account ").concat(t)),[2]}})})},t.prototype.setVisitorContext=function(t,n){this.currentVisitorId=t,this.currentVisitorExternalId=null!=n?n:null,this.logger.debug("EventQueue visitor context set",{visitorId:t,visitorExternalId:n})},t.prototype.setSessionInfoCallback=function(t){this.getSessionInfo=t,this.logger.debug("EventQueue session info callback set")},t.prototype.getCurrentAccountId=function(){return this.currentAccountId},t.prototype.getCurrentCuid=function(){return this.currentCuid},t.prototype.getCurrentVisitorId=function(){return this.currentVisitorId},t.prototype.clearUserContext=function(){this.currentCuid=null,this.currentUserIdentifierType=null,this.logger.debug("EventQueue user context cleared (cuid removed)")},t.prototype.enqueue=function(t){return Qs(this,arguments,void 0,function(t,n){var i,r,e,o;return void 0===n&&(n=!1),Zs(this,function(s){switch(s.label){case 0:if(s.trys.push([0,7,,8]),!this.currentAccountId)throw new Error("Cannot enqueue event: No account context set");if(i=null,!this.getSessionInfo)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getSessionInfo()];case 2:return i=s.sent(),[3,4];case 3:return r=s.sent(),this.logger.warn("Failed to resolve session ID at enqueue time",r),[3,4];case 4:return e={id:ym(),event:t,accountId:this.currentAccountId,timestamp:(new Date).toISOString(),attempts:0,status:hu.STATUSES.PENDING,visitorId:this.currentVisitorId,visitorExternalId:this.currentVisitorExternalId,cuid:this.currentCuid,userIdentifierType:this.currentUserIdentifierType,sessionId:i,isDLR:n},[4,this.storage.addEvent(e)];case 5:return s.sent(),this.logger.debug("Event added to queue",{eventId:e.id,eventName:t.name,visitorId:e.visitorId,cuid:e.cuid,sessionId:e.sessionId,isDLR:n}),[4,this.processQueueIfIdle()];case 6:return s.sent(),[3,8];case 7:throw o=s.sent(),this.logger.error("Failed to enqueue event",{event:t,error:o}),o;case 8:return[2]}})})},t.prototype.processQueueIfIdle=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return this.paused?(this.logger.debug("Queue processing paused, skipping"),[2]):this.isProcessing?(this.logger.debug("Queue processing already in progress, skipping"),[2]):(this.processingPromise||(this.processingPromise=this.processQueue()),[2,this.processingPromise])})})},t.prototype.getIdentityKey=function(t){var n,i,r,e,o,s=null!==(n=t.visitorId)&&void 0!==n?n:"_none_",u=null!==(i=t.visitorExternalId)&&void 0!==i?i:"_none_",a=null!==(r=t.cuid)&&void 0!==r?r:"_none_",c=null!==(e=t.userIdentifierType)&&void 0!==e?e:"_none_",f=null!==(o=t.sessionId)&&void 0!==o?o:"_none_";return"".concat(s,"|").concat(u,"|").concat(a,"|").concat(c,"|").concat(f)},t.prototype.groupEventsByIdentity=function(t){var n,i,r=new Map;try{for(var e=tu(t),o=e.next();!o.done;o=e.next()){var s=o.value,u=this.getIdentityKey(s),a=r.get(u);a?a.push(s):r.set(u,[s])}}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return Array.from(r.values())},t.prototype.processQueue=function(){return Qs(this,void 0,void 0,function(){var n=this;return Zs(this,function(i){switch(i.label){case 0:return this.isProcessing?[2]:"undefined"!=typeof navigator&&"locks"in navigator?[4,navigator.locks.request(t.QUEUE_LOCK_NAME,{ifAvailable:!0},function(t){return Qs(n,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return t?[4,this.executeProcessQueue()]:(this.logger.debug("Queue lock held by another tab, skipping"),[2]);case 1:return n.sent(),[2]}})})})]:[3,2];case 1:return i.sent(),[3,4];case 2:return[4,this.executeProcessQueue()];case 3:i.sent(),i.label=4;case 4:return[2]}})})},t.prototype.executeProcessQueue=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c;return Zs(this,function(f){switch(f.label){case 0:this.isProcessing=!0,this.logger.debug("Starting queue processing"),f.label=1;case 1:f.trys.push([1,16,17,18]),f.label=2;case 2:return this.paused?(this.logger.debug("Queue processing paused mid-cycle, stopping"),[3,15]):[4,this.checkAndPromoteRetryEvents()];case 3:return f.sent(),this.currentAccountId?[4,this.storage.getOldestPendingEvents(this.currentAccountId,this.BATCH_SIZE)]:(this.logger.debug("No account context, skipping event processing"),[3,15]);case 4:if(0===(t=f.sent()).length)return this.logger.debug("No pending events to process"),[3,15];n=this.groupEventsByIdentity(t),this.logger.info("Processing events",{totalEvents:t.length,identityGroups:n.length}),f.label=5;case 5:f.trys.push([5,11,12,13]),a=void 0,i=tu(n),r=i.next(),f.label=6;case 6:return r.done?[3,10]:(e=r.value,o=e[0],this.logger.debug("Processing identity group",{batchSize:e.length,visitorId:null==o?void 0:o.visitorId,cuid:null==o?void 0:o.cuid,sessionId:null==o?void 0:o.sessionId}),[4,this.markEventsAsProcessing(e)]);case 7:return f.sent(),[4,this.sendBatch(e)];case 8:f.sent(),f.label=9;case 9:return r=i.next(),[3,6];case 10:return[3,13];case 11:return s=f.sent(),a={error:s},[3,13];case 12:try{r&&!r.done&&(c=i.return)&&c.call(i)}finally{if(a)throw a.error}return[7];case 13:return[4,this.storage.getPendingEventCount(this.currentAccountId)];case 14:return 0===f.sent()?(this.logger.debug("No more pending events"),[3,15]):[3,2];case 15:return[3,18];case 16:return u=f.sent(),this.logger.error("Queue processing failed",u),[3,18];case 17:return this.isProcessing=!1,this.processingPromise=null,this.logger.debug("Queue processing completed"),[7];case 18:return[2]}})})},t.prototype.markEventsAsProcessing=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s,u;return Zs(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),n=tu(t),i=n.next(),a.label=1;case 1:if(i.done)return[3,6];r=i.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.storage.updateEventStatus(r.id,"processing")];case 3:return a.sent(),[3,5];case 4:return e=a.sent(),this.logger.warn("Failed to mark event as processing",{eventId:r.id,error:e}),[3,5];case 5:return i=n.next(),[3,1];case 6:return[3,9];case 7:return o=a.sent(),s={error:o},[3,9];case 8:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 9:return[2]}})})},t.prototype.sendBatch=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s,u,a,c;return Zs(this,function(f){switch(f.label){case 0:if(f.trys.push([0,5,,10]),!this.currentAccountId)throw new Error("Missing account context for batch sending");return n=t[0],i=!!(null!==(c=n.visitorId)&&void 0!==c?c:n.visitorExternalId),r=!!n.cuid,e=void 0,e=i&&r?"identified":i?"anonymous":"user-only",this.logger.debug("Sending event batch",{batchSize:t.length,trackingMode:e,hasVisitor:i,hasUser:r}),o=t.filter(function(t){return!0===t.isDLR}),(s=t.filter(function(t){return!0!==t.isDLR})).length>0?[4,this.sendRegularEvents(s)]:[3,2];case 1:f.sent(),f.label=2;case 2:return o.length>0?[4,this.sendDLREvents(o)]:[3,4];case 3:f.sent(),f.label=4;case 4:return[2,!0];case 5:return u=f.sent(),a=this.isRetryableHttpError(u),this.logger.error("Failed to send batch",{batchSize:t.length,error:u,isRetryable:a}),a?[4,this.handleFailedBatch(t)]:[3,7];case 6:return f.sent(),[3,9];case 7:return[4,this.removeNonRetryableEvents(t)];case 8:f.sent(),f.label=9;case 9:return[2,!1];case 10:return[2]}})})},t.prototype.sendRegularEvents=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s,u,a,c,f,h,d,v,l;return Zs(this,function(g){switch(g.label){case 0:if(n=t[0],i=null!==(f=n.visitorId)&&void 0!==f?f:null,r=null!==(h=n.visitorExternalId)&&void 0!==h?h:null,e=null!==(d=n.cuid)&&void 0!==d?d:null,o=null!==(v=n.userIdentifierType)&&void 0!==v?v:null,s=null!==(l=n.sessionId)&&void 0!==l?l:null,u=this.apiClient,a=t.map(function(t){return t.event}),!s)throw new Error("Session ID is required for event tracking");return[4,u.sendEvents(a,i||void 0,r||void 0,e||void 0,o||void 0,s)];case 1:return c=g.sent(),[4,this.handleBatchResponse(t,c)];case 2:return g.sent(),[2]}})})},t.prototype.sendDLREvents=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s,u,a;return Zs(this,function(c){switch(c.label){case 0:return n=t[0],i=this.apiClient,r=null!==(a=n.sessionId)&&void 0!==a?a:"",[4,Lm()];case 1:return e=c.sent(),o=km(r,e),s={events:t.map(function(t){var n=t.event,i=n.eventExternalId,r=function(t,n){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var e=0;for(r=Object.getOwnPropertySymbols(t);e<r.length;e++)n.indexOf(r[e])<0&&Object.prototype.propertyIsEnumerable.call(t,r[e])&&(i[r[e]]=t[r[e]])}return i}(n,["eventExternalId"]);return Js(Js({},r),{eventRefId:i})}),request_id:ym(),system_data:o},n.cuid?s.user={identifierName:"id",identifierValue:n.cuid}:n.visitorId&&(s.visitor={identifierName:"id",identifierValue:n.visitorId}),[4,i.sendDLR(s)];case 2:return u=c.sent(),[4,this.handleBatchResponse(t,u,hu.DLR_SUCCESS_CODE)];case 3:return c.sent(),[2]}})})},t.prototype.removeSuccessfulEvents=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:n=t.map(function(t){return t.id}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.storage.removeEvents(n)];case 2:return r.sent(),this.logger.debug("Successfully removed events from storage",{count:n.length}),[3,4];case 3:return i=r.sent(),this.logger.error("Failed to remove events from storage",{eventIds:n,error:i}),[3,4];case 4:return[2]}})})},t.prototype.handleBatchResponse=function(t,n){return Qs(this,arguments,void 0,function(t,n,i){var r;return void 0===i&&(i=hu.GLOBAL_SUCCESS_CODE),Zs(this,function(e){switch(e.label){case 0:return(r=parseInt(n.status.code,10))!==i?[3,2]:[4,this.removeSuccessfulEvents(t)];case 1:return e.sent(),this.logger.info("All events processed successfully",{count:t.length}),[3,8];case 2:return r!==hu.PARTIAL_SUCCESS_CODE?[3,4]:[4,this.handlePartialSuccess(t,n.events)];case 3:return e.sent(),[3,8];case 4:return hu.RETRYABLE_HTTP_CODES.includes(r)?[4,this.handleFailedBatch(t)]:[3,6];case 5:return e.sent(),this.logger.warn("Batch failed with retryable error",{code:r,message:n.status.message}),[3,8];case 6:return[4,this.removeNonRetryableEvents(t)];case 7:e.sent(),this.logger.error("Batch failed with non-retryable error",{code:r,message:n.status.message}),e.label=8;case 8:return[2]}})})},t.prototype.handlePartialSuccess=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s,u,a,c,f;return Zs(this,function(h){switch(h.label){case 0:i=new Map,n.forEach(function(t){i.set(t.eventExternalId,t)}),h.label=1;case 1:h.trys.push([1,12,13,14]),r=tu(t),e=r.next(),h.label=2;case 2:return e.done?[3,11]:(o=e.value,(s=i.get(o.event.eventExternalId))?[3,4]:[4,this.markEventForRetry(o,"No response received")]);case 3:return h.sent(),[3,10];case 4:return s.status.success?[4,this.storage.removeEvents([o.id])]:[3,6];case 5:return h.sent(),this.logger.debug("Event processed successfully",{eventId:o.id}),[3,10];case 6:return u=parseInt(s.status.code,10),hu.RETRYABLE_HTTP_CODES.includes(u)?[4,this.markEventForRetry(o,s.status.message)]:[3,8];case 7:return h.sent(),this.logger.debug("Event marked for retry",{eventId:o.id,code:u,message:s.status.message}),[3,10];case 8:return[4,this.storage.removeEvents([o.id])];case 9:h.sent(),this.logger.warn("Event permanently failed - removed",{eventId:o.id,code:u,message:s.status.message}),h.label=10;case 10:return e=r.next(),[3,2];case 11:return[3,14];case 12:return a=h.sent(),c={error:a},[3,14];case 13:try{e&&!e.done&&(f=r.return)&&f.call(r)}finally{if(c)throw c.error}return[7];case 14:return[2]}})})},t.prototype.markEventForRetry=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e;return Zs(this,function(o){switch(o.label){case 0:return i=(t.attempts||0)+1,[4,this.storage.updateEventStatus(t.id,"failed","Attempt ".concat(i," failed: ").concat(n),i)];case 1:return o.sent(),r=Math.min(Math.max(i-1,0),this.RETRY_DELAYS.length-1),e=this.RETRY_DELAYS[r],this.logger.debug("Event marked for retry",{eventId:t.id,attempts:i,delay:e,isInfiniteRetry:i>this.RETRY_DELAYS.length}),[2]}})})},t.prototype.checkAndPromoteRetryEvents=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c,f,h;return Zs(this,function(d){switch(d.label){case 0:return d.trys.push([0,10,,11]),this.currentAccountId?[4,this.storage.getRetryableEvents(this.currentAccountId,Number.MAX_SAFE_INTEGER)]:(this.logger.debug("No account context, skipping retry check"),[2]);case 1:if(0===(t=d.sent()).length)return[2];n=0,d.label=2;case 2:d.trys.push([2,7,8,9]),i=tu(t),r=i.next(),d.label=3;case 3:return r.done?[3,6]:(e=r.value,o=Math.min(Math.max(e.attempts-1,0),this.RETRY_DELAYS.length-1),s=this.RETRY_DELAYS[o],(u=Date.now()-(e.lastAttempt||0))>=(s||0)?[4,this.storage.updateEventStatus(e.id,"pending")]:[3,5]);case 4:d.sent(),n++,this.logger.debug("Failed event promoted to pending",{eventId:e.id,attempt:e.attempts+1,delay:s,timeSinceLastAttempt:u}),d.label=5;case 5:return r=i.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),f={error:a},[3,9];case 8:try{r&&!r.done&&(h=i.return)&&h.call(i)}finally{if(f)throw f.error}return[7];case 9:return n>0&&this.logger.debug("Promoted ".concat(n," failed events for retry")),[3,11];case 10:return c=d.sent(),this.logger.error("Failed to check retry events",c),[3,11];case 11:return[2]}})})},t.prototype.isRetryableHttpError=function(t){var n,i,r,e,o=t;if(o.code){var s=parseInt(o.code,10);return hu.RETRYABLE_HTTP_CODES.includes(s)}return null!==(e=(null===(n=o.message)||void 0===n?void 0:n.includes("network"))||(null===(i=o.message)||void 0===i?void 0:i.includes("timeout"))||(null===(r=o.message)||void 0===r?void 0:r.includes("fetch")))&&void 0!==e&&e},t.prototype.removeNonRetryableEvents=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:n=t.map(function(t){return t.id}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.storage.removeEvents(n)];case 2:return r.sent(),this.logger.warn("Non-retryable events removed permanently",{eventIds:n}),[3,4];case 3:return i=r.sent(),this.logger.error("Failed to remove non-retryable events",{eventIds:n,error:i}),[3,4];case 4:return[2]}})})},t.prototype.handleFailedBatch=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s,u;return Zs(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),n=tu(t),i=n.next(),a.label=1;case 1:if(i.done)return[3,6];r=i.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.markEventForRetry(r,"Batch failed")];case 3:return a.sent(),[3,5];case 4:return e=a.sent(),this.logger.error("Failed to mark event for retry",{eventId:r.id,error:e}),[3,5];case 5:return i=n.next(),[3,1];case 6:return[3,9];case 7:return o=a.sent(),s={error:o},[3,9];case 8:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 9:return[2]}})})},t.prototype.pause=function(){this.paused=!0,this.logger.info("EventQueue paused")},t.prototype.resume=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.paused=!1,this.logger.info("EventQueue resumed"),[4,this.processQueueIfIdle()];case 1:return t.sent(),[2]}})})},t.prototype.flush=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.logger.info("Manual flush requested"),[4,this.processQueueIfIdle()];case 1:return t.sent(),[2]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying EventQueue"),this.processingPromise?[4,this.processingPromise]:[3,2];case 1:t.sent(),t.label=2;case 2:return[4,this.storage.close()];case 3:return t.sent(),this.logger.info("EventQueue destroyed"),[2]}})})},t.QUEUE_LOCK_NAME="websdk-event-queue-lock",t}(),kp=function(){function t(t,n,i,r){this.eventQueue=null,this.initialized=!1,this.visitorId=null,this.visitorTrackingEnabled=null,this.config=t,this.logger=r,this.apiClient=n,this.storageManager=i}return t.prototype.init=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("EventTracker already initialized"),[2]):(this.logger.info("Initializing EventTracker with IndexedDB queue"),this.eventQueue=new Np(this.apiClient,this.logger,this.storageManager,this.config.retryDelays,this.config.batchSize),[4,this.eventQueue.init()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(Ru),[2]}})})},t.prototype.setUserContext=function(t,n,i){return Qs(this,void 0,void 0,function(){return Zs(this,function(r){switch(r.label){case 0:if(!this.eventQueue)throw new Error("EventTracker not initialized");return[4,this.eventQueue.setUserContext(t,n,i)];case 1:return r.sent(),this.logger.info("User context set",{accountId:t,cuid:n,userIdentifierType:i}),[2]}})})},t.prototype.setVisitorTrackingState=function(t,n,i){this.visitorId=t,this.visitorTrackingEnabled=n,this.eventQueue&&this.eventQueue.setVisitorContext(t,i),this.logger.debug("Visitor tracking state updated",{visitorId:t,visitorExternalId:i,isEnabled:n,trackingMode:t?"anonymous":"not-configured"})},t.prototype.setSessionInfoCallback=function(t){if(!this.eventQueue)throw new Error("EventTracker not initialized");this.eventQueue.setSessionInfoCallback(t),this.logger.debug("Session info callback set in EventTracker")},t.prototype.clearUserContext=function(){this.eventQueue?(this.eventQueue.clearUserContext(),this.logger.info("User context cleared from EventTracker")):this.logger.warn("Cannot clear user context - EventTracker not initialized")},t.prototype.track=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:if(!this.initialized||!this.eventQueue)throw new Error("EventTracker not initialized");if(!1===this.visitorTrackingEnabled)throw this.logger.warn("Event tracking is disabled - visitor tracking is not enabled"),new Error("Event tracking is disabled");this.logger.debug("Tracking event",{event:t}),r.label=1;case 1:return r.trys.push([1,3,,4]),n=this.convertToApiEvent(t),[4,this.eventQueue.enqueue(n)];case 2:return r.sent(),[3,4];case 3:throw i=r.sent(),this.logger.error(Uu,{event:t,error:i}),new Error("".concat(bu,": ").concat(i));case 4:return[2]}})})},t.prototype.convertToApiEvent=function(t){if(!t.name||""===t.name.trim())throw new Error("Event name is required");var n=Js({},t.data);if(!this.eventQueue)throw new Error("EventTracker not initialized");var i,r=this.eventQueue.getCurrentCuid();if(!r&&!this.visitorId){var e=null===this.visitorTrackingEnabled?"Cannot track event: User must be identified (cuid) or visitor tracking must be configured":"Cannot track event: Either visitor tracking must be enabled or user must be identified";throw this.logger.error(e,{hasVisitorId:!!this.visitorId,hasCuid:!1,visitorTrackingEnabled:this.visitorTrackingEnabled}),new Error(e)}return i=this.visitorId&&r?"identified":this.visitorId?"anonymous":"user-only",this.logger.debug("Creating event payload",{eventName:t.name,hasCuid:!!r,hasVisitorId:!!this.visitorId,trackingMode:i,visitorTrackingEnabled:this.visitorTrackingEnabled}),function(t,n){if(!t||""===t.trim())throw new Error("Event name is required");return{name:t.trim(),eventExternalId:ym(),eventDateTime:(new Date).toISOString(),attributes:n||{}}}(t.name,n)},t.prototype.pause=function(){this.eventQueue&&this.eventQueue.pause(),this.logger.info("EventTracker paused")},t.prototype.resume=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.eventQueue?[4,this.eventQueue.resume()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.logger.info("EventTracker resumed"),[2]}})})},t.prototype.flush=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.initialized&&this.eventQueue?(this.logger.info("Manual flush requested"),[4,this.eventQueue.flush()]):(this.logger.warn("Cannot flush events - EventTracker not initialized"),[2]);case 1:return t.sent(),[2]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying EventTracker"),this.eventQueue?[4,this.eventQueue.destroy()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.initialized=!1,this.logger.info(Mu),[2]}})})},t.prototype.trackNotificationReceived=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return[4,this.trackDLREvent("received",t)];case 1:return n.sent(),[2]}})})},t.prototype.trackNotificationClicked=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return[4,this.trackDLREvent("clicked",t)];case 1:return n.sent(),[2]}})})},t.prototype.trackNotificationDismissed=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return[4,this.trackDLREvent("dismissed",t)];case 1:return n.sent(),[2]}})})},t.prototype.trackDLREvent=function(t,n){return Qs(this,void 0,void 0,function(){var i,r;return Zs(this,function(e){switch(e.label){case 0:if(!this.initialized||!this.eventQueue)return this.logger.warn("EventTracker not initialized, skipping DLR event",{eventType:t}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),i=this.createDLREvent(t,n),[4,this.eventQueue.enqueue(i,!0)];case 2:return e.sent(),this.logger.info("DLR event tracked: ".concat(t),{eventType:t,eventName:i.name,messageId:n.messageId}),[3,4];case 3:return r=e.sent(),this.logger.error("Failed to track DLR event",{eventType:t,notificationData:n,error:r}),[3,4];case 4:return[2]}})})},t.prototype.createDLREvent=function(t,n){var i,r={received:ja.NOTIFICATION_RECEIVED,clicked:ja.NOTIFICATION_CLICKED,dismissed:ja.NOTIFICATION_DISMISSED},e=null===(i=this.eventQueue)||void 0===i?void 0:i.getCurrentCuid(),o={messageId:n.messageId,gateway:Va,result:{received:"SUCCESS",clicked:"CLICKED",dismissed:"DISMISSED"}[t],notification_route:Ba,cuid:e||null,visitor_id:e?null:this.visitorId||null,scope:n.scope||null};return"received"===t&&(o.notification_id=n.messageId,o.campaign_id=n.campaignId||null,o.channel=Ba,o.title=n.title||null),"clicked"===t&&(o.notification_id=n.messageId,o.campaign_id=n.campaignId||null,o.channel=Ba,o.action="open_app"),n.senderId&&(o.senderId=n.senderId),{attributes:o,name:r[t],eventDateTime:(new Date).toISOString(),eventExternalId:ym()}},t.prototype.dispatchDLREvent=function(t){return Qs(this,void 0,void 0,function(){var n;return Zs(this,function(i){switch(i.label){case 0:switch(n=Js(Js(Js(Js(Js(Js({messageId:t.messageId},void 0!==t.scope?{scope:t.scope}:{}),void 0!==t.campaignId?{campaignId:t.campaignId}:{}),void 0!==t.variationId?{variationId:t.variationId}:{}),void 0!==t.senderId?{senderId:t.senderId}:{}),void 0!==t.cuid?{cuid:t.cuid}:{}),void 0!==t.accountId?{accountId:t.accountId}:{}),t.type){case"received":return[3,1];case"clicked":return[3,3];case"dismissed":return[3,5]}return[3,7];case 1:return[4,this.trackNotificationReceived(n)];case 2:case 4:case 6:return i.sent(),[3,7];case 3:return[4,this.trackNotificationClicked(n)];case 5:return[4,this.trackNotificationDismissed(n)];case 7:return[2]}})})},t.prototype.processPendingServiceWorkerDLREvents=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u;return Zs(this,function(a){switch(a.label){case 0:if(!this.initialized)return[2];a.label=1;case 1:return a.trys.push([1,12,,13]),[4,this.getServiceWorkerPendingDLREvents()];case 2:if(0===(t=a.sent()).length)return[2];this.logger.info("Processing pending service worker DLR events",{count:t.length}),a.label=3;case 3:a.trys.push([3,8,9,10]),n=tu(t),i=n.next(),a.label=4;case 4:return i.done?[3,7]:(r=i.value,[4,this.dispatchDLREvent(r)]);case 5:a.sent(),a.label=6;case 6:return i=n.next(),[3,4];case 7:return[3,10];case 8:return e=a.sent(),s={error:e},[3,10];case 9:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 10:return[4,this.clearServiceWorkerPendingDLREvents()];case 11:return a.sent(),this.logger.info("Processed pending service worker DLR events",{count:t.length}),[3,13];case 12:return o=a.sent(),this.logger.error("Failed to process pending service worker DLR events",o),[3,13];case 13:return[2]}})})},t.prototype.getServiceWorkerPendingDLREvents=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return[2,new Promise(function(t){var n=indexedDB.open("WebSDK_DLR_SW",1);n.onerror=function(){return t([])},n.onsuccess=function(){var i=n.result;if(!i.objectStoreNames.contains("pending_dlr_events"))return i.close(),void t([]);var r=i.transaction(["pending_dlr_events"],"readonly").objectStore("pending_dlr_events").getAll();r.onerror=function(){i.close(),t([])},r.onsuccess=function(){i.close(),t(r.result||[])}},n.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains("pending_dlr_events")||n.createObjectStore("pending_dlr_events",{keyPath:"id",autoIncrement:!0})}})]})})},t.prototype.clearServiceWorkerPendingDLREvents=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return[2,new Promise(function(t){var n=indexedDB.open("WebSDK_DLR_SW",1);n.onerror=function(){return t()},n.onsuccess=function(){var i=n.result;if(!i.objectStoreNames.contains("pending_dlr_events"))return i.close(),void t();var r=i.transaction(["pending_dlr_events"],"readwrite").objectStore("pending_dlr_events").clear();r.onerror=function(){i.close(),t()},r.onsuccess=function(){i.close(),t()}},n.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains("pending_dlr_events")||n.createObjectStore("pending_dlr_events",{keyPath:"id",autoIncrement:!0})}})]})})},t}(),Dp=function(){function t(t,n,i){this.initialized=!1,this.logger=t,this.brandId=n,this.applicationId=i,this.adapter=new Cp}return t.prototype.init=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:if(this.initialized)return this.logger.warn("StorageManager already initialized"),[2];this.logger.info("Initializing StorageManager"),e.label=1;case 1:return e.trys.push([1,6,,7]),this.isIndexedDBSupported()?(t=["WebSDK"],this.brandId&&t.push(this.brandId),this.applicationId&&t.push(this.applicationId),n=t.join("_"),i=new Op(n),[4,this.testStorageAdapter(i)]):[3,3];case 2:return e.sent(),this.adapter=i,this.logger.info("StorageManager initialized with IndexedDB",{dbName:n,brandId:this.brandId,applicationId:this.applicationId}),[3,5];case 3:return[4,this.testStorageAdapter(this.adapter)];case 4:e.sent(),this.logger.info("StorageManager initialized with localStorage"),e.label=5;case 5:return this.initialized=!0,[3,7];case 6:throw r=e.sent(),this.logger.error(Fu,r),new Error("Storage initialization failed: ".concat(r));case 7:return[2]}})})},t.prototype.isIndexedDBSupported=function(){return"undefined"!=typeof window&&"indexedDB"in window&&null!==indexedDB},t.prototype.testStorageAdapter=function(t){return Qs(this,void 0,void 0,function(){var n,i,r;return Zs(this,function(e){switch(e.label){case 0:n=gu,i=mu,e.label=1;case 1:return e.trys.push([1,5,,6]),[4,t.setItem(n,i)];case 2:return e.sent(),[4,t.getItem(n)];case 3:if(e.sent()!==i)throw new Error(ju);return[4,t.removeItem(n)];case 4:return e.sent(),[3,6];case 5:throw r=e.sent(),new Error("".concat(Gu," ").concat(r));case 6:return[2]}})})},t.prototype.get=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.getItem(t)]})})},t.prototype.set=function(t,n){return Qs(this,void 0,void 0,function(){return Zs(this,function(i){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.setItem(t,n)]})})},t.prototype.remove=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.removeItem(t)]})})},t.prototype.clear=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.clear()]})})},t.prototype.getIndexedDBAdapter=function(){return this.adapter instanceof Op?this.adapter:null},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:this.logger.info("Destroying StorageManager"),n.label=1;case 1:return n.trys.push([1,4,,5]),this.adapter instanceof Op?[4,this.adapter.close()]:[3,3];case 2:n.sent(),n.label=3;case 3:return this.initialized=!1,this.logger.info(Vu),[3,5];case 4:return t=n.sent(),this.logger.error(Bu,t),this.initialized=!1,[3,5];case 5:return[2]}})})},t}(),Cp=function(){function t(){}return t.prototype.getItem=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){try{return[2,localStorage.getItem(t)]}catch(t){throw new Error("LocalStorage getItem failed: ".concat(t))}return[2]})})},t.prototype.setItem=function(t,n){return Qs(this,void 0,void 0,function(){return Zs(this,function(i){try{localStorage.setItem(t,n)}catch(t){if(t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name))throw new Error("LocalStorage quota exceeded");throw new Error("LocalStorage setItem failed: ".concat(t))}return[2]})})},t.prototype.removeItem=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){try{localStorage.removeItem(t)}catch(t){throw new Error("LocalStorage removeItem failed: ".concat(t))}return[2]})})},t.prototype.clear=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){try{localStorage.clear()}catch(t){throw new Error("LocalStorage clear failed: ".concat(t))}return[2]})})},t}();!function(t){t[t.VERBOSE=0]="VERBOSE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.NONE=5]="NONE"}(Ap||(Ap={}));var xp,Rp,Mp=function(){function t(t,n){void 0===t&&(t=!1),void 0===n&&(n=Ap.INFO),this.logs=[],this.maxLogs=1e3,this.enabled=t,this.level=n}return t.prototype.formatMessage=function(t,n){var i=(new Date).toISOString(),r=Ap[t];return"[".concat(i,"] [WebSDK:").concat(r,"] ").concat(n)},t.prototype.log=function(t,n,i){if(this.enabled&&!(t<this.level)){var r={level:t,message:n,timestamp:Date.now(),data:i};this.logs.push(r),this.logs.length>this.maxLogs&&this.logs.shift();var e=this.formatMessage(t,n),o=i?[e,i]:[e];switch(t){case Ap.VERBOSE:case Ap.DEBUG:console.debug.apply(console,iu([],nu(o),!1));break;case Ap.INFO:console.info.apply(console,iu([],nu(o),!1));break;case Ap.WARN:console.warn.apply(console,iu([],nu(o),!1));break;case Ap.ERROR:console.error.apply(console,iu([],nu(o),!1))}}},t.prototype.verbose=function(t,n){this.log(Ap.VERBOSE,t,n)},t.prototype.debug=function(t,n){this.log(Ap.DEBUG,t,n)},t.prototype.info=function(t,n){this.log(Ap.INFO,t,n)},t.prototype.warn=function(t,n){this.log(Ap.WARN,t,n)},t.prototype.error=function(t,n){this.log(Ap.ERROR,t,n)},t.prototype.setLevel=function(t){this.level=t},t.prototype.setEnabled=function(t){this.enabled=t},t.prototype.getLogs=function(){return iu([],nu(this.logs),!1)},t.prototype.clearLogs=function(){this.logs=[]},t}(),Up=function(){function t(t,n,i,r,e,o){this.initialized=!1,this.cachedConfig=null,this.orgId=t,this.apiClient=n,this.logger=i,this.storageManager=r,void 0!==e&&(this.brandId=e),void 0!==o&&(this.applicationId=o)}return t.prototype.init=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("VisitorConfigManager already initialized"),[2]):(this.logger.info("Initializing VisitorConfigManager",{orgId:this.orgId}),[4,this.restoreCachedConfig()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(Zu),[2]}})})},t.prototype.fetchConfig=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r=this;return Zs(this,function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("VisitorConfigManager not initialized");if(this.cachedConfig)return this.logger.info(ea),[2,this.cachedConfig];e.label=1;case 1:return e.trys.push([1,4,,5]),this.logger.info("Fetching visitor config from API",{orgId:this.orgId}),[4,this.apiClient.getVisitorConfig(this.orgId)];case 2:return(t=e.sent()).warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){r.logger.warn("Visitor config warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){r.logger.error("Visitor config error from response",{code:t.code,message:t.message})}),this.cachedConfig=t,[4,this.storeCachedConfig(t)];case 3:return e.sent(),this.logger.info(ta,{isEnabled:null===(i=t.data)||void 0===i?void 0:i.visitorTrackingEnabled}),[2,t];case 4:throw n=e.sent(),this.logger.error(na,n),new Error("".concat(Eu,": ").concat(n));case 5:return[2]}})})},t.prototype.isVisitorTrackingEnabled=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.fetchConfig()];case 1:return t=e.sent(),(n=!0===(null===(r=t.data)||void 0===r?void 0:r.visitorTrackingEnabled))?this.logger.info(ra):this.logger.info(ia),[2,n];case 2:return i=e.sent(),this.logger.error("Failed to check visitor tracking status",i),[2,!1];case 3:return[2]}})})},t.prototype.refreshConfig=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){if(!this.initialized)throw new Error("VisitorConfigManager not initialized");return this.logger.info("Force refreshing visitor config from API"),this.cachedConfig=null,[2,this.fetchConfig()]})})},t.prototype.getCachedConfig=function(){return this.cachedConfig},t.prototype.storeCachedConfig=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=lu("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.set(n,JSON.stringify(t))];case 1:return r.sent(),this.logger.debug("Visitor config cached to storage",{key:n}),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to store visitor config to cache",i),[3,3];case 3:return[2]}})})},t.prototype.restoreCachedConfig=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e;return Zs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=lu("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=o.sent())&&(i=JSON.parse(n),this.cachedConfig=i,this.logger.info("Visitor config restored from cache",{isEnabled:null===(e=i.data)||void 0===e?void 0:e.visitorTrackingEnabled})),[3,3];case 2:return r=o.sent(),this.logger.warn("Failed to restore visitor config from cache",r),this.cachedConfig=null,[3,3];case 3:return[2]}})})},t.prototype.clearCachedConfig=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:this.cachedConfig=null,i.label=1;case 1:return i.trys.push([1,3,,4]),t=lu("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 2:return i.sent(),this.logger.debug("Visitor config cache cleared"),[3,4];case 3:return n=i.sent(),this.logger.warn("Failed to clear visitor config cache",n),[3,4];case 4:return[2]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying VisitorConfigManager"),[4,this.clearCachedConfig()];case 1:return t.sent(),this.initialized=!1,this.logger.info("VisitorConfigManager destroyed successfully"),[2]}})})},t}(),Pp={};Rp||(Rp=1,function(){if(xp)return Pp;xp=1;var t=Sr(),n=k();t({global:!0,forced:n.globalThis!==n},{globalThis:n})}());var Lp=function(){function t(t,n,i,r,e,o){this.initialized=!1,this.visitorId=null,this.visitorExternalId=null,this.expiredAt=null,this.getFcmToken=null,this.getChannelType=null,this.getExtendedFields=null,this.getPermissionGranted=null,this.getSessionId=null,this.mergeRetryTimeoutId=null,this.accountId=t,this.orgId=n,this.apiClient=i,this.logger=r,this.storageManager=e,void 0!==(null==o?void 0:o.brandId)&&(this.brandId=o.brandId),void 0!==(null==o?void 0:o.applicationId)&&(this.applicationId=o.applicationId)}return t.prototype.setMergeDataProviders=function(t,n,i,r,e){this.getFcmToken=t,this.getChannelType=n,this.getExtendedFields=i,this.getPermissionGranted=r,this.getSessionId=e},t.prototype.init=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("AnonymousVisitorManager already initialized"),[2]):(this.logger.info("Initializing AnonymousVisitorManager",{accountId:this.accountId,orgId:this.orgId}),[4,this.restoreVisitorId()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(oa),[2]}})})},t.prototype.getOrCreateVisitorId=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:if(!this.initialized)throw new Error("AnonymousVisitorManager not initialized");if(this.visitorId&&!this.isVisitorExpired())return this.logger.info(ca,{visitorId:this.visitorId}),[2,this.visitorId];if(this.visitorId&&this.isVisitorExpired()&&this.logger.info("Visitor session expired, creating new visitor via API",{visitorId:this.visitorId,expiredAt:this.expiredAt}),!this.accountId||""===this.accountId.trim())throw i=new Error("AccountId is required for visitor creation"),this.logger.error("Visitor creation validation failed",i),i;u.label=1;case 1:return u.trys.push([1,5,,6]),this.logger.info("Creating new visitor ID",{accountId:this.accountId,hasCommChannels:!!t&&t.length>0,hasExtendedFields:!!n}),[4,this.createVisitor(t,n)];case 2:return r=u.sent(),e=r.visitorId,o=r.expiredAt,this.visitorId=e,[4,this.storeVisitorId(e)];case 3:return u.sent(),[4,this.storeExpiredAt(o)];case 4:return u.sent(),this.logger.info(sa,{visitorId:e}),[2,e];case 5:throw s=u.sent(),this.logger.error(ua,s),s;case 6:return[2]}})})},t.prototype.createVisitor=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),[4,this.getOrGenerateVisitorExternalId()];case 1:return i=u.sent(),r=t&&t.length>0?t:[],e=Js({visitorExternalId:i,profiles:[{commChannels:r}]},n&&{extendedFields:n}),this.logger.debug("Visitor creation request payload",{request:e}),[4,this.apiClient.createVisitor(this.orgId,e)];case 2:return o=u.sent(),[2,this.handleCreateVisitorResponse(o)];case 3:throw s=u.sent(),this.handleCreateVisitorError(s),s;case 4:return[2]}})})},t.prototype.handleCreateVisitorResponse=function(t){var n,i,r=this;t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){r.logger.warn("Visitor creation warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){r.logger.error("Visitor creation error from response",{code:t.code,message:t.message})});var e=null===(n=t.data)||void 0===n?void 0:n.id;if(!e||""===e.trim())throw new Error("Invalid visitor ID received from API");var o=null===(i=t.data)||void 0===i?void 0:i.expiredAt;if(!o)throw new Error("Missing expiredAt in visitor creation response");return{visitorId:e,expiredAt:o}},t.prototype.handleCreateVisitorError=function(t){var n,i=this;try{var r=(null===(n=t.response)||void 0===n?void 0:n.data)||t;r.warnings&&r.warnings.length>0&&r.warnings.forEach(function(t){t.code===Fa.ACCOUNT_NOT_EXISTS?i.logger.error("Account does not exist",{code:t.code,message:t.message,accountId:i.accountId}):i.logger.warn("Visitor creation warning",{code:t.code,message:t.message})}),r.errors&&r.errors.length>0&&r.errors.forEach(function(t){t.code===Fa.ACCOUNT_ID_NOT_PASSED?i.logger.error("AccountId not passed",{code:t.code,message:t.message}):i.logger.error("Visitor creation error",{code:t.code,message:t.message})})}catch(t){this.logger.warn("Failed to parse visitor creation error",t)}},t.prototype.updateVisitor=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:if(!this.initialized)throw new Error("AnonymousVisitorManager not initialized");if(!this.visitorId)throw new Error("No visitor ID exists. Create a visitor first.");u.label=1;case 1:return u.trys.push([1,3,,4]),this.logger.info("Updating visitor",{visitorId:this.visitorId,hasCommChannels:!!t&&t.length>0,hasExtendedFields:!!n}),i=t&&t.length>0?t:[],r=Js({profiles:[{commChannels:i}]},n&&{extendedFields:n}),this.logger.debug("Visitor update request payload",{request:r}),[4,this.apiClient.updateVisitor(this.orgId,this.visitorId,r)];case 2:return e=u.sent(),o=this.handleUpdateVisitorResponse(e),this.logger.info(fa,{visitorId:o}),[2,o];case 3:throw s=u.sent(),this.handleUpdateVisitorError(s),this.logger.error(ha,s),s;case 4:return[2]}})})},t.prototype.handleUpdateVisitorResponse=function(t){var n,i=this;t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){i.logger.warn("Visitor update warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){i.logger.error("Visitor update error from response",{code:t.code,message:t.message})});var r=null===(n=t.data)||void 0===n?void 0:n.id;if(!r||""===r.trim())throw new Error("Invalid visitor ID received from update API");return r},t.prototype.handleUpdateVisitorError=function(t){var n,i=this;try{var r=(null===(n=t.response)||void 0===n?void 0:n.data)||t;r.warnings&&r.warnings.length>0&&r.warnings.forEach(function(t){t.code===Fa.ACCOUNT_NOT_EXISTS?i.logger.error("Account does not exist",{code:t.code,message:t.message,accountId:i.accountId}):i.logger.warn("Visitor update warning",{code:t.code,message:t.message})}),r.errors&&r.errors.length>0&&r.errors.forEach(function(t){i.logger.error("Visitor update error",{code:t.code,message:t.message})})}catch(t){this.logger.warn("Failed to parse visitor update error",t)}},t.prototype.mergeVisitorWithUser=function(t,n,i,r,e,o){return Qs(this,void 0,void 0,function(){var s,u,a;return Zs(this,function(c){switch(c.label){case 0:if(!this.initialized)return this.logger.warn(la,{reason:"Not initialized"}),[2,!1];if(!this.visitorId)return this.logger.warn(la,{reason:"No visitor ID"}),[2,!1];if(!i&&!r&&!e)return this.logger.warn(la,{reason:"No email, mobile, or externalId"}),[2,!1];s=this.visitorId,u=this.visitorExternalId,c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.isMerged()];case 2:return c.sent()?(this.logger.info(la,{reason:"Visitor already merged",visitorId:s}),[2,!0]):[4,this.persistPendingMerge(s,u,Js(Js(Js(Js({firstName:t,lastName:n},void 0!==i&&{email:i}),void 0!==r&&{mobile:r}),void 0!==e&&{externalId:e}),void 0!==o&&{customData:o}))];case 3:return c.sent(),[4,this.attemptPendingMerge()];case 4:return c.sent(),[2,this.isMerged()];case 5:return a=c.sent(),this.logger.warn("Merge background task failed unexpectedly",a),[2,!1];case 6:return[2]}})})},t.prototype.retryPendingMerge=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),[4,this.getPendingMerge()];case 1:return(t=i.sent())?[4,this.isMerged()]:[2];case 2:return i.sent()?[4,this.clearPendingMerge()]:[3,4];case 3:return i.sent(),this.logger.info(la,{reason:"Already merged"}),[2];case 4:return t.attempts>=Ma?(this.logger.error(va,{visitorId:t.visitorId,attempts:t.attempts,message:"Max retries exhausted"}),[4,this.clearPendingMerge()]):[3,6];case 5:return i.sent(),[2];case 6:return this.scheduleMergeRetry(),[3,8];case 7:return n=i.sent(),this.logger.warn("Failed to retry pending merge",n),[3,8];case 8:return[2]}})})},t.prototype.cancelMergeRetryTimer=function(){null!==this.mergeRetryTimeoutId&&(globalThis.clearTimeout(this.mergeRetryTimeoutId),this.mergeRetryTimeoutId=null)},t.prototype.scheduleMergeRetry=function(){var t=this;this.cancelMergeRetryTimer(),this.mergeRetryTimeoutId=globalThis.setTimeout(function(){t.mergeRetryTimeoutId=null,t.attemptPendingMerge().catch(function(n){t.logger.warn("Scheduled merge retry failed unexpectedly",n)})},Ua)},t.prototype.collectMergeContext=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:t=this.getFcmToken?this.getFcmToken():null,n=this.getChannelType?this.getChannelType():void 0,i=!this.getPermissionGranted||this.getPermissionGranted(),r=this.getSessionId?this.getSessionId():"",u.label=1;case 1:return u.trys.push([1,5,,6]),this.getExtendedFields?[4,this.getExtendedFields()]:[3,3];case 2:return o=u.sent(),[3,4];case 3:o=void 0,u.label=4;case 4:return e=o,[3,6];case 5:return s=u.sent(),this.logger.warn("Failed to collect extended fields for merge, proceeding without them",s),e=void 0,[3,6];case 6:return[2,{fcmToken:t,channelType:n,subscribed:i,sessionId:r,extendedFields:e}]}})})},t.prototype.attemptPendingMerge=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u;return Zs(this,function(a){switch(a.label){case 0:return[4,this.getPendingMerge()];case 1:return(t=a.sent())?[4,this.collectMergeContext()]:[2];case 2:n=a.sent(),i=n.fcmToken,r=n.channelType,e=n.subscribed,o=n.sessionId,s=n.extendedFields,a.label=3;case 3:return a.trys.push([3,7,,9]),[4,this.apiClient.mergeVisitor(t.visitorId,t.visitorExternalId||null,Js(Js(Js(Js(Js(Js(Js(Js({firstName:t.firstName,lastName:t.lastName},void 0!==t.email&&{email:t.email}),void 0!==t.mobile&&{mobile:t.mobile}),i?{fcmToken:i,subscribed:e}:{}),void 0!==r&&{channelType:r}),{fields:t.customData||{}}),void 0!==s&&{extendedFields:s}),void 0!==t.externalId&&{externalId:t.externalId}),{sessionId:o}))];case 4:return a.sent(),[4,this.markAsMerged(t.visitorId)];case 5:return a.sent(),[4,this.clearPendingMerge()];case 6:return a.sent(),this.logger.info(da,{visitorId:t.visitorId,attempts:t.attempts+1}),[3,9];case 7:return u=a.sent(),[4,this.handleMergeRetryOrAbort(u,t)];case 8:return a.sent(),[3,9];case 9:return[2]}})})},t.prototype.handleMergeRetryOrAbort=function(t,n){return Qs(this,void 0,void 0,function(){var i;return Zs(this,function(r){switch(r.label){case 0:return t instanceof bp?[4,this.clearPendingMerge()]:[3,2];case 1:return r.sent(),this.logger.error("Visitor merge failed permanently, will not retry",{code:t.code,message:t.message,visitorId:n.visitorId}),[2];case 2:return i=Js(Js({},n),{attempts:n.attempts+1}),[4,this.savePendingMerge(i)];case 3:return r.sent(),i.attempts>=Ma?(this.logger.error(va,{visitorId:n.visitorId,attempts:i.attempts,message:"Max retries exhausted"}),[4,this.clearPendingMerge()]):[3,5];case 4:return r.sent(),[2];case 5:return this.logger.warn("Visitor merge attempt failed, scheduling retry",{attempt:i.attempts,maxRetries:Ma,nextRetryMs:Ua,visitorId:n.visitorId,error:t}),this.scheduleMergeRetry(),[2]}})})},t.prototype.persistPendingMerge=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e,o,s,u,a,c;return Zs(this,function(f){switch(f.label){case 0:return r=i.firstName,e=i.lastName,o=i.email,s=i.mobile,u=i.externalId,a=i.customData,c=Js(Js(Js(Js(Js(Js(Js({visitorId:t},n&&{visitorExternalId:n}),{firstName:r,lastName:e}),void 0!==o&&{email:o}),void 0!==s&&{mobile:s}),void 0!==u&&{externalId:u}),void 0!==a&&{customData:a}),{attempts:0}),[4,this.savePendingMerge(c)];case 1:return f.sent(),this.logger.debug("Pending merge request persisted to storage",{visitorId:t}),[2]}})})},t.prototype.getPendingMerge=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=lu("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=r.sent())?[2,JSON.parse(n)]:[2,null];case 2:return i=r.sent(),this.logger.warn("Failed to read pending merge from storage",i),[2,null];case 3:return[2]}})})},t.prototype.savePendingMerge=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=lu("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.set(n,JSON.stringify(t))];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to save pending merge to storage",i),[3,3];case 3:return[2]}})})},t.prototype.clearPendingMerge=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:this.cancelMergeRetryTimer(),i.label=1;case 1:return i.trys.push([1,3,,4]),t=lu("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 2:return i.sent(),this.logger.debug("Pending merge cleared from storage"),[3,4];case 3:return n=i.sent(),this.logger.warn("Failed to clear pending merge from storage",n),[3,4];case 4:return[2]}})})},t.prototype.isMerged=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=lu("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,null!=i.sent()];case 2:return n=i.sent(),this.logger.warn("Failed to check merge status",n),[2,!1];case 3:return[2]}})})},t.prototype.getMergedUserId=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=lu("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,null!=(n=r.sent())?n:null];case 2:return i=r.sent(),this.logger.warn("Failed to get merge status",i),[2,null];case 3:return[2]}})})},t.prototype.clearMergedUserId=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=lu("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return i.sent(),this.logger.info("Merge status cleared from storage"),[3,3];case 2:return n=i.sent(),this.logger.warn("Failed to clear merge status",n),[3,3];case 3:return[2]}})})},t.prototype.markAsMerged=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=lu("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 1:return r.sent(),this.logger.debug("Visitor marked as merged",{visitorId:t,key:n}),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to store merge status",i),[3,3];case 3:return[2]}})})},t.prototype.getVisitorId=function(){return this.visitorId},t.prototype.getVisitorExternalId=function(){return this.visitorExternalId},t.prototype.hasVisitorId=function(){return null!==this.visitorId},t.prototype.storeVisitorId=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=lu("VISITOR_ID",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 1:return r.sent(),this.logger.debug("Visitor ID stored to storage",{visitorId:t,key:n}),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to store visitor ID",i),[3,3];case 3:return[2]}})})},t.prototype.storeExpiredAt=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.expiredAt=t,n=lu("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 1:return r.sent(),this.logger.debug("Visitor expiredAt stored to storage",{expiredAt:t}),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to store visitor expiredAt",i),[3,3];case 3:return[2]}})})},t.prototype.isVisitorExpired=function(){if(!this.expiredAt)return!0;try{return new Date(this.expiredAt).getTime()<=Date.now()}catch(t){return this.logger.warn("Invalid expiredAt format, treating as expired",{expiredAt:this.expiredAt}),!0}},t.prototype.getOrGenerateVisitorExternalId=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:if(this.visitorExternalId)return[2,this.visitorExternalId];t=ym(),this.visitorExternalId=t,r.label=1;case 1:return r.trys.push([1,3,,4]),n=lu("VISITOR_EXTERNAL_ID",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 2:return r.sent(),this.logger.debug("visitorExternalId generated and stored",{visitorExternalId:t}),[3,4];case 3:return i=r.sent(),this.logger.warn("Failed to store visitorExternalId",i),[3,4];case 4:return[2,t]}})})},t.prototype.restoreVisitorId=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:return u.trys.push([0,4,,5]),t=lu("VISITOR_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=u.sent())&&(this.visitorId=n,this.logger.info(aa,{visitorId:n})),i=lu("VISITOR_EXTERNAL_ID",this.brandId,this.applicationId),[4,this.storageManager.get(i)];case 2:return(r=u.sent())&&(this.visitorExternalId=r),e=lu("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(e)];case 3:return(o=u.sent())&&(this.expiredAt=o),[3,5];case 4:return s=u.sent(),this.logger.warn("Failed to restore visitor ID from storage",s),this.visitorId=null,[3,5];case 5:return[2]}})})},t.prototype.clearVisitorId=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),t=lu("VISITOR_ID",this.brandId,this.applicationId),n=lu("VISITOR_EXTERNAL_ID",this.brandId,this.applicationId),i=lu("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return e.sent(),[4,this.storageManager.remove(n)];case 2:return e.sent(),[4,this.storageManager.remove(i)];case 3:return e.sent(),this.visitorId=null,this.visitorExternalId=null,this.expiredAt=null,this.logger.info("Visitor ID cleared from storage"),[3,5];case 4:return r=e.sent(),this.logger.warn("Failed to clear visitor ID",r),this.visitorId=null,this.visitorExternalId=null,this.expiredAt=null,[3,5];case 5:return[2]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return this.logger.info("Destroying AnonymousVisitorManager"),this.cancelMergeRetryTimer(),this.initialized=!1,this.logger.info("AnonymousVisitorManager destroyed successfully"),[2]})})},t}();function Fp(){return"undefined"!=typeof window&&window.firebase?window.firebase:null}function Gp(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){return(t=Fp())?[2,t]:[2,import("firebase/app")]})})}function jp(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return[2,import("firebase/messaging")]})})}function Vp(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){return(t=Fp())&&t.remoteConfig?[2,t]:[2,import("firebase/remote-config")]})})}var Bp=function(){function t(t,n,i,r,e,o){this.isInitialized=!1,this.currentToken=null,this.swRegistration=null,this.messaging=t,this.logger=n,this.vapidKey=i,this.serviceWorkerPath=r||du,this.onTokenReceivedCallback=e,this.onMessageReceivedCallback=o}return t.prototype.initialize=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return this.isInitialized?(this.logger.warn("FirebaseManager already initialized"),[2,!0]):this.messaging?(this.isInitialized=!0,this.logger.info(ya),[2,!0]):(this.logger.error(ba,new Error("Messaging instance missing")),[2,!1])})})},t.prototype.ensureServiceWorkerRegistered=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:return this.swRegistration?[2,this.swRegistration]:this.isInitialized&&this.messaging?(t=this,[4,this.registerServiceWorker()]):[2,null];case 1:return t.swRegistration=n.sent(),[2,this.swRegistration]}})})},t.prototype.registerServiceWorker=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:if(!("serviceWorker"in navigator))return this.logger.warn("Service Worker not supported"),[2,null];r.label=1;case 1:return r.trys.push([1,7,,8]),[4,navigator.serviceWorker.getRegistration(this.serviceWorkerPath)];case 2:return(t=r.sent())?(this.logger.info("Service worker already registered",{scope:t.scope}),[4,this.ensureServiceWorkerActive(t)]):[3,4];case 3:return r.sent(),[2,t];case 4:return this.logger.info("Registering service worker",{path:this.serviceWorkerPath}),[4,navigator.serviceWorker.register(this.serviceWorkerPath)];case 5:return n=r.sent(),this.logger.info(Ta,{scope:n.scope}),[4,this.ensureServiceWorkerActive(n)];case 6:return r.sent(),[2,n];case 7:return i=r.sent(),this.logger.error(Sa,i),[2,null];case 8:return[2]}})})},t.prototype.ensureServiceWorkerActive=function(t){return Qs(this,void 0,void 0,function(){var n,i=this;return Zs(this,function(r){return t.active?(this.logger.debug("Service worker is already active"),[2]):(n=t.installing||t.waiting)?(this.logger.info("Waiting for service worker to activate...",{state:n.state}),[2,new Promise(function(t,r){if("activated"!==n.state){var e=function(){"activated"===n.state?(n.removeEventListener("statechange",e),i.logger.info("Service worker activated"),t()):"redundant"===n.state&&(n.removeEventListener("statechange",e),r(new Error("Service worker became redundant")))};n.addEventListener("statechange",e)}else t()})]):(this.logger.warn("No service worker found in registration"),[2])})})},t.prototype.requestToken=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:if(!this.isInitialized||!this.messaging)return this.logger.error("FirebaseManager not initialized"),[2,null];e.label=1;case 1:return e.trys.push([1,5,,6]),(n=this.swRegistration)?[3,3]:[4,this.registerServiceWorker()];case 2:n=e.sent(),e.label=3;case 3:return(t=n)?(this.swRegistration=t,[4,this.fetchFCMToken(t)]):(this.logger.warn("Service worker registration required for FCM"),[2,null]);case 4:return(i=e.sent())?(this.currentToken=i,this.logger.info(Ea,{token:i}),this.onTokenReceivedCallback&&this.onTokenReceivedCallback(i),[2,i]):(this.logger.warn("No FCM token received - permission may be denied"),[2,null]);case 5:return r=e.sent(),this.logger.error(Ia,r),[2,null];case 6:return[2]}})})},t.prototype.fetchFCMToken=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return[4,jp()];case 1:return n=r.sent().getToken,i={serviceWorkerRegistration:t},this.vapidKey&&(i.vapidKey=this.vapidKey),[2,n(this.messaging,i)]}})})},t.prototype.setupMessageListener=function(){return Qs(this,void 0,void 0,function(){var t,n=this;return Zs(this,function(i){switch(i.label){case 0:if(!this.isInitialized||!this.messaging)return this.logger.error("FirebaseManager not initialized"),[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,jp()];case 2:return(0,i.sent().onMessage)(this.messaging,function(t){n.handleMessage(t)}),this.logger.info("Message listener setup successfully"),[3,4];case 3:return t=i.sent(),this.logger.error("Failed to setup message listener",t),[3,4];case 4:return[2]}})})},t.prototype.handleMessage=function(t){this.logger.info("FCM message received",t),this.onMessageReceivedCallback&&this.onMessageReceivedCallback(t)},t.prototype.getCurrentToken=function(){return this.currentToken},t.prototype.isFirebaseInitialized=function(){return this.isInitialized},t.prototype.destroy=function(){this.isInitialized=!1,this.messaging=null,this.currentToken=null,this.swRegistration=null,this.logger.info("FirebaseManager destroyed successfully")},t}(),zp=function(){function t(t,n,i,r,e){this.firebaseManager=null,this.tokenUpdateCallback=null,this.config=t,this.logger=n,this.storageManager=i,this.brandId=r,this.applicationId=e,this.config.onTokenRefresh&&this.logger.warn("notifications.onTokenRefresh has no effect — the modular Firebase SDK has no token-refresh event to fire it from. Call NotificationManager.refreshToken() to manually re-request a token instead."),this.state={isNotificationEnabled:!1,firebaseInitialized:!1,permissionStatus:"default"}}return t.prototype.isNotificationSupported=function(){return"undefined"!=typeof window&&"undefined"!=typeof Notification&&"undefined"!=typeof navigator&&"serviceWorker"in navigator},t.prototype.getPermissionStatus=function(){return this.isNotificationSupported()?Notification.permission:"denied"},t.prototype.shouldInitializeNotifications=function(){return this.isNotificationSupported()?!!this.config.messaging||(this.logger.warn("Firebase Messaging instance not provided - notifications disabled"),!1):(this.logger.warn("Notifications not supported in this browser"),!1)},t.prototype.restoreState=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e;return Zs(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=lu("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=o.sent())&&(i=JSON.parse(n),r=this.getPermissionStatus(),this.state=Js(Js(Js({},this.state),i),{permissionStatus:r}),this.logger.info("Notification state restored from storage",{storedPermission:i.permissionStatus,currentPermission:r,hasToken:!!i.fcmToken})),[3,3];case 2:return e=o.sent(),this.logger.warn("Failed to restore notification state",e),[3,3];case 3:return[2]}})})},t.prototype.saveState=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=lu("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.set(t,JSON.stringify(this.state))];case 1:return i.sent(),this.logger.debug("Notification state saved to storage",this.state),[3,3];case 2:return n=i.sent(),this.logger.warn("Failed to save notification state",n),[3,3];case 3:return[2]}})})},t.prototype.init=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,15,,17]),[4,this.restoreState()];case 1:return i.sent(),this.shouldInitializeNotifications()?[3,3]:(this.logger.info(wa),this.state.isNotificationEnabled=!1,[4,this.saveState()]);case 2:return i.sent(),[2,this.state];case 3:return t=this.getPermissionStatus(),this.state.permissionStatus=t,this.logger.info("Current notification permission",{permission:t,hasStoredToken:!!this.state.fcmToken,isNotificationEnabled:this.state.isNotificationEnabled}),"denied"!==t?[3,5]:(this.logger.warn(ga),this.state.isNotificationEnabled=!1,delete this.state.fcmToken,[4,this.saveState()]);case 4:return i.sent(),[2,this.state];case 5:return"default"!==t?[3,7]:(this.logger.info("Permission not yet granted - notifications will not be shown until user grants permission"),this.state.isNotificationEnabled=!1,[4,this.saveState()]);case 6:return i.sent(),[2,this.state];case 7:return"granted"!==t?[3,14]:this.state.fcmToken?(this.logger.info("Using existing FCM token from storage",{token:this.state.fcmToken.substring(0,20)+"..."}),this.state.isNotificationEnabled=!0,this.firebaseManager?[3,9]:(this.logger.info("Initializing Firebase for message listening"),[4,this.initializeFirebaseForMessaging()])):[3,11];case 8:i.sent(),i.label=9;case 9:return[4,this.saveState()];case 10:return i.sent(),[2,this.state];case 11:return this.logger.info("Permission granted - initializing Firebase to generate FCM token"),[4,this.initializeFirebase()];case 12:return i.sent(),[4,this.saveState()];case 13:i.sent(),i.label=14;case 14:return this.logger.info(ma,this.state),[2,this.state];case 15:return n=i.sent(),this.logger.error(pa,n),this.state.isNotificationEnabled=!1,[4,this.saveState()];case 16:return i.sent(),[2,this.state];case 17:return[2]}})})},t.prototype.initializeFirebaseForMessaging=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:if(!this.config.messaging)throw new Error("Firebase Messaging instance is required");n.label=1;case 1:return n.trys.push([1,5,,6]),this.firebaseManager=new Bp(this.config.messaging,this.logger,this.config.vapidKey,this.config.serviceWorkerPath,this.config.onTokenReceived,this.config.onMessageReceived),[4,this.firebaseManager.initialize()];case 2:if(!n.sent())throw new Error("Firebase initialization failed");return this.state.firebaseInitialized=!0,[4,this.firebaseManager.ensureServiceWorkerRegistered()];case 3:return n.sent(),[4,this.firebaseManager.setupMessageListener()];case 4:return n.sent(),this.logger.info("Firebase initialized for message listening"),[3,6];case 5:throw t=n.sent(),this.logger.error("Failed to initialize Firebase for messaging",t),t;case 6:return[2]}})})},t.prototype.initializeFirebase=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:if(!this.config.messaging)throw new Error("Firebase Messaging instance is required");i.label=1;case 1:return i.trys.push([1,7,,8]),this.firebaseManager=new Bp(this.config.messaging,this.logger,this.config.vapidKey,this.config.serviceWorkerPath,this.config.onTokenReceived,this.config.onMessageReceived),[4,this.firebaseManager.initialize()];case 2:if(!i.sent())throw new Error("Firebase initialization failed");return this.state.firebaseInitialized=!0,this.state.isNotificationEnabled=!0,[4,this.firebaseManager.requestToken()];case 3:return(t=i.sent())?(this.state.fcmToken=t,[4,this.storeFCMToken(t)]):[3,5];case 4:i.sent(),i.label=5;case 5:return[4,this.firebaseManager.setupMessageListener()];case 6:return i.sent(),this.logger.info("Firebase initialized and FCM token retrieved",{hasToken:!!t}),[3,8];case 7:throw n=i.sent(),this.logger.error("Failed to initialize Firebase",n),this.state.firebaseInitialized=!1,this.state.isNotificationEnabled=!1,n;case 8:return[2]}})})},t.prototype.storeFCMToken=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),n=lu("FCM_TOKEN",this.brandId,this.applicationId),i=lu("FCM_TOKEN_CREATED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(n)];case 1:return r=u.sent(),e=!r||r!==t,[4,this.storageManager.set(n,t)];case 2:return u.sent(),e?(o=(new Date).toISOString(),[4,this.storageManager.set(i,o)]):[3,4];case 3:return u.sent(),this.logger.debug("FCM token and creation date stored successfully",{createdAt:o}),[3,5];case 4:this.logger.debug("FCM token stored (creation date unchanged)"),u.label=5;case 5:return this.tokenUpdateCallback&&(this.logger.info("Notifying token update callback",{isNewToken:e,tokenPreview:t.substring(0,20)+"..."}),this.tokenUpdateCallback(t,e)),[3,7];case 6:return s=u.sent(),this.logger.warn("Failed to store FCM token",s),[3,7];case 7:return[2]}})})},t.prototype.setTokenUpdateCallback=function(t){this.tokenUpdateCallback=t,this.logger.debug("Token update callback registered")},t.prototype.clearTokenUpdateCallback=function(){this.tokenUpdateCallback=null,this.logger.debug("Token update callback cleared")},t.prototype.getState=function(){return Js({},this.state)},t.prototype.getFCMToken=function(){return this.state.fcmToken||null},t.prototype.getTokenCreationDate=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=lu("FCM_TOKEN_CREATED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,i.sent()||null];case 2:return n=i.sent(),this.logger.warn("Failed to retrieve FCM token creation date",n),[2,null];case 3:return[2]}})})},t.prototype.isEnabled=function(){return this.state.isNotificationEnabled},t.prototype.getFirebaseManager=function(){return this.firebaseManager},t.prototype.refreshToken=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:if(!this.firebaseManager||!this.state.isNotificationEnabled)return this.logger.warn("Cannot refresh token - notifications not enabled"),[2,null];i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.firebaseManager.requestToken()];case 2:return(t=i.sent())?(this.state.fcmToken=t,[4,this.storeFCMToken(t)]):[3,5];case 3:return i.sent(),[4,this.saveState()];case 4:i.sent(),this.logger.info(_a,{token:t}),i.label=5;case 5:return[2,t];case 6:return n=i.sent(),this.logger.error("Failed to refresh FCM token",n),[2,null];case 7:return[2]}})})},t.prototype.clearToken=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.logger.info("Clearing notification state (permission revoked)"),t=this.state.fcmToken,this.state.isNotificationEnabled=!1,this.state.firebaseInitialized=!1,this.firebaseManager&&(this.firebaseManager.destroy(),this.firebaseManager=null),[4,this.saveState()];case 1:return i.sent(),this.tokenUpdateCallback&&t&&(this.logger.info("Notifying permission revoked to sync push_opted:false with backend"),this.tokenUpdateCallback(t,!0)),this.logger.info("Notification state cleared"),[3,3];case 2:throw n=i.sent(),this.logger.error("Failed to clear notification state",n),n;case 3:return[2]}})})},t.prototype.hasPermissionChanged=function(){return this.getPermissionStatus()!==this.state.permissionStatus},t.prototype.handlePermissionChange=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return t=this.getPermissionStatus(),n=this.state.permissionStatus,this.logger.info("Permission status changed",{from:n,to:t}),this.state.permissionStatus=t,"denied"!==t&&"default"!==t?[3,5]:"granted"!==n?[3,2]:(this.logger.warn("Permission revoked - clearing FCM token"),[4,this.clearToken()]);case 1:return i.sent(),[3,4];case 2:return this.state.isNotificationEnabled=!1,[4,this.saveState()];case 3:i.sent(),i.label=4;case 4:return[3,10];case 5:return"granted"!==t||"granted"===n?[3,10]:this.config.messaging?[3,6]:(this.logger.warn("Firebase Messaging instance not provided - notifications disabled"),this.state.isNotificationEnabled=!1,[3,8]);case 6:return this.logger.info("Permission granted - initializing Firebase"),[4,this.initializeFirebase()];case 7:i.sent(),i.label=8;case 8:return[4,this.saveState()];case 9:i.sent(),i.label=10;case 10:return[2,this.state]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.firebaseManager&&(this.firebaseManager.destroy(),this.firebaseManager=null),t=lu("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return i.sent(),this.logger.info("NotificationManager destroyed successfully"),[3,3];case 2:return n=i.sent(),this.logger.error("Failed to destroy NotificationManager",n),[3,3];case 3:return[2]}})})},t}(),Hp=function(){function t(t,n,i,r,e){this.currentSession=null,this.sessionNumber=0,this.storageManager=t,this.logger=n,this.brandId=i,this.applicationId=r;var o=fu/6e4;this.inactivityTimeoutMs=60*(e||o)*1e3,this.logger.info("SessionManager configured with timeout:",{timeoutMinutes:e||o,timeoutMs:this.inactivityTimeoutMs,source:e?"Remote Config":"Default"})}return t.prototype.init=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.logger.info("Initializing SessionManager"),[4,this.restoreSessionNumber()];case 1:return t.sent(),[4,this.restoreSession()];case 2:return t.sent(),this.logger.info("SessionManager initialized successfully"),[2]}})})},t.prototype.getOrCreateSession=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return t=Date.now(),this.currentSession?(n=t-this.currentSession.lastEventTime)<this.inactivityTimeoutMs?(this.currentSession.lastEventTime=t,[4,this.persistSession()]):[3,2]:[3,3];case 1:return i.sent(),this.logger.debug(Hu,{sessionId:this.currentSession.sessionId,inactivityDuration:n}),[2,this.currentSession.sessionId];case 2:this.logger.info(Wu,{sessionId:this.currentSession.sessionId,inactivityDuration:n,timeoutMs:this.inactivityTimeoutMs}),i.label=3;case 3:return[2,this.startNewSession()]}})})},t.prototype.getSessionStartTime=function(){var t;return(null===(t=this.currentSession)||void 0===t?void 0:t.sessionStartTime)||null},t.prototype.getCurrentSessionId=function(){var t,n;return null!==(n=null===(t=this.currentSession)||void 0===t?void 0:t.sessionId)&&void 0!==n?n:null},t.prototype.getSessionNumber=function(){return this.sessionNumber},t.prototype.resetSessionNumber=function(){return Qs(this,arguments,void 0,function(t){return void 0===t&&(t=0),Zs(this,function(n){switch(n.label){case 0:return this.sessionNumber=t,[4,this.persistSessionNumber()];case 1:return n.sent(),this.logger.info("Session number reset",{sessionNumber:this.sessionNumber}),[2]}})})},t.prototype.endSession=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return this.currentSession?(this.logger.info(Ku,{sessionId:this.currentSession.sessionId,reason:t}),this.currentSession=null,[4,this.clearSessionStorage()]):[3,3];case 1:return n.sent(),[4,this.resetSessionNumber(0)];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){return this.logger.info("Destroying SessionManager (session persists in storage)"),this.currentSession=null,[2]})})},t.prototype.startNewSession=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return t=Date.now(),n=ym(),this.currentSession={sessionId:n,sessionStartTime:t,lastEventTime:t},this.sessionNumber+=1,[4,this.persistSession()];case 1:return i.sent(),[4,this.persistSessionNumber()];case 2:return i.sent(),this.logger.info(zu,{sessionId:n,sessionStartTime:t,sessionNumber:this.sessionNumber}),[2,n]}})})},t.prototype.restoreSession=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a;return Zs(this,function(c){switch(c.label){case 0:return c.trys.push([0,7,,9]),t=lu("SESSION_ID",this.brandId,this.applicationId),n=lu("SESSION_START_TIME",this.brandId,this.applicationId),i=lu("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return r=c.sent(),[4,this.storageManager.get(n)];case 2:return e=c.sent(),[4,this.storageManager.get(i)];case 3:return o=c.sent(),r&&e&&o?(s=Date.now(),(u=s-parseInt(o))<this.inactivityTimeoutMs?(this.currentSession={sessionId:r,sessionStartTime:parseInt(e),lastEventTime:parseInt(o)},this.logger.info(qu,{sessionId:r,timeSinceLastEvent:u}),[3,6]):[3,4]):[3,6];case 4:return this.logger.debug("Stored session expired, will create new session",{timeSinceLastEvent:u,timeoutMs:this.inactivityTimeoutMs}),[4,this.clearSessionStorage()];case 5:c.sent(),c.label=6;case 6:return[3,9];case 7:return a=c.sent(),this.logger.warn("Failed to restore session from storage",a),[4,this.clearSessionStorage()];case 8:return c.sent(),[3,9];case 9:return[2]}})})},t.prototype.persistSession=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:if(!this.currentSession)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),t=lu("SESSION_ID",this.brandId,this.applicationId),n=lu("SESSION_START_TIME",this.brandId,this.applicationId),i=lu("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,Promise.all([this.storageManager.set(t,this.currentSession.sessionId),this.storageManager.set(n,this.currentSession.sessionStartTime.toString()),this.storageManager.set(i,this.currentSession.lastEventTime.toString())])];case 2:return e.sent(),[3,4];case 3:return r=e.sent(),this.logger.warn("Failed to persist session to storage",r),[3,4];case 4:return[2]}})})},t.prototype.clearSessionStorage=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=lu("SESSION_ID",this.brandId,this.applicationId),n=lu("SESSION_START_TIME",this.brandId,this.applicationId),i=lu("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,Promise.all([this.storageManager.remove(t),this.storageManager.remove(n),this.storageManager.remove(i)])];case 1:return e.sent(),[3,3];case 2:return r=e.sent(),this.logger.warn("Failed to clear session storage",r),[3,3];case 3:return[2]}})})},t.prototype.restoreSessionNumber=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=lu("SESSION_NUMBER",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=r.sent())&&(this.sessionNumber=parseInt(n,10)||0,this.logger.debug("Session number restored",{sessionNumber:this.sessionNumber})),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to restore session number",i),[3,3];case 3:return[2]}})})},t.prototype.persistSessionNumber=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=lu("SESSION_NUMBER",this.brandId,this.applicationId),[4,this.storageManager.set(t,this.sessionNumber.toString())];case 1:return i.sent(),[3,3];case 2:return n=i.sent(),this.logger.warn("Failed to persist session number",n),[3,3];case 3:return[2]}})})},t}(),Wp=function(){function t(t,n){this.firedThresholds=new Set,this.pageStartTime=0,this.currentUrl="",this.scrollHandler=null,this.initialized=!1,this.logger=t,this.onDepthReached=n,this.thresholds=Ra}return t.prototype.init=function(){var t=this;"undefined"!=typeof window&&"undefined"!=typeof document&&(this.initialized||(this.pageStartTime=Date.now(),this.currentUrl=window.location.href,this.scrollHandler=function(){return t.handleScroll()},window.addEventListener("scroll",this.scrollHandler,{passive:!0}),this.checkScrollDepth(),this.initialized=!0,this.logger.debug("ScrollDepthTracker initialized")))},t.prototype.handleScroll=function(){this.checkSPANavigation(),this.checkScrollDepth()},t.prototype.checkSPANavigation=function(){var t=window.location.href;t!==this.currentUrl&&(this.firedThresholds.clear(),this.pageStartTime=Date.now(),this.currentUrl=t,this.logger.debug("ScrollDepthTracker reset for new page",{url:t}))},t.prototype.checkScrollDepth=function(){var t,n,i=window.scrollY,r=document.documentElement.scrollHeight-document.documentElement.clientHeight;if(!(r<=0)){var e=Math.min(100,Math.floor(i/r*100));try{for(var o=tu(this.thresholds),s=o.next();!s.done;s=o.next()){var u=s.value;if(!this.firedThresholds.has(u)&&e>=u){this.firedThresholds.add(u);var a=Math.floor((Date.now()-this.pageStartTime)/1e3);this.logger.debug("Scroll depth threshold reached",{threshold:u,timeToDepth:a,url:this.currentUrl}),this.onDepthReached({depth_percentage:u,url:this.currentUrl,time_to_depth:a})}}}catch(n){t={error:n}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}},t.prototype.destroy=function(){this.scrollHandler&&"undefined"!=typeof window&&window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null,this.firedThresholds.clear(),this.initialized=!1,this.logger.debug("ScrollDepthTracker destroyed")},t}(),Kp=function(){function t(t){this.userContextSet=!1,this.initialized=!1,this.initializationPromise=null,this.visitorTrackingEnabled=!1,this.visitorId=null,this.currentUserIdentifierType=null,this.notificationManager=null,this.permissionChangeCleanup=null,this.dlrMessageCleanup=null,this.lastAuthenticatedUser=null,this.lastUserAttributes=null,this.scrollDepthTracker=null,this.sdkDisabled=!1,this.userIdentified=!1,this.userOperationChain=Promise.resolve(),this.gamificationManager=null,this.gamificationBaseUrl=th,this.config=t,this.logger=new Mp(!1),this.validateRequiredConfig(t),t.remoteConfigKey?(this.logger.info("🔧 SDK initializing in Remote Config bootstrap mode"),this.logger.info("Will fetch configuration from Remote Config key:",t.remoteConfigKey)):this.logger.info("🔧 SDK initializing in direct-config bootstrap mode (no Firebase)")}return t.initialize=function(n){return t._?(new Mp(!0).warn("WebSDK is already initialized. Returning existing instance."),t._):(t._=new t(n),t._.init(),t._)},t.getInstance=function(){return t._},t.isInitialized=function(){return null!==t._},t.requireInstance=function(){if(!t._)throw new Error("WebSDK is not initialized. Call WebSDK.initialize(config) first.");return t._},t.track=function(n,i){t.requireInstance().track(n,i)},t.pageView=function(n){t.requireInstance().pageView(n)},t.identify=function(n){t.requireInstance().identify(n)},t.getUser=function(){return t.requireInstance().getUser()},t.getAnonymousId=function(){return t.requireInstance().getAnonymousId()},t.reset=function(){t.requireInstance().reset()},t.setCapToken=function(n){t.requireInstance().setCapToken(n)},t.getCapToken=function(){return t.requireInstance().getCapToken()},t.enablePagePathTracking=function(n){t.requireInstance().enablePagePathTracking(n)},t.onScreenChanged=function(n){t.requireInstance().onScreenChanged(n)},t.disableSDK=function(){t.requireInstance().disableSDK()},t.enableSDK=function(){t.requireInstance().enableSDK()},t.destroy=function(){if(!t._)return Promise.resolve();var n=t._.destroy();return t._=null,n},t.prototype.shouldEnableLogging=function(t){return!(!t||"NONE"===t)&&["ERROR","WARN","INFO","DEBUG","VERBOSE"].includes(t)},t.prototype.resolveLogLevel=function(t){return{NONE:Ap.NONE,ERROR:Ap.ERROR,WARN:Ap.WARN,INFO:Ap.INFO,DEBUG:Ap.DEBUG,VERBOSE:Ap.VERBOSE}[null!=t?t:"NONE"]},t.prototype.restoreUserContext=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c=this;return Zs(this,function(f){switch(f.label){case 0:return f.trys.push([0,5,,6]),t=lu("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.get(t)];case 1:return(n=f.sent())?(i=JSON.parse(n),r=i.cuid,e=i.userIdentifierType,this.currentUserIdentifierType=null!=e?e:null,o=this.config.accountId||"",[4,this.eventTracker.setUserContext(o,r,e)]):[3,3];case 2:f.sent(),this.userContextSet=!0,this.userIdentified=!0,i.attributes&&(this.lastUserAttributes=i.attributes),this.logger.info("User context restored from storage",{cuid:r,accountId:this.config.accountId}),this.gamificationManager&&this.gamificationManager.initialize(r).catch(function(t){c.logger.error("Failed to restore gamification on page refresh",t)}),f.label=3;case 3:return s=lu("LAST_AUTHENTICATED_USER",this.config.brandId,this.config.applicationId),[4,this.storageManager.get(s)];case 4:return(u=f.sent())&&(this.lastAuthenticatedUser=u,this.logger.info("Last authenticated user restored from storage",{lastAuthenticatedUser:this.lastAuthenticatedUser})),[3,6];case 5:return a=f.sent(),this.logger.warn("Failed to restore user context from storage",a),[3,6];case 6:return[2]}})})},t.prototype.validateAndClearDifferentUserContext=function(t){return Qs(this,void 0,void 0,function(){var n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,5,,7]),this.lastAuthenticatedUser&&this.lastAuthenticatedUser!==t?(this.logger.info("Different user detected, ending session and clearing context",{previousCuid:this.lastAuthenticatedUser,newCuid:t}),[4,this.sessionManager.endSession("user_switch")]):[3,3];case 1:return i.sent(),[4,this.clearUserContext()];case 2:i.sent(),this.userContextSet=!1,i.label=3;case 3:return this.lastAuthenticatedUser=t,[4,this.persistLastAuthenticatedUser(t)];case 4:return i.sent(),[3,7];case 5:return n=i.sent(),this.logger.warn("Error validating different user context",n),[4,this.clearUserContext()];case 6:return i.sent(),this.userContextSet=!1,[3,7];case 7:return[2]}})})},t.prototype.persistLastAuthenticatedUser=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=lu("LAST_AUTHENTICATED_USER",this.config.brandId,this.config.applicationId),[4,this.storageManager.set(n,t)];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),this.logger.warn("Failed to persist lastAuthenticatedUser",i),[3,3];case 3:return[2]}})})},t.prototype.storeUserContext=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),r=null!=n?n:this.currentUserIdentifierType,e={cuid:t,timestamp:Date.now()},r&&(e.userIdentifierType=r),i&&(e.attributes=i),o=lu("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.set(o,JSON.stringify(e))];case 1:return u.sent(),[3,3];case 2:return s=u.sent(),this.logger.warn("Failed to store user context",s),[3,3];case 3:return[2]}})})},t.prototype.init=function(){var t=this;this.initialized?this.logger.warn("WebSDK already initialized"):this.initializationPromise?this.logger.warn("WebSDK initialization already in progress"):(Lm(),this.initializationPromise=this.initializeAsync().catch(function(n){t.logger.error(Iu,n),t.initializationPromise=null}))},t.prototype.tryStep=function(t,n){return Qs(this,void 0,void 0,function(){var i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n()];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),this.logger.error(t,i),[3,3];case 3:return[2]}})})},t.prototype.initializeAsync=function(){return Qs(this,void 0,void 0,function(){var t,n,i=this;return Zs(this,function(r){switch(r.label){case 0:this.logger.info("Initializing WebSDK",{version:za,config:this.config}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.bootstrapConfig()];case 2:return r.sent(),[3,4];case 3:throw t=r.sent(),new Error("".concat(pu,": ").concat(t));case 4:return[4,this.tryStep(Su,function(){return i.storageManager.init()})];case 5:return r.sent(),[4,this.tryStep(Au,function(){var t;return Promise.resolve(null===(t=i.gamificationManager)||void 0===t?void 0:t.restorePersistedPagePathTracking())})];case 6:return r.sent(),[4,this.tryStep(Ou,function(){return i.sessionManager.init()})];case 7:if(r.sent(),!this.config.notifications)return[3,11];r.label=8;case 8:return r.trys.push([8,10,,11]),this.notificationManager=new zp(this.config.notifications,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.setupTokenUpdateCallback(),[4,this.notificationManager.init()];case 9:return r.sent(),this.logger.info("Notifications initialized early for FCM token availability"),[3,11];case 10:return n=r.sent(),this.logger.error(pa,n),this.notificationManager=null,[3,11];case 11:return[4,this.tryStep(Nu,function(){return i.initializeVisitorConfig()})];case 12:return r.sent(),[4,this.tryStep(ku,function(){return Qs(i,void 0,void 0,function(){var t=this;return Zs(this,function(n){switch(n.label){case 0:return[4,this.eventTracker.init()];case 1:return n.sent(),this.eventTracker.setSessionInfoCallback(function(){return Qs(t,void 0,void 0,function(){return Zs(this,function(t){return[2,this.sessionManager.getOrCreateSession()]})})}),[2]}})})})];case 13:return r.sent(),[4,this.tryStep(Du,function(){return i.restoreUserContext()})];case 14:return r.sent(),[4,this.tryStep(Cu,function(){return i.syncEventTrackerContext()})];case 15:return r.sent(),this.initialized=!0,this.notificationManager&&this.setupPermissionChangeDetection(),this.scrollDepthTracker=new Wp(this.logger,function(t){i.pushEvent(xa,i.buildInternalEventAttributes(Js({},t)))}),this.scrollDepthTracker.init(),this.config.notifications?[4,this.tryStep(xu,function(){return Qs(i,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.setupDLRServiceWorkerListener(),[4,this.eventTracker.processPendingServiceWorkerDLREvents()];case 1:return t.sent(),[2]}})})})]:[3,17];case 16:r.sent(),r.label=17;case 17:return this.logger.info(_u),[2]}})})},t.prototype.handleVisibilityChange=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:if("visible"!==document.visibilityState||!this.notificationManager)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),this.notificationManager.hasPermissionChanged()?(t="Notification"in window?Notification.permission:"denied",this.logger.info("Notification permission changed detected",{currentPermission:t}),[4,this.notificationManager.handlePermissionChange()]):[2];case 2:return(n=r.sent())&&this.logger.info("Notification state updated after permission change",n),[3,4];case 3:return i=r.sent(),this.logger.warn("Error handling permission change",i),[3,4];case 4:return[2]}})})},t.prototype.setupPermissionChangeDetection=function(){var t=this;if("undefined"!=typeof document&&"undefined"!=typeof window){var n=function(){return t.handleVisibilityChange()};document.addEventListener("visibilitychange",n),window.addEventListener("focus",n),this.permissionChangeCleanup=function(){document.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)},this.logger.debug("Permission change detection setup complete")}},t.prototype.setupDLRServiceWorkerListener=function(){var t=this;if("undefined"!=typeof navigator&&"serviceWorker"in navigator){var n=function(n){return Qs(t,void 0,void 0,function(){var t;return Zs(this,function(i){switch(i.label){case 0:if(!n.data||"HYDRA_DLR_EVENTS_PENDING"!==n.data.type)return[3,4];this.logger.info("Received DLR events pending notification from service worker"),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.eventTracker.processPendingServiceWorkerDLREvents()];case 2:return i.sent(),[3,4];case 3:return t=i.sent(),this.logger.error("Failed to process pending DLR events",t),[3,4];case 4:return[2]}})})};navigator.serviceWorker.addEventListener("message",n),this.dlrMessageCleanup=function(){navigator.serviceWorker.removeEventListener("message",n)},this.logger.debug("DLR service worker message listener setup complete")}},t.prototype.initializeVisitorConfig=function(){return Qs(this,void 0,void 0,function(){var t,n,i=this;return Zs(this,function(r){switch(r.label){case 0:return this.logger.info("Initializing visitor configuration"),[4,this.visitorConfigManager.init()];case 1:return r.sent(),t=this,[4,this.visitorConfigManager.isVisitorTrackingEnabled()];case 2:return t.visitorTrackingEnabled=r.sent(),this.visitorTrackingEnabled?(this.logger.info(ra),[4,this.anonymousVisitorManager.init()]):[3,5];case 3:return r.sent(),[4,this.getOrCreateVisitorId()];case 4:return r.sent(),this.anonymousVisitorManager.retryPendingMerge().catch(function(t){i.logger.warn("Failed to retry pending merge on init",t)}),[3,6];case 5:this.logger.info(ia),r.label=6;case 6:return(n=this.visitorConfigManager.getCachedConfig())&&n.warnings&&n.warnings.length>0&&n.warnings.forEach(function(t){i.logger.warn("Visitor config warning",{code:t.code,message:t.message})}),[2]}})})},t.prototype.syncEventTrackerContext=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r;return Zs(this,function(e){switch(e.label){case 0:return t=null!==(r=null===(i=this.anonymousVisitorManager)||void 0===i?void 0:i.getVisitorExternalId())&&void 0!==r?r:null,this.eventTracker.setVisitorTrackingState(this.visitorId,this.visitorTrackingEnabled,t),this.visitorTrackingEnabled?(n=this.config.accountId||"",this.userContextSet?[3,2]:[4,this.eventTracker.setUserContext(n)]):(this.logger.warn("Event tracking disabled: Visitor tracking is off"),[2]);case 1:return e.sent(),this.logger.info("Account context set for visitor tracking"),[3,3];case 2:this.logger.info("User context restored from storage"),e.label=3;case 3:return[2]}})})},t.prototype.getOrCreateVisitorId=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c,f;return Zs(this,function(h){switch(h.label){case 0:t=[],(n=null===(a=this.notificationManager)||void 0===a?void 0:a.getFCMToken())?(i="granted"===(null===(c=this.notificationManager)||void 0===c?void 0:c.getState().permissionStatus),t.push({type:this.getChannelType(),value:n,primary:!0,verified:!0,subscribed:i}),this.logger.info("Including FCM token in visitor creation",{tokenPreview:n.substring(0,20)+"...",subscribed:i})):this.logger.info("No FCM token available, creating visitor without commChannels"),h.label=1;case 1:return h.trys.push([1,5,,6]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,3];case 2:return o=h.sent(),[3,4];case 3:o=null,h.label=4;case 4:return e=o,r=Rm(Js(Js({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:"granted"===(null===(f=this.notificationManager)||void 0===f?void 0:f.getState().permissionStatus),fcmTokenCreatedAt:e})),this.logger.debug("Extended fields collected",{extendedFields:r}),[3,6];case 5:return s=h.sent(),this.logger.warn("Failed to collect extended fields, proceeding without them",s),r=void 0,[3,6];case 6:return u=this,[4,this.anonymousVisitorManager.getOrCreateVisitorId(t.length>0?t:void 0,r)];case 7:return u.visitorId=h.sent(),this.logger.info("Visitor ID ready",{visitorId:this.visitorId}),[2,this.visitorId]}})})},t.prototype.setupTokenUpdateCallback=function(){var t=this;this.notificationManager&&(this.notificationManager.setTokenUpdateCallback(function(n,i){return Qs(t,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return[4,this.handleTokenUpdate(n,i)];case 1:return t.sent(),[2]}})})}),this.logger.debug("Token update callback configured for backend sync"))},t.prototype.handleTokenUpdate=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e;return Zs(this,function(o){switch(o.label){case 0:if(!this.visitorId)return this.logger.debug("Skipping token sync - no visitor ID yet (will be included in create)",{isNewToken:n}),[2];if(!n)return this.logger.debug("Skipping token sync - token unchanged"),[2];i="granted"!==(null===(e=this.notificationManager)||void 0===e?void 0:e.getState().permissionStatus),this.logTokenSyncStart(t,i),o.label=1;case 1:return o.trys.push([1,6,,7]),this.userIdentified&&this.lastAuthenticatedUser?[4,this.syncTokenForIdentifiedUser(i)]:[3,3];case 2:return o.sent(),[3,5];case 3:return[4,this.syncTokenForAnonymousUser(t,i)];case 4:o.sent(),o.label=5;case 5:return[3,7];case 6:return r=o.sent(),this.logger.error("Failed to sync FCM token with backend",r),[3,7];case 7:return[2]}})})},t.prototype.logTokenSyncStart=function(t,n){n?this.logger.info("Permission revoked, syncing push_opted:false with backend",{visitorId:this.visitorId}):this.logger.info("FCM token updated, syncing with backend",{visitorId:this.visitorId,tokenPreview:t.substring(0,20)+"..."})},t.prototype.syncTokenForIdentifiedUser=function(t){return Qs(this,void 0,void 0,function(){return Zs(this,function(n){switch(n.label){case 0:return this.lastAuthenticatedUser?[4,this.sendUserEventToApi(Da,this.lastAuthenticatedUser,this.lastUserAttributes)]:[2];case 1:return n.sent(),this.logger.info("Token state synced via User Events API (user_update)",{permissionRevoked:t}),[2]}})})},t.prototype.syncTokenForAnonymousUser=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e,o,s;return Zs(this,function(u){switch(u.label){case 0:i=t?[{type:this.getChannelType(),value:t,primary:!0,verified:!0,subscribed:!n}]:[],u.label=1;case 1:return u.trys.push([1,5,,6]),n||!this.notificationManager?[3,3]:[4,this.notificationManager.getTokenCreationDate()];case 2:return o=u.sent(),[3,4];case 3:o=null,u.label=4;case 4:return e=o,r=Rm(Js(Js({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:!n,fcmTokenCreatedAt:e})),[3,6];case 5:return s=u.sent(),this.logger.warn("Failed to collect extended fields for token update",s),r=void 0,[3,6];case 6:return[4,this.anonymousVisitorManager.updateVisitor(i,r)];case 7:return u.sent(),n?this.logger.info("Token synced with subscribed:false (permission revoked)",{visitorId:this.visitorId}):this.logger.info("FCM token synced with backend successfully",{visitorId:this.visitorId}),[2]}})})},t.prototype.getAnonymousId=function(){return this.visitorId},t.prototype.getUser=function(){var t,n,i,r,e;if(this.userIdentified)throw new Error("This data is not exposed");var o=null!==(n=null===(t=this.sessionManager)||void 0===t?void 0:t.getCurrentSessionId())&&void 0!==n?n:"",s=null!==(r=null===(i=this.sessionManager)||void 0===i?void 0:i.getSessionNumber())&&void 0!==r?r:0;return{visitorId:null!==(e=this.visitorId)&&void 0!==e?e:"",userId:null,sessionId:o,isIdentified:!1,isAnonymous:!0,profileTier:"anonymous",attributes:null,sessionNumber:s,isFirstSession:1===s,isReturningVisitor:s>1}},t.prototype.setUserContext=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e;return Zs(this,function(o){switch(o.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before setting user context");return[4,this.validateAndClearDifferentUserContext(t)];case 1:return o.sent(),i=null!==(e=null!=n?n:this.currentUserIdentifierType)&&void 0!==e?e:void 0,r=this.config.accountId||"",[4,this.eventTracker.setUserContext(r,t,i)];case 2:return o.sent(),this.userContextSet=!0,n&&(this.currentUserIdentifierType=n),this.visitorId&&this.logger.info("User identified - transitioning from anonymous to identified tracking",{visitorId:this.visitorId,cuid:t,trackingMode:"identified"}),[4,this.storeUserContext(t,i)];case 3:return o.sent(),this.logger.info("User context set and persisted",{cuid:t,accountId:this.config.accountId}),[2]}})})},t.prototype.clearUserContext=function(){return Qs(this,void 0,void 0,function(){var t,n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=lu("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.remove(t)];case 1:return i.sent(),this.eventTracker&&this.eventTracker.clearUserContext(),this.currentUserIdentifierType=null,this.userContextSet=!1,this.userIdentified=!1,this.logger.info("User context cleared"),[3,3];case 2:return n=i.sent(),this.logger.warn("Failed to clear user context",n),this.currentUserIdentifierType=null,this.userContextSet=!1,this.userIdentified=!1,[3,3];case 3:return[2]}})})},t.prototype.track=function(t,n){this.sdkDisabled?this.logger.debug("SDK disabled, dropping track call",{eventName:t}):this.pushEvent(t,n)},t.prototype.pageView=function(t){var n,i,r;if(this.sdkDisabled)this.logger.debug("SDK disabled, dropping pageView call");else{var e=null!==(n=null==t?void 0:t.url)&&void 0!==n?n:"undefined"!=typeof window?window.location.href:void 0,o=null!==(i=null==t?void 0:t.title)&&void 0!==i?i:"undefined"!=typeof document?document.title:void 0,s=null!==(r=null==t?void 0:t.referrer)&&void 0!==r?r:"undefined"!=typeof document?document.referrer:void 0,u=Js(Js(Js(Js(Js({},e&&{url:e}),o&&{title:o}),s&&{referrer:s}),(null==t?void 0:t.category)&&{category:t.category}),null==t?void 0:t.properties);this.pushEvent("page_view",u)}},t.prototype.pickTraitFields=function(t){var n={},i=t.gender,r=t.birthday,e=t.city,o=t.country,s=t.timezone;return i&&(n.gender=i),r&&(n.birthday=r),e&&(n.city=e),o&&(n.country=o),s&&(n.timezone=s),n},t.prototype.identify=function(t){var n,i;if(this.sdkDisabled)this.logger.debug("SDK disabled, dropping identify call");else{var r=t.identifier,e=t.actionType,o=t.traits,s=void 0===o?{}:o;if(!r||!r.cuid)throw new Error("identifier with a non-empty cuid is required for identify");if(!["email","mobile","externalId"].includes(r.type))throw new Error("Invalid identifier type: ".concat(r.type,". Must be 'email', 'mobile', or 'externalId'."));var u=r.cuid;this.currentUserIdentifierType=r.type;var a=Js(Js(Js(Js({firstName:null!==(n=s.firstName)&&void 0!==n?n:"",lastName:null!==(i=s.lastName)&&void 0!==i?i:""},"email"===r.type&&{email:u}),"mobile"===r.type&&{mobile:u}),"externalId"===r.type&&{externalId:u}),void 0!==s.custom&&{customData:s.custom}),c=this.pickTraitFields(s);a.customData=Js(Js({},c),a.customData),this.userIdentified=!0;var f=r.type;switch(e){case"USER_REGISTER":this.pushUserSignin(u,a,f);break;case"USER_UPDATE":this.pushUserUpdate(u,a,f);break;default:throw this.logger.error("Invalid identify actionType",{actionType:e,cuid:u}),new Error("Invalid identify actionType: ".concat(e,". Must be 'USER_REGISTER' or 'USER_UPDATE'."))}}},t.prototype.trackEvent=function(t){return Qs(this,void 0,void 0,function(){var n;return Zs(this,function(i){switch(i.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events");i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.eventTracker.track(t)];case 2:return i.sent(),[3,4];case 3:throw n=i.sent(),this.logger.error(Uu,{event:t,error:n}),n;case 4:return[2]}})})},t.prototype.destroy=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:this.logger.info("Destroying WebSDK instance"),n.label=1;case 1:return n.trys.push([1,16,,17]),this.eventTracker?[4,this.eventTracker.flush()]:[3,4];case 2:return n.sent(),[4,this.eventTracker.destroy()];case 3:n.sent(),n.label=4;case 4:return this.scrollDepthTracker&&(this.scrollDepthTracker.destroy(),this.scrollDepthTracker=null),this.visitorConfigManager?[4,this.visitorConfigManager.destroy()]:[3,6];case 5:n.sent(),n.label=6;case 6:return this.anonymousVisitorManager?[4,this.anonymousVisitorManager.destroy()]:[3,8];case 7:n.sent(),n.label=8;case 8:return this.permissionChangeCleanup&&(this.permissionChangeCleanup(),this.permissionChangeCleanup=null),this.dlrMessageCleanup&&(this.dlrMessageCleanup(),this.dlrMessageCleanup=null),this.notificationManager?(this.notificationManager.clearTokenUpdateCallback(),[4,this.notificationManager.destroy()]):[3,10];case 9:n.sent(),this.notificationManager=null,n.label=10;case 10:return this.gamificationManager&&(this.gamificationManager.destroy(),this.gamificationManager=null),this.sessionManager?[4,this.sessionManager.destroy()]:[3,12];case 11:n.sent(),n.label=12;case 12:return this.storageManager?[4,this.clearUserContext()]:[3,15];case 13:return n.sent(),[4,this.storageManager.destroy()];case 14:n.sent(),n.label=15;case 15:return this.initialized=!1,this.logger.info(Tu),[3,17];case 16:throw t=n.sent(),this.logger.error(Tu,t),t;case 17:return[2]}})})},t.prototype.validateUserAttributes=function(t){if(!t.email&&!t.mobile&&!t.externalId)throw new Error("At least one of email, mobile, or externalId is required")},t.prototype.attemptVisitorMerge=function(t){return Qs(this,void 0,void 0,function(){var n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.visitorTrackingEnabled&&this.visitorId?t.email||t.mobile||t.externalId?[4,this.anonymousVisitorManager.mergeVisitorWithUser(t.firstName,t.lastName,t.email,t.mobile,t.externalId,t.customData)]:(this.logger.debug(la,{reason:"No email, mobile, or externalId"}),[2,!1]):[2,!1];case 1:return n=r.sent(),this.logger.info("Visitor merge attempt completed",{visitorId:this.visitorId,success:n}),[2,n];case 2:return i=r.sent(),this.logger.warn("Visitor merge attempt failed, proceeding with user flow",i),[2,!1];case 3:return[2]}})})},t.prototype.buildPushData=function(){var t,n,i,r="granted"===(null===(t=this.notificationManager)||void 0===t?void 0:t.getState().permissionStatus),e=null!==(i=null===(n=this.notificationManager)||void 0===n?void 0:n.getFCMToken())&&void 0!==i?i:null;return{pushOpted:r&&!!e,tokens:e?[{interface_id:e,gateway:La.WEB}]:[]}},t.prototype.buildUserAttributePayload=function(t){if(!t)return{};var n={};return t.firstName&&(n.firstName=t.firstName),t.lastName&&(n.lastName=t.lastName),t.email&&(n.email=t.email),t.mobile&&(n.phone=t.mobile),n},t.prototype.sendUserEventToApi=function(t,n,i,r){return Qs(this,void 0,void 0,function(){var e,o,s,u,a,c,f,h,d,v,l,g;return Zs(this,function(m){switch(m.label){case 0:return e=this.buildPushData(),o=e.pushOpted,s=e.tokens,u=null!==(h=null===(f=this.sessionManager)||void 0===f?void 0:f.getCurrentSessionId())&&void 0!==h?h:"",[4,this.apiClient.buildUserEventsRequest(t,Js(Js(Js({cuid:n,push_opted:o,tokens:s},this.visitorId&&{visitorId:this.visitorId}),this.buildUserAttributePayload(i)),r),u)];case 1:return a=m.sent(),c=null!==(v=null===(d=this.anonymousVisitorManager)||void 0===d?void 0:d.getVisitorExternalId())&&void 0!==v?v:void 0,[4,this.apiClient.sendUserEvents(a,null!==(l=this.visitorId)&&void 0!==l?l:void 0,c,n,null!==(g=this.currentUserIdentifierType)&&void 0!==g?g:void 0)];case 2:return m.sent(),this.logger.info("User event sent to User Events API",{eventName:t,cuid:n}),[2]}})})},t.prototype.pushUserSignin=function(t,n,i){var r=this;this.userIdentified=!0,this.queueUserOperation(function(){return Qs(r,void 0,void 0,function(){var r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.pushUserSigninAsync(t,n,i)];case 1:return e.sent(),[3,3];case 2:return r=e.sent(),this.logger.error(Xu,{cuid:t,error:r}),[3,3];case 3:return[2]}})})})},t.prototype.pushUserSigninAsync=function(t,n,i){return Qs(this,void 0,void 0,function(){var r,e,o,s,u,a,c,f,h;return Zs(this,function(d){switch(d.label){case 0:return[4,this.ensureInitialized()];case 1:return d.sent(),this.validateUserAttributes(n),r=(null!==(f=null===(c=this.sessionManager)||void 0===c?void 0:c.getSessionNumber())&&void 0!==f?f:0)>1,e=r?"returning":"new_session",[4,this.setUserContextIfNeeded(t,i)];case 2:return d.sent(),[4,this.attemptVisitorMerge(n)];case 3:return o=d.sent(),this.lastUserAttributes=n,[4,this.storeUserContext(t,i,n)];case 4:d.sent(),d.label=5;case 5:return d.trys.push([5,7,,8]),[4,this.sendUserEventToApi(ka,t,n,Js(Js({},void 0!==i&&{method:i}),{success:o,login_type:e}))];case 6:return d.sent(),this.logger.info("User signin event tracked",{cuid:t,firstName:n.firstName,lastName:n.lastName,email:n.email}),[3,8];case 7:return s=d.sent(),this.logger.error(Xu,{cuid:t,error:s}),[3,8];case 8:return u=Js(Js(Js({},n.email&&{email:n.email}),n.mobile&&{mobile:n.mobile}),n.customData&&{customAttributes:n.customData}),(a=[n.firstName,n.lastName].filter(Boolean).join(" "))&&Object.assign(u,{name:a}),null===(h=this.gamificationManager)||void 0===h||h.initialize(t,u),[2]}})})},t.prototype.pushUserSignup=function(t,n,i){var r=this;this.userIdentified=!0,this.queueUserOperation(function(){return Qs(r,void 0,void 0,function(){var r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.pushUserSignupAsync(t,n,i)];case 1:return e.sent(),[3,3];case 2:return r=e.sent(),this.logger.error($u,{cuid:t,error:r}),[3,3];case 3:return[2]}})})})},t.prototype.pushUserSignupAsync=function(t,n,i){return Qs(this,void 0,void 0,function(){var r;return Zs(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(n),[4,this.setUserContextIfNeeded(t,i)];case 2:return e.sent(),this.attemptVisitorMerge(n),this.lastUserAttributes=n,[4,this.storeUserContext(t,i,n)];case 3:e.sent(),e.label=4;case 4:return e.trys.push([4,6,,7]),[4,this.sendUserEventToApi(ka,t,n)];case 5:return e.sent(),this.logger.info("User signup event tracked (routed as user_signin)",{cuid:t,firstName:n.firstName,lastName:n.lastName,email:n.email}),[3,7];case 6:throw r=e.sent(),this.logger.error($u,{cuid:t,error:r}),r;case 7:return[2]}})})},t.prototype.pushUserUpdate=function(t,n,i){var r=this;this.queueUserOperation(function(){return Qs(r,void 0,void 0,function(){var r;return Zs(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.pushUserUpdateAsync(t,n,i)];case 1:return e.sent(),[3,3];case 2:return r=e.sent(),this.logger.error(Yu,{cuid:t,error:r}),[3,3];case 3:return[2]}})})})},t.prototype.pushUserUpdateAsync=function(t,n,i){return Qs(this,void 0,void 0,function(){var r;return Zs(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(n),[4,this.setUserContextIfNeeded(t,i)];case 2:return e.sent(),this.lastUserAttributes=n,[4,this.storeUserContext(t,i,n)];case 3:e.sent(),e.label=4;case 4:return e.trys.push([4,6,,7]),[4,this.sendUserEventToApi(Da,t,n)];case 5:return e.sent(),this.logger.info("User update event tracked",{cuid:t}),[3,7];case 6:throw r=e.sent(),this.logger.error(Yu,{cuid:t,error:r}),r;case 7:return[2]}})})},t.prototype.reset=function(){if(this.sdkDisabled)this.logger.debug("SDK disabled, dropping reset call");else{var t=this.lastAuthenticatedUser;t?this.pushUserSignOut(t):this.logger.warn("reset() called but no authenticated user to sign out")}},t.prototype.setCapToken=function(t){var n;null===(n=this.gamificationManager)||void 0===n||n.setCapToken(t)},t.prototype.getCapToken=function(){var t,n;return null!==(n=null===(t=this.gamificationManager)||void 0===t?void 0:t.getCapToken())&&void 0!==n?n:null},t.prototype.enablePagePathTracking=function(t){var n;null===(n=this.gamificationManager)||void 0===n||n.enablePagePathTracking(t)},t.prototype.onScreenChanged=function(t){var n;null===(n=this.gamificationManager)||void 0===n||n.onScreenChanged(t)},t.prototype.pushUserSignOut=function(t){var n=this;this.queueUserOperation(function(){return Qs(n,void 0,void 0,function(){var n;return Zs(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.pushUserSignOutAsync(t)];case 1:return i.sent(),[3,3];case 2:return n=i.sent(),this.logger.error(Ju,{cuid:t,error:n}),[3,3];case 3:return[2]}})})})},t.prototype.resetToAnonymousMode=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c,f,h,d,v;return Zs(this,function(l){switch(l.label){case 0:if(!this.visitorTrackingEnabled)return this.logger.info("Visitor tracking disabled per latest config, skipping anonymous mode"),this.visitorId=null,this.eventTracker.setVisitorTrackingState(null,!1),[2];null===(f=this.gamificationManager)||void 0===f||f.clean(),l.label=1;case 1:return l.trys.push([1,11,,12]),[4,this.anonymousVisitorManager.clearVisitorId()];case 2:l.sent(),this.logger.info("Visitor ID cleared on user signout"),t=[],(n=null===(h=this.notificationManager)||void 0===h?void 0:h.getFCMToken())&&(i="granted"===(null===(d=this.notificationManager)||void 0===d?void 0:d.getState().permissionStatus),t.push({type:this.getChannelType(),value:n,primary:!0,verified:!0,subscribed:i})),r=void 0,l.label=3;case 3:return l.trys.push([3,7,,8]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=null,l.label=6;case 6:return e=o,r=Rm(Js(Js({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:"granted"===(null===(v=this.notificationManager)||void 0===v?void 0:v.getState().permissionStatus),fcmTokenCreatedAt:e})),[3,8];case 7:return s=l.sent(),this.logger.warn("Failed to collect extended fields on signout, proceeding without them",s),r=void 0,[3,8];case 8:return u=this,[4,this.anonymousVisitorManager.getOrCreateVisitorId(t.length>0?t:void 0,r)];case 9:return u.visitorId=l.sent(),[4,this.sessionManager.resetSessionNumber(1)];case 10:return l.sent(),this.logger.info("New anonymous visitor ID generated after signout",{visitorId:this.visitorId,hasFCMToken:!!n}),a=this.anonymousVisitorManager.getVisitorExternalId(),this.eventTracker.setVisitorTrackingState(this.visitorId,!0,a),[3,12];case 11:return c=l.sent(),this.logger.warn("Failed to regenerate visitor ID on signout",c),this.visitorId=null,this.eventTracker.setVisitorTrackingState(null,!0),[3,12];case 12:return[2]}})})},t.prototype.pushUserSignOutAsync=function(t){return Qs(this,void 0,void 0,function(){var n,i,r,e,o,s,u,a,c;return Zs(this,function(f){switch(f.label){case 0:return[4,this.ensureInitialized()];case 1:return f.sent(),[4,this.setUserContextIfNeeded(t)];case 2:f.sent(),f.label=3;case 3:return f.trys.push([3,5,,6]),n=null!==(a=null===(u=this.sessionManager)||void 0===u?void 0:u.getSessionStartTime())&&void 0!==a?a:null,i=null!==n?Math.floor((Date.now()-n)/1e3):void 0,[4,this.sendUserEventToApi(Ca,t,this.lastUserAttributes,Js(Js({},void 0!==i&&{session_duration:i}),{logout_trigger:"user_initiated"}))];case 4:return f.sent(),this.logger.info("User signout event tracked",{cuid:t}),[3,6];case 5:return r=f.sent(),this.logger.warn("Failed to track signout event (tracking may be disabled)",{cuid:t,error:r}),[3,6];case 6:return f.trys.push([6,15,,16]),[4,this.anonymousVisitorManager.clearMergedUserId()];case 7:return f.sent(),[4,this.anonymousVisitorManager.clearPendingMerge()];case 8:return f.sent(),[4,this.clearUserContext()];case 9:f.sent(),this.logger.info("User context cleared, returning to anonymous mode (session continues)"),f.label=10;case 10:return f.trys.push([10,12,,13]),[4,this.visitorConfigManager.refreshConfig()];case 11:return e=f.sent(),this.visitorTrackingEnabled=!0===(null===(c=e.data)||void 0===c?void 0:c.visitorTrackingEnabled),this.logger.info("Visitor config refreshed on signout",{visitorTrackingEnabled:this.visitorTrackingEnabled}),[3,13];case 12:return o=f.sent(),this.logger.warn("Failed to refresh visitor config on signout, using existing value",{visitorTrackingEnabled:this.visitorTrackingEnabled,error:o}),[3,13];case 13:return[4,this.resetToAnonymousMode()];case 14:return f.sent(),this.logger.info("SDK remains active for anonymous tracking"),[3,16];case 15:throw s=f.sent(),this.logger.error("Failed to clear user context on signout",s),s;case 16:return[2]}})})},t.prototype.buildInternalEventAttributes=function(t){return Js(Js(Js({},this.userIdentified&&this.lastAuthenticatedUser&&{cuid:this.lastAuthenticatedUser}),this.visitorId&&{visitorId:this.visitorId}),t)},t.prototype.pushEvent=function(t,n){var i=this;this.pushEventAsync(t,n).catch(function(n){i.logger.error(Qu,{eventName:t,error:n})})},t.prototype.pushEventAsync=function(t,n){return Qs(this,void 0,void 0,function(){var i,r,e;return Zs(this,function(o){switch(o.label){case 0:return[4,this.ensureInitialized()];case 1:if(o.sent(),!this.visitorTrackingEnabled)return this.logger.warn("Event tracking skipped: Visitor tracking is disabled",{eventName:t}),[2];if(!this.userContextSet&&!this.visitorId)return this.logger.warn("Event tracking skipped: No visitor ID available and no user context set",{eventName:t}),[2];i=Js({},null!=n?n:{}),r={type:"behavioral",name:t,timestamp:Date.now(),data:i},o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.trackEvent(r)];case 3:return o.sent(),this.logger.info("Behavioral event tracked",{eventName:t,attributes:n}),[3,5];case 4:throw e=o.sent(),this.logger.error(Qu,{eventName:t,error:e}),e;case 5:return[2]}})})},t.prototype.disableSDK=function(){this.sdkDisabled?this.logger.warn("SDK is already disabled"):(this.sdkDisabled=!0,this.eventTracker&&this.eventTracker.pause(),this.logger.info("SDK disabled — event tracking stopped"))},t.prototype.enableSDK=function(){var t=this;this.sdkDisabled?(this.sdkDisabled=!1,this.eventTracker&&this.eventTracker.resume().catch(function(n){t.logger.error("Failed to resume event tracker",n)}),this.logger.info("SDK enabled — event tracking resumed")):this.logger.warn("SDK is already enabled")},t.prototype.getChannelType=function(){return this.config.channelType||La.WEB},t.prototype.resolveGamificationBaseUrl=function(t){return t.gamificationBaseUrl?t.gamificationBaseUrl:t.gamificationRegion?nh(t.gamificationRegion):th},t.prototype.applyConfigDefaults=function(){this.config.source=this.config.source||Pa.WEBPUSH,this.config.channelType=this.config.channelType||La.WEB;var t=fu/6e4;this.config.sessionTimeoutMinutes=this.config.sessionTimeoutMinutes||t,this.config.batchSize=this.config.batchSize||hu.BATCH_SIZE,this.config.debugLevel=this.config.debugLevel||"NONE",this.gamificationBaseUrl=this.resolveGamificationBaseUrl(this.config),this.logger.setEnabled(this.shouldEnableLogging(this.config.debugLevel)),this.logger.setLevel(this.resolveLogLevel(this.config.debugLevel))},t.prototype.applyRemoteConfigValues=function(t){this.config.accountId=t.accountId,this.config.baseURL=t.baseURL,this.config.orgId=t.orgId,this.config.source=t.source,this.config.channelType=t.channelType,this.config.brandId=this.config.brandId||t.brandId,this.config.applicationId=this.config.applicationId||t.applicationId,this.config.sessionTimeoutMinutes=t.sessionTimeoutMinutes,this.config.batchSize=t.batchSize,this.config.debugLevel=t.debugLevel,this.config.gamificationWriteKey=t.gamificationWriteKey||void 0,this.config.gamificationRegion=t.gamificationRegion||void 0,this.config.gamificationBaseUrl=t.gamificationBaseUrl||void 0,this.applyConfigDefaults(),this.logger.info("Session timeout configured:",{timeoutMinutes:this.config.sessionTimeoutMinutes,source:t.sessionTimeoutMinutes?"Remote Config":"Default"}),this.logger.info("Batch size configured:",{batchSize:this.config.batchSize,source:t.batchSize?"Remote Config":"Default"}),this.logger.info("Debug level configured:",{debugLevel:this.config.debugLevel,source:t.debugLevel?"Remote Config":"Default"})},t.prototype.applyDirectConfigValues=function(){this.applyConfigDefaults(),this.logger.info("✅ SDK configuration applied directly (no Remote Config)"),this.logger.debug("Final SDK config:",this.config)},t.prototype.bootstrapConfig=function(){return Qs(this,void 0,void 0,function(){return Zs(this,function(t){switch(t.label){case 0:return this.config.remoteConfigKey?[4,this.fetchAndApplyRemoteConfig()]:[3,2];case 1:return t.sent(),[3,3];case 2:this.applyDirectConfigValues(),this.initializeManagersFromConfig(),t.label=3;case 3:return[2]}})})},t.prototype.getExtendedFieldsForMerge=function(){return Qs(this,void 0,void 0,function(){var t,n,i;return Zs(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,2];case 1:return n=r.sent(),[3,3];case 2:n=null,r.label=3;case 3:return t=n,[2,Rm(Js(Js({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:"granted"===(null===(i=this.notificationManager)||void 0===i?void 0:i.getState().permissionStatus),fcmTokenCreatedAt:t}))];case 4:return r.sent(),[2,void 0];case 5:return[2]}})})},t.prototype.initializeManagersFromConfig=function(){var t=this;this.storageManager=new Dp(this.logger,this.config.brandId,this.config.applicationId),this.sessionManager=new Hp(this.storageManager,this.logger,this.config.brandId,this.config.applicationId,this.config.sessionTimeoutMinutes),this.apiClient=new yp({baseUrl:this.config.baseURL||""},this.logger,this.config.accountId||"",this.config.orgId||"",this.config.source||Pa.WEBPUSH);var n=this.apiClient;this.eventTracker=new kp(this.config,n,this.storageManager,this.logger);var i=this.config.orgId||"",r=this.config.accountId||"";this.visitorConfigManager=new Up(i,n,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.anonymousVisitorManager=new Lp(r,i,n,this.logger,this.storageManager,Js(Js({},void 0!==this.config.brandId?{brandId:this.config.brandId}:{}),void 0!==this.config.applicationId?{applicationId:this.config.applicationId}:{})),this.anonymousVisitorManager.setMergeDataProviders(function(){var n;return(null===(n=t.notificationManager)||void 0===n?void 0:n.getFCMToken())||null},function(){return t.getChannelType()},function(){return t.getExtendedFieldsForMerge()},function(){var n;return"granted"===(null===(n=t.notificationManager)||void 0===n?void 0:n.getState().permissionStatus)},function(){var n,i;return null!==(i=null===(n=t.sessionManager)||void 0===n?void 0:n.getCurrentSessionId())&&void 0!==i?i:""}),this.config.gamificationWriteKey&&this.gamificationBaseUrl?this.gamificationManager=new wp(this.config.gamificationWriteKey,this.gamificationBaseUrl,this.logger,this.storageManager,function(n,i){return t.pushEvent(n,i)}):this.logger.info(Rf)},t.prototype.fetchAndApplyRemoteConfig=function(){return Qs(this,void 0,void 0,function(){var t,n,i,r,e,o,s,u,a,c,f,h;return Zs(this,function(d){switch(d.label){case 0:this.logger.info("📡 Fetching configuration from Firebase Remote Config..."),d.label=1;case 1:return d.trys.push([1,5,,6]),[4,Gp()];case 2:return t=d.sent(),[4,Vp()];case 3:return n=d.sent(),i=t.initializeApp||t,r=n.getRemoteConfig||n,e=n.fetchAndActivate,o=n.getValue,s=i(this.config.firebaseConfig),(u=r(s)).settings.minimumFetchIntervalMillis=36e5,this.logger.info("🔄 Fetching Remote Config from Firebase..."),[4,e(u)];case 4:if(d.sent()||this.logger.warn("⚠️ Remote Config fetched but not activated (using cached values)"),a=o(u,this.config.remoteConfigKey),!(c=a.asString()))throw new Error('Remote Config key "'.concat(this.config.remoteConfigKey,'" is empty or not found'));f=void 0;try{f=JSON.parse(c)}catch(t){throw new Error("Failed to parse Remote Config JSON: ".concat(t))}return this.logger.info("✅ Remote Config fetched successfully:",f),this.applyRemoteConfigValues(f),this.initializeManagersFromConfig(),this.logger.info("✅ SDK configuration applied from Remote Config"),this.logger.debug("Final SDK config:",this.config),[3,6];case 5:throw h=d.sent(),this.logger.error("❌ Failed to fetch Remote Config:",h),new Error("Remote Config bootstrap failed: ".concat(h));case 6:return[2]}})})},t.prototype.validateRequiredConfig=function(t){var n=[];if(t.remoteConfigKey?t.firebaseConfig||n.push("firebaseConfig"):(t.accountId||n.push("accountId"),t.baseURL||n.push("baseURL"),t.orgId||n.push("orgId")),n.length>0)throw new Error("WebSDK initialization failed: Missing required configuration fields: ".concat(n.join(", "),". ")+'Provide either "remoteConfigKey" + "firebaseConfig" (Remote Config bootstrap) or "accountId" + "baseURL" + "orgId" directly (direct-config bootstrap).')},t.prototype.ensureInitialized=function(){return Qs(this,void 0,void 0,function(){var t;return Zs(this,function(n){switch(n.label){case 0:if(!this.initializationPromise)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.initializationPromise];case 2:return n.sent(),[3,4];case 3:throw t=n.sent(),new Error("SDK initialization failed: ".concat(t));case 4:if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events. Call init() first.");return[2]}})})},t.prototype.setUserContextIfNeeded=function(t,n){return Qs(this,void 0,void 0,function(){return Zs(this,function(i){switch(i.label){case 0:return this.userContextSet?[3,2]:[4,this.setUserContext(t,n)];case 1:i.sent(),this.logger.debug("User context set automatically",{cuid:t}),i.label=2;case 2:return[2]}})})},t.prototype.queueUserOperation=function(t){var n=this;this.userOperationChain=this.userOperationChain.then(t).catch(function(t){n.logger.error("User operation failed",t)})},t._=null,t}();t.HydraSDK=Kp,t.default=Kp,Object.defineProperty(t,"I",{value:!0})});
|
|
1
|
+
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).WebSDK={})}(this,function(t){"use strict";var i="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},n="URLSearchParams"in i,e="Symbol"in i&&"iterator"in Symbol,r="FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch(t){return!1}}(),s="FormData"in i,o="ArrayBuffer"in i;if(o)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var i={next:function(){var i=t.shift();return{done:void 0===i,value:i}}};return e&&(i[Symbol.iterator]=function(){return i}),i}function f(t){this.map={},t instanceof f?t.forEach(function(t,i){this.append(i,t)},this):Array.isArray(t)?t.forEach(function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(i){this.append(i,t[i])},this)}function l(t){if(!t.t)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function v(t){return new Promise(function(i,n){t.onload=function(){i(t.result)},t.onerror=function(){n(t.error)}})}function m(t){var i=new FileReader,n=v(i);return i.readAsArrayBuffer(t),n}function g(t){if(t.slice)return t.slice(0);var i=new Uint8Array(t.byteLength);return i.set(new Uint8Array(t)),i.buffer}function p(){return this.bodyUsed=!1,this.i=function(t){var i;this.bodyUsed=this.bodyUsed,this.o=t,t?"string"==typeof t?this.u=t:r&&Blob.prototype.isPrototypeOf(t)?this.h=t:s&&FormData.prototype.isPrototypeOf(t)?this.l=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this.u=t.toString():o&&r&&((i=t)&&DataView.prototype.isPrototypeOf(i))?(this.v=g(t.buffer),this.o=new Blob([this.v])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this.v=g(t):this.u=t=Object.prototype.toString.call(t):(this.t=!0,this.u=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this.h&&this.h.type?this.headers.set("content-type",this.h.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r&&(this.blob=function(){var t=l(this);if(t)return t;if(this.h)return Promise.resolve(this.h);if(this.v)return Promise.resolve(new Blob([this.v]));if(this.l)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this.u]))}),this.arrayBuffer=function(){if(this.v){var t=l(this);return t||(ArrayBuffer.isView(this.v)?Promise.resolve(this.v.buffer.slice(this.v.byteOffset,this.v.byteOffset+this.v.byteLength)):Promise.resolve(this.v))}if(r)return this.blob().then(m);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,i,n,e,r,s=l(this);if(s)return s;if(this.h)return t=this.h,i=new FileReader,n=v(i),e=/charset=([A-Za-z0-9_-]+)/.exec(t.type),r=e?e[1]:"utf-8",i.readAsText(t,r),n;if(this.v)return Promise.resolve(function(t){for(var i=new Uint8Array(t),n=new Array(i.length),e=0;e<i.length;e++)n[e]=String.fromCharCode(i[e]);return n.join("")}(this.v));if(this.l)throw new Error("could not read FormData body as text");return Promise.resolve(this.u)},s&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,i){t=c(t),i=h(i);var n=this.map[t];this.map[t]=n?n+", "+i:i},f.prototype.delete=function(t){delete this.map[c(t)]},f.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},f.prototype.set=function(t,i){this.map[c(t)]=h(i)},f.prototype.forEach=function(t,i){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(i,this.map[n],n,this)},f.prototype.keys=function(){var t=[];return this.forEach(function(i,n){t.push(n)}),d(t)},f.prototype.values=function(){var t=[];return this.forEach(function(i){t.push(i)}),d(t)},f.prototype.entries=function(){var t=[];return this.forEach(function(i,n){t.push([n,i])}),d(t)},e&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function y(t,n){if(!(this instanceof y))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var e,r,s=(n=n||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,n.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,s||null==t.o||(s=t.o,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=n.credentials||this.credentials||"same-origin",!n.headers&&this.headers||(this.headers=new f(n.headers)),this.method=(e=n.method||this.method||"GET",r=e.toUpperCase(),w.indexOf(r)>-1?r:e),this.mode=n.mode||this.mode||null,this.signal=n.signal||this.signal||function(){if("AbortController"in i)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this.i(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==n.cache&&"no-cache"!==n.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(t){var i=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),e=n.shift().replace(/\+/g," "),r=n.join("=").replace(/\+/g," ");i.append(decodeURIComponent(e),decodeURIComponent(r))}}),i}function _(t,i){if(!(this instanceof _))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(i||(i={}),this.type="default",this.status=void 0===i.status?200:i.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===i.statusText?"":""+i.statusText,this.headers=new f(i.headers),this.url=i.url||"",this.i(t)}y.prototype.clone=function(){return new y(this,{body:this.o})},p.call(y.prototype),p.call(_.prototype),_.prototype.clone=function(){return new _(this.o,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},_.error=function(){var t=new _(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var I=[301,302,303,307,308];_.redirect=function(t,i){if(-1===I.indexOf(i))throw new RangeError("Invalid status code");return new _(null,{status:i,headers:{location:t}})};var b=i.DOMException;try{new b}catch(t){(b=function(t,i){this.message=t,this.name=i;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),b.prototype.constructor=b}function T(t,n){return new Promise(function(e,s){var u=new y(t,n);if(u.signal&&u.signal.aborted)return s(new b("Aborted","AbortError"));var a=new XMLHttpRequest;function d(){a.abort()}if(a.onload=function(){var t,i,n={statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",i=new f,t.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t}).forEach(function(t){var n=t.split(":"),e=n.shift().trim();if(e){var r=n.join(":").trim();try{i.append(e,r)}catch(t){console.warn("Response "+t.message)}}}),i)};0===u.url.indexOf("file://")&&(a.status<200||a.status>599)?n.status=200:n.status=a.status,n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var r="response"in a?a.response:a.responseText;setTimeout(function(){e(new _(r,n))},0)},a.onerror=function(){setTimeout(function(){s(new TypeError("Network request failed"))},0)},a.ontimeout=function(){setTimeout(function(){s(new TypeError("Network request timed out"))},0)},a.onabort=function(){setTimeout(function(){s(new b("Aborted","AbortError"))},0)},a.open(u.method,function(t){try{return""===t&&i.location.href?i.location.href:t}catch(i){return t}}(u.url),!0),"include"===u.credentials?a.withCredentials=!0:"omit"===u.credentials&&(a.withCredentials=!1),"responseType"in a&&(r?a.responseType="blob":o&&(a.responseType="arraybuffer")),n&&"object"==typeof n.headers&&!(n.headers instanceof f||i.Headers&&n.headers instanceof i.Headers)){var l=[];Object.getOwnPropertyNames(n.headers).forEach(function(t){l.push(c(t)),a.setRequestHeader(t,h(n.headers[t]))}),u.headers.forEach(function(t,i){-1===l.indexOf(i)&&a.setRequestHeader(i,t)})}else u.headers.forEach(function(t,i){a.setRequestHeader(i,t)});u.signal&&(u.signal.addEventListener("abort",d),a.onreadystatechange=function(){4===a.readyState&&u.signal.removeEventListener("abort",d)}),a.send(void 0===u.o?null:u.o)})}T.polyfill=!0,i.fetch||(i.fetch=T,i.Headers=f,i.Request=y,i.Response=_);var S,N,D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},k={};function O(){if(N)return S;N=1;var t=function(t){return t&&t.Math===Math&&t};return S=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof D&&D)||t("object"==typeof S&&S)||function(){return this}()||Function("return this")()}var A,C,R,x,P,M,U,L,F={};function G(){return C?A:(C=1,A=function(t){try{return!!t()}catch(t){return!0}})}function V(){if(x)return R;x=1;var t=G();return R=!t(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})}function B(){if(M)return P;M=1;var t=G();return P=!t(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})}function z(){if(L)return U;L=1;var t=B(),i=Function.prototype.call;return U=t?i.bind(i):function(){return i.apply(i,arguments)},U}var j,H,q,K,W,X,Y,Q,J,$,Z,tt,it,nt,et,rt,st,ot,ut,at,ct,ht,dt,ft,lt,vt,mt,gt,pt,wt,yt,Et,_t,It,bt,Tt,St,Nt,Dt,kt,Ot,At={};function Ct(){return q?H:(q=1,H=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}})}function Rt(){if(W)return K;W=1;var t=B(),i=Function.prototype,n=i.call,e=t&&i.bind.bind(n,n);return K=t?e:function(t){return function(){return n.apply(t,arguments)}},K}function xt(){if(J)return Q;J=1;var t=Rt(),i=G(),n=function(){if(Y)return X;Y=1;var t=Rt(),i=t({}.toString),n=t("".slice);return X=function(t){return n(i(t),8,-1)}}(),e=Object,r=t("".split);return Q=i(function(){return!e("z").propertyIsEnumerable(0)})?function(t){return"String"===n(t)?r(t,""):e(t)}:e}function Pt(){return Z?$:(Z=1,$=function(t){return null==t})}function Mt(){if(it)return tt;it=1;var t=Pt(),i=TypeError;return tt=function(n){if(t(n))throw new i("Can't call method on "+n);return n}}function Ut(){if(et)return nt;et=1;var t=xt(),i=Mt();return nt=function(n){return t(i(n))}}function Lt(){if(st)return rt;st=1;var t="object"==typeof document&&document.all;return rt=void 0===t&&void 0!==t?function(i){return"function"==typeof i||i===t}:function(t){return"function"==typeof t}}function Ft(){if(ut)return ot;ut=1;var t=Lt();return ot=function(i){return"object"==typeof i?null!==i:t(i)}}function Gt(){if(ct)return at;ct=1;var t=O(),i=Lt();return at=function(n,e){return arguments.length<2?(r=t[n],i(r)?r:void 0):t[n]&&t[n][e];var r},at}function Vt(){if(mt)return vt;mt=1;var t,i,n=O(),e=function(){if(lt)return ft;lt=1;var t=O().navigator,i=t&&t.userAgent;return ft=i?String(i):""}(),r=n.process,s=n.Deno,o=r&&r.versions||s&&s.version,u=o&&o.v8;return u&&(i=(t=u.split("."))[0]>0&&t[0]<4?1:+(t[0]+t[1])),!i&&e&&(!(t=e.match(/Edge\/(\d+)/))||t[1]>=74)&&(t=e.match(/Chrome\/(\d+)/))&&(i=+t[1]),vt=i}function Bt(){if(pt)return gt;pt=1;var t=Vt(),i=G(),n=O().String;return gt=!!Object.getOwnPropertySymbols&&!i(function(){var i=Symbol("symbol detection");return!n(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&t&&t<41})}function zt(){if(yt)return wt;yt=1;var t=Bt();return wt=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function jt(){if(_t)return Et;_t=1;var t=Gt(),i=Lt(),n=function(){if(dt)return ht;dt=1;var t=Rt();return ht=t({}.isPrototypeOf)}(),e=zt(),r=Object;return Et=e?function(t){return"symbol"==typeof t}:function(e){var s=t("Symbol");return i(s)&&n(s.prototype,r(e))}}function Ht(){if(bt)return It;bt=1;var t=String;return It=function(i){try{return t(i)}catch(t){return"Object"}}}function qt(){if(St)return Tt;St=1;var t=Lt(),i=Ht(),n=TypeError;return Tt=function(e){if(t(e))return e;throw new n(i(e)+" is not a function")}}function Kt(){if(Dt)return Nt;Dt=1;var t=qt(),i=Pt();return Nt=function(n,e){var r=n[e];return i(r)?void 0:t(r)}}function Wt(){if(Ot)return kt;Ot=1;var t=z(),i=Lt(),n=Ft(),e=TypeError;return kt=function(r,s){var o,u;if("string"===s&&i(o=r.toString)&&!n(u=t(o,r)))return u;if(i(o=r.valueOf)&&!n(u=t(o,r)))return u;if("string"!==s&&i(o=r.toString)&&!n(u=t(o,r)))return u;throw new e("Can't convert object to primitive value")}}var Xt,Yt,Qt,Jt,$t,Zt,ti,ii,ni,ei,ri,si,oi,ui,ai,ci,hi,di,fi,li,vi,mi,gi,pi,wi={exports:{}};function yi(){if(Jt)return Qt;Jt=1;var t=O(),i=Object.defineProperty;return Qt=function(n,e){try{i(t,n,{value:e,configurable:!0,writable:!0})}catch(i){t[n]=e}return e}}function Ei(){if($t)return wi.exports;$t=1;var t=Yt?Xt:(Yt=1,Xt=!1),i=O(),n=yi(),e="__core-js_shared__",r=wi.exports=i[e]||n(e,{});return(r.versions||(r.versions=[])).push({version:"3.50.0",mode:t?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"}),wi.exports}function _i(){if(ti)return Zt;ti=1;var t=Ei(),i=Object.create||Object;return Zt=function(n,e){return t[n]||(t[n]=e||i(null))}}function Ii(){if(ni)return ii;ni=1;var t=Mt(),i=Object;return ii=function(n){return i(t(n))}}function bi(){if(ri)return ei;ri=1;var t=Rt(),i=Ii(),n=t({}.hasOwnProperty);return ei=Object.hasOwn||function(t,e){return n(i(t),e)}}function Ti(){if(oi)return si;oi=1;var t=Rt(),i=0,n=Math.random(),e=t(1.1.toString);return si=function(t){return"Symbol("+(void 0===t?"":t)+")_"+e(++i+n,36)}}function Si(){if(ai)return ui;ai=1;var t=O(),i=_i(),n=bi(),e=Ti(),r=Bt(),s=zt(),o=t.Symbol,u=i("wks"),a=s?o.for||o:o&&o.withoutSetter||e;return ui=function(t){return n(u,t)||(u[t]=r&&n(o,t)?o[t]:a("Symbol."+t)),u[t]}}function Ni(){if(hi)return ci;hi=1;var t=z(),i=Ft(),n=jt(),e=Kt(),r=Wt(),s=Si(),o=TypeError,u=s("toPrimitive");return ci=function(s,a){if(!i(s)||n(s))return s;var c,h=e(s,u);if(h){if(void 0===a&&(a="default"),c=t(h,s,a),!i(c)||n(c))return c;throw new o("Can't convert object to primitive value")}return void 0===a&&(a="number"),r(s,a)}}function Di(){if(fi)return di;fi=1;var t=Ni(),i=jt();return di=function(n){var e=t(n,"string");return i(e)?e:e+""}}function ki(){if(vi)return li;vi=1;var t=O(),i=Ft(),n=t.document,e=i(n)&&i(n.createElement);return li=function(t){return e?n.createElement(t):{}}}function Oi(){if(gi)return mi;gi=1;var t=V(),i=G(),n=ki();return mi=!t&&!i(function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a})}function Ai(){if(pi)return F;pi=1;var t=V(),i=z(),n=function(){if(j)return At;j=1;var t={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,n=i&&!t.call({1:2},1);return At.f=n?function(t){var n=i(this,t);return!!n&&n.enumerable}:t,At}(),e=Ct(),r=Ut(),s=Di(),o=bi(),u=Oi(),a=Object.getOwnPropertyDescriptor;return F.f=t?a:function(t,c){if(t=r(t),c=s(c),u)try{return a(t,c)}catch(t){}if(o(t,c))return e(!i(n.f,t,c),t[c])},F}var Ci,Ri,xi,Pi,Mi,Ui,Li,Fi={};function Gi(){if(Ri)return Ci;Ri=1;var t=V(),i=G();return Ci=t&&i(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})}function Vi(){if(Pi)return xi;Pi=1;var t=Ft(),i=String,n=TypeError;return xi=function(e){if(t(e))return e;throw new n(i(e)+" is not an object")}}function Bi(){if(Mi)return Fi;Mi=1;var t=V(),i=Oi(),n=Gi(),e=Vi(),r=Di(),s=TypeError,o=Object.defineProperty,u=Object.getOwnPropertyDescriptor,a="enumerable",c="configurable",h="writable";return Fi.f=t?n?function(t,i,n){if(e(t),i=r(i),e(n),"function"==typeof t&&"prototype"===i&&"value"in n&&h in n&&!n[h]){var s=u(t,i);s&&s[h]&&(t[i]=n.value,n={configurable:c in n?n[c]:s[c],enumerable:a in n?n[a]:s[a],writable:!1})}return o(t,i,n)}:o:function(t,n,u){if(e(t),n=r(n),e(u),i)try{return o(t,n,u)}catch(t){}if("get"in u||"set"in u)throw new s("Accessors not supported");return"value"in u&&(t[n]=u.value),t},Fi}function zi(){if(Li)return Ui;Li=1;var t=V(),i=Bi(),n=Ct();return Ui=t?function(t,e,r){return i.f(t,e,n(1,r))}:function(t,i,n){return t[i]=n,t}}var ji,Hi,qi,Ki,Wi,Xi,Yi,Qi,Ji,$i,Zi,tn,nn,en,rn,sn={exports:{}};function on(){if(Ki)return qi;Ki=1;var t=Rt(),i=Lt(),n=Ei(),e=t(Function.toString);return i(n.inspectSource)||(n.inspectSource=function(t){return e(t)}),qi=n.inspectSource}function un(){if(Qi)return Yi;Qi=1;var t=_i(),i=Ti(),n=t("keys");return Yi=function(t){return n[t]||(n[t]=i(t))}}function an(){return $i?Ji:($i=1,Ji={})}function cn(){if(tn)return Zi;tn=1;var t,i,n,e=function(){if(Xi)return Wi;Xi=1;var t=O(),i=Lt(),n=t.WeakMap;return Wi=i(n)&&/native code/.test(String(n))}(),r=O(),s=Ft(),o=zi(),u=bi(),a=Ei(),c=un(),h=an(),d="Object already initialized",f=r.TypeError,l=r.WeakMap;if(e||a.state){var v=a.state||(a.state=new l);v.get=v.get,v.has=v.has,v.set=v.set,t=function(t,i){if(v.has(t))throw new f(d);return i.facade=t,v.set(t,i),i},i=function(t){return v.get(t)||{}},n=function(t){return v.has(t)}}else{var m=c("state");h[m]=!0,t=function(t,i){if(u(t,m))throw new f(d);return i.facade=t,o(t,m,i),i},i=function(t){return u(t,m)?t[m]:{}},n=function(t){return u(t,m)}}return Zi={set:t,get:i,has:n,enforce:function(e){return n(e)?i(e):t(e,{})},getterFor:function(t){return function(n){var e;if(!s(n)||(e=i(n)).type!==t)throw new f("Incompatible receiver, "+t+" required");return e}}}}function hn(){if(nn)return sn.exports;nn=1;var t=Rt(),i=G(),n=Lt(),e=bi(),r=V(),s=function(){if(Hi)return ji;Hi=1;var t=V(),i=bi(),n=Function.prototype,e=t&&Object.getOwnPropertyDescriptor,r=i(n,"name"),s=r&&"something"===function(){}.name,o=r&&(!t||t&&e(n,"name").configurable);return ji={EXISTS:r,PROPER:s,CONFIGURABLE:o}}().CONFIGURABLE,o=on(),u=cn(),a=u.enforce,c=u.get,h=String,d=Object.defineProperty,f=t("".slice),l=t("".replace),v=t([].join),m=r&&!i(function(){return 8!==d(function(){},"length",{value:8}).length}),g=String(String).split("String"),p=sn.exports=function(t,i,n){"Symbol("===f(h(i),0,7)&&(i="["+l(h(i),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(i="get "+i),n&&n.setter&&(i="set "+i),(!e(t,"name")||s&&t.name!==i)&&(r?d(t,"name",{value:i,configurable:!0}):t.name=i),m&&n&&e(n,"arity")&&t.length!==n.arity&&d(t,"length",{value:n.arity});try{n&&e(n,"constructor")&&n.constructor?r&&d(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var o=a(t);return e(o,"source")||(o.source=v(g,"string"==typeof i?i:"")),t};return Function.prototype.toString=p(function(){return n(this)&&c(this).source||o(this)},"toString"),sn.exports}function dn(){if(rn)return en;rn=1;var t=Lt(),i=Bi(),n=hn(),e=yi();return en=function(r,s,o,u){u||(u={});var a=u.enumerable,c=void 0!==u.name?u.name:s;if(t(o)&&n(o,c,u),u.global)a?r[s]=o:e(s,o);else{try{u.unsafe?r[s]&&(a=!0):delete r[s]}catch(t){}a?r[s]=o:i.f(r,s,{value:o,enumerable:!1,configurable:!u.nonConfigurable,writable:!u.nonWritable})}return r}}var fn,ln,vn,mn,gn,pn,wn,yn,En,_n,In,bn,Tn,Sn,Nn,Dn,kn,On={};function An(){if(mn)return vn;mn=1;var t=function(){if(ln)return fn;ln=1;var t=Math.ceil,i=Math.floor;return fn=Math.trunc||function(n){var e=+n;return(e>0?i:t)(e)}}();return vn=function(i){var n=+i;return n!=n||0===n?0:t(n)}}function Cn(){if(pn)return gn;pn=1;var t=An(),i=Math.max,n=Math.min;return gn=function(e,r){var s=t(e);return s<0?i(s+r,0):n(s,r)}}function Rn(){if(yn)return wn;yn=1;var t=An(),i=Math.min;return wn=function(n){var e=t(n);return e>0?i(e,9007199254740991):0}}function xn(){if(_n)return En;_n=1;var t=Rn();return En=function(i){return t(i.length)}}function Pn(){if(bn)return In;bn=1;var t=Ut(),i=Cn(),n=xn(),e=function(e){return function(r,s,o){var u=t(r),a=n(u);if(0===a)return!e&&-1;var c,h=i(o,a);if(e&&s!=s){for(;a>h;)if((c=u[h++])!=c)return!0}else for(;a>h;h++)if((e||h in u)&&u[h]===s)return e||h||0;return!e&&-1}};return In={includes:e(!0),indexOf:e(!1)}}function Mn(){if(Sn)return Tn;Sn=1;var t=Rt(),i=bi(),n=Ut(),e=Pn().indexOf,r=an(),s=t([].push);return Tn=function(t,o){var u,a=n(t),c=0,h=[];for(u in a)!i(r,u)&&i(a,u)&&s(h,u);for(;o.length>c;)i(a,u=o[c++])&&(~e(h,u)||s(h,u));return h}}function Un(){return Dn?Nn:(Dn=1,Nn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}var Ln,Fn,Gn,Vn,Bn,zn,jn,Hn,qn,Kn={};function Wn(){if(Gn)return Fn;Gn=1;var t=Gt(),i=Rt(),n=function(){if(kn)return On;kn=1;var t=Mn(),i=Un().concat("length","prototype");return On.f=Object.getOwnPropertyNames||function(n){return t(n,i)},On}(),e=(Ln||(Ln=1,Kn.f=Object.getOwnPropertySymbols),Kn),r=Vi(),s=i([].concat);return Fn=t("Reflect","ownKeys")||function(t){var i=n.f(r(t)),o=e.f;return o?s(i,o(t)):i}}function Xn(){if(Bn)return Vn;Bn=1;var t=bi(),i=Wn(),n=Ai(),e=Bi();return Vn=function(r,s,o){for(var u=i(s),a=e.f,c=n.f,h=0;h<u.length;h++){var d=u[h];t(r,d)||o&&t(o,d)||a(r,d,c(s,d))}}}function Yn(){if(qn)return Hn;qn=1;var t=O(),i=Ai().f,n=zi(),e=dn(),r=yi(),s=Xn(),o=function(){if(jn)return zn;jn=1;var t=G(),i=Lt(),n=/#|\.prototype\./,e=function(n,e){var a=s[r(n)];return a===u||a!==o&&(i(e)?t(e):!!e)},r=e.normalize=function(t){return String(t).replace(n,".").toLowerCase()},s=e.data={},o=e.NATIVE="N",u=e.POLYFILL="P";return zn=e}();return Hn=function(u,a){var c,h,d,f,l,v=u.target,m=u.global,g=u.stat;if(c=m?t:g?t[v]||r(v,{}):t[v]&&t[v].prototype)for(h in a){if(f=a[h],d=u.dontCallGetSet?(l=i(c,h))&&l.value:c[h],!o(m?h:v+(g?".":"#")+h,u.forced)&&void 0!==d){if(typeof f==typeof d)continue;s(f,d)}(u.sham||d&&d.sham)&&n(f,"sham",!0),e(c,h,f,u)}}}var Qn,Jn,$n,Zn,te,ie,ne,ee,re,se,oe={};function ue(){if(Jn)return Qn;Jn=1;var t=Mn(),i=Un();return Qn=Object.keys||function(n){return t(n,i)}}function ae(){if(te)return Zn;te=1;var t=Gt();return Zn=t("document","documentElement")}function ce(){if(ne)return ie;ne=1;var t,i=Vi(),n=function(){if($n)return oe;$n=1;var t=V(),i=Gi(),n=Bi(),e=Vi(),r=Ut(),s=ue();return oe.f=t&&!i?Object.defineProperties:function(t,i){e(t);for(var o,u=r(i),a=s(i),c=a.length,h=0;c>h;)n.f(t,o=a[h++],u[o]);return t},oe}(),e=Un(),r=an(),s=ae(),o=ki(),u=un(),a="prototype",c="script",h=u("IE_PROTO"),d=function(){},f=function(t){return"<"+c+">"+t+"</"+c+">"},l=function(t){t.write(f("")),t.close();var i=t.parentWindow.Object;return t=null,i},v=function(){try{t=new ActiveXObject("htmlfile")}catch(t){}var i,n,r;v="undefined"!=typeof document?document.domain&&t?l(t):(n=o("iframe"),r="java"+c+":",n.style.display="none",s.appendChild(n),n.src=String(r),(i=n.contentWindow.document).open(),i.write(f("document.F=Object")),i.close(),i.F):l(t);for(var u=e.length;u--;)delete v[a][e[u]];return v()};return r[h]=!0,ie=Object.create||function(t,e){var r;return null!==t?(d[a]=i(t),r=new d,d[a]=null,r[h]=t):r=v(),void 0===e?r:n.f(r,e)}}function he(){if(re)return ee;re=1;var t=Si(),i=ce(),n=Bi().f,e=t("unscopables"),r=Array.prototype;return void 0===r[e]&&n(r,e,{configurable:!0,value:i(null)}),ee=function(t){r[e][t]=!0}}!function(){if(se)return k;se=1;var t=Yn(),i=Pn().includes,n=G(),e=he(),r=n(function(){return!Array(1).includes()}),s=n(function(){return[,1].includes(void 0,1)});t({target:"Array",proto:!0,forced:r||s},{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e("includes")}();var de=function(t,i){return de=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])},de(t,i)};function fe(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}de(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var le=function(){return le=Object.assign||function(t){for(var i,n=1,e=arguments.length;n<e;n++)for(var r in i=arguments[n])Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r]);return t},le.apply(this,arguments)};function ve(t,i,n,e){return new(n||(n=Promise))(function(r,s){function o(t){try{a(e.next(t))}catch(t){s(t)}}function u(t){try{a(e.throw(t))}catch(t){s(t)}}function a(t){var i;t.done?r(t.value):(i=t.value,i instanceof n?i:new n(function(t){t(i)})).then(o,u)}a((e=e.apply(t,i||[])).next())})}function me(t,i){var n,e,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=u(0),o.throw=u(1),o.return=u(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=i.call(t,s)}catch(t){u=[6,t],e=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function ge(t){var i="function"==typeof Symbol&&Symbol.iterator,n=i&&t[i],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}function pe(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||i-- >0)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function we(t,i,n){if(n||2===arguments.length)for(var e,r=0,s=i.length;r<s;r++)!e&&r in i||(e||(e=Array.prototype.slice.call(i,0,r)),e[r]=i[r]);return t.concat(e||Array.prototype.slice.call(i))}"function"==typeof SuppressedError&&SuppressedError;var ye="/api/v1/web/events",Ee="/api/v1/web/userEvents",_e="/sdk/v2/config",Ie="/sdk/v2/visitors",be="/sdk/v2/visitors",Te="/sdk/v2/visitors/merge",Se="/api/v1/websdk/dlr",Ne=18e5,De={STATUSES:{PENDING:"pending"},BATCH_SIZE:50,DEFAULT_RETRY_DELAYS:[6e4,12e4,24e4,48e4,9e5],RETRYABLE_HTTP_CODES:[408,429,500,502,503,504,401],GLOBAL_SUCCESS_CODE:202,PARTIAL_SUCCESS_CODE:201,DLR_SUCCESS_CODE:200},ke="/firebase-messaging-sw.js",Oe={USER_CONTEXT:"websdk_user_context",VISITOR_ID:"websdk_visitor_id",VISITOR_EXTERNAL_ID:"websdk_visitor_external_id",VISITOR_EXPIRED_AT:"websdk_visitor_expired_at",VISITOR_CONFIG:"websdk_visitor_config",FCM_TOKEN:"websdk_fcm_token",FCM_TOKEN_CREATED_AT:"websdk_fcm_token_created_at",NOTIFICATION_STATE:"websdk_notification_state",SESSION_ID:"websdk_session_id",SESSION_START_TIME:"websdk_session_start_time",LAST_EVENT_TIME:"websdk_last_event_time",LAST_AUTHENTICATED_USER:"websdk_last_authenticated_user",MERGED_USER_ID:"websdk_merged_user_id",PENDING_MERGE:"websdk_pending_merge",SESSION_NUMBER:"websdk_session_number"};function Ae(t,i,n){var e=Oe[t],r=[];return i&&r.push(i),n&&r.push(n),r.length>0?"".concat(r.join("_"),"_").concat(e):e}var Ce="websdk_storage_test",Re="test_value",xe={REQUEST_TIMEOUT_MS:15e3,SENSITIVE_LOG_KEYS:["writeKey","token","accessToken","refreshToken","password"]},Pe="INIT_ERROR",Me="AUTH_ERROR",Ue="NETWORK_ERROR",Le="EVENT_ERROR",Fe="VISITOR_CONFIG_ERROR",Ge="WebSDK initialized successfully",Ve="Failed to initialize WebSDK",Be="WebSDK destroyed successfully",ze="Failed to destroy WebSDK",je="Storage initialization failed",He="Failed to restore persisted page-path-tracking preference",qe="Failed to restore persisted gamification-suppression preference",Ke="Failed to restore persisted gamification theme",We="Session initialization failed",Xe="Visitor config initialization failed",Ye="Event tracker initialization failed",Qe="Failed to restore user context",Je="Failed to sync event tracker context",$e="DLR setup failed",Ze="EventQueue initialized successfully",tr="EventTracker initialized successfully",ir="EventTracker destroyed successfully",nr="Event added to queue",er="Failed to track event",rr="Events sent successfully",sr="Failed to send events",or="User event sent successfully",ur="Failed to send user event",ar="Failed to send batch",cr="Starting queue processing",hr="Queue processing completed",dr="Queue processing failed",fr="Queue processing already in progress, skipping",lr="No pending events to process",vr="No more pending events",mr="Failed to mark event as processing",gr="Failed to remove events from storage",pr="Failed to initialize storage:",wr="Storage test failed:",yr="Storage read/write test failed",Er="StorageManager destroyed successfully",_r="Error during storage cleanup:",Ir="New session started",br="Session continued",Tr="Session expired due to inactivity",Sr="Session ended on user switch (different user login)",Nr="Session ended on signout",Dr="Session restored from storage",kr="Failed to track user signin event",Or="Failed to track user signup event",Ar="Failed to track user update event",Cr="Failed to track user signout event",Rr="Failed to track behavioral event",xr="VisitorConfigManager initialized successfully",Pr="Visitor config fetched successfully",Mr="Failed to fetch visitor config",Ur="Visitor tracking is disabled",Lr="Visitor tracking is enabled",Fr="Visitor config retrieved from cache",Gr="AnonymousVisitorManager initialized successfully",Vr="Visitor ID generated successfully",Br="Failed to generate visitor ID",zr="Visitor ID restored from storage",jr="Using cached visitor ID",Hr="Visitor updated successfully",qr="Failed to update visitor",Kr="Visitor merged with user successfully",Wr="Failed to merge visitor with user",Xr="Visitor merge skipped",Yr="Notification permission denied by user",Qr="Notification manager initialized successfully",Jr="Failed to initialize notification manager",$r="Notification initialization skipped (disabled or not supported)",Zr="Firebase initialized successfully",ts="Failed to initialize Firebase",is="FCM token received successfully",ns="FCM token refreshed",es="Failed to retrieve FCM token",rs="Service worker registered successfully",ss="Failed to register service worker",os="Service worker not supported in this browser",us="FirebaseManager already initialized",as="FirebaseManager not initialized",cs="No service worker found in registration",hs="Service worker registration required for FCM - no token obtained",ds="getToken() returned no token despite notifications being enabled - permission may have been revoked externally, VAPID key may be invalid, or this may be transient",fs="Failed to setup message listener",ls="FCM message payload has neither notification nor data",vs="onMessageReceived callback threw",ms="Notifications not supported in this browser",gs="Firebase Messaging instance not provided - notifications disabled",ps="Failed to restore notification state",ws="Failed to save notification state",ys="Failed to initialize Firebase for messaging",Es="Failed to store FCM token",_s="Failed to retrieve FCM token creation date",Is="Cannot refresh token - notifications not enabled",bs="Failed to refresh FCM token",Ts="Failed to clear notification state",Ss="Permission revoked - clearing FCM token",Ns="Failed to destroy NotificationManager",Ds="DLR events sent successfully",ks="Failed to send DLR events",Os="web",As="user_signin",Cs="user_update",Rs="user_signout",xs="scroll_depth",Ps=[25,50,75,90],Ms=30,Us=3e3,Ls={WEBPUSH:"WEBPUSH"},Fs={WEB:"web"},Gs={ACCOUNT_NOT_EXISTS:2432,ACCOUNT_ID_NOT_PASSED:9999},Vs={ALREADY_MERGED:"1429",VISITOR_NOT_FOUND:"1428"},Bs={NOTIFICATION_RECEIVED:"push_notification_received",NOTIFICATION_CLICKED:"push_notification_click",NOTIFICATION_DISMISSED:"push_notification_close"},zs="fcm",js="push",Hs="1.10.5",qs="GamificationManager initialized successfully",Ks="Failed to initialize GamificationManager",Ws="GamificationManager destroyed successfully",Xs="GamificationManager state cleared",Ys="Gamification disabled — gamificationWriteKey not configured",Qs="GamificationManager refresh triggered",Js="GamificationManager data resync triggered",$s="GamificationManager data resync failed",Zs="GamificationManager loaded from cache — API call skipped",to="GamificationManager cache miss — fetching from API",io="GamificationManager reused cached token — token API call skipped",no="GamificationManager token cache miss — fetching new token",eo="GamificationManager got an auth error on campaigns/entry points — invalidating cached token and retrying once",ro="GamificationManager token refetch is in backoff after repeated failures — skipping network call",so="GamificationManager token refetch failed, entering backoff",oo="GamificationManager failed to handle an ACTION_EVENT trigger",uo="Failed to persist gamification-suppression preference",ao="Content-initiated open skipped — gamification is suppressed",co="Failed to persist gamification theme preference",ho="Failed to read session-dismissal record",fo="Failed to persist session-dismissal record",lo="Failed to persist pending ACTION_EVENT queue",vo="Failed to restore pending ACTION_EVENT queue",mo="Entry point with unresolvable _id present in entryPointMap",go="Failed to construct entry point instance",po="Expected a string field in analytics payload",wo="Failed to persist gamification token cache",yo="Gamification token cache miss: failed to read/parse cached entry",Eo="Gamification cache miss: no cached entry",_o="Gamification cache miss: entry expired",Io="Gamification cache miss: failed to read/parse cached entry",bo="Failed to persist gamification cache",To="Failed to read entry point count state",So="Failed to persist entry point count state",No="Failed to reconcile stale entry point state against refreshed server config",Do="GAME_PLAYED",ko="CAMPAIGN_PLAY",Oo="NO_GAME_CONFIGURED",Ao="game_open",Co="game_viewed",Ro="game_played",xo="game_completed",Po="reward_seen",Mo="content_open",Uo="content_viewed",Lo="LOYALTY",Fo="COMPLETED",Go="ACTION_EVENT",Vo="https://api.customerglu.com",Bo=function(t){return"https://api-".concat(t,".customerglu.com")},zo=3e5,jo=18e5,Ho="__GLU__CACHE__",qo="__GLU__TOKEN__",Ko="__GLU__COUNT_DATE_",Wo="__GLU__QUEUE__",Xo="__GLU__SESSION_DISMISSED_",Yo=16,Qo={LOGGED_IN:"loggedIn"},Jo={EVENT_NAME:"event_name",REWARD_TYPE:"reward_type",CAMPAIGN_ID:"campaign_id",CAMPAIGN_DETAILS:"campaign_details",REWARD_STATUS:"reward_status",REWARD_USER_ID:"reward_user_id"},$o=1e3,Zo=16e3,tu=2e3,iu=3e5,nu="glu_cap_token",eu="glu_page_path_tracking_enabled",ru="glu_gamification_suppressed",su="glu_gamification_theme",ou="/preload/",uu=5e3,au="__GLU__ORIGIN__",cu=new Set(xe.SENSITIVE_LOG_KEYS.map(function(t){return t.toLowerCase()}));function hu(t){return Array.isArray(t)?t.map(hu):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(function(t){var i=pe(t,2),n=i[0],e=i[1];return[n,cu.has(n.toLowerCase())?"[REDACTED]":hu(e)]})):t}var du=function(){function t(t,i){this.baseUrl=t.baseUrl.replace(/\/$/,""),this.logger=i}return t.prototype.request=function(t){return ve(this,arguments,void 0,function(t,i){var n,e,r,s,o,u,a,c,h,d,f,l,v,m,g,p,w;return void 0===i&&(i={}),me(this,function(y){switch(y.label){case 0:n=i.method,e=void 0===n?"GET":n,r=i.headers,s=void 0===r?{}:r,o=i.body,u=!t||t.startsWith("/")?t:"/".concat(t),a="".concat(this.baseUrl).concat(u),c=Date.now(),h=!1,d=hu(o),this.logger.debug("HTTP request started",{method:e,url:a,requestBody:d}),f=new AbortController,l=setTimeout(function(){return f.abort()},xe.REQUEST_TIMEOUT_MS),y.label=1;case 1:return y.trys.push([1,6,7,8]),v={method:e,headers:le({"Content-Type":"application/json"},s),body:o?JSON.stringify(o):null,signal:f.signal},[4,fetch(a,v)];case 2:return(m=y.sent()).ok?[3,4]:[4,m.text()];case 3:throw g=y.sent(),h=!0,this.logger.error("HTTP request failed",{method:e,url:a,status:m.status,durationMs:Date.now()-c,requestBody:d,responseBody:g}),new Error("HTTP ".concat(m.status,": ").concat(m.statusText," - ").concat(g));case 4:return[4,m.json()];case 5:return p=y.sent(),this.logger.debug("HTTP request succeeded",{method:e,url:a,status:m.status,durationMs:Date.now()-c,requestBody:d,responseBody:hu(p)}),[2,p];case 6:throw w=y.sent(),h||this.logger.error("HTTP request failed",{method:e,url:a,durationMs:Date.now()-c,requestBody:d,error:w}),this.handleError(w);case 7:return clearTimeout(l),[7];case 8:return[2]}})})},t.prototype.handleError=function(t){return t instanceof Error?"AbortError"===t.name?{code:Ue,message:"Request timeout",details:t}:t.message.includes("HTTP 401")||t.message.includes("HTTP 403")?{code:Me,message:"Authentication failed",details:t}:(t.message.includes("HTTP"),{code:Ue,message:t.message,details:t}):{code:Ue,message:"Unknown error: ".concat(String(t)),details:t}},t.prototype.get=function(t){return ve(this,arguments,void 0,function(t,i){return void 0===i&&(i={}),me(this,function(n){return[2,this.request(t,le(le({},i),{method:"GET"}))]})})},t.prototype.post=function(t,i){return ve(this,arguments,void 0,function(t,i,n){return void 0===n&&(n={}),me(this,function(e){return[2,this.request(t,le(le({},n),{method:"POST",body:i}))]})})},t.prototype.put=function(t,i){return ve(this,arguments,void 0,function(t,i,n){return void 0===n&&(n={}),me(this,function(e){return[2,this.request(t,le(le({},n),{method:"PUT",body:i}))]})})},t.prototype.delete=function(t){return ve(this,arguments,void 0,function(t,i){return void 0===i&&(i={}),me(this,function(n){return[2,this.request(t,le(le({},i),{method:"DELETE"}))]})})},t}(),fu="/user/v1/user/sdk",lu="/reward/v1.1/user",vu="/entrypoints/v1/list",mu=function(){function t(t,i){this.http=new du({baseUrl:t},i),this.logger=i}return t.prototype.getToken=function(t,i,n,e,r){return ve(this,void 0,void 0,function(){var s,o=this;return me(this,function(u){return s=le(le(le(le(le(le({writeKey:t,userId:i,userState:n,appType:"WEB",sdkVersion:Hs},e&&{anonymousId:e}),(null==r?void 0:r.name)&&{name:r.name}),(null==r?void 0:r.email)&&{email:r.email}),(null==r?void 0:r.mobile)&&{mobile:r.mobile}),(null==r?void 0:r.country)&&{country:r.country}),(null==r?void 0:r.customAttributes)&&{customAttributes:r.customAttributes}),this.logger.info("Fetching gamification token",{userId:i,userState:n}),[2,this.withRetry(function(){return ve(o,void 0,void 0,function(){var t;return me(this,function(e){switch(e.label){case 0:return[4,this.http.post("".concat(fu,"?token=true"),s)];case 1:return t=e.sent(),this.logger.info("Gamification token fetched successfully",{userId:i,userState:n}),[2,t.data.token]}})})},"getToken")]})})},t.prototype.getCampaigns=function(t){return ve(this,void 0,void 0,function(){var i=this;return me(this,function(n){return this.logger.info("Fetching gamification campaigns"),[2,this.withRetry(function(){return ve(i,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return[4,this.http.get(lu,{headers:{Authorization:"Bearer ".concat(t)}})];case 1:return i=e.sent(),n=this.normalizeCampaigns(i),this.logger.info("Gamification campaigns fetched successfully",{campaignCount:n.allIds.length,loyaltyUrlCount:n.loyaltyUrls.length}),[2,n]}})})},"getCampaigns")]})})},t.prototype.getEntryPoints=function(t){return ve(this,void 0,void 0,function(){var i=this;return me(this,function(n){return this.logger.info("Fetching gamification entry points"),[2,this.withRetry(function(){return ve(i,void 0,void 0,function(){var i;return me(this,function(n){switch(n.label){case 0:return[4,this.http.get("".concat(vu,"?consumer=WEB"),{headers:{Authorization:"Bearer ".concat(t)}})];case 1:return i=n.sent(),this.logger.info("Gamification entry points fetched successfully",{entryPointCount:i.data.length}),[2,i.data]}})})},"getEntryPoints")]})})},t.prototype.normalizeCampaigns=function(t){var i,n,e,r=[],s={};0===t.campaigns.length&&this.logger.warn("Campaigns response returned zero campaigns",{defaultUrl:t.defaultUrl});try{for(var o=ge(t.campaigns),u=o.next();!u.done;u=o.next()){var a=u.value;r.push(a.campaignId),s[a.campaignId]=a}}catch(t){i={error:t}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return{allIds:r,byId:s,defaultUrl:t.defaultUrl,base:this.extractBase(t.defaultUrl),loyaltyUrls:null!==(e=t.loyaltyUrls)&&void 0!==e?e:[]}},t.prototype.extractBase=function(t){try{var i=new URL(t);return"".concat(i.protocol,"//").concat(i.host)}catch(i){return this.logger.error("Failed to parse defaultUrl from campaigns response",{url:t,error:i}),""}},t.prototype.isAuthError=function(t){return"object"==typeof t&&null!==t&&t.code===Me},t.prototype.withRetry=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:e=function(e){var s,o,u;return me(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,5]),s={},[4,t()];case 1:return[2,(s.value=a.sent(),s)];case 2:if(o=a.sent(),n=o,r.logger.error("GamificationManager API call failed: ".concat(i),{attempt:e,maxRetries:5,error:o}),r.isAuthError(o))throw o;return e<5?(u=Math.min($o*Math.pow(2,e-1),Zo),[4,new Promise(function(t){return setTimeout(t,u)})]):[3,4];case 3:a.sent(),a.label=4;case 4:return[3,5];case 5:return[2]}})},r=this,s=1,u.label=1;case 1:return s<=5?[5,e(s)]:[3,4];case 2:if("object"==typeof(o=u.sent()))return[2,o.value];u.label=3;case 3:return s++,[3,1];case 4:throw n}})})},t}(),gu={EMBEDDED:"EMBED",POP_UP:"POP_UP",BOTTOM_SHEET:"BOTTOM_SHEET",ICON_BUTTON:"FLOATING",CHAT_BOX:"CHAT_BOX",NATIVE_BANNER:"BANNER"};function pu(t){var i,n=(i=t.container.typeId,gu[i]);return"EMBED"===n&&"STATIC"===t.content.typeId?"BANNER":n}function wu(t){return"CAMPAIGN"===t.typeId||"NUDGE"===t.typeId&&!!t.campaignId}function yu(t){return"NATIVE_BANNER"===t.container.typeId||"EMBEDDED"===t.container.typeId?"content":wu(t.content)?"game":"ICON_BUTTON"===t.container.typeId?"content":null}function Eu(t){return"NATIVE_BANNER"===t.container.typeId||"EMBEDDED"===t.container.typeId}function _u(t){return t.toFixed(2)}function Iu(t){var i,n;return null!==(n=null!==(i=null==t?void 0:t.data)&&void 0!==i?i:t)&&void 0!==n?n:{}}function bu(t){var i=null==t?void 0:t.campaignId;if("string"==typeof i)return i;if(Array.isArray(i)){var n=i[0];if("string"==typeof n)return n}return null}function Tu(t){return t.triggerType===Go}var Su=new Set(["EMBEDDED","NATIVE_BANNER"]);function Nu(t){var i;if(!Tu(t))return null;if(Su.has(t.container.typeId))return null;var n=null===(i=t.actionEventConfig)||void 0===i?void 0:i.eventName;return"string"==typeof n&&""!==n.trim()?n:null}var Du=new Set(["POP_UP","BOTTOM_SHEET","CHAT_BOX"]);function ku(t){return Du.has(t.container.typeId)}var Ou=new Set(["http:","https:"]);function Au(t){if(!t||"undefined"==typeof window)return!1;try{return Ou.has(new URL(t,window.location.href).protocol)}catch(t){return!1}}function Cu(t){var i,n,e=t.content;if("CAMPAIGN"===e.typeId)return null!==(i=e.campaignId)&&void 0!==i?i:bu(e.conditions);if("NUDGE"===e.typeId||"PROGRAM"===e.typeId)return null!==(n=e.campaignId)&&void 0!==n?n:null;if("STATIC"===e.typeId&&e.action){var r=e.action;if("TOGGLE_CONTAINER_CONTENT"===r.type||"OPEN_CONTAINER_CONTENT"===r.type)return bu(r.content.conditions)}return null}var Ru={LAUNCHER_ICON:"ICON_BUTTON",BOTTOM_SHEET:"BOTTOM_SHEET",POP_UP:"POP_UP",EMBEDDED:"EMBEDDED",CHAT_BOX:"CHAT_BOX",NATIVE_BANNER:"NATIVE_BANNER"};function xu(t){var i,n;if("string"==typeof t.m&&t.m.length>0)return t.m;try{for(var e=ge(Object.entries(t)),r=e.next();!r.done;r=e.next()){var s=pe(r.value,2),o=s[0],u=s[1];if("_id"===o&&"string"==typeof u&&u.length>0)return u}}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=e.return)&&n.call(e)}finally{if(i)throw i.error}}}function Pu(t,i){var n;return le(le(le(le(le(le(le(le(le(le({typeId:null!==(n=null==t?void 0:t.typeId)&&void 0!==n?n:""},void 0!==i&&{campaignId:i}),void 0!==(null==t?void 0:t.src)&&{src:t.src}),void 0!==(null==t?void 0:t.state)&&{state:t.state}),void 0!==(null==t?void 0:t.action)&&{action:t.action}),void 0!==(null==t?void 0:t.conditions)&&{conditions:t.conditions}),void 0!==(null==t?void 0:t.IWidgetState)&&{IWidgetState:t.IWidgetState}),void 0!==(null==t?void 0:t.widgetCss)&&{widgetCss:t.widgetCss}),void 0!==(null==t?void 0:t.progressBarIcon)&&{progressBarIcon:t.progressBarIcon}),void 0!==(null==t?void 0:t.progressMeterIcon)&&{progressMeterIcon:t.progressMeterIcon}),void 0!==(null==t?void 0:t.rootId)&&{rootId:t.rootId})}function Mu(t){var i,n,e,r,s=t.web,o=s.container,u=s.content,a=s.conditions,c=u[0],h=null==a?void 0:a.backgroundOpacity,d=null!=h?o.css.replace("{{backgroundOpacity}}",String(h)):o.css,f=null!==(n=null!==(i=null==c?void 0:c.campaignId)&&void 0!==i?i:bu(null==c?void 0:c.conditions))&&void 0!==n?n:void 0;return le(le(le(le(le(le({id:null!==(e=xu(t))&&void 0!==e?e:""},void 0!==t.name&&{name:t.name}),{container:{typeId:null!==(r=Ru[o.typeId])&&void 0!==r?r:o.typeId,css:d,height:o.height,elementHookId:o.elementId},content:Pu(c,f)}),void 0!==a&&{conditions:a}),void 0!==t.triggerType&&{triggerType:t.triggerType}),void 0!==t.actionEventConfig&&{actionEventConfig:t.actionEventConfig}),void 0!==t.createdAt&&{createdAt:t.createdAt})}function Uu(t){var i,n,e=[],r={};try{for(var s=ge(t),o=s.next();!o.done;o=s.next()){var u=Mu(o.value);e.push(u.id),r[u.id]=u}}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return{allIds:e,byId:r}}var Lu="/*";function Fu(t){return t.startsWith("#/")||t.startsWith("#!/")}function Gu(t){try{return decodeURIComponent(t)}catch(i){return t}}function Vu(t){return t.replace(/(?:^\/+)|(?:\/+$)/g,"").split("/").filter(Boolean).map(Gu)}function Bu(t){try{return new URL(t)}catch(t){return null}}function zu(t,i,n){for(var e=0;e<i.length;e++)if(t[n+e]!==i[e])return!1;return!0}function ju(t,i){if(i.length>t.length)return-1;for(var n=0;n<=t.length-i.length;n++)if(zu(t,i,n))return n;return-1}function Hu(t,i){var n=i.endsWith(Lu),e=n?i.slice(0,-2):i;if(""===e)return!1;if("/"===e)return!n&&0===t.length;var r=Vu(e),s=ju(t,r);return-1!==s&&(!n||s+r.length<t.length)}function qu(t,i){var n=function(t){var i=t.trim();if("*"===i||i===Lu)return"*";if(""===i)return"";var n=i.replace(/(?:^\/+)|(?:\/+$)/g,"");return""===n?"/":n}(i);if("*"===n)return!0;var e=t.indexOf("#"),r=-1===e?t:t.slice(0,e),s=-1===e?"":t.slice(e),o=r.replace(/\?.*$/,""),u=function(t){if(!t.startsWith("/"))return null;var i=t.lastIndexOf("/");if(i<=1)return null;var n=t.slice(1,i),e=t.slice(i+1);if(!/[*+?^${}()|[\]\\]/.test(n))return null;try{return new RegExp(n,e)}catch(t){return null}}(i.trim());if(u){var a=Fu(s)?o+s:o;return u.test(a)}var c=function(t,i){if(!/^https?:\/\//i.test(t))return null;var n=Bu(i);if(!n)return!1;var e=t.endsWith(Lu),r=Bu(e?t.slice(0,-2):t);if(!r)return!1;if(n.origin!==r.origin)return!1;if(!e)return n.pathname.replace(/\/+$/,"")===r.pathname.replace(/\/+$/,"");var s=Vu(n.pathname),o=Vu(r.pathname),u=ju(s,o);return 0===u&&u+o.length<s.length}(n,o);if(null!==c)return c;var h=Bu(t);return!!Hu(Vu(h?h.pathname:o),n)||!!Fu(s)&&Hu(Vu(s.replace(/^#!?\//,"").replace(/\?.*$/,"")),n)}function Ku(t,i){var n,e;try{for(var r=ge(i),s=r.next();!s.done;s=r.next()){if(qu(t,s.value))return!0}}catch(t){n={error:t}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(n)throw n.error}}return!1}function Wu(t,i){return"".concat(Ko).concat(null!=i?i:"anonymous","_").concat(t)}function Xu(t,i,n,e){return ve(this,void 0,void 0,function(){var r,s,o;return me(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),[4,n.get(Wu(t,i))];case 1:return(r=u.sent())?(s=JSON.parse(r),[2,(a=s,"object"==typeof a&&null!==a&&"number"==typeof a.count&&"string"==typeof a.date?s:null)]):[2,null];case 2:return o=u.sent(),e.error(To,{entryPointId:t,error:o}),[2,null];case 3:return[2]}var a})})}function Yu(t,i){return t.getFullYear()===i.getFullYear()&&t.getMonth()===i.getMonth()&&t.getDate()===i.getDate()}function Qu(t,i){var n,e;if(!t)return!0;var r=null!==(n=t.excludePaths)&&void 0!==n?n:[],s=null!==(e=t.includePaths)&&void 0!==e?e:[];return(!r.length||!Ku(i,r))&&!(s.length&&!Ku(i,s))}function Ju(t,i,n,e,r){return!n||!Yu(e,new Date(n.date))||(!(n.count>=i)||(r.info("Rule engine: daily refresh cap exhausted",{entryPointId:t,count:n.count,cap:i}),!1))}function $u(t,i,n,e){return!(n&&n.count>=i)||(e.info("Rule engine: lifetime cap exhausted",{entryPointId:t,count:n.count,cap:i}),!1)}function Zu(t,i,n,e,r){return ve(this,void 0,void 0,function(){var s,o,u,a,c,h,d,f,l,v,m;return me(this,function(g){switch(g.label){case 0:return null===(s=t.conditions)?(e.info("Rule engine: conditions explicitly null - never show",{entryPointId:t.id}),[2,!1]):s?(o=s.paths,u=s.showCount,a=s.timeWindow,c=s.isLoggedIn,h=s.backendValidations,d=new Date,f=null!=r?r:"undefined"!=typeof window?window.location.href:"",c&&!i?(e.info("Rule engine: requires login, no userId",{entryPointId:t.id}),[2,!1]):function(t,i){if(!t)return!0;var n=i.valueOf();return n>=new Date(t.start).valueOf()&&n<=new Date(t.end).valueOf()}(a,d)?Tu(t)||Qu(o,f)?"INVALID"===h?(e.info("Rule engine: backend validation invalid",{entryPointId:t.id}),[2,!1]):Tu(t)?(e.info("Rule engine: frequency cap skipped for ACTION_EVENT entry",{entryPointId:t.id}),[2,!0]):u?(l=u.count,v=u.dailyRefresh,[4,Xu(t.id,i,n,e)]):(e.info("Rule engine: no frequency cap configured - show",{entryPointId:t.id}),[2,!0]):(e.info("Rule engine: path not allowed",{entryPointId:t.id,currentHref:f,paths:o}),[2,!1]):(e.info("Rule engine: outside time window",{entryPointId:t.id,timeWindow:a}),[2,!1])):(e.info("Rule engine: no conditions - always show",{entryPointId:t.id}),[2,!0]);case 1:return m=g.sent(),[2,v?Ju(t.id,l,m,d,e):$u(t.id,l,m,e)]}})})}var ta=function(){function t(){this.queue=[]}return t.prototype.enqueue=function(t){var i,n,e=function(t){var i=r.queue.findIndex(function(i){return i.id===t.id});-1===i?r.queue.push(t):r.queue[i]=t},r=this;try{for(var s=ge(t),o=s.next();!o.done;o=s.next()){e(o.value)}}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}this.queue.sort(function(t,i){var n,e,r,s,o,u,a=(null!==(e=null===(n=i.conditions)||void 0===n?void 0:n.priority)&&void 0!==e?e:0)-(null!==(s=null===(r=t.conditions)||void 0===r?void 0:r.priority)&&void 0!==s?s:0);return 0!==a?a:(null!==(o=i.createdAt)&&void 0!==o?o:"").localeCompare(null!==(u=t.createdAt)&&void 0!==u?u:"")})},t.prototype.peek=function(){return this.queue[0]},t.prototype.dequeue=function(){return this.queue.shift()},t.prototype.remove=function(t){this.queue=this.queue.filter(function(i){return i.id!==t})},t.prototype.hasNext=function(){return this.queue.length>0},t.prototype.clear=function(){this.queue=[]},t.prototype.clearScreenTriggered=function(){this.queue=this.queue.filter(function(t){return Tu(t)})},t.prototype.size=function(){return this.queue.length},t.prototype.entries=function(){return this.queue},t}(),ia={iframe:{className:"__GLU__IFRAME",css:".__GLU__IFRAME{ height: 100%; width: 100%; border: none !important; outline: none; }"},hideScroll:{className:"__GLU_HIDE_SCROLL",css:".__GLU_HIDE_SCROLL::-moz-focus-inner {border: 0;} .__GLU_HIDE_SCROLL::-webkit-scrollbar {width: 0px !important;background: transparent !important;display: none !important;} .__GLU_HIDE_SCROLL {scrollbar-width: none !important;-ms-overflow-style: -ms-autohiding-scrollbar !important;}"},slideUp:{className:"__GLU__SLIDE_UP",css:".__GLU__SLIDE_UP { animation: GLU_SLIDE_UP 300ms ease-out; } @keyframes GLU_SLIDE_UP { from { opacity: 0; transform: translateY(100px); }to { opacity: 1; transform: translateY(0px); }}"},slideDown:{className:"__GLU__SLIDE_DOWN",css:".__GLU__SLIDE_DOWN { animation: GLU_SLIDE_DOWN 300ms ease-out; } @keyframes GLU_SLIDE_DOWN { from { opacity: 1; transform: translateY(0px); }to { opacity: 0; transform: translateY(100px); }}"},slideUpSheet:{className:"__GLU__SLIDE_UP_SHEET",css:".__GLU__SLIDE_UP_SHEET { animation: GLU_SLIDE_UP_SHEET 300ms ease-out; } @keyframes GLU_SLIDE_UP_SHEET { from { transform: translateY(100%); } to { transform: translateY(0px); }}"},slideDownSheet:{className:"__GLU__SLIDE_DOWN_SHEET",css:".__GLU__SLIDE_DOWN_SHEET { animation: GLU_SLIDE_DOWN_SHEET 300ms ease-out forwards; } @keyframes GLU_SLIDE_DOWN_SHEET { from { transform: translateY(0px); } to { transform: translateY(100%); }}"},iconButton:{className:"__GLU__ICON_BUTTON",css:".__GLU__ICON_BUTTON { position: fixed; bottom: 40px; left: 40px; height: 160px; width: 160px; overflow: hidden; z-index: 999;}"},chatBox:{className:"__GLU__CHAT_BOX",css:function(t){return".__GLU__CHAT_BOX { position: fixed; bottom: 130px; left: 40px; height: 580px; max-height: 580px; width: 360px; background-color: ".concat(t," !important; border-radius: 24px; overflow-x: hidden; z-index: 9999; }")}},popUp:{className:"__GLU__POP_UP",css:function(t){return".__GLU__POP_UP { position: relative; max-height: 740px; max-width: 1000px; width: 100%; height:90%; background-color: ".concat(t," !important; border-radius: 12px; z-index: 999999; overflow: hidden;}")}},popUpStatic:{className:"__GLU__POP_UP_STATIC",css:function(t){return".__GLU__POP_UP_STATIC { position: relative; max-height: 100%; max-width: 100%; background-color: ".concat(t," !important; border-radius: 12px; z-index: 999999; overflow: hidden;}")}},backDrop:{className:"__GLU__BACK_DROP",css:".__GLU__BACK_DROP { position: fixed; bottom: 0px; left: 0px; height: 100%; width: 100vw; background-color: rgba(0,0,0,0.2); display: flex; justify-content: center; align-items: center; z-index: 99999;}"},bottomSheet:{className:"__GLU__BOTTOM_SHEET",css:function(t){return".__GLU__BOTTOM_SHEET { position: relative; height: 880px; width: 600px; max-width: 100%; max-height: 100%; background-color: ".concat(t," !important; border-radius: 20px 20px 0px 0px; overflow-x: hidden; z-index: 999999; align-self: flex-end}")}},bottomSheetStatic:{className:"__GLU__BOTTOM_SHEET_STATIC",css:function(t){return".__GLU__BOTTOM_SHEET_STATIC { position: relative; max-width: 100%; max-height: 100%; background-color: ".concat(t," !important; border-radius: 20px 20px 0px 0px; overflow-x: hidden; z-index: 999999; align-self: flex-end}")}},embeddedStatic:{className:"__GLU__EMBEDDED_STATIC",css:".__GLU__EMBEDDED_STATIC { width: 100%; overflow-x: hidden; }"},embedded:{className:"__GLU__EMBEDDED",css:".__GLU__EMBEDDED { width: 100%; height: 100%; overflow-x: hidden; }"},loader:{className:"__GLU__LOADER",css:'.__GLU__LOADER { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 5; } .__GLU__LOADER::after { content: ""; width: 32px; height: 32px; border-radius: 50%; border: 3px solid rgba(0,0,0,0.15); border-top-color: rgba(0,0,0,0.55); animation: GLU_SPIN 800ms linear infinite; } @keyframes GLU_SPIN { to { transform: rotate(360deg); } }'},closeIcon:{className:"__GLU__CLOSE_ICON",css:".__GLU__CLOSE_ICON { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; padding: 0; border: none; border-radius: 50%; background-color: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; }"}};function na(t){var i=t?"#1E1E1E":"#fff";return Object.values(ia).map(function(t){return"function"==typeof t.css?t.css(i):t.css}).join("")}function ea(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();var t="undefined"!=typeof crypto?crypto:null;if(null==t?void 0:t.getRandomValues){var i=new Uint8Array(16);t.getRandomValues(i);var n=new DataView(i.buffer);return n.setUint8(6,15&n.getUint8(6)|64),n.setUint8(8,63&n.getUint8(8)|128),Array.from(i).map(function(t,i){return[4,6,8,10].includes(i)?"-".concat(t.toString(16).padStart(2,"0")):t.toString(16).padStart(2,"0")}).join("")}throw new Error("No cryptographically secure random number generator available")}function ra(t,i){var n;if("undefined"!=typeof URLSearchParams)return new URLSearchParams(t).get(i);var e=new RegExp("[?&]"+i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"=([^&#]*)"),r=t.match(e);return r?decodeURIComponent(null!==(n=r[1])&&void 0!==n?n:""):null}function sa(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return"UTC"}}function oa(t,i){var n,e={campaignName:ra(n=window.location.search,"utm_campaign")||"",campaignSource:ra(n,"utm_source")||"",campaignMedium:ra(n,"utm_medium")||""};return{libraryName:"cap-hydra-web-sdk",libraryVersion:Hs,locale:navigator.language||navigator.languages&&navigator.languages[0]||"en-US",userAgent:navigator.userAgent||"",timezone:sa(),ip:"",campaignName:e.campaignName,campaignSource:e.campaignSource,campaignMedium:e.campaignMedium,pageUrl:window.location.href||"",pagePath:window.location.pathname||"",pageReferrer:document.referrer||"",pageTitle:document.title||"",sessionId:t,lat:i?String(i.latitude):"",long:i?String(i.longitude):""}}function ua(){try{var t=function(){var t,i;if("undefined"!=typeof navigator&&"userAgentData"in navigator){var n=navigator.userAgentData;if(n&&n.brands)try{for(var e=ge(n.brands),r=e.next();!r.done;r=e.next()){var s=r.value;if(s.brand&&"Chromium"!==s.brand&&!s.brand.startsWith("Not"))return s.brand}}catch(i){t={error:i}}finally{try{r&&!r.done&&(i=e.return)&&i.call(e)}finally{if(t)throw t.error}}}return null}();return t||("undefined"!=typeof navigator&&navigator.userAgent?(i=navigator.userAgent).includes("Firefox/")?"Firefox":i.includes("Edg/")?"Edge":i.includes("Chrome/")?"Chrome":i.includes("Safari/")&&!i.includes("Chrome")?"Safari":i.includes("Opera/")||i.includes("OPR/")?"Opera":null:null)}catch(t){return null}var i}function aa(){try{var t=function(){if("undefined"!=typeof navigator&&"userAgentData"in navigator){var t=navigator.userAgentData;if(t&&t.platform)return t.platform}return null}();return t||("undefined"!=typeof navigator&&navigator.userAgent?(i=navigator.userAgent,null!==(e=null!==(n=function(t){if(!t.includes("Mac OS X"))return null;var i=t.match(/Mac OS X ([\d_]+)/);return(null==i?void 0:i[1])?"macOS ".concat(i[1].replace(/_/g,".")):"macOS"}(i))&&void 0!==n?n:function(t){var i;if(!t.includes("Windows NT"))return null;var n=t.match(/Windows NT ([\d.]+)/);return(null==n?void 0:n[1])?"Windows ".concat(null!==(i={"10.0":"10/11",6.3:"8.1",6.2:"8",6.1:"7"}[n[1]])&&void 0!==i?i:n[1]):"Windows"}(i))&&void 0!==e?e:function(t){var i;return t.includes("iPhone")||t.includes("iPad")?(null==(i=t.match(/OS ([\d_]+)/))?void 0:i[1])?"iOS ".concat(i[1].replace(/_/g,".")):"iOS":t.includes("Android")?(i=t.match(/Android ([\d.]+)/))?"Android ".concat(i[1]):"Android":t.includes("Linux")?"Linux":null}(i)):null)}catch(n){return null}var i,n,e}function ca(){try{if("undefined"!=typeof document&&document.referrer)return function(t){var i;if("undefined"!=typeof URL)try{return new URL(t).hostname}catch(t){return"direct"}var n=t.match(/^https?:\/\/([^/?#]+)/);return n&&null!==(i=n[1])&&void 0!==i?i:"direct"}(document.referrer)}catch(t){}return"direct"}function ha(t){var i=ua(),n=aa(),e=function(){var t;try{if("undefined"!=typeof navigator)return navigator.language||(null===(t=navigator.languages)||void 0===t?void 0:t[0])||"en-US"}catch(t){}return"en-US"}(),r=function(){try{if("undefined"!=typeof Intl)return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch(t){}return"UTC"}(),s=function(){try{if("undefined"!=typeof window&&window.screen)return"".concat(window.screen.width,"x").concat(window.screen.height)}catch(t){}return"0x0"}(),o=function(){try{if("undefined"!=typeof window&&window.location){var t=window.location.search;return{utmSource:ra(t,"utm_source"),utmMedium:ra(t,"utm_medium"),utmCampaign:ra(t,"utm_campaign"),utmTerm:ra(t,"utm_term"),utmContent:ra(t,"utm_content"),adsId:ra(t,"gclid")||ra(t,"fbclid")||ra(t,"msclkid")||ra(t,"ttclid")}}}catch(t){}return{utmSource:null,utmMedium:null,utmCampaign:null,utmTerm:null,utmContent:null,adsId:null}}(),u=ca(),a={sdk_version:Hs,consent:(null==t?void 0:t.notificationPermissionGranted)?"yes":"no"};return function(t,i,n,e,r,s){i&&(t.browser=i),n&&(t.os_version=n),e&&"en-US"!==e&&(t.locale=e),r&&"UTC"!==r&&(t.timezone=r),s&&"0x0"!==s&&(t.screen_resolution=s)}(a,i,n,e,r,s),function(t,i,n,e){(null==i?void 0:i.appVersion)&&(t.app_version=i.appVersion),(null==i?void 0:i.fcmTokenCreatedAt)&&(t.token_creation_date=i.fcmTokenCreatedAt),n.utmSource&&(t.utm_source=n.utmSource),n.utmMedium&&(t.utm_medium=n.utmMedium),n.utmCampaign&&(t.utm_campaign=n.utmCampaign),n.utmTerm&&(t.utm_term=n.utmTerm),n.utmContent&&(t.utm_content=n.utmContent),n.adsId&&(t.ads_id=n.adsId),e&&"direct"!==e&&(t.initial_referrer=e)}(a,t,o,u),a}var da=3e5,fa=null,la=0;function va(){return ve(this,void 0,void 0,function(){return me(this,function(t){return null!==fa&&Date.now()-la<da?[2,fa]:"undefined"!=typeof navigator&&navigator.geolocation?[2,new Promise(function(t){navigator.geolocation.getCurrentPosition(function(i){fa={latitude:i.coords.latitude,longitude:i.coords.longitude},la=Date.now(),t(fa)},function(){return t(null)},{maximumAge:da,timeout:2e3,enableHighAccuracy:!1})})]:[2,null]})})}var ma="__glu_container",ga="__glu_backdrop";function pa(){return"__GLU__"+ea().replace(/-/g,"")}function wa(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ya(t,i){var n=Math.max(0,Math.round(i)),e=parseInt(t.style.height,10)||0;Math.abs(e-n)<=1||(t.style.transition||(t.style.transition="height 300ms ease"),t.style.height="".concat(n,"px"))}var Ea=function(){function t(t,i){var n;this.rootElement=null,this.closeListener=null,this.isShown=!1,this.supportsPreload=!0,this.preloaded=!1,this.preloadStyleSnapshot=null,this.boundListeners=[],this.customStyles=[],this.destroyed=!1,this.loaderElement=null,this.config=t,this.contentElement=i,this.mountDefaultStyleOnce(null!==(n=t.darkMode)&&void 0!==n&&n)}return t.prototype.isVisible=function(){var t,i;return this.isShown&&null!==(i=null===(t=this.rootElement)||void 0===t?void 0:t.isConnected)&&void 0!==i&&i},t.prototype.mountDefaultStyleOnce=function(i){if("undefined"!=typeof document){var n=document.getElementById(t.DEFAULT_STYLE_ID);if(n)n.dataset.gluDark!==String(i)&&(n.textContent=na(i),n.dataset.gluDark=String(i));else{var e=this.mountStyle(na(i));e&&(e.setAttribute("id",t.DEFAULT_STYLE_ID),e.dataset.gluDark=String(i))}}},t.prototype.bindEvent=function(t,i,n){t.addEventListener(i,n),this.boundListeners.push({target:t,type:i,handler:n})},t.prototype.mountStyle=function(t){if("undefined"==typeof document)return null;var i=document.createElement("style");return i.textContent=t,document.head.appendChild(i),i},t.prototype.addCustomStyle=function(t){if(this.config.css){var i=function(t,i){var n,e,r=t;try{for(var s=ge(Object.entries(i)),o=s.next();!o.done;o=s.next()){var u=pe(o.value,2),a=u[0],c=u[1];r.includes(a)&&(r=r.replace(new RegExp(wa(a),"g"),c))}}catch(t){n={error:t}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}return r}(this.config.css,t),n=this.mountStyle(i);n&&this.customStyles.push(n)}},t.prototype.addCloseButton=function(t){var i=this;if("undefined"!=typeof document){var n=document.createElement("button");n.type="button",n.setAttribute("aria-label","Close"),n.classList.add(ia.closeIcon.className),n.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L13 13M13 1L1 13" stroke="white" stroke-width="2" stroke-linecap="round"/></svg>',this.bindEvent(n,"click",function(t){var n;t.stopPropagation(),t.preventDefault(),null===(n=i.closeListener)||void 0===n||n.call(i)}),t.appendChild(n)}},t.prototype.preload=function(){var i,n;if(this.supportsPreload&&!this.preloaded&&!this.isShown&&this.rootElement&&"undefined"!=typeof document){this.preloaded=!0;var e={};try{for(var r=ge(t.PRELOAD_STYLE_KEYS),s=r.next();!s.done;s=r.next()){var o=s.value;e[o]=this.rootElement.style[o]}}catch(t){i={error:t}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}this.preloadStyleSnapshot=e,Object.assign(this.rootElement.style,t.HIDDEN_STYLE),document.body.appendChild(this.rootElement)}},t.prototype.clearPreloadStyles=function(){var i;this.preloaded&&this.rootElement&&(this.preloaded=!1,Object.assign(this.rootElement.style,null!==(i=this.preloadStyleSnapshot)&&void 0!==i?i:t.CLEARED_STYLE),this.preloadStyleSnapshot=null)},t.prototype.show=function(){var t,i;this.rootElement&&"undefined"!=typeof document&&(this.clearPreloadStyles(),this.rootElement.parentNode||document.body.appendChild(this.rootElement),this.isShown=!0,null===(i=(t=this.config).onShown)||void 0===i||i.call(t))},t.prototype.hide=function(){this.isShown=!1,this.rootElement&&this.rootElement.parentNode&&this.rootElement.parentNode.removeChild(this.rootElement)},t.prototype.addCloseListener=function(t){this.closeListener=t},Object.defineProperty(t.prototype,"resizableElement",{get:function(){return this.rootElement},enumerable:!1,configurable:!0}),t.prototype.setHeight=function(t){var i=this.resizableElement;i&&ya(i,t)},t.prototype.showLoader=function(){var t=this.resizableElement;if(t&&!this.loaderElement&&"undefined"!=typeof document){var i=document.createElement("div");i.classList.add(ia.loader.className),t.appendChild(i),this.loaderElement=i}},t.prototype.hideLoader=function(){var t;null===(t=this.loaderElement)||void 0===t||t.remove(),this.loaderElement=null},t.prototype.destroy=function(){var t,i,n,e,r;if(!this.destroyed){this.destroyed=!0,this.isShown=!1;try{for(var s=ge(this.boundListeners),o=s.next();!o.done;o=s.next()){var u=o.value,a=u.target,c=u.type,h=u.handler;a.removeEventListener(c,h)}}catch(i){t={error:i}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}this.boundListeners.length=0,(null===(r=this.rootElement)||void 0===r?void 0:r.parentNode)&&this.rootElement.parentNode.removeChild(this.rootElement);try{for(var d=ge(this.customStyles),f=d.next();!f.done;f=d.next()){f.value.remove()}}catch(t){n={error:t}}finally{try{f&&!f.done&&(e=d.return)&&e.call(d)}finally{if(n)throw n.error}}this.customStyles.length=0,this.closeListener=null,this.onDestroy()}},t.prototype.onDestroy=function(){},t.DEFAULT_STYLE_ID="__glu_default_style",t.PRELOAD_STYLE_KEYS=["position","left","top","visibility","pointerEvents"],t.HIDDEN_STYLE={position:"fixed",left:"-9999px",top:"-9999px",visibility:"hidden",pointerEvents:"none"},t.CLEARED_STYLE={position:"",left:"",top:"",visibility:"",pointerEvents:""},t}(),_a=function(t){function i(i,n){var e,r=t.call(this,i,n)||this;return r.sheetClass=pa(),r.backdropClass=pa(),r.sheetElement=null,r.height=i.height,r.createElement(),r.addCustomStyle(((e={})[ma]=r.sheetClass,e[ga]=r.backdropClass,e)),r}return fe(i,t),i.prototype.createElement=function(){var i=this;if("undefined"!=typeof document){var n=document.createElement("div");n.classList.add(this.backdropClass,ia.backDrop.className);var e=document.createElement("div"),r="IMG"===this.contentElement.tagName;e.classList.add(this.sheetClass,r?ia.bottomSheetStatic.className:ia.bottomSheet.className,ia.hideScroll.className),e.style.height=this.height,e.appendChild(this.contentElement),this.addCloseButton(e),this.bindEvent(e,"click",function(t){return t.stopPropagation()}),n.appendChild(e),this.bindEvent(n,"click",function(t){var n;t.stopPropagation(),t.preventDefault(),null===(n=i.closeListener)||void 0===n||n.call(i)}),this.bindEvent(n,"animationend",function(){i.isShown||t.prototype.hide.call(i)}),this.rootElement=n,this.sheetElement=e}else this.config.logger.warn("BottomSheetContainer.createElement() skipped - no document (SSR), container will not render")},Object.defineProperty(i.prototype,"resizableElement",{get:function(){return this.sheetElement},enumerable:!1,configurable:!0}),i.prototype.show=function(){this.sheetElement&&(this.sheetElement.classList.remove(ia.slideDownSheet.className),this.sheetElement.classList.add(ia.slideUpSheet.className),t.prototype.show.call(this))},i.prototype.hide=function(){this.sheetElement&&(this.sheetElement.classList.remove(ia.slideUpSheet.className),this.sheetElement.classList.add(ia.slideDownSheet.className),this.isShown=!1)},i}(Ea),Ia=function(t){function i(i,n){var e,r=t.call(this,i,n)||this;return r.instanceClass=pa(),r.createElement(),r.addCustomStyle(((e={})[ma]=r.instanceClass,e)),r}return fe(i,t),i.prototype.createElement=function(){var i=this;if("undefined"!=typeof document){var n=document.createElement("div");n.appendChild(this.contentElement),n.classList.add(ia.chatBox.className,this.instanceClass),this.addCloseButton(n),this.bindEvent(n,"animationend",function(){i.isShown||t.prototype.hide.call(i)}),this.rootElement=n}else this.config.logger.warn("ChatBoxContainer.createElement() skipped - no document (SSR), container will not render")},i.prototype.show=function(){this.rootElement&&(this.rootElement.classList.remove(ia.slideDown.className),this.rootElement.classList.add(ia.slideUp.className),t.prototype.show.call(this))},i.prototype.hide=function(){this.rootElement&&(this.rootElement.classList.remove(ia.slideUp.className),this.rootElement.classList.add(ia.slideDown.className),this.isShown=!1)},i}(Ea),ba=[],Ta=!1,Sa=null,Na=null;function Da(t,i){Na=i,"undefined"!=typeof document&&(Ta||((Sa||(Sa=new MutationObserver(function(){var t,i;try{for(var n=ge(we([],pe(ba),!1)),e=n.next();!e.done;e=n.next()){var r=e.value;try{r()}catch(t){null==Na||Na.error("DOM observer callback failed",{error:t})}}}catch(i){t={error:i}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}})),Sa).observe(document.body,{childList:!0,subtree:!0}),Ta=!0),ba.includes(t)||ba.push(t))}function ka(t){0===(ba=ba.filter(function(i){return i!==t})).length&&Ta&&Sa&&(Sa.disconnect(),Sa=null,Ta=!1)}var Oa=function(t){function i(i,n){var e,r=t.call(this,i,n)||this;return r.supportsPreload=!1,r.instanceClass=pa(),r.isObserverRunning=!1,r.showOnceHookPresent=function(){var t,i;if(r.isObserverRunning&&"undefined"!=typeof document&&r.rootElement){var n=document.querySelector("#".concat(r.hookId));n&&(n.innerHTML="",n.append(r.rootElement),r.isShown=!0,null===(i=(t=r.config).onShown)||void 0===i||i.call(t),ka(r.showOnceHookPresent),r.isObserverRunning=!1)}},r.hookId=i.elementHookId,r.createElement(),r.addCustomStyle(((e={})[ma]=r.instanceClass,e)),r}return fe(i,t),i.prototype.createElement=function(){if("undefined"!=typeof document){var t=document.createElement("div");t.appendChild(this.contentElement);var i="IMG"===this.contentElement.tagName;t.classList.add(this.instanceClass,i?ia.embeddedStatic.className:ia.embedded.className),this.rootElement=t}},i.prototype.show=function(){var t,i;if("undefined"!=typeof document&&this.rootElement){var n=document.querySelector("#".concat(this.hookId));if(n)return n.innerHTML="",n.append(this.rootElement),this.isShown=!0,void(null===(i=(t=this.config).onShown)||void 0===i||i.call(t));this.isObserverRunning||(this.config.logger.info("EmbeddedContainer hook not found, waiting for it to appear",{hookId:this.hookId}),Da(this.showOnceHookPresent,this.config.logger),this.isObserverRunning=!0)}},i.prototype.hide=function(){var t;null===(t=this.rootElement)||void 0===t||t.remove(),this.isShown=!1,this.isObserverRunning&&(ka(this.showOnceHookPresent),this.isObserverRunning=!1)},i.prototype.onDestroy=function(){this.isObserverRunning&&(ka(this.showOnceHookPresent),this.isObserverRunning=!1)},i.prototype.showLoader=function(){},i.prototype.hideLoader=function(){},i}(Ea),Aa=function(t){function i(i,n){var e,r=t.call(this,i,n)||this;return r.instanceClass=pa(),r.createElement(),r.addCustomStyle(((e={})[ma]=r.instanceClass,e)),r}return fe(i,t),i.prototype.createElement=function(){if("undefined"!=typeof document){var t=document.createElement("div");t.appendChild(this.contentElement),t.classList.add(ia.iconButton.className,this.instanceClass),this.rootElement=t}else this.config.logger.warn("IconButtonContainer.createElement() skipped - no document (SSR), container will not render")},i.prototype.show=function(){this.rootElement&&(this.rootElement.classList.remove(ia.slideDown.className),this.rootElement.classList.add(ia.slideUp.className),t.prototype.show.call(this))},i.prototype.hide=function(){this.rootElement&&(this.rootElement.classList.remove(ia.slideUp.className),this.rootElement.classList.add(ia.slideDown.className),t.prototype.hide.call(this))},i}(Ea),Ca=function(t){function i(i,n){var e,r=t.call(this,i,n)||this;return r.supportsPreload=!1,r.instanceClass=pa(),r.isObserverRunning=!1,r.showOnceHookPresent=function(){var t,i;if(r.isObserverRunning&&"undefined"!=typeof document&&r.rootElement){var n=document.querySelector("#".concat(r.hookId));n&&(n.innerHTML="",n.append(r.rootElement),r.isShown=!0,null===(i=(t=r.config).onShown)||void 0===i||i.call(t),ka(r.showOnceHookPresent),r.isObserverRunning=!1)}},r.hookId=i.elementHookId,r.contentElement.classList.add(r.instanceClass),r.rootElement=r.contentElement,r.addCustomStyle(((e={})[ma]=r.instanceClass,e)),r}return fe(i,t),i.prototype.show=function(){var t,i;if("undefined"!=typeof document&&this.rootElement){var n=document.querySelector("#".concat(this.hookId));if(n)return n.innerHTML="",n.append(this.rootElement),this.isShown=!0,void(null===(i=(t=this.config).onShown)||void 0===i||i.call(t));this.isObserverRunning||(this.config.logger.info("NativeBannerContainer hook not found, waiting for it to appear",{hookId:this.hookId}),Da(this.showOnceHookPresent,this.config.logger),this.isObserverRunning=!0)}},i.prototype.hide=function(){var t;null===(t=this.rootElement)||void 0===t||t.remove(),this.isShown=!1,this.isObserverRunning&&(ka(this.showOnceHookPresent),this.isObserverRunning=!1)},i.prototype.onDestroy=function(){this.isObserverRunning&&(ka(this.showOnceHookPresent),this.isObserverRunning=!1)},i}(Ea),Ra=function(t){function i(i,n){var e,r=t.call(this,i,n)||this;return r.popupClass=pa(),r.backdropClass=pa(),r.popupElement=null,r.height=i.height,r.createElement(),r.addCustomStyle(((e={})[ma]=r.popupClass,e[ga]=r.backdropClass,e)),r}return fe(i,t),i.prototype.createElement=function(){var i=this;if("undefined"!=typeof document){var n=document.createElement("div");n.classList.add(this.backdropClass,ia.backDrop.className);var e=document.createElement("div"),r="IMG"===this.contentElement.tagName;e.classList.add(this.popupClass,r?ia.popUpStatic.className:ia.popUp.className,ia.hideScroll.className),e.style.height=this.height,e.appendChild(this.contentElement),this.addCloseButton(e),this.bindEvent(e,"click",function(t){return t.stopPropagation()}),n.appendChild(e),this.bindEvent(n,"click",function(t){var n;t.stopPropagation(),t.preventDefault(),null===(n=i.closeListener)||void 0===n||n.call(i)}),this.bindEvent(n,"animationend",function(){i.isShown||t.prototype.hide.call(i)}),this.rootElement=n,this.popupElement=e}else this.config.logger.warn("PopupContainer.createElement() skipped - no document (SSR), container will not render")},Object.defineProperty(i.prototype,"resizableElement",{get:function(){return this.popupElement},enumerable:!1,configurable:!0}),i.prototype.show=function(){this.popupElement&&(this.popupElement.classList.remove(ia.slideDown.className),this.popupElement.classList.add(ia.slideUp.className),t.prototype.show.call(this))},i.prototype.hide=function(){this.popupElement&&(this.popupElement.classList.remove(ia.slideUp.className),this.popupElement.classList.add(ia.slideDown.className),this.isShown=!1)},i}(Ea);function xa(t){var i=t;if("string"==typeof i)try{i=JSON.parse(i)}catch(t){return null}var n=function(t){if(!t||"object"!=typeof t)return null;var i=t.eventName;if("string"!=typeof i)return null;return{target:"GLU_SDK",action:{type:i,data:t.data}}}(i);return n||(i&&"object"==typeof i&&"GLU_SDK"===i.target?i:null)}var Pa=function(){function t(i){var n=this;this.sdkEventListener=null,this.boundListeners=[],this.headStyles=[],this.destroyed=!1,this.messageListener=function(t,i,e){var r,s,o="CLOSE_FRAME_CONTENT"===i.action.type?{target:"GLU_SDK",action:{type:"CLOSE_CONTAINER_CONTENT"}}:i;n.element instanceof HTMLIFrameElement&&t===n.element.contentWindow&&e===n.contentOrigin()?null===(r=n.sdkEventListener)||void 0===r||r.call(n,o):"UPDATE_CONTENT_STATE"===o.action.type?n.sendMessageToContent(o.action):"CLOSE_CONTAINER_CONTENT"===o.action.type&&n.sendMessageToContent({type:"UPDATE_CONTENT_STATE",data:null!==(s=o.action.data)&&void 0!==s?s:{}})},this.config=i,t.lastLogger=i.logger,t.listeners.push(this.messageListener),t.isListening||t.installWindowListener()}return t.prototype.bindEvent=function(t,i,n,e){t.addEventListener(i,n,e),this.boundListeners.push({target:t,type:i,handler:n})},t.prototype.addHeadStyle=function(t){if("undefined"!=typeof document){var i=document.createElement("style");i.textContent=t,document.head.appendChild(i),this.headStyles.push(i)}},t.prototype.destroy=function(){var i,n,e,r;if(!this.destroyed){this.destroyed=!0,t.removeListener(this.messageListener);try{for(var s=ge(this.boundListeners),o=s.next();!o.done;o=s.next()){var u=o.value,a=u.target,c=u.type,h=u.handler;a.removeEventListener(c,h)}}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}this.boundListeners.length=0;try{for(var d=ge(this.headStyles),f=d.next();!f.done;f=d.next()){f.value.remove()}}catch(t){e={error:t}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(e)throw e.error}}this.headStyles.length=0,this.sdkEventListener=null,this.onDestroy()}},t.prototype.onDestroy=function(){},t.removeListener=function(i){t.listeners=t.listeners.filter(function(t){return t!==i}),0===t.listeners.length&&t.windowListener&&"undefined"!=typeof window&&(window.removeEventListener("message",t.windowListener),t.windowListener=null,t.isListening=!1)},t.parseSdkEvent=function(t){return xa(t)},t.dispatchToListeners=function(i,n,e){var r,s,o;try{for(var u=ge(t.listeners),a=u.next();!a.done;a=u.next()){var c=a.value;try{c(i,n,e)}catch(i){null===(o=t.lastLogger)||void 0===o||o.error("Content message listener threw",{error:i})}}}catch(t){r={error:t}}finally{try{a&&!a.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}},t.installWindowListener=function(){if("undefined"!=typeof window){var i=function(i){var n=t.parseSdkEvent(i.data);n&&(t.dispatchToListeners(i.source,n,i.origin),i.stopPropagation())};window.addEventListener("message",i),t.windowListener=i,t.isListening=!0}},t.prototype.urlModifier=function(t,i){var n=function(t){return encodeURIComponent(String(t))},e=t.includes("?")?"&":"?";return e+="source=JS_SDK",(null==i?void 0:i.token)&&(e+="&token=".concat(n(this.config.token))),this.config.isEmbedded&&(this.config.rootId&&(e+="&rootId=".concat(n(this.config.rootId))),e+="&isEmbedded=true"),this.config.userId||(e+="¬LoggedIn=true"),void 0!==this.config.darkMode&&(e+="&darkMode=".concat(n(this.config.darkMode))),t+e},t.prototype.listen=function(t){this.sdkEventListener=t},t.prototype.reveal=function(){this.element instanceof HTMLIFrameElement&&(this.element.style.opacity="1")},t.prototype.sendMessageToContent=function(t){this.postToContentWindow({target:"GLU_SDK",action:t})},t.prototype.sendRawMessage=function(t){this.postToContentWindow(t)},t.prototype.postToContentWindow=function(t){if(this.element instanceof HTMLIFrameElement){var i=this.element.contentWindow;if(i&&"function"==typeof i.postMessage){var n=this.contentOrigin();n&&i.postMessage(t,n)}}},t.prototype.contentOrigin=function(){if(!(this.element instanceof HTMLIFrameElement&&this.element.src))return null;try{return new URL(this.element.src).origin}catch(t){return this.config.logger.warn("Could not resolve content iframe origin for postMessage",{src:this.element.src}),null}},t.listeners=[],t.isListening=!1,t.windowListener=null,t.lastLogger=null,t}(),Ma="https://api.customerglu.com/reward/v1.1/user/program/accept",Ua=["https://img.icons8.com/ios-filled/24/000000/rocket.png","https://img.icons8.com/ios-filled/24/000000/gift.png","https://img.icons8.com/ios-filled/24/000000/money.png"],La={card:"#1E1E1E",iconContainer:"#164048",heading:"#F5F5F5",notNow:"#AAAAAA"},Fa={card:"#fff",iconContainer:"#e0f7fa",heading:"#333",notNow:"#888"},Ga=function(t){function i(i,n){var e=t.call(this,n)||this;if(e.data=i,e.campaignId=e.extractCampaignId(),!e.campaignId)throw new Error("ACCEPT_GUARD content missing conditions.campaignId");if(!e.config.allCampaignsMap.byId[e.campaignId])throw new Error("ACCEPT_GUARD: campaign ".concat(e.campaignId," not present in campaign map"));return e.createElement(),e}return fe(i,t),i.prototype.extractCampaignId=function(){var t,i=null===(t=this.data.conditions)||void 0===t?void 0:t.campaignId;return"string"==typeof i?i:Array.isArray(i)&&void 0!==i[0]?String(i[0]):""},i.prototype.createElement=function(){var t,i,n,e,r,s,o=this,u=null!==(n=this.config.darkMode)&&void 0!==n&&n?La:Fa,a={container:"display: flex; justify-content: center; align-items: center;",card:"background-color: ".concat(u.card,"; text-align: center; padding: 30px 20px; max-width: 400px; width: 100%; margin: 10px;"),iconContainer:"background-color: ".concat(u.iconContainer,"; border-radius: 50%; padding: 15px; margin: 0 auto 20px; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;"),flameIcon:"width: 60px; height: 60px;",heading:"font-size: 22px; font-weight: bold; color: ".concat(u.heading,"; margin: 20px 0;"),instructions:"list-style: none; padding: 0; margin: 0 0 20px; text-align: left;",listItem:"display: flex; align-items: center; margin-bottom: 15px; font-size: 16px; color: ".concat(u.heading,";"),icon:"margin-right: 10px;",startStreakButton:"background-color: #6c63ff; color: #fff; border: none; border-radius: 25px; padding: 12px 25px; font-size: 16px; cursor: pointer; width: 80%; margin: 0 auto 10px;",notNowButton:"background: none; border: none; color: ".concat(u.notNow,"; font-size: 14px; cursor: pointer; margin-top: 5px;")},c=document.createElement("div");c.style.cssText=a.container;var h=document.createElement("div");h.style.cssText=a.card;var d=document.createElement("div");d.style.cssText=a.iconContainer;var f=document.createElement("img");f.src="https://img.icons8.com/color/96/000000/fire-element.png",f.style.cssText=a.flameIcon,d.appendChild(f);var l=document.createElement("h1");l.innerText="Can you complete a 7-day earning streak?",l.style.cssText=a.heading;var v=document.createElement("ul");v.style.cssText=a.instructions;var m=[{icon:null!==(e=Ua[0])&&void 0!==e?e:"",text:"Start a streak anytime until [DATE HERE] by earning at least $1"},{icon:null!==(r=Ua[1])&&void 0!==r?r:"",text:"Claim a bonus reward for each streak day"},{icon:null!==(s=Ua[2])&&void 0!==s?s:"",text:"Complete a 7-day streak and earn an additional up to $50 reward"}];try{for(var g=ge(m),p=g.next();!p.done;p=g.next()){var w=p.value,y=document.createElement("li");y.style.cssText=a.listItem;var E=document.createElement("img");E.src=w.icon,E.style.cssText=a.icon;var _=document.createElement("span");_.innerText=w.text,y.appendChild(E),y.appendChild(_),v.appendChild(y)}}catch(i){t={error:i}}finally{try{p&&!p.done&&(i=g.return)&&i.call(g)}finally{if(t)throw t.error}}var I=document.createElement("button");I.innerText="Earn to start your streak",I.style.cssText=a.startStreakButton,this.bindEvent(I,"click",function(){o.accept()});var b=document.createElement("button");b.innerText="Not now",b.style.cssText=a.notNowButton,this.bindEvent(b,"click",function(){var t;null===(t=o.sdkEventListener)||void 0===t||t.call(o,{target:"GLU_SDK",action:{type:"CLOSE_CONTAINER_CONTENT"}})}),h.appendChild(d),h.appendChild(l),h.appendChild(v),h.appendChild(I),h.appendChild(b),c.appendChild(h),this.element=c},i.prototype.accept=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:t={campaignId:this.campaignId,choice:"accept"},i=!1,this.config.logger.debug("ACCEPT_GUARD accept request started",{url:Ma,requestBody:t}),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,fetch(Ma,{method:"POST",headers:{authorization:"Bearer ".concat(this.config.token),"content-type":"application/json"},body:JSON.stringify(t)})];case 2:return(n=u.sent()).ok?[3,4]:[4,n.text()];case 3:throw e=u.sent(),i=!0,this.config.logger.error("ACCEPT_GUARD accept request failed",{url:Ma,requestBody:t,status:n.status,responseBody:e}),new Error("Accept failed with status ".concat(n.status));case 4:return this.config.logger.info("ACCEPT_GUARD accept request succeeded",{campaignId:this.campaignId}),r={target:"GLU_SDK",action:{type:"TOGGLE_CONTAINER_CONTENT",id:pa(),content:{typeId:"CAMPAIGN",conditions:{campaignId:[this.campaignId]}},container:{typeId:"POP_UP",css:".__glu_container { \n background-color: #000; \n border-radius: 0px;\n max-width: none;\n max-height: none;\n height: 100vh;\n width: 100vw;\n } \n .__glu_backdrop { background-color: rgba(0,0,0,0.5); \n background-color: rgba(0,0,0,0.5); \n }",height:"",elementHookId:""}}},null===(o=this.sdkEventListener)||void 0===o||o.call(this,r),[3,6];case 5:return s=u.sent(),i||this.config.logger.error("ACCEPT_GUARD accept request failed",{url:Ma,requestBody:t,error:s}),[3,6];case 6:return[2]}})})},i}(Pa);function Va(t,i,n){var e=document.createElement("iframe");e.classList.add(ia.iframe.className),e.style.height="100%",e.style.width="100%",e.style.display="block",e.setAttribute("fetchpriority","high"),e.style.opacity="0",e.style.transition="opacity 150ms ease";var r=function(){e.style.opacity="1"},s=performance.now();return e.addEventListener("load",function(){r(),null==i||i(performance.now()-s)},{once:!0}),e.addEventListener("error",function(){r(),null==n||n()},{once:!0}),e.src=t,e}var Ba=function(t){function i(i,n){var e=t.call(this,n)||this,r=e.resolveUrl(i);return e.element=Va(e.urlModifier(r),n.onLoad,function(){return n.logger.error("Campaign iframe failed to load",{src:r})}),e}return fe(i,t),i.prototype.resolveUrl=function(t){var i,n,e,r=null!==(e=t.conditions)&&void 0!==e?e:{};if(0===Object.keys(r).length){if(t.campaignId)if(h=this.config.allCampaignsMap.byId[t.campaignId])return h.url;throw new Error("CAMPAIGN content has no conditions")}var s=this.config.allCampaignsMap,o=s.allIds,u=s.byId;try{for(var a=ge(o),c=a.next();!c.done;c=a.next()){var h;if((h=u[c.value])&&this.campaignMatches(h,r))return h.url}}catch(t){i={error:t}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}throw new Error("CAMPAIGN_NOT_FOUND")},i.prototype.campaignMatches=function(t,i){var n,e,r;try{for(var s=ge(Object.keys(i)),o=s.next();!o.done;o=s.next()){var u=o.value,a=i[u],c=t[u],h=null===(r=t.banner)||void 0===r?void 0:r[u];if("string"==typeof a){if(a!==c&&a!==h)return!1}else{if(!Array.isArray(a))return!1;if(!a.includes(c)&&!a.includes(h))return!1}}}catch(t){n={error:t}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}return!0},i}(Pa);var za=function(t){function i(i,n){var e=t.call(this,n)||this;e.actionId=pa(),e.data=i;var r=e.lookupCampaign();if(!(null==r?void 0:r.banner))throw new Error("DYNAMIC content requires a campaign with banner state");return e.bannerData=r.banner,e.createElement(),e}return fe(i,t),i.prototype.bindImageErrorLog=function(t,i){var n=this;this.bindEvent(t,"error",function(){return n.config.logger.error("".concat(i," failed to load"),{src:t.src})},{once:!0})},i.prototype.lookupCampaign=function(){var t,i=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==i?void 0:i.type)){var n=null===(t=i.content.conditions)||void 0===t?void 0:t.campaignId,e="";if("string"==typeof n?e=n:Array.isArray(n)&&void 0!==n[0]&&(e=String(n[0])),e)return this.config.allCampaignsMap.byId[e]}},i.prototype.createElement=function(){var t,i,n=this,e=this.bannerData,r=null!==(t=this.data.state)&&void 0!==t?t:{},s=e.userCampaignStatus,o=null!==(i=r[s])&&void 0!==i?i:{title:"",body:""},u=e.stepCompleted,a=e.activityCount,c=e.totalCampaignParticipants,h=e.activityExpiry,d=Math.floor(Date.now()/1e3),f=Math.max(0,h-d),l=Math.floor(f/3600),v=Math.floor(f%3600/60),m="".concat(l,"h").concat(v.toString().padStart(2,"0"),"m"),g=document.createElement("div");g.className="element";var p=document.createElement("div");p.className="progress-text-container";var w=document.createElement("div");w.setAttribute("class","progress-container");var y="http://www.w3.org/2000/svg",E=document.createElementNS(y,"svg");E.setAttribute("class","progress-circle"),E.setAttribute("viewBox","0 0 36 36");var _=document.createElementNS(y,"path");_.setAttribute("class","progress-bg"),_.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831");var I=document.createElementNS(y,"path");I.setAttribute("class","progress"),I.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831");var b=a>0?u/a*100:0;I.setAttribute("stroke-dasharray","".concat(b,", 100")),I.setAttribute("stroke-linecap",0===u?"butt":"round"),E.appendChild(_),E.appendChild(I);var T=document.createElement("div");T.setAttribute("class","inner-content");var S=document.createElement("div");S.setAttribute("class","primary-icon-container");var N=document.createElement("img");N.setAttribute("class","icon-image"),N.setAttribute("src","https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/b4194687-57e6-4272-83d5-b7867053408d.svg"),this.bindImageErrorLog(N,"Dynamic content primary icon"),S.appendChild(N),T.appendChild(S),w.appendChild(E),w.appendChild(T);var D=document.createElement("p");D.setAttribute("class","progress-text"),D.innerText="".concat(u,"/").concat(a),p.appendChild(w),p.appendChild(D),g.appendChild(p);var k=document.createElement("img");k.setAttribute("class","smaller-icon"),k.setAttribute("src","https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/c7d4d74e-c9ef-4ba1-8646-277c2ba2e91d.svg"),this.bindImageErrorLog(k,"Dynamic content smaller icon"),w.appendChild(k);var O=document.createElement("div");if(O.className="time-title-body-container",g.appendChild(O),"completed"!==s){var A=document.createElement("div");A.className="icon-text-container";var C=document.createElement("img");C.className="icon-container",C.src="pristine"===s?"https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/2ca387f9-60b5-40bb-af78-272d81a73021.svg":"https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/9406d009-5604-4e13-a03b-4e24a7ca4264.svg",this.bindImageErrorLog(C,"Dynamic content timer icon"),A.appendChild(C);var R=document.createElement("p");R.className="timer-text",R.innerText="pristine"===s?"".concat(c," users currently streaking"):m,A.appendChild(R),O.appendChild(A)}var x=document.createElement("div");x.className="title-body-container";var P=document.createElement("p");P.className="title-text",P.innerText=o.title,x.appendChild(P);var M=document.createElement("p");M.className="body-text",M.innerText=o.body,x.appendChild(M),O.appendChild(x);var U=document.createElement("div");U.className="right-icon-container";var L=document.createElement("img");L.className="right-icon",L.src="https://assets.customerglu.com/d051269a-05d7-4722-9e25-7e031655b4d0/5ca637bd-2b75-4996-a3aa-14e58b60c07e.svg",this.bindImageErrorLog(L,"Dynamic content right arrow icon"),U.appendChild(L),g.appendChild(U),this.addHeadStyle(this.buildStylesheet(u===a)),this.bindEvent(g,"click",function(t){t.stopPropagation(),t.preventDefault(),n.handleClick()}),this.element=g},i.prototype.handleClick=function(){var t,i=this.data.action;if(i&&"TOGGLE_CONTAINER_CONTENT"===i.type&&this.sdkEventListener)if(this.bannerData.checkAccepted&&this.bannerData.accepted){var n=le(le({},i),{id:this.actionId});this.sdkEventListener({target:"GLU_SDK",action:n})}else{var e,r={target:"GLU_SDK",action:le(le({},i),{id:this.actionId,content:le(le({},i.content),{typeId:"ACCEPT_GUARD"}),container:le(le({},i.container),{typeId:"BOTTOM_SHEET",css:(e=null!==(t=this.config.darkMode)&&void 0!==t&&t,".__glu_container {\n background-color: ".concat(e?"#1E1E1E":"#fff",";\n height: 57vh\n }\n .__glu_backdrop {\n background-color: rgba(0,0,0,0.5);\n }"))})})};this.sdkEventListener(r)}},i.prototype.buildStylesheet=function(t){var i,n=t?"block":"none",e=null!==(i=this.config.darkMode)&&void 0!==i&&i,r=e?"#1E1E1E":"white",s=e?"#444444":"#d3d3d3",o=e?"#22303A":"#E9F2F9",u=e?"#B0B0B0":"#757575",a=e?"#444444":"#D8D8D8",c=e?"#F5F5F5":"inherit";return"\n *{ margin: 0; padding: 0; box-sizing: border-box; }\n body{ font-family: 'Poppins', sans-serif; }\n .element { border-radius: 8px; width: 100%; padding: 8px 0; align-items: stretch; background-color: ".concat(r,"; display: flex; }\n .progress-text-container{ display: flex; flex-direction: column; align-items: center; width: 20%; }\n .progress-container { align-items: center; display: flex; flex-direction: column; width: 80%; position: relative; }\n .progress-bg { fill: none; stroke: ").concat(s,"; stroke-width: 3; }\n .progress { fill: none; stroke: #FF0099; stroke-width: 3; transition: stroke-dasharray 0.3s ease; }\n .inner-content { height: 63%; width: 63%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; background-color: ").concat(o,"; border-radius: 50%; }\n .primary-icon-container { height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; }\n .icon-image{ height: 70%; width: 70%; }\n .smaller-icon { display: ").concat(n,"; position: absolute; bottom: 9%; width: 31%; right: 0%; border-radius: 50%; background-color: ").concat(r,"; padding: 1px; }\n .progress-text { margin: 0; font-size: 12px; font-weight: 400; color: ").concat(u,"; }\n .time-title-body-container { max-height: 100%; display: flex; gap: 8px; flex-direction: column; justify-content: center; width: 65%; }\n .icon-text-container { display: flex; border: 1px solid ").concat(a,"; border-radius: 4px; gap: 4px; padding: 2px 4px; width: fit-content; align-items: center; }\n .icon-container { width: 12px; height: 12px; }\n .timer-text { margin: 0px; font-size: 12px; font-weight: 600; color: ").concat(c,"; }\n .title-body-container { display: flex; gap: 8px; flex-direction: column; }\n .title-text { margin: 0; font-size: 16px; font-weight: 600; color: ").concat(c,"; }\n .body-text { margin: 0; font-size: 12px; font-weight: 400; color: ").concat(u,"; }\n .right-icon-container { display: flex; justify-content: center; align-items: center; width: 15%; }\n .right-icon { width: 20px; height: 20px; }\n ")},i}(Pa),ja=function(t){function i(i,n){var e=t.call(this,n)||this;e.actionId=pa(),e.data=i;var r=e.lookupCampaign();return(null==r?void 0:r.banner)?(e.createElement(r),e):(n.logger.warn("DynamicMultistep1Content: campaign/banner lookup failed — hiding",{campaignId:e.data.campaignId}),e.createEmptyElement(),e)}return fe(i,t),i.prototype.createEmptyElement=function(){var t=document.createElement("div");t.style.display="none",this.element=t},i.prototype.lookupCampaign=function(){var t,i=this.data.campaignId;if(i)return this.config.allCampaignsMap.byId[i];var n=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==n?void 0:n.type)){var e=null===(t=n.content.conditions)||void 0===t?void 0:t.campaignId,r="";return"string"==typeof e?r=e:Array.isArray(e)&&void 0!==e[0]&&(r=String(e[0])),r?this.config.allCampaignsMap.byId[r]:void 0}},i.prototype.createElement=function(t){var i,n,e,r,s,o,u,a,c,h=this,d=null==t?void 0:t.banner,f=null!==(i=null==d?void 0:d.stepCompleted)&&void 0!==i?i:0,l=null!==(n=null==d?void 0:d.activityCount)&&void 0!==n?n:0,v=null!==(e=null==d?void 0:d.userCampaignStatus)&&void 0!==e?e:"pristine",m=this.findWidgetState(f,v),g=null!==(r=null==m?void 0:m.title)&&void 0!==r?r:"",p=null!==(s=null==m?void 0:m.body)&&void 0!==s?s:"",w=null!==(u=null===(o=null==m?void 0:m.progressBar)||void 0===o?void 0:o.progressRewardText)&&void 0!==u?u:"",y=null!==(c=null!==(a=this.data.progressBarIcon)&&void 0!==a?a:this.data.src)&&void 0!==c?c:"",E=l>0?Math.round(f/l*100):0;this.data.widgetCss&&this.addHeadStyle(this.data.widgetCss);var _=document.createElement("div");_.className="banner-container";var I=document.createElement("div");I.className="header-progressbar-container";var b=document.createElement("div");b.className="header-container";var T=document.createElement("p");T.className="heading-text",T.innerHTML=g;var S=document.createElement("p");S.className="body-text",S.textContent=p,b.appendChild(T),b.appendChild(S);var N=document.createElement("div");N.className="progressbar-parent-container";var D=document.createElement("span");D.className="progressbar-text",D.textContent=w;var k=document.createElement("div");k.className="progressbar-container";var O=document.createElement("div");O.className="total-progress";var A=document.createElement("div");A.className="completed-progress",A.style.width="".concat(E,"%"),k.appendChild(O),k.appendChild(A),N.appendChild(D),N.appendChild(k),I.appendChild(b),I.appendChild(N);var C=document.createElement("div");if(C.className="right-icon-container",y){var R=document.createElement("img");R.src=y,R.style.width="48px",R.style.height="48px",this.bindEvent(R,"error",function(){return h.config.logger.error("DynamicMultistep1 icon failed to load",{src:y})},{once:!0}),C.appendChild(R)}_.appendChild(I),_.appendChild(C),this.bindEvent(_,"click",function(t){t.stopPropagation(),t.preventDefault(),h.handleClick()}),this.element=_},i.prototype.findWidgetState=function(t,i){var n,e,r=this.data.IWidgetState;if(null==r?void 0:r.length)return null!==(e=null!==(n=r.find(function(n){return n.step===t&&n.state===i}))&&void 0!==n?n:r.find(function(i){return i.step===t}))&&void 0!==e?e:r[0]},i.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener){var i={target:"GLU_SDK",action:le(le({},t),{id:this.actionId})};this.sdkEventListener(i)}},i}(Pa),Ha=function(t){function i(i,n){var e=t.call(this,n)||this;e.actionId=pa(),e.data=i;var r=e.lookupCampaign();return(null==r?void 0:r.banner)?(e.createElement(r),e):(n.logger.warn("DynamicMultistep2Content: campaign/banner lookup failed — hiding",{campaignId:e.data.campaignId}),e.createEmptyElement(),e)}return fe(i,t),i.prototype.createEmptyElement=function(){var t=document.createElement("div");t.style.display="none",this.element=t},i.prototype.lookupCampaign=function(){var t,i=this.data.campaignId;if(i)return this.config.allCampaignsMap.byId[i];var n=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==n?void 0:n.type)){var e=null===(t=n.content.conditions)||void 0===t?void 0:t.campaignId,r="";return"string"==typeof e?r=e:Array.isArray(e)&&void 0!==e[0]&&(r=String(e[0])),r?this.config.allCampaignsMap.byId[r]:void 0}},i.prototype.buildHeaderImage=function(t){var i=this;if(!t)return null;var n=document.createElement("div");n.className="image-container-ms2";var e=document.createElement("img");return e.className="header-image",e.src=t,this.bindEvent(e,"error",function(){return i.config.logger.error("DynamicMultistep2 header image failed to load",{src:t})},{once:!0}),n.appendChild(e),n},i.prototype.buildProgressBar=function(t,i){var n=document.createElement("div");n.className="progressbar-wrapper-ms2";var e=document.createElement("div");e.className="progressbar-container-ms2";var r=document.createElement("div");r.className="total-progress-ms2";var s=document.createElement("div");s.className="completed-progress-ms2",s.style.width="".concat(t,"%"),e.appendChild(r),e.appendChild(s);var o=document.createElement("div");o.className="progressbar-text-container-ms2";var u=document.createElement("span");return u.className="progressbar-text-ms2",u.textContent=i,o.appendChild(u),n.appendChild(e),n.appendChild(o),n},i.prototype.buildStepCircle=function(t,i){var n=document.createElement("div");n.className="step";var e=document.createElement("div");e.className=i?"circle completed":"circle";var r=document.createElement("span");return r.className=i?"amount completed":"amount",r.textContent=t,e.appendChild(r),n.appendChild(e),n},i.prototype.buildStepLabel=function(t,i,n){var e=document.createElement("div"),r="label inactive";return i?r="label completed":n&&(r="label current"),e.className=r,e.textContent=t,e},i.prototype.buildStepRows=function(t,i,n){var e=this,r=document.createElement("div");r.className="steps-container";var s=document.createElement("div");return s.className="labels-container",i.forEach(function(o,u){var a,c,h,d,f,l=null!==(a=t.find(function(t){return t.step===o&&"pristine"===t.state}))&&void 0!==a?a:t.find(function(t){return t.step===o}),v=null!==(h=null===(c=null==l?void 0:l.progressBar)||void 0===c?void 0:c.progressRewardText)&&void 0!==h?h:"",m=null!==(f=null===(d=null==l?void 0:l.progressBar)||void 0===d?void 0:d.progressLabel)&&void 0!==f?f:"",g=o<n,p=o===n;if(r.appendChild(e.buildStepCircle(v,g||p)),u<i.length-1){var w=document.createElement("div");w.className=g?"connector completed":"connector",r.appendChild(w)}s.appendChild(e.buildStepLabel(m,g,p))}),[r,s]},i.prototype.buildCtaButton=function(t){var i=this,n=document.createElement("div");n.className="button-container";var e=document.createElement("button");return e.className="view-rewards-button",e.textContent=t,this.bindEvent(e,"click",function(t){t.stopPropagation(),t.preventDefault(),i.handleClick()}),n.appendChild(e),n},i.prototype.createElement=function(t){var i,n,e,r,s,o,u,a,c,h,d=this,f=null==t?void 0:t.banner,l=null!==(i=null==f?void 0:f.stepCompleted)&&void 0!==i?i:0,v=null!==(n=null==f?void 0:f.activityCount)&&void 0!==n?n:0,m=null!==(e=null==f?void 0:f.userCampaignStatus)&&void 0!==e?e:"pristine",g=null!==(r=this.data.IWidgetState)&&void 0!==r?r:[],p=this.findWidgetState(l,m,g),w=v>0?Math.round(l/v*100):0;this.data.widgetCss&&this.addHeadStyle(this.data.widgetCss);var y=document.createElement("div");y.className="card-container-ms2";var E=document.createElement("div");E.className="banner-container-ms2";var _=null!==(u=null!==(o=null!==(s=null==p?void 0:p.headerImage)&&void 0!==s?s:this.data.progressMeterIcon)&&void 0!==o?o:this.data.src)&&void 0!==u?u:"",I=this.buildHeaderImage(_);I&&E.appendChild(I);var b=document.createElement("div");b.className="header-progressbar-container-ms2";var T=document.createElement("div");T.className="heading-container-ms2";var S=document.createElement("p");S.className="heading-text-ms2",S.innerHTML=null!==(a=null==p?void 0:p.title)&&void 0!==a?a:"",T.appendChild(S),b.appendChild(T),b.appendChild(this.buildProgressBar(w,null!==(h=null===(c=null==p?void 0:p.progressMeter)||void 0===c?void 0:c.completedText)&&void 0!==h?h:""));var N=we([],pe(new Set(g.map(function(t){return t.step}))),!1).sort(function(t,i){return t-i});if(N.length>0){var D=pe(this.buildStepRows(g,N,l),2),k=D[0],O=D[1];b.appendChild(k),b.appendChild(O)}(null==p?void 0:p.ctaText)&&b.appendChild(this.buildCtaButton(p.ctaText)),E.appendChild(b),y.appendChild(E),this.bindEvent(y,"click",function(t){t.stopPropagation(),t.preventDefault(),d.handleClick()}),this.element=y},i.prototype.findWidgetState=function(t,i,n){var e,r;return null!==(r=null!==(e=n.find(function(n){return n.step===t&&n.state===i}))&&void 0!==e?e:n.find(function(i){return i.step===t}))&&void 0!==r?r:n[0]},i.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener){var i={target:"GLU_SDK",action:le(le({},t),{id:this.actionId})};this.sdkEventListener(i)}},i}(Pa),qa=function(t){function i(i,n){var e=t.call(this,n)||this;e.actionId=pa(),e.isExpanded=!0,e.data=i;var r=e.lookupCampaign();return(null==r?void 0:r.banner)?(e.createElement(r),e):(n.logger.warn("DynamicMultistep3Content: campaign/banner lookup failed — hiding",{campaignId:e.data.campaignId}),e.createEmptyElement(),e)}return fe(i,t),i.prototype.createEmptyElement=function(){var t=document.createElement("div");t.style.display="none",this.element=t},i.prototype.lookupCampaign=function(){var t,i=this.data.campaignId;if(i)return this.config.allCampaignsMap.byId[i];var n=this.data.action;if("TOGGLE_CONTAINER_CONTENT"===(null==n?void 0:n.type)){var e=null===(t=n.content.conditions)||void 0===t?void 0:t.campaignId,r="";return"string"==typeof e?r=e:Array.isArray(e)&&void 0!==e[0]&&(r=String(e[0])),r?this.config.allCampaignsMap.byId[r]:void 0}},i.prototype.buildHeader=function(t,i){var n=this,e=document.createElement("div");e.className="header-container-ms3";var r=document.createElement("div");if(r.className="header-content-ms3",i){var s=document.createElement("span");s.className="progress-badge-ms3",s.textContent=i,r.appendChild(s)}var o=document.createElement("p");if(o.className="heading-ms3",o.innerHTML=t,r.appendChild(o),e.appendChild(r),this.data.progressBarIcon){var u=document.createElement("img");u.className="dropdown-icon-ms3",u.src=this.data.progressBarIcon;var a=this.data.progressBarIcon;this.bindEvent(u,"error",function(){return n.config.logger.error("DynamicMultistep3 dropdown icon failed to load",{src:a})},{once:!0}),e.appendChild(u)}return e},i.prototype.buildStepDiv=function(t,i,n,e){var r=document.createElement("div");r.className="step-ms3";var s=document.createElement("div"),o="circle-ms3";i?o+=" completed":n&&(o+=" current"),s.className=o;var u=document.createElement("span");if(u.className=n?"amount-ms3 current":"amount-ms3",u.textContent=t,s.appendChild(u),r.appendChild(s),e){var a=document.createElement("div");a.className=i?"connector-ms3 completed":"connector-ms3";var c=document.createElement("div");c.className="connector-progress-ms3",a.appendChild(c),r.appendChild(a)}return r},i.prototype.buildStepsContainer=function(t,i,n){var e=this,r=document.createElement("div");return r.className="steps-container-ms3",i.forEach(function(s,o){var u,a,c,h=null!==(u=t.find(function(t){return t.step===s&&"pristine"===t.state}))&&void 0!==u?u:t.find(function(t){return t.step===s}),d=null!==(c=null===(a=null==h?void 0:h.progressBar)||void 0===a?void 0:a.progressRewardText)&&void 0!==c?c:"",f=s<n,l=s===n;r.appendChild(e.buildStepDiv(d,f,l,o<i.length-1))}),r},i.prototype.buildCtaButton=function(t){var i=this,n=document.createElement("div");n.className="button-container-ms3";var e=document.createElement("button");e.className="action-button-ms3",e.textContent=t,this.bindEvent(e,"click",function(t){t.stopPropagation(),t.preventDefault(),i.handleClick()});var r=document.createElement("div");return r.className="shine-effect",n.appendChild(e),n.appendChild(r),n},i.prototype.createElement=function(t){var i,n,e,r,s=this,o=null==t?void 0:t.banner,u=null!==(i=null==o?void 0:o.stepCompleted)&&void 0!==i?i:0,a=null!==(n=null==o?void 0:o.userCampaignStatus)&&void 0!==n?n:"pristine",c=null!==(e=this.data.IWidgetState)&&void 0!==e?e:[],h=this.findWidgetState(u,a,c);this.data.widgetCss&&this.addHeadStyle(this.data.widgetCss);var d=document.createElement("div");d.className="content-container-ms3";var f=document.createElement("div");f.className="main-content-ms3";var l=we([],pe(new Set(c.map(function(t){return t.step}))),!1).sort(function(t,i){return t-i});if(l.length>0&&f.appendChild(this.buildStepsContainer(c,l,u)),null==h?void 0:h.body){var v=document.createElement("p");v.className="description-ms3",v.textContent=h.body,f.appendChild(v)}(null==h?void 0:h.ctaText)&&f.appendChild(this.buildCtaButton(h.ctaText)),d.appendChild(f);var m=this.buildHeader(null!==(r=null==h?void 0:h.title)&&void 0!==r?r:"",null==h?void 0:h.badgeTag);this.bindEvent(m,"click",function(t){t.stopPropagation(),s.isExpanded=!s.isExpanded,d.classList.toggle("hidden",!s.isExpanded)});var g=document.createElement("div");g.className="banner-container-ms3",g.appendChild(m),g.appendChild(d);var p=document.createElement("div");p.className="card-container-ms3",p.appendChild(g),this.element=p},i.prototype.findWidgetState=function(t,i,n){var e,r;return null!==(r=null!==(e=n.find(function(n){return n.step===t&&n.state===i}))&&void 0!==e?e:n.find(function(i){return i.step===t}))&&void 0!==r?r:n[0]},i.prototype.handleClick=function(){var t=this.data.action;if(t&&"TOGGLE_CONTAINER_CONTENT"===t.type&&this.sdkEventListener){var i={target:"GLU_SDK",action:le(le({},t),{id:this.actionId})};this.sdkEventListener(i)}},i}(Pa),Ka=function(t){function i(i,n){var e=t.call(this,n)||this;if(!i.url)throw new Error("NUDGE content missing `url`");return e.element=Va(e.urlModifier(i.url),n.onLoad,function(){return n.logger.error("Nudge iframe failed to load",{src:i.url})}),e}return fe(i,t),i}(Pa),Wa=function(t){function i(i,n){var e=t.call(this,n)||this;if(!i.campaignId)throw new Error("PROGRAM content missing `campaignId`");var r="".concat(e.config.allCampaignsMap.base,"/program/?campaignId=").concat(i.campaignId);return e.element=Va(e.urlModifier(r,{token:!0}),n.onLoad,function(){return n.logger.error("Program iframe failed to load",{src:r})}),e}return fe(i,t),i}(Pa),Xa=function(t){function i(i,n){var e=t.call(this,n)||this;if(!i.rewardUserId)throw new Error("REWARD content missing `rewardUserId`");var r="".concat(e.config.allCampaignsMap.base,"/reward/?rewardUserId=").concat(i.rewardUserId);return e.element=Va(e.urlModifier(r,{token:!0}),n.onLoad,function(){return n.logger.error("Reward iframe failed to load",{src:r})}),e}return fe(i,t),i}(Pa),Ya=function(t){function i(i,n){var e=t.call(this,n)||this;if(e.actionId=pa(),e.data=i,e.shouldGateOnCampaign()){var r=e.extractGatedCampaignId();return r&&e.config.allCampaignsMap.byId[r]&&e.createElement(),e}return e.createElement(),e}return fe(i,t),i.prototype.shouldGateOnCampaign=function(){var t,i,n,e=this.data.action;return!(!e||"TOGGLE_CONTAINER_CONTENT"!==e.type)&&("CAMPAIGN"===(null===(t=e.content)||void 0===t?void 0:t.typeId)&&void 0!==(null===(n=null===(i=e.content)||void 0===i?void 0:i.conditions)||void 0===n?void 0:n.campaignId))},i.prototype.extractGatedCampaignId=function(){var t,i;if("TOGGLE_CONTAINER_CONTENT"!==(null===(t=this.data.action)||void 0===t?void 0:t.type))return null;var n=null===(i=this.data.action.content.conditions)||void 0===i?void 0:i.campaignId;return"string"==typeof n?n:Array.isArray(n)&&void 0!==n[0]?String(n[0]):null},i.prototype.createElement=function(){var t=this;if(!this.data.src)throw new Error("STATIC content missing `src`");var i=document.createElement("img");i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.display="block",i.style.cursor="pointer";var n=this.config.onLoad;if(n){var e=performance.now();this.bindEvent(i,"load",function(){return n(performance.now()-e)},{once:!0})}this.bindEvent(i,"error",function(){return t.config.logger.error("Static image failed to load",{src:t.data.src})},{once:!0}),i.src=this.data.src,this.bindEvent(i,"click",function(i){i.stopPropagation(),i.preventDefault();var n=t.data.action;if(n&&t.sdkEventListener){var e={target:"GLU_SDK",action:"TOGGLE_CONTAINER_CONTENT"===n.type?le(le({},n),{id:t.actionId}):n};t.sdkEventListener(e)}}),this.element=i},i}(Pa),Qa=function(t){function i(i,n){var e=t.call(this,n)||this;return e.element=Va(e.urlModifier(e.config.allCampaignsMap.defaultUrl),n.onLoad,function(){return n.logger.error("Wallet iframe failed to load",{src:e.config.allCampaignsMap.defaultUrl})}),e}return fe(i,t),i}(Pa);var Ja=function(){function t(t,i){var n=this;this.sdkEventListener=null,this.closeListener=null,this.loaderTimeout=null,this.contentReady=!1,this.entryPoint=t,this.onOpen=i.onOpen;var e=le(le(le(le({},i),{isEmbedded:"EMBEDDED"===t.container.typeId}),void 0!==t.content.rootId&&{rootId:t.content.rootId}),{onLoad:function(t){var e;n.hideLoader(),null===(e=i.onLoad)||void 0===e||e.call(i,t)}});if(this.content=function(t,i){var n=t.content;switch(n.typeId){case"CAMPAIGN":return new Ba(n,i);case"WALLET":return new Qa(n,i);case"NUDGE":return new Ka(n,i);case"PROGRAM":return new Wa(n,i);case"REWARD":return new Xa(n,i);case"STATIC":return new Ya(n,i);case"DYNAMIC":return new za(n,i);case"DYNAMIC_MULTISTEP_1":return new ja(n,i);case"DYNAMIC_MULTISTEP_2":return new Ha(n,i);case"DYNAMIC_MULTISTEP_3":return new qa(n,i);case"ACCEPT_GUARD":return new Ga(n,i);default:var e=n.typeId;throw new Error("Unknown content typeId: ".concat(String(e)))}}(t,e),!this.content.element)throw new Error("Content ".concat(t.content.typeId," did not produce an element"));this.container=function(t,i,n,e,r){var s=t.container,o=le({typeId:s.typeId,css:s.css,logger:n,darkMode:e},void 0!==r&&{onShown:r});switch(s.typeId){case"ICON_BUTTON":return new Aa(o,i);case"CHAT_BOX":return new Ia(o,i);case"POP_UP":return new Ra(le(le({},o),{height:s.height}),i);case"BOTTOM_SHEET":return new _a(le(le({},o),{height:s.height}),i);case"NATIVE_BANNER":return new Ca(le(le({},o),{elementHookId:s.elementHookId}),i);case"EMBEDDED":return new Oa(le(le({},o),{elementHookId:s.elementHookId}),i);default:var u=s.typeId;throw new Error("Unknown container typeId: ".concat(String(u)))}}(t,this.content.element,i.logger,i.darkMode,function(){var t;return null===(t=n.onOpen)||void 0===t?void 0:t.call(n,n.entryPoint)}),this.content.listen(function(t){var i;return null===(i=n.sdkEventListener)||void 0===i?void 0:i.call(n,t)}),this.container.addCloseListener(function(){var t;return null===(t=n.closeListener)||void 0===t?void 0:t.call(n)})}return Object.defineProperty(t.prototype,"containerTypeId",{get:function(){return this.entryPoint.container.typeId},enumerable:!1,configurable:!0}),t.prototype.addEventListener=function(t){this.sdkEventListener=t},t.prototype.addCloseEventListener=function(t){this.closeListener=t},t.prototype.open=function(){var t=this;this.container.show(),this.contentReady||(this.container.showLoader(),this.clearLoaderTimeout(),this.loaderTimeout=setTimeout(function(){return t.hideLoader()},8e3))},t.prototype.preload=function(){this.container.preload()},t.prototype.close=function(){this.container.hide(),this.clearLoaderTimeout()},t.prototype.toggle=function(){this.isOpen()?this.close():this.open()},t.prototype.isOpen=function(){return this.container.isVisible()},t.prototype.sendMessage=function(t){this.content.sendMessageToContent(t)},t.prototype.sendRawMessage=function(t){this.content.sendRawMessage(t)},t.prototype.setHeight=function(t){this.container.setHeight(t)},t.prototype.hideLoader=function(){this.contentReady=!0,this.container.hideLoader(),this.content.reveal(),this.clearLoaderTimeout()},t.prototype.clearLoaderTimeout=function(){null!==this.loaderTimeout&&(clearTimeout(this.loaderTimeout),this.loaderTimeout=null)},t.prototype.destroy=function(){this.clearLoaderTimeout(),this.container.destroy(),this.content.destroy(),this.sdkEventListener=null,this.closeListener=null,this.onOpen=void 0},t}(),$a=function(){function t(){var t=this;this.windowToEmbed=new Map,this.listenerInstalled=!1,this.handleMessage=function(i){var n,e,r,s,o,u,a,c,h=i.source?t.windowToEmbed.get(i.source):void 0;if(h){var d=xa(i.data);if(d)switch(d.action.type){case"DIMENSIONS_UPDATE":var f=null!==(e=null===(n=d.action.data.data)||void 0===n?void 0:n.height)&&void 0!==e?e:d.action.data.height;"number"==typeof f&&ya(h.host,f);break;case"CLOSE":case"CLOSE_CONTAINER_CONTENT":t.removeEmbed(i.source,h);break;case"OPEN_DEEPLINK":t.handleOpenDeepLink(d.action.data,i.source,h);break;case"REQUEST_API_DATA":t.replyToEmbed(h.iframe,{eventName:"REQUEST_API_RESULT",data:{requestId:null!==(s=null===(r=d.action.data)||void 0===r?void 0:r.requestId)&&void 0!==s?s:""}});break;case"OPEN_WALLET":null===(u=null===(o=t.callbacks)||void 0===o?void 0:o.onOpenWallet)||void 0===u||u.call(o);break;case"OPEN_CG_WEBVIEW":null===(c=null===(a=t.callbacks)||void 0===a?void 0:a.onOpenCgWebView)||void 0===c||c.call(a,d.action.data)}}}}return t.prototype.render=function(t,i,n,e){var r,s;if("undefined"!=typeof document){this.callbacks=n,this.windowToEmbed.clear(),document.querySelectorAll("[data-glu-loyalty]").forEach(function(t){t.remove()});try{for(var o=ge(t),u=o.next();!u.done;u=o.next()){var a=u.value,c=document.getElementById(a.embedId);c&&this.injectIframe(c,this.buildUrl(a.url,i,e),a.embedId,n)}}catch(t){r={error:t}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}this.installMessageListener()}},t.prototype.buildUrl=function(t,i,n){var e=t,r=t.includes("?");return i&&(e+="".concat(r?"&":"?","capToken=").concat(encodeURIComponent(i)),r=!0),void 0!==n&&(e+="".concat(r?"&":"?","darkMode=").concat(n),r=!0),this.hasQueryParam(t,"isEmbedded")||(e+="".concat(r?"&":"?","isEmbedded=true")),e},t.prototype.hasQueryParam=function(t,i){var n,e;return(null!==(e=null===(n=t.split("?")[1])||void 0===n?void 0:n.split("#")[0])&&void 0!==e?e:"").split("&").some(function(t){var n;return(null===(n=t.split("=")[0])||void 0===n?void 0:n.toLowerCase())===i.toLowerCase()})},t.prototype.injectIframe=function(t,i,n,e){var r,s=document.createElement("iframe");s.src=i,s.setAttribute("data-glu-loyalty",n),s.style.cssText="border:none;width:100%;height:100%;opacity:0;transition:opacity 150ms ease;";var o=function(){s.style.opacity="1"},u=null==e?void 0:e.onLoad,a=performance.now();s.addEventListener("load",function(){o(),null==u||u(n,performance.now()-a)},{once:!0}),s.addEventListener("error",o,{once:!0}),t.appendChild(s),s.contentWindow&&this.windowToEmbed.set(s.contentWindow,{host:t,iframe:s,embedId:n}),null===(r=null==e?void 0:e.onOpen)||void 0===r||r.call(e,n)},t.prototype.installMessageListener=function(){this.listenerInstalled||"undefined"==typeof window||(this.listenerInstalled=!0,window.addEventListener("message",this.handleMessage))},t.prototype.handleOpenDeepLink=function(t,i,n){var e,r,s=Iu(t),o=s.deepLink,u=s.isHandledByCG,a=s.closeOnDeepLink;null===(r=null===(e=this.callbacks)||void 0===e?void 0:e.onDeepLinkEvent)||void 0===r||r.call(e,s),"true"===String(u).toLowerCase()&&"undefined"!=typeof window&&Au(o)&&(window.location.href=o),"true"===String(a).toLowerCase()&&this.removeEmbed(i,n)},t.prototype.removeEmbed=function(t,i){i.iframe.remove(),this.windowToEmbed.delete(t)},t.prototype.replyToEmbed=function(t,i){var n=t.contentWindow;if(n&&"function"==typeof n.postMessage&&t.src)try{n.postMessage(i,new URL(t.src).origin)}catch(t){}},t}(),Za=function(){function t(t,i,n,e,r,s){this.initialized=!1,this.userId=null,this.userAttributes=void 0,this.token=null,this.allCampaignsMap=null,this.entryPointMap=null,this.instances=new Map,this.dataDump=null,this.callback=null,this.lastSyncTimestamp=0,this.spaListenerCleanup=null,this.visibilityListenerCleanup=null,this.capToken=null,this.loyaltyRenderer=new $a,this.pagePathTrackingEnabled=!0,this.manualScreenName=null,this.pagePathTrackingExplicitlySet=!1,this.suppressed=!1,this.suppressedExplicitlySet=!1,this.theme="NONE",this.themeExplicitlySet=!1,this.tokenRefetchInFlight=null,this.authFailureCount=0,this.authBackoffUntil=0,this.pendingTimers=new Set,this.delayedOpenTimers=new Map,this.pendingShownRecordIds=new Set,this.openedCampaignIds=new Set,this.initGeneration=0,this.syncGeneration=0,this.preconnectedOrigins=new Set,this.swPreloaded=!1,this.trackingState=new Map,this.eventEntryPointMap=new Map,this.campaignQueue=new ta,this.openOverlayEntryPointId=null,this.openOverlayIds=new Set,this.ephemeralEntryPointIds=new Set,this.adHocEntryPointIds=new Set,this.adHocToggleSourceEmbedId=new Map,this.writeKey=t,this.logger=n,this.storageManager=e,this.apiClient=new mu(i,n),this.trackEvent=r,this.getSessionId=s}return t.prototype.initialize=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o,u,a,c,h,d,f,l,v,m,g,p,w,y,E;return me(this,function(_){switch(_.label){case 0:this.initialized&&(this.logger.info("GamificationManager re-initializing for new user",{userId:t}),this.clean()),this.logger.info("GamificationManager initializing",{userId:t}),n=++this.initGeneration,_.label=1;case 1:return _.trys.push([1,8,,9]),this.userId=t,this.userAttributes=i,this.preconnectFromCachedOrigin(),[4,Promise.all([this.storageManager.get(nu),this.loadFromCache(t)])];case 2:return e=pe.apply(void 0,[_.sent(),2]),r=e[0],s=e[1],n!==this.initGeneration?[2]:(r&&(this.capToken=r),s?(this.logger.info(Zs,{campaigns:null!==(a=null===(u=this.allCampaignsMap)||void 0===u?void 0:u.allIds.length)&&void 0!==a?a:0,entryPoints:null!==(h=null===(c=this.entryPointMap)||void 0===c?void 0:c.allIds.length)&&void 0!==h?h:0}),[3,5]):[3,3]);case 3:return this.logger.info(to),[4,this.fetchAndCache(t,i,n)];case 4:if(!_.sent())return[2];_.label=5;case 5:return this.entryPointMap&&(null===(f=null===(d=this.callback)||void 0===d?void 0:d.onEntryPointsLoaded)||void 0===f||f.call(d,Object.values(this.entryPointMap.byId))),this.preloadEntryPoints(),this.initialized=!0,this.logger.info(qs,{campaigns:null!==(v=null===(l=this.allCampaignsMap)||void 0===l?void 0:l.allIds.length)&&void 0!==v?v:0,entryPoints:null!==(g=null===(m=this.entryPointMap)||void 0===m?void 0:m.allIds.length)&&void 0!==g?g:0}),null===(w=null===(p=this.callback)||void 0===p?void 0:p.onInitSuccess)||void 0===w||w.call(p),[4,this.restorePersistedActionEventQueue(t)];case 6:return _.sent(),n!==this.initGeneration?[2]:[4,this.refresh()];case 7:return _.sent(),n!==this.initGeneration?[2]:(this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks(),this.resolveDarkMode()),this.registerSpaListener(),this.registerVisibilityListener(),[3,9]);case 8:return o=_.sent(),this.logger.error(Ks,o),null===(E=null===(y=this.callback)||void 0===y?void 0:y.onInitFailure)||void 0===E||E.call(y,{code:Pe,message:Ks,cause:o}),[3,9];case 9:return[2]}})})},t.prototype.getCampaignsMap=function(){return this.allCampaignsMap},t.prototype.getEntryPointMap=function(){return this.entryPointMap},t.prototype.getToken=function(){return this.token},t.prototype.setCapToken=function(t){this.capToken=t,this.storageManager.set(nu,t).catch(function(){}),this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks(),this.resolveDarkMode())},t.prototype.getCapToken=function(){return this.capToken},t.prototype.enablePagePathTracking=function(t){this.logger.info("Page path tracking mode changed",{enabled:t}),this.pagePathTrackingEnabled=t,this.pagePathTrackingExplicitlySet=!0,this.storageManager.set(eu,String(t)).catch(function(){}),this.refresh()},t.prototype.restorePersistedPagePathTracking=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:return[4,this.storageManager.get(eu)];case 1:return null===(t=i.sent())||this.pagePathTrackingExplicitlySet||(this.pagePathTrackingEnabled="true"===t),[2]}})})},t.prototype.onScreenChanged=function(t){this.manualScreenName=t,this.pagePathTrackingEnabled||this.handleScreenChange()},t.prototype.setGamificationCallback=function(t){this.callback=t},t.prototype.setGamificationSuppressed=function(t){var i=this,n=this.suppressed;this.logger.info("Gamification suppression changed",{suppressed:t}),this.suppressed=t,this.suppressedExplicitlySet=!0,this.storageManager.set(ru,String(t)).catch(function(t){i.logger.error(uo,{error:t})}),n&&!t?this.refresh():!n&&t&&this.closeSuppressedInstances()},t.prototype.closeSuppressedInstances=function(){var t,i;try{for(var n=ge(this.instances.values()),e=n.next();!e.done;e=n.next()){var r=e.value;r.isOpen()&&this.isEffectivelySuppressed(r.entryPoint)&&this.closeIfOpen(r.entryPoint)}}catch(i){t={error:i}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}this.closeAdHocEntryPoints()},t.prototype.isContentOpenSuppressed=function(t){return!!this.isEffectivelySuppressed(t)&&(this.logger.debug(ao,{entryPointId:t.id,containerTypeId:t.container.typeId}),!0)},t.prototype.isGamificationSuppressed=function(){return this.suppressed},t.prototype.restorePersistedGamificationSuppressed=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:return[4,this.storageManager.get(ru)];case 1:return null===(t=i.sent())||this.suppressedExplicitlySet||(this.suppressed="true"===t),[2]}})})},t.prototype.setTheme=function(i){var n=this;t.VALID_THEMES.includes(i)?(this.logger.info("Gamification theme changed",{theme:i}),this.theme=i,this.themeExplicitlySet=!0,this.storageManager.set(su,i).catch(function(t){n.logger.error(co,{error:t})}),this.invalidateUnopenedInstances(),this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks(),this.resolveDarkMode())):this.logger.warn("Invalid theme value, ignoring",{theme:i})},t.prototype.invalidateUnopenedInstances=function(){var t,i,n,e,r,s=[];try{for(var o=ge(this.instances),u=o.next();!u.done;u=o.next()){var a=pe(u.value,2),c=a[0],h=a[1],d=!!(v=null===(r=this.entryPointMap)||void 0===r?void 0:r.byId[c])&&Eu(v);h.isOpen()&&!d||(d&&h.isOpen()&&v&&!this.isCampaignCompleted(v)&&s.push(v),h.destroy(),this.instances.delete(c))}}catch(i){t={error:i}}finally{try{u&&!u.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}this.preloadEntryPoints();try{for(var f=ge(s),l=f.next();!l.done;l=f.next()){var v=l.value;this.openInstance(v)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(e=f.return)&&e.call(f)}finally{if(n)throw n.error}}},t.prototype.restorePersistedTheme=function(){return ve(this,void 0,void 0,function(){var i;return me(this,function(n){switch(n.label){case 0:return[4,this.storageManager.get(su)];case 1:return null!==(i=n.sent())&&!this.themeExplicitlySet&&t.VALID_THEMES.includes(i)&&(this.theme=i),[2]}})})},t.prototype.resolveDarkMode=function(){switch(this.theme){case"LIGHT":return!1;case"DARK":return!0;case"AUTO":return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;default:return}},t.prototype.openEntryPoint=function(t){if(this.initialized){var i=this.getOrCreateInstance(t);i?(ku(i.entryPoint)&&this.openOverlayIds.add(t),i.open()):this.logger.error("openEntryPoint() could not resolve an entry point instance",{entryPointId:t})}else this.logger.error("openEntryPoint() called before GamificationManager is initialized",{entryPointId:t})},t.prototype.closeEntryPoint=function(t){if(this.initialized){var i=this.instances.get(t);i||this.logger.warn("closeEntryPoint() found no open instance for this entry point",{entryPointId:t}),null==i||i.close(),this.onCampaignClosed(t)}else this.logger.warn("closeEntryPoint() called before GamificationManager is initialized",{entryPointId:t})},t.prototype.forceSync=function(){var t=this;return this.initialized?this.resyncData().then(function(){t.refresh()}):(this.logger.error("forceSync() called before GamificationManager is initialized"),Promise.resolve())},t.prototype.clean=function(){var t,i,n,e,r,s;this.logger.info(Xs),this.initGeneration++,this.syncGeneration++,null===(r=this.spaListenerCleanup)||void 0===r||r.call(this),this.spaListenerCleanup=null,null===(s=this.visibilityListenerCleanup)||void 0===s||s.call(this),this.visibilityListenerCleanup=null,this.lastSyncTimestamp=0;try{for(var o=ge(this.pendingTimers),u=o.next();!u.done;u=o.next()){var a=u.value;clearTimeout(a)}}catch(i){t={error:i}}finally{try{u&&!u.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}this.pendingTimers.clear(),this.delayedOpenTimers.clear(),this.pendingShownRecordIds.clear(),this.openedCampaignIds.clear();try{for(var c=ge(this.instances.values()),h=c.next();!h.done;h=c.next()){var d=h.value;d.isOpen()&&d.close(),d.destroy()}}catch(t){n={error:t}}finally{try{h&&!h.done&&(e=c.return)&&e.call(c)}finally{if(n)throw n.error}}this.instances.clear(),this.trackingState.clear(),this.eventEntryPointMap.clear(),this.campaignQueue.clear(),this.openOverlayEntryPointId=null,this.openOverlayIds.clear(),this.ephemeralEntryPointIds.clear(),this.adHocEntryPointIds.clear(),this.adHocToggleSourceEmbedId.clear(),this.userId&&(this.storageManager.remove(this.cacheKey(this.userId)).catch(function(){}),this.storageManager.remove(this.tokenCacheKey(this.userId)).catch(function(){}),this.storageManager.remove(this.queueStorageKey(this.userId)).catch(function(){})),this.userId=null,this.userAttributes=void 0,this.token=null,this.tokenRefetchInFlight=null,this.authFailureCount=0,this.authBackoffUntil=0,this.allCampaignsMap=null,this.entryPointMap=null,this.dataDump=null,this.capToken=null,this.storageManager.remove(nu).catch(function(){}),this.initialized=!1},t.prototype.destroy=function(){this.clean(),this.logger.info(Ws)},Object.defineProperty(t.prototype,"loyaltyUrls",{get:function(){var t,i;return null!==(i=null===(t=this.allCampaignsMap)||void 0===t?void 0:t.loyaltyUrls)&&void 0!==i?i:[]},enumerable:!1,configurable:!0}),t.prototype.resolveCurrentPath=function(){var t;return this.pagePathTrackingEnabled?"undefined"!=typeof window?window.location.href:"":null!==(t=this.manualScreenName)&&void 0!==t?t:""},t.prototype.refresh=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c,h,d;return me(this,function(f){switch(f.label){case 0:if(!this.entryPointMap)return[2];t=this.resolveCurrentPath(),this.logger.info(Qs,{entryPoints:this.entryPointMap.allIds.length,url:t}),this.campaignQueue.clearScreenTriggered(),i={},n={},e=this.entryPointMap,r=this.initGeneration,f.label=1;case 1:f.trys.push([1,6,7,8]),s=ge(this.orderedEntryPointIds(e)),o=s.next(),f.label=2;case 2:return o.done?[3,5]:(u=o.value,r!==this.initGeneration?[2]:!(a=e.byId[u])||Tu(a)?[3,4]:[4,this.refreshEntryPoint(a,i,n)]);case 3:f.sent(),f.label=4;case 4:return o=s.next(),[3,2];case 5:return[3,8];case 6:return c=f.sent(),h={error:c},[3,8];case 7:try{o&&!o.done&&(d=s.return)&&d.call(s)}finally{if(h)throw h.error}return[7];case 8:return this.showNextFromQueue(),[2]}})})},t.prototype.orderedEntryPointIds=function(t){var i=function(i){var n=t.byId[i];return n&&Eu(n)?n.container.elementHookId:null};return we([],pe(t.allIds),!1).sort(function(n,e){var r,s,o,u,a,c,h=i(n),d=i(e);if(!h||!d||h!==d)return 0;var f=t.byId[n],l=t.byId[e],v=(null!==(s=null===(r=null==l?void 0:l.conditions)||void 0===r?void 0:r.priority)&&void 0!==s?s:0)-(null!==(u=null===(o=null==f?void 0:f.conditions)||void 0===o?void 0:o.priority)&&void 0!==u?u:0);return 0!==v?v:(null!==(a=null==l?void 0:l.createdAt)&&void 0!==a?a:"").localeCompare(null!==(c=null==f?void 0:f.createdAt)&&void 0!==c?c:"")})},t.prototype.refreshEntryPoint=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o,u;return me(this,function(a){switch(a.label){case 0:return e=ku(t),r=null===(u=t.conditions)||void 0===u?void 0:u.singleOpenName,!e&&r&&i[r]?[2]:(s=Eu(t)?t.container.elementHookId:null)&&n[s]?[2]:!Tu(t)&&this.isCampaignCompleted(t)?(this.closeIfOpen(t),[2]):[4,this.isDismissedThisSession(t)];case 1:return a.sent()?(this.cancelDelayedOpen(t.id),[2]):(o=this.isEffectivelySuppressed(t),[4,Zu(t,this.userId,this.storageManager,this.logger,this.resolveCurrentPath())]);case 2:return a.sent()?(o||(!e&&r&&(i[r]=!0),s&&(n[s]=!0),this.scheduleOpenOrEnqueue(t,e)),[2]):(this.closeIfOpen(t),[2])}})})},t.prototype.isEffectivelySuppressed=function(t){return this.suppressed&&!Eu(t)},t.prototype.scheduleOpenOrEnqueue=function(t,i){var n,e=this,r=null===(n=t.conditions)||void 0===n?void 0:n.delay;if(r){this.cancelDelayedOpen(t.id);var s=setTimeout(function(){e.pendingTimers.delete(s),e.delayedOpenTimers.delete(t.id),e.fireDelayedOpen(t.id)},1e3*r);this.pendingTimers.add(s),this.delayedOpenTimers.set(t.id,s)}else this.openOrEnqueue(t,i)},t.prototype.cancelDelayedOpen=function(t){var i=this.delayedOpenTimers.get(t);void 0!==i&&(clearTimeout(i),this.pendingTimers.delete(i),this.delayedOpenTimers.delete(t))},t.prototype.fireDelayedOpen=function(t){return ve(this,void 0,void 0,function(){var i,n,e;return me(this,function(r){switch(r.label){case 0:return(i=null===(e=this.entryPointMap)||void 0===e?void 0:e.byId[t])?!Tu(i)&&this.isCampaignCompleted(i)?[2]:[4,this.isDismissedThisSession(i)]:[2];case 1:return r.sent()||this.isEffectivelySuppressed(i)?[2]:[4,Zu(i,this.userId,this.storageManager,this.logger,this.resolveCurrentPath())];case 2:return r.sent()?(n=ku(i),this.openOrEnqueue(i,n),n&&this.showNextFromQueue(),[2]):[2]}})})},t.prototype.openOrEnqueue=function(t,i){if(!i){if(this.isEffectivelySuppressed(t))return;var n=this.instances.get(t.id);if(null==n?void 0:n.isOpen())return;var e=this.getOrCreateInstance(t.id);if(!e)return;return this.recordEntryPointShownIfEligible(t),void e.open()}this.openOverlayEntryPointId!==t.id&&this.enqueueCampaign(t)},t.prototype.closeIfOpen=function(t){this.cancelDelayedOpen(t.id);var i=this.instances.get(t.id);(null==i?void 0:i.isOpen())&&i.close(),this.onCampaignClosed(t.id)},t.prototype.openInstance=function(t){var i=this.getOrCreateInstance(t.id);i&&(ku(t)&&this.openOverlayIds.add(t.id),i.open())},t.prototype.notifyCampaignOpened=function(t){var i,n,e=Cu(t);!e&&this.ephemeralEntryPointIds.has(t.id)||(this.openedCampaignIds.add(t.id),null===(n=null===(i=this.callback)||void 0===i?void 0:i.onCampaignOpened)||void 0===n||n.call(i,null!=e?e:t.id))},t.prototype.enqueueCampaign=function(t){this.campaignQueue.enqueue([t]),this.persistActionEventQueue()},t.prototype.showNextFromQueue=function(){var t,i;if(!(this.openOverlayIds.size>0||this.suppressed))try{for(var n=ge(this.campaignQueue.entries()),e=n.next();!e.done;e=n.next()){var r=e.value,s=this.getOrCreateInstance(r.id);if(s)return this.campaignQueue.remove(r.id),this.openOverlayEntryPointId=r.id,this.openOverlayIds.add(r.id),this.persistActionEventQueue(),this.recordEntryPointShownIfEligible(r),void s.open()}}catch(i){t={error:i}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}},t.prototype.recordEntryPointShownIfEligible=function(t){this.isEffectivelySuppressed(t)||(!Eu(t)||function(t){return"undefined"!=typeof document&&null!==document.querySelector("#".concat(t.container.elementHookId))}(t)?this.persistEntryPointShown(t):this.pendingShownRecordIds.add(t.id))},t.prototype.recordPendingShownIfAny=function(t){this.pendingShownRecordIds.delete(t.id)&&this.persistEntryPointShown(t)},t.prototype.persistEntryPointShown=function(t){var i=this;(function(t,i,n,e){return ve(this,void 0,void 0,function(){var r,s,o,u,a,c;return me(this,function(h){switch(h.label){case 0:return Tu(t)?[2]:(r=null===(c=t.conditions)||void 0===c?void 0:c.showCount)?(s=new Date,[4,Xu(t.id,i,n,e)]):[2];case 1:o=h.sent(),u=!r.dailyRefresh||o&&Yu(s,new Date(o.date))?{count:o?o.count+1:1,date:s.toISOString()}:{count:1,date:s.toISOString()},h.label=2;case 2:return h.trys.push([2,4,,5]),[4,n.set(Wu(t.id,i),JSON.stringify(u))];case 3:return h.sent(),[3,5];case 4:return a=h.sent(),e.error(So,{entryPointId:t.id,error:a}),[3,5];case 5:return[2]}})})})(t,this.userId,this.storageManager,this.logger).catch(function(n){i.logger.error(So,{entryPointId:t.id,error:n})})},t.prototype.onCampaignClosed=function(t){var i,n,e,r;if(this.openOverlayIds.delete(t),this.openedCampaignIds.delete(t)){var s=null===(i=this.entryPointMap)||void 0===i?void 0:i.byId[t];null===(e=null===(n=this.callback)||void 0===n?void 0:n.onCampaignClosed)||void 0===e||e.call(n,s&&null!==(r=Cu(s))&&void 0!==r?r:t)}this.openOverlayEntryPointId===t&&(this.openOverlayEntryPointId=null),0===this.openOverlayIds.size&&this.showNextFromQueue()},t.prototype.sessionDismissedKeyPrefix=function(t,i){return"".concat(Xo).concat(t,"_").concat(i,"_")},t.prototype.sessionDismissedKey=function(t,i,n){return"".concat(this.sessionDismissedKeyPrefix(t,i)).concat(n)},t.prototype.isDismissedThisSession=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s;return me(this,function(o){switch(o.label){case 0:if(Eu(t)||Tu(t))return[2,!1];if(!(i=this.getSessionId())||!this.userId)return[2,!1];o.label=1;case 1:return o.trys.push([1,3,,4]),n=this.sessionDismissedKey(this.userId,t.id,this.resolveCurrentPath()),[4,this.storageManager.get(n)];case 2:return(e=o.sent())?[2,"object"==typeof(r=JSON.parse(e))&&null!==r&&r.sessionId===i]:[2,!1];case 3:return s=o.sent(),this.logger.error(ho,{entryPointId:t.id,error:s}),[2,!1];case 4:return[2]}})})},t.prototype.recordSessionDismissal=function(t){var i,n=this,e=null===(i=this.entryPointMap)||void 0===i?void 0:i.byId[t];if(e&&!Eu(e)&&!Tu(e)){var r=this.getSessionId();if(r&&this.userId){var s=this.sessionDismissedKey(this.userId,t,this.resolveCurrentPath());this.storageManager.set(s,JSON.stringify({sessionId:r})).catch(function(i){n.logger.error(fo,{entryPointId:t,error:i})})}}},t.prototype.queueStorageKey=function(t){return Wo+t},t.prototype.persistActionEventQueue=function(){var t=this;if(this.userId){var i=this.campaignQueue.entries().filter(function(t){return Tu(t)}).map(function(t){return t.id}),n=this.queueStorageKey(this.userId);0!==i.length?this.storageManager.set(n,JSON.stringify(i)).catch(function(i){t.logger.error(lo,{error:i})}):this.storageManager.remove(n).catch(function(){})}},t.prototype.restorePersistedActionEventQueue=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a,c,h;return me(this,function(d){switch(d.label){case 0:if(!this.entryPointMap)return[2];d.label=1;case 1:return d.trys.push([1,11,,12]),[4,this.storageManager.get(this.queueStorageKey(t))];case 2:if(!(i=d.sent()))return[2];if(n=JSON.parse(i),!Array.isArray(n))return[2];d.label=3;case 3:d.trys.push([3,8,9,10]),e=ge(n),r=e.next(),d.label=4;case 4:return r.done?[3,7]:"string"!=typeof(s=r.value)?[3,6]:(o=this.entryPointMap.byId[s])&&Tu(o)?[4,Zu(o,this.userId,this.storageManager,this.logger,this.resolveCurrentPath())]:[3,6];case 5:d.sent()&&this.campaignQueue.enqueue([o]),d.label=6;case 6:return r=e.next(),[3,4];case 7:return[3,10];case 8:return u=d.sent(),c={error:u},[3,10];case 9:try{r&&!r.done&&(h=e.return)&&h.call(e)}finally{if(c)throw c.error}return[7];case 10:return this.persistActionEventQueue(),[3,12];case 11:return a=d.sent(),this.logger.error(vo,{error:a}),[3,12];case 12:return[2]}})})},t.prototype.buildEventIndex=function(){var t,i,n;if(this.eventEntryPointMap.clear(),this.entryPointMap){this.entryPointMap.allIds.includes("")&&this.logger.error(mo,{totalEntryPoints:this.entryPointMap.allIds.length});try{for(var e=ge(this.entryPointMap.allIds),r=e.next();!r.done;r=e.next()){var s=r.value,o=this.entryPointMap.byId[s],u=o?Nu(o):null;if(u){var a=null!==(n=this.eventEntryPointMap.get(u))&&void 0!==n?n:new Set;a.add(s),this.eventEntryPointMap.set(u,a)}}}catch(i){t={error:i}}finally{try{r&&!r.done&&(i=e.return)&&i.call(e)}finally{if(t)throw t.error}}}},t.prototype.handleActionEvent=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a,c,h,d,f,l;return me(this,function(v){switch(v.label){case 0:if(!this.initialized||!t||!this.entryPointMap)return[2];if(!(i=this.eventEntryPointMap.get(t))||0===i.size)return null===(l=null===(f=this.callback)||void 0===f?void 0:f.onGameEventTrigger)||void 0===l||l.call(f,t,{reason:Oo}),[2];v.label=1;case 1:v.trys.push([1,10,,11]),n={},e={},v.label=2;case 2:v.trys.push([2,7,8,9]),r=ge(i),s=r.next(),v.label=3;case 3:return s.done?[3,6]:(o=s.value,(u=this.entryPointMap.byId[o])?[4,this.refreshEntryPoint(u,n,e)]:[3,5]);case 4:v.sent(),v.label=5;case 5:return s=r.next(),[3,3];case 6:return[3,9];case 7:return a=v.sent(),h={error:a},[3,9];case 8:try{s&&!s.done&&(d=r.return)&&d.call(r)}finally{if(h)throw h.error}return[7];case 9:return this.showNextFromQueue(),[3,11];case 10:return c=v.sent(),this.logger.error(oo,{eventName:t,error:c}),[3,11];case 11:return[2]}})})},t.prototype.preloadEntryPoints=function(){var t,i,n;if(this.entryPointMap){this.preconnectToCampaignOrigin(),this.preloadServiceWorker();var e=this.resolveCurrentPath();try{for(var r=ge(this.entryPointMap.allIds),s=r.next();!s.done;s=r.next()){var o=s.value;if(!this.instances.has(o)){var u=this.entryPointMap.byId[o];if(u&&(Tu(u)||!this.isCampaignCompleted(u))&&(Tu(u)||Qu(null===(n=u.conditions)||void 0===n?void 0:n.paths,e))){var a=this.getOrCreateInstance(o);null==a||a.preload()}}}}catch(i){t={error:i}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}}},t.prototype.preconnectToCampaignOrigin=function(t){var i,n=null!=t?t:null===(i=this.allCampaignsMap)||void 0===i?void 0:i.base;if("undefined"!=typeof document&&n&&!this.preconnectedOrigins.has(n)){this.preconnectedOrigins.add(n);var e=document.createElement("link");e.rel="preconnect",e.href=n,document.head.appendChild(e)}},t.prototype.preconnectFromCachedOrigin=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.storageManager.get(au)];case 1:return(t=i.sent())&&this.preconnectToCampaignOrigin(t),[3,3];case 2:return i.sent(),[3,3];case 3:return[2]}})})},t.prototype.preloadServiceWorker=function(){var t,i=this;if("undefined"!=typeof document&&(null===(t=this.allCampaignsMap)||void 0===t?void 0:t.base)&&!this.swPreloaded){this.swPreloaded=!0;var n="".concat(this.allCampaignsMap.base).concat(ou),e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.style.cssText="position:absolute;left:-9999px;top:-9999px;width:1px;height:1px;border:0;",e.setAttribute("fetchpriority","low");var r=function(){e.remove(),clearTimeout(s),i.pendingTimers.delete(s)};e.addEventListener("load",function(){return r()},{once:!0});var s=setTimeout(function(){return r()},uu);this.pendingTimers.add(s),e.src=n,document.body.appendChild(e)}},t.prototype.getOrCreateInstance=function(t){var i,n=this,e=this.instances.get(t);if(e)return e;var r=null===(i=this.entryPointMap)||void 0===i?void 0:i.byId[t];if(!(r&&this.token&&this.allCampaignsMap&&this.userId))return this.logger.error("getOrCreateInstance() precondition not met, cannot open entry point",{entryPointId:t,hasEntryPoint:!!r,hasToken:!!this.token,hasAllCampaignsMap:!!this.allCampaignsMap,hasUserId:!!this.userId}),null;var s=this.token,o=this.userId;try{var u=function(){var i,e;return null!==(e=null===(i=n.entryPointMap)||void 0===i?void 0:i.byId[t])&&void 0!==e?e:r};this.resetDisplayTracking(t);var a=new Ja(r,{userId:o,token:s,darkMode:this.resolveDarkMode(),allCampaignsMap:this.allCampaignsMap,logger:this.logger,onOpen:function(){var t=u();n.recordPendingShownIfAny(t),n.trackEntryPointOpen(t),n.notifyCampaignOpened(t)},onLoad:function(t){return n.trackEntryPointLoaded(u(),t)}});return a.addEventListener(function(i){return n.handleSdkEvent(i,t)}),a.addCloseEventListener(function(){a.close(),n.recordSessionDismissal(t),n.onCampaignClosed(t)}),this.instances.set(t,a),a}catch(i){return this.logger.error(go,{entryPointId:t,error:i}),null}},t.prototype.trackEntryPointOpen=function(t){var i,n,e,r=this,s=yu(t);if(s&&this.userId){if(this.markOpened(t.id),"game"===s){this.getOrCreateTrackingState(t.id).completionFired=!1;var o=Cu(t),u={campaign_id:o,game_type:this.lookupGameType(o),entry_surface:null!==(i=pu(t))&&void 0!==i?i:"",embed_id:null!==(n=this.adHocToggleSourceEmbedId.get(t.id))&&void 0!==n?n:t.container.elementHookId,entry_point_id:this.resolveTrackingEntryPointId(t,o),entry_point_location:"undefined"!=typeof window?window.location.href:""};this.trackEvent(Ao,u)}else{u={page_id:t.container.elementHookId,content_surface:null!==(e=pu(t))&&void 0!==e?e:""};this.trackEvent(Mo,u)}this.fireViewedIfReady(t.id,function(i){return r.buildViewedAttributes(t,s,i)},s)}},t.prototype.trackEntryPointLoaded=function(t,i){var n=this;this.logger.debug("Campaign iframe loaded in ".concat(i.toFixed(2),"ms"),{entryPointId:t.id,campaignId:Cu(t)});var e=yu(t);e&&(this.markLoaded(t.id,i),this.fireViewedIfReady(t.id,function(i){return n.buildViewedAttributes(t,e,i)},e))},t.prototype.buildViewedAttributes=function(t,i,n){var e;if("game"===i){var r=Cu(t);return{campaign_id:r,game_type:this.lookupGameType(r),load_time_ms:_u(n)}}return{page_id:t.container.elementHookId,content_surface:null!==(e=pu(t))&&void 0!==e?e:"",load_time_ms:_u(n)}},t.prototype.lookupGameType=function(t){var i,n,e;return t&&null!==(e=null===(n=null===(i=this.allCampaignsMap)||void 0===i?void 0:i.byId[t])||void 0===n?void 0:n.type)&&void 0!==e?e:null},t.prototype.resolveTrackingEntryPointId=function(t,i){var n;if(!this.ephemeralEntryPointIds.has(t.id)||!i||!this.entryPointMap)return t.id;var e=this.entryPointMap,r=e.allIds.map(function(t){return e.byId[t]}).find(function(n){return void 0!==n&&n.id!==t.id&&Cu(n)===i});return null!==(n=null==r?void 0:r.id)&&void 0!==n?n:t.id},t.prototype.handleInboundAnalyticsEvent=function(t,i){if(this.matchesAnalyticsEventName(t,ko))return this.trackGamePlayed(i),void this.trackRewardSeenIfPresent(t,i);if(this.matchesAnalyticsEventName(t,Do)){var n=this.getOrCreateTrackingState(i),e=n.completionFired;return n.completionFired=!0,e||this.trackGameCompleted(i),void this.trackRewardSeenIfPresent(t,i)}this.trackRewardSeenIfPresent(t,i)},t.prototype.matchesAnalyticsEventName=function(t,i){return"object"==typeof t&&null!==t&&t[Jo.EVENT_NAME]===i},t.prototype.trackGamePlayed=function(t){var i,n=null===(i=this.instances.get(t))||void 0===i?void 0:i.entryPoint;if(n&&wu(n.content)&&this.userId){var e=this.getOrCreateTrackingState(t);e.playedAt=Date.now(),e.completionFired=!1;var r=Cu(n),s={campaign_id:r,game_type:this.lookupGameType(r)};this.trackEvent(Ro,s)}},t.prototype.trackGameCompleted=function(t){var i,n,e=null===(i=this.instances.get(t))||void 0===i?void 0:i.entryPoint;if(e&&wu(e.content)&&this.userId){var r=null===(n=this.trackingState.get(t))||void 0===n?void 0:n.playedAt,s=void 0!==r?Date.now()-r:0,o=Cu(e),u={campaign_id:o,game_type:this.lookupGameType(o),total_time_ms:_u(s)};this.trackEvent(xo,u)}},t.prototype.trackRewardSeenIfPresent=function(t,i){if("object"==typeof t&&null!==t){var n=t[Jo.CAMPAIGN_DETAILS];if("object"==typeof n&&null!==n){var e=n,r=e[Jo.REWARD_STATUS];"string"==typeof r&&r.split("-").includes("SEEN")&&this.trackRewardSeen(e,i)}}},t.prototype.trackRewardSeen=function(t,i){if(this.userId){var n=this.readStringField(t,Jo.REWARD_USER_ID),e=this.getOrCreateTrackingState(i);if(null===n||n!==e.lastRewardUserId){e.lastRewardUserId=n;var r={reward_id:n,campaign_id:this.readStringField(t,Jo.CAMPAIGN_ID),reward_type:this.readStringField(t,Jo.REWARD_TYPE)};this.trackEvent(Po,r)}}},t.prototype.readStringField=function(t,i){var n=t[i];return void 0===n?null:"string"==typeof n?n:(this.logger.warn(po,{field:i,value:n}),null)},t.prototype.trackLoyaltyOpen=function(t){var i=this;if(this.userId){var n=this.loyaltyStateKey(t);this.trackingState.set(n,{opened:!0,viewedFired:!1});var e={page_id:t,content_surface:Lo};this.trackEvent(Mo,e),this.fireViewedIfReady(n,function(n){return i.buildLoyaltyViewedAttributes(t,n)},"content")}},t.prototype.trackLoyaltyLoaded=function(t,i){var n=this,e=this.loyaltyStateKey(t);this.markLoaded(e,i),this.fireViewedIfReady(e,function(i){return n.buildLoyaltyViewedAttributes(t,i)},"content")},t.prototype.buildLoyaltyViewedAttributes=function(t,i){return{page_id:t,content_surface:Lo,load_time_ms:_u(i)}},t.prototype.loyaltyStateKey=function(t){return"loyalty:".concat(t)},t.prototype.loyaltyCallbacks=function(){var i=this;return{onOpen:function(t){return i.trackLoyaltyOpen(t)},onLoad:function(t,n){return i.trackLoyaltyLoaded(t,n)},onDeepLinkEvent:function(t){var n,e;return null===(e=null===(n=i.callback)||void 0===n?void 0:n.onDeepLinkEvent)||void 0===e?void 0:e.call(n,t)},onOpenWallet:function(){return i.handleOpenWallet()},onOpenCgWebView:function(n){return i.handleOpenCgWebView(n,t.LOYALTY_SOURCE_ID)}}},t.prototype.markOpened=function(t){var i=this.getOrCreateTrackingState(t);i.opened=!0,i.viewedFired=!1},t.prototype.resetDisplayTracking=function(t){var i=this.trackingState.get(t);i&&(i.opened=!1,i.viewedFired=!1,delete i.loadTimeMs)},t.prototype.markLoaded=function(t,i){this.getOrCreateTrackingState(t).loadTimeMs=i},t.prototype.getOrCreateTrackingState=function(t){var i=this.trackingState.get(t);return i||(i={opened:!1,viewedFired:!1},this.trackingState.set(t,i)),i},t.prototype.fireViewedIfReady=function(t,i,n){var e=this.trackingState.get(t);e&&!e.viewedFired&&e.opened&&void 0!==e.loadTimeMs&&this.userId&&(e.viewedFired=!0,this.trackEvent("game"===n?Co:Uo,i(e.loadTimeMs)))},t.prototype.handleSdkEvent=function(t,i){var n,e,r,s,o,u,a,c,h,d,f,l,v,m,g,p;if(this.initialized&&t&&"GLU_SDK"===t.target&&t.action){var w=t.action;switch(w.type){case"TOGGLE_CONTAINER_CONTENT":this.handleToggle(w,i);break;case"OPEN_CONTAINER_CONTENT":this.handleOpen(w);break;case"CLOSE_CONTAINER_CONTENT":case"CLOSE":this.handleClose(w,i);break;case"REQUEST_STATE":null===(e=this.instances.get(i))||void 0===e||e.sendMessage({type:"UPDATE_CONTENT_STATE",data:null!==(r=this.dataDump)&&void 0!==r?r:{}});break;case"LOGIN":this.handleLogin(w);break;case"REDIRECT":this.handleRedirect(w);break;case"ANALYTICS":null===(o=null===(s=this.callback)||void 0===s?void 0:s.onAnalyticsEvent)||void 0===o||o.call(s,w.data),this.handleInboundAnalyticsEvent(w.data,i);break;case"REFRESH":this.refresh();break;case"UPDATE_CONTENT_STATE":break;case"OPEN_DEEPLINK":this.handleOpenDeepLink(w,i);break;case"DIMENSIONS_UPDATE":null===(u=this.instances.get(i))||void 0===u||u.setHeight(null!==(c=null===(a=w.data.data)||void 0===a?void 0:a.height)&&void 0!==c?c:w.data.height);break;case"HIDE_LOADER":null===(h=this.instances.get(i))||void 0===h||h.hideLoader();break;case"REQUEST_API_DATA":null===(d=this.instances.get(i))||void 0===d||d.sendRawMessage({eventName:"REQUEST_API_RESULT",data:{requestId:null!==(l=null===(f=w.data)||void 0===f?void 0:f.requestId)&&void 0!==l?l:""}});break;case"REFRESH_API_DATA":null===(v=this.instances.get(i))||void 0===v||v.sendRawMessage({eventName:"REFRESH_API_DATA_RESULT",data:{requestId:null!==(g=null===(m=w.data)||void 0===m?void 0:m.requestId)&&void 0!==g?g:""}});break;case"OPEN_WALLET":this.handleOpenWallet();break;case"OPEN_WEBLINK":this.handleOpenWebLink(w.data);break;case"SHARE":this.handleShare(w.data);break;case"GAME_PLAYED":this.handleInboundAnalyticsEvent(le(le({},null!==(p=w.data)&&void 0!==p?p:{}),((n={})[Jo.EVENT_NAME]=Do,n)),i);break;case"OPEN_CG_WEBVIEW":this.handleOpenCgWebView(w.data,i)}}},t.prototype.handleClose=function(t,i){var n;null===(n=this.instances.get(i))||void 0===n||n.close(),this.recordSessionDismissal(i),this.onCampaignClosed(i),this.ephemeralEntryPointIds.delete(i)&&this.trackingState.delete(i),t.data&&(this.dataDump=t.data)},t.prototype.handleLogin=function(t){"undefined"!=typeof window&&Au(t.data.url)&&(window.location.href=t.data.url)},t.prototype.handleToggle=function(t,i){var n=this.instances.get(t.id);n?n.isOpen()?(n.close(),this.recordSessionDismissal(t.id),this.onCampaignClosed(t.id)):this.isContentOpenSuppressed(n.entryPoint)||(ku(n.entryPoint)&&this.openOverlayIds.add(t.id),n.open()):this.openNewToggleTarget({id:t.id,container:t.container,content:t.content},i),t.data&&(this.dataDump=t.data)},t.prototype.openNewToggleTarget=function(t,i){var n;if(!this.isContentOpenSuppressed(t)){var e=null===(n=this.instances.get(i))||void 0===n?void 0:n.entryPoint;e&&this.adHocToggleSourceEmbedId.set(t.id,e.container.elementHookId||e.id),this.registerAdHocEntryPoint(t),this.openInstance(t)}},t.prototype.handleOpen=function(t){var i={id:pa(),container:t.container,content:t.content};this.isContentOpenSuppressed(i)||(this.ephemeralEntryPointIds.add(i.id),this.registerAdHocEntryPoint(i),this.openInstance(i),t.data&&(this.dataDump=t.data))},t.prototype.handleRedirect=function(t){if("undefined"!=typeof window&&Au(t.data.url)){var i=t.data.url;this.userId&&(i+=i.includes("?")?"&":"?",i+="userId=".concat(this.userId)),t.data.openInNewTab?window.open(i,"_blank","noopener,noreferrer"):window.location.href=i}},t.prototype.handleOpenDeepLink=function(t,i){var n,e,r,s=Iu(t.data),o=s.deepLink,u=s.isHandledByCG,a=s.closeOnDeepLink;null===(e=null===(n=this.callback)||void 0===n?void 0:n.onDeepLinkEvent)||void 0===e||e.call(n,s),"true"===String(u).toLowerCase()&&"undefined"!=typeof window&&Au(o)&&(window.location.href=o),"true"===String(a).toLowerCase()&&(null===(r=this.instances.get(i))||void 0===r||r.close(),this.onCampaignClosed(i))},t.prototype.handleOpenWallet=function(){var t,i=null===(t=this.allCampaignsMap)||void 0===t?void 0:t.defaultUrl;i&&this.openAdHocContent(i)},t.prototype.handleOpenWebLink=function(t){"undefined"!=typeof window&&Au(null==t?void 0:t.url)&&window.open(t.url,"_blank","noopener,noreferrer")},t.prototype.handleShare=function(t){var i,n=null==t?void 0:t.text,e=null==t?void 0:t.image,r=null!==(i=null==t?void 0:t.channelName)&&void 0!==i?i:"OTHERS";e?"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("CUSTOMERGLU_SHARE_EVENT",{detail:t})):n&&"undefined"!=typeof window&&("WHATSAPP"===r.toUpperCase()?window.open("https://wa.me/?text=".concat(encodeURIComponent(n)),"_blank"):"undefined"!=typeof navigator&&"function"==typeof navigator.share&&navigator.share({text:n}).catch(function(){}))},t.prototype.handleOpenCgWebView=function(t,i){var n,e,r,s=null!==(n=null==t?void 0:t.data)&&void 0!==n?n:t,o=null==s?void 0:s.content,u=null==o?void 0:o.campaignId,a=this.resolveOpenCgWebViewUrl(o);a&&this.openAdHocContent(a,u,this.resolveOpenCgWebViewContainer(null==s?void 0:s.container))&&"true"===String(null!==(e=null==s?void 0:s.hidePrevious)&&void 0!==e?e:"false").toLowerCase()&&(null===(r=this.instances.get(i))||void 0===r||r.close(),this.onCampaignClosed(i))},t.prototype.resolveOpenCgWebViewUrl=function(t){var i,n,e,r,s=(null!==(i=null==t?void 0:t.type)&&void 0!==i?i:"").toUpperCase();return"WALLET"===s?null===(n=this.allCampaignsMap)||void 0===n?void 0:n.defaultUrl:"CAMPAIGN"===s&&(null==t?void 0:t.campaignId)?null===(r=null===(e=this.allCampaignsMap)||void 0===e?void 0:e.byId[t.campaignId])||void 0===r?void 0:r.url:null==t?void 0:t.url},t.prototype.resolveOpenCgWebViewContainer=function(i){var n,e=(null!==(n=null==i?void 0:i.type)&&void 0!==n?n:"").toLowerCase(),r=t.BOTTOM_SHEET_LAYOUTS.has(e)?"BOTTOM_SHEET":"POP_UP",s=Number(null==i?void 0:i.relativeHeight),o=Number(null==i?void 0:i.absoluteHeight);return s>0?{typeId:r,height:"".concat(s,"%")}:o>0?{typeId:r,height:"".concat(o,"px")}:{typeId:r,height:"".concat(t.DEFAULT_NUDGE_HEIGHT_PERCENT,"%")}},t.prototype.openAdHocContent=function(i,n,e){void 0===e&&(e={typeId:"POP_UP",height:"".concat(t.DEFAULT_NUDGE_HEIGHT_PERCENT,"%")});var r={id:pa(),container:{typeId:e.typeId,css:"",height:e.height,elementHookId:""},content:le({typeId:"NUDGE",url:i},n?{campaignId:n}:{})};return!this.isContentOpenSuppressed(r)&&(this.ephemeralEntryPointIds.add(r.id),this.registerAdHocEntryPoint(r),this.openInstance(r),!0)},t.prototype.registerAdHocEntryPoint=function(t){this.entryPointMap?(this.adHocEntryPointIds.add(t.id),this.entryPointMap.byId[t.id]||(this.entryPointMap.allIds.push(t.id),this.entryPointMap.byId[t.id]=t)):this.logger.error("registerAdHocEntryPoint() called before entryPointMap is loaded",{entryPointId:t.id})},t.prototype.closeAdHocEntryPoints=function(){var t,i;if(0!==this.adHocEntryPointIds.size){try{for(var n=ge(this.adHocEntryPointIds),e=n.next();!e.done;e=n.next()){var r=e.value,s=this.instances.get(r);if(s&&(s.isOpen()&&s.close(),s.destroy(),this.instances.delete(r)),this.trackingState.delete(r),this.ephemeralEntryPointIds.delete(r),this.adHocToggleSourceEmbedId.delete(r),this.openOverlayIds.delete(r),this.entryPointMap){delete this.entryPointMap.byId[r];var o=this.entryPointMap.allIds.indexOf(r);-1!==o&&this.entryPointMap.allIds.splice(o,1)}}}catch(i){t={error:i}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}this.adHocEntryPointIds.clear()}},t.prototype.cacheKey=function(t){return Ho+t},t.prototype.tokenCacheKey=function(t){return qo+t},t.prototype.loadTokenFromCache=function(t){return ve(this,void 0,void 0,function(){var i,n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.storageManager.get(this.tokenCacheKey(t))];case 1:return(i=r.sent())?(n=JSON.parse(i),Date.now()-n.timestamp>=jo?[2,null]:[2,n.token]):[2,null];case 2:return e=r.sent(),this.logger.error(yo,{userId:t,error:e}),[2,null];case 3:return[2]}})})},t.prototype.saveTokenToCache=function(t,i){return ve(this,void 0,void 0,function(){var n,e;return me(this,function(r){switch(r.label){case 0:n={token:i,timestamp:Date.now()},r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.storageManager.set(this.tokenCacheKey(t),JSON.stringify(n))];case 2:return r.sent(),[3,4];case 3:return e=r.sent(),this.logger.error(wo,{error:e}),[3,4];case 4:return[2]}})})},t.prototype.getOrFetchToken=function(t,i){return ve(this,void 0,void 0,function(){var n,e;return me(this,function(r){switch(r.label){case 0:return[4,this.loadTokenFromCache(t)];case 1:return(n=r.sent())?(this.logger.info(io),[2,n]):(this.logger.info(no),[4,this.apiClient.getToken(this.writeKey,t,Qo.LOGGED_IN,void 0,i)]);case 2:return e=r.sent(),[4,this.saveTokenToCache(t,e)];case 3:return r.sent(),[2,e]}})})},t.prototype.isAuthError=function(t){return"object"==typeof t&&null!==t&&t.code===Me},t.prototype.ensureFreshToken=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r;return me(this,function(s){switch(s.label){case 0:if(this.tokenRefetchInFlight)return[2,this.tokenRefetchInFlight];if(Date.now()<this.authBackoffUntil)throw this.logger.warn(ro,{retryInMs:this.authBackoffUntil-Date.now()}),new Error("Gamification token refetch is in backoff after repeated failures");i=this.refetchToken(t,this.userAttributes),this.tokenRefetchInFlight=i,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,i];case 2:return n=s.sent(),this.authFailureCount=0,this.authBackoffUntil=0,[2,n];case 3:throw e=s.sent(),this.authFailureCount+=1,r=Math.min(tu*Math.pow(2,this.authFailureCount-1),iu),this.authBackoffUntil=Date.now()+r,this.logger.error(so,{userId:t,authFailureCount:this.authFailureCount,backoffMs:r,error:e}),e;case 4:return this.tokenRefetchInFlight=null,[7];case 5:return[2]}})})},t.prototype.refetchToken=function(t,i){return ve(this,void 0,void 0,function(){var n;return me(this,function(e){switch(e.label){case 0:return[4,this.storageManager.remove(this.tokenCacheKey(t)).catch(function(){})];case 1:return e.sent(),[4,this.apiClient.getToken(this.writeKey,t,Qo.LOGGED_IN,void 0,i)];case 2:return n=e.sent(),this.userId!==t?[3,4]:[4,this.saveTokenToCache(t,n)];case 3:e.sent(),this.token=n,e.label=4;case 4:return[2,n]}})})},t.prototype.fetchCampaignsAndEntryPoints=function(t,i){return ve(this,void 0,void 0,function(){var n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,4]),[4,Promise.all([this.apiClient.getCampaigns(i),this.apiClient.getEntryPoints(i)])];case 1:return[2,r.sent()];case 2:if(n=r.sent(),!this.isAuthError(n))throw n;return this.logger.error(eo,{userId:t}),[4,this.ensureFreshToken(t)];case 3:return e=r.sent(),[2,Promise.all([this.apiClient.getCampaigns(e),this.apiClient.getEntryPoints(e)])];case 4:return[2]}})})},t.prototype.loadFromCache=function(t){return ve(this,void 0,void 0,function(){var i,n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.storageManager.get(this.cacheKey(t))];case 1:return(i=r.sent())?(n=JSON.parse(i),Date.now()-n.timestamp>=zo?(this.logger.debug(_o,{userId:t,ageMs:Date.now()-n.timestamp}),[2,!1]):(this.token=n.token,this.allCampaignsMap=n.allCampaignsMap,this.entryPointMap=n.entryPointMap,this.buildEventIndex(),this.lastSyncTimestamp=n.timestamp,[2,!0])):(this.logger.debug(Eo,{userId:t}),[2,!1]);case 2:return e=r.sent(),this.logger.error(Io,{userId:t,error:e}),[2,!1];case 3:return[2]}})})},t.prototype.saveToCache=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:if(!(this.userId&&this.token&&this.allCampaignsMap&&this.entryPointMap))return[2];t={token:this.token,allCampaignsMap:this.allCampaignsMap,entryPointMap:this.entryPointMap,timestamp:this.lastSyncTimestamp},n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.storageManager.set(this.cacheKey(this.userId),JSON.stringify(t))];case 2:return n.sent(),[3,4];case 3:return i=n.sent(),this.logger.error(bo,{error:i}),[3,4];case 4:return this.allCampaignsMap.base&&this.storageManager.set(au,this.allCampaignsMap.base).catch(function(){}),[2]}})})},t.prototype.handleScreenChange=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.closeAdHocEntryPoints(),this.isDataStale()?[4,this.resyncData()]:[3,2];case 1:return t.sent(),[3,3];case 2:this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks(),this.resolveDarkMode()),t.label=3;case 3:return this.refresh(),[2]}})})},t.prototype.isDataStale=function(){return Date.now()-this.lastSyncTimestamp>=zo},t.prototype.resyncData=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c;return me(this,function(h){switch(h.label){case 0:if(t=this.token,i=this.userId,!t||!i)return[2];n=++this.syncGeneration,this.logger.info(Js),h.label=1;case 1:return h.trys.push([1,4,,5]),[4,this.fetchCampaignsAndEntryPoints(i,t)];case 2:return e=pe.apply(void 0,[h.sent(),2]),r=e[0],s=e[1],n!==this.syncGeneration?[2]:(o=this.entryPointMap,this.allCampaignsMap=r,this.entryPointMap=Uu(s),this.buildEventIndex(),this.lastSyncTimestamp=Date.now(),null===(c=null===(a=this.callback)||void 0===a?void 0:a.onEntryPointsLoaded)||void 0===c||c.call(a,Object.values(this.entryPointMap.byId)),this.preloadEntryPoints(),[4,this.saveToCache()]);case 3:return h.sent(),this.reconcileEntryPointState(o,this.entryPointMap,i),this.loyaltyRenderer.render(this.loyaltyUrls,this.capToken,this.loyaltyCallbacks(),this.resolveDarkMode()),[3,5];case 4:return u=h.sent(),this.logger.error($s,u),[3,5];case 5:return[2]}})})},t.prototype.reconcileEntryPointState=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o,u,a,c,h,d,f,l=this;return me(this,function(v){switch(v.label){case 0:if(!t)return[2];e=this.classifyReconciledEntryPoints(t,i),r=e.removedIds,s=e.dailyRefreshChangedIds,o=function(t){u.storageManager.remove(Wu(t,n)).catch(function(i){l.logger.error(No,{entryPointId:t,error:i})})},u=this;try{for(a=ge(we(we([],pe(r),!1),pe(s),!1)),c=a.next();!c.done;c=a.next())h=c.value,o(h)}catch(t){d={error:t}}finally{try{c&&!c.done&&(f=a.return)&&f.call(a)}finally{if(d)throw d.error}}return r.length>0?[4,this.pruneSessionDismissalRecords(r,n)]:[3,2];case 1:v.sent(),v.label=2;case 2:return[2]}})})},t.prototype.classifyReconciledEntryPoints=function(t,i){var n,e,r,s,o,u,a,c,h=[],d=[];try{for(var f=ge(t.allIds),l=f.next();!l.done;l=f.next()){var v=l.value,m=t.byId[v],g=i.byId[v];if(m)if(g)(null!==(o=null===(s=null===(r=m.conditions)||void 0===r?void 0:r.showCount)||void 0===s?void 0:s.dailyRefresh)&&void 0!==o&&o)!==(null!==(c=null===(a=null===(u=g.conditions)||void 0===u?void 0:u.showCount)||void 0===a?void 0:a.dailyRefresh)&&void 0!==c&&c)&&d.push(v);else h.push(v)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(e=f.return)&&e.call(f)}finally{if(n)throw n.error}}return{removedIds:h,dailyRefreshChangedIds:d}},t.prototype.pruneSessionDismissalRecords=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o,u,a,c,h,d=this;return me(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),[4,this.storageManager.keys("".concat(Xo).concat(i,"_"))];case 1:n=f.sent(),e=function(t){var e,s,o=r.sessionDismissedKeyPrefix(i,t);try{for(var u=(e=void 0,ge(n.filter(function(t){return t.startsWith(o)}))),a=u.next();!a.done;a=u.next()){var c=a.value;r.storageManager.remove(c).catch(function(i){d.logger.error(No,{entryPointId:t,error:i})})}}catch(t){e={error:t}}finally{try{a&&!a.done&&(s=u.return)&&s.call(u)}finally{if(e)throw e.error}}},r=this;try{for(s=ge(t),o=s.next();!o.done;o=s.next())u=o.value,e(u)}catch(t){c={error:t}}finally{try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(c)throw c.error}}return[3,3];case 2:return a=f.sent(),this.logger.error(No,{entryPointId:"all",error:a}),[3,3];case 3:return[2]}})})},t.prototype.fetchAndCache=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o;return me(this,function(u){switch(u.label){case 0:return[4,this.getOrFetchToken(t,i)];case 1:return e=u.sent(),n!==this.initGeneration?[2,!1]:(this.token=e,[4,this.fetchCampaignsAndEntryPoints(t,e)]);case 2:return r=pe.apply(void 0,[u.sent(),2]),s=r[0],o=r[1],n!==this.initGeneration?[2,!1]:(this.allCampaignsMap=s,this.entryPointMap=Uu(o),this.buildEventIndex(),this.lastSyncTimestamp=Date.now(),this.saveToCache(),[2,n===this.initGeneration])}})})},t.prototype.isCampaignCompleted=function(t){var i,n,e,r=Cu(t);if(!r||!this.allCampaignsMap)return!1;var s=this.allCampaignsMap.byId[r];if(!s)return!1;var o=Fo;return(null===(i=s.status)||void 0===i?void 0:i.toUpperCase())===o||(null===(e=null===(n=s.banner)||void 0===n?void 0:n.userCampaignStatus)||void 0===e?void 0:e.toUpperCase())===o},t.prototype.registerSpaListener=function(){var t=this;if("undefined"!=typeof window&&"undefined"!=typeof document){var i=window.location.href,n=null,e=new MutationObserver(function(){var e=window.location.href;if(e!==i){if(i=e,!t.pagePathTrackingEnabled)return;n&&clearTimeout(n),n=setTimeout(function(){t.handleScreenChange()},Yo)}});e.observe(document.body,{childList:!0,subtree:!0}),this.spaListenerCleanup=function(){e.disconnect(),n&&clearTimeout(n)}}},t.prototype.registerVisibilityListener=function(){var t=this;if("undefined"!=typeof document){var i=function(){return ve(t,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return"visible"!==document.visibilityState?[2]:this.isDataStale()?[4,this.resyncData()]:[3,2];case 1:return t.sent(),this.refresh(),[2];case 2:return this.showNextFromQueue(),[2]}})})};document.addEventListener("visibilitychange",i),this.visibilityListenerCleanup=function(){document.removeEventListener("visibilitychange",i)}}},t.VALID_THEMES=["NONE","AUTO","DARK","LIGHT"],t.LOYALTY_SOURCE_ID="__GLU__LOYALTY__",t.BOTTOM_SHEET_LAYOUTS=new Set(["bottom-popup","bottom-default","bottom-slider"]),t.DEFAULT_NUDGE_HEIGHT_PERCENT=100/1.4,t}(),tc=function(){function t(t,i,n,e,r){this.httpClient=new du(t,i),this.logger=i,this.accountId=n,this.orgId=e,this.source=r}return t.prototype.sendEvents=function(t,i,n,e,r,s){return ve(this,void 0,void 0,function(){var o,u,a,c,h,d,f,l;return me(this,function(v){switch(v.label){case 0:if(!i&&!n&&!e)throw new Error("Either visitorId, visitorExternalId, or userId must be provided for event tracking");if(!s)throw new Error("Session ID is required for event tracking");return u=(o=!!i||!!n)&&e?"identified":o?"anonymous":"user-only",this.logger.info("Sending events",{eventCount:t.length,trackingMode:u,hasVisitor:o,hasUser:!!e,sessionId:s}),[4,va()];case 1:a=v.sent(),c=oa(s,a),h={request_id:ea(),context:c,events:t},i?h.visitor={identifierName:"id",identifierValue:i}:n&&(h.visitor={identifierName:"externalId",identifierValue:n}),e&&r&&(h.user={identifierName:r,identifierValue:e}),v.label=2;case 2:return v.trys.push([2,4,,5]),d={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source,"X-CAP-API-AUTH-ENTITY-ID":this.orgId},[4,this.httpClient.post(ye,h,{headers:d})];case 3:return f=v.sent(),this.logger.info(rr,{requestId:h.request_id,eventCount:t.length,trackingMode:u,success:f.status.success}),[2,f];case 4:throw l=v.sent(),this.logger.error(sr,{requestId:h.request_id,eventCount:t.length,trackingMode:u,error:l}),l;case 5:return[2]}})})},t.prototype.getVisitorConfig=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s;return me(this,function(o){switch(o.label){case 0:this.logger.info("Fetching visitor config",{orgId:t}),o.label=1;case 1:return o.trys.push([1,3,,4]),i={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":Ls.WEBPUSH},[4,this.httpClient.get(_e,{headers:i})];case 2:return n=o.sent(),this.logger.info(Pr,{isEnabled:null===(r=n.data)||void 0===r?void 0:r.visitorTrackingEnabled,warningCount:(null===(s=n.warnings)||void 0===s?void 0:s.length)||0}),[2,n];case 3:throw e=o.sent(),this.logger.error(Mr,{orgId:t,error:e}),e;case 4:return[2]}})})},t.prototype.createVisitor=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:this.logger.info("Creating anonymous visitor",{orgId:t,profileCount:i.profiles.length,hasExtendedFields:!!i.extendedFields}),u.label=1;case 1:if(u.trys.push([1,3,,4]),!i.profiles||0===i.profiles.length)throw new Error("At least one profile is required");return n={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-SOURCE-NAME":this.source,"X-CAP-ORG-ACCOUNT-ID":this.accountId},[4,this.httpClient.post(Ie,i,{headers:n})];case 2:return e=u.sent(),this.logger.info(Vr,{visitorId:null===(s=e.data)||void 0===s?void 0:s.id,warningCount:(null===(o=e.warnings)||void 0===o?void 0:o.length)||0}),[2,e];case 3:throw r=u.sent(),this.logger.error(Br,{error:r,accountId:this.accountId}),r;case 4:return[2]}})})},t.prototype.updateVisitor=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o,u,a;return me(this,function(c){switch(c.label){case 0:this.logger.info("Updating visitor",{orgId:t,visitorId:i,profileCount:n.profiles.length,hasExtendedFields:!!n.extendedFields}),c.label=1;case 1:if(c.trys.push([1,3,,4]),!n.profiles||0===n.profiles.length)throw new Error("At least one profile is required");if(!i||""===i.trim())throw new Error("Visitor ID is required for update");return e={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-SOURCE-NAME":this.source,"X-CAP-ORG-ACCOUNT-ID":this.accountId},r="".concat(be,"?identifierType=visitorId&identifierValue=").concat(encodeURIComponent(i)),[4,this.httpClient.put(r,n,{headers:e})];case 2:return s=c.sent(),this.logger.info(Hr,{visitorId:null===(u=s.data)||void 0===u?void 0:u.id,warningCount:(null===(a=s.warnings)||void 0===a?void 0:a.length)||0}),[2,s];case 3:throw o=c.sent(),this.logger.error(qr,{error:o,visitorId:i,accountId:this.accountId}),o;case 4:return[2]}})})},t.prototype.buildMergeIdentifiers=function(t,i,n,e){var r,s={email:i,mobile:n,externalId:e},o=t&&s[t]?t:void 0;r=i?"email":n?"mobile":"externalId";var u=null!=o?o:r;return[{type:u,value:s[u]}]},t.prototype.handleMergeResponse=function(t,i){var n,e=this;if(t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){e.logger.warn("Visitor merge warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0){var r=t.errors[0],s=r.code,o=r.message,u=String(s);if(u===Vs.ALREADY_MERGED)return void this.logger.info("Visitor already merged, treating as success",{visitorId:i});if(u===Vs.VISITOR_NOT_FOUND)throw this.logger.warn("Visitor not found, merge cannot proceed",{visitorId:i}),new ic(u,o);throw new Error("Merge API error: [".concat(u,"] ").concat(o))}if(202!==(null===(n=t.status)||void 0===n?void 0:n.code))throw new Error("Unexpected merge API response");this.logger.info(Kr,{visitorId:i,statusCode:t.status.code,message:t.status.message})},t.prototype.mergeVisitor=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o,u,a,c,h,d,f,l,v,m,g,p,w,y,E,_,I,b,T,S,N,D,k;return me(this,function(O){switch(O.label){case 0:if(e=n.firstName,r=n.lastName,s=n.email,o=n.mobile,u=n.fcmToken,a=n.channelType,c=n.subscribed,h=void 0===c||c,d=n.fields,f=n.extendedFields,l=n.externalId,v=n.sessionId,m=void 0===v?"":v,g=n.cuid,p=void 0===g?"":g,w=n.identifierType,!s&&!o&&!l)throw new Error("At least one identifier (email, mobile, or externalId) is required for visitor merge");if(!t&&!i)throw new Error("Either visitorId or visitorExternalId is required for visitor merge");return this.logger.info("Merging visitor with user",{visitorId:t,visitorExternalId:i,hasEmail:!!s,hasMobile:!!o,hasExternalId:!!l,hasFcmToken:!!u}),y=this.buildMergeIdentifiers(w,s,o,l),E=a||Fs.WEB,_=[],u&&_.push({type:E,value:u,primary:!0,verified:!0,subscribed:h,accountId:this.accountId,attributes:{gateway:zs,cuid:p,luid:p,lastSeen:(new Date).toISOString(),deleted:!1,pushReachable:h}}),s&&_.push({type:"email",value:s,primary:!0,subscribed:!1,accountId:this.accountId,attributes:{cuid:p}}),o&&_.push({type:"mobile",value:o,primary:!0,subscribed:!1,accountId:this.accountId,attributes:{cuid:p}}),k={visitor:t?{identifierName:"id",identifierValue:t}:{identifierName:"externalId",identifierValue:i},user:{profiles:[{firstName:e,lastName:r,identifiers:y,commChannels:_,fields:d||{}}],extendedFields:f||{}}},b=oa,T=[m],[4,va()];case 1:k.context=b.apply(void 0,T.concat([O.sent()])),I=k,O.label=2;case 2:return O.trys.push([2,4,,5]),S={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source},[4,this.httpClient.post(Te,I,{headers:S})];case 3:return N=O.sent(),this.handleMergeResponse(N,t),[3,5];case 4:if((D=O.sent())instanceof ic)throw D;throw this.logger.error(Wr,{visitorId:t,error:D}),D;case 5:return[2]}})})},t.prototype.buildUserEventsRequest=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r;return me(this,function(s){switch(s.label){case 0:return[4,va()];case 1:return e=s.sent(),r=oa(n,e),[2,{request_id:ea(),context:le(le({},r),{os_name:Os}),events:[{name:t,eventExternalId:ea(),eventDateTime:(new Date).toISOString(),attributes:i}]}]}})})},t.prototype.sendUserEvents=function(t,i,n,e,r){return ve(this,void 0,void 0,function(){var s,o,u,a,c;return me(this,function(h){switch(h.label){case 0:i?t.visitor={identifierName:"id",identifierValue:i}:n&&(t.visitor={identifierName:"externalId",identifierValue:n}),e&&r&&(t.user={identifierName:r,identifierValue:e}),this.logger.info("Sending user event",{eventName:null===(u=t.events[0])||void 0===u?void 0:u.name,requestId:t.request_id,hasVisitor:!!t.visitor,hasUser:!!t.user}),h.label=1;case 1:return h.trys.push([1,3,,4]),s={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source,"X-CAP-API-AUTH-ENTITY-ID":this.orgId},[4,this.httpClient.post(Ee,t,{headers:s})];case 2:return h.sent(),this.logger.info(or,{eventName:null===(a=t.events[0])||void 0===a?void 0:a.name,requestId:t.request_id}),[3,4];case 3:throw o=h.sent(),this.logger.error(ur,{eventName:null===(c=t.events[0])||void 0===c?void 0:c.name,requestId:t.request_id,error:o}),o;case 4:return[2]}})})},t.prototype.sendDLR=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s;return me(this,function(o){switch(o.label){case 0:this.logger.info("Sending DLR events",{eventCount:t.events.length,requestId:t.request_id,cuid:null===(r=t.user)||void 0===r?void 0:r.identifierValue,visitorId:null===(s=t.visitor)||void 0===s?void 0:s.identifierValue}),o.label=1;case 1:return o.trys.push([1,3,,4]),i={"x-cap-api-auth-org-id":this.orgId,"x-cap-request-id":t.request_id},[4,this.httpClient.post(Se,t,{headers:i})];case 2:return n=o.sent(),this.logger.info(Ds,{requestId:t.request_id,eventCount:t.events.length,success:n.status.success}),[2,n];case 3:throw e=o.sent(),this.logger.error(ks,{requestId:t.request_id,eventCount:t.events.length,error:e}),e;case 4:return[2]}})})},t}(),ic=function(t){function i(i,n){var e=t.call(this,n)||this;return e.name="MergeNonRetryableError",e.code=i,e}return fe(i,t),i}(Error);var nc,ec=function(){function t(t,i,n,e){void 0===i&&(i="WebSDK"),void 0===n&&(n=2),void 0===e&&(e="data"),this.db=null,this.logger=t,this.dbName=i,this.version=n,this.storeName=e,this.eventsStoreName="events"}return t.prototype.logAndReject=function(t,i,n){this.logger.error("IndexedDB request failed",{operation:i,error:n}),t(n)},t.prototype.attachTransactionSafety=function(t,i,n){var e=this;t.onabort=function(){return e.logAndReject(i,"".concat(n,":transaction"),t.error)},t.onerror=function(){return e.logAndReject(i,"".concat(n,":transaction"),t.error)}},t.prototype.openDB=function(){return ve(this,void 0,void 0,function(){var t=this;return me(this,function(i){return this.db?[2,this.db]:[2,new Promise(function(i,n){var e=indexedDB.open(t.dbName,t.version);e.onerror=function(){return t.logAndReject(n,"openDB",e.error)},e.onblocked=function(){return t.logAndReject(n,"openDB",new Error("IndexedDB open request blocked by another open connection"))},e.onsuccess=function(){t.db=e.result,t.db.onversionchange=function(){var i;t.logger.info("IndexedDB version change detected by another connection, closing"),null===(i=t.db)||void 0===i||i.close(),t.db=null},i(t.db)},e.onupgradeneeded=function(i){var n=i.target.result;if(t.logger.info("IndexedDB schema upgrade",{dbName:t.dbName,oldVersion:i.oldVersion,newVersion:i.newVersion}),n.objectStoreNames.contains(t.storeName)||n.createObjectStore(t.storeName),!n.objectStoreNames.contains(t.eventsStoreName)){var e=n.createObjectStore(t.eventsStoreName,{keyPath:"id"});e.createIndex("timestamp","timestamp",{unique:!1}),e.createIndex("status","status",{unique:!1})}}})]})})},t.prototype.getItem=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.storeName],"readonly");n.attachTransactionSafety(s,r,"getItem");var o=s.objectStore(n.storeName).get(t);o.onerror=function(){return n.logAndReject(r,"getItem",o.error)},o.onsuccess=function(){var t=o.result;e(null==t?null:"string"==typeof t?t:"object"==typeof t?JSON.stringify(t):String(t))}})]}})})},t.prototype.setItem=function(t,i){return ve(this,void 0,void 0,function(){var n,e=this;return me(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,s){var o=n.transaction([e.storeName],"readwrite");e.attachTransactionSafety(o,s,"setItem");var u=o.objectStore(e.storeName).put(i,t);u.onerror=function(){return e.logAndReject(s,"setItem",u.error)},u.onsuccess=function(){return r()}})]}})})},t.prototype.removeItem=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.storeName],"readwrite");n.attachTransactionSafety(s,r,"removeItem");var o=s.objectStore(n.storeName).delete(t);o.onerror=function(){return n.logAndReject(r,"removeItem",o.error)},o.onsuccess=function(){return e()}})]}})})},t.prototype.clear=function(){return ve(this,void 0,void 0,function(){var t,i=this;return me(this,function(n){switch(n.label){case 0:return[4,this.openDB()];case 1:return t=n.sent(),[2,new Promise(function(n,e){var r=t.transaction([i.storeName],"readwrite");i.attachTransactionSafety(r,e,"clear");var s=r.objectStore(i.storeName).clear();s.onerror=function(){return i.logAndReject(e,"clear",s.error)},s.onsuccess=function(){return n()}})]}})})},t.prototype.getAllKeys=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.storeName],"readonly");n.attachTransactionSafety(s,r,"getAllKeys");var o=s.objectStore(n.storeName).getAllKeys();o.onerror=function(){return n.logAndReject(r,"getAllKeys",o.error)},o.onsuccess=function(){var i=o.result.map(function(t){return String(t)});e(t?i.filter(function(i){return i.startsWith(t)}):i)}})]}})})},t.prototype.close=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){return this.db&&(this.db.close(),this.db=null),[2]})})},t.prototype.addEvent=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.eventsStoreName],"readwrite");n.attachTransactionSafety(s,r,"addEvent");var o=s.objectStore(n.eventsStoreName).add(t);o.onerror=function(){return n.logAndReject(r,"addEvent",o.error)},o.onsuccess=function(){return e()}})]}})})},t.prototype.getOldestPendingEvents=function(t){return ve(this,arguments,void 0,function(t,i){var n,e=this;return void 0===i&&(i=50),me(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,s){var o=n.transaction([e.eventsStoreName],"readonly");e.attachTransactionSafety(o,s,"getOldestPendingEvents");var u=o.objectStore(e.eventsStoreName).index("timestamp").openCursor(),a=[],c=0;u.onerror=function(){return e.logAndReject(s,"getOldestPendingEvents",u.error)},u.onsuccess=function(n){var e=n.target.result;if(e&&c<i){var s=e.value;"pending"===s.status&&s.accountId===t&&(a.push(s),c++),e.continue()}else r(a)}})]}})})},t.prototype.updateEventStatus=function(t,i,n,e){return ve(this,void 0,void 0,function(){var r,s=this;return me(this,function(o){switch(o.label){case 0:return[4,this.openDB()];case 1:return r=o.sent(),[2,new Promise(function(o,u){var a=r.transaction([s.eventsStoreName],"readwrite");s.attachTransactionSafety(a,u,"updateEventStatus");var c=a.objectStore(s.eventsStoreName),h=c.get(t);h.onerror=function(){return s.logAndReject(u,"updateEventStatus:get",h.error)},h.onsuccess=function(){var r=h.result;if(r){r.status=i,r.lastAttempt=Date.now(),n&&(r.error=n),void 0!==e&&(r.attempts=e);var a=c.put(r);a.onerror=function(){return s.logAndReject(u,"updateEventStatus:put",a.error)},a.onsuccess=function(){return o()}}else s.logAndReject(u,"updateEventStatus",new Error("Event with id ".concat(t," not found")))}})]}})})},t.prototype.removeEvents=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.eventsStoreName],"readwrite");n.attachTransactionSafety(s,r,"removeEvents");var o=s.objectStore(n.eventsStoreName),u=0,a=t.length;0!==a?t.forEach(function(t){var i=o.delete(t);i.onerror=function(){return n.logAndReject(r,"removeEvents",i.error)},i.onsuccess=function(){++u===a&&e()}}):e()})]}})})},t.prototype.recoverOrphanedEvents=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.eventsStoreName],"readwrite");n.attachTransactionSafety(s,r,"recoverOrphanedEvents");var o=s.objectStore(n.eventsStoreName).openCursor(),u=0;o.onerror=function(){return n.logAndReject(r,"recoverOrphanedEvents",o.error)},o.onsuccess=function(i){var s=i.target.result;if(s){var o=s.value;if("processing"===o.status&&o.accountId===t){o.status="failed",o.lastAttempt=Date.now(),o.error="Recovered from orphaned processing state";var a=s.update(o);a.onerror=function(){return n.logAndReject(r,"recoverOrphanedEvents:update",a.error)},a.onsuccess=function(){u++}}s.continue()}else e(u)}})]}})})},t.prototype.getPendingEventCount=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return i=e.sent(),[2,new Promise(function(e,r){var s=i.transaction([n.eventsStoreName],"readonly");n.attachTransactionSafety(s,r,"getPendingEventCount");var o=s.objectStore(n.eventsStoreName).openCursor(),u=0;o.onerror=function(){return n.logAndReject(r,"getPendingEventCount",o.error)},o.onsuccess=function(i){var n=i.target.result;if(n){var r=n.value;"pending"===r.status&&r.accountId===t&&u++,n.continue()}else e(u)}})]}})})},t.prototype.getRetryableEvents=function(t){return ve(this,arguments,void 0,function(t,i){var n,e=this;return void 0===i&&(i=5),me(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return n=r.sent(),[2,new Promise(function(r,s){var o=n.transaction([e.eventsStoreName],"readonly");e.attachTransactionSafety(o,s,"getRetryableEvents");var u=o.objectStore(e.eventsStoreName).openCursor(),a=[];u.onerror=function(){return e.logAndReject(s,"getRetryableEvents",u.error)},u.onsuccess=function(n){var e=n.target.result;if(e){var s=e.value;"failed"===s.status&&s.attempts<=i&&s.accountId===t&&a.push(s),e.continue()}else r(a)}})]}})})},t}(),rc=function(){function t(t,i,n,e,r){if(this.currentAccountId=null,this.currentCuid=null,this.currentUserIdentifierType=null,this.currentVisitorId=null,this.currentVisitorExternalId=null,this.getSessionInfo=null,this.isProcessing=!1,this.processingPromise=null,this.paused=!1,this.apiClient=t,this.logger=i,this.BATCH_SIZE=r||De.BATCH_SIZE,this.RETRY_DELAYS=e||De.DEFAULT_RETRY_DELAYS,n&&"getIndexedDBAdapter"in n){var s=n.getIndexedDBAdapter();s?(i.info("EventQueue: Reusing existing IndexedDB adapter from StorageManager"),this.storage=s):(i.warn("EventQueue: StorageManager has no IndexedDB adapter, creating new one"),this.storage=new ec(i))}else n?(i.info("EventQueue: Using provided IndexedDBStorage"),this.storage=n):(i.warn("EventQueue: No storage provided, creating new IndexedDBStorage"),this.storage=new ec(i))}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.logger.info("Initializing EventQueue"),[4,this.processQueueIfIdle()];case 1:return t.sent(),this.logger.info(Ze),[2]}})})},t.prototype.setUserContext=function(t,i,n){return ve(this,void 0,void 0,function(){var e;return me(this,function(r){switch(r.label){case 0:return this.currentAccountId=t,this.currentCuid=i||null,this.currentUserIdentifierType=n||null,this.logger.debug("EventQueue user context set",{accountId:t,cuid:i,userIdentifierType:n}),[4,this.storage.recoverOrphanedEvents(t)];case 1:return(e=r.sent())>0&&this.logger.info("Recovered ".concat(e," orphaned processing events for account ").concat(t)),[2]}})})},t.prototype.setVisitorContext=function(t,i){this.currentVisitorId=t,this.currentVisitorExternalId=null!=i?i:null,this.logger.debug("EventQueue visitor context set",{visitorId:t,visitorExternalId:i})},t.prototype.setSessionInfoCallback=function(t){this.getSessionInfo=t,this.logger.debug("EventQueue session info callback set")},t.prototype.getCurrentAccountId=function(){return this.currentAccountId},t.prototype.getCurrentCuid=function(){return this.currentCuid},t.prototype.getCurrentVisitorId=function(){return this.currentVisitorId},t.prototype.clearUserContext=function(){this.currentCuid=null,this.currentUserIdentifierType=null,this.logger.debug("EventQueue user context cleared (cuid removed)")},t.prototype.enqueue=function(t){return ve(this,arguments,void 0,function(t,i){var n,e,r;return void 0===i&&(i=!1),me(this,function(s){switch(s.label){case 0:if(!this.currentAccountId)throw new Error("Cannot enqueue event: No account context set");if(n=null,!this.getSessionInfo)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getSessionInfo()];case 2:return n=s.sent(),[3,4];case 3:return e=s.sent(),this.logger.error("Failed to resolve session ID at enqueue time",{error:e}),[3,4];case 4:return r={id:ea(),event:t,accountId:this.currentAccountId,timestamp:(new Date).toISOString(),attempts:0,status:De.STATUSES.PENDING,visitorId:this.currentVisitorId,visitorExternalId:this.currentVisitorExternalId,cuid:this.currentCuid,userIdentifierType:this.currentUserIdentifierType,sessionId:n,isDLR:i},[4,this.storage.addEvent(r)];case 5:return s.sent(),this.logger.debug(nr,{eventId:r.id,eventName:t.name,visitorId:r.visitorId,cuid:r.cuid,sessionId:r.sessionId,isDLR:i}),[4,this.processQueueIfIdle()];case 6:return s.sent(),[2]}})})},t.prototype.processQueueIfIdle=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){return this.paused?(this.logger.debug("Queue processing paused, skipping"),[2]):this.isProcessing?(this.logger.debug(fr),[2]):(this.processingPromise||(this.processingPromise=this.processQueue()),[2,this.processingPromise])})})},t.prototype.getIdentityKey=function(t){var i,n,e,r,s,o=null!==(i=t.visitorId)&&void 0!==i?i:"_none_",u=null!==(n=t.visitorExternalId)&&void 0!==n?n:"_none_",a=null!==(e=t.cuid)&&void 0!==e?e:"_none_",c=null!==(r=t.userIdentifierType)&&void 0!==r?r:"_none_",h=null!==(s=t.sessionId)&&void 0!==s?s:"_none_";return"".concat(o,"|").concat(u,"|").concat(a,"|").concat(c,"|").concat(h)},t.prototype.groupEventsByIdentity=function(t){var i,n,e=new Map;try{for(var r=ge(t),s=r.next();!s.done;s=r.next()){var o=s.value,u=this.getIdentityKey(o),a=e.get(u);a?a.push(o):e.set(u,[o])}}catch(t){i={error:t}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return Array.from(e.values())},t.prototype.processQueue=function(){return ve(this,void 0,void 0,function(){var i=this;return me(this,function(n){switch(n.label){case 0:return this.isProcessing?[2]:"undefined"!=typeof navigator&&"locks"in navigator?[4,navigator.locks.request(t.QUEUE_LOCK_NAME,{ifAvailable:!0},function(t){return ve(i,void 0,void 0,function(){return me(this,function(i){switch(i.label){case 0:return t?[4,this.executeProcessQueue()]:(this.logger.debug("Queue lock held by another tab, skipping"),[2]);case 1:return i.sent(),[2]}})})})]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this.executeProcessQueue()];case 3:n.sent(),n.label=4;case 4:return[2]}})})},t.prototype.executeProcessQueue=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c;return me(this,function(h){switch(h.label){case 0:this.isProcessing=!0,this.logger.debug(cr),h.label=1;case 1:h.trys.push([1,16,17,18]),h.label=2;case 2:return this.paused?(this.logger.debug("Queue processing paused mid-cycle, stopping"),[3,15]):[4,this.checkAndPromoteRetryEvents()];case 3:return h.sent(),this.currentAccountId?[4,this.storage.getOldestPendingEvents(this.currentAccountId,this.BATCH_SIZE)]:(this.logger.debug("No account context, skipping event processing"),[3,15]);case 4:if(0===(t=h.sent()).length)return this.logger.debug(lr),[3,15];i=this.groupEventsByIdentity(t),this.logger.info("Processing events",{totalEvents:t.length,identityGroups:i.length}),h.label=5;case 5:h.trys.push([5,11,12,13]),a=void 0,n=ge(i),e=n.next(),h.label=6;case 6:return e.done?[3,10]:(r=e.value,s=r[0],this.logger.debug("Processing identity group",{batchSize:r.length,visitorId:null==s?void 0:s.visitorId,cuid:null==s?void 0:s.cuid,sessionId:null==s?void 0:s.sessionId}),[4,this.markEventsAsProcessing(r)]);case 7:return h.sent(),[4,this.sendBatch(r)];case 8:h.sent(),h.label=9;case 9:return e=n.next(),[3,6];case 10:return[3,13];case 11:return o=h.sent(),a={error:o},[3,13];case 12:try{e&&!e.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}return[7];case 13:return[4,this.storage.getPendingEventCount(this.currentAccountId)];case 14:return 0===h.sent()?(this.logger.debug(vr),[3,15]):[3,2];case 15:return[3,18];case 16:return u=h.sent(),this.logger.error(dr,{error:u}),[3,18];case 17:return this.isProcessing=!1,this.processingPromise=null,this.logger.debug(hr),[7];case 18:return[2]}})})},t.prototype.markEventsAsProcessing=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u;return me(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),i=ge(t),n=i.next(),a.label=1;case 1:if(n.done)return[3,6];e=n.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.storage.updateEventStatus(e.id,"processing")];case 3:return a.sent(),[3,5];case 4:return r=a.sent(),this.logger.error(mr,{eventId:e.id,error:r}),[3,5];case 5:return n=i.next(),[3,1];case 6:return[3,9];case 7:return s=a.sent(),o={error:s},[3,9];case 8:try{n&&!n.done&&(u=i.return)&&u.call(i)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},t.prototype.sendBatch=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a,c;return me(this,function(h){switch(h.label){case 0:if(h.trys.push([0,5,,10]),!this.currentAccountId)throw new Error("Missing account context for batch sending");return i=t[0],n=!!(null!==(c=i.visitorId)&&void 0!==c?c:i.visitorExternalId),e=!!i.cuid,r=void 0,r=n&&e?"identified":n?"anonymous":"user-only",this.logger.debug("Sending event batch",{batchSize:t.length,trackingMode:r,hasVisitor:n,hasUser:e}),s=t.filter(function(t){return!0===t.isDLR}),(o=t.filter(function(t){return!0!==t.isDLR})).length>0?[4,this.sendRegularEvents(o)]:[3,2];case 1:h.sent(),h.label=2;case 2:return s.length>0?[4,this.sendDLREvents(s)]:[3,4];case 3:h.sent(),h.label=4;case 4:return[2,!0];case 5:return u=h.sent(),a=this.isRetryableHttpError(u),this.logger.error(ar,{batchSize:t.length,hasDLREvents:t.some(function(t){return!0===t.isDLR}),error:u,isRetryable:a}),a?[4,this.handleFailedBatch(t)]:[3,7];case 6:return h.sent(),[3,9];case 7:return[4,this.removeNonRetryableEvents(t)];case 8:h.sent(),h.label=9;case 9:return[2,!1];case 10:return[2]}})})},t.prototype.sendRegularEvents=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a,c,h,d,f,l,v;return me(this,function(m){switch(m.label){case 0:if(i=t[0],n=null!==(h=i.visitorId)&&void 0!==h?h:null,e=null!==(d=i.visitorExternalId)&&void 0!==d?d:null,r=null!==(f=i.cuid)&&void 0!==f?f:null,s=null!==(l=i.userIdentifierType)&&void 0!==l?l:null,o=null!==(v=i.sessionId)&&void 0!==v?v:null,u=this.apiClient,a=t.map(function(t){return t.event}),!o)throw new Error("Session ID is required for event tracking");return[4,u.sendEvents(a,n||void 0,e||void 0,r||void 0,s||void 0,o)];case 1:return c=m.sent(),[4,this.handleBatchResponse(t,c)];case 2:return m.sent(),[2]}})})},t.prototype.sendDLREvents=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a;return me(this,function(c){switch(c.label){case 0:return i=t[0],n=this.apiClient,e=null!==(a=i.sessionId)&&void 0!==a?a:"",[4,va()];case 1:return r=c.sent(),s=oa(e,r),o={events:t.map(function(t){var i=t.event,n=i.eventExternalId,e=function(t,i){var n={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0&&(n[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(e=Object.getOwnPropertySymbols(t);r<e.length;r++)i.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(t,e[r])&&(n[e[r]]=t[e[r]])}return n}(i,["eventExternalId"]);return le(le({},e),{eventRefId:n})}),request_id:ea(),system_data:s},i.cuid?o.user={identifierName:"id",identifierValue:i.cuid}:i.visitorId&&(o.visitor={identifierName:"id",identifierValue:i.visitorId}),[4,n.sendDLR(o)];case 2:return u=c.sent(),[4,this.handleBatchResponse(t,u,De.DLR_SUCCESS_CODE)];case 3:return c.sent(),[2]}})})},t.prototype.removeSuccessfulEvents=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:i=t.map(function(t){return t.id}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.storage.removeEvents(i)];case 2:return e.sent(),this.logger.debug("Successfully removed events from storage",{count:i.length}),[3,4];case 3:return n=e.sent(),this.logger.error(gr,{eventIds:i,error:n}),[3,4];case 4:return[2]}})})},t.prototype.handleBatchResponse=function(t,i){return ve(this,arguments,void 0,function(t,i,n){var e,r;return void 0===n&&(n=De.GLOBAL_SUCCESS_CODE),me(this,function(s){switch(s.label){case 0:return e=parseInt(i.status.code,10),r=t.some(function(t){return!0===t.isDLR}),e!==n?[3,2]:[4,this.removeSuccessfulEvents(t)];case 1:return s.sent(),this.logger.info("All events processed successfully",{count:t.length,hasDLREvents:r}),[3,8];case 2:return e!==De.PARTIAL_SUCCESS_CODE?[3,4]:[4,this.handlePartialSuccess(t,i.events)];case 3:return s.sent(),[3,8];case 4:return De.RETRYABLE_HTTP_CODES.includes(e)?[4,this.handleFailedBatch(t)]:[3,6];case 5:return s.sent(),this.logger.warn("Batch failed with retryable error",{code:e,message:i.status.message,hasDLREvents:r}),[3,8];case 6:return[4,this.removeNonRetryableEvents(t)];case 7:s.sent(),this.logger.error("Batch failed with non-retryable error",{code:e,message:i.status.message,hasDLREvents:r}),s.label=8;case 8:return[2]}})})},t.prototype.handlePartialSuccess=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o,u,a,c,h;return me(this,function(d){switch(d.label){case 0:n=new Map,i.forEach(function(t){n.set(t.eventExternalId,t)}),d.label=1;case 1:d.trys.push([1,12,13,14]),e=ge(t),r=e.next(),d.label=2;case 2:return r.done?[3,11]:(s=r.value,(o=n.get(s.event.eventExternalId))?[3,4]:[4,this.markEventForRetry(s,"No response received")]);case 3:return d.sent(),[3,10];case 4:return o.status.success?[4,this.storage.removeEvents([s.id])]:[3,6];case 5:return d.sent(),this.logger.debug("Event processed successfully",{eventId:s.id}),[3,10];case 6:return u=parseInt(o.status.code,10),De.RETRYABLE_HTTP_CODES.includes(u)?[4,this.markEventForRetry(s,o.status.message)]:[3,8];case 7:return d.sent(),[3,10];case 8:return[4,this.storage.removeEvents([s.id])];case 9:d.sent(),this.logger.warn("Event permanently failed - removed",{eventId:s.id,isDLR:s.isDLR,code:u,message:o.status.message}),d.label=10;case 10:return r=e.next(),[3,2];case 11:return[3,14];case 12:return a=d.sent(),c={error:a},[3,14];case 13:try{r&&!r.done&&(h=e.return)&&h.call(e)}finally{if(c)throw c.error}return[7];case 14:return[2]}})})},t.prototype.markEventForRetry=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r;return me(this,function(s){switch(s.label){case 0:return n=(t.attempts||0)+1,[4,this.storage.updateEventStatus(t.id,"failed","Attempt ".concat(n," failed: ").concat(i),n)];case 1:return s.sent(),e=Math.min(Math.max(n-1,0),this.RETRY_DELAYS.length-1),r=this.RETRY_DELAYS[e],this.logger.warn("Event marked for retry",{eventId:t.id,isDLR:t.isDLR,attempts:n,delay:r,isInfiniteRetry:n>this.RETRY_DELAYS.length,errorMessage:i}),[2]}})})},t.prototype.checkAndPromoteRetryEvents=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c,h,d;return me(this,function(f){switch(f.label){case 0:return f.trys.push([0,10,,11]),this.currentAccountId?[4,this.storage.getRetryableEvents(this.currentAccountId,Number.MAX_SAFE_INTEGER)]:(this.logger.debug("No account context, skipping retry check"),[2]);case 1:if(0===(t=f.sent()).length)return[2];i=0,f.label=2;case 2:f.trys.push([2,7,8,9]),n=ge(t),e=n.next(),f.label=3;case 3:return e.done?[3,6]:(r=e.value,s=Math.min(Math.max(r.attempts-1,0),this.RETRY_DELAYS.length-1),o=this.RETRY_DELAYS[s],(u=Date.now()-(r.lastAttempt||0))>=(o||0)?[4,this.storage.updateEventStatus(r.id,"pending")]:[3,5]);case 4:f.sent(),i++,this.logger.debug("Failed event promoted to pending",{eventId:r.id,attempt:r.attempts+1,delay:o,timeSinceLastAttempt:u}),f.label=5;case 5:return e=n.next(),[3,3];case 6:return[3,9];case 7:return a=f.sent(),h={error:a},[3,9];case 8:try{e&&!e.done&&(d=n.return)&&d.call(n)}finally{if(h)throw h.error}return[7];case 9:return i>0&&this.logger.debug("Promoted ".concat(i," failed events for retry")),[3,11];case 10:return c=f.sent(),this.logger.error("Failed to check retry events",{error:c}),[3,11];case 11:return[2]}})})},t.prototype.isRetryableHttpError=function(t){var i,n,e,r,s=t;if(s.code){var o=parseInt(s.code,10);return De.RETRYABLE_HTTP_CODES.includes(o)}return null!==(r=(null===(i=s.message)||void 0===i?void 0:i.includes("network"))||(null===(n=s.message)||void 0===n?void 0:n.includes("timeout"))||(null===(e=s.message)||void 0===e?void 0:e.includes("fetch")))&&void 0!==r&&r},t.prototype.removeNonRetryableEvents=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:i=t.map(function(t){return t.id}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.storage.removeEvents(i)];case 2:return e.sent(),this.logger.error("Non-retryable events removed permanently",{eventIds:i}),[3,4];case 3:return n=e.sent(),this.logger.error("Failed to remove non-retryable events",{eventIds:i,error:n}),[3,4];case 4:return[2]}})})},t.prototype.handleFailedBatch=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u;return me(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),i=ge(t),n=i.next(),a.label=1;case 1:if(n.done)return[3,6];e=n.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.markEventForRetry(e,"Batch failed")];case 3:return a.sent(),[3,5];case 4:return r=a.sent(),this.logger.error("Failed to mark event for retry",{eventId:e.id,error:r}),[3,5];case 5:return n=i.next(),[3,1];case 6:return[3,9];case 7:return s=a.sent(),o={error:s},[3,9];case 8:try{n&&!n.done&&(u=i.return)&&u.call(i)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},t.prototype.pause=function(){this.paused=!0,this.logger.info("EventQueue paused")},t.prototype.resume=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.paused=!1,this.logger.info("EventQueue resumed"),[4,this.processQueueIfIdle()];case 1:return t.sent(),[2]}})})},t.prototype.flush=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return[4,this.processQueueIfIdle()];case 1:return t.sent(),[2]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying EventQueue"),this.processingPromise?[4,this.processingPromise]:[3,2];case 1:t.sent(),t.label=2;case 2:return[4,this.storage.close()];case 3:return t.sent(),this.logger.info("EventQueue destroyed"),[2]}})})},t.QUEUE_LOCK_NAME="websdk-event-queue-lock",t}(),sc=function(){function t(t,i,n,e){this.eventQueue=null,this.initialized=!1,this.visitorId=null,this.visitorTrackingEnabled=null,this.config=t,this.logger=e,this.apiClient=i,this.storageManager=n}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("EventTracker already initialized"),[2]):(this.logger.info("Initializing EventTracker with IndexedDB queue"),this.eventQueue=new rc(this.apiClient,this.logger,this.storageManager,this.config.retryDelays,this.config.batchSize),[4,this.eventQueue.init()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(tr),[2]}})})},t.prototype.setUserContext=function(t,i,n){return ve(this,void 0,void 0,function(){return me(this,function(e){switch(e.label){case 0:if(!this.eventQueue)throw new Error("EventTracker not initialized");return[4,this.eventQueue.setUserContext(t,i,n)];case 1:return e.sent(),this.logger.info("User context set",{accountId:t,cuid:i,userIdentifierType:n}),[2]}})})},t.prototype.setVisitorTrackingState=function(t,i,n){this.visitorId=t,this.visitorTrackingEnabled=i,this.eventQueue&&this.eventQueue.setVisitorContext(t,n),this.logger.debug("Visitor tracking state updated",{visitorId:t,visitorExternalId:n,isEnabled:i,trackingMode:t?"anonymous":"not-configured"})},t.prototype.setSessionInfoCallback=function(t){if(!this.eventQueue)throw new Error("EventTracker not initialized");this.eventQueue.setSessionInfoCallback(t),this.logger.debug("Session info callback set in EventTracker")},t.prototype.clearUserContext=function(){this.eventQueue?(this.eventQueue.clearUserContext(),this.logger.info("User context cleared from EventTracker")):this.logger.warn("Cannot clear user context - EventTracker not initialized")},t.prototype.track=function(t){return ve(this,arguments,void 0,function(t,i){var n,e;return void 0===i&&(i=!1),me(this,function(r){switch(r.label){case 0:if(!this.initialized||!this.eventQueue)throw new Error("EventTracker not initialized");if(!1===this.visitorTrackingEnabled&&!i)throw this.logger.warn("Event tracking is disabled - visitor tracking is not enabled"),new Error("Event tracking is disabled");this.logger.debug("Tracking event",{event:t}),r.label=1;case 1:return r.trys.push([1,3,,4]),n=this.convertToApiEvent(t),[4,this.eventQueue.enqueue(n)];case 2:return r.sent(),[3,4];case 3:throw e=r.sent(),this.logger.error(er,{event:t,error:e}),new Error("".concat(Le,": ").concat(e));case 4:return[2]}})})},t.prototype.convertToApiEvent=function(t){if(!t.name||""===t.name.trim())throw new Error("Event name is required");var i=le({},t.data);if(!this.eventQueue)throw new Error("EventTracker not initialized");var n,e=this.eventQueue.getCurrentCuid();if(!e&&!this.visitorId){var r=null===this.visitorTrackingEnabled?"Cannot track event: User must be identified (cuid) or visitor tracking must be configured":"Cannot track event: Either visitor tracking must be enabled or user must be identified";throw this.logger.error(r,{hasVisitorId:!!this.visitorId,hasCuid:!1,visitorTrackingEnabled:this.visitorTrackingEnabled}),new Error(r)}return n=this.visitorId&&e?"identified":this.visitorId?"anonymous":"user-only",this.logger.debug("Creating event payload",{eventName:t.name,hasCuid:!!e,hasVisitorId:!!this.visitorId,trackingMode:n,visitorTrackingEnabled:this.visitorTrackingEnabled}),function(t,i){if(!t||""===t.trim())throw new Error("Event name is required");return{name:t.trim(),eventExternalId:ea(),eventDateTime:(new Date).toISOString(),attributes:i||{}}}(t.name,i)},t.prototype.pause=function(){this.eventQueue&&this.eventQueue.pause(),this.logger.info("EventTracker paused")},t.prototype.resume=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.eventQueue?[4,this.eventQueue.resume()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.logger.info("EventTracker resumed"),[2]}})})},t.prototype.flush=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.initialized&&this.eventQueue?(this.logger.info("Manual flush requested"),[4,this.eventQueue.flush()]):(this.logger.warn("Cannot flush events - EventTracker not initialized"),[2]);case 1:return t.sent(),[2]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying EventTracker"),this.eventQueue?[4,this.eventQueue.destroy()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.initialized=!1,this.logger.info(ir),[2]}})})},t.prototype.trackNotificationReceived=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){switch(i.label){case 0:return[4,this.trackDLREvent("received",t)];case 1:return i.sent(),[2]}})})},t.prototype.trackNotificationClicked=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){switch(i.label){case 0:return[4,this.trackDLREvent("clicked",t)];case 1:return i.sent(),[2]}})})},t.prototype.trackNotificationDismissed=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){switch(i.label){case 0:return[4,this.trackDLREvent("dismissed",t)];case 1:return i.sent(),[2]}})})},t.prototype.trackDLREvent=function(t,i){return ve(this,void 0,void 0,function(){var n,e;return me(this,function(r){switch(r.label){case 0:if(!this.initialized||!this.eventQueue)return this.logger.error("EventTracker not initialized, skipping DLR event",{eventType:t}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),n=this.createDLREvent(t,i),[4,this.eventQueue.enqueue(n,!0)];case 2:return r.sent(),this.logger.info("DLR event tracked: ".concat(t),{eventType:t,eventName:n.name,messageId:i.messageId}),[3,4];case 3:return e=r.sent(),this.logger.error("Failed to track DLR event",{eventType:t,notificationData:i,error:e}),[3,4];case 4:return[2]}})})},t.prototype.createDLREvent=function(t,i){var n,e={received:Bs.NOTIFICATION_RECEIVED,clicked:Bs.NOTIFICATION_CLICKED,dismissed:Bs.NOTIFICATION_DISMISSED},r=null===(n=this.eventQueue)||void 0===n?void 0:n.getCurrentCuid(),s={messageId:i.messageId,gateway:zs,result:{received:"SUCCESS",clicked:"CLICKED",dismissed:"DISMISSED"}[t],notification_route:js,cuid:r||null,visitor_id:r?null:this.visitorId||null,scope:i.scope||null};return"received"===t&&(s.notification_id=i.messageId,s.campaign_id=i.campaignId||null,s.channel=js,s.title=i.title||null),"clicked"===t&&(s.notification_id=i.messageId,s.campaign_id=i.campaignId||null,s.channel=js,s.action="open_app"),i.senderId&&(s.senderId=i.senderId),{attributes:s,name:e[t],eventDateTime:(new Date).toISOString(),eventExternalId:ea()}},t.prototype.dispatchDLREvent=function(t){return ve(this,void 0,void 0,function(){var i;return me(this,function(n){switch(n.label){case 0:switch(i=le(le(le(le(le(le({messageId:t.messageId},void 0!==t.scope?{scope:t.scope}:{}),void 0!==t.campaignId?{campaignId:t.campaignId}:{}),void 0!==t.variationId?{variationId:t.variationId}:{}),void 0!==t.senderId?{senderId:t.senderId}:{}),void 0!==t.cuid?{cuid:t.cuid}:{}),void 0!==t.accountId?{accountId:t.accountId}:{}),t.type){case"received":return[3,1];case"clicked":return[3,3];case"dismissed":return[3,5]}return[3,7];case 1:return[4,this.trackNotificationReceived(i)];case 2:case 4:case 6:return n.sent(),[3,7];case 3:return[4,this.trackNotificationClicked(i)];case 5:return[4,this.trackNotificationDismissed(i)];case 7:return[2]}})})},t.prototype.processPendingServiceWorkerDLREvents=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u;return me(this,function(a){switch(a.label){case 0:if(!this.initialized)return this.logger.error("EventTracker not initialized, skipping pending DLR event processing"),[2];a.label=1;case 1:return a.trys.push([1,12,,13]),[4,this.getServiceWorkerPendingDLREvents()];case 2:if(0===(t=a.sent()).length)return[2];this.logger.info("Processing pending service worker DLR events",{count:t.length}),a.label=3;case 3:a.trys.push([3,8,9,10]),i=ge(t),n=i.next(),a.label=4;case 4:return n.done?[3,7]:(e=n.value,[4,this.dispatchDLREvent(e)]);case 5:a.sent(),a.label=6;case 6:return n=i.next(),[3,4];case 7:return[3,10];case 8:return r=a.sent(),o={error:r},[3,10];case 9:try{n&&!n.done&&(u=i.return)&&u.call(i)}finally{if(o)throw o.error}return[7];case 10:return[4,this.clearServiceWorkerPendingDLREvents()];case 11:return a.sent(),this.logger.info("Processed pending service worker DLR events",{count:t.length}),[3,13];case 12:return s=a.sent(),this.logger.error("Failed to process pending service worker DLR events",{error:s}),[3,13];case 13:return[2]}})})},t.prototype.getServiceWorkerPendingDLREvents=function(){return ve(this,void 0,void 0,function(){var t=this;return me(this,function(i){return[2,new Promise(function(i){var n=indexedDB.open("WebSDK_DLR_SW",1);n.onerror=function(){t.logger.error("Failed to open WebSDK_DLR_SW database",n.error),i([])},n.onsuccess=function(){var e=n.result;if(!e.objectStoreNames.contains("pending_dlr_events"))return e.close(),void i([]);var r=e.transaction(["pending_dlr_events"],"readonly").objectStore("pending_dlr_events").getAll();r.onerror=function(){t.logger.error("Failed to read pending service worker DLR events",r.error),e.close(),i([])},r.onsuccess=function(){e.close(),i(r.result||[])}},n.onupgradeneeded=function(t){var i=t.target.result;i.objectStoreNames.contains("pending_dlr_events")||i.createObjectStore("pending_dlr_events",{keyPath:"id",autoIncrement:!0})}})]})})},t.prototype.clearServiceWorkerPendingDLREvents=function(){return ve(this,void 0,void 0,function(){var t=this;return me(this,function(i){return[2,new Promise(function(i){var n=indexedDB.open("WebSDK_DLR_SW",1);n.onerror=function(){t.logger.error("Failed to open WebSDK_DLR_SW database",n.error),i()},n.onsuccess=function(){var e=n.result;if(!e.objectStoreNames.contains("pending_dlr_events"))return e.close(),void i();var r=e.transaction(["pending_dlr_events"],"readwrite").objectStore("pending_dlr_events").clear();r.onerror=function(){t.logger.error("Failed to clear pending service worker DLR events",r.error),e.close(),i()},r.onsuccess=function(){e.close(),i()}},n.onupgradeneeded=function(t){var i=t.target.result;i.objectStoreNames.contains("pending_dlr_events")||i.createObjectStore("pending_dlr_events",{keyPath:"id",autoIncrement:!0})}})]})})},t}(),oc=function(){function t(t,i,n){this.initialized=!1,this.logger=t,this.brandId=i,this.applicationId=n,this.adapter=new uc(t)}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:if(this.initialized)return this.logger.warn("StorageManager already initialized"),[2];this.logger.info("Initializing StorageManager"),t=["WebSDK"],this.brandId&&t.push(this.brandId),this.applicationId&&t.push(this.applicationId),i=t.join("_"),r.label=1;case 1:return r.trys.push([1,6,,7]),this.isIndexedDBSupported()?(n=new ec(this.logger,i),[4,this.testStorageAdapter(n)]):[3,3];case 2:return r.sent(),this.adapter=n,this.logger.info("StorageManager initialized with IndexedDB",{dbName:i,brandId:this.brandId,applicationId:this.applicationId}),[3,5];case 3:return[4,this.testStorageAdapter(this.adapter)];case 4:r.sent(),this.logger.info("StorageManager initialized with localStorage"),r.label=5;case 5:return this.initialized=!0,[3,7];case 6:throw e=r.sent(),this.logger.error(pr,{brandId:this.brandId,applicationId:this.applicationId,dbName:i,error:e}),new Error("Storage initialization failed: ".concat(e));case 7:return[2]}})})},t.prototype.isIndexedDBSupported=function(){return"undefined"!=typeof window&&"indexedDB"in window&&null!==indexedDB},t.prototype.testStorageAdapter=function(t){return ve(this,void 0,void 0,function(){var i,n,e;return me(this,function(r){switch(r.label){case 0:i=Ce,n=Re,r.label=1;case 1:return r.trys.push([1,5,,6]),[4,t.setItem(i,n)];case 2:return r.sent(),[4,t.getItem(i)];case 3:if(r.sent()!==n)throw new Error(yr);return[4,t.removeItem(i)];case 4:return r.sent(),[3,6];case 5:throw e=r.sent(),new Error("".concat(wr," ").concat(e));case 6:return[2]}})})},t.prototype.get=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.getItem(t)]})})},t.prototype.set=function(t,i){return ve(this,void 0,void 0,function(){return me(this,function(n){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.setItem(t,i)]})})},t.prototype.remove=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.removeItem(t)]})})},t.prototype.clear=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.clear()]})})},t.prototype.keys=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.getAllKeys(t)]})})},t.prototype.getIndexedDBAdapter=function(){return this.adapter instanceof ec?this.adapter:null},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:this.logger.info("Destroying StorageManager"),i.label=1;case 1:return i.trys.push([1,4,,5]),this.adapter instanceof ec?[4,this.adapter.close()]:[3,3];case 2:i.sent(),i.label=3;case 3:return this.initialized=!1,this.logger.info(Er),[3,5];case 4:return t=i.sent(),this.logger.error(_r,t),this.initialized=!1,[3,5];case 5:return[2]}})})},t}(),uc=function(){function t(t){this.logger=t}return t.prototype.getItem=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){try{return[2,localStorage.getItem(t)]}catch(i){throw this.logger.error("LocalStorage getItem failed",{key:t,error:i}),new Error("LocalStorage getItem failed: ".concat(i))}return[2]})})},t.prototype.setItem=function(t,i){return ve(this,void 0,void 0,function(){return me(this,function(n){try{localStorage.setItem(t,i)}catch(i){if(i instanceof DOMException&&(22===i.code||1014===i.code||"QuotaExceededError"===i.name||"NS_ERROR_DOM_QUOTA_REACHED"===i.name))throw this.logger.error("LocalStorage quota exceeded",{key:t,error:i}),new Error("LocalStorage quota exceeded");throw this.logger.error("LocalStorage setItem failed",{key:t,error:i}),new Error("LocalStorage setItem failed: ".concat(i))}return[2]})})},t.prototype.removeItem=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){try{localStorage.removeItem(t)}catch(i){throw this.logger.error("LocalStorage removeItem failed",{key:t,error:i}),new Error("LocalStorage removeItem failed: ".concat(i))}return[2]})})},t.prototype.clear=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){try{localStorage.clear()}catch(t){throw this.logger.error("LocalStorage clear failed",{error:t}),new Error("LocalStorage clear failed: ".concat(t))}return[2]})})},t.prototype.getAllKeys=function(t){return ve(this,void 0,void 0,function(){var i,n,e;return me(this,function(r){try{for(i=[],n=0;n<localStorage.length;n++)null!==(e=localStorage.key(n))&&i.push(e);return[2,t?i.filter(function(i){return i.startsWith(t)}):i]}catch(t){throw this.logger.error("LocalStorage getAllKeys failed",{error:t}),new Error("LocalStorage getAllKeys failed: ".concat(t))}return[2]})})},t}();!function(t){t[t.VERBOSE=0]="VERBOSE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.NONE=5]="NONE"}(nc||(nc={}));var ac=function(){function t(t,i){void 0===t&&(t=!1),void 0===i&&(i=nc.INFO),this.logs=[],this.maxLogs=1e3,this.context={orgId:"",accountId:"",visitorId:"",cuid:""},this.enabled=t,this.level=i}return t.prototype.setContext=function(t){this.context=le(le({},this.context),t)},Object.defineProperty(t.prototype,"contextPrefix",{get:function(){var t=this.context.cuid||this.context.visitorId,i=[this.context.orgId,this.context.accountId,t].filter(Boolean);return i.length>0?"[".concat(i.join(" -> "),"]"):""},enumerable:!1,configurable:!0}),t.prototype.formatMessage=function(t,i){var n=(new Date).toISOString(),e=nc[t];return"[".concat(n,"] [WebSDK:").concat(e,"] ").concat(i)},t.prototype.log=function(t,i,n){if(this.enabled&&!(t<this.level)){var e={level:t,message:i,timestamp:Date.now(),data:n};this.logs.push(e),this.logs.length>this.maxLogs&&this.logs.shift();var r=t===nc.INFO||t===nc.ERROR?this.contextPrefix:"",s=r?"".concat(r," ").concat(i):i,o=this.formatMessage(t,s),u=n?[o,n]:[o];switch(t){case nc.VERBOSE:case nc.DEBUG:console.debug.apply(console,we([],pe(u),!1));break;case nc.INFO:console.info.apply(console,we([],pe(u),!1));break;case nc.WARN:console.warn.apply(console,we([],pe(u),!1));break;case nc.ERROR:console.error.apply(console,we([],pe(u),!1))}}},t.prototype.verbose=function(t,i){this.log(nc.VERBOSE,t,i)},t.prototype.debug=function(t,i){this.log(nc.DEBUG,t,i)},t.prototype.info=function(t,i){this.log(nc.INFO,t,i)},t.prototype.warn=function(t,i){this.log(nc.WARN,t,i)},t.prototype.error=function(t,i){this.log(nc.ERROR,t,i)},t.prototype.setLevel=function(t){this.level=t},t.prototype.setEnabled=function(t){this.enabled=t},t.prototype.getLogs=function(){return we([],pe(this.logs),!1)},t.prototype.clearLogs=function(){this.logs=[]},t}(),cc=function(){function t(t,i,n,e,r,s){this.initialized=!1,this.cachedConfig=null,this.orgId=t,this.apiClient=i,this.logger=n,this.storageManager=e,void 0!==r&&(this.brandId=r),void 0!==s&&(this.applicationId=s)}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("VisitorConfigManager already initialized"),[2]):(this.logger.info("Initializing VisitorConfigManager",{orgId:this.orgId}),[4,this.restoreCachedConfig()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(xr),[2]}})})},t.prototype.fetchConfig=function(){return ve(this,void 0,void 0,function(){var t,i,n=this;return me(this,function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("VisitorConfigManager not initialized");if(this.cachedConfig)return this.logger.info(Fr),[2,this.cachedConfig];e.label=1;case 1:return e.trys.push([1,4,,5]),this.logger.info("Fetching visitor config from API",{orgId:this.orgId}),[4,this.apiClient.getVisitorConfig(this.orgId)];case 2:return(t=e.sent()).warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){n.logger.warn("Visitor config warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){n.logger.error("Visitor config error from response",{code:t.code,message:t.message})}),this.cachedConfig=t,[4,this.storeCachedConfig(t)];case 3:return e.sent(),[2,t];case 4:throw i=e.sent(),new Error("".concat(Fe,": ").concat(i));case 5:return[2]}})})},t.prototype.isVisitorTrackingEnabled=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.fetchConfig()];case 1:return t=r.sent(),(i=!0===(null===(e=t.data)||void 0===e?void 0:e.visitorTrackingEnabled))?this.logger.info(Lr):this.logger.info(Ur),[2,i];case 2:return n=r.sent(),this.logger.error("Failed to check visitor tracking status",{error:n}),[2,!1];case 3:return[2]}})})},t.prototype.refreshConfig=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){if(!this.initialized)throw new Error("VisitorConfigManager not initialized");return this.logger.info("Force refreshing visitor config from API"),this.cachedConfig=null,[2,this.fetchConfig()]})})},t.prototype.getCachedConfig=function(){return this.cachedConfig},t.prototype.storeCachedConfig=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),i=Ae("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.set(i,JSON.stringify(t))];case 1:return e.sent(),this.logger.debug("Visitor config cached to storage",{key:i}),[3,3];case 2:return n=e.sent(),this.logger.error("Failed to store visitor config to cache",{error:n}),[3,3];case 3:return[2]}})})},t.prototype.restoreCachedConfig=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r;return me(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=Ae("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(i=s.sent())&&(n=JSON.parse(i),this.cachedConfig=n,this.logger.info("Visitor config restored from cache",{isEnabled:null===(r=n.data)||void 0===r?void 0:r.visitorTrackingEnabled})),[3,3];case 2:return e=s.sent(),this.logger.error("Failed to restore visitor config from cache",{error:e}),this.cachedConfig=null,[3,3];case 3:return[2]}})})},t.prototype.clearCachedConfig=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:this.cachedConfig=null,n.label=1;case 1:return n.trys.push([1,3,,4]),t=Ae("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 2:return n.sent(),this.logger.debug("Visitor config cache cleared"),[3,4];case 3:return i=n.sent(),this.logger.error("Failed to clear visitor config cache",{error:i}),[3,4];case 4:return[2]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying VisitorConfigManager"),[4,this.clearCachedConfig()];case 1:return t.sent(),this.initialized=!1,this.logger.info("VisitorConfigManager destroyed successfully"),[2]}})})},t}(),hc=function(){function t(t,i,n,e,r,s){this.initialized=!1,this.visitorId=null,this.visitorExternalId=null,this.expiredAt=null,this.getFcmToken=null,this.getChannelType=null,this.getExtendedFields=null,this.getPermissionGranted=null,this.getSessionId=null,this.mergeRetryTimeoutId=null,this.accountId=t,this.orgId=i,this.apiClient=n,this.logger=e,this.storageManager=r,void 0!==(null==s?void 0:s.brandId)&&(this.brandId=s.brandId),void 0!==(null==s?void 0:s.applicationId)&&(this.applicationId=s.applicationId)}return t.prototype.setMergeDataProviders=function(t,i,n,e,r){this.getFcmToken=t,this.getChannelType=i,this.getExtendedFields=n,this.getPermissionGranted=e,this.getSessionId=r},t.prototype.init=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("AnonymousVisitorManager already initialized"),[2]):(this.logger.info("Initializing AnonymousVisitorManager",{accountId:this.accountId,orgId:this.orgId}),[4,this.restoreVisitorId()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(Gr),[2]}})})},t.prototype.getOrCreateVisitorId=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s;return me(this,function(o){switch(o.label){case 0:if(!this.initialized)throw this.logger.error("getOrCreateVisitorId() called before AnonymousVisitorManager is initialized"),new Error("AnonymousVisitorManager not initialized");if(this.visitorId&&!this.isVisitorExpired())return this.logger.info(jr,{visitorId:this.visitorId}),[2,this.visitorId];if(this.visitorId&&this.isVisitorExpired()&&this.logger.info("Visitor session expired, creating new visitor via API",{visitorId:this.visitorId,expiredAt:this.expiredAt}),!this.accountId||""===this.accountId.trim())throw n=new Error("AccountId is required for visitor creation"),this.logger.error("Visitor creation validation failed",n),n;return this.logger.info("Creating new visitor ID",{accountId:this.accountId,hasCommChannels:!!t&&t.length>0,hasExtendedFields:!!i}),[4,this.createVisitor(t,i)];case 1:return e=o.sent(),r=e.visitorId,s=e.expiredAt,this.visitorId=r,[4,this.storeVisitorId(r)];case 2:return o.sent(),[4,this.storeExpiredAt(s)];case 3:return o.sent(),this.logger.info(Vr,{visitorId:r}),[2,r]}})})},t.prototype.createVisitor=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),[4,this.getOrGenerateVisitorExternalId()];case 1:return n=u.sent(),e=t&&t.length>0?t:[],r=le({visitorExternalId:n,profiles:[{commChannels:e}]},i&&{extendedFields:i}),this.logger.debug("Visitor creation request payload",{request:r}),[4,this.apiClient.createVisitor(this.orgId,r)];case 2:return s=u.sent(),[2,this.handleCreateVisitorResponse(s)];case 3:throw o=u.sent(),this.handleCreateVisitorError(o),o;case 4:return[2]}})})},t.prototype.handleCreateVisitorResponse=function(t){var i,n,e=this;t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){e.logger.warn("Visitor creation warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){e.logger.error("Visitor creation error from response",{code:t.code,message:t.message})});var r=null===(i=t.data)||void 0===i?void 0:i.id;if(!r||""===r.trim())throw this.logger.error("Invalid visitor ID received from API",{response:t}),new Error("Invalid visitor ID received from API");var s=null===(n=t.data)||void 0===n?void 0:n.expiredAt;if(!s)throw this.logger.error("Missing expiredAt in visitor creation response",{response:t}),new Error("Missing expiredAt in visitor creation response");return{visitorId:r,expiredAt:s}},t.prototype.logCreateVisitorWarnings=function(t){var i=this;return!(!t||0===t.length)&&(t.forEach(function(t){t.code===Gs.ACCOUNT_NOT_EXISTS?i.logger.error("Account does not exist",{code:t.code,message:t.message,accountId:i.accountId}):i.logger.warn("Visitor creation warning",{code:t.code,message:t.message})}),!0)},t.prototype.logCreateVisitorErrors=function(t){var i=this;return!(!t||0===t.length)&&(t.forEach(function(t){t.code===Gs.ACCOUNT_ID_NOT_PASSED?i.logger.error("AccountId not passed",{code:t.code,message:t.message}):i.logger.error("Visitor creation error",{code:t.code,message:t.message})}),!0)},t.prototype.handleCreateVisitorError=function(t){var i;try{var n=(null===(i=t.response)||void 0===i?void 0:i.data)||t,e=this.logCreateVisitorWarnings(n.warnings),r=this.logCreateVisitorErrors(n.errors);e||r||this.logger.error("Visitor creation failed with an unrecognized error shape",{accountId:this.accountId,error:t})}catch(t){this.logger.error("Failed to parse visitor creation error",{parseError:t})}},t.prototype.updateVisitor=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s;return me(this,function(o){switch(o.label){case 0:if(!this.initialized)throw new Error("AnonymousVisitorManager not initialized");if(!this.visitorId)throw new Error("No visitor ID exists. Create a visitor first.");o.label=1;case 1:return o.trys.push([1,3,,4]),n=t&&t.length>0?t:[],e=le({profiles:[{commChannels:n}]},i&&{extendedFields:i}),this.logger.debug("Visitor update request payload",{request:e}),[4,this.apiClient.updateVisitor(this.orgId,this.visitorId,e)];case 2:return r=o.sent(),[2,this.handleUpdateVisitorResponse(r)];case 3:throw s=o.sent(),this.handleUpdateVisitorError(s),s;case 4:return[2]}})})},t.prototype.handleUpdateVisitorResponse=function(t){var i,n=this;t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){n.logger.warn("Visitor update warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){n.logger.error("Visitor update error from response",{code:t.code,message:t.message})});var e=null===(i=t.data)||void 0===i?void 0:i.id;if(!e||""===e.trim())throw this.logger.error("Invalid visitor ID received from update API",{response:t}),new Error("Invalid visitor ID received from update API");return e},t.prototype.logUpdateVisitorWarnings=function(t){var i=this;return!(!t||0===t.length)&&(t.forEach(function(t){t.code===Gs.ACCOUNT_NOT_EXISTS?i.logger.error("Account does not exist",{code:t.code,message:t.message,accountId:i.accountId}):i.logger.warn("Visitor update warning",{code:t.code,message:t.message})}),!0)},t.prototype.logUpdateVisitorErrors=function(t){var i=this;return!(!t||0===t.length)&&(t.forEach(function(t){i.logger.error("Visitor update error",{code:t.code,message:t.message})}),!0)},t.prototype.handleUpdateVisitorError=function(t){var i;try{var n=(null===(i=t.response)||void 0===i?void 0:i.data)||t,e=this.logUpdateVisitorWarnings(n.warnings),r=this.logUpdateVisitorErrors(n.errors);e||r||this.logger.error("Visitor update failed with an unrecognized error shape",{visitorId:this.visitorId,error:t})}catch(t){this.logger.error("Failed to parse visitor update error",{parseError:t})}},t.prototype.mergeVisitorWithUser=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a,c,h,d;return me(this,function(f){switch(f.label){case 0:if(i=t.firstName,n=t.lastName,e=t.email,r=t.mobile,s=t.externalId,o=t.customData,u=t.cuid,a=t.identifierType,!this.initialized)return this.logger.warn(Xr,{reason:"Not initialized"}),[2,!1];if(!this.visitorId)return this.logger.warn(Xr,{reason:"No visitor ID"}),[2,!1];if(!e&&!r&&!s)return this.logger.warn(Xr,{reason:"No email, mobile, or externalId"}),[2,!1];c=this.visitorId,h=this.visitorExternalId,f.label=1;case 1:return f.trys.push([1,5,,6]),[4,this.isMerged()];case 2:return f.sent()?(this.logger.info(Xr,{reason:"Visitor already merged",visitorId:c}),[2,!0]):[4,this.persistPendingMerge(c,h,le(le(le(le(le(le({firstName:i,lastName:n},void 0!==e&&{email:e}),void 0!==r&&{mobile:r}),void 0!==s&&{externalId:s}),void 0!==o&&{customData:o}),void 0!==u&&{cuid:u}),void 0!==a&&{identifierType:a}))];case 3:return f.sent(),[4,this.attemptPendingMerge()];case 4:return f.sent(),[2,this.isMerged()];case 5:return d=f.sent(),this.logger.error("Merge background task failed unexpectedly",{error:d}),[2,!1];case 6:return[2]}})})},t.prototype.retryPendingMerge=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,7,,8]),[4,this.getPendingMerge()];case 1:return(t=n.sent())?[4,this.isMerged()]:[2];case 2:return n.sent()?[4,this.clearPendingMerge()]:[3,4];case 3:return n.sent(),this.logger.info(Xr,{reason:"Already merged"}),[2];case 4:return t.attempts>=Ms?(this.logger.error(Wr,{visitorId:t.visitorId,attempts:t.attempts,message:"Max retries exhausted"}),[4,this.clearPendingMerge()]):[3,6];case 5:return n.sent(),[2];case 6:return this.scheduleMergeRetry(),[3,8];case 7:return i=n.sent(),this.logger.error("Failed to retry pending merge",{error:i}),[3,8];case 8:return[2]}})})},t.prototype.cancelMergeRetryTimer=function(){null!==this.mergeRetryTimeoutId&&(globalThis.clearTimeout(this.mergeRetryTimeoutId),this.mergeRetryTimeoutId=null)},t.prototype.scheduleMergeRetry=function(){var t=this;this.cancelMergeRetryTimer(),this.mergeRetryTimeoutId=globalThis.setTimeout(function(){t.mergeRetryTimeoutId=null,t.attemptPendingMerge().catch(function(i){t.logger.error("Scheduled merge retry failed unexpectedly",{error:i})})},Us)},t.prototype.collectMergeContext=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:t=this.getFcmToken?this.getFcmToken():null,i=this.getChannelType?this.getChannelType():void 0,n=!this.getPermissionGranted||this.getPermissionGranted(),e=this.getSessionId?this.getSessionId():"",u.label=1;case 1:return u.trys.push([1,5,,6]),this.getExtendedFields?[4,this.getExtendedFields()]:[3,3];case 2:return s=u.sent(),[3,4];case 3:s=void 0,u.label=4;case 4:return r=s,[3,6];case 5:return o=u.sent(),this.logger.error("Failed to collect extended fields for merge, proceeding without them",{error:o}),r=void 0,[3,6];case 6:return[2,{fcmToken:t,channelType:i,subscribed:n,sessionId:e,extendedFields:r}]}})})},t.prototype.attemptPendingMerge=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u;return me(this,function(a){switch(a.label){case 0:return[4,this.getPendingMerge()];case 1:return(t=a.sent())?[4,this.collectMergeContext()]:(this.logger.debug("attemptPendingMerge() found no pending merge to attempt"),[2]);case 2:i=a.sent(),n=i.fcmToken,e=i.channelType,r=i.subscribed,s=i.sessionId,o=i.extendedFields,a.label=3;case 3:return a.trys.push([3,7,,9]),[4,this.apiClient.mergeVisitor(t.visitorId,t.visitorExternalId||null,le(le(le(le(le(le(le(le(le(le({firstName:t.firstName,lastName:t.lastName},void 0!==t.email&&{email:t.email}),void 0!==t.mobile&&{mobile:t.mobile}),n?{fcmToken:n,subscribed:r}:{}),void 0!==e&&{channelType:e}),{fields:t.customData||{}}),void 0!==o&&{extendedFields:o}),void 0!==t.externalId&&{externalId:t.externalId}),void 0!==t.cuid&&{cuid:t.cuid}),void 0!==t.identifierType&&{identifierType:t.identifierType}),{sessionId:s}))];case 4:return a.sent(),[4,this.markAsMerged(t.visitorId)];case 5:return a.sent(),[4,this.clearPendingMerge()];case 6:return a.sent(),this.logger.info(Kr,{visitorId:t.visitorId,attempts:t.attempts+1}),[3,9];case 7:return u=a.sent(),[4,this.handleMergeRetryOrAbort(u,t)];case 8:return a.sent(),[3,9];case 9:return[2]}})})},t.prototype.handleMergeRetryOrAbort=function(t,i){return ve(this,void 0,void 0,function(){var n;return me(this,function(e){switch(e.label){case 0:return t instanceof ic?[4,this.clearPendingMerge()]:[3,2];case 1:return e.sent(),this.logger.error("Visitor merge failed permanently, will not retry",{code:t.code,message:t.message,visitorId:i.visitorId}),[2];case 2:return n=le(le({},i),{attempts:i.attempts+1}),[4,this.savePendingMerge(n)];case 3:return e.sent(),n.attempts>=Ms?(this.logger.error(Wr,{visitorId:i.visitorId,attempts:n.attempts,message:"Max retries exhausted"}),[4,this.clearPendingMerge()]):[3,5];case 4:return e.sent(),[2];case 5:return this.logger.warn("Visitor merge attempt failed, scheduling retry",{attempt:n.attempts,maxRetries:Ms,nextRetryMs:Us,visitorId:i.visitorId,error:t}),this.scheduleMergeRetry(),[2]}})})},t.prototype.persistPendingMerge=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o,u,a,c,h,d;return me(this,function(f){switch(f.label){case 0:return e=n.firstName,r=n.lastName,s=n.email,o=n.mobile,u=n.externalId,a=n.customData,c=n.cuid,h=n.identifierType,d=le(le(le(le(le(le(le(le(le({visitorId:t},i&&{visitorExternalId:i}),{firstName:e,lastName:r}),void 0!==s&&{email:s}),void 0!==o&&{mobile:o}),void 0!==u&&{externalId:u}),void 0!==a&&{customData:a}),void 0!==c&&{cuid:c}),void 0!==h&&{identifierType:h}),{attempts:0}),[4,this.savePendingMerge(d)];case 1:return f.sent(),this.logger.debug("Pending merge request persisted to storage",{visitorId:t}),[2]}})})},t.prototype.getPendingMerge=function(){return ve(this,void 0,void 0,function(){var t,i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Ae("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(i=e.sent())?[2,JSON.parse(i)]:[2,null];case 2:return n=e.sent(),this.logger.error("Failed to read pending merge from storage",{error:n}),[2,null];case 3:return[2]}})})},t.prototype.savePendingMerge=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),i=Ae("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.set(i,JSON.stringify(t))];case 1:return e.sent(),[3,3];case 2:return n=e.sent(),this.logger.error("Failed to save pending merge to storage",{error:n}),[3,3];case 3:return[2]}})})},t.prototype.clearPendingMerge=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:this.cancelMergeRetryTimer(),n.label=1;case 1:return n.trys.push([1,3,,4]),t=Ae("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 2:return n.sent(),this.logger.debug("Pending merge cleared from storage"),[3,4];case 3:return i=n.sent(),this.logger.error("Failed to clear pending merge from storage",{error:i}),[3,4];case 4:return[2]}})})},t.prototype.isMerged=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=Ae("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,null!=n.sent()];case 2:return i=n.sent(),this.logger.error("Failed to check merge status",{error:i}),[2,!1];case 3:return[2]}})})},t.prototype.getMergedUserId=function(){return ve(this,void 0,void 0,function(){var t,i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Ae("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,null!=(i=e.sent())?i:null];case 2:return n=e.sent(),this.logger.error("Failed to get merge status",{error:n}),[2,null];case 3:return[2]}})})},t.prototype.clearMergedUserId=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=Ae("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return n.sent(),this.logger.info("Merge status cleared from storage"),[3,3];case 2:return i=n.sent(),this.logger.error("Failed to clear merge status",{error:i}),[3,3];case 3:return[2]}})})},t.prototype.markAsMerged=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),i=Ae("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.set(i,t)];case 1:return e.sent(),this.logger.debug("Visitor marked as merged",{visitorId:t,key:i}),[3,3];case 2:return n=e.sent(),this.logger.error("Failed to store merge status",{error:n}),[3,3];case 3:return[2]}})})},t.prototype.getVisitorId=function(){return this.visitorId},t.prototype.getVisitorExternalId=function(){return this.visitorExternalId},t.prototype.hasVisitorId=function(){return null!==this.visitorId},t.prototype.storeVisitorId=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),i=Ae("VISITOR_ID",this.brandId,this.applicationId),[4,this.storageManager.set(i,t)];case 1:return e.sent(),this.logger.debug("Visitor ID stored to storage",{visitorId:t,key:i}),[3,3];case 2:return n=e.sent(),this.logger.error("Failed to store visitor ID",{error:n}),[3,3];case 3:return[2]}})})},t.prototype.storeExpiredAt=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.expiredAt=t,i=Ae("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.set(i,t)];case 1:return e.sent(),this.logger.debug("Visitor expiredAt stored to storage",{expiredAt:t}),[3,3];case 2:return n=e.sent(),this.logger.error("Failed to store visitor expiredAt",{error:n}),[3,3];case 3:return[2]}})})},t.prototype.isVisitorExpired=function(){if(!this.expiredAt)return!0;try{return new Date(this.expiredAt).getTime()<=Date.now()}catch(t){return this.logger.error("Invalid expiredAt format, treating as expired",{expiredAt:this.expiredAt}),!0}},t.prototype.getOrGenerateVisitorExternalId=function(){return ve(this,void 0,void 0,function(){var t,i,n;return me(this,function(e){switch(e.label){case 0:if(this.visitorExternalId)return[2,this.visitorExternalId];t=ea(),this.visitorExternalId=t,e.label=1;case 1:return e.trys.push([1,3,,4]),i=Ae("VISITOR_EXTERNAL_ID",this.brandId,this.applicationId),[4,this.storageManager.set(i,t)];case 2:return e.sent(),this.logger.debug("visitorExternalId generated and stored",{visitorExternalId:t}),[3,4];case 3:return n=e.sent(),this.logger.error("Failed to store visitorExternalId",{error:n}),[3,4];case 4:return[2,t]}})})},t.prototype.restoreVisitorId=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:return u.trys.push([0,4,,5]),t=Ae("VISITOR_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(i=u.sent())&&(this.visitorId=i,this.logger.info(zr,{visitorId:i})),n=Ae("VISITOR_EXTERNAL_ID",this.brandId,this.applicationId),[4,this.storageManager.get(n)];case 2:return(e=u.sent())&&(this.visitorExternalId=e),r=Ae("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(r)];case 3:return(s=u.sent())&&(this.expiredAt=s),[3,5];case 4:return o=u.sent(),this.logger.error("Failed to restore visitor ID from storage",{accountId:this.accountId,error:o}),this.visitorId=null,[3,5];case 5:return[2]}})})},t.prototype.clearVisitorId=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),t=Ae("VISITOR_ID",this.brandId,this.applicationId),i=Ae("VISITOR_EXTERNAL_ID",this.brandId,this.applicationId),n=Ae("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return r.sent(),[4,this.storageManager.remove(i)];case 2:return r.sent(),[4,this.storageManager.remove(n)];case 3:return r.sent(),this.visitorId=null,this.visitorExternalId=null,this.expiredAt=null,this.logger.info("Visitor ID cleared from storage"),[3,5];case 4:return e=r.sent(),this.logger.error("Failed to clear visitor ID",{error:e}),this.visitorId=null,this.visitorExternalId=null,this.expiredAt=null,[3,5];case 5:return[2]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){return this.logger.info("Destroying AnonymousVisitorManager"),this.cancelMergeRetryTimer(),this.initialized=!1,this.logger.info("AnonymousVisitorManager destroyed successfully"),[2]})})},t}();function dc(){return"undefined"!=typeof window&&window.firebase?window.firebase:null}function fc(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){return(t=dc())?[2,t]:[2,import("firebase/app")]})})}function lc(){return ve(this,void 0,void 0,function(){return me(this,function(t){return[2,import("firebase/messaging")]})})}function vc(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){return(t=dc())&&t.remoteConfig?[2,t]:[2,import("firebase/remote-config")]})})}var mc=function(){function t(t,i,n,e,r,s){this.isInitialized=!1,this.currentToken=null,this.swRegistration=null,this.messaging=t,this.logger=i,this.vapidKey=n,this.serviceWorkerPath=e||ke,this.onTokenReceivedCallback=r,this.onMessageReceivedCallback=s}return t.prototype.initialize=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){return this.isInitialized?(this.logger.warn(us),[2,!0]):this.messaging?(this.isInitialized=!0,this.logger.info(Zr),[2,!0]):(this.logger.error(ts,new Error("Messaging instance missing")),[2,!1])})})},t.prototype.ensureServiceWorkerRegistered=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:return this.swRegistration?[2,this.swRegistration]:this.isInitialized&&this.messaging?(t=this,[4,this.registerServiceWorker()]):(this.logger.warn("ensureServiceWorkerRegistered() called before Firebase is initialized",{isInitialized:this.isInitialized,hasMessaging:!!this.messaging}),[2,null]);case 1:return t.swRegistration=i.sent(),[2,this.swRegistration]}})})},t.prototype.registerServiceWorker=function(){return ve(this,void 0,void 0,function(){var t,i,n;return me(this,function(e){switch(e.label){case 0:if(!("serviceWorker"in navigator))return this.logger.warn(os),[2,null];e.label=1;case 1:return e.trys.push([1,7,,8]),[4,navigator.serviceWorker.getRegistration(this.serviceWorkerPath)];case 2:return(t=e.sent())?(this.logger.info("Service worker already registered",{scope:t.scope}),[4,this.ensureServiceWorkerActive(t)]):[3,4];case 3:return e.sent(),[2,t];case 4:return this.logger.info("Registering service worker",{path:this.serviceWorkerPath}),[4,navigator.serviceWorker.register(this.serviceWorkerPath)];case 5:return i=e.sent(),this.logger.info(rs,{scope:i.scope}),[4,this.ensureServiceWorkerActive(i)];case 6:return e.sent(),[2,i];case 7:return n=e.sent(),this.logger.error(ss,n),[2,null];case 8:return[2]}})})},t.prototype.ensureServiceWorkerActive=function(t){return ve(this,void 0,void 0,function(){var i,n=this;return me(this,function(e){return t.active?(this.logger.debug("Service worker is already active"),[2]):(i=t.installing||t.waiting)?(this.logger.info("Waiting for service worker to activate...",{state:i.state}),[2,new Promise(function(t,e){if("activated"!==i.state){var r=function(){"activated"===i.state?(i.removeEventListener("statechange",r),n.logger.info("Service worker activated"),t()):"redundant"===i.state&&(i.removeEventListener("statechange",r),e(new Error("Service worker became redundant")))};i.addEventListener("statechange",r)}else t()})]):(this.logger.warn(cs),[2])})})},t.prototype.requestToken=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:if(!this.isInitialized||!this.messaging)return this.logger.error(as),[2,null];r.label=1;case 1:return r.trys.push([1,5,,6]),(i=this.swRegistration)?[3,3]:[4,this.registerServiceWorker()];case 2:i=r.sent(),r.label=3;case 3:return(t=i)?(this.swRegistration=t,[4,this.fetchFCMToken(t)]):(this.logger.error(hs),[2,null]);case 4:return(n=r.sent())?(this.currentToken=n,this.logger.info(is,{token:n}),this.onTokenReceivedCallback&&this.onTokenReceivedCallback(n),[2,n]):(this.logger.error(ds),[2,null]);case 5:return e=r.sent(),this.logger.error(es,{error:e}),[2,null];case 6:return[2]}})})},t.prototype.fetchFCMToken=function(t){return ve(this,void 0,void 0,function(){var i,n;return me(this,function(e){switch(e.label){case 0:return[4,lc()];case 1:return i=e.sent().getToken,n={serviceWorkerRegistration:t},this.vapidKey&&(n.vapidKey=this.vapidKey),[2,i(this.messaging,n)]}})})},t.prototype.setupMessageListener=function(){return ve(this,void 0,void 0,function(){var t,i=this;return me(this,function(n){switch(n.label){case 0:if(!this.isInitialized||!this.messaging)return this.logger.error(as),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,lc()];case 2:return(0,n.sent().onMessage)(this.messaging,function(t){i.handleMessage(t)}),this.logger.info("Message listener setup successfully"),[3,4];case 3:return t=n.sent(),this.logger.error(fs,{error:t}),[3,4];case 4:return[2]}})})},t.prototype.handleMessage=function(t){if(this.logger.info("FCM message received",t),t&&(t.notification||t.data)||this.logger.warn(ls,t),this.onMessageReceivedCallback)try{this.onMessageReceivedCallback(t)}catch(t){this.logger.error(vs,{error:t})}},t.prototype.getCurrentToken=function(){return this.currentToken},t.prototype.isFirebaseInitialized=function(){return this.isInitialized},t.prototype.destroy=function(){this.isInitialized=!1,this.messaging=null,this.currentToken=null,this.swRegistration=null,this.logger.info("FirebaseManager destroyed successfully")},t}(),gc=function(){function t(t,i,n,e,r){this.firebaseManager=null,this.tokenUpdateCallback=null,this.config=t,this.logger=i,this.storageManager=n,this.brandId=e,this.applicationId=r,this.config.onTokenRefresh&&this.logger.warn("notifications.onTokenRefresh has no effect — the modular Firebase SDK has no token-refresh event to fire it from. Call NotificationManager.refreshToken() to manually re-request a token instead."),this.state={isNotificationEnabled:!1,firebaseInitialized:!1,permissionStatus:"default"}}return t.prototype.isNotificationSupported=function(){return"undefined"!=typeof window&&"undefined"!=typeof Notification&&"undefined"!=typeof navigator&&"serviceWorker"in navigator},t.prototype.getPermissionStatus=function(){return this.isNotificationSupported()?Notification.permission:"denied"},t.prototype.shouldInitializeNotifications=function(){return this.isNotificationSupported()?!!this.config.messaging||(this.logger.info(gs),!1):(this.logger.info(ms),!1)},t.prototype.restoreState=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r;return me(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=Ae("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(i=s.sent())&&(n=JSON.parse(i),e=this.getPermissionStatus(),this.state=le(le(le({},this.state),n),{permissionStatus:e}),this.logger.info("Notification state restored from storage",{storedPermission:n.permissionStatus,currentPermission:e,hasToken:!!n.fcmToken})),[3,3];case 2:return r=s.sent(),this.logger.error(ps,{error:r}),[3,3];case 3:return[2]}})})},t.prototype.saveState=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=Ae("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.set(t,JSON.stringify(this.state))];case 1:return n.sent(),this.logger.debug("Notification state saved to storage",this.state),[3,3];case 2:return i=n.sent(),this.logger.error(ws,{error:i}),[3,3];case 3:return[2]}})})},t.prototype.init=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,15,,17]),[4,this.restoreState()];case 1:return n.sent(),this.shouldInitializeNotifications()?[3,3]:(this.logger.info($r),this.state.isNotificationEnabled=!1,[4,this.saveState()]);case 2:return n.sent(),[2,this.state];case 3:return t=this.getPermissionStatus(),this.state.permissionStatus=t,this.logger.info("Current notification permission",{permission:t,hasStoredToken:!!this.state.fcmToken,isNotificationEnabled:this.state.isNotificationEnabled}),"denied"!==t?[3,5]:(this.logger.info(Yr),this.state.isNotificationEnabled=!1,this.state.fcmToken&&(this.logger.info("Clearing stored FCM token because notification permission is denied"),delete this.state.fcmToken),[4,this.saveState()]);case 4:return n.sent(),[2,this.state];case 5:return"default"!==t?[3,7]:(this.logger.info("Permission not yet granted - notifications will not be shown until user grants permission"),this.state.isNotificationEnabled=!1,[4,this.saveState()]);case 6:return n.sent(),[2,this.state];case 7:return"granted"!==t?[3,14]:this.state.fcmToken?(this.logger.info("Using existing FCM token from storage",{token:this.state.fcmToken.substring(0,20)+"..."}),this.state.isNotificationEnabled=!0,this.firebaseManager?[3,9]:(this.logger.info("Initializing Firebase for message listening"),[4,this.initializeFirebaseForMessaging()])):[3,11];case 8:n.sent(),n.label=9;case 9:return[4,this.saveState()];case 10:return n.sent(),[2,this.state];case 11:return this.logger.info("Permission granted - initializing Firebase to generate FCM token"),[4,this.initializeFirebase()];case 12:return n.sent(),[4,this.saveState()];case 13:n.sent(),n.label=14;case 14:return this.logger.info(Qr,this.state),[2,this.state];case 15:return i=n.sent(),this.logger.error(Jr,i),this.state.isNotificationEnabled=!1,[4,this.saveState()];case 16:return n.sent(),[2,this.state];case 17:return[2]}})})},t.prototype.initializeFirebaseForMessaging=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:if(!this.config.messaging)throw new Error("Firebase Messaging instance is required");i.label=1;case 1:return i.trys.push([1,5,,6]),this.firebaseManager=new mc(this.config.messaging,this.logger,this.config.vapidKey,this.config.serviceWorkerPath,this.config.onTokenReceived,this.config.onMessageReceived),[4,this.firebaseManager.initialize()];case 2:if(!i.sent())throw new Error("Firebase initialization failed");return this.state.firebaseInitialized=!0,[4,this.firebaseManager.ensureServiceWorkerRegistered()];case 3:return i.sent(),[4,this.firebaseManager.setupMessageListener()];case 4:return i.sent(),this.logger.info("Firebase initialized for message listening"),[3,6];case 5:throw t=i.sent(),this.logger.error(ys,t),t;case 6:return[2]}})})},t.prototype.initializeFirebase=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:if(!this.config.messaging)throw new Error("Firebase Messaging instance is required");n.label=1;case 1:return n.trys.push([1,7,,8]),this.firebaseManager=new mc(this.config.messaging,this.logger,this.config.vapidKey,this.config.serviceWorkerPath,this.config.onTokenReceived,this.config.onMessageReceived),[4,this.firebaseManager.initialize()];case 2:if(!n.sent())throw new Error("Firebase initialization failed");return this.state.firebaseInitialized=!0,this.state.isNotificationEnabled=!0,[4,this.firebaseManager.requestToken()];case 3:return(t=n.sent())?(this.state.fcmToken=t,[4,this.storeFCMToken(t)]):[3,5];case 4:n.sent(),n.label=5;case 5:return[4,this.firebaseManager.setupMessageListener()];case 6:return n.sent(),this.logger.info("Firebase initialized and FCM token retrieved",{hasToken:!!t}),[3,8];case 7:throw i=n.sent(),this.logger.error(ts,i),this.state.firebaseInitialized=!1,this.state.isNotificationEnabled=!1,i;case 8:return[2]}})})},t.prototype.storeFCMToken=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),i=Ae("FCM_TOKEN",this.brandId,this.applicationId),n=Ae("FCM_TOKEN_CREATED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(i)];case 1:return e=u.sent(),r=!e||e!==t,[4,this.storageManager.set(i,t)];case 2:return u.sent(),r?(s=(new Date).toISOString(),[4,this.storageManager.set(n,s)]):[3,4];case 3:return u.sent(),this.logger.debug("FCM token and creation date stored successfully",{createdAt:s}),[3,5];case 4:this.logger.debug("FCM token stored (creation date unchanged)"),u.label=5;case 5:return this.tokenUpdateCallback&&(this.logger.info("Notifying token update callback",{isNewToken:r,tokenPreview:t.substring(0,20)+"..."}),this.tokenUpdateCallback(t,r)),[3,7];case 6:return o=u.sent(),this.logger.error(Es,{error:o}),[3,7];case 7:return[2]}})})},t.prototype.setTokenUpdateCallback=function(t){this.tokenUpdateCallback=t,this.logger.debug("Token update callback registered")},t.prototype.clearTokenUpdateCallback=function(){this.tokenUpdateCallback=null,this.logger.debug("Token update callback cleared")},t.prototype.getState=function(){return le({},this.state)},t.prototype.getFCMToken=function(){return this.state.fcmToken||null},t.prototype.getTokenCreationDate=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=Ae("FCM_TOKEN_CREATED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,n.sent()||null];case 2:return i=n.sent(),this.logger.error(_s,i),[2,null];case 3:return[2]}})})},t.prototype.isEnabled=function(){return this.state.isNotificationEnabled},t.prototype.getFirebaseManager=function(){return this.firebaseManager},t.prototype.refreshToken=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:if(!this.firebaseManager||!this.state.isNotificationEnabled)return this.logger.info(Is),[2,null];n.label=1;case 1:return n.trys.push([1,6,,7]),[4,this.firebaseManager.requestToken()];case 2:return(t=n.sent())?(this.state.fcmToken=t,[4,this.storeFCMToken(t)]):[3,5];case 3:return n.sent(),[4,this.saveState()];case 4:n.sent(),this.logger.info(ns,{token:t}),n.label=5;case 5:return[2,t];case 6:return i=n.sent(),this.logger.error(bs,i),[2,null];case 7:return[2]}})})},t.prototype.clearToken=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.logger.info("Clearing notification state (permission revoked)"),t=this.state.fcmToken,this.state.isNotificationEnabled=!1,this.state.firebaseInitialized=!1,this.firebaseManager&&(this.firebaseManager.destroy(),this.firebaseManager=null),[4,this.saveState()];case 1:return n.sent(),this.tokenUpdateCallback&&t&&(this.logger.info("Notifying permission revoked to sync push_opted:false with backend"),this.tokenUpdateCallback(t,!0)),this.logger.info("Notification state cleared"),[3,3];case 2:throw i=n.sent(),this.logger.error(Ts,i),i;case 3:return[2]}})})},t.prototype.hasPermissionChanged=function(){return this.getPermissionStatus()!==this.state.permissionStatus},t.prototype.handlePermissionChange=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return t=this.getPermissionStatus(),i=this.state.permissionStatus,this.logger.info("Permission status changed",{from:i,to:t}),this.state.permissionStatus=t,"denied"!==t&&"default"!==t?[3,5]:"granted"!==i?[3,2]:(this.logger.warn(Ss),[4,this.clearToken()]);case 1:return n.sent(),[3,4];case 2:return this.state.isNotificationEnabled=!1,[4,this.saveState()];case 3:n.sent(),n.label=4;case 4:return[3,10];case 5:return"granted"!==t||"granted"===i?[3,10]:this.config.messaging?[3,6]:(this.logger.warn(gs),this.state.isNotificationEnabled=!1,[3,8]);case 6:return this.logger.info("Permission granted - initializing Firebase"),[4,this.initializeFirebase()];case 7:n.sent(),n.label=8;case 8:return[4,this.saveState()];case 9:n.sent(),n.label=10;case 10:return[2,this.state]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.firebaseManager&&(this.firebaseManager.destroy(),this.firebaseManager=null),t=Ae("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return n.sent(),this.logger.info("NotificationManager destroyed successfully"),[3,3];case 2:return i=n.sent(),this.logger.error(Ns,i),[3,3];case 3:return[2]}})})},t}(),pc=function(){function t(t,i,n,e,r){this.currentSession=null,this.sessionNumber=0,this.storageManager=t,this.logger=i,this.brandId=n,this.applicationId=e;var s=Ne/6e4;this.inactivityTimeoutMs=60*(r||s)*1e3,this.logger.info("SessionManager configured with timeout:",{timeoutMinutes:r||s,timeoutMs:this.inactivityTimeoutMs,source:r?"Remote Config":"Default"})}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.logger.info("Initializing SessionManager"),[4,this.restoreSessionNumber()];case 1:return t.sent(),[4,this.restoreSession()];case 2:return t.sent(),this.logger.info("SessionManager initialized successfully"),[2]}})})},t.prototype.getOrCreateSession=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return t=Date.now(),this.currentSession?(i=t-this.currentSession.lastEventTime)<this.inactivityTimeoutMs?(this.currentSession.lastEventTime=t,[4,this.persistSession()]):[3,2]:[3,3];case 1:return n.sent(),this.logger.debug(br,{sessionId:this.currentSession.sessionId,inactivityDuration:i}),[2,this.currentSession.sessionId];case 2:this.logger.info(Tr,{sessionId:this.currentSession.sessionId,inactivityDuration:i,timeoutMs:this.inactivityTimeoutMs}),n.label=3;case 3:return[2,this.startNewSession()]}})})},t.prototype.getSessionStartTime=function(){var t;return(null===(t=this.currentSession)||void 0===t?void 0:t.sessionStartTime)||null},t.prototype.getCurrentSessionId=function(){var t,i;return null!==(i=null===(t=this.currentSession)||void 0===t?void 0:t.sessionId)&&void 0!==i?i:null},t.prototype.getSessionNumber=function(){return this.sessionNumber},t.prototype.resetSessionNumber=function(){return ve(this,arguments,void 0,function(t){return void 0===t&&(t=0),me(this,function(i){switch(i.label){case 0:return this.sessionNumber=t,[4,this.persistSessionNumber()];case 1:return i.sent(),this.logger.info("Session number reset",{sessionNumber:this.sessionNumber}),[2]}})})},t.prototype.endSession=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){switch(i.label){case 0:return this.currentSession?(this.logger.info("user_switch"===t?Sr:Nr,{sessionId:this.currentSession.sessionId,reason:t}),this.currentSession=null,[4,this.clearSessionStorage()]):[3,3];case 1:return i.sent(),[4,this.resetSessionNumber(0)];case 2:i.sent(),i.label=3;case 3:return[2]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){return this.logger.info("Destroying SessionManager (session persists in storage)"),this.currentSession=null,[2]})})},t.prototype.startNewSession=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return t=Date.now(),i=ea(),this.currentSession={sessionId:i,sessionStartTime:t,lastEventTime:t},this.sessionNumber+=1,[4,this.persistSession()];case 1:return n.sent(),[4,this.persistSessionNumber()];case 2:return n.sent(),this.logger.info(Ir,{sessionId:i,sessionStartTime:t,sessionNumber:this.sessionNumber}),[2,i]}})})},t.prototype.restoreSession=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a;return me(this,function(c){switch(c.label){case 0:return c.trys.push([0,7,,9]),t=Ae("SESSION_ID",this.brandId,this.applicationId),i=Ae("SESSION_START_TIME",this.brandId,this.applicationId),n=Ae("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return e=c.sent(),[4,this.storageManager.get(i)];case 2:return r=c.sent(),[4,this.storageManager.get(n)];case 3:return s=c.sent(),e&&r&&s?(o=Date.now(),(u=o-parseInt(s))<this.inactivityTimeoutMs?(this.currentSession={sessionId:e,sessionStartTime:parseInt(r),lastEventTime:parseInt(s)},this.logger.info(Dr,{sessionId:e,timeSinceLastEvent:u}),[3,6]):[3,4]):[3,6];case 4:return this.logger.debug("Stored session expired, will create new session",{timeSinceLastEvent:u,timeoutMs:this.inactivityTimeoutMs}),[4,this.clearSessionStorage()];case 5:c.sent(),c.label=6;case 6:return[3,9];case 7:return a=c.sent(),this.logger.error("Failed to restore session from storage",{error:a}),[4,this.clearSessionStorage()];case 8:return c.sent(),[3,9];case 9:return[2]}})})},t.prototype.persistSession=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:if(!this.currentSession)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),t=Ae("SESSION_ID",this.brandId,this.applicationId),i=Ae("SESSION_START_TIME",this.brandId,this.applicationId),n=Ae("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,Promise.all([this.storageManager.set(t,this.currentSession.sessionId),this.storageManager.set(i,this.currentSession.sessionStartTime.toString()),this.storageManager.set(n,this.currentSession.lastEventTime.toString())])];case 2:return r.sent(),[3,4];case 3:return e=r.sent(),this.logger.error("Failed to persist session to storage",{error:e}),[3,4];case 4:return[2]}})})},t.prototype.clearSessionStorage=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=Ae("SESSION_ID",this.brandId,this.applicationId),i=Ae("SESSION_START_TIME",this.brandId,this.applicationId),n=Ae("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,Promise.all([this.storageManager.remove(t),this.storageManager.remove(i),this.storageManager.remove(n)])];case 1:return r.sent(),[3,3];case 2:return e=r.sent(),this.logger.error("Failed to clear session storage",{error:e}),[3,3];case 3:return[2]}})})},t.prototype.restoreSessionNumber=function(){return ve(this,void 0,void 0,function(){var t,i,n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Ae("SESSION_NUMBER",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(i=e.sent())&&(this.sessionNumber=parseInt(i,10)||0,this.logger.debug("Session number restored",{sessionNumber:this.sessionNumber})),[3,3];case 2:return n=e.sent(),this.logger.error("Failed to restore session number",{error:n}),[3,3];case 3:return[2]}})})},t.prototype.persistSessionNumber=function(){return ve(this,void 0,void 0,function(){var t,i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=Ae("SESSION_NUMBER",this.brandId,this.applicationId),[4,this.storageManager.set(t,this.sessionNumber.toString())];case 1:return n.sent(),[3,3];case 2:return i=n.sent(),this.logger.error("Failed to persist session number",{error:i}),[3,3];case 3:return[2]}})})},t}(),wc=function(){function t(t,i){this.firedThresholds=new Set,this.pageStartTime=0,this.currentUrl="",this.scrollHandler=null,this.initialized=!1,this.logger=t,this.onDepthReached=i,this.thresholds=Ps}return t.prototype.init=function(){var t=this;"undefined"!=typeof window&&"undefined"!=typeof document?this.initialized?this.logger.debug("ScrollDepthTracker already initialized, skipping"):(this.pageStartTime=Date.now(),this.currentUrl=window.location.href,this.scrollHandler=function(){return t.handleScroll()},window.addEventListener("scroll",this.scrollHandler,{passive:!0}),this.checkScrollDepth(),this.initialized=!0,this.logger.debug("ScrollDepthTracker initialized")):this.logger.debug("ScrollDepthTracker.init() skipped - no window/document (SSR)")},t.prototype.handleScroll=function(){this.checkSPANavigation(),this.checkScrollDepth()},t.prototype.checkSPANavigation=function(){var t=window.location.href;t!==this.currentUrl&&(this.firedThresholds.clear(),this.pageStartTime=Date.now(),this.currentUrl=t,this.logger.debug("ScrollDepthTracker reset for new page",{url:t}))},t.prototype.checkScrollDepth=function(){var t,i,n=window.scrollY,e=document.documentElement.scrollHeight-document.documentElement.clientHeight;if(!(e<=0)){var r=Math.min(100,Math.floor(n/e*100));try{for(var s=ge(this.thresholds),o=s.next();!o.done;o=s.next()){var u=o.value;if(!this.firedThresholds.has(u)&&r>=u){this.firedThresholds.add(u);var a=Math.floor((Date.now()-this.pageStartTime)/1e3);this.logger.debug("Scroll depth threshold reached",{threshold:u,timeToDepth:a,url:this.currentUrl}),this.onDepthReached({depth_percentage:u,page_url:this.currentUrl,time_to_depth:a})}}}catch(i){t={error:i}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}}},t.prototype.destroy=function(){this.scrollHandler&&"undefined"!=typeof window&&window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null,this.firedThresholds.clear(),this.initialized=!1,this.logger.debug("ScrollDepthTracker destroyed")},t}(),yc=function(){function t(t){this.userContextSet=!1,this.initialized=!1,this.initializationPromise=null,this.visitorTrackingEnabled=!1,this.visitorId=null,this.currentUserIdentifierType=null,this.notificationManager=null,this.permissionChangeCleanup=null,this.dlrMessageCleanup=null,this.lastAuthenticatedUser=null,this.lastUserAttributes=null,this.scrollDepthTracker=null,this.sdkDisabled=!1,this.userIdentified=!1,this.userOperationChain=Promise.resolve(),this.gamificationManager=null,this.gamificationBaseUrl=Vo,this.pendingGamificationCallback=null,this.pendingGamificationSettings={},this.config=t,this.logger=new ac(!1),this.validateRequiredConfig(t),t.remoteConfigKey?(this.logger.info("🔧 SDK initializing in Remote Config bootstrap mode"),this.logger.info("Will fetch configuration from Remote Config key:",t.remoteConfigKey)):this.logger.info("🔧 SDK initializing in direct-config bootstrap mode (no Firebase)")}return t.initialize=function(i){return t.p?(new ac(!0).warn("WebSDK is already initialized. Returning existing instance."),t.p):(t.p=new t(i),t.p.init(),t.p)},t.getInstance=function(){return t.p},t.isInitialized=function(){return null!==t.p},t.requireInstance=function(){if(!t.p)throw new Error("WebSDK is not initialized. Call WebSDK.initialize(config) first.");return t.p},t.track=function(i,n){t.requireInstance().track(i,n)},t.pageView=function(i){t.requireInstance().pageView(i)},t.identify=function(i){t.requireInstance().identify(i)},t.getUser=function(){return t.requireInstance().getUser()},t.getAnonymousId=function(){return t.requireInstance().getAnonymousId()},t.reset=function(){t.requireInstance().reset()},t.setCapToken=function(i){t.requireInstance().setCapToken(i)},t.getCapToken=function(){return t.requireInstance().getCapToken()},t.enablePagePathTracking=function(i){t.requireInstance().enablePagePathTracking(i)},t.onScreenChanged=function(i){t.requireInstance().onScreenChanged(i)},t.setGamificationSuppressed=function(i){t.requireInstance().setGamificationSuppressed(i)},t.setTheme=function(i){t.requireInstance().setTheme(i)},t.forceSyncGamification=function(){t.requireInstance().forceSyncGamification()},t.setGamificationCallback=function(i){t.requireInstance().setGamificationCallback(i)},t.isGamificationSuppressed=function(){return t.requireInstance().isGamificationSuppressed()},t.disableSDK=function(){t.requireInstance().disableSDK()},t.enableSDK=function(){t.requireInstance().enableSDK()},t.destroy=function(){if(!t.p)return Promise.resolve();var i=t.p.destroy();return t.p=null,i},t.prototype.shouldEnableLogging=function(t){return!(!t||"NONE"===t)&&["ERROR","WARN","INFO","DEBUG","VERBOSE"].includes(t)},t.prototype.resolveLogLevel=function(t){return{NONE:nc.NONE,ERROR:nc.ERROR,WARN:nc.WARN,INFO:nc.INFO,DEBUG:nc.DEBUG,VERBOSE:nc.VERBOSE}[null!=t?t:"NONE"]},t.prototype.restoreUserContext=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a=this;return me(this,function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),t=Ae("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.get(t)];case 1:return(i=c.sent())?(n=JSON.parse(i),e=n.cuid,r=n.userIdentifierType,this.currentUserIdentifierType=null!=r?r:null,s=this.config.accountId||"",[4,this.eventTracker.setUserContext(s,e,r)]):[3,3];case 2:c.sent(),this.userContextSet=!0,this.userIdentified=!0,this.logger.setContext({cuid:e}),n.attributes&&(this.lastUserAttributes=n.attributes),this.logger.info("User context restored from storage",{cuid:e,accountId:this.config.accountId}),this.gamificationManager&&this.gamificationManager.initialize(e).catch(function(t){a.logger.error("Failed to restore gamification on page refresh",t)}),c.label=3;case 3:return[4,this.storageManager.get(this.lastAuthenticatedUserKey())];case 4:return(o=c.sent())&&(this.lastAuthenticatedUser=o,this.logger.info("Last authenticated user restored from storage",{lastAuthenticatedUser:this.lastAuthenticatedUser})),[3,6];case 5:return u=c.sent(),this.logger.error("Failed to restore user context from storage",{error:u}),[3,6];case 6:return[2]}})})},t.prototype.validateAndClearDifferentUserContext=function(t){return ve(this,void 0,void 0,function(){var i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,7]),this.lastAuthenticatedUser&&this.lastAuthenticatedUser!==t?(this.logger.info("Different user detected, ending session and clearing context",{previousCuid:this.lastAuthenticatedUser,newCuid:t}),[4,this.sessionManager.endSession("user_switch")]):[3,3];case 1:return n.sent(),[4,this.clearUserContext({resetIdentified:!1})];case 2:n.sent(),this.userContextSet=!1,n.label=3;case 3:return this.lastAuthenticatedUser=t,[4,this.persistLastAuthenticatedUser(t)];case 4:return n.sent(),[3,7];case 5:return i=n.sent(),this.logger.error("Error validating different user context",{previousCuid:this.lastAuthenticatedUser,newCuid:t,error:i}),[4,this.clearUserContext()];case 6:return n.sent(),this.userContextSet=!1,[3,7];case 7:return[2]}})})},t.prototype.lastAuthenticatedUserKey=function(){return Ae("LAST_AUTHENTICATED_USER",this.config.brandId,this.config.applicationId)},t.prototype.persistLastAuthenticatedUser=function(t){return ve(this,void 0,void 0,function(){var i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.storageManager.set(this.lastAuthenticatedUserKey(),t)];case 1:return n.sent(),[3,3];case 2:return i=n.sent(),this.logger.error("Failed to persist lastAuthenticatedUser",{error:i}),[3,3];case 3:return[2]}})})},t.prototype.storeUserContext=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o;return me(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),e=null!=i?i:this.currentUserIdentifierType,r={cuid:t,timestamp:Date.now()},e&&(r.userIdentifierType=e),n&&(r.attributes=n),s=Ae("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.set(s,JSON.stringify(r))];case 1:return u.sent(),[3,3];case 2:return o=u.sent(),this.logger.error("Failed to store user context",{error:o}),[3,3];case 3:return[2]}})})},t.prototype.init=function(){var t=this;this.initialized?this.logger.warn("WebSDK already initialized"):this.initializationPromise?this.logger.warn("WebSDK initialization already in progress"):(va(),this.initializationPromise=this.initializeAsync().catch(function(i){t.logger.error(Ve,i),t.initializationPromise=null}))},t.prototype.tryStep=function(t,i){return ve(this,void 0,void 0,function(){var n;return me(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,i()];case 1:return e.sent(),[3,3];case 2:return n=e.sent(),this.logger.error(t,n),[3,3];case 3:return[2]}})})},t.prototype.initializeAsync=function(){return ve(this,void 0,void 0,function(){var t,i,n=this;return me(this,function(e){switch(e.label){case 0:this.logger.info("Initializing WebSDK",{version:Hs,config:this.config}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.bootstrapConfig()];case 2:return e.sent(),[3,4];case 3:throw t=e.sent(),new Error("".concat(Pe,": ").concat(t));case 4:return[4,this.tryStep(je,function(){return n.storageManager.init()})];case 5:return e.sent(),[4,this.tryStep(He,function(){var t;return Promise.resolve(null===(t=n.gamificationManager)||void 0===t?void 0:t.restorePersistedPagePathTracking())})];case 6:return e.sent(),[4,this.tryStep(qe,function(){var t;return Promise.resolve(null===(t=n.gamificationManager)||void 0===t?void 0:t.restorePersistedGamificationSuppressed())})];case 7:return e.sent(),[4,this.tryStep(Ke,function(){var t;return Promise.resolve(null===(t=n.gamificationManager)||void 0===t?void 0:t.restorePersistedTheme())})];case 8:return e.sent(),[4,this.tryStep(We,function(){return n.sessionManager.init()})];case 9:if(e.sent(),!this.config.notifications)return[3,13];e.label=10;case 10:return e.trys.push([10,12,,13]),this.notificationManager=new gc(this.config.notifications,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.setupTokenUpdateCallback(),[4,this.notificationManager.init()];case 11:return e.sent(),this.logger.info("Notifications initialized early for FCM token availability"),[3,13];case 12:return i=e.sent(),this.logger.error("Failed to construct or configure NotificationManager",{error:i}),this.notificationManager=null,[3,13];case 13:return[4,this.tryStep(Xe,function(){return n.initializeVisitorConfig()})];case 14:return e.sent(),[4,this.tryStep(Ye,function(){return ve(n,void 0,void 0,function(){var t=this;return me(this,function(i){switch(i.label){case 0:return[4,this.eventTracker.init()];case 1:return i.sent(),this.eventTracker.setSessionInfoCallback(function(){return ve(t,void 0,void 0,function(){return me(this,function(t){return[2,this.sessionManager.getOrCreateSession()]})})}),[2]}})})})];case 15:return e.sent(),[4,this.tryStep(Qe,function(){return n.restoreUserContext()})];case 16:return e.sent(),[4,this.tryStep(Je,function(){return n.syncEventTrackerContext()})];case 17:return e.sent(),this.initialized=!0,this.notificationManager&&this.setupPermissionChangeDetection(),this.scrollDepthTracker=new wc(this.logger,function(t){n.pushEvent(xs,n.buildInternalEventAttributes(le({},t)))}),this.scrollDepthTracker.init(),this.config.notifications?[4,this.tryStep($e,function(){return ve(n,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.setupDLRServiceWorkerListener(),[4,this.eventTracker.processPendingServiceWorkerDLREvents()];case 1:return t.sent(),[2]}})})})]:[3,19];case 18:e.sent(),e.label=19;case 19:return this.logger.info(Ge),[2]}})})},t.prototype.handleVisibilityChange=function(){return ve(this,void 0,void 0,function(){var t,i,n;return me(this,function(e){switch(e.label){case 0:if("visible"!==document.visibilityState||!this.notificationManager)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),this.notificationManager.hasPermissionChanged()?(t="Notification"in window?Notification.permission:"denied",this.logger.info("Notification permission changed detected",{currentPermission:t}),[4,this.notificationManager.handlePermissionChange()]):[2];case 2:return(i=e.sent())&&this.logger.info("Notification state updated after permission change",i),[3,4];case 3:return n=e.sent(),this.logger.error("Error handling permission change",{error:n}),[3,4];case 4:return[2]}})})},t.prototype.setupPermissionChangeDetection=function(){var t=this;if("undefined"!=typeof document&&"undefined"!=typeof window){var i=function(){return t.handleVisibilityChange()};document.addEventListener("visibilitychange",i),window.addEventListener("focus",i),this.permissionChangeCleanup=function(){document.removeEventListener("visibilitychange",i),window.removeEventListener("focus",i)},this.logger.debug("Permission change detection setup complete")}},t.prototype.setupDLRServiceWorkerListener=function(){var t=this;if("undefined"!=typeof navigator&&"serviceWorker"in navigator){var i=function(i){return ve(t,void 0,void 0,function(){var t;return me(this,function(n){switch(n.label){case 0:if(!i.data||"HYDRA_DLR_EVENTS_PENDING"!==i.data.type)return[3,4];this.logger.info("Received DLR events pending notification from service worker",{serviceWorkerTimestamp:i.data.timestamp,dlrEventType:i.data.dlrEventType,messageId:i.data.messageId,campaignId:i.data.campaignId}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.eventTracker.processPendingServiceWorkerDLREvents()];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),this.logger.error("Failed to process pending DLR events",t),[3,4];case 4:return[2]}})})};navigator.serviceWorker.addEventListener("message",i),this.dlrMessageCleanup=function(){navigator.serviceWorker.removeEventListener("message",i)},this.logger.debug("DLR service worker message listener setup complete")}},t.prototype.initializeVisitorConfig=function(){return ve(this,void 0,void 0,function(){var t,i,n=this;return me(this,function(e){switch(e.label){case 0:return this.logger.info("Initializing visitor configuration"),[4,this.visitorConfigManager.init()];case 1:return e.sent(),t=this,[4,this.visitorConfigManager.isVisitorTrackingEnabled()];case 2:return t.visitorTrackingEnabled=e.sent(),this.visitorTrackingEnabled?[4,this.anonymousVisitorManager.init()]:[3,5];case 3:return e.sent(),[4,this.getOrCreateVisitorId()];case 4:e.sent(),this.anonymousVisitorManager.retryPendingMerge().catch(function(t){n.logger.error("Failed to retry pending merge on init",{error:t})}),e.label=5;case 5:return(i=this.visitorConfigManager.getCachedConfig())&&i.warnings&&i.warnings.length>0&&i.warnings.forEach(function(t){n.logger.warn("Visitor config warning",{code:t.code,message:t.message})}),[2]}})})},t.prototype.syncEventTrackerContext=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:return t=null!==(e=null===(n=this.anonymousVisitorManager)||void 0===n?void 0:n.getVisitorExternalId())&&void 0!==e?e:null,this.eventTracker.setVisitorTrackingState(this.visitorId,this.visitorTrackingEnabled,t),this.visitorTrackingEnabled?(i=this.config.accountId||"",this.userContextSet?[3,2]:[4,this.eventTracker.setUserContext(i)]):(this.logger.warn("Event tracking disabled: Visitor tracking is off"),[2]);case 1:return r.sent(),this.logger.info("Account context set for visitor tracking"),[3,3];case 2:this.logger.debug("Skipping account context set - user context already set"),r.label=3;case 3:return[2]}})})},t.prototype.getOrCreateVisitorId=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c,h;return me(this,function(d){switch(d.label){case 0:t=[],(i=null===(a=this.notificationManager)||void 0===a?void 0:a.getFCMToken())?(n="granted"===(null===(c=this.notificationManager)||void 0===c?void 0:c.getState().permissionStatus),t.push({type:this.getChannelType(),value:i,primary:!0,verified:!0,subscribed:n}),this.logger.info("Including FCM token in visitor creation",{tokenPreview:i.substring(0,20)+"...",subscribed:n})):this.logger.info("No FCM token available, creating visitor without commChannels"),d.label=1;case 1:return d.trys.push([1,5,,6]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,3];case 2:return s=d.sent(),[3,4];case 3:s=null,d.label=4;case 4:return r=s,e=ha(le(le({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:"granted"===(null===(h=this.notificationManager)||void 0===h?void 0:h.getState().permissionStatus),fcmTokenCreatedAt:r})),this.logger.debug("Extended fields collected",{extendedFields:e}),[3,6];case 5:return o=d.sent(),this.logger.error("Failed to collect extended fields, proceeding without them",{error:o}),e=void 0,[3,6];case 6:return u=this,[4,this.anonymousVisitorManager.getOrCreateVisitorId(t.length>0?t:void 0,e)];case 7:return u.visitorId=d.sent(),this.logger.setContext({visitorId:this.visitorId}),this.logger.info("Visitor ID ready",{visitorId:this.visitorId}),[2,this.visitorId]}})})},t.prototype.setupTokenUpdateCallback=function(){var t=this;this.notificationManager&&(this.notificationManager.setTokenUpdateCallback(function(i,n){return ve(t,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return[4,this.handleTokenUpdate(i,n)];case 1:return t.sent(),[2]}})})}),this.logger.debug("Token update callback configured for backend sync"))},t.prototype.handleTokenUpdate=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r;return me(this,function(s){switch(s.label){case 0:if(!this.visitorId)return this.logger.info("Skipping token sync - no visitor ID yet (will be included in create)",{isNewToken:i}),[2];if(!i)return this.logger.info("Skipping token sync - token unchanged"),[2];n="granted"!==(null===(r=this.notificationManager)||void 0===r?void 0:r.getState().permissionStatus),this.logTokenSyncStart(t,n),s.label=1;case 1:return s.trys.push([1,6,,7]),this.userIdentified&&this.lastAuthenticatedUser?[4,this.syncTokenForIdentifiedUser(n)]:[3,3];case 2:return s.sent(),[3,5];case 3:return[4,this.syncTokenForAnonymousUser(t,n)];case 4:s.sent(),s.label=5;case 5:return[3,7];case 6:return e=s.sent(),this.logger.error("Failed to sync FCM token with backend",e),[3,7];case 7:return[2]}})})},t.prototype.logTokenSyncStart=function(t,i){i?this.logger.info("Permission revoked, syncing push_opted:false with backend",{visitorId:this.visitorId}):this.logger.info("FCM token updated, syncing with backend",{visitorId:this.visitorId,tokenPreview:t.substring(0,20)+"..."})},t.prototype.syncTokenForIdentifiedUser=function(t){return ve(this,void 0,void 0,function(){return me(this,function(i){switch(i.label){case 0:return this.lastAuthenticatedUser?[4,this.sendUserEventToApi(Cs,this.lastAuthenticatedUser,this.lastUserAttributes)]:[2];case 1:return i.sent(),this.logger.info("Token state synced via User Events API (user_update)",{permissionRevoked:t}),[2]}})})},t.prototype.syncTokenForAnonymousUser=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s,o;return me(this,function(u){switch(u.label){case 0:n=t?[{type:this.getChannelType(),value:t,primary:!0,verified:!0,subscribed:!i}]:[],u.label=1;case 1:return u.trys.push([1,5,,6]),i||!this.notificationManager?[3,3]:[4,this.notificationManager.getTokenCreationDate()];case 2:return s=u.sent(),[3,4];case 3:s=null,u.label=4;case 4:return r=s,e=ha(le(le({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:!i,fcmTokenCreatedAt:r})),[3,6];case 5:return o=u.sent(),this.logger.error("Failed to collect extended fields for token update",{error:o}),e=void 0,[3,6];case 6:return[4,this.anonymousVisitorManager.updateVisitor(n,e)];case 7:return u.sent(),i?this.logger.info("Token synced with subscribed:false (permission revoked)",{visitorId:this.visitorId}):this.logger.info("FCM token synced with backend successfully",{visitorId:this.visitorId}),[2]}})})},t.prototype.getAnonymousId=function(){return this.visitorId},t.prototype.getUser=function(){var t,i,n,e,r;if(this.userIdentified)throw this.logger.error("getUser() called while a user is identified - data not exposed"),new Error("This data is not exposed");var s=null!==(i=null===(t=this.sessionManager)||void 0===t?void 0:t.getCurrentSessionId())&&void 0!==i?i:"",o=null!==(e=null===(n=this.sessionManager)||void 0===n?void 0:n.getSessionNumber())&&void 0!==e?e:0;return{visitorId:null!==(r=this.visitorId)&&void 0!==r?r:"",userId:null,sessionId:s,isIdentified:!1,isAnonymous:!0,profileTier:"anonymous",attributes:null,sessionNumber:o,isFirstSession:1===o,isReturningVisitor:o>1}},t.prototype.setUserContext=function(t,i){return ve(this,void 0,void 0,function(){var n,e,r,s;return me(this,function(o){switch(o.label){case 0:if(!this.initialized)throw this.logger.error("setUserContext() called before WebSDK is initialized"),new Error("WebSDK must be initialized before setting user context");o.label=1;case 1:return o.trys.push([1,5,,6]),[4,this.validateAndClearDifferentUserContext(t)];case 2:return o.sent(),this.logger.setContext({cuid:t}),n=null!==(s=null!=i?i:this.currentUserIdentifierType)&&void 0!==s?s:void 0,e=this.config.accountId||"",[4,this.eventTracker.setUserContext(e,t,n)];case 3:return o.sent(),this.userContextSet=!0,i&&(this.currentUserIdentifierType=i),this.visitorId&&this.logger.info("User identified - transitioning from anonymous to identified tracking",{visitorId:this.visitorId,cuid:t,trackingMode:"identified"}),[4,this.storeUserContext(t,n)];case 4:return o.sent(),this.logger.info("User context set and persisted",{cuid:t,accountId:this.config.accountId}),[3,6];case 5:throw r=o.sent(),this.logger.error("Failed to set user context",{cuid:t,error:r}),r;case 6:return[2]}})})},t.prototype.clearUserContext=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r;return me(this,function(s){switch(s.label){case 0:i=null===(r=null==t?void 0:t.resetIdentified)||void 0===r||r,s.label=1;case 1:return s.trys.push([1,5,,6]),n=Ae("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.remove(n)];case 2:return s.sent(),i?[4,this.storageManager.remove(this.lastAuthenticatedUserKey())]:[3,4];case 3:s.sent(),s.label=4;case 4:return this.eventTracker&&this.eventTracker.clearUserContext(),this.currentUserIdentifierType=null,this.userContextSet=!1,i&&(this.userIdentified=!1,this.lastAuthenticatedUser=null),this.logger.setContext({cuid:""}),this.logger.info("User context cleared"),[3,6];case 5:return e=s.sent(),this.logger.error("Failed to clear user context",{error:e}),this.currentUserIdentifierType=null,this.userContextSet=!1,i&&(this.userIdentified=!1,this.lastAuthenticatedUser=null),this.logger.setContext({cuid:""}),[3,6];case 6:return[2]}})})},t.prototype.track=function(t,i){var n;this.pushEvent(t,i),null===(n=this.gamificationManager)||void 0===n||n.handleActionEvent(t)},t.prototype.pageView=function(t){var i,n,e,r=null!==(i=null==t?void 0:t.page_url)&&void 0!==i?i:"undefined"!=typeof window?window.location.href:void 0,s=null!==(n=null==t?void 0:t.page_title)&&void 0!==n?n:"undefined"!=typeof document?document.title:void 0,o=null!==(e=null==t?void 0:t.referrer)&&void 0!==e?e:"undefined"!=typeof document?document.referrer:void 0,u=le(le(le(le(le({},r&&{page_url:r}),s&&{page_title:s}),o&&{referrer:o}),(null==t?void 0:t.page_category)&&{page_category:t.page_category}),null==t?void 0:t.properties);this.pushEvent("page_view",u)},t.prototype.pickTraitFields=function(t){var i={},n=t.gender,e=t.birthday,r=t.city,s=t.country,o=t.timezone;return n&&(i.gender=n),e&&(i.birthday=e),r&&(i.city=r),s&&(i.country=s),o&&(i.timezone=o),i},t.prototype.identify=function(t){var i,n,e,r,s,o,u,a=t.identifier,c=t.actionType,h=t.traits,d=void 0===h?{}:h;if(!a||!a.cuid)throw this.logger.error("Invalid identify call: missing identifier or cuid",{identifier:a}),new Error("identifier with a non-empty cuid is required for identify");var f=["email","mobile","externalId"],l=null===(s=null===(r=null===(e=null===(n=this.visitorConfigManager)||void 0===n?void 0:n.getCachedConfig())||void 0===e?void 0:e.data)||void 0===r?void 0:r.configs)||void 0===s?void 0:s.loginIdentifierType,v=l&&f.includes(l)?l:a.type;if(!f.includes(v))throw this.logger.error("Invalid identify call: unsupported identifier type",{type:v,cuid:a.cuid}),new Error("Invalid identifier type: ".concat(v,". Must be 'email', 'mobile', or 'externalId'."));var m=a.cuid;this.currentUserIdentifierType=v;var g=le(le(le(le(le({firstName:null!==(o=d.firstName)&&void 0!==o?o:"",lastName:null!==(u=d.lastName)&&void 0!==u?u:""},d.email&&{email:d.email}),d.mobile&&{mobile:d.mobile}),d.externalId&&{externalId:d.externalId}),((i={})[v]=m,i)),void 0!==d.custom&&{customData:d.custom}),p=this.pickTraitFields(d);g.customData=le(le({},p),g.customData),this.userIdentified=!0;var w=v;switch(c){case"USER_REGISTER":this.pushUserSignin(m,g,w);break;case"USER_UPDATE":this.pushUserUpdate(m,g,w);break;default:throw this.logger.error("Invalid identify actionType",{actionType:c,cuid:m}),new Error("Invalid identify actionType: ".concat(c,". Must be 'USER_REGISTER' or 'USER_UPDATE'."))}},t.prototype.trackEvent=function(t){return ve(this,arguments,void 0,function(t,i){return void 0===i&&(i=!1),me(this,function(n){switch(n.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events");return[4,this.eventTracker.track(t,i)];case 1:return n.sent(),[2]}})})},t.prototype.destroy=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:this.logger.info("Destroying WebSDK instance"),i.label=1;case 1:return i.trys.push([1,16,,17]),this.eventTracker?[4,this.eventTracker.flush()]:[3,4];case 2:return i.sent(),[4,this.eventTracker.destroy()];case 3:i.sent(),i.label=4;case 4:return this.scrollDepthTracker&&(this.scrollDepthTracker.destroy(),this.scrollDepthTracker=null),this.visitorConfigManager?[4,this.visitorConfigManager.destroy()]:[3,6];case 5:i.sent(),i.label=6;case 6:return this.anonymousVisitorManager?[4,this.anonymousVisitorManager.destroy()]:[3,8];case 7:i.sent(),i.label=8;case 8:return this.permissionChangeCleanup&&(this.permissionChangeCleanup(),this.permissionChangeCleanup=null),this.dlrMessageCleanup&&(this.dlrMessageCleanup(),this.dlrMessageCleanup=null),this.notificationManager?(this.notificationManager.clearTokenUpdateCallback(),[4,this.notificationManager.destroy()]):[3,10];case 9:i.sent(),this.notificationManager=null,i.label=10;case 10:return this.gamificationManager&&(this.gamificationManager.destroy(),this.gamificationManager=null),this.sessionManager?[4,this.sessionManager.destroy()]:[3,12];case 11:i.sent(),i.label=12;case 12:return this.storageManager?[4,this.clearUserContext()]:[3,15];case 13:return i.sent(),[4,this.storageManager.destroy()];case 14:i.sent(),i.label=15;case 15:return this.initialized=!1,this.logger.info(Be),[3,17];case 16:throw t=i.sent(),this.logger.error(ze,{error:t}),t;case 17:return[2]}})})},t.prototype.validateUserAttributes=function(t){if(!t.email&&!t.mobile&&!t.externalId)throw new Error("At least one of email, mobile, or externalId is required")},t.prototype.attemptVisitorMerge=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s;return me(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.visitorTrackingEnabled&&this.visitorId?t.email||t.mobile||t.externalId?(e="email"===n||"mobile"===n||"externalId"===n?n:void 0,[4,this.anonymousVisitorManager.mergeVisitorWithUser(le(le(le(le(le(le({firstName:t.firstName,lastName:t.lastName},void 0!==t.email&&{email:t.email}),void 0!==t.mobile&&{mobile:t.mobile}),void 0!==t.externalId&&{externalId:t.externalId}),void 0!==t.customData&&{customData:t.customData}),{cuid:i}),void 0!==e&&{identifierType:e}))]):(this.logger.debug(Xr,{reason:"No email, mobile, or externalId"}),[2,!1]):(this.logger.debug(Xr,{reason:this.visitorTrackingEnabled?"No visitorId":"Visitor tracking disabled"}),[2,!1]);case 1:return r=o.sent(),this.logger.info("Visitor merge attempt completed",{visitorId:this.visitorId,success:r}),[2,r];case 2:return s=o.sent(),this.logger.error(Wr,{visitorId:this.visitorId,error:s}),[2,!1];case 3:return[2]}})})},t.prototype.buildPushData=function(){var t,i,n,e="granted"===(null===(t=this.notificationManager)||void 0===t?void 0:t.getState().permissionStatus),r=null!==(n=null===(i=this.notificationManager)||void 0===i?void 0:i.getFCMToken())&&void 0!==n?n:null;return{pushOpted:e&&!!r,tokens:r?[{interface_id:r,gateway:Fs.WEB}]:[]}},t.prototype.buildUserAttributePayload=function(t){if(!t)return{};var i={};return t.firstName&&(i.firstName=t.firstName),t.lastName&&(i.lastName=t.lastName),t.email&&(i.email=t.email),t.mobile&&(i.phone=t.mobile),i},t.prototype.sendUserEventToApi=function(t,i,n,e){return ve(this,void 0,void 0,function(){var r,s,o,u,a,c,h,d,f,l,v,m;return me(this,function(g){switch(g.label){case 0:return r=this.buildPushData(),s=r.pushOpted,o=r.tokens,u=null!==(d=null===(h=this.sessionManager)||void 0===h?void 0:h.getCurrentSessionId())&&void 0!==d?d:"",[4,this.apiClient.buildUserEventsRequest(t,le(le(le({cuid:i,push_opted:s,tokens:o},this.visitorId&&{visitorId:this.visitorId}),this.buildUserAttributePayload(n)),e),u)];case 1:return a=g.sent(),c=null!==(l=null===(f=this.anonymousVisitorManager)||void 0===f?void 0:f.getVisitorExternalId())&&void 0!==l?l:void 0,[4,this.apiClient.sendUserEvents(a,null!==(v=this.visitorId)&&void 0!==v?v:void 0,c,i,null!==(m=this.currentUserIdentifierType)&&void 0!==m?m:void 0)];case 2:return g.sent(),this.logger.info("User event sent to User Events API",{eventName:t,cuid:i}),[2]}})})},t.prototype.pushUserSignin=function(t,i,n){var e=this;this.userIdentified=!0,this.queueUserOperation(function(){return ve(e,void 0,void 0,function(){var e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.pushUserSigninAsync(t,i,n)];case 1:return r.sent(),[3,3];case 2:return e=r.sent(),this.logger.error(kr,{cuid:t,error:e}),[3,3];case 3:return[2]}})})})},t.prototype.pushUserSigninAsync=function(t,i,n){return ve(this,void 0,void 0,function(){var e,r,s,o,u,a,c,h,d,f=this;return me(this,function(l){switch(l.label){case 0:return[4,this.ensureInitialized()];case 1:return l.sent(),this.validateUserAttributes(i),e=(null!==(h=null===(c=this.sessionManager)||void 0===c?void 0:c.getSessionNumber())&&void 0!==h?h:0)>1,r=e?"returning":"new_session",[4,this.setUserContextIfNeeded(t,n)];case 2:return l.sent(),[4,this.attemptVisitorMerge(i,t,n)];case 3:return s=l.sent(),this.lastUserAttributes=i,[4,this.storeUserContext(t,n,i)];case 4:l.sent(),l.label=5;case 5:return l.trys.push([5,7,,8]),[4,this.sendUserEventToApi(As,t,i,le(le({},void 0!==n&&{method:n}),{success:s,login_type:r}))];case 6:return l.sent(),this.logger.info("User signin event tracked",{cuid:t,firstName:i.firstName,lastName:i.lastName,email:i.email,loginType:r,mergeSuccess:s}),[3,8];case 7:return o=l.sent(),this.logger.error("Failed to send signin event to User Events API",{cuid:t,error:o}),[3,8];case 8:return u=le(le(le({},i.email&&{email:i.email}),i.mobile&&{mobile:i.mobile}),i.customData&&{customAttributes:i.customData}),(a=[i.firstName,i.lastName].filter(Boolean).join(" "))&&Object.assign(u,{name:a}),null===(d=this.gamificationManager)||void 0===d||d.initialize(t,u).catch(function(i){f.logger.error("Failed to initialize gamification on signin",{cuid:t,error:i})}),[2]}})})},t.prototype.pushUserSignup=function(t,i,n){var e=this;this.userIdentified=!0,this.queueUserOperation(function(){return ve(e,void 0,void 0,function(){var e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.pushUserSignupAsync(t,i,n)];case 1:return r.sent(),[3,3];case 2:return e=r.sent(),this.logger.error(Or,{cuid:t,error:e}),[3,3];case 3:return[2]}})})})},t.prototype.pushUserSignupAsync=function(t,i,n){return ve(this,void 0,void 0,function(){return me(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(i),[4,this.setUserContextIfNeeded(t,n)];case 2:return e.sent(),this.attemptVisitorMerge(i,t,n),this.lastUserAttributes=i,[4,this.storeUserContext(t,n,i)];case 3:return e.sent(),[4,this.sendUserEventToApi(As,t,i)];case 4:return e.sent(),this.logger.info("User signup event tracked (routed as user_signin)",{cuid:t,firstName:i.firstName,lastName:i.lastName,email:i.email}),[2]}})})},t.prototype.pushUserUpdate=function(t,i,n){var e=this;this.queueUserOperation(function(){return ve(e,void 0,void 0,function(){var e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.pushUserUpdateAsync(t,i,n)];case 1:return r.sent(),[3,3];case 2:return e=r.sent(),this.logger.error(Ar,{cuid:t,error:e}),[3,3];case 3:return[2]}})})})},t.prototype.pushUserUpdateAsync=function(t,i,n){return ve(this,void 0,void 0,function(){return me(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(i),[4,this.setUserContextIfNeeded(t,n)];case 2:return e.sent(),this.lastUserAttributes=i,[4,this.storeUserContext(t,n,i)];case 3:return e.sent(),[4,this.sendUserEventToApi(Cs,t,i)];case 4:return e.sent(),this.logger.info("User update event tracked",{cuid:t}),[2]}})})},t.prototype.reset=function(){var t=this.lastAuthenticatedUser;t?this.pushUserSignOut(t):this.logger.warn("reset() called but no authenticated user to sign out")},t.prototype.setCapToken=function(t){var i;this.pendingGamificationSettings.capToken=t,null===(i=this.gamificationManager)||void 0===i||i.setCapToken(t)},t.prototype.getCapToken=function(){var t,i;return null!==(i=null===(t=this.gamificationManager)||void 0===t?void 0:t.getCapToken())&&void 0!==i?i:null},t.prototype.enablePagePathTracking=function(t){var i;this.pendingGamificationSettings.pagePathTrackingEnabled=t,null===(i=this.gamificationManager)||void 0===i||i.enablePagePathTracking(t)},t.prototype.onScreenChanged=function(t){var i;this.pendingGamificationSettings.screenName=t,null===(i=this.gamificationManager)||void 0===i||i.onScreenChanged(t)},t.prototype.setGamificationSuppressed=function(t){var i;this.pendingGamificationSettings.suppressed=t,null===(i=this.gamificationManager)||void 0===i||i.setGamificationSuppressed(t)},t.prototype.isGamificationSuppressed=function(){var t,i;return null!==(i=null===(t=this.gamificationManager)||void 0===t?void 0:t.isGamificationSuppressed())&&void 0!==i&&i},t.prototype.setTheme=function(t){var i;this.pendingGamificationSettings.theme=t,null===(i=this.gamificationManager)||void 0===i||i.setTheme(t)},t.prototype.forceSyncGamification=function(){var t,i=this;null===(t=this.gamificationManager)||void 0===t||t.forceSync().catch(function(t){i.logger.error("forceSyncGamification() failed",{error:t})})},t.prototype.setGamificationCallback=function(t){var i;this.pendingGamificationCallback=t,null===(i=this.gamificationManager)||void 0===i||i.setGamificationCallback(t)},t.prototype.pushUserSignOut=function(t){var i=this;this.queueUserOperation(function(){return ve(i,void 0,void 0,function(){var i;return me(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.pushUserSignOutAsync(t)];case 1:return n.sent(),[3,3];case 2:return i=n.sent(),this.logger.error(Cr,{cuid:t,error:i}),[3,3];case 3:return[2]}})})})},t.prototype.resetToAnonymousMode=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c,h,d,f,l;return me(this,function(v){switch(v.label){case 0:return null===(h=this.gamificationManager)||void 0===h||h.clean(),[4,this.sessionManager.endSession("signout")];case 1:if(v.sent(),!this.visitorTrackingEnabled)return this.logger.info("Visitor tracking disabled per latest config, skipping anonymous mode"),this.visitorId=null,this.logger.setContext({visitorId:""}),this.eventTracker.setVisitorTrackingState(null,!1),[2];v.label=2;case 2:return v.trys.push([2,11,,12]),[4,this.anonymousVisitorManager.clearVisitorId()];case 3:v.sent(),this.logger.info("Visitor ID cleared on user signout"),t=[],(i=null===(d=this.notificationManager)||void 0===d?void 0:d.getFCMToken())&&(n="granted"===(null===(f=this.notificationManager)||void 0===f?void 0:f.getState().permissionStatus),t.push({type:this.getChannelType(),value:i,primary:!0,verified:!0,subscribed:n})),e=void 0,v.label=4;case 4:return v.trys.push([4,8,,9]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,6];case 5:return s=v.sent(),[3,7];case 6:s=null,v.label=7;case 7:return r=s,e=ha(le(le({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:"granted"===(null===(l=this.notificationManager)||void 0===l?void 0:l.getState().permissionStatus),fcmTokenCreatedAt:r})),[3,9];case 8:return o=v.sent(),this.logger.error("Failed to collect extended fields on signout, proceeding without them",{error:o}),e=void 0,[3,9];case 9:return u=this,[4,this.anonymousVisitorManager.getOrCreateVisitorId(t.length>0?t:void 0,e)];case 10:return u.visitorId=v.sent(),this.logger.setContext({visitorId:this.visitorId}),this.logger.info("New anonymous visitor ID generated after signout",{visitorId:this.visitorId,hasFCMToken:!!i}),a=this.anonymousVisitorManager.getVisitorExternalId(),this.eventTracker.setVisitorTrackingState(this.visitorId,!0,a),[3,12];case 11:return c=v.sent(),this.logger.error("Failed to regenerate visitor ID on signout",{error:c}),this.visitorId=null,this.logger.setContext({visitorId:""}),this.eventTracker.setVisitorTrackingState(null,!0),[3,12];case 12:return[2]}})})},t.prototype.pushUserSignOutAsync=function(t){return ve(this,void 0,void 0,function(){var i,n,e,r,s,o,u,a,c;return me(this,function(h){switch(h.label){case 0:return[4,this.ensureInitialized()];case 1:return h.sent(),[4,this.setUserContextIfNeeded(t)];case 2:h.sent(),h.label=3;case 3:return h.trys.push([3,5,,6]),i=null!==(a=null===(u=this.sessionManager)||void 0===u?void 0:u.getSessionStartTime())&&void 0!==a?a:null,n=null!==i?Math.floor((Date.now()-i)/1e3):void 0,[4,this.sendUserEventToApi(Rs,t,this.lastUserAttributes,le(le({},void 0!==n&&{session_duration:n}),{logout_trigger:"user_initiated"}))];case 4:return h.sent(),this.logger.info("User signout event tracked",{cuid:t}),[3,6];case 5:return e=h.sent(),this.logger.error("Failed to send signout event to User Events API",{cuid:t,error:e}),[3,6];case 6:return h.trys.push([6,15,,16]),[4,this.anonymousVisitorManager.clearMergedUserId()];case 7:return h.sent(),[4,this.anonymousVisitorManager.clearPendingMerge()];case 8:return h.sent(),[4,this.clearUserContext()];case 9:h.sent(),this.logger.info("User context cleared, returning to anonymous mode (session continues)"),h.label=10;case 10:return h.trys.push([10,12,,13]),[4,this.visitorConfigManager.refreshConfig()];case 11:return r=h.sent(),this.visitorTrackingEnabled=!0===(null===(c=r.data)||void 0===c?void 0:c.visitorTrackingEnabled),this.logger.info("Visitor config refreshed on signout",{visitorTrackingEnabled:this.visitorTrackingEnabled}),[3,13];case 12:return s=h.sent(),this.logger.error("Failed to refresh visitor config on signout, using existing value",{visitorTrackingEnabled:this.visitorTrackingEnabled,error:s}),[3,13];case 13:return[4,this.resetToAnonymousMode()];case 14:return h.sent(),this.logger.info("SDK remains active for anonymous tracking"),[3,16];case 15:throw o=h.sent(),this.logger.error("Failed to clear user context on signout",{error:o}),o;case 16:return[2]}})})},t.prototype.buildInternalEventAttributes=function(t){return le(le(le({},this.userIdentified&&this.lastAuthenticatedUser&&{cuid:this.lastAuthenticatedUser}),this.visitorId&&{visitorId:this.visitorId}),t)},t.prototype.pushEvent=function(t,i){var n=this;this.pushEventAsync(t,i).catch(function(i){n.logger.error(Rr,{eventName:t,error:i})})},t.prototype.pushGamificationEvent=function(t,i){var n=this,e=le(le({},this.userIdentified&&this.lastAuthenticatedUser&&{cuid:this.lastAuthenticatedUser}),i);this.pushEventAsync(t,e,!0).catch(function(i){n.logger.error(Rr,{eventName:t,error:i})})},t.prototype.pushEventAsync=function(t,i){return ve(this,arguments,void 0,function(t,i,n){var e,r;return void 0===n&&(n=!1),me(this,function(s){switch(s.label){case 0:return[4,this.ensureInitialized()];case 1:return s.sent(),this.visitorTrackingEnabled||n?this.sdkDisabled&&!n?(this.logger.debug("SDK disabled, dropping event",{eventName:t}),[2]):this.userContextSet||this.visitorId?(e=le({},null!=i?i:{}),r={type:"behavioral",name:t,timestamp:Date.now(),data:e},[4,this.trackEvent(r,n)]):(this.logger.warn("Event tracking skipped: No visitor ID available and no user context set",{eventName:t}),[2]):(this.logger.warn("Event tracking skipped: Visitor tracking is disabled",{eventName:t}),[2]);case 2:return s.sent(),this.logger.info("Behavioral event tracked",{eventName:t,attributes:i}),[2]}})})},t.prototype.disableSDK=function(){this.sdkDisabled?this.logger.warn("SDK is already disabled"):(this.sdkDisabled=!0,this.eventTracker&&this.eventTracker.pause(),this.logger.info("SDK disabled — event tracking stopped"))},t.prototype.enableSDK=function(){var t=this;this.sdkDisabled?(this.sdkDisabled=!1,this.eventTracker&&this.eventTracker.resume().catch(function(i){t.logger.error("Failed to resume event tracker",i)}),this.logger.info("SDK enabled — event tracking resumed")):this.logger.warn("SDK is already enabled")},t.prototype.getChannelType=function(){return this.config.channelType||Fs.WEB},t.prototype.resolveGamificationBaseUrl=function(t){return t.gamificationBaseUrl?t.gamificationBaseUrl:t.gamificationRegion?Bo(t.gamificationRegion):Vo},t.prototype.applyConfigDefaults=function(){this.config.source=this.config.source||Ls.WEBPUSH,this.config.channelType=this.config.channelType||Fs.WEB;var t=Ne/6e4;this.config.sessionTimeoutMinutes=this.config.sessionTimeoutMinutes||t,this.config.batchSize=this.config.batchSize||De.BATCH_SIZE,this.config.debugLevel=this.config.debugLevel||"NONE",this.gamificationBaseUrl=this.resolveGamificationBaseUrl(this.config),this.logger.setEnabled(this.shouldEnableLogging(this.config.debugLevel)),this.logger.setLevel(this.resolveLogLevel(this.config.debugLevel))},t.prototype.applyRemoteConfigValues=function(t){this.config.accountId=t.accountId,this.config.baseURL=t.baseURL,this.config.orgId=t.orgId,this.config.source=t.source,this.config.channelType=t.channelType,this.config.brandId=this.config.brandId||t.brandId,this.config.applicationId=this.config.applicationId||t.applicationId,this.config.sessionTimeoutMinutes=t.sessionTimeoutMinutes,this.config.batchSize=t.batchSize,this.config.debugLevel=t.debugLevel,this.config.gamificationWriteKey=t.gamificationWriteKey||void 0,this.config.gamificationRegion=t.gamificationRegion||void 0,this.config.gamificationBaseUrl=t.gamificationBaseUrl||void 0,this.applyConfigDefaults(),this.logger.info("Session timeout configured:",{timeoutMinutes:this.config.sessionTimeoutMinutes,source:t.sessionTimeoutMinutes?"Remote Config":"Default"}),this.logger.info("Batch size configured:",{batchSize:this.config.batchSize,source:t.batchSize?"Remote Config":"Default"}),this.logger.info("Debug level configured:",{debugLevel:this.config.debugLevel,source:t.debugLevel?"Remote Config":"Default"})},t.prototype.applyDirectConfigValues=function(){this.applyConfigDefaults(),this.logger.info("✅ SDK configuration applied directly (no Remote Config)"),this.logger.debug("Final SDK config:",this.config)},t.prototype.bootstrapConfig=function(){return ve(this,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return this.config.remoteConfigKey?[4,this.fetchAndApplyRemoteConfig()]:[3,2];case 1:return t.sent(),[3,3];case 2:this.applyDirectConfigValues(),this.initializeManagersFromConfig(),t.label=3;case 3:return[2]}})})},t.prototype.getExtendedFieldsForMerge=function(){return ve(this,void 0,void 0,function(){var t,i,n,e;return me(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,2];case 1:return i=r.sent(),[3,3];case 2:i=null,r.label=3;case 3:return t=i,[2,ha(le(le({},this.config.appVersion?{appVersion:this.config.appVersion}:{}),{notificationPermissionGranted:"granted"===(null===(e=this.notificationManager)||void 0===e?void 0:e.getState().permissionStatus),fcmTokenCreatedAt:t}))];case 4:return n=r.sent(),this.logger.error("Failed to collect extended fields for merge, proceeding without them",{error:n}),[2,void 0];case 5:return[2]}})})},t.prototype.initializeManagersFromConfig=function(){var t=this;this.storageManager=new oc(this.logger,this.config.brandId,this.config.applicationId),this.sessionManager=new pc(this.storageManager,this.logger,this.config.brandId,this.config.applicationId,this.config.sessionTimeoutMinutes),this.apiClient=new tc({baseUrl:this.config.baseURL||""},this.logger,this.config.accountId||"",this.config.orgId||"",this.config.source||Ls.WEBPUSH);var i=this.apiClient;this.eventTracker=new sc(this.config,i,this.storageManager,this.logger);var n=this.config.orgId||"",e=this.config.accountId||"";this.logger.setContext({orgId:n,accountId:e}),this.visitorConfigManager=new cc(n,i,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.anonymousVisitorManager=new hc(e,n,i,this.logger,this.storageManager,le(le({},void 0!==this.config.brandId?{brandId:this.config.brandId}:{}),void 0!==this.config.applicationId?{applicationId:this.config.applicationId}:{})),this.anonymousVisitorManager.setMergeDataProviders(function(){var i;return(null===(i=t.notificationManager)||void 0===i?void 0:i.getFCMToken())||null},function(){return t.getChannelType()},function(){return t.getExtendedFieldsForMerge()},function(){var i;return"granted"===(null===(i=t.notificationManager)||void 0===i?void 0:i.getState().permissionStatus)},function(){var i,n;return null!==(n=null===(i=t.sessionManager)||void 0===i?void 0:i.getCurrentSessionId())&&void 0!==n?n:""}),this.initializeGamificationManager()},t.prototype.initializeGamificationManager=function(){var t=this;this.config.gamificationWriteKey&&this.gamificationBaseUrl?(this.gamificationManager=new Za(this.config.gamificationWriteKey,this.gamificationBaseUrl,this.logger,this.storageManager,function(i,n){return t.pushGamificationEvent(i,n)},function(){var i,n;return null!==(n=null===(i=t.sessionManager)||void 0===i?void 0:i.getCurrentSessionId())&&void 0!==n?n:null}),this.pendingGamificationCallback&&this.gamificationManager.setGamificationCallback(this.pendingGamificationCallback),this.applyPendingGamificationSettings()):this.logger.info(Ys)},t.prototype.applyPendingGamificationSettings=function(){var t,i,n,e,r,s=this.pendingGamificationSettings;void 0!==s.capToken&&(null===(t=this.gamificationManager)||void 0===t||t.setCapToken(s.capToken)),void 0!==s.pagePathTrackingEnabled&&(null===(i=this.gamificationManager)||void 0===i||i.enablePagePathTracking(s.pagePathTrackingEnabled)),void 0!==s.screenName&&(null===(n=this.gamificationManager)||void 0===n||n.onScreenChanged(s.screenName)),void 0!==s.suppressed&&(null===(e=this.gamificationManager)||void 0===e||e.setGamificationSuppressed(s.suppressed)),void 0!==s.theme&&(null===(r=this.gamificationManager)||void 0===r||r.setTheme(s.theme))},t.prototype.fetchAndApplyRemoteConfig=function(){return ve(this,void 0,void 0,function(){var t,i,n,e,r,s,o,u,a,c,h,d;return me(this,function(f){switch(f.label){case 0:this.logger.info("📡 Fetching configuration from Firebase Remote Config..."),f.label=1;case 1:return f.trys.push([1,5,,6]),[4,fc()];case 2:return t=f.sent(),[4,vc()];case 3:return i=f.sent(),n=t.initializeApp||t,e=i.getRemoteConfig||i,r=i.fetchAndActivate,s=i.getValue,o=n(this.config.firebaseConfig),(u=e(o)).settings.minimumFetchIntervalMillis=36e5,this.logger.info("🔄 Fetching Remote Config from Firebase..."),[4,r(u)];case 4:if(f.sent()||this.logger.error("⚠️ Remote Config fetched but not activated (using cached values)"),a=s(u,this.config.remoteConfigKey),!(c=a.asString()))throw new Error('Remote Config key "'.concat(this.config.remoteConfigKey,'" is empty or not found'));h=void 0;try{h=JSON.parse(c)}catch(t){throw new Error("Failed to parse Remote Config JSON: ".concat(t))}return this.logger.info("✅ Remote Config fetched successfully:",h),this.applyRemoteConfigValues(h),this.initializeManagersFromConfig(),this.logger.info("✅ SDK configuration applied from Remote Config"),this.logger.debug("Final SDK config:",this.config),[3,6];case 5:throw d=f.sent(),this.logger.error("❌ Failed to fetch Remote Config:",{remoteConfigKey:this.config.remoteConfigKey,error:d}),new Error("Remote Config bootstrap failed: ".concat(d));case 6:return[2]}})})},t.prototype.validateRequiredConfig=function(t){var i=[];if(t.remoteConfigKey?t.firebaseConfig||i.push("firebaseConfig"):(t.accountId||i.push("accountId"),t.baseURL||i.push("baseURL"),t.orgId||i.push("orgId")),i.length>0)throw this.logger.error("WebSDK initialization failed: missing required configuration fields",{missingFields:i}),new Error("WebSDK initialization failed: Missing required configuration fields: ".concat(i.join(", "),". ")+'Provide either "remoteConfigKey" + "firebaseConfig" (Remote Config bootstrap) or "accountId" + "baseURL" + "orgId" directly (direct-config bootstrap).')},t.prototype.ensureInitialized=function(){return ve(this,void 0,void 0,function(){var t;return me(this,function(i){switch(i.label){case 0:if(!this.initializationPromise)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.initializationPromise];case 2:return i.sent(),[3,4];case 3:throw t=i.sent(),new Error("SDK initialization failed: ".concat(t));case 4:if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events. Call init() first.");return[2]}})})},t.prototype.setUserContextIfNeeded=function(t,i){return ve(this,void 0,void 0,function(){return me(this,function(n){switch(n.label){case 0:return this.userContextSet&&this.lastAuthenticatedUser===t?[3,2]:[4,this.setUserContext(t,i)];case 1:n.sent(),this.logger.debug("User context set automatically",{cuid:t}),n.label=2;case 2:return[2]}})})},t.prototype.queueUserOperation=function(t){var i=this;this.userOperationChain=this.userOperationChain.then(t).catch(function(t){i.logger.error("User operation failed",t)})},t.p=null,t}();t.HydraSDK=yc,t.default=yc,Object.defineProperty(t,"_",{value:!0})});
|