@debales/ai 1.1.8-canary.1 → 1.1.8

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.
@@ -111,7 +111,7 @@ or you can use record.mirror to access the mirror instance during recording.`,hL
111
111
  `+S+"]":"["+x.join(",")+"]",u=S,y}for(m in E)zw.call(E,m)&&(y=r(m,E),y&&x.push(n(m)+(u?": ":":")+y));return y=x.length===0?"{}":u?"{"+x.join(",")+S+"}":"{"+x.join(",")+"}",u=S,y}};return r("",{"":t})}}(),N.JSONDecode=function(){var e,t,n={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
112
112
  `,r:"\r",t:" "},r,a=function(x){var E=new SyntaxError(x);throw E.at=e,E.text=r,E},s=function(x){return x&&x!==t&&a("Expected '"+x+"' instead of '"+t+"'"),t=r.charAt(e),e+=1,t},u=function(){var x,E="";for(t==="-"&&(E="-",s("-"));t>="0"&&t<="9";)E+=t,s();if(t===".")for(E+=".";s()&&t>="0"&&t<="9";)E+=t;if(t==="e"||t==="E")for(E+=t,s(),(t==="-"||t==="+")&&(E+=t,s());t>="0"&&t<="9";)E+=t,s();if(x=+E,!isFinite(x))a("Bad number");else return x},d=function(){var x,E,R="",T;if(t==='"')for(;s();){if(t==='"')return s(),R;if(t==="\\")if(s(),t==="u"){for(T=0,E=0;E<4&&(x=parseInt(s(),16),!!isFinite(x));E+=1)T=T*16+x;R+=String.fromCharCode(T)}else if(typeof n[t]=="string")R+=n[t];else break;else R+=t}a("Bad string")},h=function(){for(;t&&t<=" ";)s()},m=function(){switch(t){case"t":return s("t"),s("r"),s("u"),s("e"),!0;case"f":return s("f"),s("a"),s("l"),s("s"),s("e"),!1;case"n":return s("n"),s("u"),s("l"),s("l"),null}a('Unexpected "'+t+'"')},y,v=function(){var x=[];if(t==="["){if(s("["),h(),t==="]")return s("]"),x;for(;t;){if(x.push(y()),h(),t==="]")return s("]"),x;s(","),h()}}a("Bad array")},S=function(){var x,E={};if(t==="{"){if(s("{"),h(),t==="}")return s("}"),E;for(;t;){if(x=d(),h(),s(":"),Object.hasOwnProperty.call(E,x)&&a('Duplicate key "'+x+'"'),E[x]=y(),h(),t==="}")return s("}"),E;s(","),h()}}a("Bad object")};return y=function(){switch(h(),t){case"{":return S();case"[":return v();case'"':return d();case"-":return u();default:return t>="0"&&t<="9"?u():m()}},function(x){var E;return r=x,e=0,t=" ",E=y(),h(),t&&a("Syntax error"),E}}(),N.base64Encode=function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n,r,a,s,u,d,h,m,y=0,v=0,S="",x=[];if(!e)return e;e=N.utf8Encode(e);do n=e.charCodeAt(y++),r=e.charCodeAt(y++),a=e.charCodeAt(y++),m=n<<16|r<<8|a,s=m>>18&63,u=m>>12&63,d=m>>6&63,h=m&63,x[v++]=t.charAt(s)+t.charAt(u)+t.charAt(d)+t.charAt(h);while(y<e.length);switch(S=x.join(""),e.length%3){case 1:S=S.slice(0,-2)+"==";break;case 2:S=S.slice(0,-1)+"=";break}return S},N.utf8Encode=function(e){e=(e+"").replace(/\r\n/g,`
113
113
  `).replace(/\r/g,`
114
- `);var t="",n,r,a=0,s;for(n=r=0,a=e.length,s=0;s<a;s++){var u=e.charCodeAt(s),d=null;u<128?r++:u>127&&u<2048?d=String.fromCharCode(u>>6|192,u&63|128):d=String.fromCharCode(u>>12|224,u>>6&63|128,u&63|128),d!==null&&(r>n&&(t+=e.substring(n,r)),t+=d,n=r=s+1)}return r>n&&(t+=e.substring(n,e.length)),t},N.UUID=function(){try{return ct.crypto.randomUUID()}catch{for(var e=new Array(36),t=0;t<36;t++)e[t]=Math.floor(Math.random()*16);return e[14]=4,e[19]=e[19]&=-5,e[19]=e[19]|=8,e[8]=e[13]=e[18]=e[23]="-",N.map(e,function(r){return r.toString(16)}).join("")}};var tN=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];N.isBlockedUA=function(e){var t;for(e=e.toLowerCase(),t=0;t<tN.length;t++)if(e.indexOf(tN[t])!==-1)return!0;return!1},N.HTTPBuildQuery=function(e,t){var n,r,a=[];return N.isUndefined(t)&&(t="&"),N.each(e,function(s,u){n=encodeURIComponent(s.toString()),r=encodeURIComponent(u),a[a.length]=r+"="+n}),a.join(t)},N.getQueryParam=function(e,t){t=t.replace(/[[]/g,"\\[").replace(/[\]]/g,"\\]");var n="[\\?&]"+t+"=([^&#]*)",r=new RegExp(n),a=r.exec(e);if(a===null||a&&typeof a[1]!="string"&&a[1].length)return"";var s=a[1];try{s=decodeURIComponent(s)}catch{zn.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},N.cookie={get:function(e){for(var t=e+"=",n=jn.cookie.split(";"),r=0;r<n.length;r++){for(var a=n[r];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}return null},parse:function(e){var t;try{t=N.JSONDecode(N.cookie.get(e))||{}}catch{}return t},set_seconds:function(e,t,n,r,a,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=iN(jn.location.hostname);d=y?"; domain=."+y:""}if(n){var v=new Date;v.setTime(v.getTime()+n*1e3),h="; expires="+v.toGMTString()}s&&(a=!0,m="; SameSite=None"),a&&(m+="; secure"),jn.cookie=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m},set:function(e,t,n,r,a,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=iN(jn.location.hostname);d=y?"; domain=."+y:""}if(n){var v=new Date;v.setTime(v.getTime()+n*24*60*60*1e3),h="; expires="+v.toGMTString()}s&&(a=!0,m="; SameSite=None"),a&&(m+="; secure");var S=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m;return jn.cookie=S,S},remove:function(e,t,n){N.cookie.set(e,"",-1,t,!1,!1,n)}};var nN=function(e){var t=!0;try{var n="__mplss_"+QR(8),r="xyz";e.setItem(n,r),e.getItem(n)!==r&&(t=!1),e.removeItem(n)}catch{t=!1}return t},YR=null,H0=function(e,t){return YR!==null&&!t?YR:YR=nN(e||ct.localStorage)},ZR=null,pW=function(e,t){return ZR!==null&&!t?ZR:ZR=nN(e||ct.sessionStorage)};function rN(e,t,n){var r=function(a){zn.error(t+" error: "+a)};return{is_supported:function(a){var s=n(e,a);return s||zn.error(t+" unsupported"),s},error:r,get:function(a){try{return e.getItem(a)}catch(s){r(s)}return null},parse:function(a){try{return N.JSONDecode(e.getItem(a))||{}}catch{}return null},set:function(a,s){try{e.setItem(a,s)}catch(u){r(u)}},remove:function(a){try{e.removeItem(a)}catch(s){r(s)}}}}N.localStorage=rN(ct.localStorage,"localStorage",H0),N.sessionStorage=rN(ct.sessionStorage,"sessionStorage",pW),N.register_event=function(){var e=function(r,a,s,u,d){if(!r){zn.error("No valid element provided to register_event");return}if(r.addEventListener&&!u)r.addEventListener(a,s,!!d);else{var h="on"+a,m=r[h];r[h]=t(r,s,m)}};function t(r,a,s){var u=function(d){if(d=d||n(ct.event),!!d){var h=!0,m,y;return N.isFunction(s)&&(m=s(d)),y=a.call(r,d),(m===!1||y===!1)&&(h=!1),h}};return u}function n(r){return r&&(r.preventDefault=n.preventDefault,r.stopPropagation=n.stopPropagation),r}return n.preventDefault=function(){this.returnValue=!1},n.stopPropagation=function(){this.cancelBubble=!0},e}();var gW=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');N.dom_query=function(){function e(a){return a.all?a.all:a.getElementsByTagName("*")}var t=/[\t\r\n]/g;function n(a,s){var u=" "+s+" ";return(" "+a.className+" ").replace(t," ").indexOf(u)>=0}function r(a){if(!jn.getElementsByTagName)return[];var s=a.split(" "),u,d,h,m,y,v,S,x,E,R,T=[jn];for(v=0;v<s.length;v++){if(u=s[v].replace(/^\s+/,"").replace(/\s+$/,""),u.indexOf("#")>-1){d=u.split("#"),h=d[0];var A=d[1],M=jn.getElementById(A);if(!M||h&&M.nodeName.toLowerCase()!=h)return[];T=[M];continue}if(u.indexOf(".")>-1){d=u.split("."),h=d[0];var D=d[1];for(h||(h="*"),m=[],y=0,S=0;S<T.length;S++)for(h=="*"?E=e(T[S]):E=T[S].getElementsByTagName(h),x=0;x<E.length;x++)m[y++]=E[x];for(T=[],R=0,S=0;S<m.length;S++)m[S].className&&N.isString(m[S].className)&&n(m[S],D)&&(T[R++]=m[S]);continue}var $=u.match(gW);if($){h=$[1];var U=$[2],P=$[3],Z=$[4];for(h||(h="*"),m=[],y=0,S=0;S<T.length;S++)for(h=="*"?E=e(T[S]):E=T[S].getElementsByTagName(h),x=0;x<E.length;x++)m[y++]=E[x];T=[],R=0;var X;switch(P){case"=":X=function(K){return K.getAttribute(U)==Z};break;case"~":X=function(K){return K.getAttribute(U).match(new RegExp("\\b"+Z+"\\b"))};break;case"|":X=function(K){return K.getAttribute(U).match(new RegExp("^"+Z+"-?"))};break;case"^":X=function(K){return K.getAttribute(U).indexOf(Z)===0};break;case"$":X=function(K){return K.getAttribute(U).lastIndexOf(Z)==K.getAttribute(U).length-Z.length};break;case"*":X=function(K){return K.getAttribute(U).indexOf(Z)>-1};break;default:X=function(K){return K.getAttribute(U)}}for(T=[],R=0,S=0;S<m.length;S++)X(m[S])&&(T[R++]=m[S]);continue}for(h=u,m=[],y=0,S=0;S<T.length;S++)for(E=T[S].getElementsByTagName(h),x=0;x<E.length;x++)m[y++]=E[x];T=m}return T}return function(a){return N.isElement(a)?[a]:N.isObject(a)&&!N.isUndefined(a.length)?a:r.call(this,a)}}();var mW=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","utm_id","utm_source_platform","utm_campaign_id","utm_creative_format","utm_marketing_tactic"],vW=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","sccid","ttclid","twclid","wbraid"];N.info={campaignParams:function(e){var t="",n={};return N.each(mW,function(r){t=N.getQueryParam(jn.URL,r),t.length?n[r]=t:e!==void 0&&(n[r]=e)}),n},clickParams:function(){var e="",t={};return N.each(vW,function(n){e=N.getQueryParam(jn.URL,n),e.length&&(t[n]=e)}),t},marketingParams:function(){return N.extend(N.info.campaignParams(),N.info.clickParams())},searchEngine:function(e){return e.search("https?://(.*)google.([^/?]*)")===0?"google":e.search("https?://(.*)bing.com")===0?"bing":e.search("https?://(.*)yahoo.com")===0?"yahoo":e.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null},searchInfo:function(e){var t=N.info.searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(t!==null){r.$search_engine=t;var a=N.getQueryParam(e,n);a.length&&(r.mp_keyword=a)}return r},browser:function(e,t,n){return t=t||"",n||N.includes(e," OPR/")?N.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":N.includes(e,"IEMobile")||N.includes(e,"WPDesktop")?"Internet Explorer Mobile":N.includes(e,"SamsungBrowser/")?"Samsung Internet":N.includes(e,"Edge")||N.includes(e,"Edg/")?"Microsoft Edge":N.includes(e,"FBIOS")?"Facebook Mobile":N.includes(e,"Chrome")?"Chrome":N.includes(e,"CriOS")?"Chrome iOS":N.includes(e,"UCWEB")||N.includes(e,"UCBrowser")?"UC Browser":N.includes(e,"FxiOS")?"Firefox iOS":N.includes(t,"Apple")?N.includes(e,"Mobile")?"Mobile Safari":"Safari":N.includes(e,"Android")?"Android Mobile":N.includes(e,"Konqueror")?"Konqueror":N.includes(e,"Firefox")?"Firefox":N.includes(e,"MSIE")||N.includes(e,"Trident/")?"Internet Explorer":N.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,n){var r=N.info.browser(e,t,n),a={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/},s=a[r];if(s===void 0)return null;var u=e.match(s);return u?parseFloat(u[u.length-2]):null},os:function(){var e=nc;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},device:function(e){return/Windows Phone/i.test(e)||/WPDesktop/.test(e)?"Windows Phone":/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Android/.test(e)?"Android":""},referringDomain:function(e){var t=e.split("/");return t.length>=3?t[2]:""},currentUrl:function(){return ct.location.href},properties:function(e){return typeof e!="object"&&(e={}),N.extend(N.strip_empty_properties({$os:N.info.os(),$browser:N.info.browser(nc,Df.vendor,Hw),$referrer:jn.referrer,$referring_domain:N.info.referringDomain(jn.referrer),$device:N.info.device(nc)}),{$current_url:N.info.currentUrl(),$browser_version:N.info.browserVersion(nc,Df.vendor,Hw),$screen_height:XL.height,$screen_width:XL.width,mp_lib:"web",$lib_version:hl.LIB_VERSION,$insert_id:QR(),time:N.timestamp()/1e3},N.strip_empty_properties(e))},people_properties:function(){return N.extend(N.strip_empty_properties({$os:N.info.os(),$browser:N.info.browser(nc,Df.vendor,Hw)}),{$browser_version:N.info.browserVersion(nc,Df.vendor,Hw)})},mpPageViewProperties:function(){return N.strip_empty_properties({current_page_title:jn.title,current_domain:ct.location.hostname,current_url_path:ct.location.pathname,current_url_protocol:ct.location.protocol,current_url_search:ct.location.search})}};var yW=function(e,t){var n=null,r=[];return function(a){var s=this;return r.push(a),n||(n=new Pn(function(u){setTimeout(function(){var d=e.apply(s,[r]);n=null,r=[],u(d)},t)})),n}},QR=function(e){var t=Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10);return e?t.substring(0,e):t},bW=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,_W=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,iN=function(e){var t=_W,n=e.split("."),r=n[n.length-1];(r.length>4||r==="com"||r==="org")&&(t=bW);var a=e.match(t);return a?a[0]:""},SW=function(){var e=ct.navigator.onLine;return N.isUndefined(e)||e},If=function(){},Gg=null,Pw=null;typeof JSON<"u"&&(Gg=JSON.stringify,Pw=JSON.parse),Gg=Gg||N.JSONEncode,Pw=Pw||N.JSONDecode,N.info=N.info,N.info.browser=N.info.browser,N.info.browserVersion=N.info.browserVersion,N.info.device=N.info.device,N.info.properties=N.info.properties,N.isBlockedUA=N.isBlockedUA,N.isEmptyObject=N.isEmptyObject,N.isObject=N.isObject,N.JSONDecode=N.JSONDecode,N.JSONEncode=N.JSONEncode,N.toArray=N.toArray,N.NPO=Of;var wW="mixpanelBrowserDb",aN="mixpanelRecordingEvents",KR="mixpanelRecordingRegistry",xW=1,CW=[aN,KR],eu=function(e){this.dbPromise=null,this.storeName=e};eu.prototype._openDb=function(){return new Pn(function(e,t){var n=ct.indexedDB.open(wW,xW);n.onerror=function(){t(n.error)},n.onsuccess=function(){e(n.result)},n.onupgradeneeded=function(r){var a=r.target.result;CW.forEach(function(s){a.createObjectStore(s)})}})},eu.prototype.init=function(){return ct.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof ct.IDBDatabase?Pn.resolve():Pn.reject(e)})):Pn.reject("indexedDB is not supported in this browser")},eu.prototype.makeTransaction=function(e,t){var n=this.storeName,r=function(a){return new Pn(function(s,u){var d=a.transaction(n,e);d.oncomplete=function(){s(d)},d.onabort=d.onerror=function(){u(d.error)},t(d.objectStore(n))})};return this.dbPromise.then(r).catch((function(a){return a&&a.name==="InvalidStateError"?(this.dbPromise=this._openDb(),this.dbPromise.then(r)):Pn.reject(a)}).bind(this))},eu.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(n){n.put(t,e)})},eu.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},eu.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},eu.prototype.getAll=function(){var e;return this.makeTransaction("readonly",function(t){e=t.getAll()}).then(function(){return e.result})};var EW="__mp_opt_in_out_";function AW(e,t){lN(!0,e,t)}function TW(e,t){lN(!1,e,t)}function kW(e,t){return sN(e,t)==="1"}function oN(e,t){if(OW(t))return zn.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"'),!0;var n=sN(e,t)==="0";return n&&zn.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),n}function Lf(e){return JR(e,function(t){return this.get_config(t)})}function Nf(e){return JR(e,function(t){return this._get_config(t)})}function Vg(e){return JR(e,function(t){return this._get_config(t)})}function RW(e,t){t=t||{},XR(t).remove(WR(e,t),!!t.crossSubdomainCookie,t.cookieDomain)}function XR(e){return e=e||{},e.persistenceType==="localStorage"?N.localStorage:N.cookie}function WR(e,t){return t=t||{},(t.persistencePrefix||EW)+e}function sN(e,t){return XR(t).get(WR(e,t))}function OW(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||ct,n=t.navigator||{},r=!1;return N.each([n.doNotTrack,n.msDoNotTrack,t.doNotTrack],function(a){N.includes([!0,1,"1","yes"],a)&&(r=!0)}),r}function lN(e,t,n){if(!N.isString(t)||!t.length){zn.error("gdpr."+(e?"optIn":"optOut")+" called with an invalid token");return}n=n||{},XR(n).set(WR(t,n),e?1:0,N.isNumber(n.cookieExpiration)?n.cookieExpiration:null,!!n.crossSubdomainCookie,!!n.secureCookie,!!n.crossSiteCookie,n.cookieDomain),n.track&&e&&n.track(n.trackEventName||"$opt_in",n.trackProperties,{send_immediately:!0})}function JR(e,t){return function(){var n=!1;try{var r=t.call(this,"token"),a=t.call(this,"ignore_dnt"),s=t.call(this,"opt_out_tracking_persistence_type"),u=t.call(this,"opt_out_tracking_cookie_prefix"),d=t.call(this,"window");r&&(n=oN(r,{ignoreDnt:a,persistenceType:s,persistencePrefix:u,window:d}))}catch(m){zn.error("Unexpected error when checking tracking opt-out status: "+m)}if(!n)return e.apply(this,arguments);var h=arguments[arguments.length-1];typeof h=="function"&&h(0)}}var MW=jg("lock"),uN=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||ct.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||Pn};uN.prototype.withLock=function(e,t){var n=this.promiseImpl;return new n(N.bind(function(r,a){var s=t||new Date().getTime()+"|"+Math.random(),u=new Date().getTime(),d=this.storageKey,h=this.pollIntervalMS,m=this.timeoutMS,y=this.storage,v=d+":X",S=d+":Y",x=d+":Z",E=function(D){if(new Date().getTime()-u>m){MW.error("Timeout waiting for mutex on "+d+"; clearing lock. ["+s+"]"),y.removeItem(x),y.removeItem(S),A();return}setTimeout(function(){try{D()}catch($){a($)}},h*(Math.random()+.1))},R=function(D,$){D()?$():E(function(){R(D,$)})},T=function(){var D=y.getItem(S);return D&&D!==s?!1:(y.setItem(S,s),y.getItem(S)===s?!0:(H0(y,!0)||a(new Error("localStorage support dropped while acquiring lock")),!1))},A=function(){y.setItem(v,s),R(T,function(){if(y.getItem(v)===s){M();return}E(function(){if(y.getItem(S)!==s){A();return}R(function(){return!y.getItem(x)},M)})})},M=function(){y.setItem(x,"1");var D=function(){y.removeItem(x),y.getItem(S)===s&&y.removeItem(S),y.getItem(v)===s&&y.removeItem(v)};e().then(function($){D(),r($)}).catch(function($){D(),a($)})};try{if(H0(y,!0))A();else throw new Error("localStorage support check failed")}catch(D){a(D)}},this))};var P0=function(e){this.storage=e||ct.localStorage};P0.prototype.init=function(){return Pn.resolve()},P0.prototype.setItem=function(e,t){return new Pn(N.bind(function(n,r){try{this.storage.setItem(e,Gg(t))}catch(a){r(a)}n()},this))},P0.prototype.getItem=function(e){return new Pn(N.bind(function(t,n){var r;try{r=Pw(this.storage.getItem(e))}catch(a){n(a)}t(r)},this))},P0.prototype.removeItem=function(e){return new Pn(N.bind(function(t,n){try{this.storage.removeItem(e)}catch(r){n(r)}t()},this))};var cN=jg("batch"),tu=function(e,t){t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new P0,this.lock=new uN(e,{storage:t.sharedLockStorage||ct.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||N.bind(cN.error,cN),this.pid=t.pid||null,this.memQueue=[],this.initialized=!1,t.enqueueThrottleMs?this.enqueuePersisted=yW(N.bind(this._enqueuePersisted,this),t.enqueueThrottleMs):this.enqueuePersisted=N.bind(function(n){return this._enqueuePersisted([n])},this)};tu.prototype.ensureInit=function(){return this.initialized?Pn.resolve():this.queueStorage.init().then(N.bind(function(){this.initialized=!0},this)).catch(N.bind(function(e){this.reportError("Error initializing queue persistence. Disabling persistence",e),this.initialized=!0,this.usePersistence=!1},this))},tu.prototype.enqueue=function(e,t){var n={id:QR(),flushAfter:new Date().getTime()+t*2,payload:e};return this.usePersistence?this.enqueuePersisted(n):(this.memQueue.push(n),Pn.resolve(!0))},tu.prototype._enqueuePersisted=function(e){var t=N.bind(function(){return this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(n){return this.saveToStorage(n.concat(e))},this)).then(N.bind(function(n){return n&&(this.memQueue=this.memQueue.concat(e)),n},this)).catch(N.bind(function(n){return this.reportError("Error enqueueing items",n,e),!1},this))},this);return this.lock.withLock(t,this.pid).catch(N.bind(function(n){return this.reportError("Error acquiring storage lock",n),!1},this))},tu.prototype.fillBatch=function(e){var t=this.memQueue.slice(0,e);return this.usePersistence&&t.length<e?this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(n){if(n.length){var r={};N.each(t,function(u){r[u.id]=!0});for(var a=0;a<n.length;a++){var s=n[a];if(new Date().getTime()>s.flushAfter&&!r[s.id]&&(s.orphaned=!0,t.push(s),t.length>=e))break}}return t},this)):Pn.resolve(t)};var fN=function(e,t){var n=[];return N.each(e,function(r){r.id&&!t[r.id]&&n.push(r)}),n};tu.prototype.removeItemsByID=function(e){var t={};if(N.each(e,function(r){t[r]=!0}),this.memQueue=fN(this.memQueue,t),this.usePersistence){var n=N.bind(function(){return this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(r){return r=fN(r,t),this.saveToStorage(r)},this)).then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(r){for(var a=0;a<r.length;a++){var s=r[a];if(s.id&&t[s.id])throw new Error("Item not removed from storage")}return!0},this)).catch(N.bind(function(r){return this.reportError("Error removing items",r,e),!1},this))},this);return this.lock.withLock(n,this.pid).catch(N.bind(function(r){return this.reportError("Error acquiring storage lock",r),H0(this.lock.storage,!0)?!1:n().then(N.bind(function(a){return a||this.queueStorage.removeItem(this.storageKey).then(function(){return a})},this)).catch(N.bind(function(a){return this.reportError("Error clearing queue",a),!1},this))},this))}else return Pn.resolve(!0)};var dN=function(e,t){var n=[];return N.each(e,function(r){var a=r.id;if(a in t){var s=t[a];s!==null&&(r.payload=s,n.push(r))}else n.push(r)}),n};tu.prototype.updatePayloads=function(e){return this.memQueue=dN(this.memQueue,e),this.usePersistence?this.lock.withLock(N.bind(function(){return this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(n){return n=dN(n,e),this.saveToStorage(n)},this)).catch(N.bind(function(n){return this.reportError("Error updating items",e,n),!1},this))},this),this.pid).catch(N.bind(function(t){return this.reportError("Error acquiring storage lock",t),!1},this)):Pn.resolve(!0)},tu.prototype.readFromStorage=function(){return this.ensureInit().then(N.bind(function(){return this.queueStorage.getItem(this.storageKey)},this)).then(N.bind(function(e){return e&&(N.isArray(e)||(this.reportError("Invalid storage entry:",e),e=null)),e||[]},this)).catch(N.bind(function(e){return this.reportError("Error retrieving queue",e),[]},this))},tu.prototype.saveToStorage=function(e){return this.ensureInit().then(N.bind(function(){return this.queueStorage.setItem(this.storageKey,e)},this)).then(function(){return!0}).catch(N.bind(function(t){return this.reportError("Error saving queue",t),!1},this))},tu.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(N.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):Pn.resolve()};var DW=10*60*1e3,q0=jg("batch"),ss=function(e,t){this.errorReporter=t.errorReporter,this.queue=new tu(e,{errorReporter:N.bind(this.reportError,this),queueStorage:t.queueStorage,sharedLockStorage:t.sharedLockStorage,sharedLockTimeoutMS:t.sharedLockTimeoutMS,usePersistence:t.usePersistence,enqueueThrottleMs:t.enqueueThrottleMs}),this.libConfig=t.libConfig,this.sendRequest=t.sendRequestFunc,this.beforeSendHook=t.beforeSendHook,this.stopAllBatching=t.stopAllBatchingFunc,this.batchSize=this.libConfig.batch_size,this.flushInterval=this.libConfig.batch_flush_interval_ms,this.stopped=!this.libConfig.batch_autostart,this.consecutiveRemovalFailures=0,this.itemIdsSentSuccessfully={},this.flushOnlyOnInterval=t.flushOnlyOnInterval||!1,this._flushPromise=null};ss.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},ss.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},ss.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},ss.prototype.clear=function(){return this.queue.clear()},ss.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},ss.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},ss.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(N.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},ss.prototype.sendRequestPromise=function(e,t){return new Pn(N.bind(function(n){this.sendRequest(e,t,n)},this))},ss.prototype.flush=function(e){if(this.requestInProgress)return q0.log("Flush: Request already in progress"),Pn.resolve();this.requestInProgress=!0,e=e||{};var t=this.libConfig.batch_request_timeout_ms,n=new Date().getTime(),r=this.batchSize;return this.queue.fillBatch(r).then(N.bind(function(a){var s=a.length===r,u=[],d={};if(N.each(a,function(v){var S=v.payload;if(this.beforeSendHook&&!v.orphaned&&(S=this.beforeSendHook(S)),S){S.event&&S.properties&&(S.properties=N.extend({},S.properties,{mp_sent_by_lib_version:hl.LIB_VERSION}));var x=!0,E=v.id;E?(this.itemIdsSentSuccessfully[E]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:v,batchSize:a.length,timesSent:this.itemIdsSentSuccessfully[E]}),x=!1):this.reportError("[dupe] found item with no ID",{item:v}),x&&u.push(S)}d[v.id]=S},this),u.length<1)return this.requestInProgress=!1,this.resetFlush(),Pn.resolve();var h=N.bind(function(){return this.queue.removeItemsByID(N.map(a,function(v){return v.id})).then(N.bind(function(v){return N.each(a,N.bind(function(S){var x=S.id;x?(this.itemIdsSentSuccessfully[x]=this.itemIdsSentSuccessfully[x]||0,this.itemIdsSentSuccessfully[x]++,this.itemIdsSentSuccessfully[x]>5&&this.reportError("[dupe] item ID sent too many times",{item:S,batchSize:a.length,timesSent:this.itemIdsSentSuccessfully[x]})):this.reportError("[dupe] found item with no ID while removing",{item:S})},this)),v?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!s?(this.resetFlush(),Pn.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),Pn.resolve())},this))},this),m=N.bind(function(v){this.requestInProgress=!1;try{if(e.unloading)return this.queue.updatePayloads(d);if(N.isObject(v)&&v.error==="timeout"&&new Date().getTime()-n>=t)return this.reportError("Network timeout; retrying"),this.flush();if(N.isObject(v)&&(v.httpStatusCode>=500||v.httpStatusCode===429||v.httpStatusCode<=0&&!SW()||v.error==="timeout")){var S=this.flushInterval*2;return v.retryAfter&&(S=parseInt(v.retryAfter,10)*1e3||S),S=Math.min(DW,S),this.reportError("Error; retry in "+S+" ms"),this.scheduleFlush(S),Pn.resolve()}else if(N.isObject(v)&&v.httpStatusCode===413)if(a.length>1){var x=Math.max(1,Math.floor(r/2));return this.batchSize=Math.min(this.batchSize,x,a.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush(),Pn.resolve()}else return this.reportError("Single-event request too large; dropping",a),this.resetBatchSize(),h();else return h()}catch(E){this.reportError("Error handling API response",E),this.resetFlush()}},this),y={method:"POST",verbose:!0,ignore_json_errors:!0,timeout_ms:t};return e.unloading&&(y.transport="sendBeacon"),q0.log("MIXPANEL REQUEST:",u),this.sendRequestPromise(u,y).then(m)},this)).catch(N.bind(function(a){this.reportError("Error flushing request queue",a),this.resetFlush()},this))},ss.prototype.reportError=function(e,t){if(q0.error.apply(q0.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(n){q0.error(n)}};var eO=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},IW=250,Yg=jg("recorder"),hN=ct.CompressionStream,LW={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},NW=new Set([Gt.MouseMove,Gt.MouseInteraction,Gt.Scroll,Gt.ViewportResize,Gt.Input,Gt.TouchMove,Gt.MediaInteraction,Gt.Drag,Gt.Selection]);function $W(e){return e.type===En.IncrementalSnapshot&&NW.has(e.data.source)}var da=function(e){this._mixpanel=e.mixpanelInstance,this._onIdleTimeout=e.onIdleTimeout||If,this._onMaxLengthReached=e.onMaxLengthReached||If,this._onBatchSent=e.onBatchSent||If,this._rrwebRecord=e.rrwebRecord||null,this._stopRecording=null,this.replayId=e.replayId,this.batchStartUrl=e.batchStartUrl||null,this.replayStartUrl=e.replayStartUrl||null,this.idleExpires=e.idleExpires||null,this.maxExpires=e.maxExpires||null,this.replayStartTime=e.replayStartTime||null,this.seqNo=e.seqNo||0,this.idleTimeoutId=null,this.maxTimeoutId=null,this.recordMaxMs=U0,this.recordMinMs=0;var t=H0(e.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new eu(aN),this.batcher=new ss(this.batcherKey,{errorReporter:this.reportError.bind(this),flushOnlyOnInterval:!0,libConfig:LW,sendRequestFunc:this.flushEventsWithOptOut.bind(this),queueStorage:this.queueStorage,sharedLockStorage:e.sharedLockStorage,usePersistence:t,stopAllBatchingFunc:this.stopRecording.bind(this),enqueueThrottleMs:IW,sharedLockTimeoutMS:10*1e3})};da.prototype.unloadPersistedData=function(){return this.batcher.stop(),this.batcher.flush().then((function(){return this.queueStorage.removeItem(this.batcherKey)}).bind(this))},da.prototype.getConfig=function(e){return this._mixpanel.get_config(e)},da.prototype.get_config=function(e){return this.getConfig(e)},da.prototype.startRecording=function(e){if(this._rrwebRecord===null){this.reportError("rrweb record function not provided. ");return}if(this._stopRecording!==null){Yg.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>U0&&(this.recordMaxMs=U0,Yg.critical("record_max_ms cannot be greater than "+U0+"ms. Capping value.")),this.maxExpires||(this.maxExpires=new Date().getTime()+this.recordMaxMs),this.recordMinMs=this.getConfig("record_min_ms"),this.recordMinMs>qR&&(this.recordMinMs=qR,Yg.critical("record_min_ms cannot be greater than "+qR+"ms. Capping value.")),this.replayStartTime||(this.replayStartTime=new Date().getTime(),this.batchStartUrl=N.info.currentUrl(),this.replayStartUrl=N.info.currentUrl()),e||this.recordMinMs>0?this.batcher.stop():this.batcher.start();var t=(function(){clearTimeout(this.idleTimeoutId);var a=this.getConfig("record_idle_timeout_ms");this.idleTimeoutId=setTimeout(this._onIdleTimeout,a),this.idleExpires=new Date().getTime()+a}).bind(this);t();var n=this.getConfig("record_block_selector");(n===""||n===null)&&(n=void 0);try{this._stopRecording=this._rrwebRecord({emit:(function(a){if(this.idleExpires&&this.idleExpires<a.timestamp){this._onIdleTimeout();return}$W(a)&&(this.batcher.stopped&&new Date().getTime()-this.replayStartTime>=this.recordMinMs&&this.batcher.start(),t()),this.__enqueuePromise=this.batcher.enqueue(a)}).bind(this),blockClass:this.getConfig("record_block_class"),blockSelector:n,collectFonts:this.getConfig("record_collect_fonts"),dataURLOptions:{type:"image/webp",quality:.6},maskAllInputs:!0,maskTextClass:this.getConfig("record_mask_text_class"),maskTextSelector:this.getConfig("record_mask_text_selector"),recordCanvas:this.getConfig("record_canvas"),sampling:{canvas:15}})}catch(a){this.reportError("Unexpected error when starting rrweb recording.",a)}if(typeof this._stopRecording!="function"){this.reportError("rrweb failed to start, skipping this recording."),this._stopRecording=null,this.stopRecording();return}var r=this.maxExpires-new Date().getTime();this.maxTimeoutId=setTimeout(this._onMaxLengthReached.bind(this),r)},da.prototype.stopRecording=function(e){if(!this.isRrwebStopped()){try{this._stopRecording()}catch(n){this.reportError("Error with rrweb stopRecording",n)}this._stopRecording=null}var t;return this.batcher.stopped?t=this.batcher.clear():e||(t=this.batcher.flush()),this.batcher.stop(),clearTimeout(this.idleTimeoutId),clearTimeout(this.maxTimeoutId),t},da.prototype.isRrwebStopped=function(){return this._stopRecording===null},da.prototype.flushEventsWithOptOut=function(e,t,n){var r=(function(a){a===0&&(this.stopRecording(),n({error:"Tracking has been opted out, stopping recording."}))}).bind(this);this._flushEvents(e,t,n,r)},da.prototype.serialize=function(){var e;try{e=this._mixpanel.get_tab_id()}catch(t){this.reportError("Error getting tab ID for serialization ",t),e=null}return{replayId:this.replayId,seqNo:this.seqNo,replayStartTime:this.replayStartTime,batchStartUrl:this.batchStartUrl,replayStartUrl:this.replayStartUrl,idleExpires:this.idleExpires,maxExpires:this.maxExpires,tabId:e}},da.deserialize=function(e,t){var n=new da(N.extend({},t,{replayId:e.replayId,batchStartUrl:e.batchStartUrl,replayStartUrl:e.replayStartUrl,idleExpires:e.idleExpires,maxExpires:e.maxExpires,replayStartTime:e.replayStartTime,seqNo:e.seqNo,sharedLockStorage:t.sharedLockStorage}));return n},da.prototype._sendRequest=function(e,t,n,r){var a=(function(s,u){s.status===200&&this.replayId===e&&(this.seqNo++,this.batchStartUrl=N.info.currentUrl()),this._onBatchSent(),r({status:0,httpStatusCode:s.status,responseBody:u,retryAfter:s.headers.get("Retry-After")})}).bind(this);ct.fetch(this.getConfig("api_host")+"/"+this.getConfig("api_routes").record+"?"+new URLSearchParams(t),{method:"POST",headers:{Authorization:"Basic "+btoa(this.getConfig("token")+":"),"Content-Type":"application/octet-stream"},body:n}).then(function(s){s.json().then(function(u){a(s,u)}).catch(function(u){r({error:u})})}).catch(function(s){r({error:s,httpStatusCode:0})})},da.prototype._flushEvents=Lf(function(e,t,n){var r=e.length;if(r>0){for(var a=this.replayId,s=1/0,u=-1/0,d=!1,h=0;h<r;h++)s=Math.min(s,e[h].timestamp),u=Math.max(u,e[h].timestamp),e[h].type===En.FullSnapshot&&(d=!0);if(this.seqNo===0){if(!d){n({error:"First batch does not contain a full snapshot. Aborting recording."}),this.stopRecording(!0);return}this.replayStartTime=s}else this.replayStartTime||(this.reportError("Replay start time not set but seqNo is not 0. Using current batch start time as a fallback."),this.replayStartTime=s);var m=u-this.replayStartTime,y={$current_url:this.batchStartUrl,$lib_version:hl.LIB_VERSION,batch_start_time:s/1e3,distinct_id:String(this._mixpanel.get_distinct_id()),mp_lib:"web",replay_id:a,replay_length_ms:m,replay_start_time:this.replayStartTime/1e3,replay_start_url:this.replayStartUrl,seq:this.seqNo},v=JSON.stringify(e),S=this._mixpanel.get_property("$device_id");S&&(y.$device_id=S);var x=this._mixpanel.get_property("$user_id");if(x&&(y.$user_id=x),hN){var E=new Blob([v],{type:"application/json"}).stream(),R=E.pipeThrough(new hN("gzip"));new Response(R).blob().then((function(T){y.format="gzip",this._sendRequest(a,y,T,n)}).bind(this))}else y.format="body",this._sendRequest(a,y,v,n)}}),da.prototype.reportError=function(e,t){Yg.error.apply(Yg.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(n){Yg.error(n)}};var Zg=function(e){this.idb=new eu(KR),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};Zg.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},Zg.prototype.setActiveRecording=function(e){var t=e.tabId;return t?this.idb.init().then((function(){return this.idb.setItem(t,e)}).bind(this)).catch(this.handleError.bind(this)):(console.warn("No tab ID is set, cannot persist recording metadata."),Pn.resolve())},Zg.prototype.getActiveRecording=function(){return this.idb.init().then((function(){return this.idb.getItem(this.mixpanelInstance.get_tab_id())}).bind(this)).then((function(e){return eO(e)?null:e}).bind(this)).catch(this.handleError.bind(this))},Zg.prototype.clearActiveRecording=function(){return this.getActiveRecording().then((function(e){if(e)return e.maxExpires=0,this.setActiveRecording(e)}).bind(this)).catch(this.handleError.bind(this))},Zg.prototype.flushInactiveRecordings=function(){return this.idb.init().then((function(){return this.idb.getAll()}).bind(this)).then((function(e){var t=e.filter(function(n){return eO(n)}).map((function(n){var r=da.deserialize(n,{mixpanelInstance:this.mixpanelInstance,sharedLockStorage:this.sharedLockStorage});return r.unloadPersistedData().then((function(){return this.idb.removeItem(n.tabId)}).bind(this)).catch(this.handleError.bind(this))}).bind(this));return Pn.all(t)}).bind(this)).catch(this.handleError.bind(this))};var F0=jg("recorder"),rc=function(e,t,n){this.mixpanelInstance=e,this.rrwebRecord=t||kf,this.sharedLockStorage=n,this.recordingRegistry=new Zg({mixpanelInstance:this.mixpanelInstance,errorReporter:F0.error,sharedLockStorage:n}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null};rc.prototype.startRecording=function(e){if(e=e||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){F0.log("Recording already in progress, skipping startRecording.");return}var t=(function(){F0.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),n=(function(){F0.log("Max recording length reached, stopping recording."),this.resetRecording()}).bind(this),r=(function(){this.recordingRegistry.setActiveRecording(this.activeRecording.serialize()),this.__flushPromise=this.activeRecording.batcher._flushPromise}).bind(this),a={mixpanelInstance:this.mixpanelInstance,onBatchSent:r,onIdleTimeout:t,onMaxLengthReached:n,replayId:N.UUID(),rrwebRecord:this.rrwebRecord,sharedLockStorage:this.sharedLockStorage};return e.activeSerializedRecording?this.activeRecording=da.deserialize(e.activeSerializedRecording,a):this.activeRecording=new da(a),this.activeRecording.startRecording(e.shouldStopBatcher),this.recordingRegistry.setActiveRecording(this.activeRecording.serialize())},rc.prototype.stopRecording=function(){var e=this._stopCurrentRecording(!1);return this.recordingRegistry.clearActiveRecording(),this.activeRecording=null,e},rc.prototype.pauseRecording=function(){return this._stopCurrentRecording(!1)},rc.prototype._stopCurrentRecording=function(e){return this.activeRecording?this.activeRecording.stopRecording(e):Pn.resolve()},rc.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),Pn.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(t){return t?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):(F0.log("No resumable recording found."),null)}).bind(this))},rc.prototype.resetRecording=function(){this.stopRecording(),this.startRecording({shouldStopBatcher:!0})},rc.prototype.getActiveReplayId=function(){return this.activeRecording&&!this.activeRecording.isRrwebStopped()?this.activeRecording.replayId:null},Object.defineProperty(rc.prototype,"replayId",{get:function(){return this.getActiveReplayId()}}),ct.__mp_recorder=rc;var qw="change",j0="click",pN="hashchange",Qg="mp_locationchange",gN="popstate",mN="scrollend",tO="submit",BW=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],vN=["mp-include"],nO=["mp-no-track"],yN=nO.concat(["mp-sensitive"]),UW=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],ao=jg("autocapture");function rO(e){for(var t={},n=bN(e).split(" "),r=0;r<n.length;r++){var a=n[r];a&&(t[a]=!0)}return t}function bN(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function zW(e){if(e.previousElementSibling)return e.previousElementSibling;do e=e.previousSibling;while(e&&!wN(e));return e}function _N(e,t,n,r,a,s){var u={$classes:bN(e).split(" "),$tag_name:e.tagName.toLowerCase()},d=e.id;d&&(u.$id=d),oO(e,t,a,s)&&N.each(UW.concat(r),function(v){if(e.hasAttribute(v)&&!n[v]){var S=e.getAttribute(v);Fw(S)&&(u["$attr-"+v]=S)}});for(var h=1,m=1,y=e;y=zW(y);)h++,y.tagName===e.tagName&&m++;return u.$nth_child=h,u.$nth_of_type=m,u}function HW(e,t){var n=t.allowElementCallback,r=t.allowSelectors||[],a=t.blockAttrs||[],s=t.blockElementCallback,u=t.blockSelectors||[],d=t.captureTextContent||!1,h=t.captureExtraAttrs||[],m={};N.each(a,function($){m[$]=!0});var y=null,v=typeof e.target>"u"?e.srcElement:e.target;if(xN(v)&&(v=v.parentNode),FW(v,e)&&iO(v,e,n,r)&&!aO(v,e,s,u)){for(var S=[v],x=v;x.parentNode&&!nu(x,"body");)S.push(x.parentNode),x=x.parentNode;var E=[],R,T=!1;if(N.each(S,function($){var U=oO($,e,n,r);!m.href&&$.tagName.toLowerCase()==="a"&&(R=$.getAttribute("href"),R=U&&Fw(R)&&R),aO($,e,s,u)&&(T=!0),E.push(_N($,e,m,h,n,r))},this),!T){var A=jn.documentElement;if(y={$event_type:e.type,$host:ct.location.host,$pathname:ct.location.pathname,$elements:E,$el_attr__href:R,$viewportHeight:Math.max(A.clientHeight,ct.innerHeight||0),$viewportWidth:Math.max(A.clientWidth,ct.innerWidth||0)},N.each(h,function($){if(!m[$]&&v.hasAttribute($)){var U=v.getAttribute($);Fw(U)&&(y["$el_attr__"+$]=U)}}),d&&(M=SN(v,e,n,r),M&&M.length&&(y.$el_text=M)),e.type===j0&&(N.each(BW,function($){$ in e&&(y["$"+$]=e[$])}),v=PW(e)),d){var M=SN(v,e,n,r);M&&M.length&&(y.$el_text=M)}if(v){if(!iO(v,e,n,r)||aO(v,e,s,u))return null;var D=_N(v,e,m,h,n,r);y.$target=D,y.$el_classes=D.$classes,N.extend(y,N.strip_empty_properties({$el_id:D.$id,$el_tag_name:D.$tag_name}))}}}return y}function SN(e,t,n,r){var a="";return oO(e,t,n,r)&&e.childNodes&&e.childNodes.length&&N.each(e.childNodes,function(s){xN(s)&&s.textContent&&(a+=N.trim(s.textContent).split(/(\s+)/).filter(Fw).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),N.trim(a)}function PW(e){for(var t=e.target,n=e.composedPath(),r=0;r<n.length;r++){var a=n[r];if(nu(a,"a")||nu(a,"button")||nu(a,"input")||nu(a,"select")||a.getAttribute&&a.getAttribute("role")==="button"){t=a;break}if(a===t)break}return t}function iO(e,t,n,r){if(n)try{if(!n(e,t))return!1}catch(u){return ao.critical("Error while checking element in allowElementCallback",u),!1}if(!r.length)return!0;for(var a=0;a<r.length;a++){var s=r[a];try{if(e.matches(s))return!0}catch(u){ao.critical("Error while checking selector: "+s,u)}}return!1}function aO(e,t,n,r){var a;if(n)try{if(n(e,t))return!0}catch(d){return ao.critical("Error while checking element in blockElementCallback",d),!0}if(r&&r.length)for(a=0;a<r.length;a++){var s=r[a];try{if(e.matches(s))return!0}catch(d){ao.critical("Error while checking selector: "+s,d)}}var u=rO(e);for(a=0;a<nO.length;a++)if(u[nO[a]])return!0;return!1}function wN(e){return e&&e.nodeType===1}function nu(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function xN(e){return e&&e.nodeType===3}function qW(){try{var e=jn.createElement("div");return!!e.matches}catch{return!1}}function FW(e,t){if(!e||nu(e,"html")||!wN(e))return!1;var n=e.tagName.toLowerCase();switch(n){case"form":return t.type===tO;case"input":return["button","submit"].indexOf(e.getAttribute("type"))===-1?t.type===qw:t.type===j0;case"select":case"textarea":return t.type===qw;default:return t.type===j0}}function oO(e,t,n,r){var a;if(!iO(e,t,n,r))return!1;for(var s=e;s.parentNode&&!nu(s,"body");s=s.parentNode){var u=rO(s);for(a=0;a<yN.length;a++)if(u[yN[a]])return!1}var d=rO(e);for(a=0;a<vN.length;a++)if(d[vN[a]])return!0;if(nu(e,"input")||nu(e,"select")||nu(e,"textarea")||e.getAttribute("contenteditable")==="true")return!1;var h=e.type||"";if(typeof h=="string")switch(h.toLowerCase()){case"hidden":return!1;case"password":return!1}var m=e.name||e.id||"";if(typeof m=="string"){var y=/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;if(y.test(m.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Fw(e){if(e===null||N.isUndefined(e))return!1;if(typeof e=="string"){e=N.trim(e);var t=/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;if(t.test((e||"").replace(/[- ]/g,"")))return!1;var n=/(^\d{3}-?\d{2}-?\d{4}$)/;if(n.test(e))return!1}return!0}var CN="autocapture",jW="track_pageview",EN="full-url",GW="url-with-path-and-query-string",VW="url-with-path",YW="allow_element_callback",AN="allow_selectors",TN="allow_url_regexes",kN="block_attrs",RN="block_element_callback",ON="block_selectors",MN="block_url_regexes",DN="capture_extra_attrs",IN="capture_text_content",LN="scroll_capture_all",NN="scroll_depth_percent_checkpoints",sO="click",lO="input",$N="pageview",uO="scroll",cO="submit",Gi={};Gi[AN]=[],Gi[TN]=[],Gi[kN]=[],Gi[RN]=null,Gi[ON]=[],Gi[MN]=[],Gi[DN]=[],Gi[IN]=!1,Gi[LN]=!1,Gi[NN]=[25,50,75,100],Gi[sO]=!0,Gi[lO]=!0,Gi[$N]=EN,Gi[uO]=!0,Gi[cO]=!0;var jw={$mp_autocapture:!0},ZW="$mp_click",QW="$mp_input_change",KW="$mp_scroll",XW="$mp_submit",Lo=function(e){this.mp=e};Lo.prototype.init=function(){if(!qW()){ao.critical("Autocapture unavailable: missing required DOM APIs");return}this.initPageviewTracking(),this.initClickTracking(),this.initInputTracking(),this.initScrollTracking(),this.initSubmitTracking()},Lo.prototype.getFullConfig=function(){var e=this.mp.get_config(CN);return e?N.isObject(e)?N.extend({},Gi,e):Gi:{}},Lo.prototype.getConfig=function(e){return this.getFullConfig()[e]},Lo.prototype.currentUrlBlocked=function(){var e,t=N.info.currentUrl(),n=this.getConfig(TN)||[];if(n.length){var r=!1;for(e=0;e<n.length;e++){var a=n[e];try{if(t.match(a)){r=!0;break}}catch(u){return ao.critical("Error while checking block URL regex: "+a,u),!0}}if(!r)return!0}var s=this.getConfig(MN)||[];if(!s||!s.length)return!1;for(e=0;e<s.length;e++)try{if(t.match(s[e]))return!0}catch(u){return ao.critical("Error while checking block URL regex: "+s[e],u),!0}return!1},Lo.prototype.pageviewTrackingConfig=function(){return this.mp.get_config(CN)?this.getConfig($N):this.mp.get_config(jW)},Lo.prototype.trackDomEvent=function(e,t){if(!this.currentUrlBlocked()){var n=HW(e,{allowElementCallback:this.getConfig(YW),allowSelectors:this.getConfig(AN),blockAttrs:this.getConfig(kN),blockElementCallback:this.getConfig(RN),blockSelectors:this.getConfig(ON),captureExtraAttrs:this.getConfig(DN),captureTextContent:this.getConfig(IN)});n&&(N.extend(n,jw),this.mp.track(t,n))}},Lo.prototype.initClickTracking=function(){ct.removeEventListener(j0,this.listenerClick),this.getConfig(sO)&&(ao.log("Initializing click tracking"),this.listenerClick=ct.addEventListener(j0,(function(e){this.getConfig(sO)&&this.trackDomEvent(e,ZW)}).bind(this)))},Lo.prototype.initInputTracking=function(){ct.removeEventListener(qw,this.listenerChange),this.getConfig(lO)&&(ao.log("Initializing input tracking"),this.listenerChange=ct.addEventListener(qw,(function(e){this.getConfig(lO)&&this.trackDomEvent(e,QW)}).bind(this)))},Lo.prototype.initPageviewTracking=function(){if(ct.removeEventListener(gN,this.listenerPopstate),ct.removeEventListener(pN,this.listenerHashchange),ct.removeEventListener(Qg,this.listenerLocationchange),!!this.pageviewTrackingConfig()){ao.log("Initializing pageview tracking");var e="",t=!1;this.currentUrlBlocked()||(t=this.mp.track_pageview(jw)),t&&(e=N.info.currentUrl()),this.listenerPopstate=ct.addEventListener(gN,function(){ct.dispatchEvent(new Event(Qg))}),this.listenerHashchange=ct.addEventListener(pN,function(){ct.dispatchEvent(new Event(Qg))});var n=ct.history.pushState;typeof n=="function"&&(ct.history.pushState=function(a,s,u){n.call(ct.history,a,s,u),ct.dispatchEvent(new Event(Qg))});var r=ct.history.replaceState;typeof r=="function"&&(ct.history.replaceState=function(a,s,u){r.call(ct.history,a,s,u),ct.dispatchEvent(new Event(Qg))}),this.listenerLocationchange=ct.addEventListener(Qg,VR((function(){if(!this.currentUrlBlocked()){var a=N.info.currentUrl(),s=!1,u=a.split("#")[0].split("?")[0]!==e.split("#")[0].split("?")[0],d=this.pageviewTrackingConfig();if(d===EN?s=a!==e:d===GW?s=a.split("#")[0]!==e.split("#")[0]:d===VW&&(s=u),s){var h=this.mp.track_pageview(jw);h&&(e=a),u&&(this.lastScrollCheckpoint=0,ao.log("Path change: re-initializing scroll depth checkpoints"))}}}).bind(this)))}},Lo.prototype.initScrollTracking=function(){ct.removeEventListener(mN,this.listenerScroll),this.getConfig(uO)&&(ao.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=ct.addEventListener(mN,VR((function(){if(this.getConfig(uO)&&!this.currentUrlBlocked()){var e=this.getConfig(LN),t=(this.getConfig(NN)||[]).slice().sort(function(h,m){return h-m}),n=ct.scrollY,r=N.extend({$scroll_top:n},jw);try{var a=jn.body.scrollHeight,s=Math.round(n/(a-ct.innerHeight)*100);if(r.$scroll_height=a,r.$scroll_percentage=s,s>this.lastScrollCheckpoint)for(var u=0;u<t.length;u++){var d=t[u];s>=d&&this.lastScrollCheckpoint<d&&(r.$scroll_checkpoint=d,this.lastScrollCheckpoint=d,e=!0)}}catch(h){ao.critical("Error while calculating scroll percentage",h)}e&&this.mp.track(KW,r)}}).bind(this))))},Lo.prototype.initSubmitTracking=function(){ct.removeEventListener(tO,this.listenerSubmit),this.getConfig(cO)&&(ao.log("Initializing submit tracking"),this.listenerSubmit=ct.addEventListener(tO,(function(e){this.getConfig(cO)&&this.trackDomEvent(e,XW)}).bind(this)))},hW(Lo);var ic=function(){};ic.prototype.create_properties=function(){},ic.prototype.event_handler=function(){},ic.prototype.after_track_handler=function(){},ic.prototype.init=function(e){return this.mp=e,this},ic.prototype.track=function(e,t,n,r){var a=this,s=N.dom_query(e);if(s.length===0){zn.error("The DOM query ("+e+") returned 0 elements");return}return N.each(s,function(u){N.register_event(u,this.override_event,function(d){var h={},m=a.create_properties(n,this),y=a.mp.get_config("track_links_timeout");a.event_handler(d,this,h),window.setTimeout(a.track_callback(r,m,h,!0),y),a.mp.track(t,m,a.track_callback(r,m,h))})},this),!0},ic.prototype.track_callback=function(e,t,n,r){r=r||!1;var a=this;return function(){n.callback_fired||(n.callback_fired=!0,!(e&&e(r,t)===!1)&&a.after_track_handler(t,n,r))}},ic.prototype.create_properties=function(e,t){var n;return typeof e=="function"?n=e(t):n=N.extend({},e),n};var Kg=function(){this.override_event="click"};N.inherit(Kg,ic),Kg.prototype.create_properties=function(e,t){var n=Kg.superclass.create_properties.apply(this,arguments);return t.href&&(n.url=t.href),n},Kg.prototype.event_handler=function(e,t,n){n.new_tab=e.which===2||e.metaKey||e.ctrlKey||t.target==="_blank",n.href=t.href,n.new_tab||e.preventDefault()},Kg.prototype.after_track_handler=function(e,t){t.new_tab||setTimeout(function(){window.location=t.href},0)};var Gw=function(){this.override_event="submit"};N.inherit(Gw,ic),Gw.prototype.event_handler=function(e,t,n){n.element=t,e.preventDefault()},Gw.prototype.after_track_handler=function(e,t){setTimeout(function(){t.element.submit()},0)};var $f="$set",Xg="$set_once",pl="$unset",Sh="$add",ru="$append",wh="$union",ac="$remove",WW="$delete",BN={set_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[$f]=r,n},unset_action:function(e){var t={},n=[];return N.isArray(e)||(e=[e]),N.each(e,function(r){this._is_reserved_property(r)||n.push(r)},this),t[pl]=n,t},set_once_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[Xg]=r,n},union_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=N.isArray(a)?a:[a])},this):r[e]=N.isArray(t)?t:[t],n[wh]=r,n},append_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[ru]=r,n},remove_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[ac]=r,n},delete_action:function(){var e={};return e[WW]="",e}},vr=function(){};N.extend(vr.prototype,BN),vr.prototype._init=function(e,t,n){this._mixpanel=e,this._group_key=t,this._group_id=n},vr.prototype.set=Vg(function(e,t,n){var r=this.set_action(e,t);return N.isObject(e)&&(n=t),this._send_request(r,n)}),vr.prototype.set_once=Vg(function(e,t,n){var r=this.set_once_action(e,t);return N.isObject(e)&&(n=t),this._send_request(r,n)}),vr.prototype.unset=Vg(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),vr.prototype.union=Vg(function(e,t,n){N.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),vr.prototype.delete=Vg(function(e){var t=this.delete_action();return this._send_request(t,e)}),vr.prototype.remove=Vg(function(e,t,n){var r=this.remove_action(e,t);return this._send_request(r,n)}),vr.prototype._send_request=function(e,t){e.$group_key=this._group_key,e.$group_id=this._group_id,e.$token=this._get_config("token");var n=N.encodeDates(e);return this._mixpanel._track_or_batch({type:"groups",data:n,endpoint:this._get_config("api_host")+"/"+this._get_config("api_routes").groups,batcher:this._mixpanel.request_batchers.groups},t)},vr.prototype._is_reserved_property=function(e){return e==="$group_key"||e==="$group_id"},vr.prototype._get_config=function(e){return this._mixpanel.get_config(e)},vr.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},vr.prototype.remove=vr.prototype.remove,vr.prototype.set=vr.prototype.set,vr.prototype.set_once=vr.prototype.set_once,vr.prototype.union=vr.prototype.union,vr.prototype.unset=vr.prototype.unset,vr.prototype.toString=vr.prototype.toString;var Xt=function(){};N.extend(Xt.prototype,BN),Xt.prototype._init=function(e){this._mixpanel=e},Xt.prototype.set=Nf(function(e,t,n){var r=this.set_action(e,t);return N.isObject(e)&&(n=t),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),r[$f]=N.extend({},N.info.people_properties(),r[$f]),this._send_request(r,n)}),Xt.prototype.set_once=Nf(function(e,t,n){var r=this.set_once_action(e,t);return N.isObject(e)&&(n=t),this._send_request(r,n)}),Xt.prototype.unset=Nf(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),Xt.prototype.increment=Nf(function(e,t,n){var r={},a={};return N.isObject(e)?(N.each(e,function(s,u){if(!this._is_reserved_property(u))if(isNaN(parseFloat(s))){zn.error("Invalid increment value passed to mixpanel.people.increment - must be a number");return}else a[u]=s},this),n=t):(N.isUndefined(t)&&(t=1),a[e]=t),r[Sh]=a,this._send_request(r,n)}),Xt.prototype.append=Nf(function(e,t,n){N.isObject(e)&&(n=t);var r=this.append_action(e,t);return this._send_request(r,n)}),Xt.prototype.remove=Nf(function(e,t,n){N.isObject(e)&&(n=t);var r=this.remove_action(e,t);return this._send_request(r,n)}),Xt.prototype.union=Nf(function(e,t,n){N.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),Xt.prototype.track_charge=Nf(function(e,t,n){if(!N.isNumber(e)&&(e=parseFloat(e),isNaN(e))){zn.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",N.extend({$amount:e},t),n)}),Xt.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},Xt.prototype.delete_user=function(){if(!this._identify_called()){zn.error("mixpanel.people.delete_user() requires you to call identify() first");return}var e={$delete:this._mixpanel.get_distinct_id()};return this._send_request(e)},Xt.prototype.toString=function(){return this._mixpanel.toString()+".people"},Xt.prototype._send_request=function(e,t){e.$token=this._get_config("token"),e.$distinct_id=this._mixpanel.get_distinct_id();var n=this._mixpanel.get_property("$device_id"),r=this._mixpanel.get_property("$user_id"),a=this._mixpanel.get_property("$had_persisted_distinct_id");n&&(e.$device_id=n),r&&(e.$user_id=r),a&&(e.$had_persisted_distinct_id=a);var s=N.encodeDates(e);return this._identify_called()?this._mixpanel._track_or_batch({type:"people",data:s,endpoint:this._get_config("api_host")+"/"+this._get_config("api_routes").engage,batcher:this._mixpanel.request_batchers.people},t):(this._enqueue(e),N.isUndefined(t)||(this._get_config("verbose")?t({status:-1,error:null}):t(-1)),N.truncate(s,255))},Xt.prototype._get_config=function(e){return this._mixpanel.get_config(e)},Xt.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},Xt.prototype._enqueue=function(e){$f in e?this._mixpanel.persistence._add_to_people_queue($f,e):Xg in e?this._mixpanel.persistence._add_to_people_queue(Xg,e):pl in e?this._mixpanel.persistence._add_to_people_queue(pl,e):Sh in e?this._mixpanel.persistence._add_to_people_queue(Sh,e):ru in e?this._mixpanel.persistence._add_to_people_queue(ru,e):ac in e?this._mixpanel.persistence._add_to_people_queue(ac,e):wh in e?this._mixpanel.persistence._add_to_people_queue(wh,e):zn.error("Invalid call to _enqueue():",e)},Xt.prototype._flush_one_queue=function(e,t,n,r){var a=this,s=N.extend({},this._mixpanel.persistence.load_queue(e)),u=s;!N.isUndefined(s)&&N.isObject(s)&&!N.isEmptyObject(s)&&(a._mixpanel.persistence._pop_from_people_queue(e,s),a._mixpanel.persistence.save(),r&&(u=r(s)),t.call(a,u,function(d,h){d===0&&a._mixpanel.persistence._add_to_people_queue(e,s),N.isUndefined(n)||n(d,h)}))},Xt.prototype._flush=function(e,t,n,r,a,s,u){var d=this;this._flush_one_queue($f,this.set,e),this._flush_one_queue(Xg,this.set_once,r),this._flush_one_queue(pl,this.unset,s,function(T){return N.keys(T)}),this._flush_one_queue(Sh,this.increment,t),this._flush_one_queue(wh,this.union,a);var h=this._mixpanel.persistence.load_queue(ru);if(!N.isUndefined(h)&&N.isArray(h)&&h.length)for(var m,y=function(T,A){T===0&&d._mixpanel.persistence._add_to_people_queue(ru,m),N.isUndefined(n)||n(T,A)},v=h.length-1;v>=0;v--)h=this._mixpanel.persistence.load_queue(ru),m=h.pop(),d._mixpanel.persistence.save(),N.isEmptyObject(m)||d.append(m,y);var S=this._mixpanel.persistence.load_queue(ac);if(!N.isUndefined(S)&&N.isArray(S)&&S.length)for(var x,E=function(T,A){T===0&&d._mixpanel.persistence._add_to_people_queue(ac,x),N.isUndefined(u)||u(T,A)},R=S.length-1;R>=0;R--)S=this._mixpanel.persistence.load_queue(ac),x=S.pop(),d._mixpanel.persistence.save(),N.isEmptyObject(x)||d.remove(x,E)},Xt.prototype._is_reserved_property=function(e){return e==="$distinct_id"||e==="$token"||e==="$device_id"||e==="$user_id"||e==="$had_persisted_distinct_id"},Xt.prototype.set=Xt.prototype.set,Xt.prototype.set_once=Xt.prototype.set_once,Xt.prototype.unset=Xt.prototype.unset,Xt.prototype.increment=Xt.prototype.increment,Xt.prototype.append=Xt.prototype.append,Xt.prototype.remove=Xt.prototype.remove,Xt.prototype.union=Xt.prototype.union,Xt.prototype.track_charge=Xt.prototype.track_charge,Xt.prototype.clear_charges=Xt.prototype.clear_charges,Xt.prototype.delete_user=Xt.prototype.delete_user,Xt.prototype.toString=Xt.prototype.toString;var fO="__mps",dO="__mpso",hO="__mpus",pO="__mpa",gO="__mpap",mO="__mpr",vO="__mpu",UN="$people_distinct_id",Vw="__alias",G0="__timers",JW=[fO,dO,hO,pO,gO,mO,vO,UN,Vw,G0],mn=function(e){this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="mp_"+e.persistence_name:this.name="mp_"+e.token+"_mixpanel";var t=e.persistence;t!=="cookie"&&t!=="localStorage"&&(zn.critical("Unknown persistence type "+t+"; falling back to cookie"),t=e.persistence="cookie"),t==="localStorage"&&N.localStorage.is_supported()?this.storage=N.localStorage:this.storage=N.cookie,this.load(),this.update_config(e),this.upgrade(),this.save()};mn.prototype.properties=function(){var e={};return this.load(),N.each(this.props,function(t,n){N.include(JW,n)||(e[n]=t)}),e},mn.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=N.extend({},e))}},mn.prototype.upgrade=function(){var e,t;this.storage===N.localStorage?(e=N.cookie.parse(this.name),N.cookie.remove(this.name),N.cookie.remove(this.name,!0),e&&this.register_once(e)):this.storage===N.cookie&&(t=N.localStorage.parse(this.name),N.localStorage.remove(this.name),t&&this.register_once(t))},mn.prototype.save=function(){this.disabled||this.storage.set(this.name,Gg(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},mn.prototype.load_prop=function(e){return this.load(),this.props[e]},mn.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},mn.prototype.clear=function(){this.remove(),this.props={}},mn.prototype.register_once=function(e,t,n){return N.isObject(e)?(typeof t>"u"&&(t="None"),this.expire_days=typeof n>"u"?this.default_expiry:n,this.load(),N.each(e,function(r,a){(!this.props.hasOwnProperty(a)||this.props[a]===t)&&(this.props[a]=r)},this),this.save(),!0):!1},mn.prototype.register=function(e,t){return N.isObject(e)?(this.expire_days=typeof t>"u"?this.default_expiry:t,this.load(),N.extend(this.props,e),this.save(),!0):!1},mn.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},mn.prototype.update_search_keyword=function(e){this.register(N.info.searchInfo(e))},mn.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:N.info.referringDomain(e)||"$direct"},"")},mn.prototype.get_referrer_info=function(){return N.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},mn.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cookie_domain(e.cookie_domain),this.set_cross_site(e.cross_site_cookie),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},mn.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},mn.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},mn.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},mn.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},mn.prototype.get_cross_subdomain=function(){return this.cross_subdomain},mn.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},mn.prototype._add_to_people_queue=function(e,t){var n=this._get_queue_key(e),r=t[e],a=this._get_or_create_queue($f),s=this._get_or_create_queue(Xg),u=this._get_or_create_queue(pl),d=this._get_or_create_queue(Sh),h=this._get_or_create_queue(wh),m=this._get_or_create_queue(ac,[]),y=this._get_or_create_queue(ru,[]);n===fO?(N.extend(a,r),this._pop_from_people_queue(Sh,r),this._pop_from_people_queue(wh,r),this._pop_from_people_queue(pl,r)):n===dO?(N.each(r,function(v,S){S in s||(s[S]=v)}),this._pop_from_people_queue(pl,r)):n===hO?N.each(r,function(v){N.each([a,s,d,h],function(S){v in S&&delete S[v]}),N.each(y,function(S){v in S&&delete S[v]}),u[v]=!0}):n===pO?(N.each(r,function(v,S){S in a?a[S]+=v:(S in d||(d[S]=0),d[S]+=v)},this),this._pop_from_people_queue(pl,r)):n===vO?(N.each(r,function(v,S){N.isArray(v)&&(S in h||(h[S]=[]),N.each(v,function(x){N.include(h[S],x)||h[S].push(x)}))}),this._pop_from_people_queue(pl,r)):n===mO?(m.push(r),this._pop_from_people_queue(ru,r)):n===gO&&(y.push(r),this._pop_from_people_queue(pl,r)),zn.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),zn.log(t),this.save()},mn.prototype._pop_from_people_queue=function(e,t){var n=this.props[this._get_queue_key(e)];N.isUndefined(n)||N.each(t,function(r,a){e===ru||e===ac?N.each(n,function(s){s[a]===r&&delete s[a]}):delete n[a]},this)},mn.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},mn.prototype._get_queue_key=function(e){if(e===$f)return fO;if(e===Xg)return dO;if(e===pl)return hO;if(e===Sh)return pO;if(e===ru)return gO;if(e===ac)return mO;if(e===wh)return vO;zn.error("Invalid queue:",e)},mn.prototype._get_or_create_queue=function(e,t){var n=this._get_queue_key(e);return t=N.isUndefined(t)?{}:t,this.props[n]||(this.props[n]=t)},mn.prototype.set_event_timer=function(e,t){var n=this.load_prop(G0)||{};n[e]=t,this.props[G0]=n,this.save()},mn.prototype.remove_event_timer=function(e){var t=this.load_prop(G0)||{},n=t[e];return N.isUndefined(n)||(delete this.props[G0][e],this.save()),n};var yO,zN=function(e,t){throw new Error(e+" not available in this build.")},ha,HN=0,eJ=1,tJ=function(e){return e},ls="mixpanel",PN="base64",nJ="json",bO="$device:",Wg=ct.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,qN=!Wg&&nc.indexOf("MSIE")===-1&&nc.indexOf("Mozilla")===-1,Yw=null;Df.sendBeacon&&(Yw=function(){return Df.sendBeacon.apply(Df,arguments)});var FN={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},jN={api_host:"https://api-js.mixpanel.com",api_routes:FN,api_method:"POST",api_transport:"XHR",api_payload_format:PN,app_host:"https://mixpanel.com",autocapture:!1,cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:If,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:If,mp_loader:null,track_marketing:!0,track_pageview:!1,skip_first_touch_marketing:!1,store_google:!0,stop_utm_persistence:!1,save_referrer:!0,test:!1,verbose:!1,img:!1,debug:!1,track_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_tracking_by_default:!1,opt_out_persistence_by_default:!1,opt_out_tracking_persistence_type:"localStorage",opt_out_tracking_cookie_prefix:null,property_blacklist:[],xhr_headers:{},ignore_dnt:!1,batch_requests:!0,batch_size:50,batch_flush_interval_ms:5e3,batch_request_timeout_ms:9e4,batch_autostart:!0,hooks:{},record_block_class:new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),record_block_selector:"img, video",record_canvas:!1,record_collect_fonts:!1,record_idle_timeout_ms:30*60*1e3,record_mask_text_class:new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),record_mask_text_selector:"*",record_max_ms:U0,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},GN=!1,we=function(){},_O=function(e,t,n){var r,a=n===ls?ha:ha[n];if(a&&yO===HN)r=a;else{if(a&&!N.isArray(a)){zn.error("You have already initialized "+n);return}r=new we}if(r._cached_groups={},r._init(e,t,n),r.people=new Xt,r.people._init(r),!r.get_config("skip_first_touch_marketing")){var s=N.info.campaignParams(null),u={},d=!1;N.each(s,function(h,m){u["initial_"+m]=h,h&&(d=!0)}),d&&r.people.set_once(u)}return hl.DEBUG=hl.DEBUG||r.get_config("debug"),!N.isUndefined(a)&&N.isArray(a)&&(r._execute_array.call(r.people,a.people),r._execute_array(a)),r};we.prototype.init=function(e,t,n){if(N.isUndefined(n)){this.report_error("You must name your new library: init(token, config, name)");return}if(n===ls){this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");return}var r=_O(e,t,n);return ha[n]=r,r._loaded(),r},we.prototype._init=function(e,t,n){t=t||{},this.__loaded=!0,this.config={};var r={};if(!("api_payload_format"in t)){var a=t.api_host||jN.api_host;a.match(/\.mixpanel\.com/)&&(r.api_payload_format=nJ)}if(this.set_config(N.extend({},jN,r,t,{name:n,token:e,callback_fn:(n===ls?n:ls+"."+n)+"._jsc"})),this._jsc=If,this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.request_batchers={},this._batch_requests=this.get_config("batch_requests"),this._batch_requests){if(!N.localStorage.is_supported(!0)||!Wg)this._batch_requests=!1,zn.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),N.each(this.get_batcher_configs(),function(d){zn.log("Clearing batch queue "+d.queue_key),N.localStorage.remove(d.queue_key)});else if(this.init_batchers(),Yw&&ct.addEventListener){var s=N.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);ct.addEventListener("pagehide",function(d){d.persisted&&s()}),ct.addEventListener("visibilitychange",function(){jn.visibilityState==="hidden"&&s()})}}this.persistence=this.cookie=new mn(this.config),this.unpersisted_superprops={},this._gdpr_init();var u=N.UUID();this.get_distinct_id()||this.register_once({distinct_id:bO+u,$device_id:u},""),this.autocapture=new Lo(this),this.autocapture.init(),this._init_tab_id(),this._check_and_start_session_recording()},we.prototype._init_tab_id=function(){if(N.sessionStorage.is_supported())try{var e=this.get_config("name")+"_"+this.get_config("token"),t="mp_tab_id_"+e,n="mp_gen_new_tab_id_"+e;(N.sessionStorage.get(n)||!N.sessionStorage.get(t))&&N.sessionStorage.set(t,"$tab-"+N.UUID()),N.sessionStorage.set(n,"1"),this.tab_id=N.sessionStorage.get(t),ct.addEventListener("beforeunload",function(){N.sessionStorage.remove(n)})}catch(r){this.report_error("Error initializing tab id",r)}else this.report_error("Session storage is not supported, cannot keep track of unique tab ID.")},we.prototype.get_tab_id=function(){return this.tab_id||null},we.prototype._should_load_recorder=function(){var e=new eu(KR),t=this.get_tab_id();return e.init().then(function(){return e.getAll()}).then(function(n){for(var r=0;r<n.length;r++)if(eO(n[r])||n[r].tabId===t)return!0;return!1}).catch(N.bind(function(n){this.report_error("Error checking recording registry",n)},this))},we.prototype._check_and_start_session_recording=Lf(function(e){if(!ct.MutationObserver){zn.critical("Browser does not support MutationObserver; skipping session recording");return}var t=N.bind(function(r){var a=N.bind(function(){this._recorder=this._recorder||new ct.__mp_recorder(this),this._recorder.resumeRecording(r)},this);N.isUndefined(ct.__mp_recorder)?zN(this.get_config("recorder_src"),a):a()},this),n=this.get_config("record_sessions_percent")>0&&Math.random()*100<=this.get_config("record_sessions_percent");e||n?t(!0):this._should_load_recorder().then(function(r){r&&t(!1)})}),we.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},we.prototype.stop_session_recording=function(){this._recorder&&this._recorder.stopRecording()},we.prototype.pause_session_recording=function(){this._recorder&&this._recorder.pauseRecording()},we.prototype.resume_session_recording=function(){this._recorder&&this._recorder.resumeRecording()},we.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},we.prototype.get_session_replay_url=function(){var e=null,t=this._get_session_replay_id();if(t){var n=N.HTTPBuildQuery({replay_id:t,distinct_id:this.get_distinct_id(),token:this.get_config("token")});e="https://mixpanel.com/projects/replay-redirect?"+n}return e},we.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},we.prototype.__get_recorder=function(){return this._recorder},we.prototype._loaded=function(){if(this.get_config("loaded")(this),this._set_default_superprops(),this.people.set_once(this.persistence.get_referrer_info()),this.get_config("store_google")&&this.get_config("stop_utm_persistence")){var e=N.info.campaignParams(null);N.each(e,(function(t,n){this.unregister(n)}).bind(this))}},we.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(jn.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(N.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info(jn.referrer)},we.prototype._dom_loaded=function(){N.each(this.__dom_loaded_queue,function(e){this._track_dom.apply(this,e)},this),this.has_opted_out_tracking()||N.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},we.prototype._track_dom=function(e,t){if(this.get_config("img"))return this.report_error("You can't use DOM tracking functions with img = true."),!1;if(!GN)return this.__dom_loaded_queue.push([e,t]),!1;var n=new e().init(this);return n.track.apply(n,t)},we.prototype._prepare_callback=function(e,t){if(N.isUndefined(e))return null;if(Wg){var n=function(u){e(u,t)};return n}else{var r=this._jsc,a=""+Math.floor(Math.random()*1e8),s=this.get_config("callback_fn")+"["+a+"]";return r[a]=function(u){delete r[a],e(u,t)},s}},we.prototype._send_request=function(e,t,n,r){var a=!0;if(qN)return this.__request_queue.push(arguments),a;var s={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},u=null;!r&&(N.isFunction(n)||typeof n=="string")&&(r=n,n=null),n=N.extend(s,n||{}),Wg||(n.method="GET");var d=n.method==="POST",h=Yw&&d&&n.transport.toLowerCase()==="sendbeacon",m=n.verbose;t.verbose&&(m=!0),this.get_config("test")&&(t.test=1),m&&(t.verbose=1),this.get_config("img")&&(t.img=1),Wg||(r?t.callback=r:(m||this.get_config("test"))&&(t.callback="(function(){})")),t.ip=this.get_config("ip")?1:0,t._=new Date().getTime().toString(),d&&(u="data="+encodeURIComponent(t.data),delete t.data),e+="?"+N.HTTPBuildQuery(t);var y=this;if("img"in t){var v=jn.createElement("img");v.src=e,jn.body.appendChild(v)}else if(h){try{a=Yw(e,u)}catch(A){y.report_error(A),a=!1}try{r&&r(a?1:0)}catch(A){y.report_error(A)}}else if(Wg)try{var S=new XMLHttpRequest;S.open(n.method,e,!0);var x=this.get_config("xhr_headers");if(d&&(x["Content-Type"]="application/x-www-form-urlencoded"),N.each(x,function(A,M){S.setRequestHeader(M,A)}),n.timeout_ms&&typeof S.timeout<"u"){S.timeout=n.timeout_ms;var E=new Date().getTime()}S.withCredentials=!0,S.onreadystatechange=function(){if(S.readyState===4)if(S.status===200){if(r)if(m){var A;try{A=N.JSONDecode(S.responseText)}catch($){if(y.report_error($),n.ignore_json_errors)A=S.responseText;else return}r(A)}else r(Number(S.responseText))}else{var M;if(S.timeout&&!S.status&&new Date().getTime()-E>=S.timeout?M="timeout":M="Bad HTTP status: "+S.status+" "+S.statusText,y.report_error(M),r)if(m){var D=S.responseHeaders||{};r({status:0,httpStatusCode:S.status,error:M,retryAfter:D["Retry-After"]})}else r(0)}},S.send(u)}catch(A){y.report_error(A),a=!1}else{var R=jn.createElement("script");R.type="text/javascript",R.async=!0,R.defer=!0,R.src=e;var T=jn.getElementsByTagName("script")[0];T.parentNode.insertBefore(R,T)}return a},we.prototype._execute_array=function(e){var t,n=[],r=[],a=[];N.each(e,function(u){u&&(t=u[0],N.isArray(t)?a.push(u):typeof u=="function"?u.call(this):N.isArray(u)&&t==="alias"?n.push(u):N.isArray(u)&&t.indexOf("track")!==-1&&typeof this[t]=="function"?a.push(u):r.push(u))},this);var s=function(u,d){N.each(u,function(h){if(N.isArray(h[0])){var m=d;N.each(h,function(y){m=m[y[0]].apply(m,y.slice(1))})}else this[h[0]].apply(this,h.slice(1))},d)};s(n,this),s(r,this),s(a,this)},we.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},we.prototype.get_batcher_configs=function(){var e="__mpq_"+this.get_config("token"),t=this.get_config("api_routes");return this._batcher_configs=this._batcher_configs||{events:{type:"events",endpoint:"/"+t.track,queue_key:e+"_ev"},people:{type:"people",endpoint:"/"+t.engage,queue_key:e+"_pp"},groups:{type:"groups",endpoint:"/"+t.groups,queue_key:e+"_gr"}},this._batcher_configs},we.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=N.bind(function(n){return new ss(n.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:N.bind(function(r,a,s){this._send_request(this.get_config("api_host")+n.endpoint,this._encode_data_for_request(r),a,this._prepare_callback(s,r))},this),beforeSendHook:N.bind(function(r){return this._run_hook("before_send_"+n.type,r)},this),stopAllBatchingFunc:N.bind(this.stop_batch_senders,this),usePersistence:!0})},this),t=this.get_batcher_configs();this.request_batchers={events:e(t.events),people:e(t.people),groups:e(t.groups)}}this.get_config("batch_autostart")&&this.start_batch_senders()},we.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,N.each(this.request_batchers,function(e){e.start()}))},we.prototype.stop_batch_senders=function(){this._batch_requests=!1,N.each(this.request_batchers,function(e){e.stop(),e.clear()})},we.prototype.push=function(e){this._execute_array([e])},we.prototype.disable=function(e){typeof e>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},we.prototype._encode_data_for_request=function(e){var t=Gg(e);return this.get_config("api_payload_format")===PN&&(t=N.base64Encode(t)),{data:t}},we.prototype._track_or_batch=function(e,t){var n=N.truncate(e.data,255),r=e.endpoint,a=e.batcher,s=e.should_send_immediately,u=e.send_request_options||{};t=t||If;var d=!0,h=N.bind(function(){return u.skip_hooks||(n=this._run_hook("before_send_"+e.type,n)),n?(zn.log("MIXPANEL REQUEST:"),zn.log(n),this._send_request(r,this._encode_data_for_request(n),u,this._prepare_callback(t,n))):null},this);return this._batch_requests&&!s?a.enqueue(n).then(function(m){m?t(1,n):h()}):d=h(),d&&n},we.prototype.track=Lf(function(e,t,n,r){!r&&typeof n=="function"&&(r=n,n=null),n=n||{};var a=n.transport;a&&(n.transport=a);var s=n.send_immediately;if(typeof r!="function"&&(r=If),N.isUndefined(e)){this.report_error("No event name provided to mixpanel.track");return}if(this._event_is_disabled(e)){r(0);return}t=N.extend({},t),t.token=this.get_config("token");var u=this.persistence.remove_event_timer(e);if(!N.isUndefined(u)){var d=new Date().getTime()-u;t.$duration=parseFloat((d/1e3).toFixed(3))}this._set_default_superprops();var h=this.get_config("track_marketing")?N.info.marketingParams():{};t=N.extend({},N.info.properties({mp_loader:this.get_config("mp_loader")}),h,this.persistence.properties(),this.unpersisted_superprops,this.get_session_recording_properties(),t);var m=this.get_config("property_blacklist");N.isArray(m)?N.each(m,function(S){delete t[S]}):this.report_error("Invalid value for property_blacklist config: "+m);var y={event:e,properties:t},v=this._track_or_batch({type:"events",data:y,endpoint:this.get_config("api_host")+"/"+this.get_config("api_routes").track,batcher:this.request_batchers.events,should_send_immediately:s,send_request_options:n},r);return v}),we.prototype.set_group=Lf(function(e,t,n){N.isArray(t)||(t=[t]);var r={};return r[e]=t,this.register(r),this.people.set(e,t,n)}),we.prototype.add_group=Lf(function(e,t,n){var r=this.get_property(e),a={};return r===void 0?(a[e]=[t],this.register(a)):r.indexOf(t)===-1&&(r.push(t),a[e]=r,this.register(a)),this.people.union(e,t,n)}),we.prototype.remove_group=Lf(function(e,t,n){var r=this.get_property(e);if(r!==void 0){var a=r.indexOf(t);a>-1&&(r.splice(a,1),this.register({group_key:r})),r.length===0&&this.unregister(e)}return this.people.remove(e,t,n)}),we.prototype.track_with_groups=Lf(function(e,t,n,r){var a=N.extend({},t||{});return N.each(n,function(s,u){s!=null&&(a[u]=s)}),this.track(e,a,r)}),we.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},we.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},we.prototype.get_group=function(e,t){var n=this._create_map_key(e,t),r=this._cached_groups[n];return(r===void 0||r._group_key!==e||r._group_id!==t)&&(r=new vr,r._init(this,e,t),this._cached_groups[n]=r),r},we.prototype.track_pageview=Lf(function(e,t){typeof e!="object"&&(e={}),t=t||{};var n=t.event_name||"$mp_web_page_view",r=N.extend(N.info.mpPageViewProperties(),N.info.campaignParams(),N.info.clickParams()),a=N.extend({},r,e);return this.track(n,a)}),we.prototype.track_links=function(){return this._track_dom.call(this,Kg,arguments)},we.prototype.track_forms=function(){return this._track_dom.call(this,Gw,arguments)},we.prototype.time_event=function(e){if(N.isUndefined(e)){this.report_error("No event name provided to mixpanel.time_event");return}this._event_is_disabled(e)||this.persistence.set_event_timer(e,new Date().getTime())};var rJ={persistent:!0},SO=function(e){var t;return N.isObject(e)?t=e:N.isUndefined(e)?t={}:t={days:e},N.extend({},rJ,t)};we.prototype.register=function(e,t){var n=SO(t);n.persistent?this.persistence.register(e,n.days):N.extend(this.unpersisted_superprops,e)},we.prototype.register_once=function(e,t,n){var r=SO(n);r.persistent?this.persistence.register_once(e,t,r.days):(typeof t>"u"&&(t="None"),N.each(e,function(a,s){(!this.unpersisted_superprops.hasOwnProperty(s)||this.unpersisted_superprops[s]===t)&&(this.unpersisted_superprops[s]=a)},this))},we.prototype.unregister=function(e,t){t=SO(t),t.persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},we.prototype._register_single=function(e,t){var n={};n[e]=t,this.register(n)},we.prototype.identify=function(e,t,n,r,a,s,u,d){var h=this.get_distinct_id();if(e&&h!==e){if(typeof e=="string"&&e.indexOf(bO)===0)return this.report_error("distinct_id cannot have $device: prefix"),-1;this.register({$user_id:e})}if(!this.get_property("$device_id")){var m=h;this.register_once({$had_persisted_distinct_id:!0,$device_id:m},"")}e!==h&&e!==this.get_property(Vw)&&(this.unregister(Vw),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,n,r,a,s,u,d),e!==h&&this.track("$identify",{distinct_id:e,$anon_distinct_id:h},{skip_hooks:!0})},we.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var e=N.UUID();this.register_once({distinct_id:bO+e,$device_id:e},"")},we.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},we.prototype.alias=function(e,t){if(e===this.get_property(UN))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var n=this;return N.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Vw,e),this.track("$create_alias",{alias:e,distinct_id:t},{skip_hooks:!0},function(){n.identify(e)})):(this.report_error("alias matches current distinct_id - skipping api call."),this.identify(e),-1)},we.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},we.prototype.set_config=function(e){if(N.isObject(e)){N.extend(this.config,e);var t=e.batch_size;t&&N.each(this.request_batchers,function(n){n.resetBatchSize()}),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),hl.DEBUG=hl.DEBUG||this.get_config("debug"),"autocapture"in e&&this.autocapture&&this.autocapture.init()}},we.prototype.get_config=function(e){return this.config[e]},we.prototype._run_hook=function(e){var t=(this.config.hooks[e]||tJ).apply(this,Mf.call(arguments,1));return typeof t>"u"&&(this.report_error(e+" hook did not return a value"),t=null),t},we.prototype.get_property=function(e){return this.persistence.load_prop([e])},we.prototype.toString=function(){var e=this.get_config("name");return e!==ls&&(e=ls+"."+e),e},we.prototype._event_is_disabled=function(e){return N.isBlockedUA(nc)||this._flags.disable_all_events||N.include(this.__disabled_events,e)},we.prototype._gdpr_init=function(){var e=this.get_config("opt_out_tracking_persistence_type")==="localStorage";e&&N.localStorage.is_supported()&&(!this.has_opted_in_tracking()&&this.has_opted_in_tracking({persistence_type:"cookie"})&&this.opt_in_tracking({enable_persistence:!1}),!this.has_opted_out_tracking()&&this.has_opted_out_tracking({persistence_type:"cookie"})&&this.opt_out_tracking({clear_persistence:!1}),this.clear_opt_in_out_tracking({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_tracking()?this._gdpr_update_persistence({clear_persistence:!0}):!this.has_opted_in_tracking()&&(this.get_config("opt_out_tracking_by_default")||N.cookie.get("mp_optout"))&&(N.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},we.prototype._gdpr_update_persistence=function(e){var t;if(e&&e.clear_persistence)t=!0;else if(e&&e.enable_persistence)t=!1;else return;!this.get_config("disable_persistence")&&this.persistence.disabled!==t&&this.persistence.set_disabled(t),t?(this.stop_batch_senders(),this.stop_session_recording()):this._batchers_were_started&&this.start_batch_senders()},we.prototype._gdpr_call_func=function(e,t){return t=N.extend({track:N.bind(this.track,this),persistence_type:this.get_config("opt_out_tracking_persistence_type"),cookie_prefix:this.get_config("opt_out_tracking_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_site_cookie:this.get_config("cross_site_cookie"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),cookie_domain:this.get_config("cookie_domain"),secure_cookie:this.get_config("secure_cookie"),ignore_dnt:this.get_config("ignore_dnt")},t),N.localStorage.is_supported()||(t.persistence_type="cookie"),e(this.get_config("token"),{track:t.track,trackEventName:t.track_event_name,trackProperties:t.track_properties,persistenceType:t.persistence_type,persistencePrefix:t.cookie_prefix,cookieDomain:t.cookie_domain,cookieExpiration:t.cookie_expiration,crossSiteCookie:t.cross_site_cookie,crossSubdomainCookie:t.cross_subdomain_cookie,secureCookie:t.secure_cookie,ignoreDnt:t.ignore_dnt})},we.prototype.opt_in_tracking=function(e){e=N.extend({enable_persistence:!0},e),this._gdpr_call_func(AW,e),this._gdpr_update_persistence(e)},we.prototype.opt_out_tracking=function(e){e=N.extend({clear_persistence:!0,delete_user:!0},e),e.delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(TW,e),this._gdpr_update_persistence(e)},we.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(kW,e)},we.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(oN,e)},we.prototype.clear_opt_in_out_tracking=function(e){e=N.extend({enable_persistence:!0},e),this._gdpr_call_func(RW,e),this._gdpr_update_persistence(e)},we.prototype.report_error=function(e,t){zn.error.apply(zn.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(n){zn.error(n)}},we.prototype.init=we.prototype.init,we.prototype.reset=we.prototype.reset,we.prototype.disable=we.prototype.disable,we.prototype.time_event=we.prototype.time_event,we.prototype.track=we.prototype.track,we.prototype.track_links=we.prototype.track_links,we.prototype.track_forms=we.prototype.track_forms,we.prototype.track_pageview=we.prototype.track_pageview,we.prototype.register=we.prototype.register,we.prototype.register_once=we.prototype.register_once,we.prototype.unregister=we.prototype.unregister,we.prototype.identify=we.prototype.identify,we.prototype.alias=we.prototype.alias,we.prototype.name_tag=we.prototype.name_tag,we.prototype.set_config=we.prototype.set_config,we.prototype.get_config=we.prototype.get_config,we.prototype.get_property=we.prototype.get_property,we.prototype.get_distinct_id=we.prototype.get_distinct_id,we.prototype.toString=we.prototype.toString,we.prototype.opt_out_tracking=we.prototype.opt_out_tracking,we.prototype.opt_in_tracking=we.prototype.opt_in_tracking,we.prototype.has_opted_out_tracking=we.prototype.has_opted_out_tracking,we.prototype.has_opted_in_tracking=we.prototype.has_opted_in_tracking,we.prototype.clear_opt_in_out_tracking=we.prototype.clear_opt_in_out_tracking,we.prototype.get_group=we.prototype.get_group,we.prototype.set_group=we.prototype.set_group,we.prototype.add_group=we.prototype.add_group,we.prototype.remove_group=we.prototype.remove_group,we.prototype.track_with_groups=we.prototype.track_with_groups,we.prototype.start_batch_senders=we.prototype.start_batch_senders,we.prototype.stop_batch_senders=we.prototype.stop_batch_senders,we.prototype.start_session_recording=we.prototype.start_session_recording,we.prototype.stop_session_recording=we.prototype.stop_session_recording,we.prototype.pause_session_recording=we.prototype.pause_session_recording,we.prototype.resume_session_recording=we.prototype.resume_session_recording,we.prototype.get_session_recording_properties=we.prototype.get_session_recording_properties,we.prototype.get_session_replay_url=we.prototype.get_session_replay_url,we.prototype.get_tab_id=we.prototype.get_tab_id,we.prototype.DEFAULT_API_ROUTES=FN,we.prototype.__get_recorder=we.prototype.__get_recorder,mn.prototype.properties=mn.prototype.properties,mn.prototype.update_search_keyword=mn.prototype.update_search_keyword,mn.prototype.update_referrer_info=mn.prototype.update_referrer_info,mn.prototype.get_cross_subdomain=mn.prototype.get_cross_subdomain,mn.prototype.clear=mn.prototype.clear;var Jg={},iJ=function(){N.each(Jg,function(e,t){t!==ls&&(ha[t]=e)}),ha._=N},aJ=function(){ha.init=function(e,t,n){if(n)return ha[n]||(ha[n]=Jg[n]=_O(e,t,n),ha[n]._loaded()),ha[n];var r=ha;Jg[ls]?r=Jg[ls]:e&&(r=_O(e,t,ls),r._loaded(),Jg[ls]=r),ha=r,yO===eJ&&(ct[ls]=ha),iJ()}},oJ=function(){function e(){e.done||(e.done=!0,GN=!0,qN=!1,N.each(Jg,function(r){r._dom_loaded()}))}function t(){try{jn.documentElement.doScroll("left")}catch{setTimeout(t,1);return}e()}if(jn.addEventListener)jn.readyState==="complete"?e():jn.addEventListener("DOMContentLoaded",e,!1);else if(jn.attachEvent){jn.attachEvent("onreadystatechange",e);var n=!1;try{n=ct.frameElement===null}catch{}jn.documentElement.doScroll&&n&&t()}N.register_event(ct,"load",e,!0)};function sJ(e){return zN=e,yO=HN,ha=new we,aJ(),ha.init(),oJ(),ha}function lJ(e,t){t()}var Bf=sJ(lJ);const iu="https://saas.brainlox.com",uJ="https://debales-web-app-server.azurewebsites.net",VN={"blossom-and-rhyme-6":"84e28f5a553bc260c8276723d0f365bc","doorbellmount-dea1de94-1728660454527":"f825468f4202c28be0d29c849a997208",artzfolio:"789feea8eb479f2db1144448f6465f7f",minature:"b22ef9c8fdbeb4a297947903891c5fd9","nonetz-3f0b8348-1736183595738":"a19d837ea53890c892a2b351e54afc11",bodytales:"703aa3f61539de0786fa19f82644fa8b",athflex:"b9f412aa0c6991abf8b8e3db70b2a506",www:"2637bf921fb09742d550941fbebe7160","GTK-Restaurant":"dbcb03738f942ec7c968f45833ee47bf","derkins-co-uk":"f109fd32c98dac150ba902bd69feeeed","imemyselfcare-com":"bbbe4af618eeab278a4015b4ddf8827f"},cJ="phc_nzwftWluHb06OLHwbfhb2xmhk88Ffc9OjjR8Jz5Q327",fJ=e=>({layout:{position:{isLeft:e.isLeft??!1,zIndex:e.zIndex??1e3},height:{option:e.heightOption??"Normal"},responsive:{fullScreenOnMobile:e.fullScreenOnMobile??!0,mobileDisplayMode:e.mobileDisplayMode??"normal"}},colors:{background:e.backgroundColor,font:e.fontColor,supportButtonBackgroundColor:e.supportButtonBackgroundColor??"'#ffa500'",bot:{background:e.botBackgroundColor,message:e.botMessageColor,font:e.botFontColor},user:{message:e.userMessageColor,font:e.userFontColor},header:{font:e.headerFontColor},footer:{background:e.footerBackgroundColor,inputBorder:e.fonterInputBorderColor},cta:{background:e.callToActionBackgroundColor,font:e.callToActionFontColor},suggestedQuestions:{font:e.suggestedQuestionsFontColor,background:e.suggestedQuestionsBackgroundColor,hover:e.suggestedQuestionsHoverColor,crossButton:{color:e.suggestedQuestionsCrossButtonColor,background:e.suggestedQuestionsCrossButtonBackgroundColor},highlight:e.suggestedQuestionsHighlightColor},chatButton:{animation:e.chatButtonBackgroundAnimationColor}},typography:{fontFamily:void 0,fontSize:void 0,lineHeight:void 0},borders:{radius:"4px",width:"1px"},animations:{chatButton:{type:e.chatButtonBackgroundAnimationType??"Ping",enabled:e.enableChatButtonBackgroundAnimation??!1}},branding:{visibility:{showBot:e.show_bot??!0,debalesBranding:e.debales_branding??!0},logo:{removeBackground:e.removeLogoBackground??!1}}});function Vi(){const e=sessionStorage.getItem("debalesSessionID");if(e)return e;const t=crypto.randomUUID();return sessionStorage.setItem("debalesSessionID",t),t}function dJ(){return sessionStorage.getItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:window.DebalesChat.projectId}))}function Uf(){const e=localStorage.getItem(Zi(Fi.USER_INFO));return e?JSON.parse(e):null}function wO(e){localStorage.setItem(Zi(Fi.USER_INFO),JSON.stringify(e))}function Zw(e){if(e.current){const t=e.current.lastElementChild;if(t)if(window.matchMedia("(max-width: 768px)").matches)e.current.scrollTop=e.current.scrollHeight,setTimeout(()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight)},50);else{const r=e.current.scrollTop,a=t.getBoundingClientRect().bottom+e.current.scrollTop-e.current.clientHeight,s=300,u=performance.now(),d=h=>{const m=h-u,y=Math.min(m/s,1),v=y<.5?4*y*y*y:1-Math.pow(-2*y+2,3)/2;e.current.scrollTop=r+(a-r)*v,y<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}}}function hJ(){return window.location.pathname}function YN(){const e=/test|demo|example|debales/i,t=Uf()??"";return!!(t&&e.test(t.email))}function pJ(e){const t=hJ(),r=Array.from(new Set(e.map(s=>s.path))).filter(s=>new RegExp(`^${s}(/|$)`).test(t));if(r.length>0){r.sort((d,h)=>h.length-d.length);const s=r[0];return e.filter(d=>d.path===s&&d.enable!==!1).sort((d,h)=>(d.sortOrder??0)-(h.sortOrder??0))}return e.filter(s=>s.path==="/"&&s.enable!==!1).sort((s,u)=>(s.sortOrder??0)-(u.sortOrder??0))}const ZN=new Set,gJ=e=>{const t=VN[e];if(!t)return console.warn("No Mixpanel token found"),null;if(ZN.has(e))return Bf;Bf.init(t,{debug:!0,track_pageview:!0,persistence:"localStorage"}),console.log("Mixpanel initialized");const n=Uf();return n&&n.email&&Bf.identify(n.email),ZN.add(e),Bf},mJ=async(e,t)=>{if(YN())return;const n=window.DebalesChat.projectId??t.projectId;if(!VN[n]){console.warn("No Mixpanel token found");return}Bf.track(e,t)},vJ=()=>{const e=localStorage.getItem("anonymousUserId");if(e)return e;const t=crypto.randomUUID();return localStorage.setItem("anonymousUserId",t),t};function yJ(e){return e?e.split("<br>").filter(n=>n.trim().length>0).map(n=>n.trim()):[""]}const Yi=e=>e.toLowerCase().includes("gaiabay")||e.toLowerCase().includes("debales-testing"),bJ=e=>{const t=e.findIndex(s=>s.type==="dynamic");if(t===-1)return e;const n=e.filter(s=>s.type==="static"),r=e.filter(s=>s.type==="dynamic");return[...n.slice(0,t),r,...n.slice(t)]};function Zi(e,t){return t!=null&&t.botId?`debales_${t.botId}_${e}`:`debales_${e}`}const QN=pe.createContext(null),KN=()=>{const e=pe.useContext(QN);if(!e)throw new Error("useCart must be used within a CartProvider");return e};var _J="2.0.0",em="",XN="?",Qw="function",zf="undefined",tm="object",xO="string",V0="major",Qe="model",Ve="name",je="type",Je="vendor",Ze="version",oo="architecture",nm="console",an="mobile",Er="tablet",pa="smarttv",Y0="wearable",CO="xr",EO="embedded",Z0="inapp",WN="user-agent",AO=500,TO="brands",xh="formFactors",kO="fullVersionList",rm="platform",RO="platformVersion",Kw="bitness",Hf="sec-ch-ua",SJ=Hf+"-full-version-list",wJ=Hf+"-arch",xJ=Hf+"-"+Kw,CJ=Hf+"-form-factors",EJ=Hf+"-"+an,AJ=Hf+"-"+Qe,JN=Hf+"-"+rm,TJ=JN+"-version",e5=[TO,kO,an,Qe,rm,RO,oo,xh,Kw],No="browser",oc="cpu",au="device",sc="engine",us="os",im="result",Xw="Amazon",Q0="Apple",t5="ASUS",n5="BlackBerry",Ch="Google",r5="Huawei",i5="Lenovo",kJ="Honor",OO="LG",Ww="Microsoft",a5="Motorola",K0="Samsung",o5="Sharp",Jw="Sony",MO="Xiaomi",DO="Zebra",am="Mobile ",X0=" Browser",s5="Chrome",Pf="Chromecast",RJ="Edge",W0="Firefox",J0="Opera",l5="Facebook",u5="Sogou",IO="Windows",OJ=typeof window!==zf,so=OJ&&window.navigator?window.navigator:void 0,qf=so&&so.userAgentData?so.userAgentData:void 0,MJ=function(e,t){var n={},r=t;if(!tx(t)){r={};for(var a in t)for(var s in t[a])r[s]=t[a][s].concat(r[s]?r[s]:[])}for(var u in e)n[u]=r[u]&&r[u].length%2===0?r[u].concat(e[u]):e[u];return n},ex=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},LO=function(e,t){if(typeof e===tm&&e.length>0){for(var n in e)if(lc(e[n])==lc(t))return!0;return!1}return om(e)?lc(t).indexOf(lc(e))!==-1:!1},tx=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?tx(e[n]):!1)},om=function(e){return typeof e===xO},NO=function(e){if(e){for(var t=[],n=Eh(/\\?\"/g,e).split(","),r=0;r<n.length;r++)if(n[r].indexOf(";")>-1){var a=tb(n[r]).split(";v=");t[r]={brand:a[0],version:a[1]}}else t[r]=tb(n[r]);return t}},lc=function(e){return om(e)?e.toLowerCase():e},$O=function(e){return om(e)?Eh(/[^\d\.]/g,e).split(".")[0]:void 0},uc=function(e){for(var t in e){var n=e[t];typeof n==tm&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Eh=function(e,t){return om(t)?t.replace(e,em):t},eb=function(e){return Eh(/\\?\"/g,e)},tb=function(e,t){if(om(e))return e=Eh(/^\s\s*/,e),typeof t===zf?e:e.substring(0,AO)},c5=function(e,t){if(!(!e||!t))for(var n=0,r,a,s,u,d,h;n<t.length&&!d;){var m=t[n],y=t[n+1];for(r=a=0;r<m.length&&!d&&m[r];)if(d=m[r++].exec(e),d)for(s=0;s<y.length;s++)h=d[++a],u=y[s],typeof u===tm&&u.length>0?u.length===2?typeof u[1]==Qw?this[u[0]]=u[1].call(this,h):this[u[0]]=u[1]:u.length===3?typeof u[1]===Qw&&!(u[1].exec&&u[1].test)?this[u[0]]=h?u[1].call(this,h,u[2]):void 0:this[u[0]]=h?h.replace(u[1],u[2]):void 0:u.length===4&&(this[u[0]]=h?u[3].call(this,h.replace(u[1],u[2])):void 0):this[u]=h||void 0;n+=2}},nb=function(e,t){for(var n in t)if(typeof t[n]===tm&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(LO(t[n][r],e))return n===XN?void 0:n}else if(LO(t[n],e))return n===XN?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},f5={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2","8.1":"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},d5={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},h5={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[Ze,[Ve,am+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[Ze,[Ve,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[Ve,Ze],[/opios[\/ ]+([\w\.]+)/i],[Ze,[Ve,J0+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[Ze,[Ve,J0+" GX"]],[/\bopr\/([\w\.]+)/i],[Ze,[Ve,J0]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[Ze,[Ve,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[Ze,[Ve,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[Ve,Ze],[/quark(?:pc)?\/([-\w\.]+)/i],[Ze,[Ve,"Quark"]],[/\bddg\/([\w\.]+)/i],[Ze,[Ve,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[Ze,[Ve,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[Ze,[Ve,"WeChat"]],[/konqueror\/([\w\.]+)/i],[Ze,[Ve,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[Ze,[Ve,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[Ze,[Ve,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[Ze,[Ve,"Smart "+i5+X0]],[/(avast|avg)\/([\w\.]+)/i],[[Ve,/(.+)/,"$1 Secure"+X0],Ze],[/\bfocus\/([\w\.]+)/i],[Ze,[Ve,W0+" Focus"]],[/\bopt\/([\w\.]+)/i],[Ze,[Ve,J0+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[Ze,[Ve,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[Ze,[Ve,"Dolphin"]],[/coast\/([\w\.]+)/i],[Ze,[Ve,J0+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[Ze,[Ve,"MIUI"+X0]],[/fxios\/([\w\.-]+)/i],[Ze,[Ve,am+W0]],[/\bqihoobrowser\/?([\w\.]*)/i],[Ze,[Ve,"360"]],[/\b(qq)\/([\w\.]+)/i],[[Ve,/(.+)/,"$1Browser"],Ze],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[Ve,/(.+)/,"$1"+X0],Ze],[/samsungbrowser\/([\w\.]+)/i],[Ze,[Ve,K0+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[Ze,[Ve,u5+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[Ve,u5+" Mobile"],Ze],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[Ve,Ze],[/(lbbrowser|rekonq)/i],[Ve],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[Ze,Ve],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[Ve,l5],Ze,[je,Z0]],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat)[\/ ]([-\w\.]+)/i],[Ve,Ze,[je,Z0]],[/\bgsa\/([\w\.]+) .*safari\//i],[Ze,[Ve,"GSA"],[je,Z0]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[Ze,[Ve,"TikTok"],[je,Z0]],[/\[(linkedin)app\]/i],[Ve,[je,Z0]],[/(chromium)[\/ ]([-\w\.]+)/i],[Ve,Ze],[/headlesschrome(?:\/([\w\.]+)| )/i],[Ze,[Ve,s5+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[Ve,s5+" WebView"],Ze],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[Ze,[Ve,"Android"+X0]],[/chrome\/([\w\.]+) mobile/i],[Ze,[Ve,am+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[Ve,Ze],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[Ze,[Ve,am+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[Ve,am+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[Ze,Ve],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[Ve,[Ze,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[Ve,Ze],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[Ve,am+W0],Ze],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[Ve,"Netscape"],Ze],[/(wolvic|librewolf)\/([\w\.]+)/i],[Ve,Ze],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[Ze,[Ve,W0+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[Ve,[Ze,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[Ve,[Ze,/[^\d\.]+./,em]]],cpu:[[/\b(?:(amd|x|x86[-_]?|wow|win)64)\b/i],[[oo,"amd64"]],[/(ia32(?=;))/i,/((?:i[346]|x)86)[;\)]/i],[[oo,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[oo,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[oo,"armhf"]],[/windows (ce|mobile); ppc;/i],[[oo,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[oo,/ower/,em,lc]],[/(sun4\w)[;\)]/i],[[oo,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[oo,lc]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[Qe,[Je,K0],[je,Er]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[Qe,[Je,K0],[je,an]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[Qe,[Je,Q0],[je,an]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[Qe,[Je,Q0],[je,Er]],[/(macintosh);/i],[Qe,[Je,Q0]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[Qe,[Je,o5],[je,an]],[/(?:honor)([-\w ]+)[;\)]/i],[Qe,[Je,kJ],[je,an]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[Qe,[Je,r5],[je,Er]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[Qe,[Je,r5],[je,an]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[Qe,/_/g," "],[Je,MO],[je,an]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[Qe,/_/g," "],[Je,MO],[je,Er]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[Qe,[Je,"OPPO"],[je,an]],[/\b(opd2\d{3}a?) bui/i],[Qe,[Je,"OPPO"],[je,Er]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[Qe,[Je,"Vivo"],[je,an]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[Qe,[Je,"Realme"],[je,an]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[Qe,[Je,a5],[je,an]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[Qe,[Je,a5],[je,Er]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[Qe,[Je,OO],[je,Er]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[Qe,[Je,OO],[je,an]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[Qe,[Je,i5],[je,Er]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[Qe,/_/g," "],[Je,"Nokia"],[je,an]],[/(pixel c)\b/i],[Qe,[Je,Ch],[je,Er]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[Qe,[Je,Ch],[je,an]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[Qe,[Je,Jw],[je,an]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[Qe,"Xperia Tablet"],[Je,Jw],[je,Er]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[Qe,[Je,"OnePlus"],[je,an]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[Qe,[Je,Xw],[je,Er]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[Qe,/(.+)/g,"Fire Phone $1"],[Je,Xw],[je,an]],[/(playbook);[-\w\),; ]+(rim)/i],[Qe,Je,[je,Er]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[Qe,[Je,n5],[je,an]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[Qe,[Je,t5],[je,Er]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[Qe,[Je,t5],[je,an]],[/(nexus 9)/i],[Qe,[Je,"HTC"],[je,Er]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[Je,[Qe,/_/g," "],[je,an]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[Qe,[Je,"TCL"],[je,Er]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[Qe,[Je,"TCL"],[je,an]],[/(itel) ((\w+))/i],[[Je,lc],Qe,[je,nb,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[Qe,[Je,"Acer"],[je,Er]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[Qe,[Je,"Meizu"],[je,an]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[Qe,[Je,"Ulefone"],[je,an]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[Qe,[Je,"Energizer"],[je,an]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[Qe,[Je,"Cat"],[je,an]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[Qe,[Je,"Smartfren"],[je,an]],[/droid.+; (a(?:015|06[35]|142p?))/i],[Qe,[Je,"Nothing"],[je,an]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[Je,Qe,[je,an]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[Je,Qe,[je,Er]],[/(surface duo)/i],[Qe,[Je,Ww],[je,Er]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[Qe,[Je,"Fairphone"],[je,an]],[/(shield[\w ]+) b/i],[Qe,[Je,"Nvidia"],[je,Er]],[/(sprint) (\w+)/i],[Je,Qe,[je,an]],[/(kin\.[onetw]{3})/i],[[Qe,/\./g," "],[Je,Ww],[je,an]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[Qe,[Je,DO],[je,Er]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[Qe,[Je,DO],[je,an]],[/smart-tv.+(samsung)/i],[Je,[je,pa]],[/hbbtv.+maple;(\d+)/i],[[Qe,/^/,"SmartTV"],[Je,K0],[je,pa]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[Je,OO],[je,pa]],[/(apple) ?tv/i],[Je,[Qe,Q0+" TV"],[je,pa]],[/crkey.*devicetype\/chromecast/i],[[Qe,Pf+" Third Generation"],[Je,Ch],[je,pa]],[/crkey.*devicetype\/([^/]*)/i],[[Qe,/^/,"Chromecast "],[Je,Ch],[je,pa]],[/fuchsia.*crkey/i],[[Qe,Pf+" Nest Hub"],[Je,Ch],[je,pa]],[/crkey/i],[[Qe,Pf],[Je,Ch],[je,pa]],[/droid.+aft(\w+)( bui|\))/i],[Qe,[Je,Xw],[je,pa]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[Qe,[Je,o5],[je,pa]],[/(bravia[\w ]+)( bui|\))/i],[Qe,[Je,Jw],[je,pa]],[/(mitv-\w{5}) bui/i],[Qe,[Je,MO],[je,pa]],[/Hbbtv.*(technisat) (.*);/i],[Je,Qe,[je,pa]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[Je,tb],[Qe,tb],[je,pa]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[je,pa]],[/(ouya)/i,/(nintendo) (\w+)/i],[Je,Qe,[je,nm]],[/droid.+; (shield) bui/i],[Qe,[Je,"Nvidia"],[je,nm]],[/(playstation \w+)/i],[Qe,[Je,Jw],[je,nm]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[Qe,[Je,Ww],[je,nm]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[Qe,[Je,K0],[je,Y0]],[/((pebble))app/i],[Je,Qe,[je,Y0]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[Qe,[Je,Q0],[je,Y0]],[/droid.+; (wt63?0{2,3})\)/i],[Qe,[Je,DO],[je,Y0]],[/droid.+; (glass) \d/i],[Qe,[Je,Ch],[je,CO]],[/(pico) (4|neo3(?: link|pro)?)/i],[Je,Qe,[je,CO]],[/; (quest( \d| pro)?)/i],[Qe,[Je,l5],[je,CO]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[Je,[je,EO]],[/(aeobc)\b/i],[Qe,[Je,Xw],[je,EO]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[Qe,[je,an]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[Qe,[je,Er]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[je,Er]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[je,an]],[/(android[-\w\. ]{0,9});.+buil/i],[Qe,[Je,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[Ze,[Ve,RJ+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[Ve,Ze],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[Ze,[Ve,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[Ve,Ze],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[Ze,Ve]],os:[[/microsoft (windows) (vista|xp)/i],[Ve,Ze],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[Ve,[Ze,nb,f5]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[Ze,nb,f5],[Ve,IO]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[Ze,/_/g,"."],[Ve,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[Ve,"macOS"],[Ze,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[Ze,[Ve,Pf+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[Ze,[Ve,Pf+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[Ze,[Ve,Pf+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[Ze,[Ve,Pf+" Linux"]],[/crkey\/([\d\.]+)/i],[Ze,[Ve,Pf]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[Ze,Ve],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[Ve,Ze],[/\(bb(10);/i],[Ze,[Ve,n5]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[Ze,[Ve,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[Ze,[Ve,W0+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[Ze,[Ve,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[Ze,[Ve,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[Ve,"Chrome OS"],Ze],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[Ve,Ze],[/(sunos) ?([\w\.\d]*)/i],[[Ve,"Solaris"],Ze],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[Ve,Ze]]},nx=function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return uc.call(e.init,[[No,[Ve,Ze,V0,je]],[oc,[oo]],[au,[je,Qe,Je]],[sc,[Ve,Ze]],[us,[Ve,Ze]]]),uc.call(e.isIgnore,[[No,[Ze,V0]],[sc,[Ze]],[us,[Ze]]]),uc.call(e.isIgnoreRgx,[[No,/ ?browser$/i],[us,/ ?os$/i]]),uc.call(e.toString,[[No,[Ve,Ze]],[oc,[oo]],[au,[Je,Qe]],[sc,[Ve,Ze]],[us,[Ve,Ze]]]),e}(),DJ=function(e,t){var n=nx.init[t],r=nx.isIgnore[t]||0,a=nx.isIgnoreRgx[t]||0,s=nx.toString[t]||0;function u(){uc.call(this,n)}return u.prototype.getItem=function(){return e},u.prototype.withClientHints=function(){return qf?qf.getHighEntropyValues(e5).then(function(d){return e.setCH(new p5(d,!1)).parseCH().get()}):e.parseCH().get()},u.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=im&&(u.prototype.is=function(d){var h=!1;for(var m in this)if(this.hasOwnProperty(m)&&!LO(r,m)&&lc(a?Eh(a,this[m]):this[m])==lc(a?Eh(a,d):d)){if(h=!0,d!=zf)break}else if(d==zf&&h){h=!h;break}return h},u.prototype.toString=function(){var d=em;for(var h in s)typeof this[s[h]]!==zf&&(d+=(d?" ":em)+this[s[h]]);return d||zf}),qf||(u.prototype.then=function(d){var h=this,m=function(){for(var v in h)h.hasOwnProperty(v)&&(this[v]=h[v])};m.prototype={is:u.prototype.is,toString:u.prototype.toString};var y=new m;return d(y),y}),new u};function p5(e,t){if(e=e||{},uc.call(this,e5),t)uc.call(this,[[TO,NO(e[Hf])],[kO,NO(e[SJ])],[an,/\?1/.test(e[EJ])],[Qe,eb(e[AJ])],[rm,eb(e[JN])],[RO,eb(e[TJ])],[oo,eb(e[wJ])],[xh,NO(e[CJ])],[Kw,eb(e[xJ])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==zf&&(this[n]=e[n])}function g5(e,t,n,r){return this.get=function(a){return a?this.data.hasOwnProperty(a)?this.data[a]:void 0:this.data},this.set=function(a,s){return this.data[a]=s,this},this.setCH=function(a){return this.uaCH=a,this},this.detectFeature=function(){if(so&&so.userAgent==this.ua)switch(this.itemType){case No:so.brave&&typeof so.brave.isBrave==Qw&&this.set(Ve,"Brave");break;case au:!this.get(je)&&qf&&qf[an]&&this.set(je,an),this.get(Qe)=="Macintosh"&&so&&typeof so.standalone!==zf&&so.maxTouchPoints&&so.maxTouchPoints>2&&this.set(Qe,"iPad").set(je,Er);break;case us:!this.get(Ve)&&qf&&qf[rm]&&this.set(Ve,qf[rm]);break;case im:var a=this.data,s=function(u){return a[u].getItem().detectFeature().get()};this.set(No,s(No)).set(oc,s(oc)).set(au,s(au)).set(sc,s(sc)).set(us,s(us))}return this},this.parseUA=function(){return this.itemType!=im&&c5.call(this.data,this.ua,this.rgxMap),this.itemType==No&&this.set(V0,$O(this.get(Ze))),this},this.parseCH=function(){var a=this.uaCH,s=this.rgxMap;switch(this.itemType){case No:var u=a[kO]||a[TO],d;if(u)for(var h in u){var m=Eh(/(Google|Microsoft) /,u[h].brand||u[h]),y=u[h].version;!/not.a.brand/i.test(m)&&(!d||/chrom/i.test(d)&&!/chromi/i.test(m))&&(this.set(Ve,m).set(Ze,y).set(V0,$O(y)),d=m)}break;case oc:var v=a[oo];v&&(v&&a[Kw]=="64"&&(v+="64"),c5.call(this.data,v+";",s));break;case au:if(a[an]&&this.set(je,an),a[Qe]&&this.set(Qe,a[Qe]),a[Qe]=="Xbox"&&this.set(je,nm).set(Je,Ww),a[xh]){var S;if(typeof a[xh]!="string")for(var x=0;!S&&x<a[xh].length;)S=nb(a[xh][x++],d5);else S=nb(a[xh],d5);this.set(je,S)}break;case us:var E=a[rm];if(E){var R=a[RO];E==IO&&(R=parseInt($O(R),10)>=13?"11":"10"),this.set(Ve,E).set(Ze,R)}this.get(Ve)==IO&&a[Qe]=="Xbox"&&this.set(Ve,"Xbox").set(Ze,void 0);break;case im:var T=this.data,A=function(M){return T[M].getItem().setCH(a).parseCH().get()};this.set(No,A(No)).set(oc,A(oc)).set(au,A(au)).set(sc,A(sc)).set(us,A(us))}return this},uc.call(this,[["itemType",e],["ua",t],["uaCH",r],["rgxMap",n],["data",DJ(this,e)]]),this}function cc(e,t,n){if(typeof e===tm?(tx(e,!0)?(typeof t===tm&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===xO&&!tx(t,!0)&&(n=t,t=void 0),n&&typeof n.append===Qw){var r={};n.forEach(function(h,m){r[m]=h}),n=r}if(!(this instanceof cc))return new cc(e,t,n).getResult();var a=typeof e===xO?e:n&&n[WN]?n[WN]:so&&so.userAgent?so.userAgent:em,s=new p5(n,!0),u=t?MJ(h5,t):h5,d=function(h){return h==im?function(){return new g5(h,a,u,s).set("ua",a).set(No,this.getBrowser()).set(oc,this.getCPU()).set(au,this.getDevice()).set(sc,this.getEngine()).set(us,this.getOS()).get()}:function(){return new g5(h,a,u[h],s).parseUA().get()}};return uc.call(this,[["getBrowser",d(No)],["getCPU",d(oc)],["getDevice",d(au)],["getEngine",d(sc)],["getOS",d(us)],["getResult",d(im)],["getUA",function(){return a}],["setUA",function(h){return om(h)&&(a=h.length>AO?tb(h,AO):h),this}]]).setUA(a),this}cc.VERSION=_J,cc.BROWSER=ex([Ve,Ze,V0,je]),cc.CPU=ex([oo]),cc.DEVICE=ex([Qe,Je,je,nm,an,pa,Er,Y0,EO]),cc.ENGINE=cc.OS=ex([Ve,Ze]);const ms=class ms{constructor(t){Ii(this,"config");Ii(this,"storedData");Ii(this,"deviceInfo");Ii(this,"localStorageKey","_dsjfs312313kj3debales_analytics_");this.config=t,this.deviceInfo=this.getDeviceInfo(),this.localStorageKey=t.localStorageKey||this.localStorageKey+this.config.projectName,this.config.testing=t.testing||(()=>!1);const n=localStorage.getItem(this.localStorageKey);if(n)this.storedData=JSON.parse(n),this.config.debug&&console.log("Using Existing Stored data:",this.storedData);else{const r=crypto.randomUUID();this.storedData={projectName:this.config.projectName,anonId:r,distinctId:r},this.config.debug&&console.log("Using New Stored data:",this.storedData),this.updateStorage()}this.config.debug&&console.log("Analytics initialized:",this.storedData)}static init(t){ms.instance||(ms.instance=new ms(t))}static getInstance(){if(!ms.instance)throw new Error("DebalesAnalytics is not initialized. Call init() first.");return ms.instance}static async identify(t,n){return ms.getInstance().identifyInternal(t,n)}static track(t,n){ms.getInstance().trackInternal(t,n)}static getDistinctId(){return ms.getInstance().storedData.distinctId}static getAnonId(){return ms.getInstance().storedData.anonId}async identifyInternal(t,n){try{if(this.config.testing&&this.config.testing())return;let r,a,s;if(n){const{name:h,phone:m,...y}=n;r=h,a=m,s=y}const u={distinctId:this.storedData.distinctId,anonId:[this.storedData.anonId],projectName:this.config.projectName,email:t,name:r,phone:a,properties:s},d=await this.sendRequest("/api/analytic/identify",u);d&&d.success&&d.distinctId&&(this.config.debug&&console.log("identify success new distint id"),this.storedData.distinctId=d.distinctId,this.storedData.email=t,this.updateStorage(),d.isIdentified&&this.trackInternal("identify")),this.config.debug&&console.log("Identify event sent:",u)}catch(r){console.error("Failed to identify user:",r)}}trackInternal(t,n){if(this.config.testing&&this.config.testing())return;const r={projectName:this.config.projectName,distinctId:this.storedData.distinctId,anonId:this.storedData.anonId,eventName:t,osVersion:this.deviceInfo.osVersion,browserVersion:this.deviceInfo.browserVersion,operatingSystem:this.deviceInfo.os,browser:this.deviceInfo.browser,currentUrl:window.location.href,chatId:Vi()+this.config.projectName,properties:n};this.sendRequest("/api/analytic/track",r),this.config.debug&&console.log("Track event sent:",r)}updateStorage(){localStorage.setItem(this.localStorageKey,JSON.stringify(this.storedData))}async sendRequest(t,n){try{const r=await fetch(`${iu}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return await r.json()}catch(r){console.error("Failed to send analytics data:",r)}}getDeviceInfo(){const n=new cc().getResult();return{browser:n.browser.name,os:n.os.name,browserVersion:n.browser.version,osVersion:n.os.version}}};Ii(ms,"instance",null);let BO=ms;const Ah=BO;var gl,Ae=typeof window<"u"?window:void 0,lo=typeof globalThis<"u"?globalThis:Ae,m5=Array.prototype,v5=m5.forEach,y5=m5.indexOf,$o=lo==null?void 0:lo.navigator,yt=lo==null?void 0:lo.document,uo=lo==null?void 0:lo.location,UO=lo==null?void 0:lo.fetch,zO=lo!=null&&lo.XMLHttpRequest&&"withCredentials"in new lo.XMLHttpRequest?lo.XMLHttpRequest:void 0,b5=lo==null?void 0:lo.AbortController,oi=$o==null?void 0:$o.userAgent,Wt=Ae??{},fc={DEBUG:!1,LIB_VERSION:"1.235.0"},HO="$copy_autocapture",IJ=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(e){e.GZipJS="gzip-js",e.Base64="base64"})(gl||(gl={}));var LJ=["fatal","error","warning","log","info","debug"];function bn(e,t){return e.indexOf(t)!==-1}var rx=function(e){return e.trim()},PO=function(e){return e.replace(/^\$/,"")},NJ=Array.isArray,_5=Object.prototype,S5=_5.hasOwnProperty,ix=_5.toString,Pr=NJ||function(e){return ix.call(e)==="[object Array]"},ml=e=>typeof e=="function",qr=e=>e===Object(e)&&!Pr(e),sm=e=>{if(qr(e)){for(var t in e)if(S5.call(e,t))return!1;return!0}return!1},ut=e=>e===void 0,si=e=>ix.call(e)=="[object String]",qO=e=>si(e)&&e.trim().length===0,Ff=e=>e===null,Xn=e=>ut(e)||Ff(e),Ua=e=>ix.call(e)=="[object Number]",jf=e=>ix.call(e)==="[object Boolean]",$J=e=>e instanceof FormData,BJ=e=>bn(IJ,e),w5=e=>{var t={_log:function(n){if(Ae&&(fc.DEBUG||Wt.POSTHOG_DEBUG)&&!ut(Ae.console)&&Ae.console){for(var r=("__rrweb_original__"in Ae.console[n])?Ae.console[n].__rrweb_original__:Ae.console[n],a=arguments.length,s=new Array(a>1?a-1:0),u=1;u<a;u++)s[u-1]=arguments[u];r(e,...s)}},info:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];t._log("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];t._log("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];t._log("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];console.error(e,...r)},uninitializedWarning:n=>{t.error("You must initialize PostHog before calling ".concat(n))},createLogger:n=>w5("".concat(e," ").concat(n))};return t},Ot=w5("[PostHog.js]"),ga=Ot.createLogger,UJ=ga("[ExternalScriptsLoader]"),x5=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return UJ.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var r=yt==null?void 0:yt.querySelectorAll("script");if(r){for(var a=0;a<r.length;a++)if(r[a].src===t)return n()}var s=()=>{if(!yt)return n("document not found");var u=yt.createElement("script");if(u.type="text/javascript",u.crossOrigin="anonymous",u.src=t,u.onload=m=>n(void 0,m),u.onerror=m=>n(m),e.config.prepare_external_dependency_script&&(u=e.config.prepare_external_dependency_script(u)),!u)return n("prepare_external_dependency_script returned null");var d,h=yt.querySelectorAll("body > script");h.length>0?(d=h[0].parentNode)===null||d===void 0||d.insertBefore(u,h[0]):yt.body.appendChild(u)};yt!=null&&yt.body?s():yt==null||yt.addEventListener("DOMContentLoaded",s)};function C5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function Le(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?C5(Object(n),!0).forEach(function(r){et(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C5(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function et(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E5(e,t){if(e==null)return{};var n,r,a=function(u,d){if(u==null)return{};var h,m,y={},v=Object.keys(u);for(m=0;m<v.length;m++)h=v[m],d.indexOf(h)>=0||(y[h]=u[h]);return y}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}Wt.__PosthogExtensions__=Wt.__PosthogExtensions__||{},Wt.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var r="/static/".concat(t,".js")+"?v=".concat(e.version);if(t==="remote-config"&&(r="/array/".concat(e.config.token,"/config.js")),t==="toolbar"){var a=3e5,s=Math.floor(Date.now()/a)*a;r="".concat(r,"&t=").concat(s)}var u=e.requestRouter.endpointFor("assets",r);x5(e,u,n)},Wt.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);x5(e,r,n)};var ax={};function Gf(e,t,n){if(Pr(e)){if(v5&&e.forEach===v5)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var r=0,a=e.length;r<a;r++)if(r in e&&t.call(n,e[r],r)===ax)return}}}function tr(e,t,n){if(!Xn(e)){if(Pr(e))return Gf(e,t,n);if($J(e)){for(var r of e.entries())if(t.call(n,r[1],r[0])===ax)return}else for(var a in e)if(S5.call(e,a)&&t.call(n,e[a],a)===ax)return}}var li=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Gf(n,function(a){for(var s in a)a[s]!==void 0&&(e[s]=a[s])}),e},ox=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Gf(n,function(a){Gf(a,function(s){e.push(s)})}),e};function sx(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var A5=function(e){try{return e()}catch{return}},zJ=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(this,n)}catch(a){Ot.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ot.critical(a)}}},rb=function(e){var t={};return tr(e,function(n,r){si(n)&&n.length>0&&(t[r]=n)}),t};function HJ(e,t){return n=e,r=s=>si(s)&&!Ff(t)?s.slice(0,t):s,a=new Set,function s(u,d){return u!==Object(u)?r?r(u,d):u:a.has(u)?void 0:(a.add(u),Pr(u)?(h=[],Gf(u,m=>{h.push(s(m))})):(h={},tr(u,(m,y)=>{a.has(m)||(h[y]=s(m,y))})),h);var h}(n);var n,r,a}var PJ=["herokuapp.com","vercel.app","netlify.app"];function qJ(e){var t=e==null?void 0:e.hostname;if(!si(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of PJ)if(n===r)return!1;return!0}function T5(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Kr(e,t,n,r){var{capture:a=!1,passive:s=!0}=r??{};e==null||e.addEventListener(t,n,{capture:a,passive:s})}var k5="$people_distinct_id",ib="__alias",ab="__timers",R5="$autocapture_disabled_server_side",FO="$heatmaps_enabled_server_side",O5="$exception_capture_enabled_server_side",M5="$web_vitals_enabled_server_side",D5="$dead_clicks_enabled_server_side",I5="$web_vitals_allowed_metrics",jO="$session_recording_enabled_server_side",L5="$console_log_recording_enabled_server_side",N5="$session_recording_network_payload_capture",$5="$session_recording_masking",B5="$session_recording_canvas_recording",U5="$replay_sample_rate",z5="$replay_minimum_duration",H5="$replay_script_config",lx="$sesid",ob="$session_is_sampled",GO="$session_recording_url_trigger_activated_session",VO="$session_recording_event_trigger_activated_session",lm="$enabled_feature_flags",ux="$early_access_features",YO="$feature_flag_details",sb="$stored_person_properties",Th="$stored_group_properties",ZO="$surveys",cx="$surveys_activated",fx="$flag_call_reported",dc="$user_state",QO="$client_session_props",KO="$capture_rate_limit",XO="$initial_campaign_params",WO="$initial_referrer_info",JO="$initial_person_info",dx="$epp",P5="__POSTHOG_TOOLBAR__",q5="$posthog_cookieless",FJ=[k5,ib,"__cmpns",ab,jO,FO,lx,lm,dc,ux,YO,Th,sb,ZO,fx,QO,KO,XO,WO,dx];function F5(e){var t;return e instanceof Element&&(e.id===P5||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function hx(e){return!!e&&e.nodeType===1}function Vf(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function j5(e){return!!e&&e.nodeType===3}function G5(e){return!!e&&e.nodeType===11}function eM(e){return e?rx(e).split(/\s+/):[]}function V5(e){var t=Ae==null?void 0:Ae.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function px(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return eM(t)}function Y5(e){return Xn(e)?null:rx(e).split(/(\s+)/).filter(t=>um(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function gx(e){var t="";return nM(e)&&!K5(e)&&e.childNodes&&e.childNodes.length&&tr(e.childNodes,function(n){var r;j5(n)&&n.textContent&&(t+=(r=Y5(n.textContent))!==null&&r!==void 0?r:"")}),rx(t)}function Z5(e){return ut(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var tM=["a","button","form","input","select","textarea","label"];function Q5(e){var t=e.parentNode;return!(!t||!hx(t))&&t}function jJ(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(!Ae||!e||Vf(e,"html")||!hx(e)||n!=null&&n.url_allowlist&&!V5(n.url_allowlist)||n!=null&&n.url_ignorelist&&V5(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var s=n.dom_event_allowlist;if(s&&!s.some(x=>t.type===x))return!1}for(var u=!1,d=[e],h=!0,m=e;m.parentNode&&!Vf(m,"body");)if(G5(m.parentNode))d.push(m.parentNode.host),m=m.parentNode.host;else{if(!(h=Q5(m)))break;if(r||tM.indexOf(h.tagName.toLowerCase())>-1)u=!0;else{var y=Ae.getComputedStyle(h);y&&y.getPropertyValue("cursor")==="pointer"&&(u=!0)}d.push(h),m=h}if(!function(x,E){var R=E==null?void 0:E.element_allowlist;if(ut(R))return!0;var T=function(D){if(R.some($=>D.tagName.toLowerCase()===$))return{v:!0}};for(var A of x){var M=T(A);if(typeof M=="object")return M.v}return!1}(d,n)||!function(x,E){var R=E==null?void 0:E.css_selector_allowlist;if(ut(R))return!0;var T=function(D){if(R.some($=>D.matches($)))return{v:!0}};for(var A of x){var M=T(A);if(typeof M=="object")return M.v}return!1}(d,n))return!1;var v=Ae.getComputedStyle(e);if(v&&v.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var S=e.tagName.toLowerCase();switch(S){case"html":return!1;case"form":return(a||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(a||["change","click"]).indexOf(t.type)>=0;default:return u?(a||["click"]).indexOf(t.type)>=0:(a||["click"]).indexOf(t.type)>=0&&(tM.indexOf(S)>-1||e.getAttribute("contenteditable")==="true")}}function nM(e){for(var t=e;t.parentNode&&!Vf(t,"body");t=t.parentNode){var n=px(t);if(bn(n,"ph-sensitive")||bn(n,"ph-no-capture"))return!1}if(bn(px(e),"ph-include"))return!0;var r=e.type||"";if(si(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var a=e.name||e.id||"";return!(si(a)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,"")))}function K5(e){return!!(Vf(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Vf(e,"select")||Vf(e,"textarea")||e.getAttribute("contenteditable")==="true")}var X5="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",GJ=new RegExp("^(?:".concat(X5,")$")),VJ=new RegExp(X5),W5="\\d{3}-?\\d{2}-?\\d{4}",YJ=new RegExp("^(".concat(W5,")$")),ZJ=new RegExp("(".concat(W5,")"));function um(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(Xn(e)||si(e)&&(e=rx(e),(t?GJ:VJ).test((e||"").replace(/[- ]/g,""))||(t?YJ:ZJ).test(e)))}function J5(e){var t=gx(e);return um(t="".concat(t," ").concat(e9(e)).trim())?t:""}function e9(e){var t="";return e&&e.childNodes&&e.childNodes.length&&tr(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{var a=gx(n);t="".concat(t," ").concat(a).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(e9(n)).trim())}catch(s){Ot.error("[AutoCapture]",s)}}),t}function QJ(e){return function(t){var n=t.map(r=>{var a,s,u="";if(r.tag_name&&(u+=r.tag_name),r.attr_class)for(var d of(r.attr_class.sort(),r.attr_class))u+=".".concat(d.replace(/"/g,""));var h=Le(Le(Le(Le({},r.text?{text:r.text}:{}),{},{"nth-child":(a=r.nth_child)!==null&&a!==void 0?a:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{}),r.attr_id?{attr_id:r.attr_id}:{}),r.attributes),m={};return sx(h).sort((y,v)=>{var[S]=y,[x]=v;return S.localeCompare(x)}).forEach(y=>{var[v,S]=y;return m[t9(v.toString())]=t9(S.toString())}),u+=":",u+=sx(h).map(y=>{var[v,S]=y;return"".concat(v,'="').concat(S,'"')}).join("")});return n.join(";")}(function(t){return t.map(n=>{var r,a,s={text:(r=n.$el_text)===null||r===void 0?void 0:r.slice(0,400),tag_name:n.tag_name,href:(a=n.attr__href)===null||a===void 0?void 0:a.slice(0,2048),attr_class:KJ(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return sx(n).filter(u=>{var[d]=u;return d.indexOf("attr__")===0}).forEach(u=>{var[d,h]=u;return s.attributes[d]=h}),s})}(e))}function t9(e){return e.replace(/"|\\"/g,'\\"')}function KJ(e){var t=e.attr__class;return t?Pr(t)?t:eM(t):void 0}class n9{constructor(){this.clicks=[]}isRageClick(t,n,r){var a=this.clicks[this.clicks.length-1];if(a&&Math.abs(t-a.x)+Math.abs(n-a.y)<30&&r-a.timestamp<1e3){if(this.clicks.push({x:t,y:n,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:t,y:n,timestamp:r}];return!1}}var XJ=["localhost","127.0.0.1"],cm=e=>{var t=yt==null?void 0:yt.createElement("a");return ut(t)?null:(t.href=e,t)},WJ=function(e){var t,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",a=[];return tr(e,function(s,u){ut(s)||ut(u)||u==="undefined"||(t=encodeURIComponent((d=>d instanceof File)(s)?s.name:s.toString()),n=encodeURIComponent(u),a[a.length]=n+"="+t)}),a.join(r)},mx=function(e,t){for(var n,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),a=0;a<r.length;a++){var s=r[a].split("=");if(s[0]===t){n=s;break}}if(!Pr(n)||n.length<2)return"";var u=n[1];try{u=decodeURIComponent(u)}catch{Ot.error("Skipping decoding for malformed query param: "+u)}return u.replace(/\+/g," ")},rM=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),a=r[0]||"",s=r[1],u=a.split("?"),d=u[1],h=u[0],m=(d||"").split("&"),y=[],v=0;v<m.length;v++){var S=m[v].split("=");Pr(S)&&(t.includes(S[0])?y.push(S[0]+"="+n):y.push(m[v]))}var x=h;return d!=null&&(x+="?"+y.join("&")),s!=null&&(x+="#"+s),x},vx=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},r9=ga("[AutoCapture]");function iM(e,t){return t.length>e?t.slice(0,e)+"...":t}function JJ(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!hx(t));return t}function eee(e,t,n,r){var a=e.tagName.toLowerCase(),s={tag_name:a};tM.indexOf(a)>-1&&!n&&(a.toLowerCase()==="a"||a.toLowerCase()==="button"?s.$el_text=iM(1024,J5(e)):s.$el_text=iM(1024,gx(e)));var u=px(e);u.length>0&&(s.classes=u.filter(function(y){return y!==""})),tr(e.attributes,function(y){var v;if((!K5(e)||["name","id","class","aria-label"].indexOf(y.name)!==-1)&&(r==null||!r.includes(y.name))&&!t&&um(y.value)&&(v=y.name,!si(v)||v.substring(0,10)!=="_ngcontent"&&v.substring(0,7)!=="_nghost")){var S=y.value;y.name==="class"&&(S=eM(S).join(" ")),s["attr__"+y.name]=iM(1024,S)}});for(var d=1,h=1,m=e;m=JJ(m);)d++,m.tagName===e.tagName&&h++;return s.nth_child=d,s.nth_of_type=h,s}function tee(e,t){for(var n,r,{e:a,maskAllElementAttributes:s,maskAllText:u,elementAttributeIgnoreList:d,elementsChainAsString:h}=t,m=[e],y=e;y.parentNode&&!Vf(y,"body");)G5(y.parentNode)?(m.push(y.parentNode.host),y=y.parentNode.host):(m.push(y.parentNode),y=y.parentNode);var v,S=[],x={},E=!1,R=!1;if(tr(m,$=>{var U=nM($);$.tagName.toLowerCase()==="a"&&(E=$.getAttribute("href"),E=U&&E&&um(E)&&E),bn(px($),"ph-no-capture")&&(R=!0),S.push(eee($,s,u,d));var P=function(Z){if(!nM(Z))return{};var X={};return tr(Z.attributes,function(K){if(K.name&&K.name.indexOf("data-ph-capture-attribute")===0){var G=K.name.replace("data-ph-capture-attribute-",""),ne=K.value;G&&ne&&um(ne)&&(X[G]=ne)}}),X}($);li(x,P)}),R)return{props:{},explicitNoCapture:R};if(u||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?S[0].$el_text=J5(e):S[0].$el_text=gx(e)),E){var T,A;S[0].attr__href=E;var M=(T=cm(E))===null||T===void 0?void 0:T.host,D=Ae==null||(A=Ae.location)===null||A===void 0?void 0:A.host;M&&D&&M!==D&&(v=E)}return{props:li({$event_type:a.type,$ce_version:1},h?{}:{$elements:S},{$elements_chain:QJ(S)},(n=S[0])!==null&&n!==void 0&&n.$el_text?{$el_text:(r=S[0])===null||r===void 0?void 0:r.$el_text}:{},v&&a.type==="click"?{$external_click_url:v}:{},x)}}class nee{constructor(t){et(this,"_initialized",!1),et(this,"_isDisabledServerSide",null),et(this,"rageclicks",new n9),et(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,r=qr(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(t=r.url_allowlist)===null||t===void 0?void 0:t.map(a=>new RegExp(a)),r.url_ignorelist=(n=r.url_ignorelist)===null||n===void 0?void 0:n.map(a=>new RegExp(a)),r}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ae&&yt){var t=r=>{r=r||(Ae==null?void 0:Ae.event);try{this._captureEvent(r)}catch(a){r9.error("Failed to capture event",a)}};if(Kr(yt,"submit",t,{capture:!0}),Kr(yt,"change",t,{capture:!0}),Kr(yt,"click",t,{capture:!0}),this.config.capture_copied_text){var n=r=>{r=r||(Ae==null?void 0:Ae.event),this._captureEvent(r,HO)};Kr(yt,"copy",n,{capture:!0}),Kr(yt,"cut",n,{capture:!0})}}}else r9.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[R5]:!!t.autocapture_opt_out}),this._isDisabledServerSide=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this._elementSelectors=t}getElementSelectors(t){var n,r=[];return(n=this._elementSelectors)===null||n===void 0||n.forEach(a=>{var s=yt==null?void 0:yt.querySelectorAll(a);s==null||s.forEach(u=>{t===u&&r.push(a)})}),r}get isEnabled(){var t,n,r=(t=this.instance.persistence)===null||t===void 0?void 0:t.props[R5],a=this._isDisabledServerSide;if(Ff(a)&&!jf(r)&&!this.instance.config.advanced_disable_decide)return!1;var s=(n=this._isDisabledServerSide)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!s}_captureEvent(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var r,a=Z5(t);j5(a)&&(a=a.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,"$rageclick");var s=n===HO;if(a&&jJ(a,t,this.config,s,s?["copy","cut"]:void 0)){var{props:u,explicitNoCapture:d}=tee(a,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(d)return!1;var h=this.getElementSelectors(a);if(h&&h.length>0&&(u.$element_selectors=h),n===HO){var m,y=Y5(Ae==null||(m=Ae.getSelection())===null||m===void 0?void 0:m.toString()),v=t.type||"clipboard";if(!y)return!1;u.$selected_content=y,u.$copy_type=v}return this.instance.capture(n,u),!0}}}isBrowserSupported(){return ml(yt==null?void 0:yt.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ua(e)&&isFinite(e)&&Math.floor(e)===e});var i9="0123456789abcdef";class yx{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,a){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(a)||t<0||n<0||r<0||a<0||t>0xffffffffffff||n>4095||r>1073741823||a>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=a>>>24,s[13]=a>>>16,s[14]=a>>>8,s[15]=a,new yx(s)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+i9.charAt(this.bytes[n]>>>4)+i9.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new yx(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;n<16;n++){var r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class ree{constructor(){et(this,"timestamp",0),et(this,"counter",0),et(this,"random",new iee)}generate(){var t=this.generateOrAbort();if(ut(t)){this.timestamp=0;var n=this.generateOrAbort();if(ut(n))throw new Error("Could not generate UUID after timestamp reset");return n}return t}generateOrAbort(){var t=Date.now();if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return yx.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var a9,o9=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ae&&!ut(Ae.crypto)&&crypto.getRandomValues&&(o9=e=>crypto.getRandomValues(e));class iee{constructor(){et(this,"buffer",new Uint32Array(8)),et(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(o9(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Yf=()=>aee().toString(),aee=()=>(a9||(a9=new ree)).generate(),oee="Thu, 01 Jan 1970 00:00:00 GMT",lb="",see=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function lee(e,t){if(t){var n=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:yt;if(lb)return lb;if(!s||["localhost","127.0.0.1"].includes(a))return"";for(var u=a.split("."),d=Math.min(u.length,8),h="dmn_chk_"+Yf(),m=new RegExp("(^|;)\\s*"+h+"=1");!lb&&d--;){var y=u.slice(d).join("."),v=h+"=1;domain=."+y;s.cookie=v,m.test(s.cookie)&&(s.cookie=v+";expires="+oee,lb=y)}return lb}(e);if(!n){var r=(a=>{var s=a.match(see);return s?s[0]:""})(e);r!==n&&Ot.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var Zf,hc={is_supported:()=>!!yt,error:function(e){Ot.error("cookieStore error: "+e)},get:function(e){if(yt){try{for(var t=e+"=",n=yt.cookie.split(";").filter(s=>s.length),r=0;r<n.length;r++){for(var a=n[r];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}}catch{}return null}},parse:function(e){var t;try{t=JSON.parse(hc.get(e))||{}}catch{}return t},set:function(e,t,n,r,a){if(yt)try{var s="",u="",d=lee(yt.location.hostname,r);if(n){var h=new Date;h.setTime(h.getTime()+24*n*60*60*1e3),s="; expires="+h.toUTCString()}a&&(u="; secure");var m=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+d+u;return m.length>3686.4&&Ot.warn("cookieStore warning: large cookie, len="+m.length),yt.cookie=m,m}catch{return}},remove:function(e,t){try{hc.set(e,"",-1,t)}catch{return}}},aM=null,Si={is_supported:function(){if(!Ff(aM))return aM;var e=!0;if(ut(Ae))e=!1;else try{var t="__mplssupport__";Si.set(t,"xyz"),Si.get(t)!=='"xyz"'&&(e=!1),Si.remove(t)}catch{e=!1}return e||Ot.error("localStorage unsupported; falling back to cookie store"),aM=e,e},error:function(e){Ot.error("localStorage error: "+e)},get:function(e){try{return Ae==null?void 0:Ae.localStorage.getItem(e)}catch(t){Si.error(t)}return null},parse:function(e){try{return JSON.parse(Si.get(e))||{}}catch{}return null},set:function(e,t){try{Ae==null||Ae.localStorage.setItem(e,JSON.stringify(t))}catch(n){Si.error(n)}},remove:function(e){try{Ae==null||Ae.localStorage.removeItem(e)}catch(t){Si.error(t)}}},uee=["distinct_id",lx,ob,dx,JO],bx=Le(Le({},Si),{},{parse:function(e){try{var t={};try{t=hc.parse(e)||{}}catch{}var n=li(t,JSON.parse(Si.get(e)||"{}"));return Si.set(e,n),n}catch{}return null},set:function(e,t,n,r,a,s){try{Si.set(e,t,void 0,void 0,s);var u={};uee.forEach(d=>{t[d]&&(u[d]=t[d])}),Object.keys(u).length&&hc.set(e,u,n,r,a,s)}catch(d){Si.error(d)}},remove:function(e,t){try{Ae==null||Ae.localStorage.removeItem(e),hc.remove(e,t)}catch(n){Si.error(n)}}}),_x={},cee={is_supported:function(){return!0},error:function(e){Ot.error("memoryStorage error: "+e)},get:function(e){return _x[e]||null},parse:function(e){return _x[e]||null},set:function(e,t){_x[e]=t},remove:function(e){delete _x[e]}},kh=null,Qi={is_supported:function(){if(!Ff(kh))return kh;if(kh=!0,ut(Ae))kh=!1;else try{var e="__support__";Qi.set(e,"xyz"),Qi.get(e)!=='"xyz"'&&(kh=!1),Qi.remove(e)}catch{kh=!1}return kh},error:function(e){Ot.error("sessionStorage error: ",e)},get:function(e){try{return Ae==null?void 0:Ae.sessionStorage.getItem(e)}catch(t){Qi.error(t)}return null},parse:function(e){try{return JSON.parse(Qi.get(e))||null}catch{}return null},set:function(e,t){try{Ae==null||Ae.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){Qi.error(n)}},remove:function(e){try{Ae==null||Ae.sessionStorage.removeItem(e)}catch(t){Qi.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(Zf||(Zf={}));class fee{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?Zf.DENIED:this.storedConsent}isOptedOut(){return this.consent===Zf.DENIED||this.consent===Zf.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(t){this.storage.set(this.storageKey,t?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:t,opt_out_capturing_cookie_prefix:n}=this.instance.config;return(n||"__ph_opt_in_out_")+t}get storedConsent(){var t=this.storage.get(this.storageKey);return t==="1"?Zf.GRANTED:t==="0"?Zf.DENIED:Zf.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?Si:hc;var n=t==="localStorage"?hc:Si;n.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(n.get(this.storageKey)==="1"),n.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!T5([$o==null?void 0:$o.doNotTrack,$o==null?void 0:$o.msDoNotTrack,Wt.doNotTrack],t=>bn([!0,1,"1","yes"],t))}}var Sx=ga("[Dead Clicks]"),dee=()=>!0,hee=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(D5)),r=e.instance.config.capture_dead_clicks;return jf(r)?r:n};class s9{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(t,n,r){this.instance=t,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[D5]:t==null?void 0:t.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"dead-clicks-autocapture",s=>{s?Sx.error("failed to load script",s):t()})}start(){var t;if(yt){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Wt.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=qr(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Wt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(yt),Sx.info("starting...")}}else Sx.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Sx.info("stopping..."))}}var oM=ga("[ExceptionAutocapture]");class pee{constructor(t){var n;et(this,"startCapturing",()=>{var r;if(Ae&&this.isEnabled&&(r=Wt.__PosthogExtensions__)!==null&&r!==void 0&&r.errorWrappingFunctions){var a=Wt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=Wt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,u=Wt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.unwrapOnError&&this.config.capture_unhandled_errors&&(this.unwrapOnError=a(this.captureException.bind(this))),!this.unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this.unwrapUnhandledRejection=s(this.captureException.bind(this))),!this.unwrapConsoleError&&this.config.capture_console_errors&&(this.unwrapConsoleError=u(this.captureException.bind(this)))}catch(d){oM.error("failed to start",d),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[O5]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var t=this.instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return qr(t)?n=Le(Le({},n),t):(ut(t)?this.remoteEnabled:t)&&(n=Le(Le({},n),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(oM.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"exception-autocapture",s=>{if(s)return oM.error("failed to load script",s);t()})}stopCapturing(){var t,n,r;(t=this.unwrapOnError)===null||t===void 0||t.call(this),this.unwrapOnError=void 0,(n=this.unwrapUnhandledRejection)===null||n===void 0||n.call(this),this.unwrapUnhandledRejection=void 0,(r=this.unwrapConsoleError)===null||r===void 0||r.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(t){var n=t.autocaptureExceptions;this.remoteEnabled=!!n||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[O5]:this.remoteEnabled}),this.startIfEnabled()}captureException(t){var n=this.instance.requestRouter.endpointFor("ui");t.$exception_personURL="".concat(n,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(t)}}function l9(e){return!ut(Event)&&u9(e,Event)}function u9(e,t){try{return e instanceof t}catch{return!1}}function wx(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function sM(e){return wx(e,"DOMError")}var c9=/\(error: (.*)\)/,f9=50,fm="?";function lM(e,t,n,r){var a={platform:"web:javascript",filename:e,function:t==="<anonymous>"?fm:t,in_app:!0};return ut(n)||(a.lineno=n),ut(r)||(a.colno=r),a}var gee=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,mee=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,vee=/\((\S*)(?::(\d+))(?::(\d+))\)/,yee=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,bee=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_ee=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.sort((a,s)=>a[0]-s[0]).map(a=>a[1]);return function(a){for(var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,u=[],d=a.split(`
114
+ `);var t="",n,r,a=0,s;for(n=r=0,a=e.length,s=0;s<a;s++){var u=e.charCodeAt(s),d=null;u<128?r++:u>127&&u<2048?d=String.fromCharCode(u>>6|192,u&63|128):d=String.fromCharCode(u>>12|224,u>>6&63|128,u&63|128),d!==null&&(r>n&&(t+=e.substring(n,r)),t+=d,n=r=s+1)}return r>n&&(t+=e.substring(n,e.length)),t},N.UUID=function(){try{return ct.crypto.randomUUID()}catch{for(var e=new Array(36),t=0;t<36;t++)e[t]=Math.floor(Math.random()*16);return e[14]=4,e[19]=e[19]&=-5,e[19]=e[19]|=8,e[8]=e[13]=e[18]=e[23]="-",N.map(e,function(r){return r.toString(16)}).join("")}};var tN=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];N.isBlockedUA=function(e){var t;for(e=e.toLowerCase(),t=0;t<tN.length;t++)if(e.indexOf(tN[t])!==-1)return!0;return!1},N.HTTPBuildQuery=function(e,t){var n,r,a=[];return N.isUndefined(t)&&(t="&"),N.each(e,function(s,u){n=encodeURIComponent(s.toString()),r=encodeURIComponent(u),a[a.length]=r+"="+n}),a.join(t)},N.getQueryParam=function(e,t){t=t.replace(/[[]/g,"\\[").replace(/[\]]/g,"\\]");var n="[\\?&]"+t+"=([^&#]*)",r=new RegExp(n),a=r.exec(e);if(a===null||a&&typeof a[1]!="string"&&a[1].length)return"";var s=a[1];try{s=decodeURIComponent(s)}catch{zn.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},N.cookie={get:function(e){for(var t=e+"=",n=jn.cookie.split(";"),r=0;r<n.length;r++){for(var a=n[r];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}return null},parse:function(e){var t;try{t=N.JSONDecode(N.cookie.get(e))||{}}catch{}return t},set_seconds:function(e,t,n,r,a,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=iN(jn.location.hostname);d=y?"; domain=."+y:""}if(n){var v=new Date;v.setTime(v.getTime()+n*1e3),h="; expires="+v.toGMTString()}s&&(a=!0,m="; SameSite=None"),a&&(m+="; secure"),jn.cookie=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m},set:function(e,t,n,r,a,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=iN(jn.location.hostname);d=y?"; domain=."+y:""}if(n){var v=new Date;v.setTime(v.getTime()+n*24*60*60*1e3),h="; expires="+v.toGMTString()}s&&(a=!0,m="; SameSite=None"),a&&(m+="; secure");var S=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m;return jn.cookie=S,S},remove:function(e,t,n){N.cookie.set(e,"",-1,t,!1,!1,n)}};var nN=function(e){var t=!0;try{var n="__mplss_"+QR(8),r="xyz";e.setItem(n,r),e.getItem(n)!==r&&(t=!1),e.removeItem(n)}catch{t=!1}return t},YR=null,H0=function(e,t){return YR!==null&&!t?YR:YR=nN(e||ct.localStorage)},ZR=null,pW=function(e,t){return ZR!==null&&!t?ZR:ZR=nN(e||ct.sessionStorage)};function rN(e,t,n){var r=function(a){zn.error(t+" error: "+a)};return{is_supported:function(a){var s=n(e,a);return s||zn.error(t+" unsupported"),s},error:r,get:function(a){try{return e.getItem(a)}catch(s){r(s)}return null},parse:function(a){try{return N.JSONDecode(e.getItem(a))||{}}catch{}return null},set:function(a,s){try{e.setItem(a,s)}catch(u){r(u)}},remove:function(a){try{e.removeItem(a)}catch(s){r(s)}}}}N.localStorage=rN(ct.localStorage,"localStorage",H0),N.sessionStorage=rN(ct.sessionStorage,"sessionStorage",pW),N.register_event=function(){var e=function(r,a,s,u,d){if(!r){zn.error("No valid element provided to register_event");return}if(r.addEventListener&&!u)r.addEventListener(a,s,!!d);else{var h="on"+a,m=r[h];r[h]=t(r,s,m)}};function t(r,a,s){var u=function(d){if(d=d||n(ct.event),!!d){var h=!0,m,y;return N.isFunction(s)&&(m=s(d)),y=a.call(r,d),(m===!1||y===!1)&&(h=!1),h}};return u}function n(r){return r&&(r.preventDefault=n.preventDefault,r.stopPropagation=n.stopPropagation),r}return n.preventDefault=function(){this.returnValue=!1},n.stopPropagation=function(){this.cancelBubble=!0},e}();var gW=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');N.dom_query=function(){function e(a){return a.all?a.all:a.getElementsByTagName("*")}var t=/[\t\r\n]/g;function n(a,s){var u=" "+s+" ";return(" "+a.className+" ").replace(t," ").indexOf(u)>=0}function r(a){if(!jn.getElementsByTagName)return[];var s=a.split(" "),u,d,h,m,y,v,S,x,E,R,T=[jn];for(v=0;v<s.length;v++){if(u=s[v].replace(/^\s+/,"").replace(/\s+$/,""),u.indexOf("#")>-1){d=u.split("#"),h=d[0];var A=d[1],M=jn.getElementById(A);if(!M||h&&M.nodeName.toLowerCase()!=h)return[];T=[M];continue}if(u.indexOf(".")>-1){d=u.split("."),h=d[0];var D=d[1];for(h||(h="*"),m=[],y=0,S=0;S<T.length;S++)for(h=="*"?E=e(T[S]):E=T[S].getElementsByTagName(h),x=0;x<E.length;x++)m[y++]=E[x];for(T=[],R=0,S=0;S<m.length;S++)m[S].className&&N.isString(m[S].className)&&n(m[S],D)&&(T[R++]=m[S]);continue}var $=u.match(gW);if($){h=$[1];var U=$[2],P=$[3],Z=$[4];for(h||(h="*"),m=[],y=0,S=0;S<T.length;S++)for(h=="*"?E=e(T[S]):E=T[S].getElementsByTagName(h),x=0;x<E.length;x++)m[y++]=E[x];T=[],R=0;var X;switch(P){case"=":X=function(K){return K.getAttribute(U)==Z};break;case"~":X=function(K){return K.getAttribute(U).match(new RegExp("\\b"+Z+"\\b"))};break;case"|":X=function(K){return K.getAttribute(U).match(new RegExp("^"+Z+"-?"))};break;case"^":X=function(K){return K.getAttribute(U).indexOf(Z)===0};break;case"$":X=function(K){return K.getAttribute(U).lastIndexOf(Z)==K.getAttribute(U).length-Z.length};break;case"*":X=function(K){return K.getAttribute(U).indexOf(Z)>-1};break;default:X=function(K){return K.getAttribute(U)}}for(T=[],R=0,S=0;S<m.length;S++)X(m[S])&&(T[R++]=m[S]);continue}for(h=u,m=[],y=0,S=0;S<T.length;S++)for(E=T[S].getElementsByTagName(h),x=0;x<E.length;x++)m[y++]=E[x];T=m}return T}return function(a){return N.isElement(a)?[a]:N.isObject(a)&&!N.isUndefined(a.length)?a:r.call(this,a)}}();var mW=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","utm_id","utm_source_platform","utm_campaign_id","utm_creative_format","utm_marketing_tactic"],vW=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","sccid","ttclid","twclid","wbraid"];N.info={campaignParams:function(e){var t="",n={};return N.each(mW,function(r){t=N.getQueryParam(jn.URL,r),t.length?n[r]=t:e!==void 0&&(n[r]=e)}),n},clickParams:function(){var e="",t={};return N.each(vW,function(n){e=N.getQueryParam(jn.URL,n),e.length&&(t[n]=e)}),t},marketingParams:function(){return N.extend(N.info.campaignParams(),N.info.clickParams())},searchEngine:function(e){return e.search("https?://(.*)google.([^/?]*)")===0?"google":e.search("https?://(.*)bing.com")===0?"bing":e.search("https?://(.*)yahoo.com")===0?"yahoo":e.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null},searchInfo:function(e){var t=N.info.searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(t!==null){r.$search_engine=t;var a=N.getQueryParam(e,n);a.length&&(r.mp_keyword=a)}return r},browser:function(e,t,n){return t=t||"",n||N.includes(e," OPR/")?N.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":N.includes(e,"IEMobile")||N.includes(e,"WPDesktop")?"Internet Explorer Mobile":N.includes(e,"SamsungBrowser/")?"Samsung Internet":N.includes(e,"Edge")||N.includes(e,"Edg/")?"Microsoft Edge":N.includes(e,"FBIOS")?"Facebook Mobile":N.includes(e,"Chrome")?"Chrome":N.includes(e,"CriOS")?"Chrome iOS":N.includes(e,"UCWEB")||N.includes(e,"UCBrowser")?"UC Browser":N.includes(e,"FxiOS")?"Firefox iOS":N.includes(t,"Apple")?N.includes(e,"Mobile")?"Mobile Safari":"Safari":N.includes(e,"Android")?"Android Mobile":N.includes(e,"Konqueror")?"Konqueror":N.includes(e,"Firefox")?"Firefox":N.includes(e,"MSIE")||N.includes(e,"Trident/")?"Internet Explorer":N.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,n){var r=N.info.browser(e,t,n),a={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/},s=a[r];if(s===void 0)return null;var u=e.match(s);return u?parseFloat(u[u.length-2]):null},os:function(){var e=nc;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},device:function(e){return/Windows Phone/i.test(e)||/WPDesktop/.test(e)?"Windows Phone":/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Android/.test(e)?"Android":""},referringDomain:function(e){var t=e.split("/");return t.length>=3?t[2]:""},currentUrl:function(){return ct.location.href},properties:function(e){return typeof e!="object"&&(e={}),N.extend(N.strip_empty_properties({$os:N.info.os(),$browser:N.info.browser(nc,Df.vendor,Hw),$referrer:jn.referrer,$referring_domain:N.info.referringDomain(jn.referrer),$device:N.info.device(nc)}),{$current_url:N.info.currentUrl(),$browser_version:N.info.browserVersion(nc,Df.vendor,Hw),$screen_height:XL.height,$screen_width:XL.width,mp_lib:"web",$lib_version:hl.LIB_VERSION,$insert_id:QR(),time:N.timestamp()/1e3},N.strip_empty_properties(e))},people_properties:function(){return N.extend(N.strip_empty_properties({$os:N.info.os(),$browser:N.info.browser(nc,Df.vendor,Hw)}),{$browser_version:N.info.browserVersion(nc,Df.vendor,Hw)})},mpPageViewProperties:function(){return N.strip_empty_properties({current_page_title:jn.title,current_domain:ct.location.hostname,current_url_path:ct.location.pathname,current_url_protocol:ct.location.protocol,current_url_search:ct.location.search})}};var yW=function(e,t){var n=null,r=[];return function(a){var s=this;return r.push(a),n||(n=new Pn(function(u){setTimeout(function(){var d=e.apply(s,[r]);n=null,r=[],u(d)},t)})),n}},QR=function(e){var t=Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10);return e?t.substring(0,e):t},bW=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,_W=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,iN=function(e){var t=_W,n=e.split("."),r=n[n.length-1];(r.length>4||r==="com"||r==="org")&&(t=bW);var a=e.match(t);return a?a[0]:""},SW=function(){var e=ct.navigator.onLine;return N.isUndefined(e)||e},If=function(){},Gg=null,Pw=null;typeof JSON<"u"&&(Gg=JSON.stringify,Pw=JSON.parse),Gg=Gg||N.JSONEncode,Pw=Pw||N.JSONDecode,N.info=N.info,N.info.browser=N.info.browser,N.info.browserVersion=N.info.browserVersion,N.info.device=N.info.device,N.info.properties=N.info.properties,N.isBlockedUA=N.isBlockedUA,N.isEmptyObject=N.isEmptyObject,N.isObject=N.isObject,N.JSONDecode=N.JSONDecode,N.JSONEncode=N.JSONEncode,N.toArray=N.toArray,N.NPO=Of;var wW="mixpanelBrowserDb",aN="mixpanelRecordingEvents",KR="mixpanelRecordingRegistry",xW=1,CW=[aN,KR],eu=function(e){this.dbPromise=null,this.storeName=e};eu.prototype._openDb=function(){return new Pn(function(e,t){var n=ct.indexedDB.open(wW,xW);n.onerror=function(){t(n.error)},n.onsuccess=function(){e(n.result)},n.onupgradeneeded=function(r){var a=r.target.result;CW.forEach(function(s){a.createObjectStore(s)})}})},eu.prototype.init=function(){return ct.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof ct.IDBDatabase?Pn.resolve():Pn.reject(e)})):Pn.reject("indexedDB is not supported in this browser")},eu.prototype.makeTransaction=function(e,t){var n=this.storeName,r=function(a){return new Pn(function(s,u){var d=a.transaction(n,e);d.oncomplete=function(){s(d)},d.onabort=d.onerror=function(){u(d.error)},t(d.objectStore(n))})};return this.dbPromise.then(r).catch((function(a){return a&&a.name==="InvalidStateError"?(this.dbPromise=this._openDb(),this.dbPromise.then(r)):Pn.reject(a)}).bind(this))},eu.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(n){n.put(t,e)})},eu.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},eu.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},eu.prototype.getAll=function(){var e;return this.makeTransaction("readonly",function(t){e=t.getAll()}).then(function(){return e.result})};var EW="__mp_opt_in_out_";function AW(e,t){lN(!0,e,t)}function TW(e,t){lN(!1,e,t)}function kW(e,t){return sN(e,t)==="1"}function oN(e,t){if(OW(t))return zn.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"'),!0;var n=sN(e,t)==="0";return n&&zn.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),n}function Lf(e){return JR(e,function(t){return this.get_config(t)})}function Nf(e){return JR(e,function(t){return this._get_config(t)})}function Vg(e){return JR(e,function(t){return this._get_config(t)})}function RW(e,t){t=t||{},XR(t).remove(WR(e,t),!!t.crossSubdomainCookie,t.cookieDomain)}function XR(e){return e=e||{},e.persistenceType==="localStorage"?N.localStorage:N.cookie}function WR(e,t){return t=t||{},(t.persistencePrefix||EW)+e}function sN(e,t){return XR(t).get(WR(e,t))}function OW(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||ct,n=t.navigator||{},r=!1;return N.each([n.doNotTrack,n.msDoNotTrack,t.doNotTrack],function(a){N.includes([!0,1,"1","yes"],a)&&(r=!0)}),r}function lN(e,t,n){if(!N.isString(t)||!t.length){zn.error("gdpr."+(e?"optIn":"optOut")+" called with an invalid token");return}n=n||{},XR(n).set(WR(t,n),e?1:0,N.isNumber(n.cookieExpiration)?n.cookieExpiration:null,!!n.crossSubdomainCookie,!!n.secureCookie,!!n.crossSiteCookie,n.cookieDomain),n.track&&e&&n.track(n.trackEventName||"$opt_in",n.trackProperties,{send_immediately:!0})}function JR(e,t){return function(){var n=!1;try{var r=t.call(this,"token"),a=t.call(this,"ignore_dnt"),s=t.call(this,"opt_out_tracking_persistence_type"),u=t.call(this,"opt_out_tracking_cookie_prefix"),d=t.call(this,"window");r&&(n=oN(r,{ignoreDnt:a,persistenceType:s,persistencePrefix:u,window:d}))}catch(m){zn.error("Unexpected error when checking tracking opt-out status: "+m)}if(!n)return e.apply(this,arguments);var h=arguments[arguments.length-1];typeof h=="function"&&h(0)}}var MW=jg("lock"),uN=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||ct.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||Pn};uN.prototype.withLock=function(e,t){var n=this.promiseImpl;return new n(N.bind(function(r,a){var s=t||new Date().getTime()+"|"+Math.random(),u=new Date().getTime(),d=this.storageKey,h=this.pollIntervalMS,m=this.timeoutMS,y=this.storage,v=d+":X",S=d+":Y",x=d+":Z",E=function(D){if(new Date().getTime()-u>m){MW.error("Timeout waiting for mutex on "+d+"; clearing lock. ["+s+"]"),y.removeItem(x),y.removeItem(S),A();return}setTimeout(function(){try{D()}catch($){a($)}},h*(Math.random()+.1))},R=function(D,$){D()?$():E(function(){R(D,$)})},T=function(){var D=y.getItem(S);return D&&D!==s?!1:(y.setItem(S,s),y.getItem(S)===s?!0:(H0(y,!0)||a(new Error("localStorage support dropped while acquiring lock")),!1))},A=function(){y.setItem(v,s),R(T,function(){if(y.getItem(v)===s){M();return}E(function(){if(y.getItem(S)!==s){A();return}R(function(){return!y.getItem(x)},M)})})},M=function(){y.setItem(x,"1");var D=function(){y.removeItem(x),y.getItem(S)===s&&y.removeItem(S),y.getItem(v)===s&&y.removeItem(v)};e().then(function($){D(),r($)}).catch(function($){D(),a($)})};try{if(H0(y,!0))A();else throw new Error("localStorage support check failed")}catch(D){a(D)}},this))};var P0=function(e){this.storage=e||ct.localStorage};P0.prototype.init=function(){return Pn.resolve()},P0.prototype.setItem=function(e,t){return new Pn(N.bind(function(n,r){try{this.storage.setItem(e,Gg(t))}catch(a){r(a)}n()},this))},P0.prototype.getItem=function(e){return new Pn(N.bind(function(t,n){var r;try{r=Pw(this.storage.getItem(e))}catch(a){n(a)}t(r)},this))},P0.prototype.removeItem=function(e){return new Pn(N.bind(function(t,n){try{this.storage.removeItem(e)}catch(r){n(r)}t()},this))};var cN=jg("batch"),tu=function(e,t){t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new P0,this.lock=new uN(e,{storage:t.sharedLockStorage||ct.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||N.bind(cN.error,cN),this.pid=t.pid||null,this.memQueue=[],this.initialized=!1,t.enqueueThrottleMs?this.enqueuePersisted=yW(N.bind(this._enqueuePersisted,this),t.enqueueThrottleMs):this.enqueuePersisted=N.bind(function(n){return this._enqueuePersisted([n])},this)};tu.prototype.ensureInit=function(){return this.initialized?Pn.resolve():this.queueStorage.init().then(N.bind(function(){this.initialized=!0},this)).catch(N.bind(function(e){this.reportError("Error initializing queue persistence. Disabling persistence",e),this.initialized=!0,this.usePersistence=!1},this))},tu.prototype.enqueue=function(e,t){var n={id:QR(),flushAfter:new Date().getTime()+t*2,payload:e};return this.usePersistence?this.enqueuePersisted(n):(this.memQueue.push(n),Pn.resolve(!0))},tu.prototype._enqueuePersisted=function(e){var t=N.bind(function(){return this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(n){return this.saveToStorage(n.concat(e))},this)).then(N.bind(function(n){return n&&(this.memQueue=this.memQueue.concat(e)),n},this)).catch(N.bind(function(n){return this.reportError("Error enqueueing items",n,e),!1},this))},this);return this.lock.withLock(t,this.pid).catch(N.bind(function(n){return this.reportError("Error acquiring storage lock",n),!1},this))},tu.prototype.fillBatch=function(e){var t=this.memQueue.slice(0,e);return this.usePersistence&&t.length<e?this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(n){if(n.length){var r={};N.each(t,function(u){r[u.id]=!0});for(var a=0;a<n.length;a++){var s=n[a];if(new Date().getTime()>s.flushAfter&&!r[s.id]&&(s.orphaned=!0,t.push(s),t.length>=e))break}}return t},this)):Pn.resolve(t)};var fN=function(e,t){var n=[];return N.each(e,function(r){r.id&&!t[r.id]&&n.push(r)}),n};tu.prototype.removeItemsByID=function(e){var t={};if(N.each(e,function(r){t[r]=!0}),this.memQueue=fN(this.memQueue,t),this.usePersistence){var n=N.bind(function(){return this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(r){return r=fN(r,t),this.saveToStorage(r)},this)).then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(r){for(var a=0;a<r.length;a++){var s=r[a];if(s.id&&t[s.id])throw new Error("Item not removed from storage")}return!0},this)).catch(N.bind(function(r){return this.reportError("Error removing items",r,e),!1},this))},this);return this.lock.withLock(n,this.pid).catch(N.bind(function(r){return this.reportError("Error acquiring storage lock",r),H0(this.lock.storage,!0)?!1:n().then(N.bind(function(a){return a||this.queueStorage.removeItem(this.storageKey).then(function(){return a})},this)).catch(N.bind(function(a){return this.reportError("Error clearing queue",a),!1},this))},this))}else return Pn.resolve(!0)};var dN=function(e,t){var n=[];return N.each(e,function(r){var a=r.id;if(a in t){var s=t[a];s!==null&&(r.payload=s,n.push(r))}else n.push(r)}),n};tu.prototype.updatePayloads=function(e){return this.memQueue=dN(this.memQueue,e),this.usePersistence?this.lock.withLock(N.bind(function(){return this.ensureInit().then(N.bind(function(){return this.readFromStorage()},this)).then(N.bind(function(n){return n=dN(n,e),this.saveToStorage(n)},this)).catch(N.bind(function(n){return this.reportError("Error updating items",e,n),!1},this))},this),this.pid).catch(N.bind(function(t){return this.reportError("Error acquiring storage lock",t),!1},this)):Pn.resolve(!0)},tu.prototype.readFromStorage=function(){return this.ensureInit().then(N.bind(function(){return this.queueStorage.getItem(this.storageKey)},this)).then(N.bind(function(e){return e&&(N.isArray(e)||(this.reportError("Invalid storage entry:",e),e=null)),e||[]},this)).catch(N.bind(function(e){return this.reportError("Error retrieving queue",e),[]},this))},tu.prototype.saveToStorage=function(e){return this.ensureInit().then(N.bind(function(){return this.queueStorage.setItem(this.storageKey,e)},this)).then(function(){return!0}).catch(N.bind(function(t){return this.reportError("Error saving queue",t),!1},this))},tu.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(N.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):Pn.resolve()};var DW=10*60*1e3,q0=jg("batch"),ss=function(e,t){this.errorReporter=t.errorReporter,this.queue=new tu(e,{errorReporter:N.bind(this.reportError,this),queueStorage:t.queueStorage,sharedLockStorage:t.sharedLockStorage,sharedLockTimeoutMS:t.sharedLockTimeoutMS,usePersistence:t.usePersistence,enqueueThrottleMs:t.enqueueThrottleMs}),this.libConfig=t.libConfig,this.sendRequest=t.sendRequestFunc,this.beforeSendHook=t.beforeSendHook,this.stopAllBatching=t.stopAllBatchingFunc,this.batchSize=this.libConfig.batch_size,this.flushInterval=this.libConfig.batch_flush_interval_ms,this.stopped=!this.libConfig.batch_autostart,this.consecutiveRemovalFailures=0,this.itemIdsSentSuccessfully={},this.flushOnlyOnInterval=t.flushOnlyOnInterval||!1,this._flushPromise=null};ss.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},ss.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},ss.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},ss.prototype.clear=function(){return this.queue.clear()},ss.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},ss.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},ss.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(N.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},ss.prototype.sendRequestPromise=function(e,t){return new Pn(N.bind(function(n){this.sendRequest(e,t,n)},this))},ss.prototype.flush=function(e){if(this.requestInProgress)return q0.log("Flush: Request already in progress"),Pn.resolve();this.requestInProgress=!0,e=e||{};var t=this.libConfig.batch_request_timeout_ms,n=new Date().getTime(),r=this.batchSize;return this.queue.fillBatch(r).then(N.bind(function(a){var s=a.length===r,u=[],d={};if(N.each(a,function(v){var S=v.payload;if(this.beforeSendHook&&!v.orphaned&&(S=this.beforeSendHook(S)),S){S.event&&S.properties&&(S.properties=N.extend({},S.properties,{mp_sent_by_lib_version:hl.LIB_VERSION}));var x=!0,E=v.id;E?(this.itemIdsSentSuccessfully[E]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:v,batchSize:a.length,timesSent:this.itemIdsSentSuccessfully[E]}),x=!1):this.reportError("[dupe] found item with no ID",{item:v}),x&&u.push(S)}d[v.id]=S},this),u.length<1)return this.requestInProgress=!1,this.resetFlush(),Pn.resolve();var h=N.bind(function(){return this.queue.removeItemsByID(N.map(a,function(v){return v.id})).then(N.bind(function(v){return N.each(a,N.bind(function(S){var x=S.id;x?(this.itemIdsSentSuccessfully[x]=this.itemIdsSentSuccessfully[x]||0,this.itemIdsSentSuccessfully[x]++,this.itemIdsSentSuccessfully[x]>5&&this.reportError("[dupe] item ID sent too many times",{item:S,batchSize:a.length,timesSent:this.itemIdsSentSuccessfully[x]})):this.reportError("[dupe] found item with no ID while removing",{item:S})},this)),v?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!s?(this.resetFlush(),Pn.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),Pn.resolve())},this))},this),m=N.bind(function(v){this.requestInProgress=!1;try{if(e.unloading)return this.queue.updatePayloads(d);if(N.isObject(v)&&v.error==="timeout"&&new Date().getTime()-n>=t)return this.reportError("Network timeout; retrying"),this.flush();if(N.isObject(v)&&(v.httpStatusCode>=500||v.httpStatusCode===429||v.httpStatusCode<=0&&!SW()||v.error==="timeout")){var S=this.flushInterval*2;return v.retryAfter&&(S=parseInt(v.retryAfter,10)*1e3||S),S=Math.min(DW,S),this.reportError("Error; retry in "+S+" ms"),this.scheduleFlush(S),Pn.resolve()}else if(N.isObject(v)&&v.httpStatusCode===413)if(a.length>1){var x=Math.max(1,Math.floor(r/2));return this.batchSize=Math.min(this.batchSize,x,a.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush(),Pn.resolve()}else return this.reportError("Single-event request too large; dropping",a),this.resetBatchSize(),h();else return h()}catch(E){this.reportError("Error handling API response",E),this.resetFlush()}},this),y={method:"POST",verbose:!0,ignore_json_errors:!0,timeout_ms:t};return e.unloading&&(y.transport="sendBeacon"),q0.log("MIXPANEL REQUEST:",u),this.sendRequestPromise(u,y).then(m)},this)).catch(N.bind(function(a){this.reportError("Error flushing request queue",a),this.resetFlush()},this))},ss.prototype.reportError=function(e,t){if(q0.error.apply(q0.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(n){q0.error(n)}};var eO=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},IW=250,Yg=jg("recorder"),hN=ct.CompressionStream,LW={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},NW=new Set([Gt.MouseMove,Gt.MouseInteraction,Gt.Scroll,Gt.ViewportResize,Gt.Input,Gt.TouchMove,Gt.MediaInteraction,Gt.Drag,Gt.Selection]);function $W(e){return e.type===En.IncrementalSnapshot&&NW.has(e.data.source)}var da=function(e){this._mixpanel=e.mixpanelInstance,this._onIdleTimeout=e.onIdleTimeout||If,this._onMaxLengthReached=e.onMaxLengthReached||If,this._onBatchSent=e.onBatchSent||If,this._rrwebRecord=e.rrwebRecord||null,this._stopRecording=null,this.replayId=e.replayId,this.batchStartUrl=e.batchStartUrl||null,this.replayStartUrl=e.replayStartUrl||null,this.idleExpires=e.idleExpires||null,this.maxExpires=e.maxExpires||null,this.replayStartTime=e.replayStartTime||null,this.seqNo=e.seqNo||0,this.idleTimeoutId=null,this.maxTimeoutId=null,this.recordMaxMs=U0,this.recordMinMs=0;var t=H0(e.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new eu(aN),this.batcher=new ss(this.batcherKey,{errorReporter:this.reportError.bind(this),flushOnlyOnInterval:!0,libConfig:LW,sendRequestFunc:this.flushEventsWithOptOut.bind(this),queueStorage:this.queueStorage,sharedLockStorage:e.sharedLockStorage,usePersistence:t,stopAllBatchingFunc:this.stopRecording.bind(this),enqueueThrottleMs:IW,sharedLockTimeoutMS:10*1e3})};da.prototype.unloadPersistedData=function(){return this.batcher.stop(),this.batcher.flush().then((function(){return this.queueStorage.removeItem(this.batcherKey)}).bind(this))},da.prototype.getConfig=function(e){return this._mixpanel.get_config(e)},da.prototype.get_config=function(e){return this.getConfig(e)},da.prototype.startRecording=function(e){if(this._rrwebRecord===null){this.reportError("rrweb record function not provided. ");return}if(this._stopRecording!==null){Yg.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>U0&&(this.recordMaxMs=U0,Yg.critical("record_max_ms cannot be greater than "+U0+"ms. Capping value.")),this.maxExpires||(this.maxExpires=new Date().getTime()+this.recordMaxMs),this.recordMinMs=this.getConfig("record_min_ms"),this.recordMinMs>qR&&(this.recordMinMs=qR,Yg.critical("record_min_ms cannot be greater than "+qR+"ms. Capping value.")),this.replayStartTime||(this.replayStartTime=new Date().getTime(),this.batchStartUrl=N.info.currentUrl(),this.replayStartUrl=N.info.currentUrl()),e||this.recordMinMs>0?this.batcher.stop():this.batcher.start();var t=(function(){clearTimeout(this.idleTimeoutId);var a=this.getConfig("record_idle_timeout_ms");this.idleTimeoutId=setTimeout(this._onIdleTimeout,a),this.idleExpires=new Date().getTime()+a}).bind(this);t();var n=this.getConfig("record_block_selector");(n===""||n===null)&&(n=void 0);try{this._stopRecording=this._rrwebRecord({emit:(function(a){if(this.idleExpires&&this.idleExpires<a.timestamp){this._onIdleTimeout();return}$W(a)&&(this.batcher.stopped&&new Date().getTime()-this.replayStartTime>=this.recordMinMs&&this.batcher.start(),t()),this.__enqueuePromise=this.batcher.enqueue(a)}).bind(this),blockClass:this.getConfig("record_block_class"),blockSelector:n,collectFonts:this.getConfig("record_collect_fonts"),dataURLOptions:{type:"image/webp",quality:.6},maskAllInputs:!0,maskTextClass:this.getConfig("record_mask_text_class"),maskTextSelector:this.getConfig("record_mask_text_selector"),recordCanvas:this.getConfig("record_canvas"),sampling:{canvas:15}})}catch(a){this.reportError("Unexpected error when starting rrweb recording.",a)}if(typeof this._stopRecording!="function"){this.reportError("rrweb failed to start, skipping this recording."),this._stopRecording=null,this.stopRecording();return}var r=this.maxExpires-new Date().getTime();this.maxTimeoutId=setTimeout(this._onMaxLengthReached.bind(this),r)},da.prototype.stopRecording=function(e){if(!this.isRrwebStopped()){try{this._stopRecording()}catch(n){this.reportError("Error with rrweb stopRecording",n)}this._stopRecording=null}var t;return this.batcher.stopped?t=this.batcher.clear():e||(t=this.batcher.flush()),this.batcher.stop(),clearTimeout(this.idleTimeoutId),clearTimeout(this.maxTimeoutId),t},da.prototype.isRrwebStopped=function(){return this._stopRecording===null},da.prototype.flushEventsWithOptOut=function(e,t,n){var r=(function(a){a===0&&(this.stopRecording(),n({error:"Tracking has been opted out, stopping recording."}))}).bind(this);this._flushEvents(e,t,n,r)},da.prototype.serialize=function(){var e;try{e=this._mixpanel.get_tab_id()}catch(t){this.reportError("Error getting tab ID for serialization ",t),e=null}return{replayId:this.replayId,seqNo:this.seqNo,replayStartTime:this.replayStartTime,batchStartUrl:this.batchStartUrl,replayStartUrl:this.replayStartUrl,idleExpires:this.idleExpires,maxExpires:this.maxExpires,tabId:e}},da.deserialize=function(e,t){var n=new da(N.extend({},t,{replayId:e.replayId,batchStartUrl:e.batchStartUrl,replayStartUrl:e.replayStartUrl,idleExpires:e.idleExpires,maxExpires:e.maxExpires,replayStartTime:e.replayStartTime,seqNo:e.seqNo,sharedLockStorage:t.sharedLockStorage}));return n},da.prototype._sendRequest=function(e,t,n,r){var a=(function(s,u){s.status===200&&this.replayId===e&&(this.seqNo++,this.batchStartUrl=N.info.currentUrl()),this._onBatchSent(),r({status:0,httpStatusCode:s.status,responseBody:u,retryAfter:s.headers.get("Retry-After")})}).bind(this);ct.fetch(this.getConfig("api_host")+"/"+this.getConfig("api_routes").record+"?"+new URLSearchParams(t),{method:"POST",headers:{Authorization:"Basic "+btoa(this.getConfig("token")+":"),"Content-Type":"application/octet-stream"},body:n}).then(function(s){s.json().then(function(u){a(s,u)}).catch(function(u){r({error:u})})}).catch(function(s){r({error:s,httpStatusCode:0})})},da.prototype._flushEvents=Lf(function(e,t,n){var r=e.length;if(r>0){for(var a=this.replayId,s=1/0,u=-1/0,d=!1,h=0;h<r;h++)s=Math.min(s,e[h].timestamp),u=Math.max(u,e[h].timestamp),e[h].type===En.FullSnapshot&&(d=!0);if(this.seqNo===0){if(!d){n({error:"First batch does not contain a full snapshot. Aborting recording."}),this.stopRecording(!0);return}this.replayStartTime=s}else this.replayStartTime||(this.reportError("Replay start time not set but seqNo is not 0. Using current batch start time as a fallback."),this.replayStartTime=s);var m=u-this.replayStartTime,y={$current_url:this.batchStartUrl,$lib_version:hl.LIB_VERSION,batch_start_time:s/1e3,distinct_id:String(this._mixpanel.get_distinct_id()),mp_lib:"web",replay_id:a,replay_length_ms:m,replay_start_time:this.replayStartTime/1e3,replay_start_url:this.replayStartUrl,seq:this.seqNo},v=JSON.stringify(e),S=this._mixpanel.get_property("$device_id");S&&(y.$device_id=S);var x=this._mixpanel.get_property("$user_id");if(x&&(y.$user_id=x),hN){var E=new Blob([v],{type:"application/json"}).stream(),R=E.pipeThrough(new hN("gzip"));new Response(R).blob().then((function(T){y.format="gzip",this._sendRequest(a,y,T,n)}).bind(this))}else y.format="body",this._sendRequest(a,y,v,n)}}),da.prototype.reportError=function(e,t){Yg.error.apply(Yg.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(n){Yg.error(n)}};var Zg=function(e){this.idb=new eu(KR),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};Zg.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},Zg.prototype.setActiveRecording=function(e){var t=e.tabId;return t?this.idb.init().then((function(){return this.idb.setItem(t,e)}).bind(this)).catch(this.handleError.bind(this)):(console.warn("No tab ID is set, cannot persist recording metadata."),Pn.resolve())},Zg.prototype.getActiveRecording=function(){return this.idb.init().then((function(){return this.idb.getItem(this.mixpanelInstance.get_tab_id())}).bind(this)).then((function(e){return eO(e)?null:e}).bind(this)).catch(this.handleError.bind(this))},Zg.prototype.clearActiveRecording=function(){return this.getActiveRecording().then((function(e){if(e)return e.maxExpires=0,this.setActiveRecording(e)}).bind(this)).catch(this.handleError.bind(this))},Zg.prototype.flushInactiveRecordings=function(){return this.idb.init().then((function(){return this.idb.getAll()}).bind(this)).then((function(e){var t=e.filter(function(n){return eO(n)}).map((function(n){var r=da.deserialize(n,{mixpanelInstance:this.mixpanelInstance,sharedLockStorage:this.sharedLockStorage});return r.unloadPersistedData().then((function(){return this.idb.removeItem(n.tabId)}).bind(this)).catch(this.handleError.bind(this))}).bind(this));return Pn.all(t)}).bind(this)).catch(this.handleError.bind(this))};var F0=jg("recorder"),rc=function(e,t,n){this.mixpanelInstance=e,this.rrwebRecord=t||kf,this.sharedLockStorage=n,this.recordingRegistry=new Zg({mixpanelInstance:this.mixpanelInstance,errorReporter:F0.error,sharedLockStorage:n}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null};rc.prototype.startRecording=function(e){if(e=e||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){F0.log("Recording already in progress, skipping startRecording.");return}var t=(function(){F0.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),n=(function(){F0.log("Max recording length reached, stopping recording."),this.resetRecording()}).bind(this),r=(function(){this.recordingRegistry.setActiveRecording(this.activeRecording.serialize()),this.__flushPromise=this.activeRecording.batcher._flushPromise}).bind(this),a={mixpanelInstance:this.mixpanelInstance,onBatchSent:r,onIdleTimeout:t,onMaxLengthReached:n,replayId:N.UUID(),rrwebRecord:this.rrwebRecord,sharedLockStorage:this.sharedLockStorage};return e.activeSerializedRecording?this.activeRecording=da.deserialize(e.activeSerializedRecording,a):this.activeRecording=new da(a),this.activeRecording.startRecording(e.shouldStopBatcher),this.recordingRegistry.setActiveRecording(this.activeRecording.serialize())},rc.prototype.stopRecording=function(){var e=this._stopCurrentRecording(!1);return this.recordingRegistry.clearActiveRecording(),this.activeRecording=null,e},rc.prototype.pauseRecording=function(){return this._stopCurrentRecording(!1)},rc.prototype._stopCurrentRecording=function(e){return this.activeRecording?this.activeRecording.stopRecording(e):Pn.resolve()},rc.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),Pn.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(t){return t?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):(F0.log("No resumable recording found."),null)}).bind(this))},rc.prototype.resetRecording=function(){this.stopRecording(),this.startRecording({shouldStopBatcher:!0})},rc.prototype.getActiveReplayId=function(){return this.activeRecording&&!this.activeRecording.isRrwebStopped()?this.activeRecording.replayId:null},Object.defineProperty(rc.prototype,"replayId",{get:function(){return this.getActiveReplayId()}}),ct.__mp_recorder=rc;var qw="change",j0="click",pN="hashchange",Qg="mp_locationchange",gN="popstate",mN="scrollend",tO="submit",BW=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],vN=["mp-include"],nO=["mp-no-track"],yN=nO.concat(["mp-sensitive"]),UW=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],ao=jg("autocapture");function rO(e){for(var t={},n=bN(e).split(" "),r=0;r<n.length;r++){var a=n[r];a&&(t[a]=!0)}return t}function bN(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function zW(e){if(e.previousElementSibling)return e.previousElementSibling;do e=e.previousSibling;while(e&&!wN(e));return e}function _N(e,t,n,r,a,s){var u={$classes:bN(e).split(" "),$tag_name:e.tagName.toLowerCase()},d=e.id;d&&(u.$id=d),oO(e,t,a,s)&&N.each(UW.concat(r),function(v){if(e.hasAttribute(v)&&!n[v]){var S=e.getAttribute(v);Fw(S)&&(u["$attr-"+v]=S)}});for(var h=1,m=1,y=e;y=zW(y);)h++,y.tagName===e.tagName&&m++;return u.$nth_child=h,u.$nth_of_type=m,u}function HW(e,t){var n=t.allowElementCallback,r=t.allowSelectors||[],a=t.blockAttrs||[],s=t.blockElementCallback,u=t.blockSelectors||[],d=t.captureTextContent||!1,h=t.captureExtraAttrs||[],m={};N.each(a,function($){m[$]=!0});var y=null,v=typeof e.target>"u"?e.srcElement:e.target;if(xN(v)&&(v=v.parentNode),FW(v,e)&&iO(v,e,n,r)&&!aO(v,e,s,u)){for(var S=[v],x=v;x.parentNode&&!nu(x,"body");)S.push(x.parentNode),x=x.parentNode;var E=[],R,T=!1;if(N.each(S,function($){var U=oO($,e,n,r);!m.href&&$.tagName.toLowerCase()==="a"&&(R=$.getAttribute("href"),R=U&&Fw(R)&&R),aO($,e,s,u)&&(T=!0),E.push(_N($,e,m,h,n,r))},this),!T){var A=jn.documentElement;if(y={$event_type:e.type,$host:ct.location.host,$pathname:ct.location.pathname,$elements:E,$el_attr__href:R,$viewportHeight:Math.max(A.clientHeight,ct.innerHeight||0),$viewportWidth:Math.max(A.clientWidth,ct.innerWidth||0)},N.each(h,function($){if(!m[$]&&v.hasAttribute($)){var U=v.getAttribute($);Fw(U)&&(y["$el_attr__"+$]=U)}}),d&&(M=SN(v,e,n,r),M&&M.length&&(y.$el_text=M)),e.type===j0&&(N.each(BW,function($){$ in e&&(y["$"+$]=e[$])}),v=PW(e)),d){var M=SN(v,e,n,r);M&&M.length&&(y.$el_text=M)}if(v){if(!iO(v,e,n,r)||aO(v,e,s,u))return null;var D=_N(v,e,m,h,n,r);y.$target=D,y.$el_classes=D.$classes,N.extend(y,N.strip_empty_properties({$el_id:D.$id,$el_tag_name:D.$tag_name}))}}}return y}function SN(e,t,n,r){var a="";return oO(e,t,n,r)&&e.childNodes&&e.childNodes.length&&N.each(e.childNodes,function(s){xN(s)&&s.textContent&&(a+=N.trim(s.textContent).split(/(\s+)/).filter(Fw).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),N.trim(a)}function PW(e){for(var t=e.target,n=e.composedPath(),r=0;r<n.length;r++){var a=n[r];if(nu(a,"a")||nu(a,"button")||nu(a,"input")||nu(a,"select")||a.getAttribute&&a.getAttribute("role")==="button"){t=a;break}if(a===t)break}return t}function iO(e,t,n,r){if(n)try{if(!n(e,t))return!1}catch(u){return ao.critical("Error while checking element in allowElementCallback",u),!1}if(!r.length)return!0;for(var a=0;a<r.length;a++){var s=r[a];try{if(e.matches(s))return!0}catch(u){ao.critical("Error while checking selector: "+s,u)}}return!1}function aO(e,t,n,r){var a;if(n)try{if(n(e,t))return!0}catch(d){return ao.critical("Error while checking element in blockElementCallback",d),!0}if(r&&r.length)for(a=0;a<r.length;a++){var s=r[a];try{if(e.matches(s))return!0}catch(d){ao.critical("Error while checking selector: "+s,d)}}var u=rO(e);for(a=0;a<nO.length;a++)if(u[nO[a]])return!0;return!1}function wN(e){return e&&e.nodeType===1}function nu(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function xN(e){return e&&e.nodeType===3}function qW(){try{var e=jn.createElement("div");return!!e.matches}catch{return!1}}function FW(e,t){if(!e||nu(e,"html")||!wN(e))return!1;var n=e.tagName.toLowerCase();switch(n){case"form":return t.type===tO;case"input":return["button","submit"].indexOf(e.getAttribute("type"))===-1?t.type===qw:t.type===j0;case"select":case"textarea":return t.type===qw;default:return t.type===j0}}function oO(e,t,n,r){var a;if(!iO(e,t,n,r))return!1;for(var s=e;s.parentNode&&!nu(s,"body");s=s.parentNode){var u=rO(s);for(a=0;a<yN.length;a++)if(u[yN[a]])return!1}var d=rO(e);for(a=0;a<vN.length;a++)if(d[vN[a]])return!0;if(nu(e,"input")||nu(e,"select")||nu(e,"textarea")||e.getAttribute("contenteditable")==="true")return!1;var h=e.type||"";if(typeof h=="string")switch(h.toLowerCase()){case"hidden":return!1;case"password":return!1}var m=e.name||e.id||"";if(typeof m=="string"){var y=/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;if(y.test(m.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function Fw(e){if(e===null||N.isUndefined(e))return!1;if(typeof e=="string"){e=N.trim(e);var t=/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;if(t.test((e||"").replace(/[- ]/g,"")))return!1;var n=/(^\d{3}-?\d{2}-?\d{4}$)/;if(n.test(e))return!1}return!0}var CN="autocapture",jW="track_pageview",EN="full-url",GW="url-with-path-and-query-string",VW="url-with-path",YW="allow_element_callback",AN="allow_selectors",TN="allow_url_regexes",kN="block_attrs",RN="block_element_callback",ON="block_selectors",MN="block_url_regexes",DN="capture_extra_attrs",IN="capture_text_content",LN="scroll_capture_all",NN="scroll_depth_percent_checkpoints",sO="click",lO="input",$N="pageview",uO="scroll",cO="submit",Gi={};Gi[AN]=[],Gi[TN]=[],Gi[kN]=[],Gi[RN]=null,Gi[ON]=[],Gi[MN]=[],Gi[DN]=[],Gi[IN]=!1,Gi[LN]=!1,Gi[NN]=[25,50,75,100],Gi[sO]=!0,Gi[lO]=!0,Gi[$N]=EN,Gi[uO]=!0,Gi[cO]=!0;var jw={$mp_autocapture:!0},ZW="$mp_click",QW="$mp_input_change",KW="$mp_scroll",XW="$mp_submit",Lo=function(e){this.mp=e};Lo.prototype.init=function(){if(!qW()){ao.critical("Autocapture unavailable: missing required DOM APIs");return}this.initPageviewTracking(),this.initClickTracking(),this.initInputTracking(),this.initScrollTracking(),this.initSubmitTracking()},Lo.prototype.getFullConfig=function(){var e=this.mp.get_config(CN);return e?N.isObject(e)?N.extend({},Gi,e):Gi:{}},Lo.prototype.getConfig=function(e){return this.getFullConfig()[e]},Lo.prototype.currentUrlBlocked=function(){var e,t=N.info.currentUrl(),n=this.getConfig(TN)||[];if(n.length){var r=!1;for(e=0;e<n.length;e++){var a=n[e];try{if(t.match(a)){r=!0;break}}catch(u){return ao.critical("Error while checking block URL regex: "+a,u),!0}}if(!r)return!0}var s=this.getConfig(MN)||[];if(!s||!s.length)return!1;for(e=0;e<s.length;e++)try{if(t.match(s[e]))return!0}catch(u){return ao.critical("Error while checking block URL regex: "+s[e],u),!0}return!1},Lo.prototype.pageviewTrackingConfig=function(){return this.mp.get_config(CN)?this.getConfig($N):this.mp.get_config(jW)},Lo.prototype.trackDomEvent=function(e,t){if(!this.currentUrlBlocked()){var n=HW(e,{allowElementCallback:this.getConfig(YW),allowSelectors:this.getConfig(AN),blockAttrs:this.getConfig(kN),blockElementCallback:this.getConfig(RN),blockSelectors:this.getConfig(ON),captureExtraAttrs:this.getConfig(DN),captureTextContent:this.getConfig(IN)});n&&(N.extend(n,jw),this.mp.track(t,n))}},Lo.prototype.initClickTracking=function(){ct.removeEventListener(j0,this.listenerClick),this.getConfig(sO)&&(ao.log("Initializing click tracking"),this.listenerClick=ct.addEventListener(j0,(function(e){this.getConfig(sO)&&this.trackDomEvent(e,ZW)}).bind(this)))},Lo.prototype.initInputTracking=function(){ct.removeEventListener(qw,this.listenerChange),this.getConfig(lO)&&(ao.log("Initializing input tracking"),this.listenerChange=ct.addEventListener(qw,(function(e){this.getConfig(lO)&&this.trackDomEvent(e,QW)}).bind(this)))},Lo.prototype.initPageviewTracking=function(){if(ct.removeEventListener(gN,this.listenerPopstate),ct.removeEventListener(pN,this.listenerHashchange),ct.removeEventListener(Qg,this.listenerLocationchange),!!this.pageviewTrackingConfig()){ao.log("Initializing pageview tracking");var e="",t=!1;this.currentUrlBlocked()||(t=this.mp.track_pageview(jw)),t&&(e=N.info.currentUrl()),this.listenerPopstate=ct.addEventListener(gN,function(){ct.dispatchEvent(new Event(Qg))}),this.listenerHashchange=ct.addEventListener(pN,function(){ct.dispatchEvent(new Event(Qg))});var n=ct.history.pushState;typeof n=="function"&&(ct.history.pushState=function(a,s,u){n.call(ct.history,a,s,u),ct.dispatchEvent(new Event(Qg))});var r=ct.history.replaceState;typeof r=="function"&&(ct.history.replaceState=function(a,s,u){r.call(ct.history,a,s,u),ct.dispatchEvent(new Event(Qg))}),this.listenerLocationchange=ct.addEventListener(Qg,VR((function(){if(!this.currentUrlBlocked()){var a=N.info.currentUrl(),s=!1,u=a.split("#")[0].split("?")[0]!==e.split("#")[0].split("?")[0],d=this.pageviewTrackingConfig();if(d===EN?s=a!==e:d===GW?s=a.split("#")[0]!==e.split("#")[0]:d===VW&&(s=u),s){var h=this.mp.track_pageview(jw);h&&(e=a),u&&(this.lastScrollCheckpoint=0,ao.log("Path change: re-initializing scroll depth checkpoints"))}}}).bind(this)))}},Lo.prototype.initScrollTracking=function(){ct.removeEventListener(mN,this.listenerScroll),this.getConfig(uO)&&(ao.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=ct.addEventListener(mN,VR((function(){if(this.getConfig(uO)&&!this.currentUrlBlocked()){var e=this.getConfig(LN),t=(this.getConfig(NN)||[]).slice().sort(function(h,m){return h-m}),n=ct.scrollY,r=N.extend({$scroll_top:n},jw);try{var a=jn.body.scrollHeight,s=Math.round(n/(a-ct.innerHeight)*100);if(r.$scroll_height=a,r.$scroll_percentage=s,s>this.lastScrollCheckpoint)for(var u=0;u<t.length;u++){var d=t[u];s>=d&&this.lastScrollCheckpoint<d&&(r.$scroll_checkpoint=d,this.lastScrollCheckpoint=d,e=!0)}}catch(h){ao.critical("Error while calculating scroll percentage",h)}e&&this.mp.track(KW,r)}}).bind(this))))},Lo.prototype.initSubmitTracking=function(){ct.removeEventListener(tO,this.listenerSubmit),this.getConfig(cO)&&(ao.log("Initializing submit tracking"),this.listenerSubmit=ct.addEventListener(tO,(function(e){this.getConfig(cO)&&this.trackDomEvent(e,XW)}).bind(this)))},hW(Lo);var ic=function(){};ic.prototype.create_properties=function(){},ic.prototype.event_handler=function(){},ic.prototype.after_track_handler=function(){},ic.prototype.init=function(e){return this.mp=e,this},ic.prototype.track=function(e,t,n,r){var a=this,s=N.dom_query(e);if(s.length===0){zn.error("The DOM query ("+e+") returned 0 elements");return}return N.each(s,function(u){N.register_event(u,this.override_event,function(d){var h={},m=a.create_properties(n,this),y=a.mp.get_config("track_links_timeout");a.event_handler(d,this,h),window.setTimeout(a.track_callback(r,m,h,!0),y),a.mp.track(t,m,a.track_callback(r,m,h))})},this),!0},ic.prototype.track_callback=function(e,t,n,r){r=r||!1;var a=this;return function(){n.callback_fired||(n.callback_fired=!0,!(e&&e(r,t)===!1)&&a.after_track_handler(t,n,r))}},ic.prototype.create_properties=function(e,t){var n;return typeof e=="function"?n=e(t):n=N.extend({},e),n};var Kg=function(){this.override_event="click"};N.inherit(Kg,ic),Kg.prototype.create_properties=function(e,t){var n=Kg.superclass.create_properties.apply(this,arguments);return t.href&&(n.url=t.href),n},Kg.prototype.event_handler=function(e,t,n){n.new_tab=e.which===2||e.metaKey||e.ctrlKey||t.target==="_blank",n.href=t.href,n.new_tab||e.preventDefault()},Kg.prototype.after_track_handler=function(e,t){t.new_tab||setTimeout(function(){window.location=t.href},0)};var Gw=function(){this.override_event="submit"};N.inherit(Gw,ic),Gw.prototype.event_handler=function(e,t,n){n.element=t,e.preventDefault()},Gw.prototype.after_track_handler=function(e,t){setTimeout(function(){t.element.submit()},0)};var $f="$set",Xg="$set_once",pl="$unset",Sh="$add",ru="$append",wh="$union",ac="$remove",WW="$delete",BN={set_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[$f]=r,n},unset_action:function(e){var t={},n=[];return N.isArray(e)||(e=[e]),N.each(e,function(r){this._is_reserved_property(r)||n.push(r)},this),t[pl]=n,t},set_once_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[Xg]=r,n},union_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=N.isArray(a)?a:[a])},this):r[e]=N.isArray(t)?t:[t],n[wh]=r,n},append_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[ru]=r,n},remove_action:function(e,t){var n={},r={};return N.isObject(e)?N.each(e,function(a,s){this._is_reserved_property(s)||(r[s]=a)},this):r[e]=t,n[ac]=r,n},delete_action:function(){var e={};return e[WW]="",e}},vr=function(){};N.extend(vr.prototype,BN),vr.prototype._init=function(e,t,n){this._mixpanel=e,this._group_key=t,this._group_id=n},vr.prototype.set=Vg(function(e,t,n){var r=this.set_action(e,t);return N.isObject(e)&&(n=t),this._send_request(r,n)}),vr.prototype.set_once=Vg(function(e,t,n){var r=this.set_once_action(e,t);return N.isObject(e)&&(n=t),this._send_request(r,n)}),vr.prototype.unset=Vg(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),vr.prototype.union=Vg(function(e,t,n){N.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),vr.prototype.delete=Vg(function(e){var t=this.delete_action();return this._send_request(t,e)}),vr.prototype.remove=Vg(function(e,t,n){var r=this.remove_action(e,t);return this._send_request(r,n)}),vr.prototype._send_request=function(e,t){e.$group_key=this._group_key,e.$group_id=this._group_id,e.$token=this._get_config("token");var n=N.encodeDates(e);return this._mixpanel._track_or_batch({type:"groups",data:n,endpoint:this._get_config("api_host")+"/"+this._get_config("api_routes").groups,batcher:this._mixpanel.request_batchers.groups},t)},vr.prototype._is_reserved_property=function(e){return e==="$group_key"||e==="$group_id"},vr.prototype._get_config=function(e){return this._mixpanel.get_config(e)},vr.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},vr.prototype.remove=vr.prototype.remove,vr.prototype.set=vr.prototype.set,vr.prototype.set_once=vr.prototype.set_once,vr.prototype.union=vr.prototype.union,vr.prototype.unset=vr.prototype.unset,vr.prototype.toString=vr.prototype.toString;var Xt=function(){};N.extend(Xt.prototype,BN),Xt.prototype._init=function(e){this._mixpanel=e},Xt.prototype.set=Nf(function(e,t,n){var r=this.set_action(e,t);return N.isObject(e)&&(n=t),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),r[$f]=N.extend({},N.info.people_properties(),r[$f]),this._send_request(r,n)}),Xt.prototype.set_once=Nf(function(e,t,n){var r=this.set_once_action(e,t);return N.isObject(e)&&(n=t),this._send_request(r,n)}),Xt.prototype.unset=Nf(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),Xt.prototype.increment=Nf(function(e,t,n){var r={},a={};return N.isObject(e)?(N.each(e,function(s,u){if(!this._is_reserved_property(u))if(isNaN(parseFloat(s))){zn.error("Invalid increment value passed to mixpanel.people.increment - must be a number");return}else a[u]=s},this),n=t):(N.isUndefined(t)&&(t=1),a[e]=t),r[Sh]=a,this._send_request(r,n)}),Xt.prototype.append=Nf(function(e,t,n){N.isObject(e)&&(n=t);var r=this.append_action(e,t);return this._send_request(r,n)}),Xt.prototype.remove=Nf(function(e,t,n){N.isObject(e)&&(n=t);var r=this.remove_action(e,t);return this._send_request(r,n)}),Xt.prototype.union=Nf(function(e,t,n){N.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),Xt.prototype.track_charge=Nf(function(e,t,n){if(!N.isNumber(e)&&(e=parseFloat(e),isNaN(e))){zn.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",N.extend({$amount:e},t),n)}),Xt.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},Xt.prototype.delete_user=function(){if(!this._identify_called()){zn.error("mixpanel.people.delete_user() requires you to call identify() first");return}var e={$delete:this._mixpanel.get_distinct_id()};return this._send_request(e)},Xt.prototype.toString=function(){return this._mixpanel.toString()+".people"},Xt.prototype._send_request=function(e,t){e.$token=this._get_config("token"),e.$distinct_id=this._mixpanel.get_distinct_id();var n=this._mixpanel.get_property("$device_id"),r=this._mixpanel.get_property("$user_id"),a=this._mixpanel.get_property("$had_persisted_distinct_id");n&&(e.$device_id=n),r&&(e.$user_id=r),a&&(e.$had_persisted_distinct_id=a);var s=N.encodeDates(e);return this._identify_called()?this._mixpanel._track_or_batch({type:"people",data:s,endpoint:this._get_config("api_host")+"/"+this._get_config("api_routes").engage,batcher:this._mixpanel.request_batchers.people},t):(this._enqueue(e),N.isUndefined(t)||(this._get_config("verbose")?t({status:-1,error:null}):t(-1)),N.truncate(s,255))},Xt.prototype._get_config=function(e){return this._mixpanel.get_config(e)},Xt.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},Xt.prototype._enqueue=function(e){$f in e?this._mixpanel.persistence._add_to_people_queue($f,e):Xg in e?this._mixpanel.persistence._add_to_people_queue(Xg,e):pl in e?this._mixpanel.persistence._add_to_people_queue(pl,e):Sh in e?this._mixpanel.persistence._add_to_people_queue(Sh,e):ru in e?this._mixpanel.persistence._add_to_people_queue(ru,e):ac in e?this._mixpanel.persistence._add_to_people_queue(ac,e):wh in e?this._mixpanel.persistence._add_to_people_queue(wh,e):zn.error("Invalid call to _enqueue():",e)},Xt.prototype._flush_one_queue=function(e,t,n,r){var a=this,s=N.extend({},this._mixpanel.persistence.load_queue(e)),u=s;!N.isUndefined(s)&&N.isObject(s)&&!N.isEmptyObject(s)&&(a._mixpanel.persistence._pop_from_people_queue(e,s),a._mixpanel.persistence.save(),r&&(u=r(s)),t.call(a,u,function(d,h){d===0&&a._mixpanel.persistence._add_to_people_queue(e,s),N.isUndefined(n)||n(d,h)}))},Xt.prototype._flush=function(e,t,n,r,a,s,u){var d=this;this._flush_one_queue($f,this.set,e),this._flush_one_queue(Xg,this.set_once,r),this._flush_one_queue(pl,this.unset,s,function(T){return N.keys(T)}),this._flush_one_queue(Sh,this.increment,t),this._flush_one_queue(wh,this.union,a);var h=this._mixpanel.persistence.load_queue(ru);if(!N.isUndefined(h)&&N.isArray(h)&&h.length)for(var m,y=function(T,A){T===0&&d._mixpanel.persistence._add_to_people_queue(ru,m),N.isUndefined(n)||n(T,A)},v=h.length-1;v>=0;v--)h=this._mixpanel.persistence.load_queue(ru),m=h.pop(),d._mixpanel.persistence.save(),N.isEmptyObject(m)||d.append(m,y);var S=this._mixpanel.persistence.load_queue(ac);if(!N.isUndefined(S)&&N.isArray(S)&&S.length)for(var x,E=function(T,A){T===0&&d._mixpanel.persistence._add_to_people_queue(ac,x),N.isUndefined(u)||u(T,A)},R=S.length-1;R>=0;R--)S=this._mixpanel.persistence.load_queue(ac),x=S.pop(),d._mixpanel.persistence.save(),N.isEmptyObject(x)||d.remove(x,E)},Xt.prototype._is_reserved_property=function(e){return e==="$distinct_id"||e==="$token"||e==="$device_id"||e==="$user_id"||e==="$had_persisted_distinct_id"},Xt.prototype.set=Xt.prototype.set,Xt.prototype.set_once=Xt.prototype.set_once,Xt.prototype.unset=Xt.prototype.unset,Xt.prototype.increment=Xt.prototype.increment,Xt.prototype.append=Xt.prototype.append,Xt.prototype.remove=Xt.prototype.remove,Xt.prototype.union=Xt.prototype.union,Xt.prototype.track_charge=Xt.prototype.track_charge,Xt.prototype.clear_charges=Xt.prototype.clear_charges,Xt.prototype.delete_user=Xt.prototype.delete_user,Xt.prototype.toString=Xt.prototype.toString;var fO="__mps",dO="__mpso",hO="__mpus",pO="__mpa",gO="__mpap",mO="__mpr",vO="__mpu",UN="$people_distinct_id",Vw="__alias",G0="__timers",JW=[fO,dO,hO,pO,gO,mO,vO,UN,Vw,G0],mn=function(e){this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="mp_"+e.persistence_name:this.name="mp_"+e.token+"_mixpanel";var t=e.persistence;t!=="cookie"&&t!=="localStorage"&&(zn.critical("Unknown persistence type "+t+"; falling back to cookie"),t=e.persistence="cookie"),t==="localStorage"&&N.localStorage.is_supported()?this.storage=N.localStorage:this.storage=N.cookie,this.load(),this.update_config(e),this.upgrade(),this.save()};mn.prototype.properties=function(){var e={};return this.load(),N.each(this.props,function(t,n){N.include(JW,n)||(e[n]=t)}),e},mn.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=N.extend({},e))}},mn.prototype.upgrade=function(){var e,t;this.storage===N.localStorage?(e=N.cookie.parse(this.name),N.cookie.remove(this.name),N.cookie.remove(this.name,!0),e&&this.register_once(e)):this.storage===N.cookie&&(t=N.localStorage.parse(this.name),N.localStorage.remove(this.name),t&&this.register_once(t))},mn.prototype.save=function(){this.disabled||this.storage.set(this.name,Gg(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},mn.prototype.load_prop=function(e){return this.load(),this.props[e]},mn.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},mn.prototype.clear=function(){this.remove(),this.props={}},mn.prototype.register_once=function(e,t,n){return N.isObject(e)?(typeof t>"u"&&(t="None"),this.expire_days=typeof n>"u"?this.default_expiry:n,this.load(),N.each(e,function(r,a){(!this.props.hasOwnProperty(a)||this.props[a]===t)&&(this.props[a]=r)},this),this.save(),!0):!1},mn.prototype.register=function(e,t){return N.isObject(e)?(this.expire_days=typeof t>"u"?this.default_expiry:t,this.load(),N.extend(this.props,e),this.save(),!0):!1},mn.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},mn.prototype.update_search_keyword=function(e){this.register(N.info.searchInfo(e))},mn.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:N.info.referringDomain(e)||"$direct"},"")},mn.prototype.get_referrer_info=function(){return N.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},mn.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cookie_domain(e.cookie_domain),this.set_cross_site(e.cross_site_cookie),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},mn.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},mn.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},mn.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},mn.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},mn.prototype.get_cross_subdomain=function(){return this.cross_subdomain},mn.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},mn.prototype._add_to_people_queue=function(e,t){var n=this._get_queue_key(e),r=t[e],a=this._get_or_create_queue($f),s=this._get_or_create_queue(Xg),u=this._get_or_create_queue(pl),d=this._get_or_create_queue(Sh),h=this._get_or_create_queue(wh),m=this._get_or_create_queue(ac,[]),y=this._get_or_create_queue(ru,[]);n===fO?(N.extend(a,r),this._pop_from_people_queue(Sh,r),this._pop_from_people_queue(wh,r),this._pop_from_people_queue(pl,r)):n===dO?(N.each(r,function(v,S){S in s||(s[S]=v)}),this._pop_from_people_queue(pl,r)):n===hO?N.each(r,function(v){N.each([a,s,d,h],function(S){v in S&&delete S[v]}),N.each(y,function(S){v in S&&delete S[v]}),u[v]=!0}):n===pO?(N.each(r,function(v,S){S in a?a[S]+=v:(S in d||(d[S]=0),d[S]+=v)},this),this._pop_from_people_queue(pl,r)):n===vO?(N.each(r,function(v,S){N.isArray(v)&&(S in h||(h[S]=[]),N.each(v,function(x){N.include(h[S],x)||h[S].push(x)}))}),this._pop_from_people_queue(pl,r)):n===mO?(m.push(r),this._pop_from_people_queue(ru,r)):n===gO&&(y.push(r),this._pop_from_people_queue(pl,r)),zn.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),zn.log(t),this.save()},mn.prototype._pop_from_people_queue=function(e,t){var n=this.props[this._get_queue_key(e)];N.isUndefined(n)||N.each(t,function(r,a){e===ru||e===ac?N.each(n,function(s){s[a]===r&&delete s[a]}):delete n[a]},this)},mn.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},mn.prototype._get_queue_key=function(e){if(e===$f)return fO;if(e===Xg)return dO;if(e===pl)return hO;if(e===Sh)return pO;if(e===ru)return gO;if(e===ac)return mO;if(e===wh)return vO;zn.error("Invalid queue:",e)},mn.prototype._get_or_create_queue=function(e,t){var n=this._get_queue_key(e);return t=N.isUndefined(t)?{}:t,this.props[n]||(this.props[n]=t)},mn.prototype.set_event_timer=function(e,t){var n=this.load_prop(G0)||{};n[e]=t,this.props[G0]=n,this.save()},mn.prototype.remove_event_timer=function(e){var t=this.load_prop(G0)||{},n=t[e];return N.isUndefined(n)||(delete this.props[G0][e],this.save()),n};var yO,zN=function(e,t){throw new Error(e+" not available in this build.")},ha,HN=0,eJ=1,tJ=function(e){return e},ls="mixpanel",PN="base64",nJ="json",bO="$device:",Wg=ct.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,qN=!Wg&&nc.indexOf("MSIE")===-1&&nc.indexOf("Mozilla")===-1,Yw=null;Df.sendBeacon&&(Yw=function(){return Df.sendBeacon.apply(Df,arguments)});var FN={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},jN={api_host:"https://api-js.mixpanel.com",api_routes:FN,api_method:"POST",api_transport:"XHR",api_payload_format:PN,app_host:"https://mixpanel.com",autocapture:!1,cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:If,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:If,mp_loader:null,track_marketing:!0,track_pageview:!1,skip_first_touch_marketing:!1,store_google:!0,stop_utm_persistence:!1,save_referrer:!0,test:!1,verbose:!1,img:!1,debug:!1,track_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_tracking_by_default:!1,opt_out_persistence_by_default:!1,opt_out_tracking_persistence_type:"localStorage",opt_out_tracking_cookie_prefix:null,property_blacklist:[],xhr_headers:{},ignore_dnt:!1,batch_requests:!0,batch_size:50,batch_flush_interval_ms:5e3,batch_request_timeout_ms:9e4,batch_autostart:!0,hooks:{},record_block_class:new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),record_block_selector:"img, video",record_canvas:!1,record_collect_fonts:!1,record_idle_timeout_ms:30*60*1e3,record_mask_text_class:new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),record_mask_text_selector:"*",record_max_ms:U0,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},GN=!1,we=function(){},_O=function(e,t,n){var r,a=n===ls?ha:ha[n];if(a&&yO===HN)r=a;else{if(a&&!N.isArray(a)){zn.error("You have already initialized "+n);return}r=new we}if(r._cached_groups={},r._init(e,t,n),r.people=new Xt,r.people._init(r),!r.get_config("skip_first_touch_marketing")){var s=N.info.campaignParams(null),u={},d=!1;N.each(s,function(h,m){u["initial_"+m]=h,h&&(d=!0)}),d&&r.people.set_once(u)}return hl.DEBUG=hl.DEBUG||r.get_config("debug"),!N.isUndefined(a)&&N.isArray(a)&&(r._execute_array.call(r.people,a.people),r._execute_array(a)),r};we.prototype.init=function(e,t,n){if(N.isUndefined(n)){this.report_error("You must name your new library: init(token, config, name)");return}if(n===ls){this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");return}var r=_O(e,t,n);return ha[n]=r,r._loaded(),r},we.prototype._init=function(e,t,n){t=t||{},this.__loaded=!0,this.config={};var r={};if(!("api_payload_format"in t)){var a=t.api_host||jN.api_host;a.match(/\.mixpanel\.com/)&&(r.api_payload_format=nJ)}if(this.set_config(N.extend({},jN,r,t,{name:n,token:e,callback_fn:(n===ls?n:ls+"."+n)+"._jsc"})),this._jsc=If,this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.request_batchers={},this._batch_requests=this.get_config("batch_requests"),this._batch_requests){if(!N.localStorage.is_supported(!0)||!Wg)this._batch_requests=!1,zn.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),N.each(this.get_batcher_configs(),function(d){zn.log("Clearing batch queue "+d.queue_key),N.localStorage.remove(d.queue_key)});else if(this.init_batchers(),Yw&&ct.addEventListener){var s=N.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);ct.addEventListener("pagehide",function(d){d.persisted&&s()}),ct.addEventListener("visibilitychange",function(){jn.visibilityState==="hidden"&&s()})}}this.persistence=this.cookie=new mn(this.config),this.unpersisted_superprops={},this._gdpr_init();var u=N.UUID();this.get_distinct_id()||this.register_once({distinct_id:bO+u,$device_id:u},""),this.autocapture=new Lo(this),this.autocapture.init(),this._init_tab_id(),this._check_and_start_session_recording()},we.prototype._init_tab_id=function(){if(N.sessionStorage.is_supported())try{var e=this.get_config("name")+"_"+this.get_config("token"),t="mp_tab_id_"+e,n="mp_gen_new_tab_id_"+e;(N.sessionStorage.get(n)||!N.sessionStorage.get(t))&&N.sessionStorage.set(t,"$tab-"+N.UUID()),N.sessionStorage.set(n,"1"),this.tab_id=N.sessionStorage.get(t),ct.addEventListener("beforeunload",function(){N.sessionStorage.remove(n)})}catch(r){this.report_error("Error initializing tab id",r)}else this.report_error("Session storage is not supported, cannot keep track of unique tab ID.")},we.prototype.get_tab_id=function(){return this.tab_id||null},we.prototype._should_load_recorder=function(){var e=new eu(KR),t=this.get_tab_id();return e.init().then(function(){return e.getAll()}).then(function(n){for(var r=0;r<n.length;r++)if(eO(n[r])||n[r].tabId===t)return!0;return!1}).catch(N.bind(function(n){this.report_error("Error checking recording registry",n)},this))},we.prototype._check_and_start_session_recording=Lf(function(e){if(!ct.MutationObserver){zn.critical("Browser does not support MutationObserver; skipping session recording");return}var t=N.bind(function(r){var a=N.bind(function(){this._recorder=this._recorder||new ct.__mp_recorder(this),this._recorder.resumeRecording(r)},this);N.isUndefined(ct.__mp_recorder)?zN(this.get_config("recorder_src"),a):a()},this),n=this.get_config("record_sessions_percent")>0&&Math.random()*100<=this.get_config("record_sessions_percent");e||n?t(!0):this._should_load_recorder().then(function(r){r&&t(!1)})}),we.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},we.prototype.stop_session_recording=function(){this._recorder&&this._recorder.stopRecording()},we.prototype.pause_session_recording=function(){this._recorder&&this._recorder.pauseRecording()},we.prototype.resume_session_recording=function(){this._recorder&&this._recorder.resumeRecording()},we.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},we.prototype.get_session_replay_url=function(){var e=null,t=this._get_session_replay_id();if(t){var n=N.HTTPBuildQuery({replay_id:t,distinct_id:this.get_distinct_id(),token:this.get_config("token")});e="https://mixpanel.com/projects/replay-redirect?"+n}return e},we.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},we.prototype.__get_recorder=function(){return this._recorder},we.prototype._loaded=function(){if(this.get_config("loaded")(this),this._set_default_superprops(),this.people.set_once(this.persistence.get_referrer_info()),this.get_config("store_google")&&this.get_config("stop_utm_persistence")){var e=N.info.campaignParams(null);N.each(e,(function(t,n){this.unregister(n)}).bind(this))}},we.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(jn.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(N.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info(jn.referrer)},we.prototype._dom_loaded=function(){N.each(this.__dom_loaded_queue,function(e){this._track_dom.apply(this,e)},this),this.has_opted_out_tracking()||N.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},we.prototype._track_dom=function(e,t){if(this.get_config("img"))return this.report_error("You can't use DOM tracking functions with img = true."),!1;if(!GN)return this.__dom_loaded_queue.push([e,t]),!1;var n=new e().init(this);return n.track.apply(n,t)},we.prototype._prepare_callback=function(e,t){if(N.isUndefined(e))return null;if(Wg){var n=function(u){e(u,t)};return n}else{var r=this._jsc,a=""+Math.floor(Math.random()*1e8),s=this.get_config("callback_fn")+"["+a+"]";return r[a]=function(u){delete r[a],e(u,t)},s}},we.prototype._send_request=function(e,t,n,r){var a=!0;if(qN)return this.__request_queue.push(arguments),a;var s={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},u=null;!r&&(N.isFunction(n)||typeof n=="string")&&(r=n,n=null),n=N.extend(s,n||{}),Wg||(n.method="GET");var d=n.method==="POST",h=Yw&&d&&n.transport.toLowerCase()==="sendbeacon",m=n.verbose;t.verbose&&(m=!0),this.get_config("test")&&(t.test=1),m&&(t.verbose=1),this.get_config("img")&&(t.img=1),Wg||(r?t.callback=r:(m||this.get_config("test"))&&(t.callback="(function(){})")),t.ip=this.get_config("ip")?1:0,t._=new Date().getTime().toString(),d&&(u="data="+encodeURIComponent(t.data),delete t.data),e+="?"+N.HTTPBuildQuery(t);var y=this;if("img"in t){var v=jn.createElement("img");v.src=e,jn.body.appendChild(v)}else if(h){try{a=Yw(e,u)}catch(A){y.report_error(A),a=!1}try{r&&r(a?1:0)}catch(A){y.report_error(A)}}else if(Wg)try{var S=new XMLHttpRequest;S.open(n.method,e,!0);var x=this.get_config("xhr_headers");if(d&&(x["Content-Type"]="application/x-www-form-urlencoded"),N.each(x,function(A,M){S.setRequestHeader(M,A)}),n.timeout_ms&&typeof S.timeout<"u"){S.timeout=n.timeout_ms;var E=new Date().getTime()}S.withCredentials=!0,S.onreadystatechange=function(){if(S.readyState===4)if(S.status===200){if(r)if(m){var A;try{A=N.JSONDecode(S.responseText)}catch($){if(y.report_error($),n.ignore_json_errors)A=S.responseText;else return}r(A)}else r(Number(S.responseText))}else{var M;if(S.timeout&&!S.status&&new Date().getTime()-E>=S.timeout?M="timeout":M="Bad HTTP status: "+S.status+" "+S.statusText,y.report_error(M),r)if(m){var D=S.responseHeaders||{};r({status:0,httpStatusCode:S.status,error:M,retryAfter:D["Retry-After"]})}else r(0)}},S.send(u)}catch(A){y.report_error(A),a=!1}else{var R=jn.createElement("script");R.type="text/javascript",R.async=!0,R.defer=!0,R.src=e;var T=jn.getElementsByTagName("script")[0];T.parentNode.insertBefore(R,T)}return a},we.prototype._execute_array=function(e){var t,n=[],r=[],a=[];N.each(e,function(u){u&&(t=u[0],N.isArray(t)?a.push(u):typeof u=="function"?u.call(this):N.isArray(u)&&t==="alias"?n.push(u):N.isArray(u)&&t.indexOf("track")!==-1&&typeof this[t]=="function"?a.push(u):r.push(u))},this);var s=function(u,d){N.each(u,function(h){if(N.isArray(h[0])){var m=d;N.each(h,function(y){m=m[y[0]].apply(m,y.slice(1))})}else this[h[0]].apply(this,h.slice(1))},d)};s(n,this),s(r,this),s(a,this)},we.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},we.prototype.get_batcher_configs=function(){var e="__mpq_"+this.get_config("token"),t=this.get_config("api_routes");return this._batcher_configs=this._batcher_configs||{events:{type:"events",endpoint:"/"+t.track,queue_key:e+"_ev"},people:{type:"people",endpoint:"/"+t.engage,queue_key:e+"_pp"},groups:{type:"groups",endpoint:"/"+t.groups,queue_key:e+"_gr"}},this._batcher_configs},we.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=N.bind(function(n){return new ss(n.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:N.bind(function(r,a,s){this._send_request(this.get_config("api_host")+n.endpoint,this._encode_data_for_request(r),a,this._prepare_callback(s,r))},this),beforeSendHook:N.bind(function(r){return this._run_hook("before_send_"+n.type,r)},this),stopAllBatchingFunc:N.bind(this.stop_batch_senders,this),usePersistence:!0})},this),t=this.get_batcher_configs();this.request_batchers={events:e(t.events),people:e(t.people),groups:e(t.groups)}}this.get_config("batch_autostart")&&this.start_batch_senders()},we.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,N.each(this.request_batchers,function(e){e.start()}))},we.prototype.stop_batch_senders=function(){this._batch_requests=!1,N.each(this.request_batchers,function(e){e.stop(),e.clear()})},we.prototype.push=function(e){this._execute_array([e])},we.prototype.disable=function(e){typeof e>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},we.prototype._encode_data_for_request=function(e){var t=Gg(e);return this.get_config("api_payload_format")===PN&&(t=N.base64Encode(t)),{data:t}},we.prototype._track_or_batch=function(e,t){var n=N.truncate(e.data,255),r=e.endpoint,a=e.batcher,s=e.should_send_immediately,u=e.send_request_options||{};t=t||If;var d=!0,h=N.bind(function(){return u.skip_hooks||(n=this._run_hook("before_send_"+e.type,n)),n?(zn.log("MIXPANEL REQUEST:"),zn.log(n),this._send_request(r,this._encode_data_for_request(n),u,this._prepare_callback(t,n))):null},this);return this._batch_requests&&!s?a.enqueue(n).then(function(m){m?t(1,n):h()}):d=h(),d&&n},we.prototype.track=Lf(function(e,t,n,r){!r&&typeof n=="function"&&(r=n,n=null),n=n||{};var a=n.transport;a&&(n.transport=a);var s=n.send_immediately;if(typeof r!="function"&&(r=If),N.isUndefined(e)){this.report_error("No event name provided to mixpanel.track");return}if(this._event_is_disabled(e)){r(0);return}t=N.extend({},t),t.token=this.get_config("token");var u=this.persistence.remove_event_timer(e);if(!N.isUndefined(u)){var d=new Date().getTime()-u;t.$duration=parseFloat((d/1e3).toFixed(3))}this._set_default_superprops();var h=this.get_config("track_marketing")?N.info.marketingParams():{};t=N.extend({},N.info.properties({mp_loader:this.get_config("mp_loader")}),h,this.persistence.properties(),this.unpersisted_superprops,this.get_session_recording_properties(),t);var m=this.get_config("property_blacklist");N.isArray(m)?N.each(m,function(S){delete t[S]}):this.report_error("Invalid value for property_blacklist config: "+m);var y={event:e,properties:t},v=this._track_or_batch({type:"events",data:y,endpoint:this.get_config("api_host")+"/"+this.get_config("api_routes").track,batcher:this.request_batchers.events,should_send_immediately:s,send_request_options:n},r);return v}),we.prototype.set_group=Lf(function(e,t,n){N.isArray(t)||(t=[t]);var r={};return r[e]=t,this.register(r),this.people.set(e,t,n)}),we.prototype.add_group=Lf(function(e,t,n){var r=this.get_property(e),a={};return r===void 0?(a[e]=[t],this.register(a)):r.indexOf(t)===-1&&(r.push(t),a[e]=r,this.register(a)),this.people.union(e,t,n)}),we.prototype.remove_group=Lf(function(e,t,n){var r=this.get_property(e);if(r!==void 0){var a=r.indexOf(t);a>-1&&(r.splice(a,1),this.register({group_key:r})),r.length===0&&this.unregister(e)}return this.people.remove(e,t,n)}),we.prototype.track_with_groups=Lf(function(e,t,n,r){var a=N.extend({},t||{});return N.each(n,function(s,u){s!=null&&(a[u]=s)}),this.track(e,a,r)}),we.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},we.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},we.prototype.get_group=function(e,t){var n=this._create_map_key(e,t),r=this._cached_groups[n];return(r===void 0||r._group_key!==e||r._group_id!==t)&&(r=new vr,r._init(this,e,t),this._cached_groups[n]=r),r},we.prototype.track_pageview=Lf(function(e,t){typeof e!="object"&&(e={}),t=t||{};var n=t.event_name||"$mp_web_page_view",r=N.extend(N.info.mpPageViewProperties(),N.info.campaignParams(),N.info.clickParams()),a=N.extend({},r,e);return this.track(n,a)}),we.prototype.track_links=function(){return this._track_dom.call(this,Kg,arguments)},we.prototype.track_forms=function(){return this._track_dom.call(this,Gw,arguments)},we.prototype.time_event=function(e){if(N.isUndefined(e)){this.report_error("No event name provided to mixpanel.time_event");return}this._event_is_disabled(e)||this.persistence.set_event_timer(e,new Date().getTime())};var rJ={persistent:!0},SO=function(e){var t;return N.isObject(e)?t=e:N.isUndefined(e)?t={}:t={days:e},N.extend({},rJ,t)};we.prototype.register=function(e,t){var n=SO(t);n.persistent?this.persistence.register(e,n.days):N.extend(this.unpersisted_superprops,e)},we.prototype.register_once=function(e,t,n){var r=SO(n);r.persistent?this.persistence.register_once(e,t,r.days):(typeof t>"u"&&(t="None"),N.each(e,function(a,s){(!this.unpersisted_superprops.hasOwnProperty(s)||this.unpersisted_superprops[s]===t)&&(this.unpersisted_superprops[s]=a)},this))},we.prototype.unregister=function(e,t){t=SO(t),t.persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},we.prototype._register_single=function(e,t){var n={};n[e]=t,this.register(n)},we.prototype.identify=function(e,t,n,r,a,s,u,d){var h=this.get_distinct_id();if(e&&h!==e){if(typeof e=="string"&&e.indexOf(bO)===0)return this.report_error("distinct_id cannot have $device: prefix"),-1;this.register({$user_id:e})}if(!this.get_property("$device_id")){var m=h;this.register_once({$had_persisted_distinct_id:!0,$device_id:m},"")}e!==h&&e!==this.get_property(Vw)&&(this.unregister(Vw),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,n,r,a,s,u,d),e!==h&&this.track("$identify",{distinct_id:e,$anon_distinct_id:h},{skip_hooks:!0})},we.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var e=N.UUID();this.register_once({distinct_id:bO+e,$device_id:e},"")},we.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},we.prototype.alias=function(e,t){if(e===this.get_property(UN))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var n=this;return N.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Vw,e),this.track("$create_alias",{alias:e,distinct_id:t},{skip_hooks:!0},function(){n.identify(e)})):(this.report_error("alias matches current distinct_id - skipping api call."),this.identify(e),-1)},we.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},we.prototype.set_config=function(e){if(N.isObject(e)){N.extend(this.config,e);var t=e.batch_size;t&&N.each(this.request_batchers,function(n){n.resetBatchSize()}),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),hl.DEBUG=hl.DEBUG||this.get_config("debug"),"autocapture"in e&&this.autocapture&&this.autocapture.init()}},we.prototype.get_config=function(e){return this.config[e]},we.prototype._run_hook=function(e){var t=(this.config.hooks[e]||tJ).apply(this,Mf.call(arguments,1));return typeof t>"u"&&(this.report_error(e+" hook did not return a value"),t=null),t},we.prototype.get_property=function(e){return this.persistence.load_prop([e])},we.prototype.toString=function(){var e=this.get_config("name");return e!==ls&&(e=ls+"."+e),e},we.prototype._event_is_disabled=function(e){return N.isBlockedUA(nc)||this._flags.disable_all_events||N.include(this.__disabled_events,e)},we.prototype._gdpr_init=function(){var e=this.get_config("opt_out_tracking_persistence_type")==="localStorage";e&&N.localStorage.is_supported()&&(!this.has_opted_in_tracking()&&this.has_opted_in_tracking({persistence_type:"cookie"})&&this.opt_in_tracking({enable_persistence:!1}),!this.has_opted_out_tracking()&&this.has_opted_out_tracking({persistence_type:"cookie"})&&this.opt_out_tracking({clear_persistence:!1}),this.clear_opt_in_out_tracking({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_tracking()?this._gdpr_update_persistence({clear_persistence:!0}):!this.has_opted_in_tracking()&&(this.get_config("opt_out_tracking_by_default")||N.cookie.get("mp_optout"))&&(N.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},we.prototype._gdpr_update_persistence=function(e){var t;if(e&&e.clear_persistence)t=!0;else if(e&&e.enable_persistence)t=!1;else return;!this.get_config("disable_persistence")&&this.persistence.disabled!==t&&this.persistence.set_disabled(t),t?(this.stop_batch_senders(),this.stop_session_recording()):this._batchers_were_started&&this.start_batch_senders()},we.prototype._gdpr_call_func=function(e,t){return t=N.extend({track:N.bind(this.track,this),persistence_type:this.get_config("opt_out_tracking_persistence_type"),cookie_prefix:this.get_config("opt_out_tracking_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_site_cookie:this.get_config("cross_site_cookie"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),cookie_domain:this.get_config("cookie_domain"),secure_cookie:this.get_config("secure_cookie"),ignore_dnt:this.get_config("ignore_dnt")},t),N.localStorage.is_supported()||(t.persistence_type="cookie"),e(this.get_config("token"),{track:t.track,trackEventName:t.track_event_name,trackProperties:t.track_properties,persistenceType:t.persistence_type,persistencePrefix:t.cookie_prefix,cookieDomain:t.cookie_domain,cookieExpiration:t.cookie_expiration,crossSiteCookie:t.cross_site_cookie,crossSubdomainCookie:t.cross_subdomain_cookie,secureCookie:t.secure_cookie,ignoreDnt:t.ignore_dnt})},we.prototype.opt_in_tracking=function(e){e=N.extend({enable_persistence:!0},e),this._gdpr_call_func(AW,e),this._gdpr_update_persistence(e)},we.prototype.opt_out_tracking=function(e){e=N.extend({clear_persistence:!0,delete_user:!0},e),e.delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(TW,e),this._gdpr_update_persistence(e)},we.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(kW,e)},we.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(oN,e)},we.prototype.clear_opt_in_out_tracking=function(e){e=N.extend({enable_persistence:!0},e),this._gdpr_call_func(RW,e),this._gdpr_update_persistence(e)},we.prototype.report_error=function(e,t){zn.error.apply(zn.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(n){zn.error(n)}},we.prototype.init=we.prototype.init,we.prototype.reset=we.prototype.reset,we.prototype.disable=we.prototype.disable,we.prototype.time_event=we.prototype.time_event,we.prototype.track=we.prototype.track,we.prototype.track_links=we.prototype.track_links,we.prototype.track_forms=we.prototype.track_forms,we.prototype.track_pageview=we.prototype.track_pageview,we.prototype.register=we.prototype.register,we.prototype.register_once=we.prototype.register_once,we.prototype.unregister=we.prototype.unregister,we.prototype.identify=we.prototype.identify,we.prototype.alias=we.prototype.alias,we.prototype.name_tag=we.prototype.name_tag,we.prototype.set_config=we.prototype.set_config,we.prototype.get_config=we.prototype.get_config,we.prototype.get_property=we.prototype.get_property,we.prototype.get_distinct_id=we.prototype.get_distinct_id,we.prototype.toString=we.prototype.toString,we.prototype.opt_out_tracking=we.prototype.opt_out_tracking,we.prototype.opt_in_tracking=we.prototype.opt_in_tracking,we.prototype.has_opted_out_tracking=we.prototype.has_opted_out_tracking,we.prototype.has_opted_in_tracking=we.prototype.has_opted_in_tracking,we.prototype.clear_opt_in_out_tracking=we.prototype.clear_opt_in_out_tracking,we.prototype.get_group=we.prototype.get_group,we.prototype.set_group=we.prototype.set_group,we.prototype.add_group=we.prototype.add_group,we.prototype.remove_group=we.prototype.remove_group,we.prototype.track_with_groups=we.prototype.track_with_groups,we.prototype.start_batch_senders=we.prototype.start_batch_senders,we.prototype.stop_batch_senders=we.prototype.stop_batch_senders,we.prototype.start_session_recording=we.prototype.start_session_recording,we.prototype.stop_session_recording=we.prototype.stop_session_recording,we.prototype.pause_session_recording=we.prototype.pause_session_recording,we.prototype.resume_session_recording=we.prototype.resume_session_recording,we.prototype.get_session_recording_properties=we.prototype.get_session_recording_properties,we.prototype.get_session_replay_url=we.prototype.get_session_replay_url,we.prototype.get_tab_id=we.prototype.get_tab_id,we.prototype.DEFAULT_API_ROUTES=FN,we.prototype.__get_recorder=we.prototype.__get_recorder,mn.prototype.properties=mn.prototype.properties,mn.prototype.update_search_keyword=mn.prototype.update_search_keyword,mn.prototype.update_referrer_info=mn.prototype.update_referrer_info,mn.prototype.get_cross_subdomain=mn.prototype.get_cross_subdomain,mn.prototype.clear=mn.prototype.clear;var Jg={},iJ=function(){N.each(Jg,function(e,t){t!==ls&&(ha[t]=e)}),ha._=N},aJ=function(){ha.init=function(e,t,n){if(n)return ha[n]||(ha[n]=Jg[n]=_O(e,t,n),ha[n]._loaded()),ha[n];var r=ha;Jg[ls]?r=Jg[ls]:e&&(r=_O(e,t,ls),r._loaded(),Jg[ls]=r),ha=r,yO===eJ&&(ct[ls]=ha),iJ()}},oJ=function(){function e(){e.done||(e.done=!0,GN=!0,qN=!1,N.each(Jg,function(r){r._dom_loaded()}))}function t(){try{jn.documentElement.doScroll("left")}catch{setTimeout(t,1);return}e()}if(jn.addEventListener)jn.readyState==="complete"?e():jn.addEventListener("DOMContentLoaded",e,!1);else if(jn.attachEvent){jn.attachEvent("onreadystatechange",e);var n=!1;try{n=ct.frameElement===null}catch{}jn.documentElement.doScroll&&n&&t()}N.register_event(ct,"load",e,!0)};function sJ(e){return zN=e,yO=HN,ha=new we,aJ(),ha.init(),oJ(),ha}function lJ(e,t){t()}var Bf=sJ(lJ);const iu="https://debales.ai",uJ="https://debales-web-app-server-prod.azurewebsites.net",VN={"blossom-and-rhyme-6":"84e28f5a553bc260c8276723d0f365bc","doorbellmount-dea1de94-1728660454527":"f825468f4202c28be0d29c849a997208",artzfolio:"789feea8eb479f2db1144448f6465f7f",minature:"b22ef9c8fdbeb4a297947903891c5fd9","nonetz-3f0b8348-1736183595738":"a19d837ea53890c892a2b351e54afc11",bodytales:"703aa3f61539de0786fa19f82644fa8b",athflex:"b9f412aa0c6991abf8b8e3db70b2a506",www:"2637bf921fb09742d550941fbebe7160","GTK-Restaurant":"dbcb03738f942ec7c968f45833ee47bf","derkins-co-uk":"f109fd32c98dac150ba902bd69feeeed","imemyselfcare-com":"bbbe4af618eeab278a4015b4ddf8827f"},cJ="phc_OKaClHZDmbEpVscrwceWJB5lsMYbMaV586L7pai6ZKD",fJ=e=>({layout:{position:{isLeft:e.isLeft??!1,zIndex:e.zIndex??1e3},height:{option:e.heightOption??"Normal"},responsive:{fullScreenOnMobile:e.fullScreenOnMobile??!0,mobileDisplayMode:e.mobileDisplayMode??"normal"}},colors:{background:e.backgroundColor,font:e.fontColor,supportButtonBackgroundColor:e.supportButtonBackgroundColor??"'#ffa500'",bot:{background:e.botBackgroundColor,message:e.botMessageColor,font:e.botFontColor},user:{message:e.userMessageColor,font:e.userFontColor},header:{font:e.headerFontColor},footer:{background:e.footerBackgroundColor,inputBorder:e.fonterInputBorderColor},cta:{background:e.callToActionBackgroundColor,font:e.callToActionFontColor},suggestedQuestions:{font:e.suggestedQuestionsFontColor,background:e.suggestedQuestionsBackgroundColor,hover:e.suggestedQuestionsHoverColor,crossButton:{color:e.suggestedQuestionsCrossButtonColor,background:e.suggestedQuestionsCrossButtonBackgroundColor},highlight:e.suggestedQuestionsHighlightColor},chatButton:{animation:e.chatButtonBackgroundAnimationColor}},typography:{fontFamily:void 0,fontSize:void 0,lineHeight:void 0},borders:{radius:"4px",width:"1px"},animations:{chatButton:{type:e.chatButtonBackgroundAnimationType??"Ping",enabled:e.enableChatButtonBackgroundAnimation??!1}},branding:{visibility:{showBot:e.show_bot??!0,debalesBranding:e.debales_branding??!0},logo:{removeBackground:e.removeLogoBackground??!1}}});function Vi(){const e=sessionStorage.getItem("debalesSessionID");if(e)return e;const t=crypto.randomUUID();return sessionStorage.setItem("debalesSessionID",t),t}function dJ(){return sessionStorage.getItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:window.DebalesChat.projectId}))}function Uf(){const e=localStorage.getItem(Zi(Fi.USER_INFO));return e?JSON.parse(e):null}function wO(e){localStorage.setItem(Zi(Fi.USER_INFO),JSON.stringify(e))}function Zw(e){if(e.current){const t=e.current.lastElementChild;if(t)if(window.matchMedia("(max-width: 768px)").matches)e.current.scrollTop=e.current.scrollHeight,setTimeout(()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight)},50);else{const r=e.current.scrollTop,a=t.getBoundingClientRect().bottom+e.current.scrollTop-e.current.clientHeight,s=300,u=performance.now(),d=h=>{const m=h-u,y=Math.min(m/s,1),v=y<.5?4*y*y*y:1-Math.pow(-2*y+2,3)/2;e.current.scrollTop=r+(a-r)*v,y<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}}}function hJ(){return window.location.pathname}function YN(){const e=/test|demo|example|debales/i,t=Uf()??"";return!!(t&&e.test(t.email))}function pJ(e){const t=hJ(),r=Array.from(new Set(e.map(s=>s.path))).filter(s=>new RegExp(`^${s}(/|$)`).test(t));if(r.length>0){r.sort((d,h)=>h.length-d.length);const s=r[0];return e.filter(d=>d.path===s&&d.enable!==!1).sort((d,h)=>(d.sortOrder??0)-(h.sortOrder??0))}return e.filter(s=>s.path==="/"&&s.enable!==!1).sort((s,u)=>(s.sortOrder??0)-(u.sortOrder??0))}const ZN=new Set,gJ=e=>{const t=VN[e];if(!t)return console.warn("No Mixpanel token found"),null;if(ZN.has(e))return Bf;Bf.init(t,{debug:!1,track_pageview:!0,persistence:"localStorage"}),console.log("Mixpanel initialized");const n=Uf();return n&&n.email&&Bf.identify(n.email),ZN.add(e),Bf},mJ=async(e,t)=>{if(YN())return;const n=window.DebalesChat.projectId??t.projectId;if(!VN[n]){console.warn("No Mixpanel token found");return}Bf.track(e,t)},vJ=()=>{const e=localStorage.getItem("anonymousUserId");if(e)return e;const t=crypto.randomUUID();return localStorage.setItem("anonymousUserId",t),t};function yJ(e){return e?e.split("<br>").filter(n=>n.trim().length>0).map(n=>n.trim()):[""]}const Yi=e=>e.toLowerCase().includes("gaiabay")||e.toLowerCase().includes("debales-testing"),bJ=e=>{const t=e.findIndex(s=>s.type==="dynamic");if(t===-1)return e;const n=e.filter(s=>s.type==="static"),r=e.filter(s=>s.type==="dynamic");return[...n.slice(0,t),r,...n.slice(t)]};function Zi(e,t){return t!=null&&t.botId?`debales_${t.botId}_${e}`:`debales_${e}`}const QN=pe.createContext(null),KN=()=>{const e=pe.useContext(QN);if(!e)throw new Error("useCart must be used within a CartProvider");return e};var _J="2.0.0",em="",XN="?",Qw="function",zf="undefined",tm="object",xO="string",V0="major",Qe="model",Ve="name",je="type",Je="vendor",Ze="version",oo="architecture",nm="console",an="mobile",Er="tablet",pa="smarttv",Y0="wearable",CO="xr",EO="embedded",Z0="inapp",WN="user-agent",AO=500,TO="brands",xh="formFactors",kO="fullVersionList",rm="platform",RO="platformVersion",Kw="bitness",Hf="sec-ch-ua",SJ=Hf+"-full-version-list",wJ=Hf+"-arch",xJ=Hf+"-"+Kw,CJ=Hf+"-form-factors",EJ=Hf+"-"+an,AJ=Hf+"-"+Qe,JN=Hf+"-"+rm,TJ=JN+"-version",e5=[TO,kO,an,Qe,rm,RO,oo,xh,Kw],No="browser",oc="cpu",au="device",sc="engine",us="os",im="result",Xw="Amazon",Q0="Apple",t5="ASUS",n5="BlackBerry",Ch="Google",r5="Huawei",i5="Lenovo",kJ="Honor",OO="LG",Ww="Microsoft",a5="Motorola",K0="Samsung",o5="Sharp",Jw="Sony",MO="Xiaomi",DO="Zebra",am="Mobile ",X0=" Browser",s5="Chrome",Pf="Chromecast",RJ="Edge",W0="Firefox",J0="Opera",l5="Facebook",u5="Sogou",IO="Windows",OJ=typeof window!==zf,so=OJ&&window.navigator?window.navigator:void 0,qf=so&&so.userAgentData?so.userAgentData:void 0,MJ=function(e,t){var n={},r=t;if(!tx(t)){r={};for(var a in t)for(var s in t[a])r[s]=t[a][s].concat(r[s]?r[s]:[])}for(var u in e)n[u]=r[u]&&r[u].length%2===0?r[u].concat(e[u]):e[u];return n},ex=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},LO=function(e,t){if(typeof e===tm&&e.length>0){for(var n in e)if(lc(e[n])==lc(t))return!0;return!1}return om(e)?lc(t).indexOf(lc(e))!==-1:!1},tx=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?tx(e[n]):!1)},om=function(e){return typeof e===xO},NO=function(e){if(e){for(var t=[],n=Eh(/\\?\"/g,e).split(","),r=0;r<n.length;r++)if(n[r].indexOf(";")>-1){var a=tb(n[r]).split(";v=");t[r]={brand:a[0],version:a[1]}}else t[r]=tb(n[r]);return t}},lc=function(e){return om(e)?e.toLowerCase():e},$O=function(e){return om(e)?Eh(/[^\d\.]/g,e).split(".")[0]:void 0},uc=function(e){for(var t in e){var n=e[t];typeof n==tm&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Eh=function(e,t){return om(t)?t.replace(e,em):t},eb=function(e){return Eh(/\\?\"/g,e)},tb=function(e,t){if(om(e))return e=Eh(/^\s\s*/,e),typeof t===zf?e:e.substring(0,AO)},c5=function(e,t){if(!(!e||!t))for(var n=0,r,a,s,u,d,h;n<t.length&&!d;){var m=t[n],y=t[n+1];for(r=a=0;r<m.length&&!d&&m[r];)if(d=m[r++].exec(e),d)for(s=0;s<y.length;s++)h=d[++a],u=y[s],typeof u===tm&&u.length>0?u.length===2?typeof u[1]==Qw?this[u[0]]=u[1].call(this,h):this[u[0]]=u[1]:u.length===3?typeof u[1]===Qw&&!(u[1].exec&&u[1].test)?this[u[0]]=h?u[1].call(this,h,u[2]):void 0:this[u[0]]=h?h.replace(u[1],u[2]):void 0:u.length===4&&(this[u[0]]=h?u[3].call(this,h.replace(u[1],u[2])):void 0):this[u]=h||void 0;n+=2}},nb=function(e,t){for(var n in t)if(typeof t[n]===tm&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(LO(t[n][r],e))return n===XN?void 0:n}else if(LO(t[n],e))return n===XN?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},f5={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2","8.1":"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},d5={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},h5={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[Ze,[Ve,am+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[Ze,[Ve,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[Ve,Ze],[/opios[\/ ]+([\w\.]+)/i],[Ze,[Ve,J0+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[Ze,[Ve,J0+" GX"]],[/\bopr\/([\w\.]+)/i],[Ze,[Ve,J0]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[Ze,[Ve,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[Ze,[Ve,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[Ve,Ze],[/quark(?:pc)?\/([-\w\.]+)/i],[Ze,[Ve,"Quark"]],[/\bddg\/([\w\.]+)/i],[Ze,[Ve,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[Ze,[Ve,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[Ze,[Ve,"WeChat"]],[/konqueror\/([\w\.]+)/i],[Ze,[Ve,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[Ze,[Ve,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[Ze,[Ve,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[Ze,[Ve,"Smart "+i5+X0]],[/(avast|avg)\/([\w\.]+)/i],[[Ve,/(.+)/,"$1 Secure"+X0],Ze],[/\bfocus\/([\w\.]+)/i],[Ze,[Ve,W0+" Focus"]],[/\bopt\/([\w\.]+)/i],[Ze,[Ve,J0+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[Ze,[Ve,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[Ze,[Ve,"Dolphin"]],[/coast\/([\w\.]+)/i],[Ze,[Ve,J0+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[Ze,[Ve,"MIUI"+X0]],[/fxios\/([\w\.-]+)/i],[Ze,[Ve,am+W0]],[/\bqihoobrowser\/?([\w\.]*)/i],[Ze,[Ve,"360"]],[/\b(qq)\/([\w\.]+)/i],[[Ve,/(.+)/,"$1Browser"],Ze],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[Ve,/(.+)/,"$1"+X0],Ze],[/samsungbrowser\/([\w\.]+)/i],[Ze,[Ve,K0+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[Ze,[Ve,u5+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[Ve,u5+" Mobile"],Ze],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[Ve,Ze],[/(lbbrowser|rekonq)/i],[Ve],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[Ze,Ve],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[Ve,l5],Ze,[je,Z0]],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat)[\/ ]([-\w\.]+)/i],[Ve,Ze,[je,Z0]],[/\bgsa\/([\w\.]+) .*safari\//i],[Ze,[Ve,"GSA"],[je,Z0]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[Ze,[Ve,"TikTok"],[je,Z0]],[/\[(linkedin)app\]/i],[Ve,[je,Z0]],[/(chromium)[\/ ]([-\w\.]+)/i],[Ve,Ze],[/headlesschrome(?:\/([\w\.]+)| )/i],[Ze,[Ve,s5+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[Ve,s5+" WebView"],Ze],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[Ze,[Ve,"Android"+X0]],[/chrome\/([\w\.]+) mobile/i],[Ze,[Ve,am+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[Ve,Ze],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[Ze,[Ve,am+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[Ve,am+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[Ze,Ve],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[Ve,[Ze,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[Ve,Ze],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[Ve,am+W0],Ze],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[Ve,"Netscape"],Ze],[/(wolvic|librewolf)\/([\w\.]+)/i],[Ve,Ze],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[Ze,[Ve,W0+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[Ve,[Ze,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[Ve,[Ze,/[^\d\.]+./,em]]],cpu:[[/\b(?:(amd|x|x86[-_]?|wow|win)64)\b/i],[[oo,"amd64"]],[/(ia32(?=;))/i,/((?:i[346]|x)86)[;\)]/i],[[oo,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[oo,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[oo,"armhf"]],[/windows (ce|mobile); ppc;/i],[[oo,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[oo,/ower/,em,lc]],[/(sun4\w)[;\)]/i],[[oo,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[oo,lc]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[Qe,[Je,K0],[je,Er]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[Qe,[Je,K0],[je,an]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[Qe,[Je,Q0],[je,an]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[Qe,[Je,Q0],[je,Er]],[/(macintosh);/i],[Qe,[Je,Q0]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[Qe,[Je,o5],[je,an]],[/(?:honor)([-\w ]+)[;\)]/i],[Qe,[Je,kJ],[je,an]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[Qe,[Je,r5],[je,Er]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[Qe,[Je,r5],[je,an]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[Qe,/_/g," "],[Je,MO],[je,an]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[Qe,/_/g," "],[Je,MO],[je,Er]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[Qe,[Je,"OPPO"],[je,an]],[/\b(opd2\d{3}a?) bui/i],[Qe,[Je,"OPPO"],[je,Er]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[Qe,[Je,"Vivo"],[je,an]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[Qe,[Je,"Realme"],[je,an]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[Qe,[Je,a5],[je,an]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[Qe,[Je,a5],[je,Er]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[Qe,[Je,OO],[je,Er]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[Qe,[Je,OO],[je,an]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[Qe,[Je,i5],[je,Er]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[Qe,/_/g," "],[Je,"Nokia"],[je,an]],[/(pixel c)\b/i],[Qe,[Je,Ch],[je,Er]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[Qe,[Je,Ch],[je,an]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[Qe,[Je,Jw],[je,an]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[Qe,"Xperia Tablet"],[Je,Jw],[je,Er]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[Qe,[Je,"OnePlus"],[je,an]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[Qe,[Je,Xw],[je,Er]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[Qe,/(.+)/g,"Fire Phone $1"],[Je,Xw],[je,an]],[/(playbook);[-\w\),; ]+(rim)/i],[Qe,Je,[je,Er]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[Qe,[Je,n5],[je,an]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[Qe,[Je,t5],[je,Er]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[Qe,[Je,t5],[je,an]],[/(nexus 9)/i],[Qe,[Je,"HTC"],[je,Er]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[Je,[Qe,/_/g," "],[je,an]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[Qe,[Je,"TCL"],[je,Er]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[Qe,[Je,"TCL"],[je,an]],[/(itel) ((\w+))/i],[[Je,lc],Qe,[je,nb,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[Qe,[Je,"Acer"],[je,Er]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[Qe,[Je,"Meizu"],[je,an]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[Qe,[Je,"Ulefone"],[je,an]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[Qe,[Je,"Energizer"],[je,an]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[Qe,[Je,"Cat"],[je,an]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[Qe,[Je,"Smartfren"],[je,an]],[/droid.+; (a(?:015|06[35]|142p?))/i],[Qe,[Je,"Nothing"],[je,an]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[Je,Qe,[je,an]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[Je,Qe,[je,Er]],[/(surface duo)/i],[Qe,[Je,Ww],[je,Er]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[Qe,[Je,"Fairphone"],[je,an]],[/(shield[\w ]+) b/i],[Qe,[Je,"Nvidia"],[je,Er]],[/(sprint) (\w+)/i],[Je,Qe,[je,an]],[/(kin\.[onetw]{3})/i],[[Qe,/\./g," "],[Je,Ww],[je,an]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[Qe,[Je,DO],[je,Er]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[Qe,[Je,DO],[je,an]],[/smart-tv.+(samsung)/i],[Je,[je,pa]],[/hbbtv.+maple;(\d+)/i],[[Qe,/^/,"SmartTV"],[Je,K0],[je,pa]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[Je,OO],[je,pa]],[/(apple) ?tv/i],[Je,[Qe,Q0+" TV"],[je,pa]],[/crkey.*devicetype\/chromecast/i],[[Qe,Pf+" Third Generation"],[Je,Ch],[je,pa]],[/crkey.*devicetype\/([^/]*)/i],[[Qe,/^/,"Chromecast "],[Je,Ch],[je,pa]],[/fuchsia.*crkey/i],[[Qe,Pf+" Nest Hub"],[Je,Ch],[je,pa]],[/crkey/i],[[Qe,Pf],[Je,Ch],[je,pa]],[/droid.+aft(\w+)( bui|\))/i],[Qe,[Je,Xw],[je,pa]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[Qe,[Je,o5],[je,pa]],[/(bravia[\w ]+)( bui|\))/i],[Qe,[Je,Jw],[je,pa]],[/(mitv-\w{5}) bui/i],[Qe,[Je,MO],[je,pa]],[/Hbbtv.*(technisat) (.*);/i],[Je,Qe,[je,pa]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[Je,tb],[Qe,tb],[je,pa]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[je,pa]],[/(ouya)/i,/(nintendo) (\w+)/i],[Je,Qe,[je,nm]],[/droid.+; (shield) bui/i],[Qe,[Je,"Nvidia"],[je,nm]],[/(playstation \w+)/i],[Qe,[Je,Jw],[je,nm]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[Qe,[Je,Ww],[je,nm]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[Qe,[Je,K0],[je,Y0]],[/((pebble))app/i],[Je,Qe,[je,Y0]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[Qe,[Je,Q0],[je,Y0]],[/droid.+; (wt63?0{2,3})\)/i],[Qe,[Je,DO],[je,Y0]],[/droid.+; (glass) \d/i],[Qe,[Je,Ch],[je,CO]],[/(pico) (4|neo3(?: link|pro)?)/i],[Je,Qe,[je,CO]],[/; (quest( \d| pro)?)/i],[Qe,[Je,l5],[je,CO]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[Je,[je,EO]],[/(aeobc)\b/i],[Qe,[Je,Xw],[je,EO]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[Qe,[je,an]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[Qe,[je,Er]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[je,Er]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[je,an]],[/(android[-\w\. ]{0,9});.+buil/i],[Qe,[Je,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[Ze,[Ve,RJ+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[Ve,Ze],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[Ze,[Ve,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[Ve,Ze],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[Ze,Ve]],os:[[/microsoft (windows) (vista|xp)/i],[Ve,Ze],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[Ve,[Ze,nb,f5]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[Ze,nb,f5],[Ve,IO]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[Ze,/_/g,"."],[Ve,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[Ve,"macOS"],[Ze,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[Ze,[Ve,Pf+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[Ze,[Ve,Pf+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[Ze,[Ve,Pf+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[Ze,[Ve,Pf+" Linux"]],[/crkey\/([\d\.]+)/i],[Ze,[Ve,Pf]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[Ze,Ve],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[Ve,Ze],[/\(bb(10);/i],[Ze,[Ve,n5]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[Ze,[Ve,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[Ze,[Ve,W0+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[Ze,[Ve,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[Ze,[Ve,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[Ve,"Chrome OS"],Ze],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[Ve,Ze],[/(sunos) ?([\w\.\d]*)/i],[[Ve,"Solaris"],Ze],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[Ve,Ze]]},nx=function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return uc.call(e.init,[[No,[Ve,Ze,V0,je]],[oc,[oo]],[au,[je,Qe,Je]],[sc,[Ve,Ze]],[us,[Ve,Ze]]]),uc.call(e.isIgnore,[[No,[Ze,V0]],[sc,[Ze]],[us,[Ze]]]),uc.call(e.isIgnoreRgx,[[No,/ ?browser$/i],[us,/ ?os$/i]]),uc.call(e.toString,[[No,[Ve,Ze]],[oc,[oo]],[au,[Je,Qe]],[sc,[Ve,Ze]],[us,[Ve,Ze]]]),e}(),DJ=function(e,t){var n=nx.init[t],r=nx.isIgnore[t]||0,a=nx.isIgnoreRgx[t]||0,s=nx.toString[t]||0;function u(){uc.call(this,n)}return u.prototype.getItem=function(){return e},u.prototype.withClientHints=function(){return qf?qf.getHighEntropyValues(e5).then(function(d){return e.setCH(new p5(d,!1)).parseCH().get()}):e.parseCH().get()},u.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=im&&(u.prototype.is=function(d){var h=!1;for(var m in this)if(this.hasOwnProperty(m)&&!LO(r,m)&&lc(a?Eh(a,this[m]):this[m])==lc(a?Eh(a,d):d)){if(h=!0,d!=zf)break}else if(d==zf&&h){h=!h;break}return h},u.prototype.toString=function(){var d=em;for(var h in s)typeof this[s[h]]!==zf&&(d+=(d?" ":em)+this[s[h]]);return d||zf}),qf||(u.prototype.then=function(d){var h=this,m=function(){for(var v in h)h.hasOwnProperty(v)&&(this[v]=h[v])};m.prototype={is:u.prototype.is,toString:u.prototype.toString};var y=new m;return d(y),y}),new u};function p5(e,t){if(e=e||{},uc.call(this,e5),t)uc.call(this,[[TO,NO(e[Hf])],[kO,NO(e[SJ])],[an,/\?1/.test(e[EJ])],[Qe,eb(e[AJ])],[rm,eb(e[JN])],[RO,eb(e[TJ])],[oo,eb(e[wJ])],[xh,NO(e[CJ])],[Kw,eb(e[xJ])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==zf&&(this[n]=e[n])}function g5(e,t,n,r){return this.get=function(a){return a?this.data.hasOwnProperty(a)?this.data[a]:void 0:this.data},this.set=function(a,s){return this.data[a]=s,this},this.setCH=function(a){return this.uaCH=a,this},this.detectFeature=function(){if(so&&so.userAgent==this.ua)switch(this.itemType){case No:so.brave&&typeof so.brave.isBrave==Qw&&this.set(Ve,"Brave");break;case au:!this.get(je)&&qf&&qf[an]&&this.set(je,an),this.get(Qe)=="Macintosh"&&so&&typeof so.standalone!==zf&&so.maxTouchPoints&&so.maxTouchPoints>2&&this.set(Qe,"iPad").set(je,Er);break;case us:!this.get(Ve)&&qf&&qf[rm]&&this.set(Ve,qf[rm]);break;case im:var a=this.data,s=function(u){return a[u].getItem().detectFeature().get()};this.set(No,s(No)).set(oc,s(oc)).set(au,s(au)).set(sc,s(sc)).set(us,s(us))}return this},this.parseUA=function(){return this.itemType!=im&&c5.call(this.data,this.ua,this.rgxMap),this.itemType==No&&this.set(V0,$O(this.get(Ze))),this},this.parseCH=function(){var a=this.uaCH,s=this.rgxMap;switch(this.itemType){case No:var u=a[kO]||a[TO],d;if(u)for(var h in u){var m=Eh(/(Google|Microsoft) /,u[h].brand||u[h]),y=u[h].version;!/not.a.brand/i.test(m)&&(!d||/chrom/i.test(d)&&!/chromi/i.test(m))&&(this.set(Ve,m).set(Ze,y).set(V0,$O(y)),d=m)}break;case oc:var v=a[oo];v&&(v&&a[Kw]=="64"&&(v+="64"),c5.call(this.data,v+";",s));break;case au:if(a[an]&&this.set(je,an),a[Qe]&&this.set(Qe,a[Qe]),a[Qe]=="Xbox"&&this.set(je,nm).set(Je,Ww),a[xh]){var S;if(typeof a[xh]!="string")for(var x=0;!S&&x<a[xh].length;)S=nb(a[xh][x++],d5);else S=nb(a[xh],d5);this.set(je,S)}break;case us:var E=a[rm];if(E){var R=a[RO];E==IO&&(R=parseInt($O(R),10)>=13?"11":"10"),this.set(Ve,E).set(Ze,R)}this.get(Ve)==IO&&a[Qe]=="Xbox"&&this.set(Ve,"Xbox").set(Ze,void 0);break;case im:var T=this.data,A=function(M){return T[M].getItem().setCH(a).parseCH().get()};this.set(No,A(No)).set(oc,A(oc)).set(au,A(au)).set(sc,A(sc)).set(us,A(us))}return this},uc.call(this,[["itemType",e],["ua",t],["uaCH",r],["rgxMap",n],["data",DJ(this,e)]]),this}function cc(e,t,n){if(typeof e===tm?(tx(e,!0)?(typeof t===tm&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===xO&&!tx(t,!0)&&(n=t,t=void 0),n&&typeof n.append===Qw){var r={};n.forEach(function(h,m){r[m]=h}),n=r}if(!(this instanceof cc))return new cc(e,t,n).getResult();var a=typeof e===xO?e:n&&n[WN]?n[WN]:so&&so.userAgent?so.userAgent:em,s=new p5(n,!0),u=t?MJ(h5,t):h5,d=function(h){return h==im?function(){return new g5(h,a,u,s).set("ua",a).set(No,this.getBrowser()).set(oc,this.getCPU()).set(au,this.getDevice()).set(sc,this.getEngine()).set(us,this.getOS()).get()}:function(){return new g5(h,a,u[h],s).parseUA().get()}};return uc.call(this,[["getBrowser",d(No)],["getCPU",d(oc)],["getDevice",d(au)],["getEngine",d(sc)],["getOS",d(us)],["getResult",d(im)],["getUA",function(){return a}],["setUA",function(h){return om(h)&&(a=h.length>AO?tb(h,AO):h),this}]]).setUA(a),this}cc.VERSION=_J,cc.BROWSER=ex([Ve,Ze,V0,je]),cc.CPU=ex([oo]),cc.DEVICE=ex([Qe,Je,je,nm,an,pa,Er,Y0,EO]),cc.ENGINE=cc.OS=ex([Ve,Ze]);const ms=class ms{constructor(t){Ii(this,"config");Ii(this,"storedData");Ii(this,"deviceInfo");Ii(this,"localStorageKey","_dsjfs312313kj3debales_analytics_");this.config=t,this.deviceInfo=this.getDeviceInfo(),this.localStorageKey=t.localStorageKey||this.localStorageKey+this.config.projectName,this.config.testing=t.testing||(()=>!1);const n=localStorage.getItem(this.localStorageKey);if(n)this.storedData=JSON.parse(n),this.config.debug&&console.log("Using Existing Stored data:",this.storedData);else{const r=crypto.randomUUID();this.storedData={projectName:this.config.projectName,anonId:r,distinctId:r},this.config.debug&&console.log("Using New Stored data:",this.storedData),this.updateStorage()}this.config.debug&&console.log("Analytics initialized:",this.storedData)}static init(t){ms.instance||(ms.instance=new ms(t))}static getInstance(){if(!ms.instance)throw new Error("DebalesAnalytics is not initialized. Call init() first.");return ms.instance}static async identify(t,n){return ms.getInstance().identifyInternal(t,n)}static track(t,n){ms.getInstance().trackInternal(t,n)}static getDistinctId(){return ms.getInstance().storedData.distinctId}static getAnonId(){return ms.getInstance().storedData.anonId}async identifyInternal(t,n){try{if(this.config.testing&&this.config.testing())return;let r,a,s;if(n){const{name:h,phone:m,...y}=n;r=h,a=m,s=y}const u={distinctId:this.storedData.distinctId,anonId:[this.storedData.anonId],projectName:this.config.projectName,email:t,name:r,phone:a,properties:s},d=await this.sendRequest("/api/analytic/identify",u);d&&d.success&&d.distinctId&&(this.config.debug&&console.log("identify success new distint id"),this.storedData.distinctId=d.distinctId,this.storedData.email=t,this.updateStorage(),d.isIdentified&&this.trackInternal("identify")),this.config.debug&&console.log("Identify event sent:",u)}catch(r){console.error("Failed to identify user:",r)}}trackInternal(t,n){if(this.config.testing&&this.config.testing())return;const r={projectName:this.config.projectName,distinctId:this.storedData.distinctId,anonId:this.storedData.anonId,eventName:t,osVersion:this.deviceInfo.osVersion,browserVersion:this.deviceInfo.browserVersion,operatingSystem:this.deviceInfo.os,browser:this.deviceInfo.browser,currentUrl:window.location.href,chatId:Vi()+this.config.projectName,properties:n};this.sendRequest("/api/analytic/track",r),this.config.debug&&console.log("Track event sent:",r)}updateStorage(){localStorage.setItem(this.localStorageKey,JSON.stringify(this.storedData))}async sendRequest(t,n){try{const r=await fetch(`${iu}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return await r.json()}catch(r){console.error("Failed to send analytics data:",r)}}getDeviceInfo(){const n=new cc().getResult();return{browser:n.browser.name,os:n.os.name,browserVersion:n.browser.version,osVersion:n.os.version}}};Ii(ms,"instance",null);let BO=ms;const Ah=BO;var gl,Ae=typeof window<"u"?window:void 0,lo=typeof globalThis<"u"?globalThis:Ae,m5=Array.prototype,v5=m5.forEach,y5=m5.indexOf,$o=lo==null?void 0:lo.navigator,yt=lo==null?void 0:lo.document,uo=lo==null?void 0:lo.location,UO=lo==null?void 0:lo.fetch,zO=lo!=null&&lo.XMLHttpRequest&&"withCredentials"in new lo.XMLHttpRequest?lo.XMLHttpRequest:void 0,b5=lo==null?void 0:lo.AbortController,oi=$o==null?void 0:$o.userAgent,Wt=Ae??{},fc={DEBUG:!1,LIB_VERSION:"1.235.0"},HO="$copy_autocapture",IJ=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(e){e.GZipJS="gzip-js",e.Base64="base64"})(gl||(gl={}));var LJ=["fatal","error","warning","log","info","debug"];function bn(e,t){return e.indexOf(t)!==-1}var rx=function(e){return e.trim()},PO=function(e){return e.replace(/^\$/,"")},NJ=Array.isArray,_5=Object.prototype,S5=_5.hasOwnProperty,ix=_5.toString,Pr=NJ||function(e){return ix.call(e)==="[object Array]"},ml=e=>typeof e=="function",qr=e=>e===Object(e)&&!Pr(e),sm=e=>{if(qr(e)){for(var t in e)if(S5.call(e,t))return!1;return!0}return!1},ut=e=>e===void 0,si=e=>ix.call(e)=="[object String]",qO=e=>si(e)&&e.trim().length===0,Ff=e=>e===null,Xn=e=>ut(e)||Ff(e),Ua=e=>ix.call(e)=="[object Number]",jf=e=>ix.call(e)==="[object Boolean]",$J=e=>e instanceof FormData,BJ=e=>bn(IJ,e),w5=e=>{var t={_log:function(n){if(Ae&&(fc.DEBUG||Wt.POSTHOG_DEBUG)&&!ut(Ae.console)&&Ae.console){for(var r=("__rrweb_original__"in Ae.console[n])?Ae.console[n].__rrweb_original__:Ae.console[n],a=arguments.length,s=new Array(a>1?a-1:0),u=1;u<a;u++)s[u-1]=arguments[u];r(e,...s)}},info:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];t._log("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];t._log("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];t._log("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];console.error(e,...r)},uninitializedWarning:n=>{t.error("You must initialize PostHog before calling ".concat(n))},createLogger:n=>w5("".concat(e," ").concat(n))};return t},Ot=w5("[PostHog.js]"),ga=Ot.createLogger,UJ=ga("[ExternalScriptsLoader]"),x5=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return UJ.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var r=yt==null?void 0:yt.querySelectorAll("script");if(r){for(var a=0;a<r.length;a++)if(r[a].src===t)return n()}var s=()=>{if(!yt)return n("document not found");var u=yt.createElement("script");if(u.type="text/javascript",u.crossOrigin="anonymous",u.src=t,u.onload=m=>n(void 0,m),u.onerror=m=>n(m),e.config.prepare_external_dependency_script&&(u=e.config.prepare_external_dependency_script(u)),!u)return n("prepare_external_dependency_script returned null");var d,h=yt.querySelectorAll("body > script");h.length>0?(d=h[0].parentNode)===null||d===void 0||d.insertBefore(u,h[0]):yt.body.appendChild(u)};yt!=null&&yt.body?s():yt==null||yt.addEventListener("DOMContentLoaded",s)};function C5(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function Le(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?C5(Object(n),!0).forEach(function(r){et(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C5(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function et(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E5(e,t){if(e==null)return{};var n,r,a=function(u,d){if(u==null)return{};var h,m,y={},v=Object.keys(u);for(m=0;m<v.length;m++)h=v[m],d.indexOf(h)>=0||(y[h]=u[h]);return y}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}Wt.__PosthogExtensions__=Wt.__PosthogExtensions__||{},Wt.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var r="/static/".concat(t,".js")+"?v=".concat(e.version);if(t==="remote-config"&&(r="/array/".concat(e.config.token,"/config.js")),t==="toolbar"){var a=3e5,s=Math.floor(Date.now()/a)*a;r="".concat(r,"&t=").concat(s)}var u=e.requestRouter.endpointFor("assets",r);x5(e,u,n)},Wt.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);x5(e,r,n)};var ax={};function Gf(e,t,n){if(Pr(e)){if(v5&&e.forEach===v5)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var r=0,a=e.length;r<a;r++)if(r in e&&t.call(n,e[r],r)===ax)return}}}function tr(e,t,n){if(!Xn(e)){if(Pr(e))return Gf(e,t,n);if($J(e)){for(var r of e.entries())if(t.call(n,r[1],r[0])===ax)return}else for(var a in e)if(S5.call(e,a)&&t.call(n,e[a],a)===ax)return}}var li=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Gf(n,function(a){for(var s in a)a[s]!==void 0&&(e[s]=a[s])}),e},ox=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Gf(n,function(a){Gf(a,function(s){e.push(s)})}),e};function sx(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var A5=function(e){try{return e()}catch{return}},zJ=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(this,n)}catch(a){Ot.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ot.critical(a)}}},rb=function(e){var t={};return tr(e,function(n,r){si(n)&&n.length>0&&(t[r]=n)}),t};function HJ(e,t){return n=e,r=s=>si(s)&&!Ff(t)?s.slice(0,t):s,a=new Set,function s(u,d){return u!==Object(u)?r?r(u,d):u:a.has(u)?void 0:(a.add(u),Pr(u)?(h=[],Gf(u,m=>{h.push(s(m))})):(h={},tr(u,(m,y)=>{a.has(m)||(h[y]=s(m,y))})),h);var h}(n);var n,r,a}var PJ=["herokuapp.com","vercel.app","netlify.app"];function qJ(e){var t=e==null?void 0:e.hostname;if(!si(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of PJ)if(n===r)return!1;return!0}function T5(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Kr(e,t,n,r){var{capture:a=!1,passive:s=!0}=r??{};e==null||e.addEventListener(t,n,{capture:a,passive:s})}var k5="$people_distinct_id",ib="__alias",ab="__timers",R5="$autocapture_disabled_server_side",FO="$heatmaps_enabled_server_side",O5="$exception_capture_enabled_server_side",M5="$web_vitals_enabled_server_side",D5="$dead_clicks_enabled_server_side",I5="$web_vitals_allowed_metrics",jO="$session_recording_enabled_server_side",L5="$console_log_recording_enabled_server_side",N5="$session_recording_network_payload_capture",$5="$session_recording_masking",B5="$session_recording_canvas_recording",U5="$replay_sample_rate",z5="$replay_minimum_duration",H5="$replay_script_config",lx="$sesid",ob="$session_is_sampled",GO="$session_recording_url_trigger_activated_session",VO="$session_recording_event_trigger_activated_session",lm="$enabled_feature_flags",ux="$early_access_features",YO="$feature_flag_details",sb="$stored_person_properties",Th="$stored_group_properties",ZO="$surveys",cx="$surveys_activated",fx="$flag_call_reported",dc="$user_state",QO="$client_session_props",KO="$capture_rate_limit",XO="$initial_campaign_params",WO="$initial_referrer_info",JO="$initial_person_info",dx="$epp",P5="__POSTHOG_TOOLBAR__",q5="$posthog_cookieless",FJ=[k5,ib,"__cmpns",ab,jO,FO,lx,lm,dc,ux,YO,Th,sb,ZO,fx,QO,KO,XO,WO,dx];function F5(e){var t;return e instanceof Element&&(e.id===P5||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function hx(e){return!!e&&e.nodeType===1}function Vf(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function j5(e){return!!e&&e.nodeType===3}function G5(e){return!!e&&e.nodeType===11}function eM(e){return e?rx(e).split(/\s+/):[]}function V5(e){var t=Ae==null?void 0:Ae.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function px(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return eM(t)}function Y5(e){return Xn(e)?null:rx(e).split(/(\s+)/).filter(t=>um(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function gx(e){var t="";return nM(e)&&!K5(e)&&e.childNodes&&e.childNodes.length&&tr(e.childNodes,function(n){var r;j5(n)&&n.textContent&&(t+=(r=Y5(n.textContent))!==null&&r!==void 0?r:"")}),rx(t)}function Z5(e){return ut(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var tM=["a","button","form","input","select","textarea","label"];function Q5(e){var t=e.parentNode;return!(!t||!hx(t))&&t}function jJ(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(!Ae||!e||Vf(e,"html")||!hx(e)||n!=null&&n.url_allowlist&&!V5(n.url_allowlist)||n!=null&&n.url_ignorelist&&V5(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var s=n.dom_event_allowlist;if(s&&!s.some(x=>t.type===x))return!1}for(var u=!1,d=[e],h=!0,m=e;m.parentNode&&!Vf(m,"body");)if(G5(m.parentNode))d.push(m.parentNode.host),m=m.parentNode.host;else{if(!(h=Q5(m)))break;if(r||tM.indexOf(h.tagName.toLowerCase())>-1)u=!0;else{var y=Ae.getComputedStyle(h);y&&y.getPropertyValue("cursor")==="pointer"&&(u=!0)}d.push(h),m=h}if(!function(x,E){var R=E==null?void 0:E.element_allowlist;if(ut(R))return!0;var T=function(D){if(R.some($=>D.tagName.toLowerCase()===$))return{v:!0}};for(var A of x){var M=T(A);if(typeof M=="object")return M.v}return!1}(d,n)||!function(x,E){var R=E==null?void 0:E.css_selector_allowlist;if(ut(R))return!0;var T=function(D){if(R.some($=>D.matches($)))return{v:!0}};for(var A of x){var M=T(A);if(typeof M=="object")return M.v}return!1}(d,n))return!1;var v=Ae.getComputedStyle(e);if(v&&v.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var S=e.tagName.toLowerCase();switch(S){case"html":return!1;case"form":return(a||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(a||["change","click"]).indexOf(t.type)>=0;default:return u?(a||["click"]).indexOf(t.type)>=0:(a||["click"]).indexOf(t.type)>=0&&(tM.indexOf(S)>-1||e.getAttribute("contenteditable")==="true")}}function nM(e){for(var t=e;t.parentNode&&!Vf(t,"body");t=t.parentNode){var n=px(t);if(bn(n,"ph-sensitive")||bn(n,"ph-no-capture"))return!1}if(bn(px(e),"ph-include"))return!0;var r=e.type||"";if(si(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var a=e.name||e.id||"";return!(si(a)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,"")))}function K5(e){return!!(Vf(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Vf(e,"select")||Vf(e,"textarea")||e.getAttribute("contenteditable")==="true")}var X5="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",GJ=new RegExp("^(?:".concat(X5,")$")),VJ=new RegExp(X5),W5="\\d{3}-?\\d{2}-?\\d{4}",YJ=new RegExp("^(".concat(W5,")$")),ZJ=new RegExp("(".concat(W5,")"));function um(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(Xn(e)||si(e)&&(e=rx(e),(t?GJ:VJ).test((e||"").replace(/[- ]/g,""))||(t?YJ:ZJ).test(e)))}function J5(e){var t=gx(e);return um(t="".concat(t," ").concat(e9(e)).trim())?t:""}function e9(e){var t="";return e&&e.childNodes&&e.childNodes.length&&tr(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{var a=gx(n);t="".concat(t," ").concat(a).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(e9(n)).trim())}catch(s){Ot.error("[AutoCapture]",s)}}),t}function QJ(e){return function(t){var n=t.map(r=>{var a,s,u="";if(r.tag_name&&(u+=r.tag_name),r.attr_class)for(var d of(r.attr_class.sort(),r.attr_class))u+=".".concat(d.replace(/"/g,""));var h=Le(Le(Le(Le({},r.text?{text:r.text}:{}),{},{"nth-child":(a=r.nth_child)!==null&&a!==void 0?a:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{}),r.attr_id?{attr_id:r.attr_id}:{}),r.attributes),m={};return sx(h).sort((y,v)=>{var[S]=y,[x]=v;return S.localeCompare(x)}).forEach(y=>{var[v,S]=y;return m[t9(v.toString())]=t9(S.toString())}),u+=":",u+=sx(h).map(y=>{var[v,S]=y;return"".concat(v,'="').concat(S,'"')}).join("")});return n.join(";")}(function(t){return t.map(n=>{var r,a,s={text:(r=n.$el_text)===null||r===void 0?void 0:r.slice(0,400),tag_name:n.tag_name,href:(a=n.attr__href)===null||a===void 0?void 0:a.slice(0,2048),attr_class:KJ(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return sx(n).filter(u=>{var[d]=u;return d.indexOf("attr__")===0}).forEach(u=>{var[d,h]=u;return s.attributes[d]=h}),s})}(e))}function t9(e){return e.replace(/"|\\"/g,'\\"')}function KJ(e){var t=e.attr__class;return t?Pr(t)?t:eM(t):void 0}class n9{constructor(){this.clicks=[]}isRageClick(t,n,r){var a=this.clicks[this.clicks.length-1];if(a&&Math.abs(t-a.x)+Math.abs(n-a.y)<30&&r-a.timestamp<1e3){if(this.clicks.push({x:t,y:n,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:t,y:n,timestamp:r}];return!1}}var XJ=["localhost","127.0.0.1"],cm=e=>{var t=yt==null?void 0:yt.createElement("a");return ut(t)?null:(t.href=e,t)},WJ=function(e){var t,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",a=[];return tr(e,function(s,u){ut(s)||ut(u)||u==="undefined"||(t=encodeURIComponent((d=>d instanceof File)(s)?s.name:s.toString()),n=encodeURIComponent(u),a[a.length]=n+"="+t)}),a.join(r)},mx=function(e,t){for(var n,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),a=0;a<r.length;a++){var s=r[a].split("=");if(s[0]===t){n=s;break}}if(!Pr(n)||n.length<2)return"";var u=n[1];try{u=decodeURIComponent(u)}catch{Ot.error("Skipping decoding for malformed query param: "+u)}return u.replace(/\+/g," ")},rM=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),a=r[0]||"",s=r[1],u=a.split("?"),d=u[1],h=u[0],m=(d||"").split("&"),y=[],v=0;v<m.length;v++){var S=m[v].split("=");Pr(S)&&(t.includes(S[0])?y.push(S[0]+"="+n):y.push(m[v]))}var x=h;return d!=null&&(x+="?"+y.join("&")),s!=null&&(x+="#"+s),x},vx=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},r9=ga("[AutoCapture]");function iM(e,t){return t.length>e?t.slice(0,e)+"...":t}function JJ(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!hx(t));return t}function eee(e,t,n,r){var a=e.tagName.toLowerCase(),s={tag_name:a};tM.indexOf(a)>-1&&!n&&(a.toLowerCase()==="a"||a.toLowerCase()==="button"?s.$el_text=iM(1024,J5(e)):s.$el_text=iM(1024,gx(e)));var u=px(e);u.length>0&&(s.classes=u.filter(function(y){return y!==""})),tr(e.attributes,function(y){var v;if((!K5(e)||["name","id","class","aria-label"].indexOf(y.name)!==-1)&&(r==null||!r.includes(y.name))&&!t&&um(y.value)&&(v=y.name,!si(v)||v.substring(0,10)!=="_ngcontent"&&v.substring(0,7)!=="_nghost")){var S=y.value;y.name==="class"&&(S=eM(S).join(" ")),s["attr__"+y.name]=iM(1024,S)}});for(var d=1,h=1,m=e;m=JJ(m);)d++,m.tagName===e.tagName&&h++;return s.nth_child=d,s.nth_of_type=h,s}function tee(e,t){for(var n,r,{e:a,maskAllElementAttributes:s,maskAllText:u,elementAttributeIgnoreList:d,elementsChainAsString:h}=t,m=[e],y=e;y.parentNode&&!Vf(y,"body");)G5(y.parentNode)?(m.push(y.parentNode.host),y=y.parentNode.host):(m.push(y.parentNode),y=y.parentNode);var v,S=[],x={},E=!1,R=!1;if(tr(m,$=>{var U=nM($);$.tagName.toLowerCase()==="a"&&(E=$.getAttribute("href"),E=U&&E&&um(E)&&E),bn(px($),"ph-no-capture")&&(R=!0),S.push(eee($,s,u,d));var P=function(Z){if(!nM(Z))return{};var X={};return tr(Z.attributes,function(K){if(K.name&&K.name.indexOf("data-ph-capture-attribute")===0){var G=K.name.replace("data-ph-capture-attribute-",""),ne=K.value;G&&ne&&um(ne)&&(X[G]=ne)}}),X}($);li(x,P)}),R)return{props:{},explicitNoCapture:R};if(u||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?S[0].$el_text=J5(e):S[0].$el_text=gx(e)),E){var T,A;S[0].attr__href=E;var M=(T=cm(E))===null||T===void 0?void 0:T.host,D=Ae==null||(A=Ae.location)===null||A===void 0?void 0:A.host;M&&D&&M!==D&&(v=E)}return{props:li({$event_type:a.type,$ce_version:1},h?{}:{$elements:S},{$elements_chain:QJ(S)},(n=S[0])!==null&&n!==void 0&&n.$el_text?{$el_text:(r=S[0])===null||r===void 0?void 0:r.$el_text}:{},v&&a.type==="click"?{$external_click_url:v}:{},x)}}class nee{constructor(t){et(this,"_initialized",!1),et(this,"_isDisabledServerSide",null),et(this,"rageclicks",new n9),et(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,r=qr(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(t=r.url_allowlist)===null||t===void 0?void 0:t.map(a=>new RegExp(a)),r.url_ignorelist=(n=r.url_ignorelist)===null||n===void 0?void 0:n.map(a=>new RegExp(a)),r}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ae&&yt){var t=r=>{r=r||(Ae==null?void 0:Ae.event);try{this._captureEvent(r)}catch(a){r9.error("Failed to capture event",a)}};if(Kr(yt,"submit",t,{capture:!0}),Kr(yt,"change",t,{capture:!0}),Kr(yt,"click",t,{capture:!0}),this.config.capture_copied_text){var n=r=>{r=r||(Ae==null?void 0:Ae.event),this._captureEvent(r,HO)};Kr(yt,"copy",n,{capture:!0}),Kr(yt,"cut",n,{capture:!0})}}}else r9.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[R5]:!!t.autocapture_opt_out}),this._isDisabledServerSide=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this._elementSelectors=t}getElementSelectors(t){var n,r=[];return(n=this._elementSelectors)===null||n===void 0||n.forEach(a=>{var s=yt==null?void 0:yt.querySelectorAll(a);s==null||s.forEach(u=>{t===u&&r.push(a)})}),r}get isEnabled(){var t,n,r=(t=this.instance.persistence)===null||t===void 0?void 0:t.props[R5],a=this._isDisabledServerSide;if(Ff(a)&&!jf(r)&&!this.instance.config.advanced_disable_decide)return!1;var s=(n=this._isDisabledServerSide)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!s}_captureEvent(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var r,a=Z5(t);j5(a)&&(a=a.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,"$rageclick");var s=n===HO;if(a&&jJ(a,t,this.config,s,s?["copy","cut"]:void 0)){var{props:u,explicitNoCapture:d}=tee(a,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(d)return!1;var h=this.getElementSelectors(a);if(h&&h.length>0&&(u.$element_selectors=h),n===HO){var m,y=Y5(Ae==null||(m=Ae.getSelection())===null||m===void 0?void 0:m.toString()),v=t.type||"clipboard";if(!y)return!1;u.$selected_content=y,u.$copy_type=v}return this.instance.capture(n,u),!0}}}isBrowserSupported(){return ml(yt==null?void 0:yt.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ua(e)&&isFinite(e)&&Math.floor(e)===e});var i9="0123456789abcdef";class yx{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,a){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(a)||t<0||n<0||r<0||a<0||t>0xffffffffffff||n>4095||r>1073741823||a>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=a>>>24,s[13]=a>>>16,s[14]=a>>>8,s[15]=a,new yx(s)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+i9.charAt(this.bytes[n]>>>4)+i9.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new yx(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;n<16;n++){var r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class ree{constructor(){et(this,"timestamp",0),et(this,"counter",0),et(this,"random",new iee)}generate(){var t=this.generateOrAbort();if(ut(t)){this.timestamp=0;var n=this.generateOrAbort();if(ut(n))throw new Error("Could not generate UUID after timestamp reset");return n}return t}generateOrAbort(){var t=Date.now();if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return yx.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var a9,o9=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ae&&!ut(Ae.crypto)&&crypto.getRandomValues&&(o9=e=>crypto.getRandomValues(e));class iee{constructor(){et(this,"buffer",new Uint32Array(8)),et(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(o9(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Yf=()=>aee().toString(),aee=()=>(a9||(a9=new ree)).generate(),oee="Thu, 01 Jan 1970 00:00:00 GMT",lb="",see=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function lee(e,t){if(t){var n=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:yt;if(lb)return lb;if(!s||["localhost","127.0.0.1"].includes(a))return"";for(var u=a.split("."),d=Math.min(u.length,8),h="dmn_chk_"+Yf(),m=new RegExp("(^|;)\\s*"+h+"=1");!lb&&d--;){var y=u.slice(d).join("."),v=h+"=1;domain=."+y;s.cookie=v,m.test(s.cookie)&&(s.cookie=v+";expires="+oee,lb=y)}return lb}(e);if(!n){var r=(a=>{var s=a.match(see);return s?s[0]:""})(e);r!==n&&Ot.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var Zf,hc={is_supported:()=>!!yt,error:function(e){Ot.error("cookieStore error: "+e)},get:function(e){if(yt){try{for(var t=e+"=",n=yt.cookie.split(";").filter(s=>s.length),r=0;r<n.length;r++){for(var a=n[r];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}}catch{}return null}},parse:function(e){var t;try{t=JSON.parse(hc.get(e))||{}}catch{}return t},set:function(e,t,n,r,a){if(yt)try{var s="",u="",d=lee(yt.location.hostname,r);if(n){var h=new Date;h.setTime(h.getTime()+24*n*60*60*1e3),s="; expires="+h.toUTCString()}a&&(u="; secure");var m=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+d+u;return m.length>3686.4&&Ot.warn("cookieStore warning: large cookie, len="+m.length),yt.cookie=m,m}catch{return}},remove:function(e,t){try{hc.set(e,"",-1,t)}catch{return}}},aM=null,Si={is_supported:function(){if(!Ff(aM))return aM;var e=!0;if(ut(Ae))e=!1;else try{var t="__mplssupport__";Si.set(t,"xyz"),Si.get(t)!=='"xyz"'&&(e=!1),Si.remove(t)}catch{e=!1}return e||Ot.error("localStorage unsupported; falling back to cookie store"),aM=e,e},error:function(e){Ot.error("localStorage error: "+e)},get:function(e){try{return Ae==null?void 0:Ae.localStorage.getItem(e)}catch(t){Si.error(t)}return null},parse:function(e){try{return JSON.parse(Si.get(e))||{}}catch{}return null},set:function(e,t){try{Ae==null||Ae.localStorage.setItem(e,JSON.stringify(t))}catch(n){Si.error(n)}},remove:function(e){try{Ae==null||Ae.localStorage.removeItem(e)}catch(t){Si.error(t)}}},uee=["distinct_id",lx,ob,dx,JO],bx=Le(Le({},Si),{},{parse:function(e){try{var t={};try{t=hc.parse(e)||{}}catch{}var n=li(t,JSON.parse(Si.get(e)||"{}"));return Si.set(e,n),n}catch{}return null},set:function(e,t,n,r,a,s){try{Si.set(e,t,void 0,void 0,s);var u={};uee.forEach(d=>{t[d]&&(u[d]=t[d])}),Object.keys(u).length&&hc.set(e,u,n,r,a,s)}catch(d){Si.error(d)}},remove:function(e,t){try{Ae==null||Ae.localStorage.removeItem(e),hc.remove(e,t)}catch(n){Si.error(n)}}}),_x={},cee={is_supported:function(){return!0},error:function(e){Ot.error("memoryStorage error: "+e)},get:function(e){return _x[e]||null},parse:function(e){return _x[e]||null},set:function(e,t){_x[e]=t},remove:function(e){delete _x[e]}},kh=null,Qi={is_supported:function(){if(!Ff(kh))return kh;if(kh=!0,ut(Ae))kh=!1;else try{var e="__support__";Qi.set(e,"xyz"),Qi.get(e)!=='"xyz"'&&(kh=!1),Qi.remove(e)}catch{kh=!1}return kh},error:function(e){Ot.error("sessionStorage error: ",e)},get:function(e){try{return Ae==null?void 0:Ae.sessionStorage.getItem(e)}catch(t){Qi.error(t)}return null},parse:function(e){try{return JSON.parse(Qi.get(e))||null}catch{}return null},set:function(e,t){try{Ae==null||Ae.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){Qi.error(n)}},remove:function(e){try{Ae==null||Ae.sessionStorage.removeItem(e)}catch(t){Qi.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(Zf||(Zf={}));class fee{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?Zf.DENIED:this.storedConsent}isOptedOut(){return this.consent===Zf.DENIED||this.consent===Zf.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(t){this.storage.set(this.storageKey,t?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:t,opt_out_capturing_cookie_prefix:n}=this.instance.config;return(n||"__ph_opt_in_out_")+t}get storedConsent(){var t=this.storage.get(this.storageKey);return t==="1"?Zf.GRANTED:t==="0"?Zf.DENIED:Zf.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?Si:hc;var n=t==="localStorage"?hc:Si;n.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(n.get(this.storageKey)==="1"),n.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!T5([$o==null?void 0:$o.doNotTrack,$o==null?void 0:$o.msDoNotTrack,Wt.doNotTrack],t=>bn([!0,1,"1","yes"],t))}}var Sx=ga("[Dead Clicks]"),dee=()=>!0,hee=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(D5)),r=e.instance.config.capture_dead_clicks;return jf(r)?r:n};class s9{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(t,n,r){this.instance=t,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[D5]:t==null?void 0:t.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"dead-clicks-autocapture",s=>{s?Sx.error("failed to load script",s):t()})}start(){var t;if(yt){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Wt.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=qr(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Wt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(yt),Sx.info("starting...")}}else Sx.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Sx.info("stopping..."))}}var oM=ga("[ExceptionAutocapture]");class pee{constructor(t){var n;et(this,"startCapturing",()=>{var r;if(Ae&&this.isEnabled&&(r=Wt.__PosthogExtensions__)!==null&&r!==void 0&&r.errorWrappingFunctions){var a=Wt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=Wt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,u=Wt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.unwrapOnError&&this.config.capture_unhandled_errors&&(this.unwrapOnError=a(this.captureException.bind(this))),!this.unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this.unwrapUnhandledRejection=s(this.captureException.bind(this))),!this.unwrapConsoleError&&this.config.capture_console_errors&&(this.unwrapConsoleError=u(this.captureException.bind(this)))}catch(d){oM.error("failed to start",d),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[O5]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var t=this.instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return qr(t)?n=Le(Le({},n),t):(ut(t)?this.remoteEnabled:t)&&(n=Le(Le({},n),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(oM.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"exception-autocapture",s=>{if(s)return oM.error("failed to load script",s);t()})}stopCapturing(){var t,n,r;(t=this.unwrapOnError)===null||t===void 0||t.call(this),this.unwrapOnError=void 0,(n=this.unwrapUnhandledRejection)===null||n===void 0||n.call(this),this.unwrapUnhandledRejection=void 0,(r=this.unwrapConsoleError)===null||r===void 0||r.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(t){var n=t.autocaptureExceptions;this.remoteEnabled=!!n||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[O5]:this.remoteEnabled}),this.startIfEnabled()}captureException(t){var n=this.instance.requestRouter.endpointFor("ui");t.$exception_personURL="".concat(n,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(t)}}function l9(e){return!ut(Event)&&u9(e,Event)}function u9(e,t){try{return e instanceof t}catch{return!1}}function wx(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function sM(e){return wx(e,"DOMError")}var c9=/\(error: (.*)\)/,f9=50,fm="?";function lM(e,t,n,r){var a={platform:"web:javascript",filename:e,function:t==="<anonymous>"?fm:t,in_app:!0};return ut(n)||(a.lineno=n),ut(r)||(a.colno=r),a}var gee=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,mee=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,vee=/\((\S*)(?::(\d+))(?::(\d+))\)/,yee=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,bee=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_ee=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.sort((a,s)=>a[0]-s[0]).map(a=>a[1]);return function(a){for(var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,u=[],d=a.split(`
115
115
  `),h=s;h<d.length;h++){var m=d[h];if(!(m.length>1024)){var y=c9.test(m)?m.replace(c9,"$1"):m;if(!y.match(/\S*Error: /)){for(var v of r){var S=v(y);if(S){u.push(S);break}}if(u.length>=f9)break}}}return function(x){if(!x.length)return[];var E=Array.from(x);return E.reverse(),E.slice(0,f9).map(R=>Le(Le({},R),{},{filename:R.filename||See(E).filename,function:R.function||fm}))}(u)}}([30,e=>{var t=gee.exec(e);if(t){var[,n,r,a]=t;return lM(n,fm,+r,+a)}var s=mee.exec(e);if(s){if(s[2]&&s[2].indexOf("eval")===0){var u=vee.exec(s[2]);u&&(s[2]=u[1],s[3]=u[2],s[4]=u[3])}var[d,h]=h9(s[1]||fm,s[2]);return lM(h,d,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,e=>{var t=yee.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=bee.exec(t[3]);n&&(t[1]=t[1]||"eval",t[3]=n[1],t[4]=n[2],t[5]="")}var r=t[3],a=t[1]||fm;return[a,r]=h9(a,r),lM(r,a,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]);function See(e){return e[e.length-1]||{}}var xx,d9,uM,h9=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:fm,n?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]},wee=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function cM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=e.stacktrace||e.stack||"",r=function(u){return u&&xee.test(u.message)?1:0}(e);try{var a=_ee,s=function(u,d){var h=function(m){var y=globalThis._posthogChunkIds;if(!y)return{};var v=Object.keys(y);return uM&&v.length===d9||(d9=v.length,uM=v.reduce((S,x)=>{xx||(xx={});var E=xx[x];if(E)S[E[0]]=E[1];else for(var R=m(x),T=R.length-1;T>=0;T--){var A=R[T],M=A==null?void 0:A.filename,D=y[x];if(M&&D){S[M]=D,xx[x]=[M,D];break}}return S},{})),uM}(d);return u.forEach(m=>{m.filename&&(m.chunk_id=h[m.filename])}),u}(a(n,r),a);return s.slice(0,s.length-t)}catch{}return[]}var xee=/Minified React error #\d+;/i;function fM(e,t){var n,r,a=cM(e),s=(n=t==null?void 0:t.handled)===null||n===void 0||n,u=(r=t==null?void 0:t.synthetic)!==null&&r!==void 0&&r;return{$exception_list:[{type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:e.name,value:function(d){var h=d.message;return h.error&&typeof h.error.message=="string"?String(h.error.message):String(h)}(e),stacktrace:{frames:a,type:"raw"},mechanism:{handled:s,synthetic:u}}],$exception_level:"error"}}function dM(e,t){var n,r,a,s=(n=t==null?void 0:t.handled)===null||n===void 0||n,u=(r=t==null?void 0:t.synthetic)===null||r===void 0||r,d={type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:(a=t==null?void 0:t.defaultExceptionType)!==null&&a!==void 0?a:"Error",value:e||(t==null?void 0:t.defaultExceptionMessage),mechanism:{handled:s,synthetic:u}};if(t!=null&&t.syntheticException){var h=cM(t.syntheticException,1);h.length&&(d.stacktrace={frames:h,type:"raw"})}return{$exception_list:[d],$exception_level:"error"}}function Cee(e){return si(e)&&!qO(e)&&LJ.indexOf(e)>=0}function Eee(e,t){var n,r,a=(n=t==null?void 0:t.handled)===null||n===void 0||n,s=(r=t==null?void 0:t.synthetic)===null||r===void 0||r,u=t!=null&&t.overrideExceptionType?t.overrideExceptionType:l9(e)?e.constructor.name:"Error",d="Non-Error 'exception' captured with keys: ".concat(function(y){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:40,S=Object.keys(y);if(S.sort(),!S.length)return"[object has no keys]";for(var x=S.length;x>0;x--){var E=S.slice(0,x).join(", ");if(!(E.length>v))return x===S.length||E.length<=v?E:"".concat(E.slice(0,v),"...")}return""}(e)),h={type:u,value:d,mechanism:{handled:a,synthetic:s}};if(t!=null&&t.syntheticException){var m=cM(t==null?void 0:t.syntheticException,1);m.length&&(h.stacktrace={frames:m,type:"raw"})}return{$exception_list:[h],$exception_level:Cee(e.level)?e.level:"error"}}function Aee(e,t){var{error:n,event:r}=e,a={$exception_list:[]},s=n||r;if(sM(s)||function(x){return wx(x,"DOMException")}(s)){var u=s;if(function(x){return"stack"in x}(s))a=fM(s,t);else{var d=u.name||(sM(u)?"DOMError":"DOMException"),h=u.message?"".concat(d,": ").concat(u.message):d,m=sM(u)?"DOMError":"DOMException";a=dM(h,Le(Le({},t),{},{overrideExceptionType:m,defaultExceptionMessage:h}))}return"code"in u&&(a.$exception_DOMException_code="".concat(u.code)),a}if(function(x){return wx(x,"ErrorEvent")}(s)&&s.error)return fM(s.error,t);if(function(x){switch(Object.prototype.toString.call(x)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return u9(x,Error)}}(s))return fM(s,t);if(function(x){return wx(x,"Object")}(s)||l9(s))return Eee(s,t);if(ut(n)&&si(r)){var y="Error",v=r,S=r.match(wee);return S&&(y=S[1],v=S[2]),dM(v,Le(Le({},t),{},{overrideExceptionType:y,defaultExceptionMessage:v}))}return dM(s,t)}function Cx(e){var t,n;return((t=JSON.stringify(e,(n=[],function(r,a){if(qr(a)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(a)?"[Circular]":(n.push(a),a)}return a})))===null||t===void 0?void 0:t.length)||0}function hM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(e.size>=t&&e.data.length>1){var n=Math.floor(e.data.length/2),r=e.data.slice(0,n),a=e.data.slice(n);return[hM({size:Cx(r),data:r,sessionId:e.sessionId,windowId:e.windowId}),hM({size:Cx(a),data:a,sessionId:e.sessionId,windowId:e.windowId})].flatMap(s=>s)}return[e]}var pc=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(pc||{}),vl=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(vl||{}),pM="[SessionRecording]",gM="redacted",Ex={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},Tee=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],kee=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],Ree=["/s/","/e/","/i/"];function p9(e,t,n,r){if(Xn(e))return e;var a=(t==null?void 0:t["content-length"])||function(s){return new Blob([s]).size}(e);return si(a)&&(a=parseInt(a)),a>n?pM+" ".concat(r," body too large to record (").concat(a," bytes)"):e}function g9(e,t){if(Xn(e))return e;var n=e;return um(n,!1)||(n=pM+" "+t+" body "+gM),tr(kee,r=>{var a,s;(a=n)!==null&&a!==void 0&&a.length&&((s=n)===null||s===void 0?void 0:s.indexOf(r))!==-1&&(n=pM+" "+t+" body "+gM+" as might contain: "+r)}),n}var Oee=(e,t)=>{var n,r,a,s={payloadSizeLimitBytes:Ex.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...Ex.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...Ex.payloadHostDenyList]},u=e.session_recording.recordHeaders!==!1&&t.recordHeaders,d=e.session_recording.recordBody!==!1&&t.recordBody,h=e.capture_performance!==!1&&t.recordPerformance,m=(n=s,a=Math.min(1e6,(r=n.payloadSizeLimitBytes)!==null&&r!==void 0?r:1e6),S=>(S!=null&&S.requestBody&&(S.requestBody=p9(S.requestBody,S.requestHeaders,a,"Request")),S!=null&&S.responseBody&&(S.responseBody=p9(S.responseBody,S.responseHeaders,a,"Response")),S)),y=S=>{return m(((R,T)=>{var A,M=cm(R.name),D=T.indexOf("http")===0?(A=cm(T))===null||A===void 0?void 0:A.pathname:T;D==="/"&&(D="");var $=M==null?void 0:M.pathname.replace(D||"","");if(!(M&&$&&Ree.some(U=>$.indexOf(U)===0)))return R})((E=(x=S).requestHeaders,Xn(E)||tr(Object.keys(E??{}),R=>{Tee.includes(R.toLowerCase())&&(E[R]=gM)}),x),e.api_host));var x,E},v=ml(e.session_recording.maskNetworkRequestFn);return v&&ml(e.session_recording.maskCapturedNetworkRequestFn)&&Ot.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),v&&(e.session_recording.maskCapturedNetworkRequestFn=S=>{var x=e.session_recording.maskNetworkRequestFn({url:S.name});return Le(Le({},S),{},{name:x==null?void 0:x.url})}),s.maskRequestFn=ml(e.session_recording.maskCapturedNetworkRequestFn)?S=>{var x,E,R,T=y(S);return T&&(x=(E=(R=e.session_recording).maskCapturedNetworkRequestFn)===null||E===void 0?void 0:E.call(R,T))!==null&&x!==void 0?x:void 0}:S=>function(x){if(!ut(x))return x.requestBody=g9(x.requestBody,"Request"),x.responseBody=g9(x.responseBody,"Response"),x}(y(S)),Le(Le(Le({},Ex),s),{},{recordHeaders:u,recordBody:d,recordPerformance:h,recordInitialRequests:h})};function cs(e,t,n,r,a){return t>n&&(Ot.warn("min cannot be greater than max."),t=n),Ua(e)?e>n?(r&&Ot.warn(r+" cannot be greater than max: "+n+". Using max value instead."),n):e<t?(r&&Ot.warn(r+" cannot be less than min: "+t+". Using min value instead."),t):e:(r&&Ot.warn(r+" must be a number. using max or fallback. max: "+n+", fallback: "+a),cs(a||n,t,n,r))}class Mee{constructor(t){var n,r,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};et(this,"bucketSize",100),et(this,"refillRate",10),et(this,"mutationBuckets",{}),et(this,"loggedTracker",{}),et(this,"refillBuckets",()=>{Object.keys(this.mutationBuckets).forEach(s=>{this.mutationBuckets[s]=this.mutationBuckets[s]+this.refillRate,this.mutationBuckets[s]>=this.bucketSize&&delete this.mutationBuckets[s]})}),et(this,"getNodeOrRelevantParent",s=>{var u=this.rrweb.mirror.getNode(s);if((u==null?void 0:u.nodeName)!=="svg"&&u instanceof Element){var d=u.closest("svg");if(d)return[this.rrweb.mirror.getId(d),d]}return[s,u]}),et(this,"numberOfChanges",s=>{var u,d,h,m,y,v,S,x;return((u=(d=s.removes)===null||d===void 0?void 0:d.length)!==null&&u!==void 0?u:0)+((h=(m=s.attributes)===null||m===void 0?void 0:m.length)!==null&&h!==void 0?h:0)+((y=(v=s.texts)===null||v===void 0?void 0:v.length)!==null&&y!==void 0?y:0)+((S=(x=s.adds)===null||x===void 0?void 0:x.length)!==null&&S!==void 0?S:0)}),et(this,"throttleMutations",s=>{if(s.type!==3||s.data.source!==0)return s;var u=s.data,d=this.numberOfChanges(u);u.attributes&&(u.attributes=u.attributes.filter(m=>{var y,v,S,[x,E]=this.getNodeOrRelevantParent(m.id);return this.mutationBuckets[x]===0?!1:(this.mutationBuckets[x]=(y=this.mutationBuckets[x])!==null&&y!==void 0?y:this.bucketSize,this.mutationBuckets[x]=Math.max(this.mutationBuckets[x]-1,0),this.mutationBuckets[x]===0&&(this.loggedTracker[x]||(this.loggedTracker[x]=!0,(v=(S=this.options).onBlockedNode)===null||v===void 0||v.call(S,x,E))),m)}));var h=this.numberOfChanges(u);return h!==0||d===h?s:void 0}),this.rrweb=t,this.options=a,this.refillRate=cs((n=this.options.refillRate)!==null&&n!==void 0?n:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=cs((r=this.options.bucketSize)!==null&&r!==void 0?r:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}}var fs=Uint8Array,co=Uint16Array,dm=Uint32Array,mM=new fs([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),vM=new fs([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),m9=new fs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),v9=function(e,t){for(var n=new co(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var a=new dm(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)a[s]=s-n[r]<<5|r;return[n,a]},y9=v9(mM,2),Dee=y9[0],yM=y9[1];Dee[28]=258,yM[258]=28;for(var b9=v9(vM,0)[1],_9=new co(32768),yr=0;yr<32768;++yr){var Rh=(43690&yr)>>>1|(21845&yr)<<1;Rh=(61680&(Rh=(52428&Rh)>>>2|(13107&Rh)<<2))>>>4|(3855&Rh)<<4,_9[yr]=((65280&Rh)>>>8|(255&Rh)<<8)>>>1}var ub=function(e,t,n){for(var r=e.length,a=0,s=new co(t);a<r;++a)++s[e[a]-1];var u,d=new co(t);for(a=0;a<t;++a)d[a]=d[a-1]+s[a-1]<<1;for(u=new co(r),a=0;a<r;++a)u[a]=_9[d[e[a]-1]++]>>>15-e[a];return u},Oh=new fs(288);for(yr=0;yr<144;++yr)Oh[yr]=8;for(yr=144;yr<256;++yr)Oh[yr]=9;for(yr=256;yr<280;++yr)Oh[yr]=7;for(yr=280;yr<288;++yr)Oh[yr]=8;var Ax=new fs(32);for(yr=0;yr<32;++yr)Ax[yr]=5;var Iee=ub(Oh,9),Lee=ub(Ax,5),S9=function(e){return(e/8>>0)+(7&e&&1)},w9=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof co?co:e instanceof dm?dm:fs)(n-t);return r.set(e.subarray(t,n)),r},gc=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},cb=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},bM=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var a=n.length,s=n.slice();if(!a)return[new fs(0),0];if(a==1){var u=new fs(n[0].s+1);return u[n[0].s]=1,[u,1]}n.sort(function(U,P){return U.f-P.f}),n.push({s:-1,f:25001});var d=n[0],h=n[1],m=0,y=1,v=2;for(n[0]={s:-1,f:d.f+h.f,l:d,r:h};y!=a-1;)d=n[n[m].f<n[v].f?m++:v++],h=n[m!=y&&n[m].f<n[v].f?m++:v++],n[y++]={s:-1,f:d.f+h.f,l:d,r:h};var S=s[0].s;for(r=1;r<a;++r)s[r].s>S&&(S=s[r].s);var x=new co(S+1),E=_M(n[y-1],x,0);if(E>t){r=0;var R=0,T=E-t,A=1<<T;for(s.sort(function(U,P){return x[P.s]-x[U.s]||U.f-P.f});r<a;++r){var M=s[r].s;if(!(x[M]>t))break;R+=A-(1<<E-x[M]),x[M]=t}for(R>>>=T;R>0;){var D=s[r].s;x[D]<t?R-=1<<t-x[D]++-1:++r}for(;r>=0&&R;--r){var $=s[r].s;x[$]==t&&(--x[$],++R)}E=t}return[new fs(x),E]},_M=function(e,t,n){return e.s==-1?Math.max(_M(e.l,t,n+1),_M(e.r,t,n+1)):t[e.s]=n},x9=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new co(++t),r=0,a=e[0],s=1,u=function(h){n[r++]=h},d=1;d<=t;++d)if(e[d]==a&&d!=t)++s;else{if(!a&&s>2){for(;s>138;s-=138)u(32754);s>2&&(u(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(u(a),--s;s>6;s-=6)u(8304);s>2&&(u(s-3<<5|8208),s=0)}for(;s--;)u(a);s=1,a=e[d]}return[n.subarray(0,r),t]},fb=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},SM=function(e,t,n){var r=n.length,a=S9(t+2);e[a]=255&r,e[a+1]=r>>>8,e[a+2]=255^e[a],e[a+3]=255^e[a+1];for(var s=0;s<r;++s)e[a+s+4]=n[s];return 8*(a+4+r)},C9=function(e,t,n,r,a,s,u,d,h,m,y){gc(t,y++,n),++a[256];for(var v=bM(a,15),S=v[0],x=v[1],E=bM(s,15),R=E[0],T=E[1],A=x9(S),M=A[0],D=A[1],$=x9(R),U=$[0],P=$[1],Z=new co(19),X=0;X<M.length;++X)Z[31&M[X]]++;for(X=0;X<U.length;++X)Z[31&U[X]]++;for(var K=bM(Z,7),G=K[0],ne=K[1],se=19;se>4&&!G[m9[se-1]];--se);var be,ae,ve,Y,te=m+5<<3,fe=fb(a,Oh)+fb(s,Ax)+u,Ue=fb(a,S)+fb(s,R)+u+14+3*se+fb(Z,G)+(2*Z[16]+3*Z[17]+7*Z[18]);if(te<=fe&&te<=Ue)return SM(t,y,e.subarray(h,h+m));if(gc(t,y,1+(Ue<fe)),y+=2,Ue<fe){be=ub(S,x),ae=S,ve=ub(R,T),Y=R;var B=ub(G,ne);for(gc(t,y,D-257),gc(t,y+5,P-1),gc(t,y+10,se-4),y+=14,X=0;X<se;++X)gc(t,y+3*X,G[m9[X]]);y+=3*se;for(var $e=[M,U],ke=0;ke<2;++ke){var j=$e[ke];for(X=0;X<j.length;++X){var Ge=31&j[X];gc(t,y,B[Ge]),y+=G[Ge],Ge>15&&(gc(t,y,j[X]>>>5&127),y+=j[X]>>>12)}}}else be=Iee,ae=Oh,ve=Lee,Y=Ax;for(X=0;X<d;++X)if(r[X]>255){Ge=r[X]>>>18&31,cb(t,y,be[Ge+257]),y+=ae[Ge+257],Ge>7&&(gc(t,y,r[X]>>>23&31),y+=mM[Ge]);var it=31&r[X];cb(t,y,ve[it]),y+=Y[it],it>3&&(cb(t,y,r[X]>>>5&8191),y+=vM[it])}else cb(t,y,be[r[X]]),y+=ae[r[X]];return cb(t,y,be[256]),y+ae[256]},Nee=new dm([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$ee=function(){for(var e=new dm(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Bee=function(){var e=4294967295;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=$ee[255&n^t[r]]^n>>>8;e=n},d:function(){return 4294967295^e}}},Uee=function(e,t,n,r,a){return function(s,u,d,h,m,y){var v=s.length,S=new fs(h+v+5*(1+Math.floor(v/7e3))+m),x=S.subarray(h,S.length-m),E=0;if(!u||v<8)for(var R=0;R<=v;R+=65535){var T=R+65535;T<v?E=SM(x,E,s.subarray(R,T)):(x[R]=y,E=SM(x,E,s.subarray(R,v)))}else{for(var A=Nee[u-1],M=A>>>13,D=8191&A,$=(1<<d)-1,U=new co(32768),P=new co($+1),Z=Math.ceil(d/3),X=2*Z,K=function(Ct){return(s[Ct]^s[Ct+1]<<Z^s[Ct+2]<<X)&$},G=new dm(25e3),ne=new co(288),se=new co(32),be=0,ae=0,ve=(R=0,0),Y=0,te=0;R<v;++R){var fe=K(R),Ue=32767&R,B=P[fe];if(U[Ue]=B,P[fe]=Ue,Y<=R){var $e=v-R;if((be>7e3||ve>24576)&&$e>423){E=C9(s,x,0,G,ne,se,ae,ve,te,R-te,E),ve=be=ae=0,te=R;for(var ke=0;ke<286;++ke)ne[ke]=0;for(ke=0;ke<30;++ke)se[ke]=0}var j=2,Ge=0,it=D,ze=Ue-B&32767;if($e>2&&fe==K(R-ze))for(var Nt=Math.min(M,$e)-1,dt=Math.min(32767,R),Rt=Math.min(258,$e);ze<=dt&&--it&&Ue!=B;){if(s[R+j]==s[R+j-ze]){for(var Dt=0;Dt<Rt&&s[R+Dt]==s[R+Dt-ze];++Dt);if(Dt>j){if(j=Dt,Ge=ze,Dt>Nt)break;var nt=Math.min(ze,Dt-2),Pe=0;for(ke=0;ke<nt;++ke){var lt=R-ze+ke+32768&32767,gt=lt-U[lt]+32768&32767;gt>Pe&&(Pe=gt,B=lt)}}}ze+=(Ue=B)-(B=U[Ue])+32768&32767}if(Ge){G[ve++]=268435456|yM[j]<<18|b9[Ge];var $t=31&yM[j],ht=31&b9[Ge];ae+=mM[$t]+vM[ht],++ne[257+$t],++se[ht],Y=R+j,++be}else G[ve++]=s[R],++ne[s[R]]}}E=C9(s,x,y,G,ne,se,ae,ve,te,R-te,E)}return w9(S,0,h+S9(E)+m)}(e,t.level==null?6:t.level,t.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)},wM=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},zee=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&wM(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},Hee=function(e){return 10+(e.filename&&e.filename.length+1||0)};function E9(e,t){t===void 0&&(t={});var n=Bee(),r=e.length;n.p(e);var a=Uee(e,t,Hee(t),8),s=a.length;return zee(a,t),wM(a,s-8,n.d()),wM(a,s-4,r),a}function A9(e,t){var n=e.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var r=new fs(e.length+(e.length>>>1)),a=0,s=function(m){r[a++]=m},u=0;u<n;++u){if(a+5>r.length){var d=new fs(a+8+(n-u<<1));d.set(r),r=d}var h=e.charCodeAt(u);h<128||t?s(h):h<2048?(s(192|h>>>6),s(128|63&h)):h>55295&&h<57344?(s(240|(h=65536+(1047552&h)|1023&e.charCodeAt(++u))>>>18),s(128|h>>>12&63),s(128|h>>>6&63),s(128|63&h)):(s(224|h>>>12),s(128|h>>>6&63),s(128|63&h))}return w9(r,0,a)}function Pee(e,t){return function(n){for(var r=0,a=0;a<n.length;a++)r=(r<<5)-r+n.charCodeAt(a),r|=0;return Math.abs(r)}(e)%100<cs(100*t,0,100)}var db="[SessionRecording]",ma=ga(db);function Tx(){var e,t;return Wt==null||(e=Wt.__PosthogExtensions__)===null||e===void 0||(t=e.rrweb)===null||t===void 0?void 0:t.record}var qee=3e5,Fee=[vl.MouseMove,vl.MouseInteraction,vl.Scroll,vl.ViewportResize,vl.Input,vl.TouchMove,vl.MediaInteraction,vl.Drag],T9=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function Mh(e){return function(t,n){for(var r="",a=0;a<t.length;){var s=t[a++];r+=String.fromCharCode(s)}return r}(E9(A9(JSON.stringify(e))))}function k9(e){return e.type===pc.Custom&&e.data.tag==="sessionIdle"}function R9(e,t){return t.some(n=>n.matching==="regex"&&new RegExp(n.url).test(e))}class jee{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(db+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var t,n;return this.triggerStatus==="trigger_pending"?6e4:(t=(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.full_snapshot_interval_millis)!==null&&t!==void 0?t:qee}get isSampled(){var t=this.instance.get_property(ob);return jf(t)?t:null}get sessionDuration(){var t,n,r=(t=this.buffer)===null||t===void 0?void 0:t.data[((n=this.buffer)===null||n===void 0?void 0:n.data.length)-1],{sessionStartTimestamp:a}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return r?r.timestamp-a:null}get isRecordingEnabled(){var t=!!this.instance.get_property(jO),n=!this.instance.config.disable_session_recording;return Ae&&t&&n}get isConsoleLogCaptureEnabled(){var t=!!this.instance.get_property(L5),n=this.instance.config.enable_recording_console_log;return n??t}get canvasRecording(){var t,n,r,a,s,u,d=this.instance.config.session_recording.captureCanvas,h=this.instance.get_property(B5),m=(t=(n=d==null?void 0:d.recordCanvas)!==null&&n!==void 0?n:h==null?void 0:h.enabled)!==null&&t!==void 0&&t,y=(r=(a=d==null?void 0:d.canvasFps)!==null&&a!==void 0?a:h==null?void 0:h.fps)!==null&&r!==void 0?r:4,v=(s=(u=d==null?void 0:d.canvasQuality)!==null&&u!==void 0?u:h==null?void 0:h.quality)!==null&&s!==void 0?s:.4;if(typeof v=="string"){var S=parseFloat(v);v=isNaN(S)?.4:S}return{enabled:m,fps:cs(y,0,12,"canvas recording fps",4),quality:cs(v,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var t,n,r=this.instance.get_property(N5),a={recordHeaders:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.recordHeaders,recordBody:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.recordBody},s=(a==null?void 0:a.recordHeaders)||(r==null?void 0:r.recordHeaders),u=(a==null?void 0:a.recordBody)||(r==null?void 0:r.recordBody),d=qr(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,h=!!(jf(d)?d:r!=null&&r.capturePerformance);return s||u||h?{recordHeaders:s,recordBody:u,recordPerformance:h}:void 0}get masking(){var t,n,r,a,s,u,d=this.instance.get_property($5),h={maskAllInputs:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.maskAllInputs,maskTextSelector:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.maskTextSelector,blockSelector:(r=this.instance.config.session_recording)===null||r===void 0?void 0:r.blockSelector},m=(a=h==null?void 0:h.maskAllInputs)!==null&&a!==void 0?a:d==null?void 0:d.maskAllInputs,y=(s=h==null?void 0:h.maskTextSelector)!==null&&s!==void 0?s:d==null?void 0:d.maskTextSelector,v=(u=h==null?void 0:h.blockSelector)!==null&&u!==void 0?u:d==null?void 0:d.blockSelector;return ut(m)&&ut(y)&&ut(v)?void 0:{maskAllInputs:m==null||m,maskTextSelector:y,blockSelector:v}}get sampleRate(){var t=this.instance.get_property(U5);return Ua(t)?t:null}get minimumDuration(){var t=this.instance.get_property(z5);return Ua(t)?t:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":Xn(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":jf(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var t;return this._urlTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(GO))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var t;return this._eventTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(VO))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var t=this.eventTriggerStatus==="trigger_activated"||this.urlTriggerStatus==="trigger_activated",n=this.eventTriggerStatus==="trigger_pending"||this.urlTriggerStatus==="trigger_pending";return t?"trigger_activated":n?"trigger_pending":"trigger_disabled"}constructor(t){if(et(this,"queuedRRWebEvents",[]),et(this,"isIdle","unknown"),et(this,"_linkedFlagSeen",!1),et(this,"_lastActivityTimestamp",Date.now()),et(this,"_linkedFlag",null),et(this,"_removePageViewCaptureHook",void 0),et(this,"_onSessionIdListener",void 0),et(this,"_persistDecideOnSessionListener",void 0),et(this,"_samplingSessionListener",void 0),et(this,"_urlTriggers",[]),et(this,"_urlBlocklist",[]),et(this,"_urlBlocked",!1),et(this,"_eventTriggers",[]),et(this,"_removeEventTriggerCaptureHook",void 0),et(this,"_forceAllowLocalhostNetworkCapture",!1),et(this,"_onBeforeUnload",()=>{this._flushBuffer()}),et(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),et(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),et(this,"_onVisibilityChange",()=>{if(yt!=null&&yt.visibilityState){var a="window "+yt.visibilityState;this._tryAddCustomEvent(a,{})}}),this.instance=t,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw ma.error("started without valid sessionManager"),new Error(db+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(db+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:n,windowId:r}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=n,this.windowId=r,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&ma.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(t){this.isRecordingEnabled?(this._startCapture(t),Kr(Ae,"beforeunload",this._onBeforeUnload),Kr(Ae,"offline",this._onOffline),Kr(Ae,"online",this._onOnline),Kr(Ae,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),Xn(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",n=>{try{if(n.event==="$pageview"){var r=n!=null&&n.properties.$current_url?this._maskUrl(n==null?void 0:n.properties.$current_url):"";if(!r)return;this._tryAddCustomEvent("$pageview",{href:r})}}catch(a){ma.error("Could not add $pageview to rrweb session",a)}})),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId((n,r,a)=>{var s,u,d,h;a&&(this._tryAddCustomEvent("$session_id_change",{sessionId:n,windowId:r,changeReason:a}),(s=this.instance)===null||s===void 0||(u=s.persistence)===null||u===void 0||u.unregister(VO),(d=this.instance)===null||d===void 0||(h=d.persistence)===null||h===void 0||h.unregister(GO))}))):this.stopRecording()}stopRecording(){var t,n,r,a;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,Ae==null||Ae.removeEventListener("beforeunload",this._onBeforeUnload),Ae==null||Ae.removeEventListener("offline",this._onOffline),Ae==null||Ae.removeEventListener("online",this._onOnline),Ae==null||Ae.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),(t=this._removePageViewCaptureHook)===null||t===void 0||t.call(this),this._removePageViewCaptureHook=void 0,(n=this._removeEventTriggerCaptureHook)===null||n===void 0||n.call(this),this._removeEventTriggerCaptureHook=void 0,(r=this._onSessionIdListener)===null||r===void 0||r.call(this),this._onSessionIdListener=void 0,(a=this._samplingSessionListener)===null||a===void 0||a.call(this),this._samplingSessionListener=void 0,ma.info("stopped"))}_resetSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.unregister(ob)}makeSamplingDecision(t){var n,r=this.sessionId!==t,a=this.sampleRate;if(Ua(a)){var s=this.isSampled,u=r||!jf(s),d=u?Pee(t,a):s;u&&(d?this._reportStarted("sampled"):ma.warn("Sample rate (".concat(a,") has determined that this sessionId (").concat(t,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:a,isSampled:d})),(n=this.instance.persistence)===null||n===void 0||n.register({[ob]:d})}else this._resetSampling()}onRemoteConfig(t){var n,r,a,s,u,d;if(this._tryAddCustomEvent("$remote_config_received",t),this._persistRemoteConfig(t),this._linkedFlag=((n=t.sessionRecording)===null||n===void 0?void 0:n.linkedFlag)||null,(r=t.sessionRecording)!==null&&r!==void 0&&r.endpoint&&(this._endpoint=(d=t.sessionRecording)===null||d===void 0?void 0:d.endpoint),this._setupSampling(),!Xn(this._linkedFlag)&&!this._linkedFlagSeen){var h=si(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,m=si(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((y,v)=>{var S=qr(v)&&h in v,x=m?v[h]===m:S;x&&this._reportStarted("linked_flag_matched",{linkedFlag:h,linkedVariant:m}),this._linkedFlagSeen=x})}(a=t.sessionRecording)!==null&&a!==void 0&&a.urlTriggers&&(this._urlTriggers=t.sessionRecording.urlTriggers),(s=t.sessionRecording)!==null&&s!==void 0&&s.urlBlocklist&&(this._urlBlocklist=t.sessionRecording.urlBlocklist),(u=t.sessionRecording)!==null&&u!==void 0&&u.eventTriggers&&(this._eventTriggers=t.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){Ua(this.sampleRate)&&Xn(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(t=>{this.makeSamplingDecision(t)}))}_persistRemoteConfig(t){if(this.instance.persistence){var n,r=this.instance.persistence,a=()=>{var s,u,d,h,m,y,v,S,x,E=(s=t.sessionRecording)===null||s===void 0?void 0:s.sampleRate,R=Xn(E)?null:parseFloat(E);Xn(R)&&this._resetSampling();var T=(u=t.sessionRecording)===null||u===void 0?void 0:u.minimumDurationMilliseconds;r.register({[jO]:!!t.sessionRecording,[L5]:(d=t.sessionRecording)===null||d===void 0?void 0:d.consoleLogRecordingEnabled,[N5]:Le({capturePerformance:t.capturePerformance},(h=t.sessionRecording)===null||h===void 0?void 0:h.networkPayloadCapture),[$5]:(m=t.sessionRecording)===null||m===void 0?void 0:m.masking,[B5]:{enabled:(y=t.sessionRecording)===null||y===void 0?void 0:y.recordCanvas,fps:(v=t.sessionRecording)===null||v===void 0?void 0:v.canvasFps,quality:(S=t.sessionRecording)===null||S===void 0?void 0:S.canvasQuality},[U5]:R,[z5]:ut(T)?null:T,[H5]:(x=t.sessionRecording)===null||x===void 0?void 0:x.scriptConfig})};a(),(n=this._persistDecideOnSessionListener)===null||n===void 0||n.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(a)}}log(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(n=this.instance.sessionRecording)===null||n===void 0||n.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:r,trace:[],payload:[JSON.stringify(t)]}},timestamp:Date.now()})}_startCapture(t){if(!ut(Object.assign)&&!ut(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var n,r;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),Tx()?this._onScriptLoaded():(n=Wt.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,this.scriptName,a=>{if(a)return ma.error("could not load recorder",a);this._onScriptLoaded()}),ma.info("starting"),this.status==="active"&&this._reportStarted(t||"recording_initialized")}}get scriptName(){var t,n,r;return((t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0||(r=n.get_property(H5))===null||r===void 0?void 0:r.script)||"recorder"}isInteractiveEvent(t){var n;return t.type===3&&Fee.indexOf((n=t.data)===null||n===void 0?void 0:n.source)!==-1}_updateWindowAndSessionIds(t){var n=this.isInteractiveEvent(t);n||this.isIdle||t.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:t.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var r=!1;if(n&&(this._lastActivityTimestamp=t.timestamp,this.isIdle)){var a=this.isIdle==="unknown";this.isIdle=!1,a||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:t.type}),r=!0)}if(!this.isIdle){var{windowId:s,sessionId:u}=this.sessionManager.checkAndGetSessionAndWindowId(!n,t.timestamp),d=this.sessionId!==u,h=this.windowId!==s;this.windowId=s,this.sessionId=u,d||h?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):r&&this._scheduleFullSnapshot()}}_tryRRWebMethod(t){try{return t.rrwebMethod(),!0}catch(n){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:t.enqueuedAt||Date.now(),attempt:t.attempt++,rrwebMethod:t.rrwebMethod}):ma.warn("could not emit queued rrweb event.",n,t),!1}}_tryAddCustomEvent(t,n){return this._tryRRWebMethod(T9(()=>Tx().addCustomEvent(t,n)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(T9(()=>Tx().takeFullSnapshot()))}_onScriptLoaded(){var t,n,r,a,s={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},u=this.instance.config.session_recording;for(var[d,h]of Object.entries(u||{}))d in s&&(d==="maskInputOptions"?s.maskInputOptions=Le({password:!0},h):s[d]=h);this.canvasRecording&&this.canvasRecording.enabled&&(s.recordCanvas=!0,s.sampling={canvas:this.canvasRecording.fps},s.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking&&(s.maskAllInputs=(n=this.masking.maskAllInputs)===null||n===void 0||n,s.maskTextSelector=(r=this.masking.maskTextSelector)!==null&&r!==void 0?r:void 0,s.blockSelector=(a=this.masking.blockSelector)!==null&&a!==void 0?a:void 0);var m=Tx();if(m){this.mutationRateLimiter=(t=this.mutationRateLimiter)!==null&&t!==void 0?t:new Mee(m,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(v,S)=>{var x="Too many mutations on node '".concat(v,"'. Rate limiting. This could be due to SVG animations or something similar");ma.info(x,{node:S}),this.log(db+" "+x,"warn")}});var y=this._gatherRRWebPlugins();this.stopRrweb=m(Le({emit:v=>{this.onRRwebEmit(v)},plugins:y},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=jf(this.isIdle)?this.isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:s,activePlugins:y.map(v=>v==null?void 0:v.name)}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else ma.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle!==!0){var t=this.fullSnapshotIntervalMillis;t&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},t))}}_gatherRRWebPlugins(){var t,n,r,a,s=[],u=(t=Wt.__PosthogExtensions__)===null||t===void 0||(n=t.rrwebPlugins)===null||n===void 0?void 0:n.getRecordConsolePlugin;u&&this.isConsoleLogCaptureEnabled&&s.push(u());var d=(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.rrwebPlugins)===null||a===void 0?void 0:a.getRecordNetworkPlugin;return this.networkPayloadCapture&&ml(d)&&(!XJ.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(d(Oee(this.instance.config,this.networkPayloadCapture))):ma.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(t){var n;if(this._processQueuedEvents(),t&&qr(t)){if(t.type===pc.Meta){var r=this._maskUrl(t.data.href);if(this._lastHref=r,!r)return;t.data.href=r}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(v){return v.type===pc.Custom&&v.data.tag==="recording paused"}(t)){t.type===pc.FullSnapshot&&this._scheduleFullSnapshot(),t.type===pc.FullSnapshot&&this.triggerStatus==="trigger_pending"&&this.clearBuffer();var a=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(t):t;if(a){var s=function(v){var S=v;if(S&&qr(S)&&S.type===6&&qr(S.data)&&S.data.plugin==="rrweb/console@1"){S.data.payload.payload.length>10&&(S.data.payload.payload=S.data.payload.payload.slice(0,10),S.data.payload.payload.push("...[truncated]"));for(var x=[],E=0;E<S.data.payload.payload.length;E++)S.data.payload.payload[E]&&S.data.payload.payload[E].length>2e3?x.push(S.data.payload.payload[E].slice(0,2e3)+"...[truncated]"):x.push(S.data.payload.payload[E]);return S.data.payload.payload=x,v}return v}(a);if(this._updateWindowAndSessionIds(s),this.isIdle!==!0||k9(s)){if(k9(s)){var u=s.data.payload;if(u){var d=u.lastActivityTimestamp,h=u.threshold;s.timestamp=d+h}}var m=(n=this.instance.config.session_recording.compress_events)===null||n===void 0||n?function(v){if(Cx(v)<1024)return v;try{if(v.type===pc.FullSnapshot)return Le(Le({},v),{},{data:Mh(v.data),cv:"2024-10"});if(v.type===pc.IncrementalSnapshot&&v.data.source===vl.Mutation)return Le(Le({},v),{},{cv:"2024-10",data:Le(Le({},v.data),{},{texts:Mh(v.data.texts),attributes:Mh(v.data.attributes),removes:Mh(v.data.removes),adds:Mh(v.data.adds)})});if(v.type===pc.IncrementalSnapshot&&v.data.source===vl.StyleSheetRule)return Le(Le({},v),{},{cv:"2024-10",data:Le(Le({},v.data),{},{adds:v.data.adds?Mh(v.data.adds):void 0,removes:v.data.removes?Mh(v.data.removes):void 0})})}catch(S){ma.error("could not compress event - will use uncompressed event",S)}return v}(s):s,y={$snapshot_bytes:Cx(m),$snapshot_data:m,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(y):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&Ae){var t=this._maskUrl(Ae.location.href);this._lastHref!==t&&(this._tryAddCustomEvent("$url_changed",{href:t}),this._lastHref=t)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var t=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],t.forEach(n=>{Date.now()-n.enqueuedAt<=2e3&&this._tryRRWebMethod(n)})}}_maskUrl(t){var n=this.instance.config.session_recording;if(n.maskNetworkRequestFn){var r,a={url:t};return(r=a=n.maskNetworkRequestFn(a))===null||r===void 0?void 0:r.url}return t}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var t=this.minimumDuration,n=this.sessionDuration,r=Ua(n)&&n>=0,a=Ua(t)&&r&&n<t;return this.status==="buffering"||this.status==="paused"||this.status==="disabled"||a?(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&hM(this.buffer).forEach(s=>{this._captureSnapshot({$snapshot_bytes:s.size,$snapshot_data:s.data,$session_id:s.sessionId,$window_id:s.windowId,$lib:"web",$lib_version:fc.LIB_VERSION})}),this.clearBuffer())}_captureSnapshotBuffered(t){var n,r=2+(((n=this.buffer)===null||n===void 0?void 0:n.data.length)||0);!this.isIdle&&(this.buffer.size+t.$snapshot_bytes+r>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=t.$snapshot_bytes,this.buffer.data.push(t.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_captureSnapshot(t){this.instance.capture("$snapshot",t,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(Ae!==void 0&&Ae.location.href){var t=Ae.location.href,n=this._urlBlocked,r=R9(t,this._urlBlocklist);r&&!n?this._pauseRecording():!r&&n&&this._resumeRecording(),R9(t,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(t){var n,r;this.triggerStatus==="trigger_pending"&&((n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0||r.register({[t==="url"?GO:VO]:this.sessionId}),this._flushBuffer(),this._reportStarted(t+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),ma.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),ma.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&Xn(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",t=>{try{this._eventTriggers.includes(t.event)&&this._activateTrigger("event")}catch(n){ma.error("Could not activate event trigger",n)}}))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.register({[ob]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(t){this._activateTrigger(t)}_reportStarted(t,n){this.instance.register_for_session({$session_recording_start_reason:t}),ma.info(t.replace("_"," "),n),bn(["recording_initialized","session_id_changed"],t)||this._tryAddCustomEvent(t,n)}}var xM=ga("[SegmentIntegration]");function Gee(e,t){var n=e.config.segment;if(!n)return t();(function(r,a){var s=r.config.segment;if(!s)return a();var u=h=>{var m=()=>h.anonymousId()||Yf();r.config.get_device_id=m,h.id()&&(r.register({distinct_id:h.id(),$device_id:m()}),r.persistence.set_property(dc,"identified")),a()},d=s.user();"then"in d&&ml(d.then)?d.then(h=>u(h)):u(d)})(e,()=>{n.register((r=>{Promise&&Promise.resolve||xM.warn("This browser does not have Promise support, and can not use the segment integration");var a=(s,u)=>{var d;if(!u)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(xM.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(xM.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var h=r._calculate_event_properties(u,(d=s.event.properties)!==null&&d!==void 0?d:{},new Date);return s.event.properties=Object.assign({},h,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>a(s,s.event.event),page:s=>a(s,"$pageview"),identify:s=>a(s,"$identify"),screen:s=>a(s,"$screen")}})(e)).then(()=>{t()})})}var O9="posthog-js";function M9(e){var{organization:t,projectId:n,prefix:r,severityAllowList:a=["error"]}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return s=>{var u,d,h,m,y;if(!(a==="*"||a.includes(s.level))||!e.__loaded)return s;s.tags||(s.tags={});var v=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));s.tags["PostHog Person URL"]=v,e.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var S=((u=s.exception)===null||u===void 0?void 0:u.values)||[],x=S.map(R=>Le(Le({},R),{},{stacktrace:R.stacktrace?Le(Le({},R.stacktrace),{},{type:"raw",frames:(R.stacktrace.frames||[]).map(T=>Le(Le({},T),{},{platform:"web:javascript"}))}):void 0})),E={$exception_message:((d=S[0])===null||d===void 0?void 0:d.value)||s.message,$exception_type:(h=S[0])===null||h===void 0?void 0:h.type,$exception_personURL:v,$exception_level:s.level,$exception_list:x,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:((m=S[0])===null||m===void 0?void 0:m.value)||s.message,$sentry_exception_type:(y=S[0])===null||y===void 0?void 0:y.type,$sentry_tags:s.tags};return t&&n&&(E.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+s.event_id),e.exceptions.sendExceptionEvent(E),s}}class Vee{constructor(t,n,r,a,s){this.name=O9,this.setupOnce=function(u){u(M9(t,{organization:n,projectId:r,prefix:a,severityAllowList:s}))}}}var mc,Yee=Ae!=null&&Ae.location?vx(Ae.location.hash,"__posthog")||vx(location.hash,"state"):null,D9="_postHogToolbarParams",I9=ga("[Toolbar]");(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"})(mc||(mc={}));class Zee{constructor(t){this.instance=t}setToolbarState(t){Wt.ph_toolbar_state=t}getToolbarState(){var t;return(t=Wt.ph_toolbar_state)!==null&&t!==void 0?t:mc.UNINITIALIZED}maybeLoadToolbar(){var t,n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!Ae||!yt)return!1;r=(t=r)!==null&&t!==void 0?t:Ae.location,s=(n=s)!==null&&n!==void 0?n:Ae.history;try{if(!a){try{Ae.localStorage.setItem("test","test"),Ae.localStorage.removeItem("test")}catch{return!1}a=Ae==null?void 0:Ae.localStorage}var u,d=Yee||vx(r.hash,"__posthog")||vx(r.hash,"state"),h=d?A5(()=>JSON.parse(atob(decodeURIComponent(d))))||A5(()=>JSON.parse(decodeURIComponent(d))):null;return h&&h.action==="ph_authorize"?((u=h).source="url",u&&Object.keys(u).length>0&&(h.desiredHash?r.hash=h.desiredHash:s?s.replaceState(s.state,"",r.pathname+r.search):r.hash="")):((u=JSON.parse(a.getItem(D9)||"{}")).source="localstorage",delete u.userIntent),!(!u.token||this.instance.config.token!==u.token)&&(this.loadToolbar(u),!0)}catch{return!1}}_callLoadToolbar(t){var n=Wt.ph_load_toolbar||Wt.ph_load_editor;!Xn(n)&&ml(n)?n(t,this.instance):I9.warn("No toolbar load function found")}loadToolbar(t){var n=!(yt==null||!yt.getElementById(P5));if(!Ae||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,a=Le(Le({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(Ae.localStorage.setItem(D9,JSON.stringify(Le(Le({},a),{},{source:void 0}))),this.getToolbarState()===mc.LOADED)this._callLoadToolbar(a);else if(this.getToolbarState()===mc.UNINITIALIZED){var s,u;this.setToolbarState(mc.LOADING),(s=Wt.__PosthogExtensions__)===null||s===void 0||(u=s.loadExternalDependency)===null||u===void 0||u.call(s,this.instance,"toolbar",d=>{if(d)return I9.error("[Toolbar] Failed to load",d),void this.setToolbarState(mc.UNINITIALIZED);this.setToolbarState(mc.LOADED),this._callLoadToolbar(a)}),Kr(Ae,"turbolinks:load",()=>{this.setToolbarState(mc.UNINITIALIZED),this.loadToolbar(a)})}return!0}_loadEditor(t){return this.loadToolbar(t)}maybeLoadEditor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(t,n,r)}}var Qee=ga("[TracingHeaders]");class Kee{constructor(t){et(this,"_restoreXHRPatch",void 0),et(this,"_restoreFetchPatch",void 0),et(this,"_startCapturing",()=>{var n,r,a,s;ut(this._restoreXHRPatch)&&((n=Wt.__PosthogExtensions__)===null||n===void 0||(r=n.tracingHeadersPatchFns)===null||r===void 0||r._patchXHR(this.instance.sessionManager)),ut(this._restoreFetchPatch)&&((a=Wt.__PosthogExtensions__)===null||a===void 0||(s=a.tracingHeadersPatchFns)===null||s===void 0||s._patchFetch(this.instance.sessionManager))}),this.instance=t}_loadScript(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.tracingHeadersPatchFns&&t(),(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"tracing-headers",s=>{if(s)return Qee.error("failed to load script",s);t()})}startIfEnabledOrStop(){var t,n;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((t=this._restoreXHRPatch)===null||t===void 0||t.call(this),(n=this._restoreFetchPatch)===null||n===void 0||n.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var Qf=ga("[Web Vitals]"),L9=9e5;let Xee=class{constructor(t){var n;et(this,"_enabledServerSide",!1),et(this,"_initialized",!1),et(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),et(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((r,a)=>Le(Le({},r),{},{["$web_vitals_".concat(a.name,"_event")]:Le({},a),["$web_vitals_".concat(a.name,"_value")]:a.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),et(this,"_addToBuffer",r=>{var a,s=(a=this.instance.sessionManager)===null||a===void 0?void 0:a.checkAndGetSessionAndWindowId(!0);if(ut(s))Qf.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var u=this._currentURL();ut(u)||(Xn(r==null?void 0:r.name)||Xn(r==null?void 0:r.value)?Qf.error("Invalid metric received",r):this._maxAllowedValue&&r.value>=this._maxAllowedValue?Qf.error("Ignoring metric with value >= "+this._maxAllowedValue,r):(this.buffer.url!==u&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),ut(this.buffer.url)&&(this.buffer.url=u),this.buffer.firstMetricTimestamp=ut(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(Le(Le({},r),{},{$current_url:u,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),et(this,"_startCapturing",()=>{var r,a,s,u,d=Wt.__PosthogExtensions__;ut(d)||ut(d.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:a,onFCP:s,onINP:u}=d.postHogWebVitalsCallbacks),r&&a&&s&&u?(this.allowedMetrics.indexOf("LCP")>-1&&r(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&a(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&u(this._addToBuffer.bind(this)),this._initialized=!0):Qf.error("web vitals callbacks not loaded - not starting")}),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[M5]),this.startIfEnabled()}get allowedMetrics(){var t,n,r=qr(this.instance.config.capture_performance)?(t=this.instance.config.capture_performance)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return ut(r)?((n=this.instance.persistence)===null||n===void 0?void 0:n.props[I5])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(qr(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var t=qr(this.instance.config.capture_performance)&&Ua(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:L9;return 0<t&&t<=6e4?L9:t}get isEnabled(){var t=uo==null?void 0:uo.protocol;if(t!=="http:"&&t!=="https:")return Qf.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=qr(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return jf(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Qf.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(t){var n=qr(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=qr(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[M5]:n}),this.instance.persistence.register({[I5]:r})),this._enabledServerSide=n,this.startIfEnabled()}loadScript(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.postHogWebVitalsCallbacks&&t(),(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"web-vitals",s=>{s?Qf.error("failed to load script",s):t()})}_currentURL(){var t=Ae?Ae.location.href:void 0;return t||Qf.error("Could not determine current URL"),t}};var Wee=ga("[Heatmaps]");function N9(e){return qr(e)&&"clientX"in e&&"clientY"in e&&Ua(e.clientX)&&Ua(e.clientY)}class Jee{constructor(t){var n;et(this,"rageclicks",new n9),et(this,"_enabledServerSide",!1),et(this,"_initialized",!1),et(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[FO])}get flushIntervalMilliseconds(){var t=5e3;return qr(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(t=this.instance.config.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return ut(this.instance.config.capture_heatmaps)?ut(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Wee.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var t,n;clearInterval((t=this._flushInterval)!==null&&t!==void 0?t:void 0),(n=this.deadClicksCapture)===null||n===void 0||n.stop(),this.getAndClearBuffer()}}onRemoteConfig(t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[FO]:n}),this._enabledServerSide=n,this.startIfEnabled()}getAndClearBuffer(){var t=this.buffer;return this.buffer=void 0,t}_onDeadClick(t){this._onClick(t.originalEvent,"deadclick")}_setupListeners(){Ae&&yt&&(Kr(Ae,"beforeunload",this.flush.bind(this)),Kr(yt,"click",t=>this._onClick(t||(Ae==null?void 0:Ae.event)),{capture:!0}),Kr(yt,"mousemove",t=>this._onMouseMove(t||(Ae==null?void 0:Ae.event)),{capture:!0}),this.deadClicksCapture=new s9(this.instance,dee,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(t,n){var r=this.instance.scrollManager.scrollY(),a=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),u=function(d,h,m){for(var y=d;y&&hx(y)&&!Vf(y,"body");){if(y===m)return!1;if(bn(h,Ae==null?void 0:Ae.getComputedStyle(y).position))return!0;y=Q5(y)}return!1}(Z5(t),["fixed","sticky"],s);return{x:t.clientX+(u?0:a),y:t.clientY+(u?0:r),target_fixed:u,type:n}}_onClick(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"click";if(!F5(t.target)&&N9(t)){var a=this._getProperties(t,r);(n=this.rageclicks)!==null&&n!==void 0&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._capture(Le(Le({},a),{},{type:"rageclick"})),this._capture(a)}}_onMouseMove(t){!F5(t.target)&&N9(t)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(t,"mousemove"))},500))}_capture(t){if(Ae){var n=Ae.location.href;this.buffer=this.buffer||{},this.buffer[n]||(this.buffer[n]=[]),this.buffer[n].push(t)}}flush(){this.buffer&&!sm(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class ete{constructor(t){this._instance=t}doPageView(t,n){var r,a=this._previousPageViewProperties(t,n);return this._currentPageview={pathname:(r=Ae==null?void 0:Ae.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),a}doPageLeave(t){var n;return this._previousPageViewProperties(t,(n=this._currentPageview)===null||n===void 0?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this._currentPageview)===null||t===void 0?void 0:t.pageViewId}}_previousPageViewProperties(t,n){var r=this._currentPageview;if(!r)return{$pageview_id:n};var a={$pageview_id:n,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:u,lastScrollY:d,maxScrollY:h,maxContentHeight:m,lastContentY:y,maxContentY:v}=s;if(!(ut(u)||ut(d)||ut(h)||ut(m)||ut(y)||ut(v))){u=Math.ceil(u),d=Math.ceil(d),h=Math.ceil(h),m=Math.ceil(m),y=Math.ceil(y),v=Math.ceil(v);var S=u<=1?1:cs(d/u,0,1),x=u<=1?1:cs(h/u,0,1),E=m<=1?1:cs(y/m,0,1),R=m<=1?1:cs(v/m,0,1);a=li(a,{$prev_pageview_last_scroll:d,$prev_pageview_last_scroll_percentage:S,$prev_pageview_max_scroll:h,$prev_pageview_max_scroll_percentage:x,$prev_pageview_last_content:y,$prev_pageview_last_content_percentage:E,$prev_pageview_max_content:v,$prev_pageview_max_content_percentage:R})}}return r.pathname&&(a.$prev_pageview_pathname=r.pathname),r.timestamp&&(a.$prev_pageview_duration=(t.getTime()-r.timestamp.getTime())/1e3),a}}class tte{constructor(t){this.instance=t}sendExceptionEvent(t){this.instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var ds="Mobile",kx="iOS",ou="Android",hb="Tablet",$9=ou+" "+hb,B9="iPad",U9="Apple",z9=U9+" Watch",pb="Safari",hm="BlackBerry",H9="Samsung",P9=H9+"Browser",q9=H9+" Internet",Dh="Chrome",nte=Dh+" OS",F9=Dh+" "+kx,CM="Internet Explorer",j9=CM+" "+ds,EM="Opera",rte=EM+" Mini",AM="Edge",G9="Microsoft "+AM,pm="Firefox",V9=pm+" "+kx,gb="Nintendo",mb="PlayStation",gm="Xbox",Y9=ou+" "+ds,Z9=ds+" "+pb,vb="Windows",TM=vb+" Phone",Q9="Nokia",kM="Ouya",K9="Generic",ite=K9+" "+ds.toLowerCase(),X9=K9+" "+hb.toLowerCase(),RM="Konqueror",za="(\\d+(\\.\\d+)?)",OM=new RegExp("Version/"+za),ate=new RegExp(gm,"i"),ote=new RegExp(mb+" \\w+","i"),ste=new RegExp(gb+" \\w+","i"),MM=new RegExp(hm+"|PlayBook|BB10","i"),lte={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},DM,ute=(e,t)=>t&&bn(t,U9)||function(n){return bn(n,pb)&&!bn(n,Dh)&&!bn(n,ou)}(e),W9=function(e,t){return t=t||"",bn(e," OPR/")&&bn(e,"Mini")?rte:bn(e," OPR/")?EM:MM.test(e)?hm:bn(e,"IE"+ds)||bn(e,"WPDesktop")?j9:bn(e,P9)?q9:bn(e,AM)||bn(e,"Edg/")?G9:bn(e,"FBIOS")?"Facebook "+ds:bn(e,"UCWEB")||bn(e,"UCBrowser")?"UC Browser":bn(e,"CriOS")?F9:bn(e,"CrMo")||bn(e,Dh)?Dh:bn(e,ou)&&bn(e,pb)?Y9:bn(e,"FxiOS")?V9:bn(e.toLowerCase(),RM.toLowerCase())?RM:ute(e,t)?bn(e,ds)?Z9:pb:bn(e,pm)?pm:bn(e,"MSIE")||bn(e,"Trident/")?CM:bn(e,"Gecko")?pm:""},cte={[j9]:[new RegExp("rv:"+za)],[G9]:[new RegExp(AM+"?\\/"+za)],[Dh]:[new RegExp("("+Dh+"|CrMo)\\/"+za)],[F9]:[new RegExp("CriOS\\/"+za)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+za)],[pb]:[OM],[Z9]:[OM],[EM]:[new RegExp("(Opera|OPR)\\/"+za)],[pm]:[new RegExp(pm+"\\/"+za)],[V9]:[new RegExp("FxiOS\\/"+za)],[RM]:[new RegExp("Konqueror[:/]?"+za,"i")],[hm]:[new RegExp(hm+" "+za),OM],[Y9]:[new RegExp("android\\s"+za,"i")],[q9]:[new RegExp(P9+"\\/"+za)],[CM]:[new RegExp("(rv:|MSIE )"+za)],Mozilla:[new RegExp("rv:"+za)]},J9=[[new RegExp(gm+"; "+gm+" (.*?)[);]","i"),e=>[gm,e&&e[1]||""]],[new RegExp(gb,"i"),[gb,""]],[new RegExp(mb,"i"),[mb,""]],[MM,[hm,""]],[new RegExp(vb,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[TM,""];if(new RegExp(ds).test(t)&&!/IEMobile\b/.test(t))return[vb+" "+ds,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=n[1],a=lte[r]||"";return/arm/i.test(t)&&(a="RT"),[vb,a]}return[vb,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[kx,t.join(".")]}return[kx,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ut(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ou+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ou+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ou,t.join(".")]}return[ou,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[nte,""]],[/Linux|debian/i,["Linux",""]]],e8=function(e){return ste.test(e)?gb:ote.test(e)?mb:ate.test(e)?gm:new RegExp(kM,"i").test(e)?kM:new RegExp("("+TM+"|WPDesktop)","i").test(e)?TM:/iPad/.test(e)?B9:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?z9:MM.test(e)?hm:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Q9,"i").test(e)?Q9:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ds).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ou:$9:ou:new RegExp("(pda|"+ds+")","i").test(e)?ite:new RegExp(hb,"i").test(e)&&!new RegExp(hb+" pc","i").test(e)?X9:""},Rx="https?://(.*)",Ox=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],fte=ox(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ox),IM="<masked>",Ar={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!yt)return{};var r=t?ox([],Ox,n||[]):[];return this._campaignParamsFromUrl(rM(yt.URL,r,IM),e)},_campaignParamsFromUrl:function(e,t){var n=fte.concat(t||[]),r={};return tr(n,function(a){var s=mx(e,a);r[a]=s||null}),r},_searchEngine:function(e){return e?e.search(Rx+"google.([^/?]*)")===0?"google":e.search(Rx+"bing.com")===0?"bing":e.search(Rx+"yahoo.com")===0?"yahoo":e.search(Rx+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=Ar._searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(!Ff(t)){r.$search_engine=t;var a=yt?mx(yt.referrer,n):"";a.length&&(r.ph_keyword=a)}return r},searchInfo:function(){var e=yt==null?void 0:yt.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:W9,browserVersion:function(e,t){var n=W9(e,t),r=cte[n];if(ut(r))return null;for(var a=0;a<r.length;a++){var s=r[a],u=e.match(s);if(u)return parseFloat(u[u.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return typeof e=="string"?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<J9.length;t++){var[n,r]=J9[t],a=n.exec(e),s=a&&(ml(r)?r(a,e):r);if(s)return s}return["",""]},device:e8,deviceType:function(e){var t=e8(e);return t===B9||t===$9||t==="Kobo"||t==="Kindle Fire"||t===X9?hb:t===gb||t===gm||t===mb||t===kM?"Console":t===z9?"Wearable":t?ds:"Desktop"},referrer:function(){return(yt==null?void 0:yt.referrer)||"$direct"},referringDomain:function(){var e;return yt!=null&&yt.referrer&&((e=cm(yt.referrer))===null||e===void 0?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e?ox([],Ox,t||[]):[],r=uo==null?void 0:uo.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:r?rM(r,n,IM):void 0}},personPropsFromInfo:function(e){var t,{r:n,u:r}=e,a={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(t=cm(n))===null||t===void 0?void 0:t.host};if(r){a.$current_url=r;var s=cm(r);a.$host=s==null?void 0:s.host,a.$pathname=s==null?void 0:s.pathname;var u=this._campaignParamsFromUrl(r);li(a,u)}if(n){var d=this._searchInfoFromReferrer(n);li(a,d)}return a},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),n={};return tr(t,function(r,a){n["$initial_".concat(PO(a))]=r}),n},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}},timezoneOffset:function(){try{return new Date().getTimezoneOffset()}catch{return}},properties:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!oi)return{};var n=e?ox([],Ox,t||[]):[],[r,a]=Ar.os(oi);return li(rb({$os:r,$os_version:a,$browser:Ar.browser(oi,navigator.vendor),$device:Ar.device(oi),$device_type:Ar.deviceType(oi),$timezone:Ar.timezone(),$timezone_offset:Ar.timezoneOffset()}),{$current_url:rM(uo==null?void 0:uo.href,n,IM),$host:uo==null?void 0:uo.host,$pathname:uo==null?void 0:uo.pathname,$raw_user_agent:oi.length>1e3?oi.substring(0,997)+"...":oi,$browser_version:Ar.browserVersion(oi,navigator.vendor),$browser_language:Ar.browserLanguage(),$browser_language_prefix:Ar.browserLanguagePrefix(),$screen_height:Ae==null?void 0:Ae.screen.height,$screen_width:Ae==null?void 0:Ae.screen.width,$viewport_height:Ae==null?void 0:Ae.innerHeight,$viewport_width:Ae==null?void 0:Ae.innerWidth,$lib:"web",$lib_version:fc.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!oi)return{};var[e,t]=Ar.os(oi);return li(rb({$os:e,$os_version:t,$browser:Ar.browser(oi,navigator.vendor)}),{$browser_version:Ar.browserVersion(oi,navigator.vendor)})}},su=ga("[FeatureFlags]"),LM="$active_feature_flags",mm="$override_feature_flags",t8="$feature_flag_payloads",yb="$override_feature_flag_payloads",n8="$feature_flag_request_id",r8=e=>{var t={};for(var[n,r]of sx(e||{}))r&&(t[n]=r);return t},dte=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(n=>{var r;return[n,(r=t[n].variant)!==null&&r!==void 0?r:t[n].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(n=>t[n].enabled).filter(n=>{var r;return(r=t[n].metadata)===null||r===void 0?void 0:r.payload}).map(n=>{var r;return[n,(r=t[n].metadata)===null||r===void 0?void 0:r.payload]}))):su.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e};(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(DM||(DM={}));class hte{constructor(t){et(this,"_override_warning",!1),et(this,"_hasLoadedFlags",!1),et(this,"_requestInFlight",!1),et(this,"_reloadingDisabled",!1),et(this,"_additionalReloadRequested",!1),et(this,"_decideCalled",!1),et(this,"_flagsLoadedFromRemote",!1),this.instance=t,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var t=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:t})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.instance.get_property(YO),n=this.instance.get_property(mm),r=this.instance.get_property(yb);if(!r&&!n)return t||{};var a=li({},t||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var u of s){var d,h,m=a[u],y=n==null?void 0:n[u],v=ut(y)?(d=m==null?void 0:m.enabled)!==null&&d!==void 0&&d:!!y,S=ut(y)?m.variant:typeof y=="string"?y:void 0,x=r==null?void 0:r[u],E=Le(Le({},m),{},{enabled:v,variant:v?S??(m==null?void 0:m.variant):void 0});v!==(m==null?void 0:m.enabled)&&(E.original_enabled=m==null?void 0:m.enabled),S!==(m==null?void 0:m.variant)&&(E.original_variant=m==null?void 0:m.variant),x&&(E.metadata=Le(Le({},m==null?void 0:m.metadata),{},{payload:x,original_payload:m==null||(h=m.metadata)===null||h===void 0?void 0:h.payload})),a[u]=E}return this._override_warning||(su.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:a}),this._override_warning=!0),a}getFlagVariants(){var t=this.instance.get_property(lm),n=this.instance.get_property(mm);if(!n)return t||{};for(var r=li({},t),a=Object.keys(n),s=0;s<a.length;s++)r[a[s]]=n[a[s]];return this._override_warning||(su.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:n,finalFlags:r}),this._override_warning=!0),r}getFlagPayloads(){var t=this.instance.get_property(t8),n=this.instance.get_property(yb);if(!n)return t||{};for(var r=li({},t||{}),a=Object.keys(n),s=0;s<a.length;s++)r[a[s]]=n[a[s]];return this._override_warning||(su.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:n,finalPayloads:r}),this._override_warning=!0),r}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout(()=>{this._callDecideEndpoint()},5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this._reloadingDisabled=t}_callDecideEndpoint(t){var n;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Le(Le({},((n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())||{}),this.instance.get_property(sb)||{}),group_properties:this.instance.get_property(Th)};(t!=null&&t.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0);var a=this.instance.config.__preview_flags_v2&&this.instance.config.__preview_remote_config;a&&(r.timezone=Ar.timezone()),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api",a?"/flags/?v=2":"/decide/?v=4"),data:r,compression:this.instance.config.disable_compression?void 0:gl.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:s=>{var u,d,h,m=!0;s.statusCode===200&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),m=!1),this._requestInFlight=!1,this._decideCalled||(this._decideCalled=!0,this.instance._onRemoteConfig((h=s.json)!==null&&h!==void 0?h:{})),r.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!m,s.json&&(u=s.json.quotaLimited)!==null&&u!==void 0&&u.includes(DM.FeatureFlags)?su.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags((d=s.json)!==null&&d!==void 0?d:{},m),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[t],a="".concat(r),s=this.instance.get_property(n8)||void 0,u=this.instance.get_property(fx)||{};if((n.send_event||!("send_event"in n))&&(!(t in u)||!u[t].includes(a))){var d,h,m,y,v,S,x,E,R,T,A;Pr(u[t])?u[t].push(a):u[t]=[a],(d=this.instance.persistence)===null||d===void 0||d.register({[fx]:u});var M=this.getFeatureFlagDetails(t),D={$feature_flag:t,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(t)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:((h=this.instance.config.bootstrap)===null||h===void 0||(m=h.featureFlags)===null||m===void 0?void 0:m[t])||null,$feature_flag_bootstrapped_payload:((y=this.instance.config.bootstrap)===null||y===void 0||(v=y.featureFlagPayloads)===null||v===void 0?void 0:v[t])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};ut(M==null||(S=M.metadata)===null||S===void 0?void 0:S.version)||(D.$feature_flag_version=M.metadata.version);var $,U=(x=M==null||(E=M.reason)===null||E===void 0?void 0:E.description)!==null&&x!==void 0?x:M==null||(R=M.reason)===null||R===void 0?void 0:R.code;U&&(D.$feature_flag_reason=U),M!=null&&(T=M.metadata)!==null&&T!==void 0&&T.id&&(D.$feature_flag_id=M.metadata.id),ut(M==null?void 0:M.original_variant)&&ut(M==null?void 0:M.original_enabled)||(D.$feature_flag_original_response=ut(M.original_variant)?M.original_enabled:M.original_variant),M!=null&&(A=M.metadata)!==null&&A!==void 0&&A.original_payload&&(D.$feature_flag_original_payload=M==null||($=M.metadata)===null||$===void 0?void 0:$.original_payload),this.instance.capture("$feature_flag_called",D)}return r}su.warn('getFeatureFlag for key "'+t+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){return this.getFlagPayloads()[t]}getRemoteConfigPayload(t,n){var r=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=4"),data:{distinct_id:this.instance.get_distinct_id(),token:r},compression:this.instance.config.disable_compression?void 0:gl.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:a=>{var s,u=(s=a.json)===null||s===void 0?void 0:s.featureFlagPayloads;n((u==null?void 0:u[t])||void 0)}})}isFeatureEnabled(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(t,n);su.warn('isFeatureEnabled for key "'+t+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==t)}receivedFeatureFlags(t,n){if(this.instance.persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),a=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(u,d){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},y=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},v=dte(u),S=v.flags,x=v.featureFlags,E=v.featureFlagPayloads;if(x){var R=u.requestId;if(Pr(x)){su.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var T={};if(x)for(var A=0;A<x.length;A++)T[x[A]]=!0;d&&d.register({[LM]:x,[lm]:T})}else{var M=x,D=E,$=S;u.errorsWhileComputingFlags&&(M=Le(Le({},h),M),D=Le(Le({},m),D),$=Le(Le({},y),$)),d&&d.register(Le({[LM]:Object.keys(r8(M)),[lm]:M||{},[t8]:D||{},[YO]:$||{}},R?{[n8]:R}:{}))}}})(t,this.instance.persistence,r,a,s),this._fireFeatureFlagsCallbacks(n)}}override(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];su.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:n})}overrideFeatureFlags(t){if(!this.instance.__loaded||!this.instance.persistence)return su.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.instance.persistence.unregister(mm),this.instance.persistence.unregister(yb),void this._fireFeatureFlagsCallbacks();if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,r=t;if(this._override_warning=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this.instance.persistence.unregister(mm);else if(r.flags)if(Pr(r.flags)){for(var a={},s=0;s<r.flags.length;s++)a[r.flags[s]]=!0;this.instance.persistence.register({[mm]:a})}else this.instance.persistence.register({[mm]:r.flags})}return"payloads"in r&&(r.payloads===!1?this.instance.persistence.unregister(yb):r.payloads&&this.instance.persistence.register({[yb]:r.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this._hasLoadedFlags){var{flags:n,flagVariants:r}=this._prepareFeatureFlagsForCallbacks();t(n,r)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,n){var r,a=(this.instance.get_property(ux)||[]).find(h=>h.flagKey===t),s={["$feature_enrollment/".concat(t)]:n},u={$feature_flag:t,$feature_enrollment:n,$set:s};a&&(u.$early_access_feature_name=a.name),this.instance.capture("$feature_enrollment_update",u),this.setPersonPropertiesForFlags(s,!1);var d=Le(Le({},this.getFlagVariants()),{},{[t]:n});(r=this.instance.persistence)===null||r===void 0||r.register({[LM]:Object.keys(r8(d)),[lm]:d}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1],r=arguments.length>2?arguments[2]:void 0,a=this.instance.get_property(ux),s=r?"&".concat(r.map(u=>"stage=".concat(u)).join("&")):"";if(a&&!n)return t(a);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(s)),method:"GET",callback:u=>{var d;if(u.json){var h=u.json.earlyAccessFeatures;return(d=this.instance.persistence)===null||d===void 0||d.register({[ux]:h}),t(h)}}})}_prepareFeatureFlagsForCallbacks(){var t=this.getFlags(),n=this.getFlagVariants();return{flags:t.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,a)=>(r[a]=n[a],r),{})}}_fireFeatureFlagsCallbacks(t){var{flags:n,flagVariants:r}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(a=>a(n,r,{errorsLoading:t}))}setPersonPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(sb)||{};this.instance.register({[sb]:Le(Le({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(sb)}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(Th)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(a=>{r[a]=Le(Le({},r[a]),t[a]),delete t[a]}),this.instance.register({[Th]:Le(Le({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var n=this.instance.get_property(Th)||{};this.instance.register({[Th]:Le(Le({},n),{},{[t]:{}})})}else this.instance.unregister(Th)}}var pte=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class NM{constructor(t){this.config=t,this.props={},this.campaign_params_saved=!1,this.name=(n=>{var r="";return n.token&&(r=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+r+"_posthog"})(t),this.storage=this.buildStorage(t),this.load(),t.debug&&Ot.info("Persistence loaded",t.persistence,Le({},this.props)),this.update_config(t,t),this.save()}buildStorage(t){pte.indexOf(t.persistence.toLowerCase())===-1&&(Ot.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n=t.persistence.toLowerCase();return n==="localstorage"&&Si.is_supported()?Si:n==="localstorage+cookie"&&bx.is_supported()?bx:n==="sessionstorage"&&Qi.is_supported()?Qi:n==="memory"?cee:n==="cookie"?hc:bx.is_supported()?bx:hc}properties(){var t={};return tr(this.props,function(n,r){if(r===lm&&qr(n))for(var a=Object.keys(n),s=0;s<a.length;s++)t["$feature/".concat(a[s])]=n[a[s]];else d=r,h=!1,(Ff(u=FJ)?h:y5&&u.indexOf===y5?u.indexOf(d)!=-1:(tr(u,function(m){if(h||(h=m===d))return ax}),h))||(t[r]=n);var u,d,h}),t}load(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=li({},t))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(t,n,r){if(qr(t)){ut(n)&&(n="None"),this.expire_days=ut(r)?this.default_expiry:r;var a=!1;if(tr(t,(s,u)=>{this.props.hasOwnProperty(u)&&this.props[u]!==n||(this.props[u]=s,a=!0)}),a)return this.save(),!0}return!1}register(t,n){if(qr(t)){this.expire_days=ut(n)?this.default_expiry:n;var r=!1;if(tr(t,(a,s)=>{t.hasOwnProperty(s)&&this.props[s]!==a&&(this.props[s]=a,r=!0)}),r)return this.save(),!0}return!1}unregister(t){t in this.props&&(delete this.props[t],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var t=Ar.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});sm(rb(t))||this.register(t),this.campaign_params_saved=!0}}update_search_keyword(){this.register(Ar.searchInfo())}update_referrer_info(){this.register_once(Ar.referrerInfo(),void 0)}set_initial_person_info(){this.props[XO]||this.props[WO]||this.register_once({[JO]:Ar.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return rb({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var t={};tr([WO,XO],a=>{var s=this.props[a];s&&tr(s,function(u,d){t["$initial_"+PO(d)]=u})});var n=this.props[JO];if(n){var r=Ar.initialPersonPropsFromInfo(n);li(t,r)}return t}safe_merge(t){return tr(this.props,function(n,r){r in t||(t[r]=n)}),t}update_config(t,n){if(this.default_expiry=this.expire_days=t.cookie_expiration,this.set_disabled(t.disable_persistence),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),t.persistence!==n.persistence){var r=this.buildStorage(t),a=this.props;this.clear(),this.storage=r,this.props=a,this.save()}}set_disabled(t){this.disabled=t,this.disabled?this.remove():this.save()}set_cross_subdomain(t){t!==this.cross_subdomain&&(this.cross_subdomain=t,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(t){t!==this.secure&&(this.secure=t,this.remove(),this.save())}set_event_timer(t,n){var r=this.props[ab]||{};r[t]=n,this.props[ab]=r,this.save()}remove_event_timer(t){var n=(this.props[ab]||{})[t];return ut(n)||(delete this.props[ab][t],this.save()),n}get_property(t){return this.props[t]}set_property(t,n){this.props[t]=n,this.save()}}var i8,Fr,a8,Ih,o8,s8,$M,l8,u8,c8,f8,d8,h8,BM={},p8=[],gte=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,UM=Array.isArray;function Kf(e,t){for(var n in t)e[n]=t[n];return e}function g8(e){var t=e.parentNode;t&&t.removeChild(e)}function zM(e,t,n,r,a){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:a??++a8,__i:-1,__u:0};return a==null&&Fr.vnode!=null&&Fr.vnode(s),s}function HM(e){return e.children}function Mx(e,t){this.props=e,this.context=t}function vm(e,t){if(t==null)return e.__?vm(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?vm(e):null}function m8(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return m8(e)}}function PM(e){(!e.__d&&(e.__d=!0)&&Ih.push(e)&&!Dx.__r++||o8!==Fr.debounceRendering)&&((o8=Fr.debounceRendering)||s8)(Dx)}function Dx(){var e,t,n,r,a,s,u,d,h;for(Ih.sort($M);e=Ih.shift();)e.__d&&(t=Ih.length,r=void 0,s=(a=(n=e).__v).__e,d=[],h=[],(u=n.__P)&&((r=Kf({},a)).__v=a.__v+1,Fr.vnode&&Fr.vnode(r),w8(u,r,a,n.__n,u.ownerSVGElement!==void 0,32&a.__u?[s]:null,d,s??vm(a),!!(32&a.__u),h),r.__.__k[r.__i]=r,yte(d,r,h),r.__e!=s&&m8(r)),Ih.length>t&&Ih.sort($M));Dx.__r=0}function v8(e,t,n,r,a,s,u,d,h,m,y){var v,S,x,E,R,T=r&&r.__k||p8,A=t.length;for(n.__d=h,mte(n,t,T),h=n.__d,v=0;v<A;v++)(x=n.__k[v])!=null&&typeof x!="boolean"&&typeof x!="function"&&(S=x.__i===-1?BM:T[x.__i]||BM,x.__i=v,w8(e,x,S,a,s,u,d,h,m,y),E=x.__e,x.ref&&S.ref!=x.ref&&(S.ref&&qM(S.ref,null,x),y.push(x.ref,x.__c||E,x)),R==null&&E!=null&&(R=E),65536&x.__u||S.__k===x.__k?h=y8(x,h,e):typeof x.type=="function"&&x.__d!==void 0?h=x.__d:E&&(h=E.nextSibling),x.__d=void 0,x.__u&=-196609);n.__d=h,n.__e=R}function mte(e,t,n){var r,a,s,u,d,h=t.length,m=n.length,y=m,v=0;for(e.__k=[],r=0;r<h;r++)(a=e.__k[r]=(a=t[r])==null||typeof a=="boolean"||typeof a=="function"?null:typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?zM(null,a,null,null,a):UM(a)?zM(HM,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?zM(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a)!=null?(a.__=e,a.__b=e.__b+1,d=vte(a,n,u=r+v,y),a.__i=d,s=null,d!==-1&&(y--,(s=n[d])&&(s.__u|=131072)),s==null||s.__v===null?(d==-1&&v--,typeof a.type!="function"&&(a.__u|=65536)):d!==u&&(d===u+1?v++:d>u?y>h-u?v+=d-u:v--:v=d<u&&d==u-1?d-u:0,d!==r+v&&(a.__u|=65536))):(s=n[r])&&s.key==null&&s.__e&&(s.__e==e.__d&&(e.__d=vm(s)),FM(s,s,!1),n[r]=null,y--);if(y)for(r=0;r<m;r++)(s=n[r])!=null&&(131072&s.__u)==0&&(s.__e==e.__d&&(e.__d=vm(s)),FM(s,s))}function y8(e,t,n){var r,a;if(typeof e.type=="function"){for(r=e.__k,a=0;r&&a<r.length;a++)r[a]&&(r[a].__=e,t=y8(r[a],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function vte(e,t,n,r){var a=e.key,s=e.type,u=n-1,d=n+1,h=t[n];if(h===null||h&&a==h.key&&s===h.type)return n;if(r>(h!=null&&(131072&h.__u)==0?1:0))for(;u>=0||d<t.length;){if(u>=0){if((h=t[u])&&(131072&h.__u)==0&&a==h.key&&s===h.type)return u;u--}if(d<t.length){if((h=t[d])&&(131072&h.__u)==0&&a==h.key&&s===h.type)return d;d++}}return-1}function b8(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||gte.test(t)?n:n+"px"}function Ix(e,t,n,r,a){var s;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||b8(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||b8(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Date.now(),e.addEventListener(t,s?S8:_8,s)):e.removeEventListener(t,s?S8:_8,s);else{if(a)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,n))}}function _8(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Fr.event?Fr.event(e):e)}function S8(e){return this.l[e.type+!0](Fr.event?Fr.event(e):e)}function w8(e,t,n,r,a,s,u,d,h,m){var y,v,S,x,E,R,T,A,M,D,$,U,P,Z,X,K=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(h=!!(32&n.__u),s=[d=t.__e=n.__e]),(y=Fr.__b)&&y(t);e:if(typeof K=="function")try{if(A=t.props,M=(y=K.contextType)&&r[y.__c],D=y?M?M.props.value:y.__:r,n.__c?T=(v=t.__c=n.__c).__=v.__E:("prototype"in K&&K.prototype.render?t.__c=v=new K(A,D):(t.__c=v=new Mx(A,D),v.constructor=K,v.render=_te),M&&M.sub(v),v.props=A,v.state||(v.state={}),v.context=D,v.__n=r,S=v.__d=!0,v.__h=[],v._sb=[]),v.__s==null&&(v.__s=v.state),K.getDerivedStateFromProps!=null&&(v.__s==v.state&&(v.__s=Kf({},v.__s)),Kf(v.__s,K.getDerivedStateFromProps(A,v.__s))),x=v.props,E=v.state,v.__v=t,S)K.getDerivedStateFromProps==null&&v.componentWillMount!=null&&v.componentWillMount(),v.componentDidMount!=null&&v.__h.push(v.componentDidMount);else{if(K.getDerivedStateFromProps==null&&A!==x&&v.componentWillReceiveProps!=null&&v.componentWillReceiveProps(A,D),!v.__e&&(v.shouldComponentUpdate!=null&&v.shouldComponentUpdate(A,v.__s,D)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(v.props=A,v.state=v.__s,v.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(G){G&&(G.__=t)}),$=0;$<v._sb.length;$++)v.__h.push(v._sb[$]);v._sb=[],v.__h.length&&u.push(v);break e}v.componentWillUpdate!=null&&v.componentWillUpdate(A,v.__s,D),v.componentDidUpdate!=null&&v.__h.push(function(){v.componentDidUpdate(x,E,R)})}if(v.context=D,v.props=A,v.__P=e,v.__e=!1,U=Fr.__r,P=0,"prototype"in K&&K.prototype.render){for(v.state=v.__s,v.__d=!1,U&&U(t),y=v.render(v.props,v.state,v.context),Z=0;Z<v._sb.length;Z++)v.__h.push(v._sb[Z]);v._sb=[]}else do v.__d=!1,U&&U(t),y=v.render(v.props,v.state,v.context),v.state=v.__s;while(v.__d&&++P<25);v.state=v.__s,v.getChildContext!=null&&(r=Kf(Kf({},r),v.getChildContext())),S||v.getSnapshotBeforeUpdate==null||(R=v.getSnapshotBeforeUpdate(x,E)),v8(e,UM(X=y!=null&&y.type===HM&&y.key==null?y.props.children:y)?X:[X],t,n,r,a,s,u,d,h,m),v.base=t.__e,t.__u&=-161,v.__h.length&&u.push(v),T&&(v.__E=v.__=null)}catch(G){t.__v=null,h||s!=null?(t.__e=d,t.__u|=h?160:32,s[s.indexOf(d)]=null):(t.__e=n.__e,t.__k=n.__k),Fr.__e(G,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=bte(n.__e,t,n,r,a,s,u,h,m);(y=Fr.diffed)&&y(t)}function yte(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)qM(n[r],n[++r],n[++r]);Fr.__c&&Fr.__c(t,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(s){s.call(a)})}catch(s){Fr.__e(s,a.__v)}})}function bte(e,t,n,r,a,s,u,d,h){var m,y,v,S,x,E,R,T=n.props,A=t.props,M=t.type;if(M==="svg"&&(a=!0),s!=null){for(m=0;m<s.length;m++)if((x=s[m])&&"setAttribute"in x==!!M&&(M?x.localName===M:x.nodeType===3)){e=x,s[m]=null;break}}if(e==null){if(M===null)return document.createTextNode(A);e=a?document.createElementNS("http://www.w3.org/2000/svg",M):document.createElement(M,A.is&&A),s=null,d=!1}if(M===null)T===A||d&&e.data===A||(e.data=A);else{if(s=s&&i8.call(e.childNodes),T=n.props||BM,!d&&s!=null)for(T={},m=0;m<e.attributes.length;m++)T[(x=e.attributes[m]).name]=x.value;for(m in T)x=T[m],m=="children"||(m=="dangerouslySetInnerHTML"?v=x:m==="key"||m in A||Ix(e,m,null,x,a));for(m in A)x=A[m],m=="children"?S=x:m=="dangerouslySetInnerHTML"?y=x:m=="value"?E=x:m=="checked"?R=x:m==="key"||d&&typeof x!="function"||T[m]===x||Ix(e,m,x,T[m],a);if(y)d||v&&(y.__html===v.__html||y.__html===e.innerHTML)||(e.innerHTML=y.__html),t.__k=[];else if(v&&(e.innerHTML=""),v8(e,UM(S)?S:[S],t,n,r,a&&M!=="foreignObject",s,u,s?s[0]:n.__k&&vm(n,0),d,h),s!=null)for(m=s.length;m--;)s[m]!=null&&g8(s[m]);d||(m="value",E!==void 0&&(E!==e[m]||M==="progress"&&!E||M==="option"&&E!==T[m])&&Ix(e,m,E,T[m],!1),m="checked",R!==void 0&&R!==e[m]&&Ix(e,m,R,T[m],!1))}return e}function qM(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(r){Fr.__e(r,n)}}function FM(e,t,n){var r,a;if(Fr.unmount&&Fr.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||qM(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){Fr.__e(s,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(a=0;a<r.length;a++)r[a]&&FM(r[a],t,n||typeof e.type!="function");n||e.__e==null||g8(e.__e),e.__=e.__e=e.__d=void 0}function _te(e,t,n){return this.constructor(e,n)}i8=p8.slice,Fr={__e:function(e,t,n,r){for(var a,s,u;t=t.__;)if((a=t.__c)&&!a.__)try{if((s=a.constructor)&&s.getDerivedStateFromError!=null&&(a.setState(s.getDerivedStateFromError(e)),u=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,r||{}),u=a.__d),u)return a.__E=a}catch(d){e=d}throw e}},a8=0,Mx.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Kf({},this.state),typeof e=="function"&&(e=e(Kf({},n),this.props)),e&&Kf(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),PM(this))},Mx.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),PM(this))},Mx.prototype.render=HM,Ih=[],s8=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,$M=function(e,t){return e.__v.__b-t.__v.__b},Dx.__r=0,l8=0,function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}(u8||(u8={})),function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(c8||(c8={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(f8||(f8={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(d8||(d8={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(h8||(h8={})),function(e,t){var n={__c:t="__cC"+l8++,__:e,Consumer:function(r,a){return r.children(a)},Provider:function(r){var a,s;return this.getChildContext||(a=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(u){this.props.value!==u.value&&a.some(function(d){d.__e=!0,PM(d)})},this.sub=function(u){a.push(u);var d=u.componentWillUnmount;u.componentWillUnmount=function(){a.splice(a.indexOf(u),1),d&&d.call(u)}}),r.children}};n.Provider.__=n.Consumer.contextType=n}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{}});var ym=function(e,t){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};class x8{constructor(){et(this,"events",{}),this.events={}}on(t,n){return this.events[t]||(this.events[t]=[]),this.events[t].push(n),()=>{this.events[t]=this.events[t].filter(r=>r!==n)}}emit(t,n){for(var r of this.events[t]||[])r(n);for(var a of this.events["*"]||[])a(t,n)}}class Lh{constructor(t){et(this,"_debugEventEmitter",new x8),et(this,"checkStep",(n,r)=>this.checkStepEvent(n,r)&&this.checkStepUrl(n,r)&&this.checkStepElement(n,r)),et(this,"checkStepEvent",(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event)),this.instance=t,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var t;if(!ut((t=this.instance)===null||t===void 0?void 0:t._addCaptureHook)){var n;(n=this.instance)===null||n===void 0||n._addCaptureHook((r,a)=>{this.on(r,a)})}}register(t){var n,r;if(!ut((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)&&(t.forEach(u=>{var d,h;(d=this.actionRegistry)===null||d===void 0||d.add(u),(h=u.steps)===null||h===void 0||h.forEach(m=>{var y;(y=this.actionEvents)===null||y===void 0||y.add((m==null?void 0:m.event)||"")})}),(r=this.instance)!==null&&r!==void 0&&r.autocapture)){var a,s=new Set;t.forEach(u=>{var d;(d=u.steps)===null||d===void 0||d.forEach(h=>{h!=null&&h.selector&&s.add(h==null?void 0:h.selector)})}),(a=this.instance)===null||a===void 0||a.autocapture.setElementSelectors(s)}}on(t,n){var r;n!=null&&t.length!=0&&(this.actionEvents.has(t)||this.actionEvents.has(n==null?void 0:n.event))&&this.actionRegistry&&((r=this.actionRegistry)===null||r===void 0?void 0:r.size)>0&&this.actionRegistry.forEach(a=>{this.checkAction(n,a)&&this._debugEventEmitter.emit("actionCaptured",a.name)})}_addActionHook(t){this.onAction("actionCaptured",n=>t(n))}checkAction(t,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.checkStep(t,r))return!0;return!1}onAction(t,n){return this._debugEventEmitter.on(t,n)}checkStepUrl(t,n){if(n!=null&&n.url){var r,a=t==null||(r=t.properties)===null||r===void 0?void 0:r.$current_url;if(!a||typeof a!="string"||!Lh.matchString(a,n==null?void 0:n.url,(n==null?void 0:n.url_matching)||"contains"))return!1}return!0}static matchString(t,n,r){switch(r){case"regex":return!!Ae&&ym(t,n);case"exact":return n===t;case"contains":var a=Lh.escapeStringRegexp(n).replace(/_/g,".").replace(/%/g,".*");return ym(t,a);default:return!1}}static escapeStringRegexp(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(t,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.getElementsList(t).some(s=>!(n!=null&&n.href&&!Lh.matchString(s.href||"",n==null?void 0:n.href,(n==null?void 0:n.href_matching)||"exact"))&&(n==null||!n.tag_name||s.tag_name===(n==null?void 0:n.tag_name))&&!(n!=null&&n.text&&!Lh.matchString(s.text||"",n==null?void 0:n.text,(n==null?void 0:n.text_matching)||"exact")&&!Lh.matchString(s.$el_text||"",n==null?void 0:n.text,(n==null?void 0:n.text_matching)||"exact"))))return!1;if(n!=null&&n.selector){var r,a=t==null||(r=t.properties)===null||r===void 0?void 0:r.$element_selectors;if(!a||!a.includes(n==null?void 0:n.selector))return!1}return!0}getElementsList(t){return(t==null?void 0:t.properties.$elements)==null?[]:t==null?void 0:t.properties.$elements}}class bb{constructor(t){this.instance=t,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(t){var n;ut((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)||(this.setupEventBasedSurveys(t),this.setupActionBasedSurveys(t))}setupActionBasedSurveys(t){var n=t.filter(r=>{var a,s,u,d;return((a=r.conditions)===null||a===void 0?void 0:a.actions)&&((s=r.conditions)===null||s===void 0||(u=s.actions)===null||u===void 0||(d=u.values)===null||d===void 0?void 0:d.length)>0});n.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new Lh(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(r=>{this.onAction(r)})),n.forEach(r=>{var a,s,u,d,h,m,y,v,S,x;r.conditions&&(a=r.conditions)!==null&&a!==void 0&&a.actions&&(s=r.conditions)!==null&&s!==void 0&&(u=s.actions)!==null&&u!==void 0&&u.values&&((d=r.conditions)===null||d===void 0||(h=d.actions)===null||h===void 0||(m=h.values)===null||m===void 0?void 0:m.length)>0&&((y=this.actionMatcher)===null||y===void 0||y.register(r.conditions.actions.values),(v=r.conditions)===null||v===void 0||(S=v.actions)===null||S===void 0||(x=S.values)===null||x===void 0||x.forEach(E=>{if(E&&E.name){var R=this.actionToSurveys.get(E.name);R&&R.push(r.id),this.actionToSurveys.set(E.name,R||[r.id])}}))}))}setupEventBasedSurveys(t){var n;t.filter(r=>{var a,s,u,d;return((a=r.conditions)===null||a===void 0?void 0:a.events)&&((s=r.conditions)===null||s===void 0||(u=s.events)===null||u===void 0||(d=u.values)===null||d===void 0?void 0:d.length)>0}).length!==0&&((n=this.instance)===null||n===void 0||n._addCaptureHook((r,a)=>{this.onEvent(r,a)}),t.forEach(r=>{var a,s,u;(a=r.conditions)===null||a===void 0||(s=a.events)===null||s===void 0||(u=s.values)===null||u===void 0||u.forEach(d=>{if(d&&d.name){var h=this.eventToSurveys.get(d.name);h&&h.push(r.id),this.eventToSurveys.set(d.name,h||[r.id])}})}))}onEvent(t,n){var r,a,s=((r=this.instance)===null||r===void 0||(a=r.persistence)===null||a===void 0?void 0:a.props[cx])||[];if(bb.SURVEY_SHOWN_EVENT_NAME==t&&n&&s.length>0){var u,d=n==null||(u=n.properties)===null||u===void 0?void 0:u.$survey_id;if(d){var h=s.indexOf(d);h>=0&&(s.splice(h,1),this._updateActivatedSurveys(s))}}else this.eventToSurveys.has(t)&&this._updateActivatedSurveys(s.concat(this.eventToSurveys.get(t)||[]))}onAction(t){var n,r,a=((n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0?void 0:r.props[cx])||[];this.actionToSurveys.has(t)&&this._updateActivatedSurveys(a.concat(this.actionToSurveys.get(t)||[]))}_updateActivatedSurveys(t){var n,r;(n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0||r.register({[cx]:[...new Set(t)]})}getSurveys(){var t,n,r=(t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0?void 0:n.props[cx];return r||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}et(bb,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Ki=ga("[Surveys]"),C8={icontains:(e,t)=>e.some(n=>t.toLowerCase().includes(n.toLowerCase())),not_icontains:(e,t)=>e.every(n=>!t.toLowerCase().includes(n.toLowerCase())),regex:(e,t)=>e.some(n=>ym(t,n)),not_regex:(e,t)=>e.every(n=>!ym(t,n)),exact:(e,t)=>e.some(n=>t===n),is_not:(e,t)=>e.every(n=>t!==n)};function E8(e){return e??"icontains"}class Ste{constructor(t){et(this,"_isFetchingSurveys",!1),et(this,"_isInitializingSurveys",!1),et(this,"_surveyCallbacks",[]),this.instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){var n=t.surveys;if(Xn(n))return Ki.warn("Decide not loaded yet. Not loading surveys.");var r=Pr(n);this._hasSurveys=r?n.length>0:n,Ki.info("decide response received, hasSurveys: ".concat(this._hasSurveys)),this._hasSurveys&&this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var t=(()=>{for(var n=[],r=0;r<localStorage.length;r++){var a=localStorage.key(r);a!=null&&a.startsWith("seenSurvey_")&&n.push(a)}return n})();t.forEach(n=>localStorage.removeItem(n))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Ki.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)Ki.info("Disabled. Not loading surveys.");else{var t=Wt==null?void 0:Wt.__PosthogExtensions__;if(t)if(this._hasSurveys){this._isInitializingSurveys=!0;try{var n=t.generateSurveys;if(n)this._surveyManager=n(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new bb(this.instance),Ki.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0});else{var r=t.loadExternalDependency;if(r)r(this.instance,"surveys",s=>{if(s||!t.generateSurveys)return Ki.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=t.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new bb(this.instance),Ki.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var a="PostHog loadExternalDependency extension not found. Cannot load remote config.";Ki.error(a),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:a})}}}catch(s){throw Ki.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else Ki.info("No surveys to load.");else Ki.error("PostHog Extensions not found.")}}onSurveysLoaded(t){return this._surveyCallbacks.push(t),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(n=>n!==t)}}getSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return Ki.info("Disabled. Not loading surveys."),t([]);var r=this.instance.get_property(ZO);if(r&&!n)return t(r,{isLoaded:!0});if(this._isFetchingSurveys)return t([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:a=>{var s;this._isFetchingSurveys=!1;var u=a.statusCode;if(u!==200||!a.json){var d="Surveys API could not be loaded, status: ".concat(u);return Ki.error(d),t([],{isLoaded:!1,error:d})}var h,m=a.json.surveys||[],y=m.filter(v=>{var S,x,E,R,T,A,M,D,$,U,P,Z;return((S=v.conditions)===null||S===void 0?void 0:S.events)&&((x=v.conditions)===null||x===void 0||(E=x.events)===null||E===void 0?void 0:E.values)&&((R=v.conditions)===null||R===void 0||(T=R.events)===null||T===void 0||(A=T.values)===null||A===void 0?void 0:A.length)>0||((M=v.conditions)===null||M===void 0?void 0:M.actions)&&((D=v.conditions)===null||D===void 0||($=D.actions)===null||$===void 0?void 0:$.values)&&((U=v.conditions)===null||U===void 0||(P=U.actions)===null||P===void 0||(Z=P.values)===null||Z===void 0?void 0:Z.length)>0});return y.length>0&&((h=this._surveyEventReceiver)===null||h===void 0||h.register(y)),(s=this.instance.persistence)===null||s===void 0||s.register({[ZO]:m}),t(m,{isLoaded:!0})}})}catch(a){throw this._isFetchingSurveys=!1,a}}_notifySurveyCallbacks(t){for(var n of this._surveyCallbacks)try{t.isLoaded?this.getSurveys(n):n([],t)}catch(r){Ki.error("Error in survey callback",r)}}isSurveyFeatureFlagEnabled(t){return!t||this.instance.featureFlags.isFeatureEnabled(t)}getActiveMatchingSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(r=>{var a,s=r.filter(h=>!(!h.start_date||h.end_date)).filter(h=>{var m;if(!h.conditions)return!0;var y=function(x){var E,R,T;if((E=x.conditions)===null||E===void 0||!E.url)return!0;var A=Ae==null||(R=Ae.location)===null||R===void 0?void 0:R.href;if(!A)return!1;var M=[x.conditions.url];return C8[E8((T=x.conditions)===null||T===void 0?void 0:T.urlMatchType)](M,A)}(h),v=(m=h.conditions)===null||m===void 0||!m.selector||(yt==null?void 0:yt.querySelector(h.conditions.selector)),S=function(x){var E,R,T;if((E=x.conditions)===null||E===void 0||!E.deviceTypes||((R=x.conditions)===null||R===void 0?void 0:R.deviceTypes.length)===0)return!0;if(!oi)return!1;var A=Ar.deviceType(oi);return C8[E8((T=x.conditions)===null||T===void 0?void 0:T.deviceTypesMatchType)](x.conditions.deviceTypes,A)}(h);return y&&v&&S}),u=(a=this._surveyEventReceiver)===null||a===void 0?void 0:a.getSurveys(),d=s.filter(h=>{var m,y,v,S,x,E,R,T,A;if(!(h.linked_flag_key||h.targeting_flag_key||h.internal_targeting_flag_key||(m=h.feature_flag_keys)!==null&&m!==void 0&&m.length))return!0;var M=this.isSurveyFeatureFlagEnabled(h.linked_flag_key),D=this.isSurveyFeatureFlagEnabled(h.targeting_flag_key),$=((y=(v=h.conditions)===null||v===void 0||(S=v.events)===null||S===void 0||(x=S.values)===null||x===void 0?void 0:x.length)!==null&&y!==void 0?y:0)>0,U=((E=(R=h.conditions)===null||R===void 0||(T=R.actions)===null||T===void 0||(A=T.values)===null||A===void 0?void 0:A.length)!==null&&E!==void 0?E:0)>0,P=!$&&!U||(u==null?void 0:u.includes(h.id)),Z=this._canActivateRepeatedly(h)||this.isSurveyFeatureFlagEnabled(h.internal_targeting_flag_key),X=this.checkFlags(h);return M&&D&&Z&&P&&X});return t(d)},n)}checkFlags(t){var n;return(n=t.feature_flag_keys)===null||n===void 0||!n.length||t.feature_flag_keys.every(r=>{var{key:a,value:s}=r;return!a||!s||this.instance.featureFlags.isFeatureEnabled(s)})}_canActivateRepeatedly(t){var n;return Xn((n=Wt.__PosthogExtensions__)===null||n===void 0?void 0:n.canActivateRepeatedly)?(Ki.warn("init was not called"),!1):Wt.__PosthogExtensions__.canActivateRepeatedly(t)}canRenderSurvey(t){if(Xn(this._surveyManager))return Ki.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=null;return this.getSurveys(r=>{var a=r.filter(s=>s.id===t)[0];n=a?Le({},this._surveyManager.canRenderSurvey(a)):{visible:!1,disabledReason:"Survey not found"}}),n}renderSurvey(t,n){Xn(this._surveyManager)?Ki.warn("init was not called"):this.getSurveys(r=>{var a=r.filter(s=>s.id===t)[0];this._surveyManager.renderSurvey(a,yt==null?void 0:yt.querySelector(n))})}}var A8=ga("[RateLimiter]");class wte{constructor(t){var n,r;et(this,"serverLimits",{}),et(this,"lastEventRateLimited",!1),et(this,"checkForLimiting",a=>{var s=a.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(u=>{A8.info("".concat(u||"events"," is quota limited.")),this.serverLimits[u]=new Date().getTime()+6e4})}catch(u){return void A8.warn('could not rate limit - continuing. Error: "'.concat(u==null?void 0:u.message,'"'),{text:s})}}),this.instance=t,this.captureEventsPerSecond=((n=t.config.rate_limiting)===null||n===void 0?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=t.config.rate_limiting)===null||r===void 0?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var t,n,r,a=arguments.length>0&&arguments[0]!==void 0&&arguments[0],s=new Date().getTime(),u=(t=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_property(KO))!==null&&t!==void 0?t:{tokens:this.captureEventsBurstLimit,last:s};u.tokens+=(s-u.last)/1e3*this.captureEventsPerSecond,u.last=s,u.tokens>this.captureEventsBurstLimit&&(u.tokens=this.captureEventsBurstLimit);var d=u.tokens<1;return d||a||(u.tokens=Math.max(0,u.tokens-1)),!d||this.lastEventRateLimited||a||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=d,(r=this.instance.persistence)===null||r===void 0||r.set_property(KO,u),{isRateLimited:d,remainingTokens:u.tokens}}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Nh=ga("[RemoteConfig]");class xte{constructor(t){this.instance=t}get remoteConfig(){var t,n;return(t=Wt._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(n=t[this.instance.config.token])===null||n===void 0?void 0:n.config}_loadRemoteConfigJs(t){var n,r,a;(n=Wt.__PosthogExtensions__)!==null&&n!==void 0&&n.loadExternalDependency?(r=Wt.__PosthogExtensions__)===null||r===void 0||(a=r.loadExternalDependency)===null||a===void 0||a.call(r,this.instance,"remote-config",()=>t(this.remoteConfig)):(Nh.error("PostHog Extensions not found. Cannot load remote config."),t())}_loadRemoteConfigJSON(t){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:n=>{t(n.json)}})}load(){try{if(this.remoteConfig)return Nh.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void Nh.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(t=>{if(!t)return Nh.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(n=>{this.onRemoteConfig(n)});this.onRemoteConfig(t)})}catch(t){Nh.error("Error loading remote config",t)}}onRemoteConfig(t){t?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(t),t.hasFeatureFlags!==!1&&this.instance.featureFlags.ensureFlagsLoaded()):Nh.info("__preview_remote_config is disabled. Logging config instead",t):Nh.error("Failed to fetch remote config from PostHog.")}}var Cte=function(e){var t,n,r,a,s="";for(t=n=0,r=(e=(e+"").replace(/\r\n/g,`
116
116
  `).replace(/\r/g,`
117
117
  `)).length,a=0;a<r;a++){var u=e.charCodeAt(a),d=null;u<128?n++:d=u>127&&u<2048?String.fromCharCode(u>>6|192,63&u|128):String.fromCharCode(u>>12|224,u>>6&63|128,63&u|128),Ff(d)||(n>t&&(s+=e.substring(t,n)),s+=d,t=n=a+1)}return n>t&&(s+=e.substring(t,e.length)),s},Ete=!!zO||!!UO,T8="text/plain",Lx=(e,t)=>{var[n,r]=e.split("?"),a=Le({},t);r==null||r.split("&").forEach(u=>{var[d]=u.split("=");delete a[d]});var s=WJ(a);return s=s?(r?r+"&":"")+s:r,"".concat(n,"?").concat(s)},_b=(e,t)=>JSON.stringify(e,(n,r)=>typeof r=="bigint"?r.toString():r,t),jM=e=>{var{data:t,compression:n}=e;if(t){if(n===gl.GZipJS){var r=E9(A9(_b(t)),{mtime:0}),a=new Blob([r],{type:T8});return{contentType:T8,body:a,estimatedSize:a.size}}if(n===gl.Base64){var s=function(h){var m,y,v,S,x,E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",R=0,T=0,A="",M=[];if(!h)return h;h=Cte(h);do m=(x=h.charCodeAt(R++)<<16|h.charCodeAt(R++)<<8|h.charCodeAt(R++))>>18&63,y=x>>12&63,v=x>>6&63,S=63&x,M[T++]=E.charAt(m)+E.charAt(y)+E.charAt(v)+E.charAt(S);while(R<h.length);switch(A=M.join(""),h.length%3){case 1:A=A.slice(0,-2)+"==";break;case 2:A=A.slice(0,-1)+"="}return A}(_b(t)),u=(h=>"data="+encodeURIComponent(typeof h=="string"?h:_b(h)))(s);return{contentType:"application/x-www-form-urlencoded",body:u,estimatedSize:new Blob([u]).size}}var d=_b(t);return{contentType:"application/json",body:d,estimatedSize:new Blob([d]).size}}},Sb=[];UO&&Sb.push({transport:"fetch",method:e=>{var t,n,{contentType:r,body:a,estimatedSize:s}=(t=jM(e))!==null&&t!==void 0?t:{},u=new Headers;tr(e.headers,function(y,v){u.append(v,y)}),r&&u.append("Content-Type",r);var d=e.url,h=null;if(b5){var m=new b5;h={signal:m.signal,timeout:setTimeout(()=>m.abort(),e.timeout)}}UO(d,Le({method:(e==null?void 0:e.method)||"GET",headers:u,keepalive:e.method==="POST"&&(s||0)<52428.8,body:a,signal:(n=h)===null||n===void 0?void 0:n.signal},e.fetchOptions)).then(y=>y.text().then(v=>{var S,x={statusCode:y.status,text:v};if(y.status===200)try{x.json=JSON.parse(v)}catch(E){Ot.error(E)}(S=e.callback)===null||S===void 0||S.call(e,x)})).catch(y=>{var v;Ot.error(y),(v=e.callback)===null||v===void 0||v.call(e,{statusCode:0,text:y})}).finally(()=>h?clearTimeout(h.timeout):null)}}),zO&&Sb.push({transport:"XHR",method:e=>{var t,n=new zO;n.open(e.method||"GET",e.url,!0);var{contentType:r,body:a}=(t=jM(e))!==null&&t!==void 0?t:{};tr(e.headers,function(s,u){n.setRequestHeader(u,s)}),r&&n.setRequestHeader("Content-Type",r),e.timeout&&(n.timeout=e.timeout),n.withCredentials=!0,n.onreadystatechange=()=>{if(n.readyState===4){var s,u={statusCode:n.status,text:n.responseText};if(n.status===200)try{u.json=JSON.parse(n.responseText)}catch{}(s=e.callback)===null||s===void 0||s.call(e,u)}},n.send(a)}}),$o!=null&&$o.sendBeacon&&Sb.push({transport:"sendBeacon",method:e=>{var t=Lx(e.url,{beacon:"1"});try{var n,{contentType:r,body:a}=(n=jM(e))!==null&&n!==void 0?n:{},s=typeof a=="string"?new Blob([a],{type:r}):a;$o.sendBeacon(t,s)}catch{}}});var GM=3e3;class Ate{constructor(t,n){et(this,"isPaused",!0),et(this,"queue",[]),this.flushTimeoutMs=cs((n==null?void 0:n.flush_interval_ms)||GM,250,5e3,"flush interval",GM),this.sendRequest=t}enqueue(t){this.queue.push(t),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var t=this.queue.length>0?this.formatQueue():{},n=Object.values(t),r=[...n.filter(a=>a.url.indexOf("/e")===0),...n.filter(a=>a.url.indexOf("/e")!==0)];r.map(a=>{this.sendRequest(Le(Le({},a),{},{transport:"sendBeacon"}))})}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var t=this;this.isPaused||(this.flushTimeout=setTimeout(()=>{if(this.clearFlushTimeout(),this.queue.length>0){var n=this.formatQueue(),r=function(s){var u=n[s],d=new Date().getTime();u.data&&Pr(u.data)&&tr(u.data,h=>{h.offset=Math.abs(h.timestamp-d),delete h.timestamp}),t.sendRequest(u)};for(var a in n)r(a)}},this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var t={};return tr(this.queue,n=>{var r,a=n,s=(a?a.batchKey:null)||a.url;ut(t[s])&&(t[s]=Le(Le({},a),{},{data:[]})),(r=t[s].data)===null||r===void 0||r.push(a.data)}),this.queue=[],t}}var Tte=["retriesPerformedSoFar"];class kte{constructor(t){et(this,"isPolling",!1),et(this,"pollIntervalMs",3e3),et(this,"queue",[]),this.instance=t,this.queue=[],this.areWeOnline=!0,!ut(Ae)&&"onLine"in Ae.navigator&&(this.areWeOnline=Ae.navigator.onLine,Kr(Ae,"online",()=>{this.areWeOnline=!0,this.flush()}),Kr(Ae,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(t){var{retriesPerformedSoFar:n}=t,r=E5(t,Tte);Ua(n)&&n>0&&(r.url=Lx(r.url,{retry_count:n})),this.instance._send_request(Le(Le({},r),{},{callback:a=>{var s;a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(n??0)<10?this.enqueue(Le({retriesPerformedSoFar:n},r)):(s=r.callback)===null||s===void 0||s.call(r,a)}}))}enqueue(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var r=function(u){var d=3e3*Math.pow(2,u),h=d/2,m=Math.min(18e5,d),y=(Math.random()-.5)*(m-h);return Math.ceil(m+y)}(n),a=Date.now()+r;this.queue.push({retryAt:a,requestOptions:t});var s="Enqueued failed request for retry in ".concat(r);navigator.onLine||(s+=" (Browser is offline)"),Ot.warn(s),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout(()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()},this.pollIntervalMs)}flush(){var t=Date.now(),n=[],r=this.queue.filter(s=>s.retryAt<t||(n.push(s),!1));if(this.queue=n,r.length>0)for(var{requestOptions:a}of r)this.retriableRequest(a)}unload(){for(var{requestOptions:t}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(Le(Le({},t),{},{transport:"sendBeacon"}))}catch(n){Ot.error(n)}this.queue=[]}}class Rte{constructor(t){et(this,"_updateScrollData",()=>{var n,r,a,s;this.context||(this.context={});var u=this.scrollElement(),d=this.scrollY(),h=u?Math.max(0,u.scrollHeight-u.clientHeight):0,m=d+((u==null?void 0:u.clientHeight)||0),y=(u==null?void 0:u.scrollHeight)||0;this.context.lastScrollY=Math.ceil(d),this.context.maxScrollY=Math.max(d,(n=this.context.maxScrollY)!==null&&n!==void 0?n:0),this.context.maxScrollHeight=Math.max(h,(r=this.context.maxScrollHeight)!==null&&r!==void 0?r:0),this.context.lastContentY=m,this.context.maxContentY=Math.max(m,(a=this.context.maxContentY)!==null&&a!==void 0?a:0),this.context.maxContentHeight=Math.max(y,(s=this.context.maxContentHeight)!==null&&s!==void 0?s:0)}),this.instance=t}getContext(){return this.context}resetContext(){var t=this.context;return setTimeout(this._updateScrollData,0),t}startMeasuringScrollPosition(){Kr(Ae,"scroll",this._updateScrollData,{capture:!0}),Kr(Ae,"scrollend",this._updateScrollData,{capture:!0}),Kr(Ae,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return Ae==null?void 0:Ae.document.documentElement;var t=Pr(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var n of t){var r=Ae==null?void 0:Ae.document.querySelector(n);if(r)return r}}scrollY(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollTop||0}return Ae&&(Ae.scrollY||Ae.pageYOffset||Ae.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollLeft||0}return Ae&&(Ae.scrollX||Ae.pageXOffset||Ae.document.documentElement.scrollLeft)||0}}var Ote=e=>Ar.personInfo({maskPersonalDataProperties:e==null?void 0:e.config.mask_personal_data_properties,customPersonalDataProperties:e==null?void 0:e.config.custom_personal_data_properties});class Mte{constructor(t,n,r,a){et(this,"_onSessionIdCallback",s=>{var u=this._getStored();if(!u||u.sessionId!==s){var d={sessionId:s,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[QO]:d})}}),this.instance=t,this._sessionIdManager=n,this._persistence=r,this._sessionSourceParamGenerator=a||Ote,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[QO]}getSetOnceProps(){var t,n=(t=this._getStored())===null||t===void 0?void 0:t.props;return n?"r"in n?Ar.personPropsFromInfo(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var t={};return tr(rb(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),t["$session_entry_".concat(PO(r))]=n}),t}}var k8=ga("[SessionId]");class Dte{constructor(t,n,r){var a;if(et(this,"_sessionIdChangedHandlers",[]),!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=t.config,this.persistence=t.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=n||Yf,this._windowIdGenerator=r||Yf;var s=this.config.persistence_name||this.config.token,u=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*cs(u,60,36e3,"session_idle_timeout_seconds",1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var d=Qi.parse(this._window_id_storage_key),h=Qi.parse(this._primary_window_exists_storage_key);d&&!h?this._windowId=d:Qi.remove(this._window_id_storage_key),Qi.set(this._primary_window_exists_storage_key,!0)}if((a=this.config.bootstrap)!==null&&a!==void 0&&a.sessionID)try{var m=(y=>{var v=y.replace(/-/g,"");if(v.length!==32)throw new Error("Not a valid UUID");if(v[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(v.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),m)}catch(y){k8.error("Invalid sessionID in bootstrap",y)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return ut(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(t),this._sessionId&&t(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(n=>n!==t)}}_canUseSessionStorage(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&Qi.is_supported()}_setWindowId(t){t!==this._windowId&&(this._windowId=t,this._canUseSessionStorage()&&Qi.set(this._window_id_storage_key,t))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Qi.parse(this._window_id_storage_key):null}_setSessionId(t,n,r){t===this._sessionId&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this._sessionId=t,this.persistence.register({[lx]:[n,t,r]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var t=this.persistence.props[lx];return Pr(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){Kr(Ae,"beforeunload",()=>{this._canUseSessionStorage()&&Qi.remove(this._primary_window_exists_storage_key)},{capture:!1})}checkAndGetSessionAndWindowId(){var t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var r=n||new Date().getTime(),[a,s,u]=this._getSessionId(),d=this._getWindowId(),h=Ua(u)&&u>0&&Math.abs(r-u)>864e5,m=!1,y=!s,v=!t&&Math.abs(r-a)>this.sessionTimeoutMs;y||v||h?(s=this._sessionIdGenerator(),d=this._windowIdGenerator(),k8.info("new session ID generated",{sessionId:s,windowId:d,changeReason:{noSessionId:y,activityTimeout:v,sessionPastMaximumLength:h}}),u=r,m=!0):d||(d=this._windowIdGenerator(),m=!0);var S=a===0||!t||h?r:a,x=u===0?new Date().getTime():u;return this._setWindowId(d),this._setSessionId(s,S,x),t||this.resetIdleTimer(),m&&this._sessionIdChangedHandlers.forEach(E=>E(s,d,m?{noSessionId:y,activityTimeout:v,sessionPastMaximumLength:h}:void 0)),{sessionId:s,windowId:d,sessionStartTimestamp:x,changeReason:m?{noSessionId:y,activityTimeout:v,sessionPastMaximumLength:h}:void 0,lastActivityTimestamp:a}}resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var Ite=["$set_once","$set"],Xf=ga("[SiteApps]");class Lte{constructor(t){this.instance=t,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(t,n){if(n){var r=this.globalsForEvent(n);this.bufferedInvocations.push(r),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var t,n;return(t=Wt._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(n=t[this.instance.config.token])===null||n===void 0?void 0:n.siteApps}init(){if(this.isEnabled){var t=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{t(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(t){var n,r,a,s,u,d,h;if(!t)throw new Error("Event payload is required");var m={},y=this.instance.get_property("$groups")||[],v=this.instance.get_property("$stored_group_properties")||{};for(var[S,x]of Object.entries(v))m[S]={id:y[S],type:S,properties:x};var{$set_once:E,$set:R}=t;return{event:Le(Le({},E5(t,Ite)),{},{properties:Le(Le(Le({},t.properties),R?{$set:Le(Le({},(n=(r=t.properties)===null||r===void 0?void 0:r.$set)!==null&&n!==void 0?n:{}),R)}:{}),E?{$set_once:Le(Le({},(a=(s=t.properties)===null||s===void 0?void 0:s.$set_once)!==null&&a!==void 0?a:{}),E)}:{}),elements_chain:(u=(d=t.properties)===null||d===void 0?void 0:d.$elements_chain)!==null&&u!==void 0?u:"",distinct_id:(h=t.properties)===null||h===void 0?void 0:h.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:m}}setupSiteApp(t){var n=this.apps[t.id],r=()=>{var d;!n.errored&&this.bufferedInvocations.length&&(Xf.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(t.id)),this.bufferedInvocations.forEach(h=>{var m;return(m=n.processEvent)===null||m===void 0?void 0:m.call(n,h)}),n.processedBuffer=!0),Object.values(this.apps).every(h=>h.processedBuffer||h.errored)&&((d=this.stopBuffering)===null||d===void 0||d.call(this))},a=!1,s=d=>{n.errored=!d,n.loaded=!0,Xf.info("Site app with id ".concat(t.id," ").concat(d?"loaded":"errored")),a&&r()};try{var{processEvent:u}=t.init({posthog:this.instance,callback:d=>{s(d)}});u&&(n.processEvent=u),a=!0}catch(d){Xf.error("Error while initializing PostHog app with config id ".concat(t.id),d),s(!1)}if(a&&n.loaded)try{r()}catch(d){Xf.error("Error while processing buffered events PostHog app with config id ".concat(t.id),d),n.errored=!0}}setupSiteApps(){var t=this.siteAppLoaders||[];for(var n of t)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of t)this.setupSiteApp(r)}onCapturedEvent(t){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(t);for(var r of Object.values(this.apps))try{var a;(a=r.processEvent)===null||a===void 0||a.call(r,n)}catch(s){Xf.error("Error while processing event ".concat(t.event," for site app ").concat(r.id),s)}}}onRemoteConfig(t){var n,r,a,s=this;if((n=this.siteAppLoaders)!==null&&n!==void 0&&n.length)return this.isEnabled?(this.setupSiteApps(),void this.instance.on("eventCaptured",m=>this.onCapturedEvent(m))):void Xf.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.stopBuffering)===null||r===void 0||r.call(this),(a=t.siteApps)!==null&&a!==void 0&&a.length)if(this.isEnabled){var u=function(m,y){var v,S;Wt["__$$ph_site_app_".concat(m)]=s.instance,(v=Wt.__PosthogExtensions__)===null||v===void 0||(S=v.loadSiteApp)===null||S===void 0||S.call(v,s.instance,y,x=>{if(x)return Xf.error("Error while initializing PostHog app with config id ".concat(m),x)})};for(var{id:d,url:h}of t.siteApps)u(d,h)}else Xf.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var $h,Nte=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","bytespider"],R8=function(e,t){if(!e)return!1;var n=e.toLowerCase();return Nte.concat(t||[]).some(r=>{var a=r.toLowerCase();return n.indexOf(a)!==-1})},O8=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&R8(n,t))return!0;try{var r=e==null?void 0:e.userAgentData;if(r!=null&&r.brands&&r.brands.some(a=>R8(a==null?void 0:a.brand,t)))return!0}catch{}return!!e.webdriver};function M8(e,t,n){return _b({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}(function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"})($h||($h={}));var D8="i.posthog.com";class $te{constructor(t){et(this,"_regionCache",{}),this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get uiHost(){var t,n=(t=this.instance.config.ui_host)===null||t===void 0?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace(".".concat(D8),".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=$h.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=$h.EU:this._regionCache[this.apiHost]=$h.CUSTOM),this._regionCache[this.apiHost]}endpointFor(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(n&&(n=n[0]==="/"?n:"/".concat(n)),t==="ui")return this.uiHost+n;if(this.region===$h.CUSTOM)return this.apiHost+n;var r=D8+n;switch(t){case"assets":return"https://".concat(this.region,"-assets.").concat(r);case"api":return"https://".concat(this.region,".").concat(r)}}}var Bte={icontains:(e,t)=>!!Ae&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!Ae&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!Ae&&ym(t.href,e),not_regex:(e,t)=>!!Ae&&!ym(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class va{constructor(t){var n=this;et(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var r=arguments.length>0&&arguments[0]!==void 0&&arguments[0];n.getWebExperiments(a=>{va.logInfo("retrieved web experiments from the server"),n._flagToExperiments=new Map,a.forEach(s=>{if(s.feature_flag_key){var u;n._flagToExperiments&&(va.logInfo("setting flag key ",s.feature_flag_key," to web experiment ",s),(u=n._flagToExperiments)===null||u===void 0||u.set(s.feature_flag_key,s));var d=n.instance.getFeatureFlag(s.feature_flag_key);si(d)&&s.variants[d]&&n.applyTransforms(s.name,d,s.variants[d].transforms)}else if(s.variants)for(var h in s.variants){var m=s.variants[h];va.matchesTestVariant(m)&&n.applyTransforms(s.name,h,m.transforms)}})},r)}),this.instance=t,this.instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(t){if(this._is_bot())va.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(Xn(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();va.logInfo("applying feature flags",t),t.forEach(n=>{var r;if(this._flagToExperiments&&(r=this._flagToExperiments)!==null&&r!==void 0&&r.has(n)){var a,s=this.instance.getFeatureFlag(n),u=(a=this._flagToExperiments)===null||a===void 0?void 0:a.get(n);s&&u!=null&&u.variants[s]&&this.applyTransforms(u.name,s,u.variants[s].transforms)}})}}previewWebExperiment(){var t=va.getWindowLocation();if(t!=null&&t.search){var n=mx(t==null?void 0:t.search,"__experiment_id"),r=mx(t==null?void 0:t.search,"__experiment_variant");n&&r&&(va.logInfo("previewing web experiments ".concat(n," && ").concat(r)),this.getWebExperiments(a=>{this.showPreviewWebExperiment(parseInt(n),r,a)},!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,r){if(this.instance.config.disable_web_experiments&&!r)return t([]);var a=this.instance.get_property("$web_experiments");if(a&&!n)return t(a);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return t([]);var u=s.json.experiments||[];return t(u)}})}showPreviewWebExperiment(t,n,r){var a=r.filter(s=>s.id===t);a&&a.length>0&&(va.logInfo("Previewing web experiment [".concat(a[0].name,"] with variant [").concat(n,"]")),this.applyTransforms(a[0].name,n,a[0].variants[n].transforms))}static matchesTestVariant(t){return!Xn(t.conditions)&&va.matchUrlConditions(t)&&va.matchUTMConditions(t)}static matchUrlConditions(t){var n;if(Xn(t.conditions)||Xn((n=t.conditions)===null||n===void 0?void 0:n.url))return!0;var r,a,s,u=va.getWindowLocation();return!!u&&((r=t.conditions)===null||r===void 0||!r.url||Bte[(a=(s=t.conditions)===null||s===void 0?void 0:s.urlMatchType)!==null&&a!==void 0?a:"icontains"](t.conditions.url,u))}static getWindowLocation(){return Ae==null?void 0:Ae.location}static matchUTMConditions(t){var n;if(Xn(t.conditions)||Xn((n=t.conditions)===null||n===void 0?void 0:n.utm))return!0;var r=Ar.campaignParams();if(r.utm_source){var a,s,u,d,h,m,y,v,S,x,E,R,T,A,M,D,$=(a=t.conditions)===null||a===void 0||(s=a.utm)===null||s===void 0||!s.utm_campaign||((u=t.conditions)===null||u===void 0||(d=u.utm)===null||d===void 0?void 0:d.utm_campaign)==r.utm_campaign,U=(h=t.conditions)===null||h===void 0||(m=h.utm)===null||m===void 0||!m.utm_source||((y=t.conditions)===null||y===void 0||(v=y.utm)===null||v===void 0?void 0:v.utm_source)==r.utm_source,P=(S=t.conditions)===null||S===void 0||(x=S.utm)===null||x===void 0||!x.utm_medium||((E=t.conditions)===null||E===void 0||(R=E.utm)===null||R===void 0?void 0:R.utm_medium)==r.utm_medium,Z=(T=t.conditions)===null||T===void 0||(A=T.utm)===null||A===void 0||!A.utm_term||((M=t.conditions)===null||M===void 0||(D=M.utm)===null||D===void 0?void 0:D.utm_term)==r.utm_term;return $&&P&&Z&&U}return!1}static logInfo(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];Ot.info("[WebExperiments] ".concat(t),r)}applyTransforms(t,n,r){this._is_bot()?va.logInfo("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach(a=>{if(a.selector){var s;va.logInfo("applying transform of variant ".concat(n," for experiment ").concat(t," "),a);var u=(s=document)===null||s===void 0?void 0:s.querySelectorAll(a.selector);u==null||u.forEach(d=>{var h=d;a.html&&(h.innerHTML=a.html),a.css&&h.setAttribute("style",a.css)})}}):va.logInfo("Control variants leave the page unmodified.")}_is_bot(){return $o&&this.instance?O8($o,this.instance.config.custom_blocked_useragents):void 0}}var wb={},VM=()=>{},bm="posthog",I8=!Ete&&(oi==null?void 0:oi.indexOf("MSIE"))===-1&&(oi==null?void 0:oi.indexOf("Mozilla"))===-1,L8=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:qJ(yt==null?void 0:yt.location),persistence:"localStorage+cookie",persistence_name:"",loaded:VM,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:uo&&si(uo==null?void 0:uo.search)&&uo.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(Ae==null||(e=Ae.location)===null||e===void 0?void 0:e.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var n="Bad HTTP status: "+t.statusCode+" "+t.text;Ot.error(n)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:GM},_onCapture:VM}},N8=e=>{var t={};ut(e.process_person)||(t.person_profiles=e.process_person),ut(e.xhr_headers)||(t.request_headers=e.xhr_headers),ut(e.cookie_name)||(t.persistence_name=e.cookie_name),ut(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),ut(e.store_google)||(t.save_campaign_params=e.store_google),ut(e.verbose)||(t.debug=e.verbose);var n=li({},t,e);return Pr(e.property_blacklist)&&(ut(e.property_denylist)?n.property_denylist=e.property_blacklist:Pr(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ot.error("Invalid value for property_denylist config: "+e.property_denylist)),n};class Ute{constructor(){et(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(t){Ot.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Nx{get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){et(this,"webPerformance",new Ute),et(this,"_personProcessingSetOncePropertiesSent",!1),et(this,"version",fc.LIB_VERSION),et(this,"_internalEventEmitter",new x8),this.config=L8(),this.SentryIntegration=Vee,this.sentryIntegration=t=>function(n,r){var a=M9(n,r);return{name:O9,processEvent:s=>a(s)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new hte(this),this.toolbar=new Zee(this),this.scrollManager=new Rte(this),this.pageViewManager=new ete(this),this.surveys=new Ste(this),this.experiments=new va(this),this.exceptions=new tte(this),this.rateLimiter=new wte(this),this.requestRouter=new $te(this),this.consent=new fee(this),this.people={set:(t,n,r)=>{var a=si(t)?{[t]:n}:t;this.setPersonProperties(a),r==null||r({})},set_once:(t,n,r)=>{var a=si(t)?{[t]:n}:t;this.setPersonProperties(void 0,a),r==null||r({})}},this.on("eventCaptured",t=>Ot.info('send "'.concat(t==null?void 0:t.event,'"'),t))}init(t,n,r){if(r&&r!==bm){var a,s=(a=wb[r])!==null&&a!==void 0?a:new Nx;return s._init(t,n,r),wb[r]=s,wb[bm][r]=s,s}return this._init(t,n,r)}_init(t){var n,r,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(ut(t)||qO(t))return Ot.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return Ot.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],a.person_profiles&&(this._initialPersonProfilesConfig=a.person_profiles),this.set_config(li({},L8(),N8(a),{name:s,token:t})),this.config.on_xhr_error&&Ot.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=a.disable_compression?void 0:gl.GZipJS,this.persistence=new NM(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new NM(Le(Le({},this.config),{},{persistence:"sessionStorage"}));var u=Le({},this.persistence.props),d=Le({},this.sessionPersistence.props);if(this._requestQueue=new Ate(A=>this._send_retriable_request(A),this.config.request_queue_config),this._retryQueue=new kte(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new Dte(this),this.sessionPropsManager=new Mte(this,this.sessionManager,this.persistence)),new Kee(this).startIfEnabledOrStop(),this.siteApps=new Lte(this),(n=this.siteApps)===null||n===void 0||n.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new jee(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new nee(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Jee(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Xee(this),this.exceptionObserver=new pee(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new s9(this,hee),this.deadClicksAutocapture.startIfEnabled(),fc.DEBUG=fc.DEBUG||this.config.debug,fc.DEBUG&&Ot.info("Starting in debug mode",{this:this,config:a,thisC:Le({},this.config),p:u,s:d}),this._sync_opt_out_with_persistence(),((r=a.bootstrap)===null||r===void 0?void 0:r.distinctID)!==void 0){var h,m,y=this.config.get_device_id(Yf()),v=(h=a.bootstrap)!==null&&h!==void 0&&h.isIdentifiedID?y:a.bootstrap.distinctID;this.persistence.set_property(dc,(m=a.bootstrap)!==null&&m!==void 0&&m.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:a.bootstrap.distinctID,$device_id:v})}if(this._hasBootstrappedFeatureFlags()){var S,x,E=Object.keys(((S=a.bootstrap)===null||S===void 0?void 0:S.featureFlags)||{}).filter(A=>{var M,D;return!((M=a.bootstrap)===null||M===void 0||(D=M.featureFlags)===null||D===void 0||!D[A])}).reduce((A,M)=>{var D,$;return A[M]=((D=a.bootstrap)===null||D===void 0||($=D.featureFlags)===null||$===void 0?void 0:$[M])||!1,A},{}),R=Object.keys(((x=a.bootstrap)===null||x===void 0?void 0:x.featureFlagPayloads)||{}).filter(A=>E[A]).reduce((A,M)=>{var D,$,U,P;return(D=a.bootstrap)!==null&&D!==void 0&&($=D.featureFlagPayloads)!==null&&$!==void 0&&$[M]&&(A[M]=(U=a.bootstrap)===null||U===void 0||(P=U.featureFlagPayloads)===null||P===void 0?void 0:P[M]),A},{});this.featureFlags.receivedFeatureFlags({featureFlags:E,featureFlagPayloads:R})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:q5,$device_id:null},"");else if(!this.get_distinct_id()){var T=this.config.get_device_id(Yf());this.register_once({distinct_id:T,$device_id:T},""),this.persistence.set_property(dc,"anonymous")}return Kr(Ae,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),a.segment?Gee(this,()=>this._loaded()):this._loaded(),ml(this.config._onCapture)&&this.config._onCapture!==VM&&(Ot.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",A=>this.config._onCapture(A.event,A))),this}_onRemoteConfig(t){var n,r,a,s,u,d,h,m;if(!yt||!yt.body)return Ot.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(t)},500);this.compression=void 0,t.supportedCompression&&!this.config.disable_compression&&(this.compression=bn(t.supportedCompression,gl.GZipJS)?gl.GZipJS:bn(t.supportedCompression,gl.Base64)?gl.Base64:void 0),(n=t.analytics)!==null&&n!==void 0&&n.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),(r=this.siteApps)===null||r===void 0||r.onRemoteConfig(t),(a=this.sessionRecording)===null||a===void 0||a.onRemoteConfig(t),(s=this.autocapture)===null||s===void 0||s.onRemoteConfig(t),(u=this.heatmaps)===null||u===void 0||u.onRemoteConfig(t),this.surveys.onRemoteConfig(t),(d=this.webVitalsAutocapture)===null||d===void 0||d.onRemoteConfig(t),(h=this.exceptionObserver)===null||h===void 0||h.onRemoteConfig(t),(m=this.deadClicksAutocapture)===null||m===void 0||m.onRemoteConfig(t)}_loaded(){try{this.config.loaded(this)}catch(t){Ot.critical("`loaded` function failed",t)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new xte(this).load(),this.featureFlags.decide()}_start_queue_if_opted_in(){var t;this.has_opted_out_capturing()||this.config.request_batching&&((t=this._requestQueue)===null||t===void 0||t.enable())}_dom_loaded(){this.has_opted_out_capturing()||Gf(this.__request_queue,t=>this._send_retriable_request(t)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var t,n;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(t=this._requestQueue)===null||t===void 0||t.unload(),(n=this._retryQueue)===null||n===void 0||n.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(t){this.__loaded&&(I8?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)||(t.transport=t.transport||this.config.api_transport,t.url=Lx(t.url,{ip:this.config.ip?1:0}),t.headers=Le({},this.config.request_headers),t.compression=t.compression==="best-available"?this.compression:t.compression,t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var r,a,s,u=Le({},n);u.timeout=u.timeout||6e4,u.url=Lx(u.url,{_:new Date().getTime().toString(),ver:fc.LIB_VERSION,compression:u.compression});var d=(r=u.transport)!==null&&r!==void 0?r:"fetch",h=(a=(s=T5(Sb,m=>m.transport===d))===null||s===void 0?void 0:s.method)!==null&&a!==void 0?a:Sb[0].method;if(!h)throw new Error("No available transport method");h(u)})(Le(Le({},t),{},{callback:n=>{var r,a,s;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((a=(s=this.config).on_request_error)===null||a===void 0||a.call(s,n)),(r=t.callback)===null||r===void 0||r.call(t,n)}}))))}_send_retriable_request(t){this._retryQueue?this._retryQueue.retriableRequest(t):this._send_request(t)}_execute_array(t){var n,r=[],a=[],s=[];Gf(t,d=>{d&&(n=d[0],Pr(n)?s.push(d):ml(d)?d.call(this):Pr(d)&&n==="alias"?r.push(d):Pr(d)&&n.indexOf("capture")!==-1&&ml(this[n])?s.push(d):a.push(d))});var u=function(d,h){Gf(d,function(m){if(Pr(m[0])){var y=h;tr(m,function(v){y=y[v[0]].apply(y,v.slice(1))})}else this[m[0]].apply(this,m.slice(1))},h)};u(r,this),u(a,this),u(s,this)}_hasBootstrappedFeatureFlags(){var t,n;return((t=this.config.bootstrap)===null||t===void 0?void 0:t.featureFlags)&&Object.keys((n=this.config.bootstrap)===null||n===void 0?void 0:n.featureFlags).length>0||!1}push(t){this._execute_array([t])}capture(t,n,r){var a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!ut(t)&&si(t)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var s=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){n!=null&&n.$current_url&&!si(n==null?void 0:n.$current_url)&&(Ot.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var u=new Date,d=(r==null?void 0:r.timestamp)||u,h=Yf(),m={uuid:h,event:t,properties:this._calculate_event_properties(t,n||{},d,h)};s&&(m.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),r!=null&&r.$set&&(m.$set=r==null?void 0:r.$set);var y=this._calculate_set_once_properties(r==null?void 0:r.$set_once);y&&(m.$set_once=y),(m=HJ(m,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=d,ut(r==null?void 0:r.timestamp)||(m.properties.$event_time_override_provided=!0,m.properties.$event_time_override_system_time=u);var v=Le(Le({},m.properties.$set),m.$set);if(sm(v)||this.setPersonPropertiesForFlags(v),!Xn(this.config.before_send)){var S=this._runBeforeSend(m);if(!S)return;m=S}this._internalEventEmitter.emit("eventCaptured",m);var x={method:"POST",url:(a=r==null?void 0:r._url)!==null&&a!==void 0?a:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:m,compression:"best-available",batchKey:r==null?void 0:r._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this._send_retriable_request(x):this._requestQueue.enqueue(x),m}Ot.critical("This capture call is ignored due to client rate limiting.")}}else Ot.error("No event name provided to posthog.capture")}else Ot.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",n=>t(n.event,n))}_calculate_event_properties(t,n,r,a){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var s=this.persistence.remove_event_timer(t),u=Le({},n);if(u.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(u.$cookieless_mode=!0),t==="$snapshot"){var d=Le(Le({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=d.distinct_id,(!si(u.distinct_id)&&!Ua(u.distinct_id)||qO(u.distinct_id))&&Ot.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}var h,m=Ar.properties({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});if(this.sessionManager){var{sessionId:y,windowId:v}=this.sessionManager.checkAndGetSessionAndWindowId();u.$session_id=y,u.$window_id=v}this.sessionPropsManager&&li(u,this.sessionPropsManager.getSessionProps());try{var S,x;this.sessionRecording&&(u.$recording_status=this.sessionRecording.status,u.$sdk_debug_replay_internal_buffer_length=this.sessionRecording.buffer.data.length,u.$sdk_debug_replay_internal_buffer_size=this.sessionRecording.buffer.size),u.$sdk_debug_retry_queue_size=(S=this._retryQueue)===null||S===void 0||(x=S.queue)===null||x===void 0?void 0:x.length}catch(A){u.$sdk_debug_error_capturing_properties=String(A)}if(this.requestRouter.region===$h.CUSTOM&&(u.$lib_custom_api_host=this.config.api_host),h=t==="$pageview"?this.pageViewManager.doPageView(r,a):t==="$pageleave"?this.pageViewManager.doPageLeave(r):this.pageViewManager.doEvent(),u=li(u,h),t==="$pageview"&&yt&&(u.title=yt.title),!ut(s)){var E=r.getTime()-s;u.$duration=parseFloat((E/1e3).toFixed(3))}oi&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser"),(u=li({},m,this.persistence.properties(),this.sessionPersistence.properties(),u)).$is_identified=this._isIdentified(),Pr(this.config.property_denylist)?tr(this.config.property_denylist,function(A){delete u[A]}):Ot.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var R=this.config.sanitize_properties;R&&(Ot.error("sanitize_properties is deprecated. Use before_send instead"),u=R(u,t));var T=this._hasPersonProcessing();return u.$process_person_profile=T,T&&this._requirePersonProcessing("_calculate_event_properties"),u}_calculate_set_once_properties(t){var n;if(!this.persistence||!this._hasPersonProcessing()||this._personProcessingSetOncePropertiesSent)return t;var r=this.persistence.get_initial_props(),a=(n=this.sessionPropsManager)===null||n===void 0?void 0:n.getSetOnceProps(),s=li({},r,a||{},t||{}),u=this.config.sanitize_properties;return u&&(Ot.error("sanitize_properties is deprecated. Use before_send instead"),s=u(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,sm(s)?void 0:s}register(t,n){var r;(r=this.persistence)===null||r===void 0||r.register(t,n)}register_once(t,n,r){var a;(a=this.persistence)===null||a===void 0||a.register_once(t,n,r)}register_for_session(t){var n;(n=this.sessionPersistence)===null||n===void 0||n.register(t)}unregister(t){var n;(n=this.persistence)===null||n===void 0||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(t)}_register_single(t,n){this.register({[t]:n})}getFeatureFlag(t,n){return this.featureFlags.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n=this.featureFlags.getFeatureFlagPayload(t);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(t,n){return this.featureFlags.isFeatureEnabled(t,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(t,n){this.featureFlags.updateEarlyAccessFeatureEnrollment(t,n)}getEarlyAccessFeatures(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1],r=arguments.length>2?arguments[2]:void 0;return this.featureFlags.getEarlyAccessFeatures(t,n,r)}on(t,n){return this._internalEventEmitter.on(t,n)}onFeatureFlags(t){return this.featureFlags.onFeatureFlags(t)}onSurveysLoaded(t){return this.surveys.onSurveysLoaded(t)}onSessionId(t){var n,r;return(n=(r=this.sessionManager)===null||r===void 0?void 0:r.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(t,n)}getActiveMatchingSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(t,n)}renderSurvey(t,n){this.surveys.renderSurvey(t,n)}canRenderSurvey(t){return this.surveys.canRenderSurvey(t)}identify(t,n,r){if(!this.__loaded||!this.persistence)return Ot.uninitializedWarning("posthog.identify");if(Ua(t)&&(t=t.toString(),Ot.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),t){if(["distinct_id","distinctid"].includes(t.toLowerCase()))Ot.critical('The string "'.concat(t,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var a=this.get_distinct_id();if(this.register({$user_id:t}),!this.get_property("$device_id")){var s=a;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}t!==a&&t!==this.get_property(ib)&&(this.unregister(ib),this.register({distinct_id:t}));var u=(this.persistence.get_property(dc)||"anonymous")==="anonymous";t!==a&&u?(this.persistence.set_property(dc,"identified"),this.setPersonPropertiesForFlags(Le(Le({},r||{}),n||{}),!1),this.capture("$identify",{distinct_id:t,$anon_distinct_id:a},{$set:n||{},$set_once:r||{}}),this._cachedPersonProperties=M8(t,n,r),this.featureFlags.setAnonymousDistinctId(a)):(n||r)&&this.setPersonProperties(n,r),t!==a&&(this.reloadFeatureFlags(),this.unregister(fx))}}else Ot.error("Unique user id has not been set in posthog.identify")}setPersonProperties(t,n){if((t||n)&&this._requirePersonProcessing("posthog.setPersonProperties")){var r=M8(this.get_distinct_id(),t,n);this._cachedPersonProperties!==r?(this.setPersonPropertiesForFlags(Le(Le({},n||{}),t||{})),this.capture("$set",{$set:t||{},$set_once:n||{}}),this._cachedPersonProperties=r):Ot.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(t,n,r){if(t&&n){if(this._requirePersonProcessing("posthog.group")){var a=this.getGroups();a[t]!==n&&this.resetGroupPropertiesForFlags(t),this.register({$groups:Le(Le({},a),{},{[t]:n})}),r&&(this.capture("$groupidentify",{$group_type:t,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[t]:r})),a[t]===n||r||this.reloadFeatureFlags()}}else Ot.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(t,n)}resetGroupPropertiesForFlags(t){this.featureFlags.resetGroupPropertiesForFlags(t)}reset(t){var n,r,a,s;if(Ot.info("reset"),!this.__loaded)return Ot.uninitializedWarning("posthog.reset");var u=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)===null||n===void 0||n.clear(),(r=this.sessionPersistence)===null||r===void 0||r.clear(),this.surveys.reset(),(a=this.persistence)===null||a===void 0||a.set_property(dc,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId(),this._cachedPersonProperties=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:q5,$device_id:null},"");else{var d=this.config.get_device_id(Yf());this.register_once({distinct_id:d,$device_id:t?d:u},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)===null||n===void 0?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),a=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(n));if(t!=null&&t.withTimestamp&&r){var s,u=(s=t.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return a;var d=Math.max(Math.floor((new Date().getTime()-r)/1e3)-u,0);a+="?t=".concat(d)}return a}alias(t,n){return t===this.get_property(k5)?(Ot.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(ut(n)&&(n=this.get_distinct_id()),t!==n?(this._register_single(ib,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(Ot.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n,r,a,s,u=Le({},this.config);qr(t)&&(li(this.config,N8(t)),(n=this.persistence)===null||n===void 0||n.update_config(this.config,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new NM(Le(Le({},this.config),{},{persistence:"sessionStorage"})),Si.is_supported()&&Si.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(fc.DEBUG=!0,Ot.info("set_config",JSON.stringify({config:t,oldConfig:u,newConfig:Le({},this.config)},null,2))),(r=this.sessionRecording)===null||r===void 0||r.startIfEnabledOrStop(),(a=this.autocapture)===null||a===void 0||a.startIfEnabled(),(s=this.heatmaps)===null||s===void 0||s.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(t){var n=t===!0,r={sampling:n||!(t==null||!t.sampling),linked_flag:n||!(t==null||!t.linked_flag),url_trigger:n||!(t==null||!t.url_trigger),event_trigger:n||!(t==null||!t.event_trigger)};if(Object.values(r).some(Boolean)){var a,s,u,d,h;(a=this.sessionManager)===null||a===void 0||a.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)===null||s===void 0||s.overrideSampling()),r.linked_flag&&((u=this.sessionRecording)===null||u===void 0||u.overrideLinkedFlag()),r.url_trigger&&((d=this.sessionRecording)===null||d===void 0||d.overrideTrigger("url")),r.event_trigger&&((h=this.sessionRecording)===null||h===void 0||h.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)===null||t===void 0||!t.started)}captureException(t,n){var r=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(Le(Le({},Aee((a=>a instanceof Error)(t)?{error:t,event:t.message}:{event:t},{syntheticException:r})),n))}loadToolbar(t){return this.toolbar.loadToolbar(t)}get_property(t){var n;return(n=this.persistence)===null||n===void 0?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)===null||n===void 0?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:bm;return n!==bm&&(n=bm+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)===null||t===void 0?void 0:t.get_property(dc))==="identified"||((n=this.sessionPersistence)===null||n===void 0?void 0:n.get_property(dc))==="identified"}_hasPersonProcessing(){var t,n,r,a;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&sm(this.getGroups())&&((t=this.persistence)===null||t===void 0||(n=t.props)===null||n===void 0||!n[ib])&&((r=this.persistence)===null||r===void 0||(a=r.props)===null||a===void 0||!a[dx]))}_shouldCapturePageleave(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(t){return this.config.person_profiles==="never"?(Ot.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(dx,!0),!0)}_sync_opt_out_with_persistence(){var t,n,r,a,s=this.consent.isOptedOut(),u=this.config.opt_out_persistence_by_default,d=this.config.disable_persistence||s&&!!u;((t=this.persistence)===null||t===void 0?void 0:t.disabled)!==d&&((r=this.persistence)===null||r===void 0||r.set_disabled(d)),((n=this.sessionPersistence)===null||n===void 0?void 0:n.disabled)!==d&&((a=this.sessionPersistence)===null||a===void 0||a.set_disabled(d))}opt_in_capturing(t){var n;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(ut(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((n=t==null?void 0:t.captureEventName)!==null&&n!==void 0?n:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return $o?O8($o,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){yt&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:yt.title},{send_instantly:!0}))}debug(t){t===!1?(Ae==null||Ae.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(Ae==null||Ae.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_runBeforeSend(t){if(Xn(this.config.before_send))return t;var n=Pr(this.config.before_send)?this.config.before_send:[this.config.before_send],r=t;for(var a of n){if(r=a(r),Xn(r)){var s="Event '".concat(t.event,"' was rejected in beforeSend function");return BJ(t.event)?Ot.warn("".concat(s,". This can cause unexpected behavior.")):Ot.info(s),null}r.properties&&!sm(r.properties)||Ot.warn("Event '".concat(t.event,"' has no properties after beforeSend function, this is likely an error."))}return r}getPageViewId(){var t;return(t=this.pageViewManager._currentPageview)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,r){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(r)})}}(function(e,t){for(var n=0;n<t.length;n++)e.prototype[t[n]]=zJ(e.prototype[t[n]])})(Nx,["identify"]);var $8,hs=($8=wb[bm]=new Nx,function(){function e(){e.done||(e.done=!0,I8=!1,tr(wb,function(t){t._dom_loaded()}))}yt!=null&&yt.addEventListener?yt.readyState==="complete"?e():Kr(yt,"DOMContentLoaded",e,{capture:!1}):Ae&&Ot.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),$8),B8=pe.createContext({client:hs});function U8(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(var s=0,u=r;s<u.length;s++){var d=u[s];if(!a.includes(d)||!U8(e[d],t[d],n))return!1}return!0}function zte(e){var t=e.children,n=e.client,r=e.apiKey,a=e.options,s=pe.useState(!1),u=s[0],d=s[1],h=pe.useMemo(function(){return n?(r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),a&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n):r?u!==!1?(r!==u.previousAPIKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),a&&!U8(a,u.previousOptions)&&hs.set_config(a),d({previousAPIKey:r,previousOptions:a??{}}),hs):(hs.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),hs.init(r,a),d({previousAPIKey:r,previousOptions:a??{}}),hs):(console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),hs)},[n,r,JSON.stringify(a)]);return pe.createElement(B8.Provider,{value:{client:h}},t)}var z8=function(){var e=pe.useContext(B8).client;return e};function YM(e){var t=z8(),n=pe.useState(function(){return t.isFeatureEnabled(e)}),r=n[0],a=n[1];return pe.useEffect(function(){return t.onFeatureFlags(function(){a(t.isFeatureEnabled(e))})},[t,e]),r}function Hte(e){var t=z8(),n=pe.useState(function(){return t.getFeatureFlagPayload(e)}),r=n[0],a=n[1];return pe.useEffect(function(){return t.onFeatureFlags(function(){a(t.getFeatureFlagPayload(e))})},[t,e]),r}function Pte(e){y3(e,[/\r?\n|\r/g,qte])}function qte(){return{type:"break"}}function Fte(){return function(e){Pte(e)}}const nr={OPEN_STATE_CHANGE:"open_state_change",CHAT_BUTTON_CLICKED:"Chat button clicked",USER_FORM_FILLED:"User form filled",ADD_BULK_ITEM:"Add bulk item",USER_FORM_CLOSE:"user_form_close",CHECKOUT_CLICKED:"Checkout Clicked",ADD_TO_CART_CLICKED:"add to cart clicked",SUGGESTED_QUESTION_CLICKED:"Suggested Question Clicked",INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED:"Initial Leading Query Suggested Question Clicked",LEADING_QUERY_CLICKED:"Leading Query Clicked",COLLECTION_VIDEO_CLICKED:"Collection Video Clicked",COLLECTION_IMAGE_CLICKED:"Collection Image Clicked",VIEW_PRODUCT_CLICKED:"view product clicked",PRODUCT_VIDEO_CLICKED:"Product Video Clicked",PRODUCT_IMAGE_CLICKED:"Product Image Clicked",SHOW_SIMILAR_CLICKED:"show similar clicked",CHAT_MESSAGE_SENT:"chat_message_sent",CHAT_MESSAGE_TYPING_STARTED:"chat_message_typing_started",CHAT_MESSAGE_TYPING_ENDED:"chat_message_typing_ended",DISCOUNT_VIEWED:"discount_viewed",SHOPIFY_LINK_CLICKED:"shopify_link_clicked"},ps={OPEN_STATE_CHANGE:"open_state_change"},jte=e=>{window.DebalesChat||(window.DebalesChat={isOpen:!1,projectId:e,getSessionId:()=>Vi(),getChatId:()=>Vi()+"_"+e,getAnonId:()=>Ah.getAnonId(),isIdentified:()=>{if(hs._isIdentified())return!0;const t=Uf();return!!(t&&t.email)},getIdentifiedUser:()=>Uf(),getDistinctId:()=>hs.get_distinct_id(),getOldDistinctId:()=>Ah.getDistinctId(),debug:!1,identify:(t,n)=>{hs._isIdentified()||hs.identify(t,{...n,project:e}),Ah.identify(t,n),wO({email:t,name:n==null?void 0:n.name,phone:n==null?void 0:n.phone})},track:(t,n)=>{Ah.track(t,{...n,sessionId:window.DebalesChat.getSessionId()}),hs.capture(t,{...n}),mJ(t,{...n,sessionId:Vi(),projectId:e})},onOpenChange:t=>{const n=r=>{t(r.detail.isOpen)};return window.addEventListener(ps.OPEN_STATE_CHANGE,n),()=>window.removeEventListener(ps.OPEN_STATE_CHANGE,n)},removeOpenChangeListener:t=>{const n=r=>{t(r.detail.isOpen)};window.removeEventListener(ps.OPEN_STATE_CHANGE,n)},open:()=>{window.DebalesChat.isOpen||window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:!0,projectId:e}}))},close:()=>{window.DebalesChat.isOpen&&window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:!1,projectId:e}}))},toggle:()=>{window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:!window.DebalesChat.isOpen,projectId:e}}))}})};var Xi=(e=>(e.DEFAULT="DEFAULT",e.SHOPIFY="SHOPIFY",e.WOOCOMMERCE="WOOCOMMERCE",e.MAGENTO="MAGENTO",e.UNKNOWN="UNKNOWN",e))(Xi||{});class xb{static detect(){var t,n,r,a,s,u;if(typeof window<"u"&&window.Shopify!==void 0&&window.Shopify.routes!==void 0)return Xi.SHOPIFY;if(typeof window<"u"&&document.body.classList.contains("woocommerce"))return Xi.WOOCOMMERCE;if(typeof window<"u"){if(window.MAGENTO_VERSION!==void 0||window.MAGE!==void 0||window.Mage!==void 0||["page-wrapper","magento-theme","catalog-product-view","catalog-category-view"].some(v=>document.body.classList.contains(v)))return Xi.MAGENTO;const h=document.getElementsByTagName("script");for(const v of Array.from(h))if(v.src.includes("mage/")||v.src.includes("magento")||(t=v.textContent)!=null&&t.includes("Mage.")||(n=v.textContent)!=null&&n.includes("require(")||(r=v.getAttribute("data-requiremodule"))!=null&&r.startsWith("mage")||(a=v.getAttribute("data-requiremodule"))!=null&&a.startsWith("Magento"))return Xi.MAGENTO;if(document.cookie.split(";").some(v=>v.trim().startsWith("mage-")||v.trim().startsWith("form_key")))return Xi.MAGENTO;const y=document.getElementsByTagName("meta");for(const v of Array.from(y))if((s=v.getAttribute("content"))!=null&&s.includes("Magento")||(u=v.getAttribute("name"))!=null&&u.includes("magento"))return Xi.MAGENTO}return Xi.UNKNOWN}}const Gte=me.button`
@@ -2306,7 +2306,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2306
2306
  margin-top: 16px;
2307
2307
  display: flex;
2308
2308
  justify-content: flex-end;
2309
- `,Hoe=({botId:e})=>{var Ss,kr;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:a,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:S,changeDisplayModel:x,loadConversation:E,suggestedQuestions:R,setSuggestedQuestions:T,showUserInfoModel:A,setShowUserInfoModel:M,isUserInfoNeeded:D,setPendingQuestion:$}=QM(),{cart:U,addToCart:P,generateCartUrl:Z,addCartAttributes:X}=KN(),K=Hte("use-chatbot-icon-size"),G=xb.detect(),ne=t==null?void 0:t.isLeft,se=Kte(),be=t==null?void 0:t.heightOption,[ae,ve]=pe.useState(!1);pe.useEffect(()=>{const ue=()=>{ve(window.matchMedia("(max-width: 768px)").matches)};return ue(),window.addEventListener("resize",ue),()=>window.removeEventListener("resize",ue)},[]);const[Y,te]=gn.useState(!1),[fe,Ue]=gn.useState(!1),[B,$e]=pe.useState(""),[ke,j]=pe.useState(""),[,Ge]=pe.useState(0);gn.useEffect(()=>{e&&jte(e)},[e]),gn.useEffect(()=>{gJ(e)},[e]),gn.useEffect(()=>{let ue=Uf();if(!ue&&window.Thinkific){const We=window.Thinkific.current_user;We&&(ue={name:We.full_name,email:We.email},wO(ue))}Ah.init({projectName:e,debug:!0,testing:YN}),ue&&ue.email&&(window.DebalesChat.identify(ue.email,{name:ue.name,phone:ue.phone,email:ue.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:ue.email,first_name:ue.name,phone:ue.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const it=gn.useRef(null),ze=Zi(Fi.CLICKED_QUESTIONS,{botId:e}),[Nt,dt]=pe.useState(()=>{try{const ue=sessionStorage.getItem(ze);return ue?new Set(JSON.parse(ue)):new Set}catch{return new Set}});gn.useEffect(()=>{try{sessionStorage.setItem(ze,JSON.stringify(Array.from(Nt)))}catch(ue){console.error("Failed to save to sessionStorage:",ue)}},[Nt]);const Rt=pe.useCallback((ue,We)=>{ue?(window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:ue,source:We,projectId:e}})),setTimeout(()=>{Ue(!0)},50)):(Ue(!1),window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:ue,source:We,projectId:e}})))},[]);pe.useEffect(()=>{const ue=We=>{te(We.detail.isOpen),We.detail.isOpen&&setTimeout(()=>Ue(!0),50),window.DebalesChat.isOpen=We.detail.isOpen,window.DebalesChat.track(nr.OPEN_STATE_CHANGE,{isOpen:We.detail.isOpen,source:We.detail.source})};return window.addEventListener(ps.OPEN_STATE_CHANGE,ue),()=>{window.removeEventListener(ps.OPEN_STATE_CHANGE,ue)}},[]),pe.useEffect(()=>{const ue=We=>{te(We.detail.isOpen),window.DebalesChat.isOpen=We.detail.isOpen,window.DebalesChat.track(nr.OPEN_STATE_CHANGE,{isOpen:We.detail.isOpen})};return window.addEventListener(ps.OPEN_STATE_CHANGE,ue),()=>{window.removeEventListener(ps.OPEN_STATE_CHANGE,ue)}},[]);const[Dt,nt]=gn.useState(!1),[Pe,lt]=gn.useState(()=>{const ue=Zi(Fi.PENDING_BULK_ITEMS,{botId:e}),We=sessionStorage.getItem(ue);return We?JSON.parse(We):[]});gn.useEffect(()=>{const ue=Zi(Fi.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(ue,JSON.stringify(Pe))},[Pe,e]);const[gt,$t]=pe.useState(!1),[ht,Ct]=pe.useState({name:"",email:"",message:""}),V=YM("exit_model"),[Q,oe]=pe.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[De,Ne]=pe.useState({suggestions:!1,products:!1,collections:!1,leadingQueries:!1,initialMessage:!1,cartSummary:!1,bulkItems:!1}),[He,bt]=pe.useState(!1),[At,ce]=pe.useState(!0),[Oe,at]=pe.useState(!1),[ft,Et]=pe.useState(!1),On=2e3,Gn=pe.useCallback(ue=>{const We=ue.target,vt=We.scrollHeight-We.scrollTop<=We.clientHeight+0;ce(vt)},[]);gn.useEffect(()=>{var ue,We,vt,_t,Ke,Bt;if(h.length>0&&!m){const tn=h[h.length-1],ir=sessionStorage.getItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:e})),ws=tn.isBot&&tn.conversationId===u&&tn.conversationId!==ir,ya=(U==null?void 0:U.itemCount)&&(U==null?void 0:U.itemCount)>0&&tn.conversationId===u;if(ws){bt(!0),Ne(on=>({...on,initialMessage:!0,leadingQueries:!0})),sessionStorage.setItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:e}),tn.conversationId||""),oe({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const qe=1600;let vc=qe;const Ji=[{type:"leadingQueries",condition:h.length===1&&((ue=tn.leading_queries)==null?void 0:ue.length)&&((We=tn.leading_queries)==null?void 0:We.length)>0},{type:"collections",condition:((vt=tn.collections)==null?void 0:vt.length)&&((_t=tn.collections)==null?void 0:_t.length)>0},{type:"products",condition:((Ke=tn.products)==null?void 0:Ke.length)&&((Bt=tn.products)==null?void 0:Bt.length)>0},{type:"cartSummary",condition:(U==null?void 0:U.itemCount)&&(U==null?void 0:U.itemCount)>0},{type:"bulkItems",condition:(Pe==null?void 0:Pe.length)>0}].filter(on=>on.condition);if(Ji.length===0){bt(!1),Ne(on=>({...on,initialMessage:!1,leadingQueries:!1}));return}Ji.forEach(({type:on},br)=>{setTimeout(()=>{if(Ne(jr=>({...jr,[on]:!0})),oe(jr=>({...jr,[on]:!0})),At&&it.current){const jr=it.current;jr.scrollHeight-jr.scrollTop<=jr.clientHeight&&Zw(it)}br===Ji.length-1&&bt(!1)},vc),vc+=qe})}else ya&&oe(qe=>({...qe,cartSummary:!0}))}},[h,m,u,U==null?void 0:U.itemCount,Pe==null?void 0:Pe.length,At,e]),gn.useEffect(()=>{if(!a&&h.length>0){const ue=it.current;ue&&At&&ue.scrollHeight-ue.scrollTop<=ue.clientHeight+100&&setTimeout(()=>Zw(it),100)}},[h.length,a,At]),gn.useEffect(()=>{const ue=document.querySelector('meta[name="viewport"]'),We=ue==null?void 0:ue.content;if(Y){let vt=ue;const _t=window.matchMedia("(max-width: 768px)").matches;vt?vt.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(vt=document.createElement("meta"),vt.name="viewport",vt.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(vt)),_t&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ke=vt;return()=>{We&&Ke&&(Ke.content=We),_t&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="")}}return()=>{window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="")}},[Y,t==null?void 0:t.mobileDisplayMode]),gn.useEffect(()=>{if(Y&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const ue=We=>{let vt=We.target,_t=!1;const Ke=it.current;if(Ke){for(;vt&&vt!==document.body;){if(vt===Ke){_t=!0;break}if(vt.parentNode)vt=vt.parentNode;else break}if(!_t)We.preventDefault();else{const Bt=Ke.scrollTop<=0,tn=Ke.scrollTop+Ke.clientHeight>=Ke.scrollHeight-5;if(Bt&&We.touches[0].clientY>0||tn&&We.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",ue,{passive:!1}),()=>{document.removeEventListener("touchmove",ue)}}return()=>{}},[Y,t==null?void 0:t.mobileDisplayMode,it]),gn.useEffect(()=>{const ue=setTimeout(()=>{nt(!0)},1e3);return()=>clearTimeout(ue)},[]),gn.useEffect(()=>{a||setTimeout(()=>Zw(it),100)},[h.length,a]),gn.useEffect(()=>{U!=null&&U.itemCount&&U.itemCount===0&&!a&&setTimeout(()=>Zw(it),100)},[U==null?void 0:U.itemCount,a]),gn.useEffect(()=>{u&&sessionStorage.setItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const fn=gn.useRef(Date.now()),$n=gn.useRef(0),Tt=gn.useRef(window.location.pathname),Vt=gn.useRef(R),ot=gn.useRef(!1),kt=YM("acquisition_agent");gn.useEffect(()=>{Vt.current=R},[R]);const ci=gn.useCallback(async()=>{const ue=Date.now();if(ue-fn.current>=6e3&&ue-$n.current>=6e4&&!ot.current)try{ot.current=!0,console.log("fetching acquisition data");const _t=await fetch(`${iu}/api/wordpress/acquisition`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),page_information:window.location.href.split("?")[0],botid:e})});if(_t.ok){const Ke=await _t.json(),tn=[...Vt.current.filter(ir=>ir.path!==Tt.current),{question:Ke.Popup_Message,answer:"",path:Tt.current,nameSpace:e,type:"dynamic",Follow_up_Question:Ke.Follow_up_Question}];T(tn)}$n.current=ue}catch(_t){console.error("Error fetching acquisition data:",_t)}finally{ot.current=!1}},[e]);gn.useEffect(()=>{if(!kt||(t==null?void 0:t.show_bot)===!1)return;const ue=()=>{fn.current=Date.now()};document.addEventListener("mousemove",ue),document.addEventListener("mousedown",ue),document.addEventListener("keypress",ue),document.addEventListener("scroll",ue),document.addEventListener("touchstart",ue),document.addEventListener("touchmove",ue);const We=setInterval(ci,1e3),vt=()=>{const Ke=window.location.pathname.split("?")[0],Bt=Tt.current.split("?")[0];(()=>{const ir=Bt.split("/").filter(Boolean),ws=Ke.split("/").filter(Boolean);return ir.length!==ws.length?!0:ir.length===0&&ws.length===0?!1:Ke!==Bt})()&&(Tt.current=Ke,fn.current=Date.now())};return window.addEventListener("popstate",vt),()=>{document.removeEventListener("mousemove",ue),document.removeEventListener("mousedown",ue),document.removeEventListener("keypress",ue),document.removeEventListener("scroll",ue),document.removeEventListener("touchstart",ue),document.removeEventListener("touchmove",ue),window.removeEventListener("popstate",vt),clearInterval(We)}},[kt,ci,t==null?void 0:t.show_bot]);const[Wi,fi]=pe.useState(!1),[Li,Bo]=pe.useState(!1),[Uo,fo]=pe.useState(null),di=async ue=>{const We=Vi();if(Ue(!1),ue&&h.length>1)try{(await fetch(`${iu}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:We,userRating:ue,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(vt){console.error("Error submitting rating:",vt)}setTimeout(()=>{Bo(!1),Rt(!1,"close_button_clicked")},1e3)},vs=ue=>{y(!0),Pe.forEach(vt=>{P(vt.id,vt.quantity)}),window.DebalesChat.track(nr.ADD_BULK_ITEM,{products:Pe,message:ue});const We=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:ue,isBot:!0}];v(We),S(We),d(ue),lt([]),y(!1)},Jf=()=>{var ue;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((ue=window.shiprocketCheckoutEvents)!=null&&ue.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=Z((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Z((t==null?void 0:t.shopifyShopDomain)??""),!1},qh=async ue=>{ue.preventDefault(),window.DebalesChat.track(nr.CHECKOUT_CLICKED,{chatId:Vi()+e,cartValue:Number(U==null?void 0:U.total),cart:U}),X({dbls_method:"checkout_clicked"}),Jf()&&Rt(!1,"checkout_clicked")},[rr,Tr]=pe.useState([]);gn.useEffect(()=>{const ue=bJ(pJ(R));Tr(ue)},[R]);const cr=gn.useMemo(()=>rr.map(ue=>{if(Array.isArray(ue)){const We=ue.filter(_t=>!Nt.has(_t.question));if(We.length===0)return null;const vt={isHighlighted:ue[0].isHighlighted,enable:ue[0].enable,type:ue[0].type};return We.map(_t=>({..._t,...vt}))}else return Nt.has(ue.question)?null:ue}).filter(Boolean),[rr,Nt]);gn.useEffect(()=>{const ue=_t=>{const Ke=_t.detail.formId;switch(_t.detail.type){case"open":case"embedOpen":setTimeout(()=>{const tn=We(Ke);tn&&$e(tn)},800);break;case"close":B&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{Rt(!0,"klaviyo_form_closed"),j(Ke),r(B,void 0,void 0,!0,void 0,void 0)},1e4);break}},We=_t=>{const Ke=document.querySelector(`[data-testid="klaviyo-form-${_t}"]`);if(console.log(`formElement text ${_t} =>`,Ke==null?void 0:Ke.innerText,Ke==null?void 0:Ke.textContent),Ke instanceof HTMLElement){const Bt=Ke.innerText||Ke.textContent;if(Bt)return console.log("Found form text:",Bt),`=> Klaviyo form content:
2309
+ `,Hoe=({botId:e})=>{var Ss,kr;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:a,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:S,changeDisplayModel:x,loadConversation:E,suggestedQuestions:R,setSuggestedQuestions:T,showUserInfoModel:A,setShowUserInfoModel:M,isUserInfoNeeded:D,setPendingQuestion:$}=QM(),{cart:U,addToCart:P,generateCartUrl:Z,addCartAttributes:X}=KN(),K=Hte("use-chatbot-icon-size"),G=xb.detect(),ne=t==null?void 0:t.isLeft,se=Kte(),be=t==null?void 0:t.heightOption,[ae,ve]=pe.useState(!1);pe.useEffect(()=>{const ue=()=>{ve(window.matchMedia("(max-width: 768px)").matches)};return ue(),window.addEventListener("resize",ue),()=>window.removeEventListener("resize",ue)},[]);const[Y,te]=gn.useState(!1),[fe,Ue]=gn.useState(!1),[B,$e]=pe.useState(""),[ke,j]=pe.useState(""),[,Ge]=pe.useState(0);gn.useEffect(()=>{e&&jte(e)},[e]),gn.useEffect(()=>{gJ(e)},[e]),gn.useEffect(()=>{let ue=Uf();if(!ue&&window.Thinkific){const We=window.Thinkific.current_user;We&&(ue={name:We.full_name,email:We.email},wO(ue))}Ah.init({projectName:e,debug:!1,testing:YN}),ue&&ue.email&&(window.DebalesChat.identify(ue.email,{name:ue.name,phone:ue.phone,email:ue.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:ue.email,first_name:ue.name,phone:ue.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const it=gn.useRef(null),ze=Zi(Fi.CLICKED_QUESTIONS,{botId:e}),[Nt,dt]=pe.useState(()=>{try{const ue=sessionStorage.getItem(ze);return ue?new Set(JSON.parse(ue)):new Set}catch{return new Set}});gn.useEffect(()=>{try{sessionStorage.setItem(ze,JSON.stringify(Array.from(Nt)))}catch(ue){console.error("Failed to save to sessionStorage:",ue)}},[Nt]);const Rt=pe.useCallback((ue,We)=>{ue?(window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:ue,source:We,projectId:e}})),setTimeout(()=>{Ue(!0)},50)):(Ue(!1),window.dispatchEvent(new CustomEvent(ps.OPEN_STATE_CHANGE,{detail:{isOpen:ue,source:We,projectId:e}})))},[]);pe.useEffect(()=>{const ue=We=>{te(We.detail.isOpen),We.detail.isOpen&&setTimeout(()=>Ue(!0),50),window.DebalesChat.isOpen=We.detail.isOpen,window.DebalesChat.track(nr.OPEN_STATE_CHANGE,{isOpen:We.detail.isOpen,source:We.detail.source})};return window.addEventListener(ps.OPEN_STATE_CHANGE,ue),()=>{window.removeEventListener(ps.OPEN_STATE_CHANGE,ue)}},[]),pe.useEffect(()=>{const ue=We=>{te(We.detail.isOpen),window.DebalesChat.isOpen=We.detail.isOpen,window.DebalesChat.track(nr.OPEN_STATE_CHANGE,{isOpen:We.detail.isOpen})};return window.addEventListener(ps.OPEN_STATE_CHANGE,ue),()=>{window.removeEventListener(ps.OPEN_STATE_CHANGE,ue)}},[]);const[Dt,nt]=gn.useState(!1),[Pe,lt]=gn.useState(()=>{const ue=Zi(Fi.PENDING_BULK_ITEMS,{botId:e}),We=sessionStorage.getItem(ue);return We?JSON.parse(We):[]});gn.useEffect(()=>{const ue=Zi(Fi.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(ue,JSON.stringify(Pe))},[Pe,e]);const[gt,$t]=pe.useState(!1),[ht,Ct]=pe.useState({name:"",email:"",message:""}),V=YM("exit_model"),[Q,oe]=pe.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[De,Ne]=pe.useState({suggestions:!1,products:!1,collections:!1,leadingQueries:!1,initialMessage:!1,cartSummary:!1,bulkItems:!1}),[He,bt]=pe.useState(!1),[At,ce]=pe.useState(!0),[Oe,at]=pe.useState(!1),[ft,Et]=pe.useState(!1),On=2e3,Gn=pe.useCallback(ue=>{const We=ue.target,vt=We.scrollHeight-We.scrollTop<=We.clientHeight+0;ce(vt)},[]);gn.useEffect(()=>{var ue,We,vt,_t,Ke,Bt;if(h.length>0&&!m){const tn=h[h.length-1],ir=sessionStorage.getItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:e})),ws=tn.isBot&&tn.conversationId===u&&tn.conversationId!==ir,ya=(U==null?void 0:U.itemCount)&&(U==null?void 0:U.itemCount)>0&&tn.conversationId===u;if(ws){bt(!0),Ne(on=>({...on,initialMessage:!0,leadingQueries:!0})),sessionStorage.setItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:e}),tn.conversationId||""),oe({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const qe=1600;let vc=qe;const Ji=[{type:"leadingQueries",condition:h.length===1&&((ue=tn.leading_queries)==null?void 0:ue.length)&&((We=tn.leading_queries)==null?void 0:We.length)>0},{type:"collections",condition:((vt=tn.collections)==null?void 0:vt.length)&&((_t=tn.collections)==null?void 0:_t.length)>0},{type:"products",condition:((Ke=tn.products)==null?void 0:Ke.length)&&((Bt=tn.products)==null?void 0:Bt.length)>0},{type:"cartSummary",condition:(U==null?void 0:U.itemCount)&&(U==null?void 0:U.itemCount)>0},{type:"bulkItems",condition:(Pe==null?void 0:Pe.length)>0}].filter(on=>on.condition);if(Ji.length===0){bt(!1),Ne(on=>({...on,initialMessage:!1,leadingQueries:!1}));return}Ji.forEach(({type:on},br)=>{setTimeout(()=>{if(Ne(jr=>({...jr,[on]:!0})),oe(jr=>({...jr,[on]:!0})),At&&it.current){const jr=it.current;jr.scrollHeight-jr.scrollTop<=jr.clientHeight&&Zw(it)}br===Ji.length-1&&bt(!1)},vc),vc+=qe})}else ya&&oe(qe=>({...qe,cartSummary:!0}))}},[h,m,u,U==null?void 0:U.itemCount,Pe==null?void 0:Pe.length,At,e]),gn.useEffect(()=>{if(!a&&h.length>0){const ue=it.current;ue&&At&&ue.scrollHeight-ue.scrollTop<=ue.clientHeight+100&&setTimeout(()=>Zw(it),100)}},[h.length,a,At]),gn.useEffect(()=>{const ue=document.querySelector('meta[name="viewport"]'),We=ue==null?void 0:ue.content;if(Y){let vt=ue;const _t=window.matchMedia("(max-width: 768px)").matches;vt?vt.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(vt=document.createElement("meta"),vt.name="viewport",vt.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(vt)),_t&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ke=vt;return()=>{We&&Ke&&(Ke.content=We),_t&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="")}}return()=>{window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="")}},[Y,t==null?void 0:t.mobileDisplayMode]),gn.useEffect(()=>{if(Y&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const ue=We=>{let vt=We.target,_t=!1;const Ke=it.current;if(Ke){for(;vt&&vt!==document.body;){if(vt===Ke){_t=!0;break}if(vt.parentNode)vt=vt.parentNode;else break}if(!_t)We.preventDefault();else{const Bt=Ke.scrollTop<=0,tn=Ke.scrollTop+Ke.clientHeight>=Ke.scrollHeight-5;if(Bt&&We.touches[0].clientY>0||tn&&We.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",ue,{passive:!1}),()=>{document.removeEventListener("touchmove",ue)}}return()=>{}},[Y,t==null?void 0:t.mobileDisplayMode,it]),gn.useEffect(()=>{const ue=setTimeout(()=>{nt(!0)},1e3);return()=>clearTimeout(ue)},[]),gn.useEffect(()=>{a||setTimeout(()=>Zw(it),100)},[h.length,a]),gn.useEffect(()=>{U!=null&&U.itemCount&&U.itemCount===0&&!a&&setTimeout(()=>Zw(it),100)},[U==null?void 0:U.itemCount,a]),gn.useEffect(()=>{u&&sessionStorage.setItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const fn=gn.useRef(Date.now()),$n=gn.useRef(0),Tt=gn.useRef(window.location.pathname),Vt=gn.useRef(R),ot=gn.useRef(!1),kt=YM("acquisition_agent");gn.useEffect(()=>{Vt.current=R},[R]);const ci=gn.useCallback(async()=>{const ue=Date.now();if(ue-fn.current>=6e3&&ue-$n.current>=6e4&&!ot.current)try{ot.current=!0,console.log("fetching acquisition data");const _t=await fetch(`${iu}/api/wordpress/acquisition`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),page_information:window.location.href.split("?")[0],botid:e})});if(_t.ok){const Ke=await _t.json(),tn=[...Vt.current.filter(ir=>ir.path!==Tt.current),{question:Ke.Popup_Message,answer:"",path:Tt.current,nameSpace:e,type:"dynamic",Follow_up_Question:Ke.Follow_up_Question}];T(tn)}$n.current=ue}catch(_t){console.error("Error fetching acquisition data:",_t)}finally{ot.current=!1}},[e]);gn.useEffect(()=>{if(!kt||(t==null?void 0:t.show_bot)===!1)return;const ue=()=>{fn.current=Date.now()};document.addEventListener("mousemove",ue),document.addEventListener("mousedown",ue),document.addEventListener("keypress",ue),document.addEventListener("scroll",ue),document.addEventListener("touchstart",ue),document.addEventListener("touchmove",ue);const We=setInterval(ci,1e3),vt=()=>{const Ke=window.location.pathname.split("?")[0],Bt=Tt.current.split("?")[0];(()=>{const ir=Bt.split("/").filter(Boolean),ws=Ke.split("/").filter(Boolean);return ir.length!==ws.length?!0:ir.length===0&&ws.length===0?!1:Ke!==Bt})()&&(Tt.current=Ke,fn.current=Date.now())};return window.addEventListener("popstate",vt),()=>{document.removeEventListener("mousemove",ue),document.removeEventListener("mousedown",ue),document.removeEventListener("keypress",ue),document.removeEventListener("scroll",ue),document.removeEventListener("touchstart",ue),document.removeEventListener("touchmove",ue),window.removeEventListener("popstate",vt),clearInterval(We)}},[kt,ci,t==null?void 0:t.show_bot]);const[Wi,fi]=pe.useState(!1),[Li,Bo]=pe.useState(!1),[Uo,fo]=pe.useState(null),di=async ue=>{const We=Vi();if(Ue(!1),ue&&h.length>1)try{(await fetch(`${iu}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:We,userRating:ue,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(vt){console.error("Error submitting rating:",vt)}setTimeout(()=>{Bo(!1),Rt(!1,"close_button_clicked")},1e3)},vs=ue=>{y(!0),Pe.forEach(vt=>{P(vt.id,vt.quantity)}),window.DebalesChat.track(nr.ADD_BULK_ITEM,{products:Pe,message:ue});const We=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:ue,isBot:!0}];v(We),S(We),d(ue),lt([]),y(!1)},Jf=()=>{var ue;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((ue=window.shiprocketCheckoutEvents)!=null&&ue.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=Z((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Z((t==null?void 0:t.shopifyShopDomain)??""),!1},qh=async ue=>{ue.preventDefault(),window.DebalesChat.track(nr.CHECKOUT_CLICKED,{chatId:Vi()+e,cartValue:Number(U==null?void 0:U.total),cart:U}),X({dbls_method:"checkout_clicked"}),Jf()&&Rt(!1,"checkout_clicked")},[rr,Tr]=pe.useState([]);gn.useEffect(()=>{const ue=bJ(pJ(R));Tr(ue)},[R]);const cr=gn.useMemo(()=>rr.map(ue=>{if(Array.isArray(ue)){const We=ue.filter(_t=>!Nt.has(_t.question));if(We.length===0)return null;const vt={isHighlighted:ue[0].isHighlighted,enable:ue[0].enable,type:ue[0].type};return We.map(_t=>({..._t,...vt}))}else return Nt.has(ue.question)?null:ue}).filter(Boolean),[rr,Nt]);gn.useEffect(()=>{const ue=_t=>{const Ke=_t.detail.formId;switch(_t.detail.type){case"open":case"embedOpen":setTimeout(()=>{const tn=We(Ke);tn&&$e(tn)},800);break;case"close":B&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{Rt(!0,"klaviyo_form_closed"),j(Ke),r(B,void 0,void 0,!0,void 0,void 0)},1e4);break}},We=_t=>{const Ke=document.querySelector(`[data-testid="klaviyo-form-${_t}"]`);if(console.log(`formElement text ${_t} =>`,Ke==null?void 0:Ke.innerText,Ke==null?void 0:Ke.textContent),Ke instanceof HTMLElement){const Bt=Ke.innerText||Ke.textContent;if(Bt)return console.log("Found form text:",Bt),`=> Klaviyo form content:
2310
2310
 
2311
2311
  `+Bt+`
2312
2312
 
@@ -2559,4 +2559,4 @@ Learn more: https://react.dev/warnings/version-mismatch`))}(),typeof Map=="funct
2559
2559
  You might need to use a local HTTP server (instead of file://): https://react.dev/link/react-devtools-faq`:""),"font-weight:bold")}Db.createRoot=function(i,o){if(!T(i))throw Error("Target container is not a DOM element.");MA(i);var c=!1,g="",_=__,w=oA,O=gv,I=null;return o!=null&&(o.hydrate?console.warn("hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead."):typeof o=="object"&&o!==null&&o.$$typeof===zu&&console.error(`You passed a JSX element to createRoot. You probably meant to call root.render instead. Example usage:
2560
2560
 
2561
2561
  let root = createRoot(domContainer);
2562
- root.render(<App />);`),o.unstable_strictMode===!0&&(c=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onUncaughtError!==void 0&&(_=o.onUncaughtError),o.onCaughtError!==void 0&&(w=o.onCaughtError),o.onRecoverableError!==void 0&&(O=o.onRecoverableError),o.unstable_transitionCallbacks!==void 0&&(I=o.unstable_transitionCallbacks)),o=m1(i,1,!1,null,null,c,g,_,w,O,I,null),i[ju]=o.current,W_(i),new ly(o)},Db.hydrateRoot=function(i,o,c){if(!T(i))throw Error("Target container is not a DOM element.");MA(i),o===void 0&&console.error("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");var g=!1,_="",w=__,O=oA,I=gv,H=null,F=null;return c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onUncaughtError!==void 0&&(w=c.onUncaughtError),c.onCaughtError!==void 0&&(O=c.onCaughtError),c.onRecoverableError!==void 0&&(I=c.onRecoverableError),c.unstable_transitionCallbacks!==void 0&&(H=c.unstable_transitionCallbacks),c.formState!==void 0&&(F=c.formState)),o=m1(i,1,!0,o,c??null,g,_,w,O,I,H,F),o.context=v1(null),c=o.current,g=Aa(c),g=Oe(g),_=ks(g),_.callback=null,Vo(c,_,g),c=g,o.current.lanes=c,He(o,c),xo(o),i[ju]=o.current,W_(i),new qp(o)},Db.version="19.1.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Db}var ZU;function Goe(){if(ZU)return RE.exports;ZU=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function")){if(process.env.NODE_ENV!=="production")throw new Error("^_^");try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}}return process.env.NODE_ENV==="production"?(e(),RE.exports=Foe()):RE.exports=joe(),RE.exports}var Voe=Goe();const QU="debales-ai-assistant",KU="debales-chatbot-container",Yoe=pe.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},a)=>{const s=pe.useRef(null),[u,d]=pe.useState(null),h=pe.useRef(null),m=pe.useRef(null),y=pe.useRef({get shadowRoot(){return h.current},get container(){return u},querySelector:v=>{var S;return((S=h.current)==null?void 0:S.querySelector(v))||null},querySelectorAll:v=>{var S;return((S=h.current)==null?void 0:S.querySelectorAll(v))||null}});return pe.useImperativeHandle(a,()=>y.current,[]),pe.useEffect(()=>{const v=document.getElementById(QU);if(v?s.current=v:s.current&&(s.current.id=QU),s.current&&(s.current.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;"),s.current){if(s.current.shadowRoot){h.current=s.current.shadowRoot;const E=h.current.querySelector(`#${KU}`);E&&d(E);return}const S=s.current.attachShadow({mode:"open"});if(h.current=S,t){const E=document.createElement("style");E.textContent=t,S.appendChild(E)}const x=document.createElement("div");x.id=KU,x.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;",S.appendChild(x),d(x),r&&r(S,x)}},[t,r]),pe.useEffect(()=>(u&&!m.current&&(m.current=Voe.createRoot(u)),m.current&&u&&m.current.render(q.jsx(me.StyleSheetManager,{target:u,children:q.jsx(q8,{value:y.current,children:e})})),()=>{m.current&&m.current.unmount()}),[u,e]),q.jsx("div",{ref:s,style:n})});class h2{isSupported(){return xb.detect()===this.platform}createSuccessResult(t,n){return{success:!0,data:t,message:n}}createErrorResult(t){return{success:!1,error:t}}}class Zoe extends h2{constructor(){super(...arguments);Ii(this,"platform",Xi.DEFAULT)}async fetchCart(){return console.log("DefaultCartAdapter: fetchCart called"),this.createSuccessResult({items:[],total:0,itemCount:0,currency:"USD",token:"default-token"},"Default cart fetched")}async addToCart(n,r=1,a){return console.log("DefaultCartAdapter: addToCart called",{variantId:n,quantity:r,properties:a}),this.createSuccessResult(void 0,"Item added to cart (mock)")}async removeFromCart(n){return console.log("DefaultCartAdapter: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("DefaultCartAdapter: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("DefaultCartAdapter: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=n.replace(/^https?:\/\//,"");return console.log("DefaultCartAdapter: generateCartUrl called",{domain:n,sanitizedDomain:r}),`https://${r}/cart`}generateProductUrl(n,r){if(r.handle){const a=new URL(`https://${n}/products/${r.handle}`);return a.searchParams.append("variant",r.product_id),zh(a.toString())}else return zh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}class Qoe extends h2{constructor(){var n,r;super();Ii(this,"platform",Xi.SHOPIFY);Ii(this,"cartEndpoint");Ii(this,"localCartKey","debales_track_cart");this.cartEndpoint=((r=(n=window.Shopify)==null?void 0:n.routes)==null?void 0:r.root)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:r.id,variant_id:r.variant_id,quantity:r.quantity,title:r.title,price:r.price,properties:r.properties})),total:n.total_price/100,itemCount:n.item_count,currency:n.currency,token:n.token.split("?")[0]}}generateProductUrl(n,r){const a=kE(n);if(!a.isValid)return"";if(r.handle){const s=new URL(`/products/${r.handle}`,a.url);return s.searchParams.append("variant",r.product_id),zh(s.toString())}else return zh(r.link)}updateTrackCart({cartToken:n,sessionId:r=Vi()}){localStorage.setItem(this.localCartKey,JSON.stringify({sessionId:r,cartToken:n}))}async fetchCart(){try{const n=await fetch(`${this.cartEndpoint}cart.js`),r=await n.json();if(!n.ok){const s=r;return this.createErrorResult(s.description||`Failed to fetch cart: ${n.status}`)}const a=r;return this.createSuccessResult(this.normalizeCartData(a),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1,a){try{const s=await fetch(`${this.cartEndpoint}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:n,quantity:r,properties:a}],attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:Vi(),dbls_method:"add_to_cart"}})}),u=await s.json();if(!s.ok){const d=u;return this.createErrorResult(d.description||`Failed to add item to cart: ${s.status}`)}return this.fetchCart().then(d=>{d.success&&this.updateTrackCart({cartToken:d==null?void 0:d.data.token})}),this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(s){return this.createErrorResult(s instanceof Error?`Error adding to cart: ${s.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return this.updateQuantity({id:n,quantity:0})}async updateQuantity(n){try{const r=await fetch(`${this.cartEndpoint}cart/change.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:n.id,quantity:n.quantity})}),a=await r.json();if(!r.ok){const s=a;return this.createErrorResult(s.description||`Failed to update item quantity: ${r.status}`)}return this.fetchCart().then(s=>{s.success&&this.updateTrackCart({cartToken:s==null?void 0:s.data.token})}),this.createSuccessResult(void 0,n.quantity===0?"Item removed from cart":`Quantity updated to ${n.quantity}`)}catch(r){return this.createErrorResult(r instanceof Error?`Error updating quantity: ${r.message}`:"Unknown error occurred while updating quantity")}}async clearCart(){try{const n=await fetch(`${this.cartEndpoint}cart/clear.js`,{method:"POST"});if(!n.ok){const r=await n.json();return this.createErrorResult(r.description||`Failed to clear cart: ${n.status}`)}return this.createSuccessResult(void 0,"Cart cleared successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error clearing cart: ${n.message}`:"Unknown error occurred while clearing cart")}}async addCartAttributes(n={}){try{const r=await fetch(`${this.cartEndpoint}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:Vi(),...n}})});if(!r.ok){const a=await r.json();return this.createErrorResult(a.description||`Failed to update cart attributes: ${r.status}`)}return this.createSuccessResult(void 0,"Cart attributes updated successfully")}catch(r){return this.createErrorResult(r instanceof Error?`Error updating cart attributes: ${r.message}`:"Unknown error occurred while updating cart attributes")}}generateCartUrl(n){const r=kE(n);if(!r.isValid)return"";const a=new URL("/cart",r.url);return a.searchParams.append("ref",`debales-ai-${new Date().toISOString()}`),a.searchParams.append("attributes[from]","debales-ai-chatbot"),a.searchParams.append("attributes[through]","add-to-cart"),a.searchParams.append("attributes[dbls_session_id]",Vi()),a.searchParams.append("timestamp",Date.now().toString()),zh(a.toString())}}class Koe extends h2{constructor(){var n,r;super();Ii(this,"platform",Xi.MAGENTO);Ii(this,"checkoutEndpoint");Ii(this,"baseUrl");this.checkoutEndpoint=((n=window.checkout)==null?void 0:n.checkoutUrl)||"/",this.baseUrl=((r=window.checkout)==null?void 0:r.baseUrl)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:parseInt(r.item_id),variant_id:parseInt(r.product_id),quantity:r.qty,title:r.product_name,price:r.product_price_value,properties:{name:r.product_name}})),total:parseFloat(n.subtotalAmount),itemCount:n.summary_count,currency:"USD",token:n.data_id.toString()}}async fetchCart(){try{const n=await fetch(`${this.baseUrl}customer/section/load/?sections=cart&update_section_id=false`),r=await n.json();if(!n.ok)return this.createErrorResult(`Failed to fetch cart: ${n.status}`);const a=r.cart;return this.createSuccessResult(this.normalizeCartData(a),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1){var a;try{const s=(a=document.querySelector('input[name="form_key"]'))==null?void 0:a.value;if(!s)return this.createErrorResult("Form key not found");const u=await fetch(`${this.checkoutEndpoint}cart/add`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:new URLSearchParams({product:n,qty:r.toString(),form_key:s})});if(!u.ok)return this.createErrorResult(`Failed to add item to cart: ${u.status}`);try{window.require(["Magento_Customer/js/customer-data"],d=>d.reload(["cart"],!0))}catch(d){console.warn("Failed to reload cart data:",d)}return this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(s){return this.createErrorResult(s instanceof Error?`Error adding to cart: ${s.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return console.log("MethodNotImplemented: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("MethodNotImplemented: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("MethodNotImplemented: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=new URL(`https://${n}/checkout/cart?ref=debales-ai-${new Date().toISOString()}&attributes[from]=debales-ai-chatbot&attributes[through]=add-to-cart`);return r.searchParams.append("timestamp",Date.now().toString()),r.toString()}generateProductUrl(n,r){const a=kE(n);if(!a.isValid)return"";if(r.handle){const s=new URL(`/${r.handle}.html`,a.url);return zh(s.toString())}else return zh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}const Hh=class Hh{constructor(){Ii(this,"adapterCache");this.adapterCache=new Map}static getInstance(){return Hh.instance||(Hh.instance=new Hh),Hh.instance}getAdapter(t){const n=t||xb.detect(),r=this.adapterCache.get(n);if(r)return r;let a;switch(n){case Xi.SHOPIFY:a=new Qoe;break;case Xi.MAGENTO:a=new Koe;break;default:console.warn(`No specific adapter found for platform ${n}, using default adapter`),a=new Zoe}return this.adapterCache.set(n,a),a}clearCache(){this.adapterCache.clear()}};Ii(Hh,"instance");let p2=Hh;const Xoe=({adapter:e,children:t,autoFetch:n=!0})=>{const[r,a]=pe.useState(!1),[s,u]=pe.useState(null),[d,h]=pe.useState(null),m=pe.useCallback(async()=>{try{a(!0),u(null);const M=await e.fetchCart();M.success?h(M.data):u(M.error)}catch(M){u(M instanceof Error?M.message:"Failed to fetch cart")}finally{a(!1)}},[e]),y=async(M,D,$)=>{try{u(null);const U=await e.addToCart(M,D,$);return U.success&&await m(),U}catch(U){return{success:!1,error:U instanceof Error?U.message:"Failed to add item to cart"}}},v=async M=>{try{u(null);const D=await e.removeFromCart(M);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to remove item from cart"}}},S=async M=>{try{u(null);const D=await e.updateQuantity(M);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to update quantity"}}},x=async()=>{try{u(null);const M=await e.clearCart();return M.success&&await m(),M}catch(M){return{success:!1,error:M instanceof Error?M.message:"Failed to clear cart"}}},E=M=>e.generateCartUrl(M),R=(M,D)=>e.generateProductUrl(M,D),T=async M=>e.addCartAttributes(M);pe.useEffect(()=>{n&&m()},[n,m]);const A={isLoading:r,error:s,cart:d,fetchCart:m,addToCart:y,removeFromCart:v,updateQuantity:S,clearCart:x,generateCartUrl:E,generateProductUrl:R,addCartAttributes:T};return q.jsx(QN.Provider,{value:A,children:t})},lu=Object.create(null);lu.open="0",lu.close="1",lu.ping="2",lu.pong="3",lu.message="4",lu.upgrade="5",lu.noop="6";const ME=Object.create(null);Object.keys(lu).forEach(e=>{ME[lu[e]]=e});const g2={type:"error",data:"parser error"},XU=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",WU=typeof ArrayBuffer=="function",JU=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,m2=({type:e,data:t},n,r)=>XU&&t instanceof Blob?n?r(t):ez(t,r):WU&&(t instanceof ArrayBuffer||JU(t))?n?r(t):ez(new Blob([t]),r):r(lu[e]+(t||"")),ez=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function tz(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let v2;function Woe(e,t){if(XU&&e.data instanceof Blob)return e.data.arrayBuffer().then(tz).then(t);if(WU&&(e.data instanceof ArrayBuffer||JU(e.data)))return t(tz(e.data));m2(e,!1,n=>{v2||(v2=new TextEncoder),t(v2.encode(n))})}const nz="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ib=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<nz.length;e++)Ib[nz.charCodeAt(e)]=e;const Joe=e=>{let t=e.length*.75,n=e.length,r,a=0,s,u,d,h;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const m=new ArrayBuffer(t),y=new Uint8Array(m);for(r=0;r<n;r+=4)s=Ib[e.charCodeAt(r)],u=Ib[e.charCodeAt(r+1)],d=Ib[e.charCodeAt(r+2)],h=Ib[e.charCodeAt(r+3)],y[a++]=s<<2|u>>4,y[a++]=(u&15)<<4|d>>2,y[a++]=(d&3)<<6|h&63;return m},ese=typeof ArrayBuffer=="function",y2=(e,t)=>{if(typeof e!="string")return{type:"message",data:rz(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:tse(e.substring(1),t)}:ME[n]?e.length>1?{type:ME[n],data:e.substring(1)}:{type:ME[n]}:g2},tse=(e,t)=>{if(ese){const n=Joe(e);return rz(n,t)}else return{base64:!0,data:e}},rz=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},iz="",nse=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((s,u)=>{m2(s,!1,d=>{r[u]=d,++a===n&&t(r.join(iz))})})},rse=(e,t)=>{const n=e.split(iz),r=[];for(let a=0;a<n.length;a++){const s=y2(n[a],t);if(r.push(s),s.type==="error")break}return r};function ise(){return new TransformStream({transform(e,t){Woe(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const s=new DataView(a.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{a=new Uint8Array(9);const s=new DataView(a.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let b2;function DE(e){return e.reduce((t,n)=>t+n.length,0)}function IE(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function ase(e,t){b2||(b2=new TextDecoder);const n=[];let r=0,a=-1,s=!1;return new TransformStream({transform(u,d){for(n.push(u);;){if(r===0){if(DE(n)<1)break;const h=IE(n,1);s=(h[0]&128)===128,a=h[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(DE(n)<2)break;const h=IE(n,2);a=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(DE(n)<8)break;const h=IE(n,8),m=new DataView(h.buffer,h.byteOffset,h.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){d.enqueue(g2);break}a=y*Math.pow(2,32)+m.getUint32(4),r=3}else{if(DE(n)<a)break;const h=IE(n,a);d.enqueue(y2(s?h:b2.decode(h),t)),r=0}if(a===0||a>e){d.enqueue(g2);break}}}})}const az=4;function ui(e){if(e)return ose(e)}function ose(e){for(var t in ui.prototype)e[t]=ui.prototype[t];return e}ui.prototype.on=ui.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},ui.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},ui.prototype.off=ui.prototype.removeListener=ui.prototype.removeAllListeners=ui.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this},ui.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this},ui.prototype.emitReserved=ui.prototype.emit,ui.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},ui.prototype.hasListeners=function(e){return!!this.listeners(e).length};const LE=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),gs=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),sse="arraybuffer";function xue(){}function oz(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const lse=gs.setTimeout,use=gs.clearTimeout;function NE(e,t){t.useNativeTimers?(e.setTimeoutFn=lse.bind(gs),e.clearTimeoutFn=use.bind(gs)):(e.setTimeoutFn=gs.setTimeout.bind(gs),e.clearTimeoutFn=gs.clearTimeout.bind(gs))}const cse=1.33;function fse(e){return typeof e=="string"?dse(e):Math.ceil((e.byteLength||e.size)*cse)}function dse(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function sz(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function hse(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function pse(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let s=n[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}class gse extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class _2 extends ui{constructor(t){super(),this.writable=!1,NE(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new gse(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=y2(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=hse(t);return n.length?"?"+n:""}}class mse extends _2{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};rse(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,nse(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=sz()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let lz=!1;try{lz=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const vse=lz;function yse(){}class bse extends mse{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,s)=>{this.onError("xhr post error",a,s)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class uu extends ui{constructor(t,n,r){super(),this.createRequest=t,NE(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=oz(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=uu.requestsCount++,uu.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=yse,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete uu.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(uu.requestsCount=0,uu.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",uz);else if(typeof addEventListener=="function"){const e="onpagehide"in gs?"pagehide":"unload";addEventListener(e,uz,!1)}}function uz(){for(let e in uu.requests)uu.requests.hasOwnProperty(e)&&uu.requests[e].abort()}const _se=function(){const e=cz({xdomain:!1});return e&&e.responseType!==null}();class Sse extends bse{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=_se&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new uu(cz,this.uri(),t)}}function cz(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||vse))return new XMLHttpRequest}catch{}if(!t)try{return new gs[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const fz=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class wse extends _2{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=fz?{}:oz(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;m2(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}a&&LE(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=sz()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const S2=gs.WebSocket||gs.MozWebSocket;class xse extends wse{createSocket(t,n,r){return fz?new S2(t,n,r):n?new S2(t,n):new S2(t)}doWrite(t,n){this.ws.send(n)}}class Cse extends _2{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=ase(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=ise();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const s=()=>{r.read().then(({done:d,value:h})=>{d||(this.onPacket(h),s())}).catch(d=>{})};s();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this._writer.write(u).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&LE(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Ese={websocket:xse,webtransport:Cse,polling:Sse},Ase=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Tse=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function w2(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=Ase.exec(e||""),s={},u=14;for(;u--;)s[Tse[u]]=a[u]||"";return n!=-1&&r!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=kse(s,s.path),s.queryKey=Rse(s,s.query),s}function kse(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Rse(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,s){a&&(n[a]=s)}),n}const x2=typeof addEventListener=="function"&&typeof removeEventListener=="function",$E=[];x2&&addEventListener("offline",()=>{$E.forEach(e=>e())},!1);class Wf extends ui{constructor(t,n){if(super(),this.binaryType=sse,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=w2(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=w2(n.host).host);NE(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=pse(this.opts.query)),x2&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},$E.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=az,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Wf.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Wf.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=fse(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,LE(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const s={type:t,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Wf.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),x2&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=$E.indexOf(this._offlineEventListener);r!==-1&&$E.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Wf.protocol=az;class Ose extends Wf{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Wf.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",v=>{if(!r)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Wf.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(y(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=n.name,this.emitReserved("upgradeError",S)}}))};function s(){r||(r=!0,y(),n.close(),n=null)}const u=v=>{const S=new Error("probe error: "+v);S.transport=n.name,s(),this.emitReserved("upgradeError",S)};function d(){u("transport closed")}function h(){u("socket closed")}function m(v){n&&v.name!==n.name&&s()}const y=()=>{n.removeListener("open",a),n.removeListener("error",u),n.removeListener("close",d),this.off("close",h),this.off("upgrading",m)};n.once("open",a),n.once("error",u),n.once("close",d),this.once("close",h),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let Mse=class extends Ose{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>Ese[a]).filter(a=>!!a)),super(t,r)}};function Dse(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=w2(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+t,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}const Ise=typeof ArrayBuffer=="function",Lse=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,dz=Object.prototype.toString,Nse=typeof Blob=="function"||typeof Blob<"u"&&dz.call(Blob)==="[object BlobConstructor]",$se=typeof File=="function"||typeof File<"u"&&dz.call(File)==="[object FileConstructor]";function C2(e){return Ise&&(e instanceof ArrayBuffer||Lse(e))||Nse&&e instanceof Blob||$se&&e instanceof File}function BE(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(BE(e[n]))return!0;return!1}if(C2(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return BE(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&BE(e[n]))return!0;return!1}function Bse(e){const t=[],n=e.data,r=e;return r.data=E2(n,t),r.attachments=t.length,{packet:r,buffers:t}}function E2(e,t){if(!e)return e;if(C2(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=E2(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=E2(e[r],t));return n}return e}function Use(e,t){return e.data=A2(e.data,t),delete e.attachments,e}function A2(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=A2(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=A2(e[n],t));return e}const zse=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Hse=5;var An;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(An||(An={}));class Pse{constructor(t){this.replacer=t}encode(t){return(t.type===An.EVENT||t.type===An.ACK)&&BE(t)?this.encodeAsBinary({type:t.type===An.EVENT?An.BINARY_EVENT:An.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===An.BINARY_EVENT||t.type===An.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=Bse(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function hz(e){return Object.prototype.toString.call(e)==="[object Object]"}class T2 extends ui{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===An.BINARY_EVENT;r||n.type===An.BINARY_ACK?(n.type=r?An.EVENT:An.ACK,this.reconstructor=new qse(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(C2(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(An[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===An.BINARY_EVENT||r.type===An.BINARY_ACK){const s=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const u=t.substring(s,n);if(u!=Number(u)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(u)}if(t.charAt(n+1)==="/"){const s=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(s,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const s=n+1;for(;++n;){const u=t.charAt(n);if(u==null||Number(u)!=u){--n;break}if(n===t.length)break}r.id=Number(t.substring(s,n+1))}if(t.charAt(++n)){const s=this.tryParse(t.substr(n));if(T2.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case An.CONNECT:return hz(n);case An.DISCONNECT:return n===void 0;case An.CONNECT_ERROR:return typeof n=="string"||hz(n);case An.EVENT:case An.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&zse.indexOf(n[0])===-1);case An.ACK:case An.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qse{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=Use(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Fse=Object.freeze(Object.defineProperty({__proto__:null,Decoder:T2,Encoder:Pse,get PacketType(){return An},protocol:Hse},Symbol.toStringTag,{value:"Module"}));function bl(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const jse=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class pz extends ui{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[bl(t,"open",this.onopen.bind(this)),bl(t,"packet",this.onpacket.bind(this)),bl(t,"error",this.onerror.bind(this)),bl(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,s;if(jse.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const u={type:An.EVENT,data:n};if(u.options={},u.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const y=this.ids++,v=n.pop();this._registerAckCallback(y,v),u.id=y}const d=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,h=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!d||(h?(this.notifyOutgoingListeners(u),this.packet(u)):this.sendBuffer.push(u)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const s=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let d=0;d<this.sendBuffer.length;d++)this.sendBuffer[d].id===t&&this.sendBuffer.splice(d,1);n.call(this,new Error("operation has timed out"))},a),u=(...d)=>{this.io.clearTimeoutFn(s),n.apply(this,d)};u.withError=!0,this.acks[t]=u}emitWithAck(t,...n){return new Promise((r,a)=>{const s=(u,d)=>u?a(u):r(d);s.withError=!0,n.push(s),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...s)=>r!==this._queue[0]?void 0:(a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:An.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case An.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case An.EVENT:case An.BINARY_EVENT:this.onevent(t);break;case An.ACK:case An.BINARY_ACK:this.onack(t);break;case An.DISCONNECT:this.ondisconnect();break;case An.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:An.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:An.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function $m(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}$m.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0},$m.prototype.reset=function(){this.attempts=0},$m.prototype.setMin=function(e){this.ms=e},$m.prototype.setMax=function(e){this.max=e},$m.prototype.setJitter=function(e){this.jitter=e};class k2 extends ui{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,NE(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new $m({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||Fse;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Mse(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=bl(n,"open",function(){r.onopen(),t&&t()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),t?t(d):this.maybeReconnectOnOpen()},u=bl(n,"error",s);if(this._timeout!==!1){const d=this._timeout,h=this.setTimeoutFn(()=>{a(),s(new Error("timeout")),n.close()},d);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(a),this.subs.push(u),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(bl(t,"ping",this.onping.bind(this)),bl(t,"data",this.ondata.bind(this)),bl(t,"error",this.onerror.bind(this)),bl(t,"close",this.onclose.bind(this)),bl(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){LE(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new pz(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Lb={};function UE(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=Dse(e,t.path||"/socket.io"),r=n.source,a=n.id,s=n.path,u=Lb[a]&&s in Lb[a].nsps,d=t.forceNew||t["force new connection"]||t.multiplex===!1||u;let h;return d?h=new k2(r,t):(Lb[a]||(Lb[a]=new k2(r,t)),h=Lb[a]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}Object.assign(UE,{Manager:k2,Socket:pz,io:UE,connect:UE});const Ph=class Ph{constructor(){Ii(this,"socket",null);Ii(this,"isConnected",!1);Ii(this,"eventListeners",new Map)}static getInstance(){return Ph.instance||(Ph.instance=new Ph),Ph.instance}connect(t){return this.socket?this.socket:(this.socket=UE(`${uJ}${t}`,{transports:["websocket"]}),this.socket.on("connect",()=>{this.isConnected=!0,this.emitEvent("connect")}),this.socket.on("disconnect",()=>{this.isConnected=!1,this.emitEvent("disconnect")}),this.socket)}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null,this.isConnected=!1,this.eventListeners.clear())}getSocket(){return this.socket}getIsConnected(){return this.isConnected}on(t,n){var r,a;this.eventListeners.has(t)||this.eventListeners.set(t,[]),(r=this.eventListeners.get(t))==null||r.push(n),(a=this.socket)==null||a.on(t,n)}off(t,n){var a;const r=this.eventListeners.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1),(a=this.socket)==null||a.off(t,n)}}emit(t,...n){var r;(r=this.socket)==null||r.emit(t,...n)}emitEvent(t,...n){const r=this.eventListeners.get(t);r&&r.forEach(a=>a(...n))}};Ii(Ph,"instance");let R2=Ph;const cu=R2.getInstance();var Gse={MESSAGE:"MESSAGE"},Vse={USER:"USER"};function zE(e,t){window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:t}))}const gz=(e,t)=>{const n=JSON.stringify(t);window.localStorage.setItem(e,n),zE(e,n)},Yse=e=>{window.localStorage.removeItem(e),zE(e,null)},mz=e=>window.localStorage.getItem(e),Zse=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Qse=()=>{throw Error("useLocalStorage is a client-only hook")};function Kse(e,t){const n=()=>mz(e),r=gn.useSyncExternalStore(Zse,n,Qse),a=gn.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Yse(e):gz(e,u)}catch(u){console.warn(u)}},[e,r]);return gn.useEffect(()=>{mz(e)===null&&gz(e,t)},[e,t]),[r?JSON.parse(r):t,a]}const vz=(e,t)=>{const n=JSON.stringify(t);window.sessionStorage.setItem(e,n),zE(e,n)},Xse=e=>{window.sessionStorage.removeItem(e),zE(e,null)},yz=e=>window.sessionStorage.getItem(e),Wse=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Jse=()=>{throw Error("useSessionStorage is a client-only hook")};function ele(e,t){const n=()=>yz(e),r=gn.useSyncExternalStore(Wse,n,Jse),a=gn.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Xse(e):vz(e,u)}catch(u){console.warn(u)}},[e,r]);return gn.useEffect(()=>{yz(e)===null&&vz(e,t)},[e,t]),[r?JSON.parse(r):t,a]}const tle=({children:e,nameSpace:t})=>{const[n,r]=pe.useState(""),[a,s]=pe.useState([]),[u,d]=pe.useState(!1),[h,m]=pe.useState(!1),[y,v]=pe.useState([]),[S,x]=pe.useState(!1),[E,R]=pe.useState(!1),[T,A]=pe.useState([]),[M,D]=Kse(Zi(Fi.USER_INFO),null),[$,U]=ele(Zi(Fi.IS_FORM_CLOSED_BY_USER),!1),[P,Z]=pe.useState(null),X=YM("web-socket"),[K,G]=pe.useState([]),[ne,se]=pe.useState(null),[be,ae]=pe.useState(!1),[ve,Y]=pe.useState(sessionStorage.getItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:t}))),te=vJ(),fe=Vi(),[Ue,B]=pe.useState(null),[$e,ke]=pe.useState(null);pe.useEffect(()=>{if(X){const nt=cu.connect("/api/v1/chat");se(nt);const Pe=()=>{console.debug("connected to websocket"),ae(!0)},lt=()=>{console.debug("disconnected from websocket"),ae(!1)},gt=ht=>{console.debug("response from websocket",ht);const Ct=ht.conversationId??crypto.randomUUID().toString();Y(Ct),ht.Variants_quantity&&A(Q=>[...Q,...ht.Variants_quantity]);const V=[...a,{text:ht.response,products:ht.products,conversationId:Ct,rating:"neutral",leading_queries:ht.leading_queries,collections:ht.collections,variants:ht.variants,shop:ht.shop,Variants_quantity:ht.Variants_quantity,monthlyChatLimitReached:ht.monthlyChatLimitReached,isBot:!0}];s(V),j(V),v(Q=>[...Q,[a[a.length-1].text,ht.response]]),m(!1)},$t=ht=>{if(ht.event==="error"){const Ct={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},V=[...a,Ct];s(V),j(V),m(!1)}};return cu.on("connect",Pe),cu.on("disconnect",lt),cu.on("response",gt),cu.on("system",$t),()=>{cu.off("connect",Pe),cu.off("disconnect",lt),cu.off("response",gt),cu.off("system",$t)}}},[X,a]);const j=nt=>{sessionStorage.setItem(Zi(Fi.CHAT_HISTORY,{botId:window.DebalesChat.projectId}),JSON.stringify(nt))},Ge=()=>{const nt=sessionStorage.getItem(Zi(Fi.CHAT_HISTORY,{botId:window.DebalesChat.projectId}));return nt?JSON.parse(nt):[]},it=pe.useCallback(async()=>{if(t)try{d(!0);const nt=await fetch(`${iu}/api/wordpress/UiData?value=${t}`),Pe=await nt.json();if(!nt.ok)throw new Error("failed to fetch data"+Pe.error);const lt=document.getElementById("debales-ai-assistant");lt&&(lt.style.zIndex=String(Pe.zIndex??2031483602)),ke(Pe),Pe!=null&&Pe.shopifyShopDomain&&Zte(Pe.shopifyShopDomain).then($t=>{B($t)}),G(Pe.suggestedQuestions);const gt=Ge();if(gt.length>0)s(gt);else{const $t={text:Pe.initialMessage||"Hi, I am an AI Assistant. How can I help you?",isBot:!0};s([$t])}}catch(nt){console.error(nt)}finally{d(!1)}},[t]);pe.useEffect(()=>{it()},[it]);const ze=pe.useMemo(()=>{var nt;return!!(!$&&((nt=$e==null?void 0:$e.pluginConfig)!=null&&nt.collectedUserInfo)&&($e.pluginConfig.collectedUserInfo.name||$e.pluginConfig.collectedUserInfo.email||$e.pluginConfig.collectedUserInfo.phone)&&!M)},[$e,M,$]),Nt=pe.useCallback(async(nt,Pe,lt,gt,$t,ht)=>{if(!nt||nt.trim()===""||h&&!lt)return;let Ct=[...a];gt?gt&&a.length<=2?(x(!0),Ct=[]):x(!1):(Ct.push({text:nt,isBot:!1}),x(!1));const V=Vi();m(!0);try{s(Ct),j(Ct);const Q=await fetch(`${iu}/api/wordpress/ChatWithBot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:V,userMessage:nt,nameSpace:t,chat_history:y,leading_queries:$t,answer:Pe,products:lt,userInfo:JSON.stringify(M),anonymousUserId:te,distinctId:Ah.getDistinctId(),timestamp:new Date().toISOString(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,followUpQuestion:ht})});if(!Q.ok)throw new Error("Network response was not ok");const oe=await Q.json(),De=oe.conversationId??crypto.randomUUID().toString();Y(De),oe.Variants_quantity&&A(He=>[...He,...oe.Variants_quantity]);const Ne=[...Ct,{text:oe.response,products:oe.products,conversationId:De,rating:"neutral",leading_queries:oe.leading_queries,collections:oe.collections,variants:oe.variants,shop:oe.shop,Variants_quantity:oe.Variants_quantity,monthlyChatLimitReached:oe.monthlyChatLimitReached,isBot:!0}];s(Ne),j(Ne),v(He=>[...He,[nt,oe.response]])}catch(Q){console.error(Q);const oe={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},De=[...Ct,oe];gt||(s(De),j(De))}finally{m(!1)}},[a,h,y,t,te,M]),dt=pe.useCallback(nt=>{$e&&ke(Pe=>Pe?{...Pe,mobileDisplayMode:nt}:null)},[$e]),Rt=pe.useCallback(async(nt,Pe,lt,gt,$t,ht)=>{if(!nt||nt.trim()===""||h&&!lt)return;let Ct=[...a];if(gt?gt&&a.length<=2?(x(!0),Ct=[]):x(!1):(Ct.push({text:nt,isBot:!1}),x(!1)),m(!0),s(Ct),j(Ct),ne&&be){const V={type:Gse.MESSAGE,role:Vse.USER,query:nt,nameSpace:t,leadingQueries:$t,answer:Pe,products:lt,userInfo:M,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),sessionId:fe,anonymousUserId:te,distinctId:Ah.getDistinctId(),followUpQuestion:ht};cu.emit("chat",V)}else Nt(nt,Pe,lt,gt,$t,ht)},[a,h,t,te,ne,be,fe,Nt,M]),Dt={sessionId:fe,messages:a,isLoading:u,isMessageLoading:h,isKlaviyoMessage:S,showUserInfoModel:E,pendingBulkItems:T,lastedBotmessageId:ve,uiData:$e,storeMetaData:Ue,suggestedQuestions:K,isUserInfoNeeded:ze,input:n,pendingQuestion:P,userInfo:M,isFormClosedByUser:$,onSendMessage:X?Rt:Nt,setMessages:s,setIsLoading:d,setIsMessageLoading:m,setIsKlaviyoMessage:x,setShowUserInfoModel:R,setPendingBulkItems:A,setLastedBotmessageId:Y,fetchUiInfo:it,changeDisplayModel:dt,saveConversation:j,loadConversation:Ge,setSuggestedQuestions:G,setUserInfo:D,setInput:r,setPendingQuestion:Z,setIsFormClosedByUser:U};return q.jsx(F8.Provider,{value:Dt,children:e})};function nle(e){const t=p2.getInstance().getAdapter();return q.jsx(tle,{nameSpace:e.botId,children:q.jsx(zte,{apiKey:cJ,options:{capture_pageview:e.botId!=="burgerbaeclothing",capture_pageleave:e.botId!=="burgerbaeclothing",api_host:iu+"/ingest",ui_host:"https://us.posthog.com",loaded:n=>{n.register({platform:xb.detect(),project:e.botId,sessionId:Vi()}),n.group("project",e.botId,{platform:xb.detect()});const r=Uf();r&&r.email&&!n._isIdentified()&&n.identify(r.email,{name:r.name,phone:r.phone,email:r.email,project:e.botId})},debug:!0},children:q.jsx(Xoe,{adapter:t,children:e.children})})})}function rle(e){return q.jsx(Yoe,{children:q.jsx(nle,{botId:e.botId,children:q.jsx(Hoe,{...e})})})}return rle});
2562
+ root.render(<App />);`),o.unstable_strictMode===!0&&(c=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onUncaughtError!==void 0&&(_=o.onUncaughtError),o.onCaughtError!==void 0&&(w=o.onCaughtError),o.onRecoverableError!==void 0&&(O=o.onRecoverableError),o.unstable_transitionCallbacks!==void 0&&(I=o.unstable_transitionCallbacks)),o=m1(i,1,!1,null,null,c,g,_,w,O,I,null),i[ju]=o.current,W_(i),new ly(o)},Db.hydrateRoot=function(i,o,c){if(!T(i))throw Error("Target container is not a DOM element.");MA(i),o===void 0&&console.error("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");var g=!1,_="",w=__,O=oA,I=gv,H=null,F=null;return c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onUncaughtError!==void 0&&(w=c.onUncaughtError),c.onCaughtError!==void 0&&(O=c.onCaughtError),c.onRecoverableError!==void 0&&(I=c.onRecoverableError),c.unstable_transitionCallbacks!==void 0&&(H=c.unstable_transitionCallbacks),c.formState!==void 0&&(F=c.formState)),o=m1(i,1,!0,o,c??null,g,_,w,O,I,H,F),o.context=v1(null),c=o.current,g=Aa(c),g=Oe(g),_=ks(g),_.callback=null,Vo(c,_,g),c=g,o.current.lanes=c,He(o,c),xo(o),i[ju]=o.current,W_(i),new qp(o)},Db.version="19.1.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Db}var ZU;function Goe(){if(ZU)return RE.exports;ZU=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function")){if(process.env.NODE_ENV!=="production")throw new Error("^_^");try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}}return process.env.NODE_ENV==="production"?(e(),RE.exports=Foe()):RE.exports=joe(),RE.exports}var Voe=Goe();const QU="debales-ai-assistant",KU="debales-chatbot-container",Yoe=pe.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},a)=>{const s=pe.useRef(null),[u,d]=pe.useState(null),h=pe.useRef(null),m=pe.useRef(null),y=pe.useRef({get shadowRoot(){return h.current},get container(){return u},querySelector:v=>{var S;return((S=h.current)==null?void 0:S.querySelector(v))||null},querySelectorAll:v=>{var S;return((S=h.current)==null?void 0:S.querySelectorAll(v))||null}});return pe.useImperativeHandle(a,()=>y.current,[]),pe.useEffect(()=>{const v=document.getElementById(QU);if(v?s.current=v:s.current&&(s.current.id=QU),s.current&&(s.current.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;"),s.current){if(s.current.shadowRoot){h.current=s.current.shadowRoot;const E=h.current.querySelector(`#${KU}`);E&&d(E);return}const S=s.current.attachShadow({mode:"open"});if(h.current=S,t){const E=document.createElement("style");E.textContent=t,S.appendChild(E)}const x=document.createElement("div");x.id=KU,x.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;",S.appendChild(x),d(x),r&&r(S,x)}},[t,r]),pe.useEffect(()=>(u&&!m.current&&(m.current=Voe.createRoot(u)),m.current&&u&&m.current.render(q.jsx(me.StyleSheetManager,{target:u,children:q.jsx(q8,{value:y.current,children:e})})),()=>{m.current&&m.current.unmount()}),[u,e]),q.jsx("div",{ref:s,style:n})});class h2{isSupported(){return xb.detect()===this.platform}createSuccessResult(t,n){return{success:!0,data:t,message:n}}createErrorResult(t){return{success:!1,error:t}}}class Zoe extends h2{constructor(){super(...arguments);Ii(this,"platform",Xi.DEFAULT)}async fetchCart(){return console.log("DefaultCartAdapter: fetchCart called"),this.createSuccessResult({items:[],total:0,itemCount:0,currency:"USD",token:"default-token"},"Default cart fetched")}async addToCart(n,r=1,a){return console.log("DefaultCartAdapter: addToCart called",{variantId:n,quantity:r,properties:a}),this.createSuccessResult(void 0,"Item added to cart (mock)")}async removeFromCart(n){return console.log("DefaultCartAdapter: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("DefaultCartAdapter: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("DefaultCartAdapter: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=n.replace(/^https?:\/\//,"");return console.log("DefaultCartAdapter: generateCartUrl called",{domain:n,sanitizedDomain:r}),`https://${r}/cart`}generateProductUrl(n,r){if(r.handle){const a=new URL(`https://${n}/products/${r.handle}`);return a.searchParams.append("variant",r.product_id),zh(a.toString())}else return zh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}class Qoe extends h2{constructor(){var n,r;super();Ii(this,"platform",Xi.SHOPIFY);Ii(this,"cartEndpoint");Ii(this,"localCartKey","debales_track_cart");this.cartEndpoint=((r=(n=window.Shopify)==null?void 0:n.routes)==null?void 0:r.root)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:r.id,variant_id:r.variant_id,quantity:r.quantity,title:r.title,price:r.price,properties:r.properties})),total:n.total_price/100,itemCount:n.item_count,currency:n.currency,token:n.token.split("?")[0]}}generateProductUrl(n,r){const a=kE(n);if(!a.isValid)return"";if(r.handle){const s=new URL(`/products/${r.handle}`,a.url);return s.searchParams.append("variant",r.product_id),zh(s.toString())}else return zh(r.link)}updateTrackCart({cartToken:n,sessionId:r=Vi()}){localStorage.setItem(this.localCartKey,JSON.stringify({sessionId:r,cartToken:n}))}async fetchCart(){try{const n=await fetch(`${this.cartEndpoint}cart.js`),r=await n.json();if(!n.ok){const s=r;return this.createErrorResult(s.description||`Failed to fetch cart: ${n.status}`)}const a=r;return this.createSuccessResult(this.normalizeCartData(a),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1,a){try{const s=await fetch(`${this.cartEndpoint}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:n,quantity:r,properties:a}],attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:Vi(),dbls_method:"add_to_cart"}})}),u=await s.json();if(!s.ok){const d=u;return this.createErrorResult(d.description||`Failed to add item to cart: ${s.status}`)}return this.fetchCart().then(d=>{d.success&&this.updateTrackCart({cartToken:d==null?void 0:d.data.token})}),this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(s){return this.createErrorResult(s instanceof Error?`Error adding to cart: ${s.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return this.updateQuantity({id:n,quantity:0})}async updateQuantity(n){try{const r=await fetch(`${this.cartEndpoint}cart/change.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:n.id,quantity:n.quantity})}),a=await r.json();if(!r.ok){const s=a;return this.createErrorResult(s.description||`Failed to update item quantity: ${r.status}`)}return this.fetchCart().then(s=>{s.success&&this.updateTrackCart({cartToken:s==null?void 0:s.data.token})}),this.createSuccessResult(void 0,n.quantity===0?"Item removed from cart":`Quantity updated to ${n.quantity}`)}catch(r){return this.createErrorResult(r instanceof Error?`Error updating quantity: ${r.message}`:"Unknown error occurred while updating quantity")}}async clearCart(){try{const n=await fetch(`${this.cartEndpoint}cart/clear.js`,{method:"POST"});if(!n.ok){const r=await n.json();return this.createErrorResult(r.description||`Failed to clear cart: ${n.status}`)}return this.createSuccessResult(void 0,"Cart cleared successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error clearing cart: ${n.message}`:"Unknown error occurred while clearing cart")}}async addCartAttributes(n={}){try{const r=await fetch(`${this.cartEndpoint}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:Vi(),...n}})});if(!r.ok){const a=await r.json();return this.createErrorResult(a.description||`Failed to update cart attributes: ${r.status}`)}return this.createSuccessResult(void 0,"Cart attributes updated successfully")}catch(r){return this.createErrorResult(r instanceof Error?`Error updating cart attributes: ${r.message}`:"Unknown error occurred while updating cart attributes")}}generateCartUrl(n){const r=kE(n);if(!r.isValid)return"";const a=new URL("/cart",r.url);return a.searchParams.append("ref",`debales-ai-${new Date().toISOString()}`),a.searchParams.append("attributes[from]","debales-ai-chatbot"),a.searchParams.append("attributes[through]","add-to-cart"),a.searchParams.append("attributes[dbls_session_id]",Vi()),a.searchParams.append("timestamp",Date.now().toString()),zh(a.toString())}}class Koe extends h2{constructor(){var n,r;super();Ii(this,"platform",Xi.MAGENTO);Ii(this,"checkoutEndpoint");Ii(this,"baseUrl");this.checkoutEndpoint=((n=window.checkout)==null?void 0:n.checkoutUrl)||"/",this.baseUrl=((r=window.checkout)==null?void 0:r.baseUrl)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:parseInt(r.item_id),variant_id:parseInt(r.product_id),quantity:r.qty,title:r.product_name,price:r.product_price_value,properties:{name:r.product_name}})),total:parseFloat(n.subtotalAmount),itemCount:n.summary_count,currency:"USD",token:n.data_id.toString()}}async fetchCart(){try{const n=await fetch(`${this.baseUrl}customer/section/load/?sections=cart&update_section_id=false`),r=await n.json();if(!n.ok)return this.createErrorResult(`Failed to fetch cart: ${n.status}`);const a=r.cart;return this.createSuccessResult(this.normalizeCartData(a),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1){var a;try{const s=(a=document.querySelector('input[name="form_key"]'))==null?void 0:a.value;if(!s)return this.createErrorResult("Form key not found");const u=await fetch(`${this.checkoutEndpoint}cart/add`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:new URLSearchParams({product:n,qty:r.toString(),form_key:s})});if(!u.ok)return this.createErrorResult(`Failed to add item to cart: ${u.status}`);try{window.require(["Magento_Customer/js/customer-data"],d=>d.reload(["cart"],!0))}catch(d){console.warn("Failed to reload cart data:",d)}return this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(s){return this.createErrorResult(s instanceof Error?`Error adding to cart: ${s.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return console.log("MethodNotImplemented: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("MethodNotImplemented: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("MethodNotImplemented: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=new URL(`https://${n}/checkout/cart?ref=debales-ai-${new Date().toISOString()}&attributes[from]=debales-ai-chatbot&attributes[through]=add-to-cart`);return r.searchParams.append("timestamp",Date.now().toString()),r.toString()}generateProductUrl(n,r){const a=kE(n);if(!a.isValid)return"";if(r.handle){const s=new URL(`/${r.handle}.html`,a.url);return zh(s.toString())}else return zh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}const Hh=class Hh{constructor(){Ii(this,"adapterCache");this.adapterCache=new Map}static getInstance(){return Hh.instance||(Hh.instance=new Hh),Hh.instance}getAdapter(t){const n=t||xb.detect(),r=this.adapterCache.get(n);if(r)return r;let a;switch(n){case Xi.SHOPIFY:a=new Qoe;break;case Xi.MAGENTO:a=new Koe;break;default:console.warn(`No specific adapter found for platform ${n}, using default adapter`),a=new Zoe}return this.adapterCache.set(n,a),a}clearCache(){this.adapterCache.clear()}};Ii(Hh,"instance");let p2=Hh;const Xoe=({adapter:e,children:t,autoFetch:n=!0})=>{const[r,a]=pe.useState(!1),[s,u]=pe.useState(null),[d,h]=pe.useState(null),m=pe.useCallback(async()=>{try{a(!0),u(null);const M=await e.fetchCart();M.success?h(M.data):u(M.error)}catch(M){u(M instanceof Error?M.message:"Failed to fetch cart")}finally{a(!1)}},[e]),y=async(M,D,$)=>{try{u(null);const U=await e.addToCart(M,D,$);return U.success&&await m(),U}catch(U){return{success:!1,error:U instanceof Error?U.message:"Failed to add item to cart"}}},v=async M=>{try{u(null);const D=await e.removeFromCart(M);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to remove item from cart"}}},S=async M=>{try{u(null);const D=await e.updateQuantity(M);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to update quantity"}}},x=async()=>{try{u(null);const M=await e.clearCart();return M.success&&await m(),M}catch(M){return{success:!1,error:M instanceof Error?M.message:"Failed to clear cart"}}},E=M=>e.generateCartUrl(M),R=(M,D)=>e.generateProductUrl(M,D),T=async M=>e.addCartAttributes(M);pe.useEffect(()=>{n&&m()},[n,m]);const A={isLoading:r,error:s,cart:d,fetchCart:m,addToCart:y,removeFromCart:v,updateQuantity:S,clearCart:x,generateCartUrl:E,generateProductUrl:R,addCartAttributes:T};return q.jsx(QN.Provider,{value:A,children:t})},lu=Object.create(null);lu.open="0",lu.close="1",lu.ping="2",lu.pong="3",lu.message="4",lu.upgrade="5",lu.noop="6";const ME=Object.create(null);Object.keys(lu).forEach(e=>{ME[lu[e]]=e});const g2={type:"error",data:"parser error"},XU=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",WU=typeof ArrayBuffer=="function",JU=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,m2=({type:e,data:t},n,r)=>XU&&t instanceof Blob?n?r(t):ez(t,r):WU&&(t instanceof ArrayBuffer||JU(t))?n?r(t):ez(new Blob([t]),r):r(lu[e]+(t||"")),ez=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function tz(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let v2;function Woe(e,t){if(XU&&e.data instanceof Blob)return e.data.arrayBuffer().then(tz).then(t);if(WU&&(e.data instanceof ArrayBuffer||JU(e.data)))return t(tz(e.data));m2(e,!1,n=>{v2||(v2=new TextEncoder),t(v2.encode(n))})}const nz="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ib=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<nz.length;e++)Ib[nz.charCodeAt(e)]=e;const Joe=e=>{let t=e.length*.75,n=e.length,r,a=0,s,u,d,h;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const m=new ArrayBuffer(t),y=new Uint8Array(m);for(r=0;r<n;r+=4)s=Ib[e.charCodeAt(r)],u=Ib[e.charCodeAt(r+1)],d=Ib[e.charCodeAt(r+2)],h=Ib[e.charCodeAt(r+3)],y[a++]=s<<2|u>>4,y[a++]=(u&15)<<4|d>>2,y[a++]=(d&3)<<6|h&63;return m},ese=typeof ArrayBuffer=="function",y2=(e,t)=>{if(typeof e!="string")return{type:"message",data:rz(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:tse(e.substring(1),t)}:ME[n]?e.length>1?{type:ME[n],data:e.substring(1)}:{type:ME[n]}:g2},tse=(e,t)=>{if(ese){const n=Joe(e);return rz(n,t)}else return{base64:!0,data:e}},rz=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},iz="",nse=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((s,u)=>{m2(s,!1,d=>{r[u]=d,++a===n&&t(r.join(iz))})})},rse=(e,t)=>{const n=e.split(iz),r=[];for(let a=0;a<n.length;a++){const s=y2(n[a],t);if(r.push(s),s.type==="error")break}return r};function ise(){return new TransformStream({transform(e,t){Woe(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const s=new DataView(a.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{a=new Uint8Array(9);const s=new DataView(a.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let b2;function DE(e){return e.reduce((t,n)=>t+n.length,0)}function IE(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function ase(e,t){b2||(b2=new TextDecoder);const n=[];let r=0,a=-1,s=!1;return new TransformStream({transform(u,d){for(n.push(u);;){if(r===0){if(DE(n)<1)break;const h=IE(n,1);s=(h[0]&128)===128,a=h[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(DE(n)<2)break;const h=IE(n,2);a=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(DE(n)<8)break;const h=IE(n,8),m=new DataView(h.buffer,h.byteOffset,h.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){d.enqueue(g2);break}a=y*Math.pow(2,32)+m.getUint32(4),r=3}else{if(DE(n)<a)break;const h=IE(n,a);d.enqueue(y2(s?h:b2.decode(h),t)),r=0}if(a===0||a>e){d.enqueue(g2);break}}}})}const az=4;function ui(e){if(e)return ose(e)}function ose(e){for(var t in ui.prototype)e[t]=ui.prototype[t];return e}ui.prototype.on=ui.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},ui.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},ui.prototype.off=ui.prototype.removeListener=ui.prototype.removeAllListeners=ui.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this},ui.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this},ui.prototype.emitReserved=ui.prototype.emit,ui.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},ui.prototype.hasListeners=function(e){return!!this.listeners(e).length};const LE=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),gs=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),sse="arraybuffer";function xue(){}function oz(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const lse=gs.setTimeout,use=gs.clearTimeout;function NE(e,t){t.useNativeTimers?(e.setTimeoutFn=lse.bind(gs),e.clearTimeoutFn=use.bind(gs)):(e.setTimeoutFn=gs.setTimeout.bind(gs),e.clearTimeoutFn=gs.clearTimeout.bind(gs))}const cse=1.33;function fse(e){return typeof e=="string"?dse(e):Math.ceil((e.byteLength||e.size)*cse)}function dse(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function sz(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function hse(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function pse(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let s=n[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}class gse extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class _2 extends ui{constructor(t){super(),this.writable=!1,NE(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new gse(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=y2(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=hse(t);return n.length?"?"+n:""}}class mse extends _2{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};rse(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,nse(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=sz()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let lz=!1;try{lz=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const vse=lz;function yse(){}class bse extends mse{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,s)=>{this.onError("xhr post error",a,s)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class uu extends ui{constructor(t,n,r){super(),this.createRequest=t,NE(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=oz(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=uu.requestsCount++,uu.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=yse,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete uu.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(uu.requestsCount=0,uu.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",uz);else if(typeof addEventListener=="function"){const e="onpagehide"in gs?"pagehide":"unload";addEventListener(e,uz,!1)}}function uz(){for(let e in uu.requests)uu.requests.hasOwnProperty(e)&&uu.requests[e].abort()}const _se=function(){const e=cz({xdomain:!1});return e&&e.responseType!==null}();class Sse extends bse{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=_se&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new uu(cz,this.uri(),t)}}function cz(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||vse))return new XMLHttpRequest}catch{}if(!t)try{return new gs[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const fz=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class wse extends _2{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=fz?{}:oz(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;m2(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}a&&LE(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=sz()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const S2=gs.WebSocket||gs.MozWebSocket;class xse extends wse{createSocket(t,n,r){return fz?new S2(t,n,r):n?new S2(t,n):new S2(t)}doWrite(t,n){this.ws.send(n)}}class Cse extends _2{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=ase(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=ise();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const s=()=>{r.read().then(({done:d,value:h})=>{d||(this.onPacket(h),s())}).catch(d=>{})};s();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this._writer.write(u).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&LE(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Ese={websocket:xse,webtransport:Cse,polling:Sse},Ase=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Tse=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function w2(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=Ase.exec(e||""),s={},u=14;for(;u--;)s[Tse[u]]=a[u]||"";return n!=-1&&r!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=kse(s,s.path),s.queryKey=Rse(s,s.query),s}function kse(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Rse(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,s){a&&(n[a]=s)}),n}const x2=typeof addEventListener=="function"&&typeof removeEventListener=="function",$E=[];x2&&addEventListener("offline",()=>{$E.forEach(e=>e())},!1);class Wf extends ui{constructor(t,n){if(super(),this.binaryType=sse,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=w2(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=w2(n.host).host);NE(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=pse(this.opts.query)),x2&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},$E.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=az,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Wf.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Wf.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=fse(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,LE(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const s={type:t,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Wf.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),x2&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=$E.indexOf(this._offlineEventListener);r!==-1&&$E.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Wf.protocol=az;class Ose extends Wf{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Wf.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",v=>{if(!r)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Wf.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(y(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=n.name,this.emitReserved("upgradeError",S)}}))};function s(){r||(r=!0,y(),n.close(),n=null)}const u=v=>{const S=new Error("probe error: "+v);S.transport=n.name,s(),this.emitReserved("upgradeError",S)};function d(){u("transport closed")}function h(){u("socket closed")}function m(v){n&&v.name!==n.name&&s()}const y=()=>{n.removeListener("open",a),n.removeListener("error",u),n.removeListener("close",d),this.off("close",h),this.off("upgrading",m)};n.once("open",a),n.once("error",u),n.once("close",d),this.once("close",h),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let Mse=class extends Ose{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>Ese[a]).filter(a=>!!a)),super(t,r)}};function Dse(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=w2(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+t,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}const Ise=typeof ArrayBuffer=="function",Lse=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,dz=Object.prototype.toString,Nse=typeof Blob=="function"||typeof Blob<"u"&&dz.call(Blob)==="[object BlobConstructor]",$se=typeof File=="function"||typeof File<"u"&&dz.call(File)==="[object FileConstructor]";function C2(e){return Ise&&(e instanceof ArrayBuffer||Lse(e))||Nse&&e instanceof Blob||$se&&e instanceof File}function BE(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(BE(e[n]))return!0;return!1}if(C2(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return BE(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&BE(e[n]))return!0;return!1}function Bse(e){const t=[],n=e.data,r=e;return r.data=E2(n,t),r.attachments=t.length,{packet:r,buffers:t}}function E2(e,t){if(!e)return e;if(C2(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=E2(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=E2(e[r],t));return n}return e}function Use(e,t){return e.data=A2(e.data,t),delete e.attachments,e}function A2(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=A2(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=A2(e[n],t));return e}const zse=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Hse=5;var An;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(An||(An={}));class Pse{constructor(t){this.replacer=t}encode(t){return(t.type===An.EVENT||t.type===An.ACK)&&BE(t)?this.encodeAsBinary({type:t.type===An.EVENT?An.BINARY_EVENT:An.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===An.BINARY_EVENT||t.type===An.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=Bse(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function hz(e){return Object.prototype.toString.call(e)==="[object Object]"}class T2 extends ui{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===An.BINARY_EVENT;r||n.type===An.BINARY_ACK?(n.type=r?An.EVENT:An.ACK,this.reconstructor=new qse(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(C2(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(An[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===An.BINARY_EVENT||r.type===An.BINARY_ACK){const s=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const u=t.substring(s,n);if(u!=Number(u)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(u)}if(t.charAt(n+1)==="/"){const s=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(s,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const s=n+1;for(;++n;){const u=t.charAt(n);if(u==null||Number(u)!=u){--n;break}if(n===t.length)break}r.id=Number(t.substring(s,n+1))}if(t.charAt(++n)){const s=this.tryParse(t.substr(n));if(T2.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case An.CONNECT:return hz(n);case An.DISCONNECT:return n===void 0;case An.CONNECT_ERROR:return typeof n=="string"||hz(n);case An.EVENT:case An.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&zse.indexOf(n[0])===-1);case An.ACK:case An.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qse{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=Use(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Fse=Object.freeze(Object.defineProperty({__proto__:null,Decoder:T2,Encoder:Pse,get PacketType(){return An},protocol:Hse},Symbol.toStringTag,{value:"Module"}));function bl(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const jse=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class pz extends ui{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[bl(t,"open",this.onopen.bind(this)),bl(t,"packet",this.onpacket.bind(this)),bl(t,"error",this.onerror.bind(this)),bl(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,s;if(jse.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const u={type:An.EVENT,data:n};if(u.options={},u.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const y=this.ids++,v=n.pop();this._registerAckCallback(y,v),u.id=y}const d=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,h=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!d||(h?(this.notifyOutgoingListeners(u),this.packet(u)):this.sendBuffer.push(u)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const s=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let d=0;d<this.sendBuffer.length;d++)this.sendBuffer[d].id===t&&this.sendBuffer.splice(d,1);n.call(this,new Error("operation has timed out"))},a),u=(...d)=>{this.io.clearTimeoutFn(s),n.apply(this,d)};u.withError=!0,this.acks[t]=u}emitWithAck(t,...n){return new Promise((r,a)=>{const s=(u,d)=>u?a(u):r(d);s.withError=!0,n.push(s),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...s)=>r!==this._queue[0]?void 0:(a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:An.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case An.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case An.EVENT:case An.BINARY_EVENT:this.onevent(t);break;case An.ACK:case An.BINARY_ACK:this.onack(t);break;case An.DISCONNECT:this.ondisconnect();break;case An.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:An.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:An.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function $m(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}$m.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0},$m.prototype.reset=function(){this.attempts=0},$m.prototype.setMin=function(e){this.ms=e},$m.prototype.setMax=function(e){this.max=e},$m.prototype.setJitter=function(e){this.jitter=e};class k2 extends ui{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,NE(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new $m({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||Fse;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Mse(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=bl(n,"open",function(){r.onopen(),t&&t()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),t?t(d):this.maybeReconnectOnOpen()},u=bl(n,"error",s);if(this._timeout!==!1){const d=this._timeout,h=this.setTimeoutFn(()=>{a(),s(new Error("timeout")),n.close()},d);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(a),this.subs.push(u),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(bl(t,"ping",this.onping.bind(this)),bl(t,"data",this.ondata.bind(this)),bl(t,"error",this.onerror.bind(this)),bl(t,"close",this.onclose.bind(this)),bl(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){LE(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new pz(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Lb={};function UE(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=Dse(e,t.path||"/socket.io"),r=n.source,a=n.id,s=n.path,u=Lb[a]&&s in Lb[a].nsps,d=t.forceNew||t["force new connection"]||t.multiplex===!1||u;let h;return d?h=new k2(r,t):(Lb[a]||(Lb[a]=new k2(r,t)),h=Lb[a]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}Object.assign(UE,{Manager:k2,Socket:pz,io:UE,connect:UE});const Ph=class Ph{constructor(){Ii(this,"socket",null);Ii(this,"isConnected",!1);Ii(this,"eventListeners",new Map)}static getInstance(){return Ph.instance||(Ph.instance=new Ph),Ph.instance}connect(t){return this.socket?this.socket:(this.socket=UE(`${uJ}${t}`,{transports:["websocket"]}),this.socket.on("connect",()=>{this.isConnected=!0,this.emitEvent("connect")}),this.socket.on("disconnect",()=>{this.isConnected=!1,this.emitEvent("disconnect")}),this.socket)}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null,this.isConnected=!1,this.eventListeners.clear())}getSocket(){return this.socket}getIsConnected(){return this.isConnected}on(t,n){var r,a;this.eventListeners.has(t)||this.eventListeners.set(t,[]),(r=this.eventListeners.get(t))==null||r.push(n),(a=this.socket)==null||a.on(t,n)}off(t,n){var a;const r=this.eventListeners.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1),(a=this.socket)==null||a.off(t,n)}}emit(t,...n){var r;(r=this.socket)==null||r.emit(t,...n)}emitEvent(t,...n){const r=this.eventListeners.get(t);r&&r.forEach(a=>a(...n))}};Ii(Ph,"instance");let R2=Ph;const cu=R2.getInstance();var Gse={MESSAGE:"MESSAGE"},Vse={USER:"USER"};function zE(e,t){window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:t}))}const gz=(e,t)=>{const n=JSON.stringify(t);window.localStorage.setItem(e,n),zE(e,n)},Yse=e=>{window.localStorage.removeItem(e),zE(e,null)},mz=e=>window.localStorage.getItem(e),Zse=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Qse=()=>{throw Error("useLocalStorage is a client-only hook")};function Kse(e,t){const n=()=>mz(e),r=gn.useSyncExternalStore(Zse,n,Qse),a=gn.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Yse(e):gz(e,u)}catch(u){console.warn(u)}},[e,r]);return gn.useEffect(()=>{mz(e)===null&&gz(e,t)},[e,t]),[r?JSON.parse(r):t,a]}const vz=(e,t)=>{const n=JSON.stringify(t);window.sessionStorage.setItem(e,n),zE(e,n)},Xse=e=>{window.sessionStorage.removeItem(e),zE(e,null)},yz=e=>window.sessionStorage.getItem(e),Wse=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Jse=()=>{throw Error("useSessionStorage is a client-only hook")};function ele(e,t){const n=()=>yz(e),r=gn.useSyncExternalStore(Wse,n,Jse),a=gn.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Xse(e):vz(e,u)}catch(u){console.warn(u)}},[e,r]);return gn.useEffect(()=>{yz(e)===null&&vz(e,t)},[e,t]),[r?JSON.parse(r):t,a]}const tle=({children:e,nameSpace:t})=>{const[n,r]=pe.useState(""),[a,s]=pe.useState([]),[u,d]=pe.useState(!1),[h,m]=pe.useState(!1),[y,v]=pe.useState([]),[S,x]=pe.useState(!1),[E,R]=pe.useState(!1),[T,A]=pe.useState([]),[M,D]=Kse(Zi(Fi.USER_INFO),null),[$,U]=ele(Zi(Fi.IS_FORM_CLOSED_BY_USER),!1),[P,Z]=pe.useState(null),X=YM("web-socket"),[K,G]=pe.useState([]),[ne,se]=pe.useState(null),[be,ae]=pe.useState(!1),[ve,Y]=pe.useState(sessionStorage.getItem(Zi(Fi.LAST_SHOWN_MESSAGE_ID,{botId:t}))),te=vJ(),fe=Vi(),[Ue,B]=pe.useState(null),[$e,ke]=pe.useState(null);pe.useEffect(()=>{if(X){const nt=cu.connect("/api/v1/chat");se(nt);const Pe=()=>{console.debug("connected to websocket"),ae(!0)},lt=()=>{console.debug("disconnected from websocket"),ae(!1)},gt=ht=>{console.debug("response from websocket",ht);const Ct=ht.conversationId??crypto.randomUUID().toString();Y(Ct),ht.Variants_quantity&&A(Q=>[...Q,...ht.Variants_quantity]);const V=[...a,{text:ht.response,products:ht.products,conversationId:Ct,rating:"neutral",leading_queries:ht.leading_queries,collections:ht.collections,variants:ht.variants,shop:ht.shop,Variants_quantity:ht.Variants_quantity,monthlyChatLimitReached:ht.monthlyChatLimitReached,isBot:!0}];s(V),j(V),v(Q=>[...Q,[a[a.length-1].text,ht.response]]),m(!1)},$t=ht=>{if(ht.event==="error"){const Ct={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},V=[...a,Ct];s(V),j(V),m(!1)}};return cu.on("connect",Pe),cu.on("disconnect",lt),cu.on("response",gt),cu.on("system",$t),()=>{cu.off("connect",Pe),cu.off("disconnect",lt),cu.off("response",gt),cu.off("system",$t)}}},[X,a]);const j=nt=>{sessionStorage.setItem(Zi(Fi.CHAT_HISTORY,{botId:window.DebalesChat.projectId}),JSON.stringify(nt))},Ge=()=>{const nt=sessionStorage.getItem(Zi(Fi.CHAT_HISTORY,{botId:window.DebalesChat.projectId}));return nt?JSON.parse(nt):[]},it=pe.useCallback(async()=>{if(t)try{d(!0);const nt=await fetch(`${iu}/api/wordpress/UiData?value=${t}`),Pe=await nt.json();if(!nt.ok)throw new Error("failed to fetch data"+Pe.error);const lt=document.getElementById("debales-ai-assistant");lt&&(lt.style.zIndex=String(Pe.zIndex??2031483602)),ke(Pe),Pe!=null&&Pe.shopifyShopDomain&&Zte(Pe.shopifyShopDomain).then($t=>{B($t)}),G(Pe.suggestedQuestions);const gt=Ge();if(gt.length>0)s(gt);else{const $t={text:Pe.initialMessage||"Hi, I am an AI Assistant. How can I help you?",isBot:!0};s([$t])}}catch(nt){console.error(nt)}finally{d(!1)}},[t]);pe.useEffect(()=>{it()},[it]);const ze=pe.useMemo(()=>{var nt;return!!(!$&&((nt=$e==null?void 0:$e.pluginConfig)!=null&&nt.collectedUserInfo)&&($e.pluginConfig.collectedUserInfo.name||$e.pluginConfig.collectedUserInfo.email||$e.pluginConfig.collectedUserInfo.phone)&&!M)},[$e,M,$]),Nt=pe.useCallback(async(nt,Pe,lt,gt,$t,ht)=>{if(!nt||nt.trim()===""||h&&!lt)return;let Ct=[...a];gt?gt&&a.length<=2?(x(!0),Ct=[]):x(!1):(Ct.push({text:nt,isBot:!1}),x(!1));const V=Vi();m(!0);try{s(Ct),j(Ct);const Q=await fetch(`${iu}/api/wordpress/ChatWithBot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:V,userMessage:nt,nameSpace:t,chat_history:y,leading_queries:$t,answer:Pe,products:lt,userInfo:JSON.stringify(M),anonymousUserId:te,distinctId:Ah.getDistinctId(),timestamp:new Date().toISOString(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,followUpQuestion:ht})});if(!Q.ok)throw new Error("Network response was not ok");const oe=await Q.json(),De=oe.conversationId??crypto.randomUUID().toString();Y(De),oe.Variants_quantity&&A(He=>[...He,...oe.Variants_quantity]);const Ne=[...Ct,{text:oe.response,products:oe.products,conversationId:De,rating:"neutral",leading_queries:oe.leading_queries,collections:oe.collections,variants:oe.variants,shop:oe.shop,Variants_quantity:oe.Variants_quantity,monthlyChatLimitReached:oe.monthlyChatLimitReached,isBot:!0}];s(Ne),j(Ne),v(He=>[...He,[nt,oe.response]])}catch(Q){console.error(Q);const oe={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},De=[...Ct,oe];gt||(s(De),j(De))}finally{m(!1)}},[a,h,y,t,te,M]),dt=pe.useCallback(nt=>{$e&&ke(Pe=>Pe?{...Pe,mobileDisplayMode:nt}:null)},[$e]),Rt=pe.useCallback(async(nt,Pe,lt,gt,$t,ht)=>{if(!nt||nt.trim()===""||h&&!lt)return;let Ct=[...a];if(gt?gt&&a.length<=2?(x(!0),Ct=[]):x(!1):(Ct.push({text:nt,isBot:!1}),x(!1)),m(!0),s(Ct),j(Ct),ne&&be){const V={type:Gse.MESSAGE,role:Vse.USER,query:nt,nameSpace:t,leadingQueries:$t,answer:Pe,products:lt,userInfo:M,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),sessionId:fe,anonymousUserId:te,distinctId:Ah.getDistinctId(),followUpQuestion:ht};cu.emit("chat",V)}else Nt(nt,Pe,lt,gt,$t,ht)},[a,h,t,te,ne,be,fe,Nt,M]),Dt={sessionId:fe,messages:a,isLoading:u,isMessageLoading:h,isKlaviyoMessage:S,showUserInfoModel:E,pendingBulkItems:T,lastedBotmessageId:ve,uiData:$e,storeMetaData:Ue,suggestedQuestions:K,isUserInfoNeeded:ze,input:n,pendingQuestion:P,userInfo:M,isFormClosedByUser:$,onSendMessage:X?Rt:Nt,setMessages:s,setIsLoading:d,setIsMessageLoading:m,setIsKlaviyoMessage:x,setShowUserInfoModel:R,setPendingBulkItems:A,setLastedBotmessageId:Y,fetchUiInfo:it,changeDisplayModel:dt,saveConversation:j,loadConversation:Ge,setSuggestedQuestions:G,setUserInfo:D,setInput:r,setPendingQuestion:Z,setIsFormClosedByUser:U};return q.jsx(F8.Provider,{value:Dt,children:e})};function nle(e){const t=p2.getInstance().getAdapter();return q.jsx(tle,{nameSpace:e.botId,children:q.jsx(zte,{apiKey:cJ,options:{capture_pageview:e.botId!=="burgerbaeclothing",capture_pageleave:e.botId!=="burgerbaeclothing",api_host:iu+"/ingest",ui_host:"https://us.posthog.com",loaded:n=>{n.register({platform:xb.detect(),project:e.botId,sessionId:Vi()}),n.group("project",e.botId,{platform:xb.detect()});const r=Uf();r&&r.email&&!n._isIdentified()&&n.identify(r.email,{name:r.name,phone:r.phone,email:r.email,project:e.botId})},debug:!1},children:q.jsx(Xoe,{adapter:t,children:e.children})})})}function rle(e){return q.jsx(Yoe,{children:q.jsx(nle,{botId:e.botId,children:q.jsx(Hoe,{...e})})})}return rle});