@debales/ai 1.1.10-canary.0 → 1.1.10

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.
@@ -114,7 +114,7 @@ or you can use record.mirror to access the mirror instance during recording.`,TN
114
114
  `+x+"]":"["+w.join(",")+"]",u=x,y}for(m in E)$w.call(E,m)&&(y=r(m,E),y&&w.push(n(m)+(u?": ":":")+y));return y=w.length===0?"{}":u?"{"+w.join(",")+x+"}":"{"+w.join(",")+"}",u=x,y}};return r("",{"":t})}}(),z.JSONDecode=function(){var e,t,n={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
115
115
  `,r:"\r",t:" "},r,o=function(w){var E=new SyntaxError(w);throw E.at=e,E.text=r,E},s=function(w){return w&&w!==t&&o("Expected '"+w+"' instead of '"+t+"'"),t=r.charAt(e),e+=1,t},u=function(){var w,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(w=+E,!isFinite(w))o("Bad number");else return w},d=function(){var w,E,M="",A;if(t==='"')for(;s();){if(t==='"')return s(),M;if(t==="\\")if(s(),t==="u"){for(A=0,E=0;E<4&&(w=parseInt(s(),16),!!isFinite(w));E+=1)A=A*16+w;M+=String.fromCharCode(A)}else if(typeof n[t]=="string")M+=n[t];else break;else M+=t}o("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}o('Unexpected "'+t+'"')},y,v=function(){var w=[];if(t==="["){if(s("["),h(),t==="]")return s("]"),w;for(;t;){if(w.push(y()),h(),t==="]")return s("]"),w;s(","),h()}}o("Bad array")},x=function(){var w,E={};if(t==="{"){if(s("{"),h(),t==="}")return s("}"),E;for(;t;){if(w=d(),h(),s(":"),Object.hasOwnProperty.call(E,w)&&o('Duplicate key "'+w+'"'),E[w]=y(),h(),t==="}")return s("}"),E;s(","),h()}}o("Bad object")};return y=function(){switch(h(),t){case"{":return x();case"[":return v();case'"':return d();case"-":return u();default:return t>="0"&&t<="9"?u():m()}},function(w){var E;return r=w,e=0,t=" ",E=y(),h(),t&&o("Syntax error"),E}}(),z.base64Encode=function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n,r,o,s,u,d,h,m,y=0,v=0,x="",w=[];if(!e)return e;e=z.utf8Encode(e);do n=e.charCodeAt(y++),r=e.charCodeAt(y++),o=e.charCodeAt(y++),m=n<<16|r<<8|o,s=m>>18&63,u=m>>12&63,d=m>>6&63,h=m&63,w[v++]=t.charAt(s)+t.charAt(u)+t.charAt(d)+t.charAt(h);while(y<e.length);switch(x=w.join(""),e.length%3){case 1:x=x.slice(0,-2)+"==";break;case 2:x=x.slice(0,-1)+"=";break}return x},z.utf8Encode=function(e){e=(e+"").replace(/\r\n/g,`
116
116
  `).replace(/\r/g,`
117
- `);var t="",n,r,o=0,s;for(n=r=0,o=e.length,s=0;s<o;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},z.UUID=function(){try{return Rt.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]="-",z.map(e,function(r){return r.toString(16)}).join("")}};var m8=["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"];z.isBlockedUA=function(e){var t;for(e=e.toLowerCase(),t=0;t<m8.length;t++)if(e.indexOf(m8[t])!==-1)return!0;return!1},z.HTTPBuildQuery=function(e,t){var n,r,o=[];return z.isUndefined(t)&&(t="&"),z.each(e,function(s,u){n=encodeURIComponent(s.toString()),r=encodeURIComponent(u),o[o.length]=r+"="+n}),o.join(t)},z.getQueryParam=function(e,t){t=t.replace(/[[]/g,"\\[").replace(/[\]]/g,"\\]");var n="[\\?&]"+t+"=([^&#]*)",r=new RegExp(n),o=r.exec(e);if(o===null||o&&typeof o[1]!="string"&&o[1].length)return"";var s=o[1];try{s=decodeURIComponent(s)}catch{er.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},z.cookie={get:function(e){for(var t=e+"=",n=cr.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];o.charAt(0)==" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return decodeURIComponent(o.substring(t.length,o.length))}return null},parse:function(e){var t;try{t=z.JSONDecode(z.cookie.get(e))||{}}catch{}return t},set_seconds:function(e,t,n,r,o,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=b8(cr.location.hostname);d=y?"; domain=."+y:""}if(n){var v=new Date;v.setTime(v.getTime()+n*1e3),h="; expires="+v.toGMTString()}s&&(o=!0,m="; SameSite=None"),o&&(m+="; secure"),cr.cookie=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m},set:function(e,t,n,r,o,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=b8(cr.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&&(o=!0,m="; SameSite=None"),o&&(m+="; secure");var x=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m;return cr.cookie=x,x},remove:function(e,t,n){z.cookie.set(e,"",-1,t,!1,!1,n)}};var v8=function(e){var t=!0;try{var n="__mplss_"+jO(8),r="xyz";e.setItem(n,r),e.getItem(n)!==r&&(t=!1),e.removeItem(n)}catch{t=!1}return t},zO=null,_b=function(e,t){return zO!==null&&!t?zO:zO=v8(e||Rt.localStorage)},UO=null,bte=function(e,t){return UO!==null&&!t?UO:UO=v8(e||Rt.sessionStorage)};function y8(e,t,n){var r=function(o){er.error(t+" error: "+o)};return{is_supported:function(o){var s=n(e,o);return s||er.error(t+" unsupported"),s},error:r,get:function(o){try{return e.getItem(o)}catch(s){r(s)}return null},parse:function(o){try{return z.JSONDecode(e.getItem(o))||{}}catch{}return null},set:function(o,s){try{e.setItem(o,s)}catch(u){r(u)}},remove:function(o){try{e.removeItem(o)}catch(s){r(s)}}}}z.localStorage=y8(Rt.localStorage,"localStorage",_b),z.sessionStorage=y8(Rt.sessionStorage,"sessionStorage",bte),z.register_event=function(){var e=function(r,o,s,u,d){if(!r){er.error("No valid element provided to register_event");return}if(r.addEventListener&&!u)r.addEventListener(o,s,!!d);else{var h="on"+o,m=r[h];r[h]=t(r,s,m)}};function t(r,o,s){var u=function(d){if(d=d||n(Rt.event),!!d){var h=!0,m,y;return z.isFunction(s)&&(m=s(d)),y=o.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 _te=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');z.dom_query=function(){function e(o){return o.all?o.all:o.getElementsByTagName("*")}var t=/[\t\r\n]/g;function n(o,s){var u=" "+s+" ";return(" "+o.className+" ").replace(t," ").indexOf(u)>=0}function r(o){if(!cr.getElementsByTagName)return[];var s=o.split(" "),u,d,h,m,y,v,x,w,E,M,A=[cr];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 k=d[1],R=cr.getElementById(k);if(!R||h&&R.nodeName.toLowerCase()!=h)return[];A=[R];continue}if(u.indexOf(".")>-1){d=u.split("."),h=d[0];var D=d[1];for(h||(h="*"),m=[],y=0,x=0;x<A.length;x++)for(h=="*"?E=e(A[x]):E=A[x].getElementsByTagName(h),w=0;w<E.length;w++)m[y++]=E[w];for(A=[],M=0,x=0;x<m.length;x++)m[x].className&&z.isString(m[x].className)&&n(m[x],D)&&(A[M++]=m[x]);continue}var B=u.match(_te);if(B){h=B[1];var L=B[2],H=B[3],K=B[4];for(h||(h="*"),m=[],y=0,x=0;x<A.length;x++)for(h=="*"?E=e(A[x]):E=A[x].getElementsByTagName(h),w=0;w<E.length;w++)m[y++]=E[w];A=[],M=0;var ee;switch(H){case"=":ee=function(J){return J.getAttribute(L)==K};break;case"~":ee=function(J){return J.getAttribute(L).match(new RegExp("\\b"+K+"\\b"))};break;case"|":ee=function(J){return J.getAttribute(L).match(new RegExp("^"+K+"-?"))};break;case"^":ee=function(J){return J.getAttribute(L).indexOf(K)===0};break;case"$":ee=function(J){return J.getAttribute(L).lastIndexOf(K)==J.getAttribute(L).length-K.length};break;case"*":ee=function(J){return J.getAttribute(L).indexOf(K)>-1};break;default:ee=function(J){return J.getAttribute(L)}}for(A=[],M=0,x=0;x<m.length;x++)ee(m[x])&&(A[M++]=m[x]);continue}for(h=u,m=[],y=0,x=0;x<A.length;x++)for(E=A[x].getElementsByTagName(h),w=0;w<E.length;w++)m[y++]=E[w];A=m}return A}return function(o){return z.isElement(o)?[o]:z.isObject(o)&&!z.isUndefined(o.length)?o:r.call(this,o)}}();var xte=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","utm_id","utm_source_platform","utm_campaign_id","utm_creative_format","utm_marketing_tactic"],Ste=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","sccid","ttclid","twclid","wbraid"];z.info={campaignParams:function(e){var t="",n={};return z.each(xte,function(r){t=z.getQueryParam(cr.URL,r),t.length?n[r]=t:e!==void 0&&(n[r]=e)}),n},clickParams:function(){var e="",t={};return z.each(Ste,function(n){e=z.getQueryParam(cr.URL,n),e.length&&(t[n]=e)}),t},marketingParams:function(){return z.extend(z.info.campaignParams(),z.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=z.info.searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(t!==null){r.$search_engine=t;var o=z.getQueryParam(e,n);o.length&&(r.mp_keyword=o)}return r},browser:function(e,t,n){return t=t||"",n||z.includes(e," OPR/")?z.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":z.includes(e,"IEMobile")||z.includes(e,"WPDesktop")?"Internet Explorer Mobile":z.includes(e,"SamsungBrowser/")?"Samsung Internet":z.includes(e,"Edge")||z.includes(e,"Edg/")?"Microsoft Edge":z.includes(e,"FBIOS")?"Facebook Mobile":z.includes(e,"Chrome")?"Chrome":z.includes(e,"CriOS")?"Chrome iOS":z.includes(e,"UCWEB")||z.includes(e,"UCBrowser")?"UC Browser":z.includes(e,"FxiOS")?"Firefox iOS":z.includes(t,"Apple")?z.includes(e,"Mobile")?"Mobile Safari":"Safari":z.includes(e,"Android")?"Android Mobile":z.includes(e,"Konqueror")?"Konqueror":z.includes(e,"Firefox")?"Firefox":z.includes(e,"MSIE")||z.includes(e,"Trident/")?"Internet Explorer":z.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,n){var r=z.info.browser(e,t,n),o={"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=o[r];if(s===void 0)return null;var u=e.match(s);return u?parseFloat(u[u.length-2]):null},os:function(){var e=bc;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 Rt.location.href},properties:function(e){return typeof e!="object"&&(e={}),z.extend(z.strip_empty_properties({$os:z.info.os(),$browser:z.info.browser(bc,Jf.vendor,Lw),$referrer:cr.referrer,$referring_domain:z.info.referringDomain(cr.referrer),$device:z.info.device(bc)}),{$current_url:z.info.currentUrl(),$browser_version:z.info.browserVersion(bc,Jf.vendor,Lw),$screen_height:d8.height,$screen_width:d8.width,mp_lib:"web",$lib_version:Al.LIB_VERSION,$insert_id:jO(),time:z.timestamp()/1e3},z.strip_empty_properties(e))},people_properties:function(){return z.extend(z.strip_empty_properties({$os:z.info.os(),$browser:z.info.browser(bc,Jf.vendor,Lw)}),{$browser_version:z.info.browserVersion(bc,Jf.vendor,Lw)})},mpPageViewProperties:function(){return z.strip_empty_properties({current_page_title:cr.title,current_domain:Rt.location.hostname,current_url_path:Rt.location.pathname,current_url_protocol:Rt.location.protocol,current_url_search:Rt.location.search})}};var wte=function(e,t){var n=null,r=[];return function(o){var s=this;return r.push(o),n||(n=new ir(function(u){setTimeout(function(){var d=e.apply(s,[r]);n=null,r=[],u(d)},t)})),n}},jO=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},Cte=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,Ete=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,b8=function(e){var t=Ete,n=e.split("."),r=n[n.length-1];(r.length>4||r==="com"||r==="org")&&(t=Cte);var o=e.match(t);return o?o[0]:""},kte=function(){var e=Rt.navigator.onLine;return z.isUndefined(e)||e},ed=function(){},hm=null,Nw=null;typeof JSON<"u"&&(hm=JSON.stringify,Nw=JSON.parse),hm=hm||z.JSONEncode,Nw=Nw||z.JSONDecode,z.info=z.info,z.info.browser=z.info.browser,z.info.browserVersion=z.info.browserVersion,z.info.device=z.info.device,z.info.properties=z.info.properties,z.isBlockedUA=z.isBlockedUA,z.isEmptyObject=z.isEmptyObject,z.isObject=z.isObject,z.JSONDecode=z.JSONDecode,z.JSONEncode=z.JSONEncode,z.toArray=z.toArray,z.NPO=Xf;var Ate="mixpanelBrowserDb",_8="mixpanelRecordingEvents",HO="mixpanelRecordingRegistry",Tte=1,Mte=[_8,HO],pu=function(e){this.dbPromise=null,this.storeName=e};pu.prototype._openDb=function(){return new ir(function(e,t){var n=Rt.indexedDB.open(Ate,Tte);n.onerror=function(){t(n.error)},n.onsuccess=function(){e(n.result)},n.onupgradeneeded=function(r){var o=r.target.result;Mte.forEach(function(s){o.createObjectStore(s)})}})},pu.prototype.init=function(){return Rt.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof Rt.IDBDatabase?ir.resolve():ir.reject(e)})):ir.reject("indexedDB is not supported in this browser")},pu.prototype.makeTransaction=function(e,t){var n=this.storeName,r=function(o){return new ir(function(s,u){var d=o.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(o){return o&&o.name==="InvalidStateError"?(this.dbPromise=this._openDb(),this.dbPromise.then(r)):ir.reject(o)}).bind(this))},pu.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(n){n.put(t,e)})},pu.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},pu.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},pu.prototype.getAll=function(){var e;return this.makeTransaction("readonly",function(t){e=t.getAll()}).then(function(){return e.result})};var Ote="__mp_opt_in_out_";function Rte(e,t){w8(!0,e,t)}function Ite(e,t){w8(!1,e,t)}function Dte(e,t){return S8(e,t)==="1"}function x8(e,t){if(Lte(t))return er.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=S8(e,t)==="0";return n&&er.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),n}function td(e){return FO(e,function(t){return this.get_config(t)})}function nd(e){return FO(e,function(t){return this._get_config(t)})}function pm(e){return FO(e,function(t){return this._get_config(t)})}function $te(e,t){t=t||{},qO(t).remove(PO(e,t),!!t.crossSubdomainCookie,t.cookieDomain)}function qO(e){return e=e||{},e.persistenceType==="localStorage"?z.localStorage:z.cookie}function PO(e,t){return t=t||{},(t.persistencePrefix||Ote)+e}function S8(e,t){return qO(t).get(PO(e,t))}function Lte(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||Rt,n=t.navigator||{},r=!1;return z.each([n.doNotTrack,n.msDoNotTrack,t.doNotTrack],function(o){z.includes([!0,1,"1","yes"],o)&&(r=!0)}),r}function w8(e,t,n){if(!z.isString(t)||!t.length){er.error("gdpr."+(e?"optIn":"optOut")+" called with an invalid token");return}n=n||{},qO(n).set(PO(t,n),e?1:0,z.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 FO(e,t){return function(){var n=!1;try{var r=t.call(this,"token"),o=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=x8(r,{ignoreDnt:o,persistenceType:s,persistencePrefix:u,window:d}))}catch(m){er.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 Nte=dm("lock"),C8=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||Rt.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||ir};C8.prototype.withLock=function(e,t){var n=this.promiseImpl;return new n(z.bind(function(r,o){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",x=d+":Y",w=d+":Z",E=function(D){if(new Date().getTime()-u>m){Nte.error("Timeout waiting for mutex on "+d+"; clearing lock. ["+s+"]"),y.removeItem(w),y.removeItem(x),k();return}setTimeout(function(){try{D()}catch(B){o(B)}},h*(Math.random()+.1))},M=function(D,B){D()?B():E(function(){M(D,B)})},A=function(){var D=y.getItem(x);return D&&D!==s?!1:(y.setItem(x,s),y.getItem(x)===s?!0:(_b(y,!0)||o(new Error("localStorage support dropped while acquiring lock")),!1))},k=function(){y.setItem(v,s),M(A,function(){if(y.getItem(v)===s){R();return}E(function(){if(y.getItem(x)!==s){k();return}M(function(){return!y.getItem(w)},R)})})},R=function(){y.setItem(w,"1");var D=function(){y.removeItem(w),y.getItem(x)===s&&y.removeItem(x),y.getItem(v)===s&&y.removeItem(v)};e().then(function(B){D(),r(B)}).catch(function(B){D(),o(B)})};try{if(_b(y,!0))k();else throw new Error("localStorage support check failed")}catch(D){o(D)}},this))};var xb=function(e){this.storage=e||Rt.localStorage};xb.prototype.init=function(){return ir.resolve()},xb.prototype.setItem=function(e,t){return new ir(z.bind(function(n,r){try{this.storage.setItem(e,hm(t))}catch(o){r(o)}n()},this))},xb.prototype.getItem=function(e){return new ir(z.bind(function(t,n){var r;try{r=Nw(this.storage.getItem(e))}catch(o){n(o)}t(r)},this))},xb.prototype.removeItem=function(e){return new ir(z.bind(function(t,n){try{this.storage.removeItem(e)}catch(r){n(r)}t()},this))};var E8=dm("batch"),gu=function(e,t){t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new xb,this.lock=new C8(e,{storage:t.sharedLockStorage||Rt.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||z.bind(E8.error,E8),this.pid=t.pid||null,this.memQueue=[],this.initialized=!1,t.enqueueThrottleMs?this.enqueuePersisted=wte(z.bind(this._enqueuePersisted,this),t.enqueueThrottleMs):this.enqueuePersisted=z.bind(function(n){return this._enqueuePersisted([n])},this)};gu.prototype.ensureInit=function(){return this.initialized?ir.resolve():this.queueStorage.init().then(z.bind(function(){this.initialized=!0},this)).catch(z.bind(function(e){this.reportError("Error initializing queue persistence. Disabling persistence",e),this.initialized=!0,this.usePersistence=!1},this))},gu.prototype.enqueue=function(e,t){var n={id:jO(),flushAfter:new Date().getTime()+t*2,payload:e};return this.usePersistence?this.enqueuePersisted(n):(this.memQueue.push(n),ir.resolve(!0))},gu.prototype._enqueuePersisted=function(e){var t=z.bind(function(){return this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(n){return this.saveToStorage(n.concat(e))},this)).then(z.bind(function(n){return n&&(this.memQueue=this.memQueue.concat(e)),n},this)).catch(z.bind(function(n){return this.reportError("Error enqueueing items",n,e),!1},this))},this);return this.lock.withLock(t,this.pid).catch(z.bind(function(n){return this.reportError("Error acquiring storage lock",n),!1},this))},gu.prototype.fillBatch=function(e){var t=this.memQueue.slice(0,e);return this.usePersistence&&t.length<e?this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(n){if(n.length){var r={};z.each(t,function(u){r[u.id]=!0});for(var o=0;o<n.length;o++){var s=n[o];if(new Date().getTime()>s.flushAfter&&!r[s.id]&&(s.orphaned=!0,t.push(s),t.length>=e))break}}return t},this)):ir.resolve(t)};var k8=function(e,t){var n=[];return z.each(e,function(r){r.id&&!t[r.id]&&n.push(r)}),n};gu.prototype.removeItemsByID=function(e){var t={};if(z.each(e,function(r){t[r]=!0}),this.memQueue=k8(this.memQueue,t),this.usePersistence){var n=z.bind(function(){return this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(r){return r=k8(r,t),this.saveToStorage(r)},this)).then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(r){for(var o=0;o<r.length;o++){var s=r[o];if(s.id&&t[s.id])throw new Error("Item not removed from storage")}return!0},this)).catch(z.bind(function(r){return this.reportError("Error removing items",r,e),!1},this))},this);return this.lock.withLock(n,this.pid).catch(z.bind(function(r){return this.reportError("Error acquiring storage lock",r),_b(this.lock.storage,!0)?!1:n().then(z.bind(function(o){return o||this.queueStorage.removeItem(this.storageKey).then(function(){return o})},this)).catch(z.bind(function(o){return this.reportError("Error clearing queue",o),!1},this))},this))}else return ir.resolve(!0)};var A8=function(e,t){var n=[];return z.each(e,function(r){var o=r.id;if(o in t){var s=t[o];s!==null&&(r.payload=s,n.push(r))}else n.push(r)}),n};gu.prototype.updatePayloads=function(e){return this.memQueue=A8(this.memQueue,e),this.usePersistence?this.lock.withLock(z.bind(function(){return this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(n){return n=A8(n,e),this.saveToStorage(n)},this)).catch(z.bind(function(n){return this.reportError("Error updating items",e,n),!1},this))},this),this.pid).catch(z.bind(function(t){return this.reportError("Error acquiring storage lock",t),!1},this)):ir.resolve(!0)},gu.prototype.readFromStorage=function(){return this.ensureInit().then(z.bind(function(){return this.queueStorage.getItem(this.storageKey)},this)).then(z.bind(function(e){return e&&(z.isArray(e)||(this.reportError("Invalid storage entry:",e),e=null)),e||[]},this)).catch(z.bind(function(e){return this.reportError("Error retrieving queue",e),[]},this))},gu.prototype.saveToStorage=function(e){return this.ensureInit().then(z.bind(function(){return this.queueStorage.setItem(this.storageKey,e)},this)).then(function(){return!0}).catch(z.bind(function(t){return this.reportError("Error saving queue",t),!1},this))},gu.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(z.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):ir.resolve()};var Bte=10*60*1e3,Sb=dm("batch"),Ms=function(e,t){this.errorReporter=t.errorReporter,this.queue=new gu(e,{errorReporter:z.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};Ms.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},Ms.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},Ms.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},Ms.prototype.clear=function(){return this.queue.clear()},Ms.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},Ms.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},Ms.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(z.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},Ms.prototype.sendRequestPromise=function(e,t){return new ir(z.bind(function(n){this.sendRequest(e,t,n)},this))},Ms.prototype.flush=function(e){if(this.requestInProgress)return Sb.log("Flush: Request already in progress"),ir.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(z.bind(function(o){var s=o.length===r,u=[],d={};if(z.each(o,function(v){var x=v.payload;if(this.beforeSendHook&&!v.orphaned&&(x=this.beforeSendHook(x)),x){x.event&&x.properties&&(x.properties=z.extend({},x.properties,{mp_sent_by_lib_version:Al.LIB_VERSION}));var w=!0,E=v.id;E?(this.itemIdsSentSuccessfully[E]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:v,batchSize:o.length,timesSent:this.itemIdsSentSuccessfully[E]}),w=!1):this.reportError("[dupe] found item with no ID",{item:v}),w&&u.push(x)}d[v.id]=x},this),u.length<1)return this.requestInProgress=!1,this.resetFlush(),ir.resolve();var h=z.bind(function(){return this.queue.removeItemsByID(z.map(o,function(v){return v.id})).then(z.bind(function(v){return z.each(o,z.bind(function(x){var w=x.id;w?(this.itemIdsSentSuccessfully[w]=this.itemIdsSentSuccessfully[w]||0,this.itemIdsSentSuccessfully[w]++,this.itemIdsSentSuccessfully[w]>5&&this.reportError("[dupe] item ID sent too many times",{item:x,batchSize:o.length,timesSent:this.itemIdsSentSuccessfully[w]})):this.reportError("[dupe] found item with no ID while removing",{item:x})},this)),v?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!s?(this.resetFlush(),ir.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),ir.resolve())},this))},this),m=z.bind(function(v){this.requestInProgress=!1;try{if(e.unloading)return this.queue.updatePayloads(d);if(z.isObject(v)&&v.error==="timeout"&&new Date().getTime()-n>=t)return this.reportError("Network timeout; retrying"),this.flush();if(z.isObject(v)&&(v.httpStatusCode>=500||v.httpStatusCode===429||v.httpStatusCode<=0&&!kte()||v.error==="timeout")){var x=this.flushInterval*2;return v.retryAfter&&(x=parseInt(v.retryAfter,10)*1e3||x),x=Math.min(Bte,x),this.reportError("Error; retry in "+x+" ms"),this.scheduleFlush(x),ir.resolve()}else if(z.isObject(v)&&v.httpStatusCode===413)if(o.length>1){var w=Math.max(1,Math.floor(r/2));return this.batchSize=Math.min(this.batchSize,w,o.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush(),ir.resolve()}else return this.reportError("Single-event request too large; dropping",o),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"),Sb.log("MIXPANEL REQUEST:",u),this.sendRequestPromise(u,y).then(m)},this)).catch(z.bind(function(o){this.reportError("Error flushing request queue",o),this.resetFlush()},this))},Ms.prototype.reportError=function(e,t){if(Sb.error.apply(Sb.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(n){Sb.error(n)}};var GO=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},zte=250,gm=dm("recorder"),T8=Rt.CompressionStream,Ute={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},jte=new Set([on.MouseMove,on.MouseInteraction,on.Scroll,on.ViewportResize,on.Input,on.TouchMove,on.MediaInteraction,on.Drag,on.Selection]);function Hte(e){return e.type===jn.IncrementalSnapshot&&jte.has(e.data.source)}var zo=function(e){this._mixpanel=e.mixpanelInstance,this._onIdleTimeout=e.onIdleTimeout||ed,this._onMaxLengthReached=e.onMaxLengthReached||ed,this._onBatchSent=e.onBatchSent||ed,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=yb,this.recordMinMs=0;var t=_b(e.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new pu(_8),this.batcher=new Ms(this.batcherKey,{errorReporter:this.reportError.bind(this),flushOnlyOnInterval:!0,libConfig:Ute,sendRequestFunc:this.flushEventsWithOptOut.bind(this),queueStorage:this.queueStorage,sharedLockStorage:e.sharedLockStorage,usePersistence:t,stopAllBatchingFunc:this.stopRecording.bind(this),enqueueThrottleMs:zte,sharedLockTimeoutMS:10*1e3})};zo.prototype.unloadPersistedData=function(){return this.batcher.stop(),this.batcher.flush().then((function(){return this.queueStorage.removeItem(this.batcherKey)}).bind(this))},zo.prototype.getConfig=function(e){return this._mixpanel.get_config(e)},zo.prototype.get_config=function(e){return this.getConfig(e)},zo.prototype.startRecording=function(e){if(this._rrwebRecord===null){this.reportError("rrweb record function not provided. ");return}if(this._stopRecording!==null){gm.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>yb&&(this.recordMaxMs=yb,gm.critical("record_max_ms cannot be greater than "+yb+"ms. Capping value.")),this.maxExpires||(this.maxExpires=new Date().getTime()+this.recordMaxMs),this.recordMinMs=this.getConfig("record_min_ms"),this.recordMinMs>DO&&(this.recordMinMs=DO,gm.critical("record_min_ms cannot be greater than "+DO+"ms. Capping value.")),this.replayStartTime||(this.replayStartTime=new Date().getTime(),this.batchStartUrl=z.info.currentUrl(),this.replayStartUrl=z.info.currentUrl()),e||this.recordMinMs>0?this.batcher.stop():this.batcher.start();var t=(function(){clearTimeout(this.idleTimeoutId);var o=this.getConfig("record_idle_timeout_ms");this.idleTimeoutId=setTimeout(this._onIdleTimeout,o),this.idleExpires=new Date().getTime()+o}).bind(this);t();var n=this.getConfig("record_block_selector");(n===""||n===null)&&(n=void 0);try{this._stopRecording=this._rrwebRecord({emit:(function(o){if(this.idleExpires&&this.idleExpires<o.timestamp){this._onIdleTimeout();return}Hte(o)&&(this.batcher.stopped&&new Date().getTime()-this.replayStartTime>=this.recordMinMs&&this.batcher.start(),t()),this.__enqueuePromise=this.batcher.enqueue(o)}).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(o){this.reportError("Unexpected error when starting rrweb recording.",o)}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)},zo.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},zo.prototype.isRrwebStopped=function(){return this._stopRecording===null},zo.prototype.flushEventsWithOptOut=function(e,t,n){var r=(function(o){o===0&&(this.stopRecording(),n({error:"Tracking has been opted out, stopping recording."}))}).bind(this);this._flushEvents(e,t,n,r)},zo.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}},zo.deserialize=function(e,t){var n=new zo(z.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},zo.prototype._sendRequest=function(e,t,n,r){var o=(function(s,u){s.status===200&&this.replayId===e&&(this.seqNo++,this.batchStartUrl=z.info.currentUrl()),this._onBatchSent(),r({status:0,httpStatusCode:s.status,responseBody:u,retryAfter:s.headers.get("Retry-After")})}).bind(this);Rt.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){o(s,u)}).catch(function(u){r({error:u})})}).catch(function(s){r({error:s,httpStatusCode:0})})},zo.prototype._flushEvents=td(function(e,t,n){var r=e.length;if(r>0){for(var o=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===jn.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:Al.LIB_VERSION,batch_start_time:s/1e3,distinct_id:String(this._mixpanel.get_distinct_id()),mp_lib:"web",replay_id:o,replay_length_ms:m,replay_start_time:this.replayStartTime/1e3,replay_start_url:this.replayStartUrl,seq:this.seqNo},v=JSON.stringify(e),x=this._mixpanel.get_property("$device_id");x&&(y.$device_id=x);var w=this._mixpanel.get_property("$user_id");if(w&&(y.$user_id=w),T8){var E=new Blob([v],{type:"application/json"}).stream(),M=E.pipeThrough(new T8("gzip"));new Response(M).blob().then((function(A){y.format="gzip",this._sendRequest(o,y,A,n)}).bind(this))}else y.format="body",this._sendRequest(o,y,v,n)}}),zo.prototype.reportError=function(e,t){gm.error.apply(gm.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(n){gm.error(n)}};var mm=function(e){this.idb=new pu(HO),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};mm.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},mm.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."),ir.resolve())},mm.prototype.getActiveRecording=function(){return this.idb.init().then((function(){return this.idb.getItem(this.mixpanelInstance.get_tab_id())}).bind(this)).then((function(e){return GO(e)?null:e}).bind(this)).catch(this.handleError.bind(this))},mm.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))},mm.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 GO(n)}).map((function(n){var r=zo.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 ir.all(t)}).bind(this)).catch(this.handleError.bind(this))};var wb=dm("recorder"),_c=function(e,t,n){this.mixpanelInstance=e,this.rrwebRecord=t||Qf,this.sharedLockStorage=n,this.recordingRegistry=new mm({mixpanelInstance:this.mixpanelInstance,errorReporter:wb.error,sharedLockStorage:n}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null};_c.prototype.startRecording=function(e){if(e=e||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){wb.log("Recording already in progress, skipping startRecording.");return}var t=(function(){wb.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),n=(function(){wb.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),o={mixpanelInstance:this.mixpanelInstance,onBatchSent:r,onIdleTimeout:t,onMaxLengthReached:n,replayId:z.UUID(),rrwebRecord:this.rrwebRecord,sharedLockStorage:this.sharedLockStorage};return e.activeSerializedRecording?this.activeRecording=zo.deserialize(e.activeSerializedRecording,o):this.activeRecording=new zo(o),this.activeRecording.startRecording(e.shouldStopBatcher),this.recordingRegistry.setActiveRecording(this.activeRecording.serialize())},_c.prototype.stopRecording=function(){var e=this._stopCurrentRecording(!1);return this.recordingRegistry.clearActiveRecording(),this.activeRecording=null,e},_c.prototype.pauseRecording=function(){return this._stopCurrentRecording(!1)},_c.prototype._stopCurrentRecording=function(e){return this.activeRecording?this.activeRecording.stopRecording(e):ir.resolve()},_c.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),ir.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(t){return t?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):(wb.log("No resumable recording found."),null)}).bind(this))},_c.prototype.resetRecording=function(){this.stopRecording(),this.startRecording({shouldStopBatcher:!0})},_c.prototype.getActiveReplayId=function(){return this.activeRecording&&!this.activeRecording.isRrwebStopped()?this.activeRecording.replayId:null},Object.defineProperty(_c.prototype,"replayId",{get:function(){return this.getActiveReplayId()}}),Rt.__mp_recorder=_c;var Bw="change",Cb="click",M8="hashchange",vm="mp_locationchange",O8="popstate",R8="scrollend",VO="submit",qte=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],I8=["mp-include"],YO=["mp-no-track"],D8=YO.concat(["mp-sensitive"]),Pte=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],Ma=dm("autocapture");function ZO(e){for(var t={},n=$8(e).split(" "),r=0;r<n.length;r++){var o=n[r];o&&(t[o]=!0)}return t}function $8(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function Fte(e){if(e.previousElementSibling)return e.previousElementSibling;do e=e.previousSibling;while(e&&!B8(e));return e}function L8(e,t,n,r,o,s){var u={$classes:$8(e).split(" "),$tag_name:e.tagName.toLowerCase()},d=e.id;d&&(u.$id=d),XO(e,t,o,s)&&z.each(Pte.concat(r),function(v){if(e.hasAttribute(v)&&!n[v]){var x=e.getAttribute(v);zw(x)&&(u["$attr-"+v]=x)}});for(var h=1,m=1,y=e;y=Fte(y);)h++,y.tagName===e.tagName&&m++;return u.$nth_child=h,u.$nth_of_type=m,u}function Gte(e,t){var n=t.allowElementCallback,r=t.allowSelectors||[],o=t.blockAttrs||[],s=t.blockElementCallback,u=t.blockSelectors||[],d=t.captureTextContent||!1,h=t.captureExtraAttrs||[],m={};z.each(o,function(B){m[B]=!0});var y=null,v=typeof e.target>"u"?e.srcElement:e.target;if(z8(v)&&(v=v.parentNode),Zte(v,e)&&QO(v,e,n,r)&&!KO(v,e,s,u)){for(var x=[v],w=v;w.parentNode&&!mu(w,"body");)x.push(w.parentNode),w=w.parentNode;var E=[],M,A=!1;if(z.each(x,function(B){var L=XO(B,e,n,r);!m.href&&B.tagName.toLowerCase()==="a"&&(M=B.getAttribute("href"),M=L&&zw(M)&&M),KO(B,e,s,u)&&(A=!0),E.push(L8(B,e,m,h,n,r))},this),!A){var k=cr.documentElement;if(y={$event_type:e.type,$host:Rt.location.host,$pathname:Rt.location.pathname,$elements:E,$el_attr__href:M,$viewportHeight:Math.max(k.clientHeight,Rt.innerHeight||0),$viewportWidth:Math.max(k.clientWidth,Rt.innerWidth||0)},z.each(h,function(B){if(!m[B]&&v.hasAttribute(B)){var L=v.getAttribute(B);zw(L)&&(y["$el_attr__"+B]=L)}}),d&&(R=N8(v,e,n,r),R&&R.length&&(y.$el_text=R)),e.type===Cb&&(z.each(qte,function(B){B in e&&(y["$"+B]=e[B])}),v=Vte(e)),d){var R=N8(v,e,n,r);R&&R.length&&(y.$el_text=R)}if(v){if(!QO(v,e,n,r)||KO(v,e,s,u))return null;var D=L8(v,e,m,h,n,r);y.$target=D,y.$el_classes=D.$classes,z.extend(y,z.strip_empty_properties({$el_id:D.$id,$el_tag_name:D.$tag_name}))}}}return y}function N8(e,t,n,r){var o="";return XO(e,t,n,r)&&e.childNodes&&e.childNodes.length&&z.each(e.childNodes,function(s){z8(s)&&s.textContent&&(o+=z.trim(s.textContent).split(/(\s+)/).filter(zw).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),z.trim(o)}function Vte(e){for(var t=e.target,n=e.composedPath(),r=0;r<n.length;r++){var o=n[r];if(mu(o,"a")||mu(o,"button")||mu(o,"input")||mu(o,"select")||o.getAttribute&&o.getAttribute("role")==="button"){t=o;break}if(o===t)break}return t}function QO(e,t,n,r){if(n)try{if(!n(e,t))return!1}catch(u){return Ma.critical("Error while checking element in allowElementCallback",u),!1}if(!r.length)return!0;for(var o=0;o<r.length;o++){var s=r[o];try{if(e.matches(s))return!0}catch(u){Ma.critical("Error while checking selector: "+s,u)}}return!1}function KO(e,t,n,r){var o;if(n)try{if(n(e,t))return!0}catch(d){return Ma.critical("Error while checking element in blockElementCallback",d),!0}if(r&&r.length)for(o=0;o<r.length;o++){var s=r[o];try{if(e.matches(s))return!0}catch(d){Ma.critical("Error while checking selector: "+s,d)}}var u=ZO(e);for(o=0;o<YO.length;o++)if(u[YO[o]])return!0;return!1}function B8(e){return e&&e.nodeType===1}function mu(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function z8(e){return e&&e.nodeType===3}function Yte(){try{var e=cr.createElement("div");return!!e.matches}catch{return!1}}function Zte(e,t){if(!e||mu(e,"html")||!B8(e))return!1;var n=e.tagName.toLowerCase();switch(n){case"form":return t.type===VO;case"input":return["button","submit"].indexOf(e.getAttribute("type"))===-1?t.type===Bw:t.type===Cb;case"select":case"textarea":return t.type===Bw;default:return t.type===Cb}}function XO(e,t,n,r){var o;if(!QO(e,t,n,r))return!1;for(var s=e;s.parentNode&&!mu(s,"body");s=s.parentNode){var u=ZO(s);for(o=0;o<D8.length;o++)if(u[D8[o]])return!1}var d=ZO(e);for(o=0;o<I8.length;o++)if(d[I8[o]])return!0;if(mu(e,"input")||mu(e,"select")||mu(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 zw(e){if(e===null||z.isUndefined(e))return!1;if(typeof e=="string"){e=z.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 U8="autocapture",Qte="track_pageview",j8="full-url",Kte="url-with-path-and-query-string",Xte="url-with-path",Wte="allow_element_callback",H8="allow_selectors",q8="allow_url_regexes",P8="block_attrs",F8="block_element_callback",G8="block_selectors",V8="block_url_regexes",Y8="capture_extra_attrs",Z8="capture_text_content",Q8="scroll_capture_all",K8="scroll_depth_percent_checkpoints",WO="click",JO="input",X8="pageview",eR="scroll",tR="submit",yo={};yo[H8]=[],yo[q8]=[],yo[P8]=[],yo[F8]=null,yo[G8]=[],yo[V8]=[],yo[Y8]=[],yo[Z8]=!1,yo[Q8]=!1,yo[K8]=[25,50,75,100],yo[WO]=!0,yo[JO]=!0,yo[X8]=j8,yo[eR]=!0,yo[tR]=!0;var Uw={$mp_autocapture:!0},Jte="$mp_click",ene="$mp_input_change",tne="$mp_scroll",nne="$mp_submit",ns=function(e){this.mp=e};ns.prototype.init=function(){if(!Yte()){Ma.critical("Autocapture unavailable: missing required DOM APIs");return}this.initPageviewTracking(),this.initClickTracking(),this.initInputTracking(),this.initScrollTracking(),this.initSubmitTracking()},ns.prototype.getFullConfig=function(){var e=this.mp.get_config(U8);return e?z.isObject(e)?z.extend({},yo,e):yo:{}},ns.prototype.getConfig=function(e){return this.getFullConfig()[e]},ns.prototype.currentUrlBlocked=function(){var e,t=z.info.currentUrl(),n=this.getConfig(q8)||[];if(n.length){var r=!1;for(e=0;e<n.length;e++){var o=n[e];try{if(t.match(o)){r=!0;break}}catch(u){return Ma.critical("Error while checking block URL regex: "+o,u),!0}}if(!r)return!0}var s=this.getConfig(V8)||[];if(!s||!s.length)return!1;for(e=0;e<s.length;e++)try{if(t.match(s[e]))return!0}catch(u){return Ma.critical("Error while checking block URL regex: "+s[e],u),!0}return!1},ns.prototype.pageviewTrackingConfig=function(){return this.mp.get_config(U8)?this.getConfig(X8):this.mp.get_config(Qte)},ns.prototype.trackDomEvent=function(e,t){if(!this.currentUrlBlocked()){var n=Gte(e,{allowElementCallback:this.getConfig(Wte),allowSelectors:this.getConfig(H8),blockAttrs:this.getConfig(P8),blockElementCallback:this.getConfig(F8),blockSelectors:this.getConfig(G8),captureExtraAttrs:this.getConfig(Y8),captureTextContent:this.getConfig(Z8)});n&&(z.extend(n,Uw),this.mp.track(t,n))}},ns.prototype.initClickTracking=function(){Rt.removeEventListener(Cb,this.listenerClick),this.getConfig(WO)&&(Ma.log("Initializing click tracking"),this.listenerClick=Rt.addEventListener(Cb,(function(e){this.getConfig(WO)&&this.trackDomEvent(e,Jte)}).bind(this)))},ns.prototype.initInputTracking=function(){Rt.removeEventListener(Bw,this.listenerChange),this.getConfig(JO)&&(Ma.log("Initializing input tracking"),this.listenerChange=Rt.addEventListener(Bw,(function(e){this.getConfig(JO)&&this.trackDomEvent(e,ene)}).bind(this)))},ns.prototype.initPageviewTracking=function(){if(Rt.removeEventListener(O8,this.listenerPopstate),Rt.removeEventListener(M8,this.listenerHashchange),Rt.removeEventListener(vm,this.listenerLocationchange),!!this.pageviewTrackingConfig()){Ma.log("Initializing pageview tracking");var e="",t=!1;this.currentUrlBlocked()||(t=this.mp.track_pageview(Uw)),t&&(e=z.info.currentUrl()),this.listenerPopstate=Rt.addEventListener(O8,function(){Rt.dispatchEvent(new Event(vm))}),this.listenerHashchange=Rt.addEventListener(M8,function(){Rt.dispatchEvent(new Event(vm))});var n=Rt.history.pushState;typeof n=="function"&&(Rt.history.pushState=function(o,s,u){n.call(Rt.history,o,s,u),Rt.dispatchEvent(new Event(vm))});var r=Rt.history.replaceState;typeof r=="function"&&(Rt.history.replaceState=function(o,s,u){r.call(Rt.history,o,s,u),Rt.dispatchEvent(new Event(vm))}),this.listenerLocationchange=Rt.addEventListener(vm,BO((function(){if(!this.currentUrlBlocked()){var o=z.info.currentUrl(),s=!1,u=o.split("#")[0].split("?")[0]!==e.split("#")[0].split("?")[0],d=this.pageviewTrackingConfig();if(d===j8?s=o!==e:d===Kte?s=o.split("#")[0]!==e.split("#")[0]:d===Xte&&(s=u),s){var h=this.mp.track_pageview(Uw);h&&(e=o),u&&(this.lastScrollCheckpoint=0,Ma.log("Path change: re-initializing scroll depth checkpoints"))}}}).bind(this)))}},ns.prototype.initScrollTracking=function(){Rt.removeEventListener(R8,this.listenerScroll),this.getConfig(eR)&&(Ma.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=Rt.addEventListener(R8,BO((function(){if(this.getConfig(eR)&&!this.currentUrlBlocked()){var e=this.getConfig(Q8),t=(this.getConfig(K8)||[]).slice().sort(function(h,m){return h-m}),n=Rt.scrollY,r=z.extend({$scroll_top:n},Uw);try{var o=cr.body.scrollHeight,s=Math.round(n/(o-Rt.innerHeight)*100);if(r.$scroll_height=o,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){Ma.critical("Error while calculating scroll percentage",h)}e&&this.mp.track(tne,r)}}).bind(this))))},ns.prototype.initSubmitTracking=function(){Rt.removeEventListener(VO,this.listenerSubmit),this.getConfig(tR)&&(Ma.log("Initializing submit tracking"),this.listenerSubmit=Rt.addEventListener(VO,(function(e){this.getConfig(tR)&&this.trackDomEvent(e,nne)}).bind(this)))},yte(ns);var xc=function(){};xc.prototype.create_properties=function(){},xc.prototype.event_handler=function(){},xc.prototype.after_track_handler=function(){},xc.prototype.init=function(e){return this.mp=e,this},xc.prototype.track=function(e,t,n,r){var o=this,s=z.dom_query(e);if(s.length===0){er.error("The DOM query ("+e+") returned 0 elements");return}return z.each(s,function(u){z.register_event(u,this.override_event,function(d){var h={},m=o.create_properties(n,this),y=o.mp.get_config("track_links_timeout");o.event_handler(d,this,h),window.setTimeout(o.track_callback(r,m,h,!0),y),o.mp.track(t,m,o.track_callback(r,m,h))})},this),!0},xc.prototype.track_callback=function(e,t,n,r){r=r||!1;var o=this;return function(){n.callback_fired||(n.callback_fired=!0,!(e&&e(r,t)===!1)&&o.after_track_handler(t,n,r))}},xc.prototype.create_properties=function(e,t){var n;return typeof e=="function"?n=e(t):n=z.extend({},e),n};var ym=function(){this.override_event="click"};z.inherit(ym,xc),ym.prototype.create_properties=function(e,t){var n=ym.superclass.create_properties.apply(this,arguments);return t.href&&(n.url=t.href),n},ym.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()},ym.prototype.after_track_handler=function(e,t){t.new_tab||setTimeout(function(){window.location=t.href},0)};var jw=function(){this.override_event="submit"};z.inherit(jw,xc),jw.prototype.event_handler=function(e,t,n){n.element=t,e.preventDefault()},jw.prototype.after_track_handler=function(e,t){setTimeout(function(){t.element.submit()},0)};var rd="$set",bm="$set_once",Tl="$unset",qh="$add",vu="$append",Ph="$union",Sc="$remove",rne="$delete",W8={set_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[rd]=r,n},unset_action:function(e){var t={},n=[];return z.isArray(e)||(e=[e]),z.each(e,function(r){this._is_reserved_property(r)||n.push(r)},this),t[Tl]=n,t},set_once_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[bm]=r,n},union_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=z.isArray(o)?o:[o])},this):r[e]=z.isArray(t)?t:[t],n[Ph]=r,n},append_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[vu]=r,n},remove_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[Sc]=r,n},delete_action:function(){var e={};return e[rne]="",e}},jr=function(){};z.extend(jr.prototype,W8),jr.prototype._init=function(e,t,n){this._mixpanel=e,this._group_key=t,this._group_id=n},jr.prototype.set=pm(function(e,t,n){var r=this.set_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),jr.prototype.set_once=pm(function(e,t,n){var r=this.set_once_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),jr.prototype.unset=pm(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),jr.prototype.union=pm(function(e,t,n){z.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),jr.prototype.delete=pm(function(e){var t=this.delete_action();return this._send_request(t,e)}),jr.prototype.remove=pm(function(e,t,n){var r=this.remove_action(e,t);return this._send_request(r,n)}),jr.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=z.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)},jr.prototype._is_reserved_property=function(e){return e==="$group_key"||e==="$group_id"},jr.prototype._get_config=function(e){return this._mixpanel.get_config(e)},jr.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},jr.prototype.remove=jr.prototype.remove,jr.prototype.set=jr.prototype.set,jr.prototype.set_once=jr.prototype.set_once,jr.prototype.union=jr.prototype.union,jr.prototype.unset=jr.prototype.unset,jr.prototype.toString=jr.prototype.toString;var fn=function(){};z.extend(fn.prototype,W8),fn.prototype._init=function(e){this._mixpanel=e},fn.prototype.set=nd(function(e,t,n){var r=this.set_action(e,t);return z.isObject(e)&&(n=t),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),r[rd]=z.extend({},z.info.people_properties(),r[rd]),this._send_request(r,n)}),fn.prototype.set_once=nd(function(e,t,n){var r=this.set_once_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),fn.prototype.unset=nd(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),fn.prototype.increment=nd(function(e,t,n){var r={},o={};return z.isObject(e)?(z.each(e,function(s,u){if(!this._is_reserved_property(u))if(isNaN(parseFloat(s))){er.error("Invalid increment value passed to mixpanel.people.increment - must be a number");return}else o[u]=s},this),n=t):(z.isUndefined(t)&&(t=1),o[e]=t),r[qh]=o,this._send_request(r,n)}),fn.prototype.append=nd(function(e,t,n){z.isObject(e)&&(n=t);var r=this.append_action(e,t);return this._send_request(r,n)}),fn.prototype.remove=nd(function(e,t,n){z.isObject(e)&&(n=t);var r=this.remove_action(e,t);return this._send_request(r,n)}),fn.prototype.union=nd(function(e,t,n){z.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),fn.prototype.track_charge=nd(function(e,t,n){if(!z.isNumber(e)&&(e=parseFloat(e),isNaN(e))){er.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",z.extend({$amount:e},t),n)}),fn.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},fn.prototype.delete_user=function(){if(!this._identify_called()){er.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)},fn.prototype.toString=function(){return this._mixpanel.toString()+".people"},fn.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"),o=this._mixpanel.get_property("$had_persisted_distinct_id");n&&(e.$device_id=n),r&&(e.$user_id=r),o&&(e.$had_persisted_distinct_id=o);var s=z.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),z.isUndefined(t)||(this._get_config("verbose")?t({status:-1,error:null}):t(-1)),z.truncate(s,255))},fn.prototype._get_config=function(e){return this._mixpanel.get_config(e)},fn.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},fn.prototype._enqueue=function(e){rd in e?this._mixpanel.persistence._add_to_people_queue(rd,e):bm in e?this._mixpanel.persistence._add_to_people_queue(bm,e):Tl in e?this._mixpanel.persistence._add_to_people_queue(Tl,e):qh in e?this._mixpanel.persistence._add_to_people_queue(qh,e):vu in e?this._mixpanel.persistence._add_to_people_queue(vu,e):Sc in e?this._mixpanel.persistence._add_to_people_queue(Sc,e):Ph in e?this._mixpanel.persistence._add_to_people_queue(Ph,e):er.error("Invalid call to _enqueue():",e)},fn.prototype._flush_one_queue=function(e,t,n,r){var o=this,s=z.extend({},this._mixpanel.persistence.load_queue(e)),u=s;!z.isUndefined(s)&&z.isObject(s)&&!z.isEmptyObject(s)&&(o._mixpanel.persistence._pop_from_people_queue(e,s),o._mixpanel.persistence.save(),r&&(u=r(s)),t.call(o,u,function(d,h){d===0&&o._mixpanel.persistence._add_to_people_queue(e,s),z.isUndefined(n)||n(d,h)}))},fn.prototype._flush=function(e,t,n,r,o,s,u){var d=this;this._flush_one_queue(rd,this.set,e),this._flush_one_queue(bm,this.set_once,r),this._flush_one_queue(Tl,this.unset,s,function(A){return z.keys(A)}),this._flush_one_queue(qh,this.increment,t),this._flush_one_queue(Ph,this.union,o);var h=this._mixpanel.persistence.load_queue(vu);if(!z.isUndefined(h)&&z.isArray(h)&&h.length)for(var m,y=function(A,k){A===0&&d._mixpanel.persistence._add_to_people_queue(vu,m),z.isUndefined(n)||n(A,k)},v=h.length-1;v>=0;v--)h=this._mixpanel.persistence.load_queue(vu),m=h.pop(),d._mixpanel.persistence.save(),z.isEmptyObject(m)||d.append(m,y);var x=this._mixpanel.persistence.load_queue(Sc);if(!z.isUndefined(x)&&z.isArray(x)&&x.length)for(var w,E=function(A,k){A===0&&d._mixpanel.persistence._add_to_people_queue(Sc,w),z.isUndefined(u)||u(A,k)},M=x.length-1;M>=0;M--)x=this._mixpanel.persistence.load_queue(Sc),w=x.pop(),d._mixpanel.persistence.save(),z.isEmptyObject(w)||d.remove(w,E)},fn.prototype._is_reserved_property=function(e){return e==="$distinct_id"||e==="$token"||e==="$device_id"||e==="$user_id"||e==="$had_persisted_distinct_id"},fn.prototype.set=fn.prototype.set,fn.prototype.set_once=fn.prototype.set_once,fn.prototype.unset=fn.prototype.unset,fn.prototype.increment=fn.prototype.increment,fn.prototype.append=fn.prototype.append,fn.prototype.remove=fn.prototype.remove,fn.prototype.union=fn.prototype.union,fn.prototype.track_charge=fn.prototype.track_charge,fn.prototype.clear_charges=fn.prototype.clear_charges,fn.prototype.delete_user=fn.prototype.delete_user,fn.prototype.toString=fn.prototype.toString;var nR="__mps",rR="__mpso",iR="__mpus",oR="__mpa",aR="__mpap",sR="__mpr",lR="__mpu",J8="$people_distinct_id",Hw="__alias",Eb="__timers",ine=[nR,rR,iR,oR,aR,sR,lR,J8,Hw,Eb],An=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"&&(er.critical("Unknown persistence type "+t+"; falling back to cookie"),t=e.persistence="cookie"),t==="localStorage"&&z.localStorage.is_supported()?this.storage=z.localStorage:this.storage=z.cookie,this.load(),this.update_config(e),this.upgrade(),this.save()};An.prototype.properties=function(){var e={};return this.load(),z.each(this.props,function(t,n){z.include(ine,n)||(e[n]=t)}),e},An.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=z.extend({},e))}},An.prototype.upgrade=function(){var e,t;this.storage===z.localStorage?(e=z.cookie.parse(this.name),z.cookie.remove(this.name),z.cookie.remove(this.name,!0),e&&this.register_once(e)):this.storage===z.cookie&&(t=z.localStorage.parse(this.name),z.localStorage.remove(this.name),t&&this.register_once(t))},An.prototype.save=function(){this.disabled||this.storage.set(this.name,hm(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},An.prototype.load_prop=function(e){return this.load(),this.props[e]},An.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},An.prototype.clear=function(){this.remove(),this.props={}},An.prototype.register_once=function(e,t,n){return z.isObject(e)?(typeof t>"u"&&(t="None"),this.expire_days=typeof n>"u"?this.default_expiry:n,this.load(),z.each(e,function(r,o){(!this.props.hasOwnProperty(o)||this.props[o]===t)&&(this.props[o]=r)},this),this.save(),!0):!1},An.prototype.register=function(e,t){return z.isObject(e)?(this.expire_days=typeof t>"u"?this.default_expiry:t,this.load(),z.extend(this.props,e),this.save(),!0):!1},An.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},An.prototype.update_search_keyword=function(e){this.register(z.info.searchInfo(e))},An.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:z.info.referringDomain(e)||"$direct"},"")},An.prototype.get_referrer_info=function(){return z.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},An.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)},An.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},An.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},An.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},An.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},An.prototype.get_cross_subdomain=function(){return this.cross_subdomain},An.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},An.prototype._add_to_people_queue=function(e,t){var n=this._get_queue_key(e),r=t[e],o=this._get_or_create_queue(rd),s=this._get_or_create_queue(bm),u=this._get_or_create_queue(Tl),d=this._get_or_create_queue(qh),h=this._get_or_create_queue(Ph),m=this._get_or_create_queue(Sc,[]),y=this._get_or_create_queue(vu,[]);n===nR?(z.extend(o,r),this._pop_from_people_queue(qh,r),this._pop_from_people_queue(Ph,r),this._pop_from_people_queue(Tl,r)):n===rR?(z.each(r,function(v,x){x in s||(s[x]=v)}),this._pop_from_people_queue(Tl,r)):n===iR?z.each(r,function(v){z.each([o,s,d,h],function(x){v in x&&delete x[v]}),z.each(y,function(x){v in x&&delete x[v]}),u[v]=!0}):n===oR?(z.each(r,function(v,x){x in o?o[x]+=v:(x in d||(d[x]=0),d[x]+=v)},this),this._pop_from_people_queue(Tl,r)):n===lR?(z.each(r,function(v,x){z.isArray(v)&&(x in h||(h[x]=[]),z.each(v,function(w){z.include(h[x],w)||h[x].push(w)}))}),this._pop_from_people_queue(Tl,r)):n===sR?(m.push(r),this._pop_from_people_queue(vu,r)):n===aR&&(y.push(r),this._pop_from_people_queue(Tl,r)),er.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),er.log(t),this.save()},An.prototype._pop_from_people_queue=function(e,t){var n=this.props[this._get_queue_key(e)];z.isUndefined(n)||z.each(t,function(r,o){e===vu||e===Sc?z.each(n,function(s){s[o]===r&&delete s[o]}):delete n[o]},this)},An.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},An.prototype._get_queue_key=function(e){if(e===rd)return nR;if(e===bm)return rR;if(e===Tl)return iR;if(e===qh)return oR;if(e===vu)return aR;if(e===Sc)return sR;if(e===Ph)return lR;er.error("Invalid queue:",e)},An.prototype._get_or_create_queue=function(e,t){var n=this._get_queue_key(e);return t=z.isUndefined(t)?{}:t,this.props[n]||(this.props[n]=t)},An.prototype.set_event_timer=function(e,t){var n=this.load_prop(Eb)||{};n[e]=t,this.props[Eb]=n,this.save()},An.prototype.remove_event_timer=function(e){var t=this.load_prop(Eb)||{},n=t[e];return z.isUndefined(n)||(delete this.props[Eb][e],this.save()),n};var uR,e9=function(e,t){throw new Error(e+" not available in this build.")},Uo,t9=0,one=1,ane=function(e){return e},Os="mixpanel",n9="base64",sne="json",cR="$device:",_m=Rt.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,r9=!_m&&bc.indexOf("MSIE")===-1&&bc.indexOf("Mozilla")===-1,qw=null;Jf.sendBeacon&&(qw=function(){return Jf.sendBeacon.apply(Jf,arguments)});var i9={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},o9={api_host:"https://api-js.mixpanel.com",api_routes:i9,api_method:"POST",api_transport:"XHR",api_payload_format:n9,app_host:"https://mixpanel.com",autocapture:!1,cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:ed,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:ed,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:yb,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},a9=!1,Te=function(){},fR=function(e,t,n){var r,o=n===Os?Uo:Uo[n];if(o&&uR===t9)r=o;else{if(o&&!z.isArray(o)){er.error("You have already initialized "+n);return}r=new Te}if(r._cached_groups={},r._init(e,t,n),r.people=new fn,r.people._init(r),!r.get_config("skip_first_touch_marketing")){var s=z.info.campaignParams(null),u={},d=!1;z.each(s,function(h,m){u["initial_"+m]=h,h&&(d=!0)}),d&&r.people.set_once(u)}return Al.DEBUG=Al.DEBUG||r.get_config("debug"),!z.isUndefined(o)&&z.isArray(o)&&(r._execute_array.call(r.people,o.people),r._execute_array(o)),r};Te.prototype.init=function(e,t,n){if(z.isUndefined(n)){this.report_error("You must name your new library: init(token, config, name)");return}if(n===Os){this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");return}var r=fR(e,t,n);return Uo[n]=r,r._loaded(),r},Te.prototype._init=function(e,t,n){t=t||{},this.__loaded=!0,this.config={};var r={};if(!("api_payload_format"in t)){var o=t.api_host||o9.api_host;o.match(/\.mixpanel\.com/)&&(r.api_payload_format=sne)}if(this.set_config(z.extend({},o9,r,t,{name:n,token:e,callback_fn:(n===Os?n:Os+"."+n)+"._jsc"})),this._jsc=ed,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(!z.localStorage.is_supported(!0)||!_m)this._batch_requests=!1,er.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),z.each(this.get_batcher_configs(),function(d){er.log("Clearing batch queue "+d.queue_key),z.localStorage.remove(d.queue_key)});else if(this.init_batchers(),qw&&Rt.addEventListener){var s=z.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);Rt.addEventListener("pagehide",function(d){d.persisted&&s()}),Rt.addEventListener("visibilitychange",function(){cr.visibilityState==="hidden"&&s()})}}this.persistence=this.cookie=new An(this.config),this.unpersisted_superprops={},this._gdpr_init();var u=z.UUID();this.get_distinct_id()||this.register_once({distinct_id:cR+u,$device_id:u},""),this.autocapture=new ns(this),this.autocapture.init(),this._init_tab_id(),this._check_and_start_session_recording()},Te.prototype._init_tab_id=function(){if(z.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;(z.sessionStorage.get(n)||!z.sessionStorage.get(t))&&z.sessionStorage.set(t,"$tab-"+z.UUID()),z.sessionStorage.set(n,"1"),this.tab_id=z.sessionStorage.get(t),Rt.addEventListener("beforeunload",function(){z.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.")},Te.prototype.get_tab_id=function(){return this.tab_id||null},Te.prototype._should_load_recorder=function(){var e=new pu(HO),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(GO(n[r])||n[r].tabId===t)return!0;return!1}).catch(z.bind(function(n){this.report_error("Error checking recording registry",n)},this))},Te.prototype._check_and_start_session_recording=td(function(e){if(!Rt.MutationObserver){er.critical("Browser does not support MutationObserver; skipping session recording");return}var t=z.bind(function(r){var o=z.bind(function(){this._recorder=this._recorder||new Rt.__mp_recorder(this),this._recorder.resumeRecording(r)},this);z.isUndefined(Rt.__mp_recorder)?e9(this.get_config("recorder_src"),o):o()},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)})}),Te.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},Te.prototype.stop_session_recording=function(){this._recorder&&this._recorder.stopRecording()},Te.prototype.pause_session_recording=function(){this._recorder&&this._recorder.pauseRecording()},Te.prototype.resume_session_recording=function(){this._recorder&&this._recorder.resumeRecording()},Te.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},Te.prototype.get_session_replay_url=function(){var e=null,t=this._get_session_replay_id();if(t){var n=z.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},Te.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},Te.prototype.__get_recorder=function(){return this._recorder},Te.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=z.info.campaignParams(null);z.each(e,(function(t,n){this.unregister(n)}).bind(this))}},Te.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(cr.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(z.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info(cr.referrer)},Te.prototype._dom_loaded=function(){z.each(this.__dom_loaded_queue,function(e){this._track_dom.apply(this,e)},this),this.has_opted_out_tracking()||z.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},Te.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(!a9)return this.__dom_loaded_queue.push([e,t]),!1;var n=new e().init(this);return n.track.apply(n,t)},Te.prototype._prepare_callback=function(e,t){if(z.isUndefined(e))return null;if(_m){var n=function(u){e(u,t)};return n}else{var r=this._jsc,o=""+Math.floor(Math.random()*1e8),s=this.get_config("callback_fn")+"["+o+"]";return r[o]=function(u){delete r[o],e(u,t)},s}},Te.prototype._send_request=function(e,t,n,r){var o=!0;if(r9)return this.__request_queue.push(arguments),o;var s={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},u=null;!r&&(z.isFunction(n)||typeof n=="string")&&(r=n,n=null),n=z.extend(s,n||{}),_m||(n.method="GET");var d=n.method==="POST",h=qw&&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),_m||(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+="?"+z.HTTPBuildQuery(t);var y=this;if("img"in t){var v=cr.createElement("img");v.src=e,cr.body.appendChild(v)}else if(h){try{o=qw(e,u)}catch(k){y.report_error(k),o=!1}try{r&&r(o?1:0)}catch(k){y.report_error(k)}}else if(_m)try{var x=new XMLHttpRequest;x.open(n.method,e,!0);var w=this.get_config("xhr_headers");if(d&&(w["Content-Type"]="application/x-www-form-urlencoded"),z.each(w,function(k,R){x.setRequestHeader(R,k)}),n.timeout_ms&&typeof x.timeout<"u"){x.timeout=n.timeout_ms;var E=new Date().getTime()}x.withCredentials=!0,x.onreadystatechange=function(){if(x.readyState===4)if(x.status===200){if(r)if(m){var k;try{k=z.JSONDecode(x.responseText)}catch(B){if(y.report_error(B),n.ignore_json_errors)k=x.responseText;else return}r(k)}else r(Number(x.responseText))}else{var R;if(x.timeout&&!x.status&&new Date().getTime()-E>=x.timeout?R="timeout":R="Bad HTTP status: "+x.status+" "+x.statusText,y.report_error(R),r)if(m){var D=x.responseHeaders||{};r({status:0,httpStatusCode:x.status,error:R,retryAfter:D["Retry-After"]})}else r(0)}},x.send(u)}catch(k){y.report_error(k),o=!1}else{var M=cr.createElement("script");M.type="text/javascript",M.async=!0,M.defer=!0,M.src=e;var A=cr.getElementsByTagName("script")[0];A.parentNode.insertBefore(M,A)}return o},Te.prototype._execute_array=function(e){var t,n=[],r=[],o=[];z.each(e,function(u){u&&(t=u[0],z.isArray(t)?o.push(u):typeof u=="function"?u.call(this):z.isArray(u)&&t==="alias"?n.push(u):z.isArray(u)&&t.indexOf("track")!==-1&&typeof this[t]=="function"?o.push(u):r.push(u))},this);var s=function(u,d){z.each(u,function(h){if(z.isArray(h[0])){var m=d;z.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(o,this)},Te.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},Te.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},Te.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=z.bind(function(n){return new Ms(n.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:z.bind(function(r,o,s){this._send_request(this.get_config("api_host")+n.endpoint,this._encode_data_for_request(r),o,this._prepare_callback(s,r))},this),beforeSendHook:z.bind(function(r){return this._run_hook("before_send_"+n.type,r)},this),stopAllBatchingFunc:z.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()},Te.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,z.each(this.request_batchers,function(e){e.start()}))},Te.prototype.stop_batch_senders=function(){this._batch_requests=!1,z.each(this.request_batchers,function(e){e.stop(),e.clear()})},Te.prototype.push=function(e){this._execute_array([e])},Te.prototype.disable=function(e){typeof e>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},Te.prototype._encode_data_for_request=function(e){var t=hm(e);return this.get_config("api_payload_format")===n9&&(t=z.base64Encode(t)),{data:t}},Te.prototype._track_or_batch=function(e,t){var n=z.truncate(e.data,255),r=e.endpoint,o=e.batcher,s=e.should_send_immediately,u=e.send_request_options||{};t=t||ed;var d=!0,h=z.bind(function(){return u.skip_hooks||(n=this._run_hook("before_send_"+e.type,n)),n?(er.log("MIXPANEL REQUEST:"),er.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?o.enqueue(n).then(function(m){m?t(1,n):h()}):d=h(),d&&n},Te.prototype.track=td(function(e,t,n,r){!r&&typeof n=="function"&&(r=n,n=null),n=n||{};var o=n.transport;o&&(n.transport=o);var s=n.send_immediately;if(typeof r!="function"&&(r=ed),z.isUndefined(e)){this.report_error("No event name provided to mixpanel.track");return}if(this._event_is_disabled(e)){r(0);return}t=z.extend({},t),t.token=this.get_config("token");var u=this.persistence.remove_event_timer(e);if(!z.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")?z.info.marketingParams():{};t=z.extend({},z.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");z.isArray(m)?z.each(m,function(x){delete t[x]}):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}),Te.prototype.set_group=td(function(e,t,n){z.isArray(t)||(t=[t]);var r={};return r[e]=t,this.register(r),this.people.set(e,t,n)}),Te.prototype.add_group=td(function(e,t,n){var r=this.get_property(e),o={};return r===void 0?(o[e]=[t],this.register(o)):r.indexOf(t)===-1&&(r.push(t),o[e]=r,this.register(o)),this.people.union(e,t,n)}),Te.prototype.remove_group=td(function(e,t,n){var r=this.get_property(e);if(r!==void 0){var o=r.indexOf(t);o>-1&&(r.splice(o,1),this.register({group_key:r})),r.length===0&&this.unregister(e)}return this.people.remove(e,t,n)}),Te.prototype.track_with_groups=td(function(e,t,n,r){var o=z.extend({},t||{});return z.each(n,function(s,u){s!=null&&(o[u]=s)}),this.track(e,o,r)}),Te.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},Te.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},Te.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 jr,r._init(this,e,t),this._cached_groups[n]=r),r},Te.prototype.track_pageview=td(function(e,t){typeof e!="object"&&(e={}),t=t||{};var n=t.event_name||"$mp_web_page_view",r=z.extend(z.info.mpPageViewProperties(),z.info.campaignParams(),z.info.clickParams()),o=z.extend({},r,e);return this.track(n,o)}),Te.prototype.track_links=function(){return this._track_dom.call(this,ym,arguments)},Te.prototype.track_forms=function(){return this._track_dom.call(this,jw,arguments)},Te.prototype.time_event=function(e){if(z.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 lne={persistent:!0},dR=function(e){var t;return z.isObject(e)?t=e:z.isUndefined(e)?t={}:t={days:e},z.extend({},lne,t)};Te.prototype.register=function(e,t){var n=dR(t);n.persistent?this.persistence.register(e,n.days):z.extend(this.unpersisted_superprops,e)},Te.prototype.register_once=function(e,t,n){var r=dR(n);r.persistent?this.persistence.register_once(e,t,r.days):(typeof t>"u"&&(t="None"),z.each(e,function(o,s){(!this.unpersisted_superprops.hasOwnProperty(s)||this.unpersisted_superprops[s]===t)&&(this.unpersisted_superprops[s]=o)},this))},Te.prototype.unregister=function(e,t){t=dR(t),t.persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},Te.prototype._register_single=function(e,t){var n={};n[e]=t,this.register(n)},Te.prototype.identify=function(e,t,n,r,o,s,u,d){var h=this.get_distinct_id();if(e&&h!==e){if(typeof e=="string"&&e.indexOf(cR)===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(Hw)&&(this.unregister(Hw),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,n,r,o,s,u,d),e!==h&&this.track("$identify",{distinct_id:e,$anon_distinct_id:h},{skip_hooks:!0})},Te.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var e=z.UUID();this.register_once({distinct_id:cR+e,$device_id:e},"")},Te.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},Te.prototype.alias=function(e,t){if(e===this.get_property(J8))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var n=this;return z.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Hw,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)},Te.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},Te.prototype.set_config=function(e){if(z.isObject(e)){z.extend(this.config,e);var t=e.batch_size;t&&z.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),Al.DEBUG=Al.DEBUG||this.get_config("debug"),"autocapture"in e&&this.autocapture&&this.autocapture.init()}},Te.prototype.get_config=function(e){return this.config[e]},Te.prototype._run_hook=function(e){var t=(this.config.hooks[e]||ane).apply(this,Wf.call(arguments,1));return typeof t>"u"&&(this.report_error(e+" hook did not return a value"),t=null),t},Te.prototype.get_property=function(e){return this.persistence.load_prop([e])},Te.prototype.toString=function(){var e=this.get_config("name");return e!==Os&&(e=Os+"."+e),e},Te.prototype._event_is_disabled=function(e){return z.isBlockedUA(bc)||this._flags.disable_all_events||z.include(this.__disabled_events,e)},Te.prototype._gdpr_init=function(){var e=this.get_config("opt_out_tracking_persistence_type")==="localStorage";e&&z.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")||z.cookie.get("mp_optout"))&&(z.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},Te.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()},Te.prototype._gdpr_call_func=function(e,t){return t=z.extend({track:z.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),z.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})},Te.prototype.opt_in_tracking=function(e){e=z.extend({enable_persistence:!0},e),this._gdpr_call_func(Rte,e),this._gdpr_update_persistence(e)},Te.prototype.opt_out_tracking=function(e){e=z.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(Ite,e),this._gdpr_update_persistence(e)},Te.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(Dte,e)},Te.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(x8,e)},Te.prototype.clear_opt_in_out_tracking=function(e){e=z.extend({enable_persistence:!0},e),this._gdpr_call_func($te,e),this._gdpr_update_persistence(e)},Te.prototype.report_error=function(e,t){er.error.apply(er.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(n){er.error(n)}},Te.prototype.init=Te.prototype.init,Te.prototype.reset=Te.prototype.reset,Te.prototype.disable=Te.prototype.disable,Te.prototype.time_event=Te.prototype.time_event,Te.prototype.track=Te.prototype.track,Te.prototype.track_links=Te.prototype.track_links,Te.prototype.track_forms=Te.prototype.track_forms,Te.prototype.track_pageview=Te.prototype.track_pageview,Te.prototype.register=Te.prototype.register,Te.prototype.register_once=Te.prototype.register_once,Te.prototype.unregister=Te.prototype.unregister,Te.prototype.identify=Te.prototype.identify,Te.prototype.alias=Te.prototype.alias,Te.prototype.name_tag=Te.prototype.name_tag,Te.prototype.set_config=Te.prototype.set_config,Te.prototype.get_config=Te.prototype.get_config,Te.prototype.get_property=Te.prototype.get_property,Te.prototype.get_distinct_id=Te.prototype.get_distinct_id,Te.prototype.toString=Te.prototype.toString,Te.prototype.opt_out_tracking=Te.prototype.opt_out_tracking,Te.prototype.opt_in_tracking=Te.prototype.opt_in_tracking,Te.prototype.has_opted_out_tracking=Te.prototype.has_opted_out_tracking,Te.prototype.has_opted_in_tracking=Te.prototype.has_opted_in_tracking,Te.prototype.clear_opt_in_out_tracking=Te.prototype.clear_opt_in_out_tracking,Te.prototype.get_group=Te.prototype.get_group,Te.prototype.set_group=Te.prototype.set_group,Te.prototype.add_group=Te.prototype.add_group,Te.prototype.remove_group=Te.prototype.remove_group,Te.prototype.track_with_groups=Te.prototype.track_with_groups,Te.prototype.start_batch_senders=Te.prototype.start_batch_senders,Te.prototype.stop_batch_senders=Te.prototype.stop_batch_senders,Te.prototype.start_session_recording=Te.prototype.start_session_recording,Te.prototype.stop_session_recording=Te.prototype.stop_session_recording,Te.prototype.pause_session_recording=Te.prototype.pause_session_recording,Te.prototype.resume_session_recording=Te.prototype.resume_session_recording,Te.prototype.get_session_recording_properties=Te.prototype.get_session_recording_properties,Te.prototype.get_session_replay_url=Te.prototype.get_session_replay_url,Te.prototype.get_tab_id=Te.prototype.get_tab_id,Te.prototype.DEFAULT_API_ROUTES=i9,Te.prototype.__get_recorder=Te.prototype.__get_recorder,An.prototype.properties=An.prototype.properties,An.prototype.update_search_keyword=An.prototype.update_search_keyword,An.prototype.update_referrer_info=An.prototype.update_referrer_info,An.prototype.get_cross_subdomain=An.prototype.get_cross_subdomain,An.prototype.clear=An.prototype.clear;var xm={},une=function(){z.each(xm,function(e,t){t!==Os&&(Uo[t]=e)}),Uo._=z},cne=function(){Uo.init=function(e,t,n){if(n)return Uo[n]||(Uo[n]=xm[n]=fR(e,t,n),Uo[n]._loaded()),Uo[n];var r=Uo;xm[Os]?r=xm[Os]:e&&(r=fR(e,t,Os),r._loaded(),xm[Os]=r),Uo=r,uR===one&&(Rt[Os]=Uo),une()}},fne=function(){function e(){e.done||(e.done=!0,a9=!0,r9=!1,z.each(xm,function(r){r._dom_loaded()}))}function t(){try{cr.documentElement.doScroll("left")}catch{setTimeout(t,1);return}e()}if(cr.addEventListener)cr.readyState==="complete"?e():cr.addEventListener("DOMContentLoaded",e,!1);else if(cr.attachEvent){cr.attachEvent("onreadystatechange",e);var n=!1;try{n=Rt.frameElement===null}catch{}cr.documentElement.doScroll&&n&&t()}z.register_event(Rt,"load",e,!0)};function dne(e){return e9=e,uR=t9,Uo=new Te,cne(),Uo.init(),fne(),Uo}function hne(e,t){t()}var id=dne(hne);const ci="https://saas.brainlox.com",pne="https://debales-web-app-server.azurewebsites.net",s9={"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"},gne="phc_nzwftWluHb06OLHwbfhb2xmhk88Ffc9OjjR8Jz5Q327",Pw=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 tr(){const e=sessionStorage.getItem("debalesSessionID");if(e)return e;const t=crypto.randomUUID();return sessionStorage.setItem("debalesSessionID",t),t}function mne(){return sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:window.DebalesChat.projectId}))}function bo(){const e=localStorage.getItem(Dn(In.USER_INFO));return e?JSON.parse(e):null}function wc(e){localStorage.setItem(Dn(In.USER_INFO),JSON.stringify(e))}function jo(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,o=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+(o-r)*v,y<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}}}function vne(){return window.location.pathname}function kb(){const e=/test|demo|example|debales/i,t=bo()??"";return!!(t&&e.test(t.email))}function Fw(e){const t=vne(),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 l9=new Set,Gw=e=>{const t=s9[e];if(!t)return console.warn("No Mixpanel token found"),null;if(l9.has(e))return id;id.init(t,{debug:!0,track_pageview:!0,persistence:"localStorage"}),console.log("Mixpanel initialized");const n=bo();return n&&n.email&&id.identify(n.email),l9.add(e),id},yne=async(e,t)=>{if(kb())return;const n=window.DebalesChat.projectId??t.projectId;if(!s9[n]){console.warn("No Mixpanel token found");return}id.track(e,t)},bne=()=>{const e=localStorage.getItem("anonymousUserId");if(e)return e;const t=crypto.randomUUID();return localStorage.setItem("anonymousUserId",t),t};function Fh(e){return e?e.split("<br>").filter(n=>n.trim().length>0).map(n=>n.trim()):[""]}const _o=e=>e.toLowerCase().includes("gaiabay")||e.toLowerCase().includes("debales-testing"),_ne=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 Dn(e,t){return t!=null&&t.botId?`debales_${t.botId}_${e}`:`debales_${e}`}const u9=W.createContext(null),Ab=()=>{const e=W.useContext(u9);if(!e)throw new Error("useCart must be used within a CartProvider");return e};var xne="2.0.0",Sm="",c9="?",Vw="function",od="undefined",wm="object",hR="string",Tb="major",st="model",rt="name",nt="type",vt="vendor",ot="version",Oa="architecture",Cm="console",yn="mobile",Zr="tablet",Ho="smarttv",Mb="wearable",pR="xr",gR="embedded",Ob="inapp",f9="user-agent",mR=500,vR="brands",Gh="formFactors",yR="fullVersionList",Em="platform",bR="platformVersion",Yw="bitness",ad="sec-ch-ua",Sne=ad+"-full-version-list",wne=ad+"-arch",Cne=ad+"-"+Yw,Ene=ad+"-form-factors",kne=ad+"-"+yn,Ane=ad+"-"+st,d9=ad+"-"+Em,Tne=d9+"-version",h9=[vR,yR,yn,st,Em,bR,Oa,Gh,Yw],rs="browser",Cc="cpu",yu="device",Ec="engine",Rs="os",km="result",Zw="Amazon",Rb="Apple",p9="ASUS",g9="BlackBerry",Vh="Google",m9="Huawei",v9="Lenovo",Mne="Honor",_R="LG",Qw="Microsoft",y9="Motorola",Ib="Samsung",b9="Sharp",Kw="Sony",xR="Xiaomi",SR="Zebra",Am="Mobile ",Db=" Browser",_9="Chrome",sd="Chromecast",One="Edge",$b="Firefox",Lb="Opera",x9="Facebook",S9="Sogou",wR="Windows",Rne=typeof window!==od,Ra=Rne&&window.navigator?window.navigator:void 0,ld=Ra&&Ra.userAgentData?Ra.userAgentData:void 0,Ine=function(e,t){var n={},r=t;if(!Ww(t)){r={};for(var o in t)for(var s in t[o])r[s]=t[o][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},Xw=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},CR=function(e,t){if(typeof e===wm&&e.length>0){for(var n in e)if(kc(e[n])==kc(t))return!0;return!1}return Tm(e)?kc(t).indexOf(kc(e))!==-1:!1},Ww=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?Ww(e[n]):!1)},Tm=function(e){return typeof e===hR},ER=function(e){if(e){for(var t=[],n=Yh(/\\?\"/g,e).split(","),r=0;r<n.length;r++)if(n[r].indexOf(";")>-1){var o=Bb(n[r]).split(";v=");t[r]={brand:o[0],version:o[1]}}else t[r]=Bb(n[r]);return t}},kc=function(e){return Tm(e)?e.toLowerCase():e},kR=function(e){return Tm(e)?Yh(/[^\d\.]/g,e).split(".")[0]:void 0},Ac=function(e){for(var t in e){var n=e[t];typeof n==wm&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Yh=function(e,t){return Tm(t)?t.replace(e,Sm):t},Nb=function(e){return Yh(/\\?\"/g,e)},Bb=function(e,t){if(Tm(e))return e=Yh(/^\s\s*/,e),typeof t===od?e:e.substring(0,mR)},w9=function(e,t){if(!(!e||!t))for(var n=0,r,o,s,u,d,h;n<t.length&&!d;){var m=t[n],y=t[n+1];for(r=o=0;r<m.length&&!d&&m[r];)if(d=m[r++].exec(e),d)for(s=0;s<y.length;s++)h=d[++o],u=y[s],typeof u===wm&&u.length>0?u.length===2?typeof u[1]==Vw?this[u[0]]=u[1].call(this,h):this[u[0]]=u[1]:u.length===3?typeof u[1]===Vw&&!(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}},zb=function(e,t){for(var n in t)if(typeof t[n]===wm&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(CR(t[n][r],e))return n===c9?void 0:n}else if(CR(t[n],e))return n===c9?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},C9={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"},E9={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},k9={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[ot,[rt,Am+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[ot,[rt,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[rt,ot],[/opios[\/ ]+([\w\.]+)/i],[ot,[rt,Lb+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[ot,[rt,Lb+" GX"]],[/\bopr\/([\w\.]+)/i],[ot,[rt,Lb]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[ot,[rt,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[ot,[rt,"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],[rt,ot],[/quark(?:pc)?\/([-\w\.]+)/i],[ot,[rt,"Quark"]],[/\bddg\/([\w\.]+)/i],[ot,[rt,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[ot,[rt,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[ot,[rt,"WeChat"]],[/konqueror\/([\w\.]+)/i],[ot,[rt,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[ot,[rt,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[ot,[rt,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[ot,[rt,"Smart "+v9+Db]],[/(avast|avg)\/([\w\.]+)/i],[[rt,/(.+)/,"$1 Secure"+Db],ot],[/\bfocus\/([\w\.]+)/i],[ot,[rt,$b+" Focus"]],[/\bopt\/([\w\.]+)/i],[ot,[rt,Lb+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[ot,[rt,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[ot,[rt,"Dolphin"]],[/coast\/([\w\.]+)/i],[ot,[rt,Lb+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[ot,[rt,"MIUI"+Db]],[/fxios\/([\w\.-]+)/i],[ot,[rt,Am+$b]],[/\bqihoobrowser\/?([\w\.]*)/i],[ot,[rt,"360"]],[/\b(qq)\/([\w\.]+)/i],[[rt,/(.+)/,"$1Browser"],ot],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[rt,/(.+)/,"$1"+Db],ot],[/samsungbrowser\/([\w\.]+)/i],[ot,[rt,Ib+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[ot,[rt,S9+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[rt,S9+" Mobile"],ot],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[rt,ot],[/(lbbrowser|rekonq)/i],[rt],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[ot,rt],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[rt,x9],ot,[nt,Ob]],[/(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],[rt,ot,[nt,Ob]],[/\bgsa\/([\w\.]+) .*safari\//i],[ot,[rt,"GSA"],[nt,Ob]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[ot,[rt,"TikTok"],[nt,Ob]],[/\[(linkedin)app\]/i],[rt,[nt,Ob]],[/(chromium)[\/ ]([-\w\.]+)/i],[rt,ot],[/headlesschrome(?:\/([\w\.]+)| )/i],[ot,[rt,_9+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[rt,_9+" WebView"],ot],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[ot,[rt,"Android"+Db]],[/chrome\/([\w\.]+) mobile/i],[ot,[rt,Am+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[rt,ot],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[ot,[rt,Am+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[rt,Am+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[ot,rt],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[rt,[ot,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[rt,ot],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[rt,Am+$b],ot],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[rt,"Netscape"],ot],[/(wolvic|librewolf)\/([\w\.]+)/i],[rt,ot],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[ot,[rt,$b+" 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],[rt,[ot,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[rt,[ot,/[^\d\.]+./,Sm]]],cpu:[[/\b(?:(amd|x|x86[-_]?|wow|win)64)\b/i],[[Oa,"amd64"]],[/(ia32(?=;))/i,/((?:i[346]|x)86)[;\)]/i],[[Oa,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[Oa,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[Oa,"armhf"]],[/windows (ce|mobile); ppc;/i],[[Oa,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[Oa,/ower/,Sm,kc]],[/(sun4\w)[;\)]/i],[[Oa,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[Oa,kc]]],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],[st,[vt,Ib],[nt,Zr]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[st,[vt,Ib],[nt,yn]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[st,[vt,Rb],[nt,yn]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[st,[vt,Rb],[nt,Zr]],[/(macintosh);/i],[st,[vt,Rb]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[st,[vt,b9],[nt,yn]],[/(?:honor)([-\w ]+)[;\)]/i],[st,[vt,Mne],[nt,yn]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[st,[vt,m9],[nt,Zr]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[st,[vt,m9],[nt,yn]],[/\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],[[st,/_/g," "],[vt,xR],[nt,yn]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[st,/_/g," "],[vt,xR],[nt,Zr]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[st,[vt,"OPPO"],[nt,yn]],[/\b(opd2\d{3}a?) bui/i],[st,[vt,"OPPO"],[nt,Zr]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[st,[vt,"Vivo"],[nt,yn]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[st,[vt,"Realme"],[nt,yn]],[/\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],[st,[vt,y9],[nt,yn]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[st,[vt,y9],[nt,Zr]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[st,[vt,_R],[nt,Zr]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[st,[vt,_R],[nt,yn]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[st,[vt,v9],[nt,Zr]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[st,/_/g," "],[vt,"Nokia"],[nt,yn]],[/(pixel c)\b/i],[st,[vt,Vh],[nt,Zr]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[st,[vt,Vh],[nt,yn]],[/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],[st,[vt,Kw],[nt,yn]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[st,"Xperia Tablet"],[vt,Kw],[nt,Zr]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[st,[vt,"OnePlus"],[nt,yn]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[st,[vt,Zw],[nt,Zr]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[st,/(.+)/g,"Fire Phone $1"],[vt,Zw],[nt,yn]],[/(playbook);[-\w\),; ]+(rim)/i],[st,vt,[nt,Zr]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[st,[vt,g9],[nt,yn]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[st,[vt,p9],[nt,Zr]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[st,[vt,p9],[nt,yn]],[/(nexus 9)/i],[st,[vt,"HTC"],[nt,Zr]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[vt,[st,/_/g," "],[nt,yn]],[/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],[st,[vt,"TCL"],[nt,Zr]],[/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],[st,[vt,"TCL"],[nt,yn]],[/(itel) ((\w+))/i],[[vt,kc],st,[nt,zb,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[st,[vt,"Acer"],[nt,Zr]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[st,[vt,"Meizu"],[nt,yn]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[st,[vt,"Ulefone"],[nt,yn]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[st,[vt,"Energizer"],[nt,yn]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[st,[vt,"Cat"],[nt,yn]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[st,[vt,"Smartfren"],[nt,yn]],[/droid.+; (a(?:015|06[35]|142p?))/i],[st,[vt,"Nothing"],[nt,yn]],[/(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],[vt,st,[nt,yn]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[vt,st,[nt,Zr]],[/(surface duo)/i],[st,[vt,Qw],[nt,Zr]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[st,[vt,"Fairphone"],[nt,yn]],[/(shield[\w ]+) b/i],[st,[vt,"Nvidia"],[nt,Zr]],[/(sprint) (\w+)/i],[vt,st,[nt,yn]],[/(kin\.[onetw]{3})/i],[[st,/\./g," "],[vt,Qw],[nt,yn]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[st,[vt,SR],[nt,Zr]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[st,[vt,SR],[nt,yn]],[/smart-tv.+(samsung)/i],[vt,[nt,Ho]],[/hbbtv.+maple;(\d+)/i],[[st,/^/,"SmartTV"],[vt,Ib],[nt,Ho]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[vt,_R],[nt,Ho]],[/(apple) ?tv/i],[vt,[st,Rb+" TV"],[nt,Ho]],[/crkey.*devicetype\/chromecast/i],[[st,sd+" Third Generation"],[vt,Vh],[nt,Ho]],[/crkey.*devicetype\/([^/]*)/i],[[st,/^/,"Chromecast "],[vt,Vh],[nt,Ho]],[/fuchsia.*crkey/i],[[st,sd+" Nest Hub"],[vt,Vh],[nt,Ho]],[/crkey/i],[[st,sd],[vt,Vh],[nt,Ho]],[/droid.+aft(\w+)( bui|\))/i],[st,[vt,Zw],[nt,Ho]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[st,[vt,b9],[nt,Ho]],[/(bravia[\w ]+)( bui|\))/i],[st,[vt,Kw],[nt,Ho]],[/(mitv-\w{5}) bui/i],[st,[vt,xR],[nt,Ho]],[/Hbbtv.*(technisat) (.*);/i],[vt,st,[nt,Ho]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[vt,Bb],[st,Bb],[nt,Ho]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[nt,Ho]],[/(ouya)/i,/(nintendo) (\w+)/i],[vt,st,[nt,Cm]],[/droid.+; (shield) bui/i],[st,[vt,"Nvidia"],[nt,Cm]],[/(playstation \w+)/i],[st,[vt,Kw],[nt,Cm]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[st,[vt,Qw],[nt,Cm]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[st,[vt,Ib],[nt,Mb]],[/((pebble))app/i],[vt,st,[nt,Mb]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[st,[vt,Rb],[nt,Mb]],[/droid.+; (wt63?0{2,3})\)/i],[st,[vt,SR],[nt,Mb]],[/droid.+; (glass) \d/i],[st,[vt,Vh],[nt,pR]],[/(pico) (4|neo3(?: link|pro)?)/i],[vt,st,[nt,pR]],[/; (quest( \d| pro)?)/i],[st,[vt,x9],[nt,pR]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[vt,[nt,gR]],[/(aeobc)\b/i],[st,[vt,Zw],[nt,gR]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[st,[nt,yn]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[st,[nt,Zr]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[nt,Zr]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[nt,yn]],[/(android[-\w\. ]{0,9});.+buil/i],[st,[vt,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[ot,[rt,One+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[rt,ot],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[ot,[rt,"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],[rt,ot],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[ot,rt]],os:[[/microsoft (windows) (vista|xp)/i],[rt,ot],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[rt,[ot,zb,C9]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[ot,zb,C9],[rt,wR]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[ot,/_/g,"."],[rt,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[rt,"macOS"],[ot,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[ot,[rt,sd+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[ot,[rt,sd+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[ot,[rt,sd+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[ot,[rt,sd+" Linux"]],[/crkey\/([\d\.]+)/i],[ot,[rt,sd]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[ot,rt],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[rt,ot],[/\(bb(10);/i],[ot,[rt,g9]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[ot,[rt,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[ot,[rt,$b+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[ot,[rt,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[ot,[rt,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[rt,"Chrome OS"],ot],[/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],[rt,ot],[/(sunos) ?([\w\.\d]*)/i],[[rt,"Solaris"],ot],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[rt,ot]]},Jw=function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return Ac.call(e.init,[[rs,[rt,ot,Tb,nt]],[Cc,[Oa]],[yu,[nt,st,vt]],[Ec,[rt,ot]],[Rs,[rt,ot]]]),Ac.call(e.isIgnore,[[rs,[ot,Tb]],[Ec,[ot]],[Rs,[ot]]]),Ac.call(e.isIgnoreRgx,[[rs,/ ?browser$/i],[Rs,/ ?os$/i]]),Ac.call(e.toString,[[rs,[rt,ot]],[Cc,[Oa]],[yu,[vt,st]],[Ec,[rt,ot]],[Rs,[rt,ot]]]),e}(),Dne=function(e,t){var n=Jw.init[t],r=Jw.isIgnore[t]||0,o=Jw.isIgnoreRgx[t]||0,s=Jw.toString[t]||0;function u(){Ac.call(this,n)}return u.prototype.getItem=function(){return e},u.prototype.withClientHints=function(){return ld?ld.getHighEntropyValues(h9).then(function(d){return e.setCH(new A9(d,!1)).parseCH().get()}):e.parseCH().get()},u.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=km&&(u.prototype.is=function(d){var h=!1;for(var m in this)if(this.hasOwnProperty(m)&&!CR(r,m)&&kc(o?Yh(o,this[m]):this[m])==kc(o?Yh(o,d):d)){if(h=!0,d!=od)break}else if(d==od&&h){h=!h;break}return h},u.prototype.toString=function(){var d=Sm;for(var h in s)typeof this[s[h]]!==od&&(d+=(d?" ":Sm)+this[s[h]]);return d||od}),ld||(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 A9(e,t){if(e=e||{},Ac.call(this,h9),t)Ac.call(this,[[vR,ER(e[ad])],[yR,ER(e[Sne])],[yn,/\?1/.test(e[kne])],[st,Nb(e[Ane])],[Em,Nb(e[d9])],[bR,Nb(e[Tne])],[Oa,Nb(e[wne])],[Gh,ER(e[Ene])],[Yw,Nb(e[Cne])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==od&&(this[n]=e[n])}function T9(e,t,n,r){return this.get=function(o){return o?this.data.hasOwnProperty(o)?this.data[o]:void 0:this.data},this.set=function(o,s){return this.data[o]=s,this},this.setCH=function(o){return this.uaCH=o,this},this.detectFeature=function(){if(Ra&&Ra.userAgent==this.ua)switch(this.itemType){case rs:Ra.brave&&typeof Ra.brave.isBrave==Vw&&this.set(rt,"Brave");break;case yu:!this.get(nt)&&ld&&ld[yn]&&this.set(nt,yn),this.get(st)=="Macintosh"&&Ra&&typeof Ra.standalone!==od&&Ra.maxTouchPoints&&Ra.maxTouchPoints>2&&this.set(st,"iPad").set(nt,Zr);break;case Rs:!this.get(rt)&&ld&&ld[Em]&&this.set(rt,ld[Em]);break;case km:var o=this.data,s=function(u){return o[u].getItem().detectFeature().get()};this.set(rs,s(rs)).set(Cc,s(Cc)).set(yu,s(yu)).set(Ec,s(Ec)).set(Rs,s(Rs))}return this},this.parseUA=function(){return this.itemType!=km&&w9.call(this.data,this.ua,this.rgxMap),this.itemType==rs&&this.set(Tb,kR(this.get(ot))),this},this.parseCH=function(){var o=this.uaCH,s=this.rgxMap;switch(this.itemType){case rs:var u=o[yR]||o[vR],d;if(u)for(var h in u){var m=Yh(/(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(rt,m).set(ot,y).set(Tb,kR(y)),d=m)}break;case Cc:var v=o[Oa];v&&(v&&o[Yw]=="64"&&(v+="64"),w9.call(this.data,v+";",s));break;case yu:if(o[yn]&&this.set(nt,yn),o[st]&&this.set(st,o[st]),o[st]=="Xbox"&&this.set(nt,Cm).set(vt,Qw),o[Gh]){var x;if(typeof o[Gh]!="string")for(var w=0;!x&&w<o[Gh].length;)x=zb(o[Gh][w++],E9);else x=zb(o[Gh],E9);this.set(nt,x)}break;case Rs:var E=o[Em];if(E){var M=o[bR];E==wR&&(M=parseInt(kR(M),10)>=13?"11":"10"),this.set(rt,E).set(ot,M)}this.get(rt)==wR&&o[st]=="Xbox"&&this.set(rt,"Xbox").set(ot,void 0);break;case km:var A=this.data,k=function(R){return A[R].getItem().setCH(o).parseCH().get()};this.set(rs,k(rs)).set(Cc,k(Cc)).set(yu,k(yu)).set(Ec,k(Ec)).set(Rs,k(Rs))}return this},Ac.call(this,[["itemType",e],["ua",t],["uaCH",r],["rgxMap",n],["data",Dne(this,e)]]),this}function Tc(e,t,n){if(typeof e===wm?(Ww(e,!0)?(typeof t===wm&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===hR&&!Ww(t,!0)&&(n=t,t=void 0),n&&typeof n.append===Vw){var r={};n.forEach(function(h,m){r[m]=h}),n=r}if(!(this instanceof Tc))return new Tc(e,t,n).getResult();var o=typeof e===hR?e:n&&n[f9]?n[f9]:Ra&&Ra.userAgent?Ra.userAgent:Sm,s=new A9(n,!0),u=t?Ine(k9,t):k9,d=function(h){return h==km?function(){return new T9(h,o,u,s).set("ua",o).set(rs,this.getBrowser()).set(Cc,this.getCPU()).set(yu,this.getDevice()).set(Ec,this.getEngine()).set(Rs,this.getOS()).get()}:function(){return new T9(h,o,u[h],s).parseUA().get()}};return Ac.call(this,[["getBrowser",d(rs)],["getCPU",d(Cc)],["getDevice",d(yu)],["getEngine",d(Ec)],["getOS",d(Rs)],["getResult",d(km)],["getUA",function(){return o}],["setUA",function(h){return Tm(h)&&(o=h.length>mR?Bb(h,mR):h),this}]]).setUA(o),this}Tc.VERSION=xne,Tc.BROWSER=Xw([rt,ot,Tb,nt]),Tc.CPU=Xw([Oa]),Tc.DEVICE=Xw([st,vt,nt,Cm,yn,Ho,Zr,Mb,gR]),Tc.ENGINE=Tc.OS=Xw([rt,ot]);const Ds=class Ds{constructor(t){oo(this,"config");oo(this,"storedData");oo(this,"deviceInfo");oo(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){Ds.instance||(Ds.instance=new Ds(t))}static getInstance(){if(!Ds.instance)throw new Error("DebalesAnalytics is not initialized. Call init() first.");return Ds.instance}static async identify(t,n){return Ds.getInstance().identifyInternal(t,n)}static track(t,n){Ds.getInstance().trackInternal(t,n)}static getDistinctId(){return Ds.getInstance().storedData.distinctId}static getAnonId(){return Ds.getInstance().storedData.anonId}async identifyInternal(t,n){try{if(this.config.testing&&this.config.testing())return;let r,o,s;if(n){const{name:h,phone:m,...y}=n;r=h,o=m,s=y}const u={distinctId:this.storedData.distinctId,anonId:[this.storedData.anonId],projectName:this.config.projectName,email:t,name:r,phone:o,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:tr()+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(`${ci}${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 Tc().getResult();return{browser:n.browser.name,os:n.os.name,browserVersion:n.browser.version,osVersion:n.os.version}}};oo(Ds,"instance",null);let AR=Ds;const bu=AR;function $ne(e){D$(e,[/\r?\n|\r/g,Lne])}function Lne(){return{type:"break"}}function eC(){return function(e){$ne(e)}}const Gt={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"},fr={OPEN_STATE_CHANGE:"open_state_change"},tC=e=>{window.DebalesChat||(window.DebalesChat={isOpen:!1,projectId:e,getSessionId:()=>tr(),getChatId:()=>tr()+"_"+e,getAnonId:()=>bu.getAnonId(),isIdentified:()=>{if(ks._isIdentified())return!0;const t=bo();return!!(t&&t.email)},getIdentifiedUser:()=>bo(),getDistinctId:()=>ks.get_distinct_id(),getOldDistinctId:()=>bu.getDistinctId(),debug:!1,identify:(t,n)=>{ks._isIdentified()||ks.identify(t,{...n,project:e}),bu.identify(t,n),wc({email:t,name:n==null?void 0:n.name,phone:n==null?void 0:n.phone})},track:(t,n)=>{bu.track(t,{...n,sessionId:window.DebalesChat.getSessionId()}),ks.capture(t,{...n}),yne(t,{...n,sessionId:tr(),projectId:e})},onOpenChange:t=>{const n=r=>{t(r.detail.isOpen)};return window.addEventListener(fr.OPEN_STATE_CHANGE,n),()=>window.removeEventListener(fr.OPEN_STATE_CHANGE,n)},removeOpenChangeListener:t=>{const n=r=>{t(r.detail.isOpen)};window.removeEventListener(fr.OPEN_STATE_CHANGE,n)},open:()=>{window.DebalesChat.isOpen||window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:!0,projectId:e}}))},close:()=>{window.DebalesChat.isOpen&&window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:!1,projectId:e}}))},toggle:()=>{window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:!window.DebalesChat.isOpen,projectId:e}}))}})};var xo=(e=>(e.DEFAULT="DEFAULT",e.SHOPIFY="SHOPIFY",e.WOOCOMMERCE="WOOCOMMERCE",e.MAGENTO="MAGENTO",e.UNKNOWN="UNKNOWN",e))(xo||{});class ud{static detect(){var t,n,r,o,s,u;if(typeof window<"u"&&window.Shopify!==void 0&&window.Shopify.routes!==void 0)return xo.SHOPIFY;if(typeof window<"u"&&document.body.classList.contains("woocommerce"))return xo.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 xo.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")||(o=v.getAttribute("data-requiremodule"))!=null&&o.startsWith("Magento"))return xo.MAGENTO;if(document.cookie.split(";").some(v=>v.trim().startsWith("mage-")||v.trim().startsWith("form_key")))return xo.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 xo.MAGENTO}return xo.UNKNOWN}}const nC=V.button`
117
+ `);var t="",n,r,o=0,s;for(n=r=0,o=e.length,s=0;s<o;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},z.UUID=function(){try{return Rt.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]="-",z.map(e,function(r){return r.toString(16)}).join("")}};var m8=["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"];z.isBlockedUA=function(e){var t;for(e=e.toLowerCase(),t=0;t<m8.length;t++)if(e.indexOf(m8[t])!==-1)return!0;return!1},z.HTTPBuildQuery=function(e,t){var n,r,o=[];return z.isUndefined(t)&&(t="&"),z.each(e,function(s,u){n=encodeURIComponent(s.toString()),r=encodeURIComponent(u),o[o.length]=r+"="+n}),o.join(t)},z.getQueryParam=function(e,t){t=t.replace(/[[]/g,"\\[").replace(/[\]]/g,"\\]");var n="[\\?&]"+t+"=([^&#]*)",r=new RegExp(n),o=r.exec(e);if(o===null||o&&typeof o[1]!="string"&&o[1].length)return"";var s=o[1];try{s=decodeURIComponent(s)}catch{er.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},z.cookie={get:function(e){for(var t=e+"=",n=cr.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];o.charAt(0)==" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return decodeURIComponent(o.substring(t.length,o.length))}return null},parse:function(e){var t;try{t=z.JSONDecode(z.cookie.get(e))||{}}catch{}return t},set_seconds:function(e,t,n,r,o,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=b8(cr.location.hostname);d=y?"; domain=."+y:""}if(n){var v=new Date;v.setTime(v.getTime()+n*1e3),h="; expires="+v.toGMTString()}s&&(o=!0,m="; SameSite=None"),o&&(m+="; secure"),cr.cookie=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m},set:function(e,t,n,r,o,s,u){var d="",h="",m="";if(u)d="; domain="+u;else if(r){var y=b8(cr.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&&(o=!0,m="; SameSite=None"),o&&(m+="; secure");var x=e+"="+encodeURIComponent(t)+h+"; path=/"+d+m;return cr.cookie=x,x},remove:function(e,t,n){z.cookie.set(e,"",-1,t,!1,!1,n)}};var v8=function(e){var t=!0;try{var n="__mplss_"+jO(8),r="xyz";e.setItem(n,r),e.getItem(n)!==r&&(t=!1),e.removeItem(n)}catch{t=!1}return t},zO=null,_b=function(e,t){return zO!==null&&!t?zO:zO=v8(e||Rt.localStorage)},UO=null,bte=function(e,t){return UO!==null&&!t?UO:UO=v8(e||Rt.sessionStorage)};function y8(e,t,n){var r=function(o){er.error(t+" error: "+o)};return{is_supported:function(o){var s=n(e,o);return s||er.error(t+" unsupported"),s},error:r,get:function(o){try{return e.getItem(o)}catch(s){r(s)}return null},parse:function(o){try{return z.JSONDecode(e.getItem(o))||{}}catch{}return null},set:function(o,s){try{e.setItem(o,s)}catch(u){r(u)}},remove:function(o){try{e.removeItem(o)}catch(s){r(s)}}}}z.localStorage=y8(Rt.localStorage,"localStorage",_b),z.sessionStorage=y8(Rt.sessionStorage,"sessionStorage",bte),z.register_event=function(){var e=function(r,o,s,u,d){if(!r){er.error("No valid element provided to register_event");return}if(r.addEventListener&&!u)r.addEventListener(o,s,!!d);else{var h="on"+o,m=r[h];r[h]=t(r,s,m)}};function t(r,o,s){var u=function(d){if(d=d||n(Rt.event),!!d){var h=!0,m,y;return z.isFunction(s)&&(m=s(d)),y=o.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 _te=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');z.dom_query=function(){function e(o){return o.all?o.all:o.getElementsByTagName("*")}var t=/[\t\r\n]/g;function n(o,s){var u=" "+s+" ";return(" "+o.className+" ").replace(t," ").indexOf(u)>=0}function r(o){if(!cr.getElementsByTagName)return[];var s=o.split(" "),u,d,h,m,y,v,x,w,E,M,A=[cr];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 k=d[1],R=cr.getElementById(k);if(!R||h&&R.nodeName.toLowerCase()!=h)return[];A=[R];continue}if(u.indexOf(".")>-1){d=u.split("."),h=d[0];var D=d[1];for(h||(h="*"),m=[],y=0,x=0;x<A.length;x++)for(h=="*"?E=e(A[x]):E=A[x].getElementsByTagName(h),w=0;w<E.length;w++)m[y++]=E[w];for(A=[],M=0,x=0;x<m.length;x++)m[x].className&&z.isString(m[x].className)&&n(m[x],D)&&(A[M++]=m[x]);continue}var B=u.match(_te);if(B){h=B[1];var L=B[2],H=B[3],K=B[4];for(h||(h="*"),m=[],y=0,x=0;x<A.length;x++)for(h=="*"?E=e(A[x]):E=A[x].getElementsByTagName(h),w=0;w<E.length;w++)m[y++]=E[w];A=[],M=0;var ee;switch(H){case"=":ee=function(J){return J.getAttribute(L)==K};break;case"~":ee=function(J){return J.getAttribute(L).match(new RegExp("\\b"+K+"\\b"))};break;case"|":ee=function(J){return J.getAttribute(L).match(new RegExp("^"+K+"-?"))};break;case"^":ee=function(J){return J.getAttribute(L).indexOf(K)===0};break;case"$":ee=function(J){return J.getAttribute(L).lastIndexOf(K)==J.getAttribute(L).length-K.length};break;case"*":ee=function(J){return J.getAttribute(L).indexOf(K)>-1};break;default:ee=function(J){return J.getAttribute(L)}}for(A=[],M=0,x=0;x<m.length;x++)ee(m[x])&&(A[M++]=m[x]);continue}for(h=u,m=[],y=0,x=0;x<A.length;x++)for(E=A[x].getElementsByTagName(h),w=0;w<E.length;w++)m[y++]=E[w];A=m}return A}return function(o){return z.isElement(o)?[o]:z.isObject(o)&&!z.isUndefined(o.length)?o:r.call(this,o)}}();var xte=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","utm_id","utm_source_platform","utm_campaign_id","utm_creative_format","utm_marketing_tactic"],Ste=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","sccid","ttclid","twclid","wbraid"];z.info={campaignParams:function(e){var t="",n={};return z.each(xte,function(r){t=z.getQueryParam(cr.URL,r),t.length?n[r]=t:e!==void 0&&(n[r]=e)}),n},clickParams:function(){var e="",t={};return z.each(Ste,function(n){e=z.getQueryParam(cr.URL,n),e.length&&(t[n]=e)}),t},marketingParams:function(){return z.extend(z.info.campaignParams(),z.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=z.info.searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(t!==null){r.$search_engine=t;var o=z.getQueryParam(e,n);o.length&&(r.mp_keyword=o)}return r},browser:function(e,t,n){return t=t||"",n||z.includes(e," OPR/")?z.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":z.includes(e,"IEMobile")||z.includes(e,"WPDesktop")?"Internet Explorer Mobile":z.includes(e,"SamsungBrowser/")?"Samsung Internet":z.includes(e,"Edge")||z.includes(e,"Edg/")?"Microsoft Edge":z.includes(e,"FBIOS")?"Facebook Mobile":z.includes(e,"Chrome")?"Chrome":z.includes(e,"CriOS")?"Chrome iOS":z.includes(e,"UCWEB")||z.includes(e,"UCBrowser")?"UC Browser":z.includes(e,"FxiOS")?"Firefox iOS":z.includes(t,"Apple")?z.includes(e,"Mobile")?"Mobile Safari":"Safari":z.includes(e,"Android")?"Android Mobile":z.includes(e,"Konqueror")?"Konqueror":z.includes(e,"Firefox")?"Firefox":z.includes(e,"MSIE")||z.includes(e,"Trident/")?"Internet Explorer":z.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,n){var r=z.info.browser(e,t,n),o={"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=o[r];if(s===void 0)return null;var u=e.match(s);return u?parseFloat(u[u.length-2]):null},os:function(){var e=bc;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 Rt.location.href},properties:function(e){return typeof e!="object"&&(e={}),z.extend(z.strip_empty_properties({$os:z.info.os(),$browser:z.info.browser(bc,Jf.vendor,Lw),$referrer:cr.referrer,$referring_domain:z.info.referringDomain(cr.referrer),$device:z.info.device(bc)}),{$current_url:z.info.currentUrl(),$browser_version:z.info.browserVersion(bc,Jf.vendor,Lw),$screen_height:d8.height,$screen_width:d8.width,mp_lib:"web",$lib_version:Al.LIB_VERSION,$insert_id:jO(),time:z.timestamp()/1e3},z.strip_empty_properties(e))},people_properties:function(){return z.extend(z.strip_empty_properties({$os:z.info.os(),$browser:z.info.browser(bc,Jf.vendor,Lw)}),{$browser_version:z.info.browserVersion(bc,Jf.vendor,Lw)})},mpPageViewProperties:function(){return z.strip_empty_properties({current_page_title:cr.title,current_domain:Rt.location.hostname,current_url_path:Rt.location.pathname,current_url_protocol:Rt.location.protocol,current_url_search:Rt.location.search})}};var wte=function(e,t){var n=null,r=[];return function(o){var s=this;return r.push(o),n||(n=new ir(function(u){setTimeout(function(){var d=e.apply(s,[r]);n=null,r=[],u(d)},t)})),n}},jO=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},Cte=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,Ete=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,b8=function(e){var t=Ete,n=e.split("."),r=n[n.length-1];(r.length>4||r==="com"||r==="org")&&(t=Cte);var o=e.match(t);return o?o[0]:""},kte=function(){var e=Rt.navigator.onLine;return z.isUndefined(e)||e},ed=function(){},hm=null,Nw=null;typeof JSON<"u"&&(hm=JSON.stringify,Nw=JSON.parse),hm=hm||z.JSONEncode,Nw=Nw||z.JSONDecode,z.info=z.info,z.info.browser=z.info.browser,z.info.browserVersion=z.info.browserVersion,z.info.device=z.info.device,z.info.properties=z.info.properties,z.isBlockedUA=z.isBlockedUA,z.isEmptyObject=z.isEmptyObject,z.isObject=z.isObject,z.JSONDecode=z.JSONDecode,z.JSONEncode=z.JSONEncode,z.toArray=z.toArray,z.NPO=Xf;var Ate="mixpanelBrowserDb",_8="mixpanelRecordingEvents",HO="mixpanelRecordingRegistry",Tte=1,Mte=[_8,HO],pu=function(e){this.dbPromise=null,this.storeName=e};pu.prototype._openDb=function(){return new ir(function(e,t){var n=Rt.indexedDB.open(Ate,Tte);n.onerror=function(){t(n.error)},n.onsuccess=function(){e(n.result)},n.onupgradeneeded=function(r){var o=r.target.result;Mte.forEach(function(s){o.createObjectStore(s)})}})},pu.prototype.init=function(){return Rt.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof Rt.IDBDatabase?ir.resolve():ir.reject(e)})):ir.reject("indexedDB is not supported in this browser")},pu.prototype.makeTransaction=function(e,t){var n=this.storeName,r=function(o){return new ir(function(s,u){var d=o.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(o){return o&&o.name==="InvalidStateError"?(this.dbPromise=this._openDb(),this.dbPromise.then(r)):ir.reject(o)}).bind(this))},pu.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(n){n.put(t,e)})},pu.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},pu.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},pu.prototype.getAll=function(){var e;return this.makeTransaction("readonly",function(t){e=t.getAll()}).then(function(){return e.result})};var Ote="__mp_opt_in_out_";function Rte(e,t){w8(!0,e,t)}function Ite(e,t){w8(!1,e,t)}function Dte(e,t){return S8(e,t)==="1"}function x8(e,t){if(Lte(t))return er.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=S8(e,t)==="0";return n&&er.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),n}function td(e){return FO(e,function(t){return this.get_config(t)})}function nd(e){return FO(e,function(t){return this._get_config(t)})}function pm(e){return FO(e,function(t){return this._get_config(t)})}function $te(e,t){t=t||{},qO(t).remove(PO(e,t),!!t.crossSubdomainCookie,t.cookieDomain)}function qO(e){return e=e||{},e.persistenceType==="localStorage"?z.localStorage:z.cookie}function PO(e,t){return t=t||{},(t.persistencePrefix||Ote)+e}function S8(e,t){return qO(t).get(PO(e,t))}function Lte(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||Rt,n=t.navigator||{},r=!1;return z.each([n.doNotTrack,n.msDoNotTrack,t.doNotTrack],function(o){z.includes([!0,1,"1","yes"],o)&&(r=!0)}),r}function w8(e,t,n){if(!z.isString(t)||!t.length){er.error("gdpr."+(e?"optIn":"optOut")+" called with an invalid token");return}n=n||{},qO(n).set(PO(t,n),e?1:0,z.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 FO(e,t){return function(){var n=!1;try{var r=t.call(this,"token"),o=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=x8(r,{ignoreDnt:o,persistenceType:s,persistencePrefix:u,window:d}))}catch(m){er.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 Nte=dm("lock"),C8=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||Rt.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||ir};C8.prototype.withLock=function(e,t){var n=this.promiseImpl;return new n(z.bind(function(r,o){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",x=d+":Y",w=d+":Z",E=function(D){if(new Date().getTime()-u>m){Nte.error("Timeout waiting for mutex on "+d+"; clearing lock. ["+s+"]"),y.removeItem(w),y.removeItem(x),k();return}setTimeout(function(){try{D()}catch(B){o(B)}},h*(Math.random()+.1))},M=function(D,B){D()?B():E(function(){M(D,B)})},A=function(){var D=y.getItem(x);return D&&D!==s?!1:(y.setItem(x,s),y.getItem(x)===s?!0:(_b(y,!0)||o(new Error("localStorage support dropped while acquiring lock")),!1))},k=function(){y.setItem(v,s),M(A,function(){if(y.getItem(v)===s){R();return}E(function(){if(y.getItem(x)!==s){k();return}M(function(){return!y.getItem(w)},R)})})},R=function(){y.setItem(w,"1");var D=function(){y.removeItem(w),y.getItem(x)===s&&y.removeItem(x),y.getItem(v)===s&&y.removeItem(v)};e().then(function(B){D(),r(B)}).catch(function(B){D(),o(B)})};try{if(_b(y,!0))k();else throw new Error("localStorage support check failed")}catch(D){o(D)}},this))};var xb=function(e){this.storage=e||Rt.localStorage};xb.prototype.init=function(){return ir.resolve()},xb.prototype.setItem=function(e,t){return new ir(z.bind(function(n,r){try{this.storage.setItem(e,hm(t))}catch(o){r(o)}n()},this))},xb.prototype.getItem=function(e){return new ir(z.bind(function(t,n){var r;try{r=Nw(this.storage.getItem(e))}catch(o){n(o)}t(r)},this))},xb.prototype.removeItem=function(e){return new ir(z.bind(function(t,n){try{this.storage.removeItem(e)}catch(r){n(r)}t()},this))};var E8=dm("batch"),gu=function(e,t){t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new xb,this.lock=new C8(e,{storage:t.sharedLockStorage||Rt.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||z.bind(E8.error,E8),this.pid=t.pid||null,this.memQueue=[],this.initialized=!1,t.enqueueThrottleMs?this.enqueuePersisted=wte(z.bind(this._enqueuePersisted,this),t.enqueueThrottleMs):this.enqueuePersisted=z.bind(function(n){return this._enqueuePersisted([n])},this)};gu.prototype.ensureInit=function(){return this.initialized?ir.resolve():this.queueStorage.init().then(z.bind(function(){this.initialized=!0},this)).catch(z.bind(function(e){this.reportError("Error initializing queue persistence. Disabling persistence",e),this.initialized=!0,this.usePersistence=!1},this))},gu.prototype.enqueue=function(e,t){var n={id:jO(),flushAfter:new Date().getTime()+t*2,payload:e};return this.usePersistence?this.enqueuePersisted(n):(this.memQueue.push(n),ir.resolve(!0))},gu.prototype._enqueuePersisted=function(e){var t=z.bind(function(){return this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(n){return this.saveToStorage(n.concat(e))},this)).then(z.bind(function(n){return n&&(this.memQueue=this.memQueue.concat(e)),n},this)).catch(z.bind(function(n){return this.reportError("Error enqueueing items",n,e),!1},this))},this);return this.lock.withLock(t,this.pid).catch(z.bind(function(n){return this.reportError("Error acquiring storage lock",n),!1},this))},gu.prototype.fillBatch=function(e){var t=this.memQueue.slice(0,e);return this.usePersistence&&t.length<e?this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(n){if(n.length){var r={};z.each(t,function(u){r[u.id]=!0});for(var o=0;o<n.length;o++){var s=n[o];if(new Date().getTime()>s.flushAfter&&!r[s.id]&&(s.orphaned=!0,t.push(s),t.length>=e))break}}return t},this)):ir.resolve(t)};var k8=function(e,t){var n=[];return z.each(e,function(r){r.id&&!t[r.id]&&n.push(r)}),n};gu.prototype.removeItemsByID=function(e){var t={};if(z.each(e,function(r){t[r]=!0}),this.memQueue=k8(this.memQueue,t),this.usePersistence){var n=z.bind(function(){return this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(r){return r=k8(r,t),this.saveToStorage(r)},this)).then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(r){for(var o=0;o<r.length;o++){var s=r[o];if(s.id&&t[s.id])throw new Error("Item not removed from storage")}return!0},this)).catch(z.bind(function(r){return this.reportError("Error removing items",r,e),!1},this))},this);return this.lock.withLock(n,this.pid).catch(z.bind(function(r){return this.reportError("Error acquiring storage lock",r),_b(this.lock.storage,!0)?!1:n().then(z.bind(function(o){return o||this.queueStorage.removeItem(this.storageKey).then(function(){return o})},this)).catch(z.bind(function(o){return this.reportError("Error clearing queue",o),!1},this))},this))}else return ir.resolve(!0)};var A8=function(e,t){var n=[];return z.each(e,function(r){var o=r.id;if(o in t){var s=t[o];s!==null&&(r.payload=s,n.push(r))}else n.push(r)}),n};gu.prototype.updatePayloads=function(e){return this.memQueue=A8(this.memQueue,e),this.usePersistence?this.lock.withLock(z.bind(function(){return this.ensureInit().then(z.bind(function(){return this.readFromStorage()},this)).then(z.bind(function(n){return n=A8(n,e),this.saveToStorage(n)},this)).catch(z.bind(function(n){return this.reportError("Error updating items",e,n),!1},this))},this),this.pid).catch(z.bind(function(t){return this.reportError("Error acquiring storage lock",t),!1},this)):ir.resolve(!0)},gu.prototype.readFromStorage=function(){return this.ensureInit().then(z.bind(function(){return this.queueStorage.getItem(this.storageKey)},this)).then(z.bind(function(e){return e&&(z.isArray(e)||(this.reportError("Invalid storage entry:",e),e=null)),e||[]},this)).catch(z.bind(function(e){return this.reportError("Error retrieving queue",e),[]},this))},gu.prototype.saveToStorage=function(e){return this.ensureInit().then(z.bind(function(){return this.queueStorage.setItem(this.storageKey,e)},this)).then(function(){return!0}).catch(z.bind(function(t){return this.reportError("Error saving queue",t),!1},this))},gu.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(z.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):ir.resolve()};var Bte=10*60*1e3,Sb=dm("batch"),Ms=function(e,t){this.errorReporter=t.errorReporter,this.queue=new gu(e,{errorReporter:z.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};Ms.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},Ms.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},Ms.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},Ms.prototype.clear=function(){return this.queue.clear()},Ms.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},Ms.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},Ms.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(z.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},Ms.prototype.sendRequestPromise=function(e,t){return new ir(z.bind(function(n){this.sendRequest(e,t,n)},this))},Ms.prototype.flush=function(e){if(this.requestInProgress)return Sb.log("Flush: Request already in progress"),ir.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(z.bind(function(o){var s=o.length===r,u=[],d={};if(z.each(o,function(v){var x=v.payload;if(this.beforeSendHook&&!v.orphaned&&(x=this.beforeSendHook(x)),x){x.event&&x.properties&&(x.properties=z.extend({},x.properties,{mp_sent_by_lib_version:Al.LIB_VERSION}));var w=!0,E=v.id;E?(this.itemIdsSentSuccessfully[E]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:v,batchSize:o.length,timesSent:this.itemIdsSentSuccessfully[E]}),w=!1):this.reportError("[dupe] found item with no ID",{item:v}),w&&u.push(x)}d[v.id]=x},this),u.length<1)return this.requestInProgress=!1,this.resetFlush(),ir.resolve();var h=z.bind(function(){return this.queue.removeItemsByID(z.map(o,function(v){return v.id})).then(z.bind(function(v){return z.each(o,z.bind(function(x){var w=x.id;w?(this.itemIdsSentSuccessfully[w]=this.itemIdsSentSuccessfully[w]||0,this.itemIdsSentSuccessfully[w]++,this.itemIdsSentSuccessfully[w]>5&&this.reportError("[dupe] item ID sent too many times",{item:x,batchSize:o.length,timesSent:this.itemIdsSentSuccessfully[w]})):this.reportError("[dupe] found item with no ID while removing",{item:x})},this)),v?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!s?(this.resetFlush(),ir.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),ir.resolve())},this))},this),m=z.bind(function(v){this.requestInProgress=!1;try{if(e.unloading)return this.queue.updatePayloads(d);if(z.isObject(v)&&v.error==="timeout"&&new Date().getTime()-n>=t)return this.reportError("Network timeout; retrying"),this.flush();if(z.isObject(v)&&(v.httpStatusCode>=500||v.httpStatusCode===429||v.httpStatusCode<=0&&!kte()||v.error==="timeout")){var x=this.flushInterval*2;return v.retryAfter&&(x=parseInt(v.retryAfter,10)*1e3||x),x=Math.min(Bte,x),this.reportError("Error; retry in "+x+" ms"),this.scheduleFlush(x),ir.resolve()}else if(z.isObject(v)&&v.httpStatusCode===413)if(o.length>1){var w=Math.max(1,Math.floor(r/2));return this.batchSize=Math.min(this.batchSize,w,o.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush(),ir.resolve()}else return this.reportError("Single-event request too large; dropping",o),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"),Sb.log("MIXPANEL REQUEST:",u),this.sendRequestPromise(u,y).then(m)},this)).catch(z.bind(function(o){this.reportError("Error flushing request queue",o),this.resetFlush()},this))},Ms.prototype.reportError=function(e,t){if(Sb.error.apply(Sb.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(n){Sb.error(n)}};var GO=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},zte=250,gm=dm("recorder"),T8=Rt.CompressionStream,Ute={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},jte=new Set([on.MouseMove,on.MouseInteraction,on.Scroll,on.ViewportResize,on.Input,on.TouchMove,on.MediaInteraction,on.Drag,on.Selection]);function Hte(e){return e.type===jn.IncrementalSnapshot&&jte.has(e.data.source)}var zo=function(e){this._mixpanel=e.mixpanelInstance,this._onIdleTimeout=e.onIdleTimeout||ed,this._onMaxLengthReached=e.onMaxLengthReached||ed,this._onBatchSent=e.onBatchSent||ed,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=yb,this.recordMinMs=0;var t=_b(e.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new pu(_8),this.batcher=new Ms(this.batcherKey,{errorReporter:this.reportError.bind(this),flushOnlyOnInterval:!0,libConfig:Ute,sendRequestFunc:this.flushEventsWithOptOut.bind(this),queueStorage:this.queueStorage,sharedLockStorage:e.sharedLockStorage,usePersistence:t,stopAllBatchingFunc:this.stopRecording.bind(this),enqueueThrottleMs:zte,sharedLockTimeoutMS:10*1e3})};zo.prototype.unloadPersistedData=function(){return this.batcher.stop(),this.batcher.flush().then((function(){return this.queueStorage.removeItem(this.batcherKey)}).bind(this))},zo.prototype.getConfig=function(e){return this._mixpanel.get_config(e)},zo.prototype.get_config=function(e){return this.getConfig(e)},zo.prototype.startRecording=function(e){if(this._rrwebRecord===null){this.reportError("rrweb record function not provided. ");return}if(this._stopRecording!==null){gm.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>yb&&(this.recordMaxMs=yb,gm.critical("record_max_ms cannot be greater than "+yb+"ms. Capping value.")),this.maxExpires||(this.maxExpires=new Date().getTime()+this.recordMaxMs),this.recordMinMs=this.getConfig("record_min_ms"),this.recordMinMs>DO&&(this.recordMinMs=DO,gm.critical("record_min_ms cannot be greater than "+DO+"ms. Capping value.")),this.replayStartTime||(this.replayStartTime=new Date().getTime(),this.batchStartUrl=z.info.currentUrl(),this.replayStartUrl=z.info.currentUrl()),e||this.recordMinMs>0?this.batcher.stop():this.batcher.start();var t=(function(){clearTimeout(this.idleTimeoutId);var o=this.getConfig("record_idle_timeout_ms");this.idleTimeoutId=setTimeout(this._onIdleTimeout,o),this.idleExpires=new Date().getTime()+o}).bind(this);t();var n=this.getConfig("record_block_selector");(n===""||n===null)&&(n=void 0);try{this._stopRecording=this._rrwebRecord({emit:(function(o){if(this.idleExpires&&this.idleExpires<o.timestamp){this._onIdleTimeout();return}Hte(o)&&(this.batcher.stopped&&new Date().getTime()-this.replayStartTime>=this.recordMinMs&&this.batcher.start(),t()),this.__enqueuePromise=this.batcher.enqueue(o)}).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(o){this.reportError("Unexpected error when starting rrweb recording.",o)}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)},zo.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},zo.prototype.isRrwebStopped=function(){return this._stopRecording===null},zo.prototype.flushEventsWithOptOut=function(e,t,n){var r=(function(o){o===0&&(this.stopRecording(),n({error:"Tracking has been opted out, stopping recording."}))}).bind(this);this._flushEvents(e,t,n,r)},zo.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}},zo.deserialize=function(e,t){var n=new zo(z.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},zo.prototype._sendRequest=function(e,t,n,r){var o=(function(s,u){s.status===200&&this.replayId===e&&(this.seqNo++,this.batchStartUrl=z.info.currentUrl()),this._onBatchSent(),r({status:0,httpStatusCode:s.status,responseBody:u,retryAfter:s.headers.get("Retry-After")})}).bind(this);Rt.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){o(s,u)}).catch(function(u){r({error:u})})}).catch(function(s){r({error:s,httpStatusCode:0})})},zo.prototype._flushEvents=td(function(e,t,n){var r=e.length;if(r>0){for(var o=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===jn.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:Al.LIB_VERSION,batch_start_time:s/1e3,distinct_id:String(this._mixpanel.get_distinct_id()),mp_lib:"web",replay_id:o,replay_length_ms:m,replay_start_time:this.replayStartTime/1e3,replay_start_url:this.replayStartUrl,seq:this.seqNo},v=JSON.stringify(e),x=this._mixpanel.get_property("$device_id");x&&(y.$device_id=x);var w=this._mixpanel.get_property("$user_id");if(w&&(y.$user_id=w),T8){var E=new Blob([v],{type:"application/json"}).stream(),M=E.pipeThrough(new T8("gzip"));new Response(M).blob().then((function(A){y.format="gzip",this._sendRequest(o,y,A,n)}).bind(this))}else y.format="body",this._sendRequest(o,y,v,n)}}),zo.prototype.reportError=function(e,t){gm.error.apply(gm.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(n){gm.error(n)}};var mm=function(e){this.idb=new pu(HO),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};mm.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},mm.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."),ir.resolve())},mm.prototype.getActiveRecording=function(){return this.idb.init().then((function(){return this.idb.getItem(this.mixpanelInstance.get_tab_id())}).bind(this)).then((function(e){return GO(e)?null:e}).bind(this)).catch(this.handleError.bind(this))},mm.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))},mm.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 GO(n)}).map((function(n){var r=zo.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 ir.all(t)}).bind(this)).catch(this.handleError.bind(this))};var wb=dm("recorder"),_c=function(e,t,n){this.mixpanelInstance=e,this.rrwebRecord=t||Qf,this.sharedLockStorage=n,this.recordingRegistry=new mm({mixpanelInstance:this.mixpanelInstance,errorReporter:wb.error,sharedLockStorage:n}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null};_c.prototype.startRecording=function(e){if(e=e||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){wb.log("Recording already in progress, skipping startRecording.");return}var t=(function(){wb.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),n=(function(){wb.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),o={mixpanelInstance:this.mixpanelInstance,onBatchSent:r,onIdleTimeout:t,onMaxLengthReached:n,replayId:z.UUID(),rrwebRecord:this.rrwebRecord,sharedLockStorage:this.sharedLockStorage};return e.activeSerializedRecording?this.activeRecording=zo.deserialize(e.activeSerializedRecording,o):this.activeRecording=new zo(o),this.activeRecording.startRecording(e.shouldStopBatcher),this.recordingRegistry.setActiveRecording(this.activeRecording.serialize())},_c.prototype.stopRecording=function(){var e=this._stopCurrentRecording(!1);return this.recordingRegistry.clearActiveRecording(),this.activeRecording=null,e},_c.prototype.pauseRecording=function(){return this._stopCurrentRecording(!1)},_c.prototype._stopCurrentRecording=function(e){return this.activeRecording?this.activeRecording.stopRecording(e):ir.resolve()},_c.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),ir.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(t){return t?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):(wb.log("No resumable recording found."),null)}).bind(this))},_c.prototype.resetRecording=function(){this.stopRecording(),this.startRecording({shouldStopBatcher:!0})},_c.prototype.getActiveReplayId=function(){return this.activeRecording&&!this.activeRecording.isRrwebStopped()?this.activeRecording.replayId:null},Object.defineProperty(_c.prototype,"replayId",{get:function(){return this.getActiveReplayId()}}),Rt.__mp_recorder=_c;var Bw="change",Cb="click",M8="hashchange",vm="mp_locationchange",O8="popstate",R8="scrollend",VO="submit",qte=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],I8=["mp-include"],YO=["mp-no-track"],D8=YO.concat(["mp-sensitive"]),Pte=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],Ma=dm("autocapture");function ZO(e){for(var t={},n=$8(e).split(" "),r=0;r<n.length;r++){var o=n[r];o&&(t[o]=!0)}return t}function $8(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function Fte(e){if(e.previousElementSibling)return e.previousElementSibling;do e=e.previousSibling;while(e&&!B8(e));return e}function L8(e,t,n,r,o,s){var u={$classes:$8(e).split(" "),$tag_name:e.tagName.toLowerCase()},d=e.id;d&&(u.$id=d),XO(e,t,o,s)&&z.each(Pte.concat(r),function(v){if(e.hasAttribute(v)&&!n[v]){var x=e.getAttribute(v);zw(x)&&(u["$attr-"+v]=x)}});for(var h=1,m=1,y=e;y=Fte(y);)h++,y.tagName===e.tagName&&m++;return u.$nth_child=h,u.$nth_of_type=m,u}function Gte(e,t){var n=t.allowElementCallback,r=t.allowSelectors||[],o=t.blockAttrs||[],s=t.blockElementCallback,u=t.blockSelectors||[],d=t.captureTextContent||!1,h=t.captureExtraAttrs||[],m={};z.each(o,function(B){m[B]=!0});var y=null,v=typeof e.target>"u"?e.srcElement:e.target;if(z8(v)&&(v=v.parentNode),Zte(v,e)&&QO(v,e,n,r)&&!KO(v,e,s,u)){for(var x=[v],w=v;w.parentNode&&!mu(w,"body");)x.push(w.parentNode),w=w.parentNode;var E=[],M,A=!1;if(z.each(x,function(B){var L=XO(B,e,n,r);!m.href&&B.tagName.toLowerCase()==="a"&&(M=B.getAttribute("href"),M=L&&zw(M)&&M),KO(B,e,s,u)&&(A=!0),E.push(L8(B,e,m,h,n,r))},this),!A){var k=cr.documentElement;if(y={$event_type:e.type,$host:Rt.location.host,$pathname:Rt.location.pathname,$elements:E,$el_attr__href:M,$viewportHeight:Math.max(k.clientHeight,Rt.innerHeight||0),$viewportWidth:Math.max(k.clientWidth,Rt.innerWidth||0)},z.each(h,function(B){if(!m[B]&&v.hasAttribute(B)){var L=v.getAttribute(B);zw(L)&&(y["$el_attr__"+B]=L)}}),d&&(R=N8(v,e,n,r),R&&R.length&&(y.$el_text=R)),e.type===Cb&&(z.each(qte,function(B){B in e&&(y["$"+B]=e[B])}),v=Vte(e)),d){var R=N8(v,e,n,r);R&&R.length&&(y.$el_text=R)}if(v){if(!QO(v,e,n,r)||KO(v,e,s,u))return null;var D=L8(v,e,m,h,n,r);y.$target=D,y.$el_classes=D.$classes,z.extend(y,z.strip_empty_properties({$el_id:D.$id,$el_tag_name:D.$tag_name}))}}}return y}function N8(e,t,n,r){var o="";return XO(e,t,n,r)&&e.childNodes&&e.childNodes.length&&z.each(e.childNodes,function(s){z8(s)&&s.textContent&&(o+=z.trim(s.textContent).split(/(\s+)/).filter(zw).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),z.trim(o)}function Vte(e){for(var t=e.target,n=e.composedPath(),r=0;r<n.length;r++){var o=n[r];if(mu(o,"a")||mu(o,"button")||mu(o,"input")||mu(o,"select")||o.getAttribute&&o.getAttribute("role")==="button"){t=o;break}if(o===t)break}return t}function QO(e,t,n,r){if(n)try{if(!n(e,t))return!1}catch(u){return Ma.critical("Error while checking element in allowElementCallback",u),!1}if(!r.length)return!0;for(var o=0;o<r.length;o++){var s=r[o];try{if(e.matches(s))return!0}catch(u){Ma.critical("Error while checking selector: "+s,u)}}return!1}function KO(e,t,n,r){var o;if(n)try{if(n(e,t))return!0}catch(d){return Ma.critical("Error while checking element in blockElementCallback",d),!0}if(r&&r.length)for(o=0;o<r.length;o++){var s=r[o];try{if(e.matches(s))return!0}catch(d){Ma.critical("Error while checking selector: "+s,d)}}var u=ZO(e);for(o=0;o<YO.length;o++)if(u[YO[o]])return!0;return!1}function B8(e){return e&&e.nodeType===1}function mu(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function z8(e){return e&&e.nodeType===3}function Yte(){try{var e=cr.createElement("div");return!!e.matches}catch{return!1}}function Zte(e,t){if(!e||mu(e,"html")||!B8(e))return!1;var n=e.tagName.toLowerCase();switch(n){case"form":return t.type===VO;case"input":return["button","submit"].indexOf(e.getAttribute("type"))===-1?t.type===Bw:t.type===Cb;case"select":case"textarea":return t.type===Bw;default:return t.type===Cb}}function XO(e,t,n,r){var o;if(!QO(e,t,n,r))return!1;for(var s=e;s.parentNode&&!mu(s,"body");s=s.parentNode){var u=ZO(s);for(o=0;o<D8.length;o++)if(u[D8[o]])return!1}var d=ZO(e);for(o=0;o<I8.length;o++)if(d[I8[o]])return!0;if(mu(e,"input")||mu(e,"select")||mu(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 zw(e){if(e===null||z.isUndefined(e))return!1;if(typeof e=="string"){e=z.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 U8="autocapture",Qte="track_pageview",j8="full-url",Kte="url-with-path-and-query-string",Xte="url-with-path",Wte="allow_element_callback",H8="allow_selectors",q8="allow_url_regexes",P8="block_attrs",F8="block_element_callback",G8="block_selectors",V8="block_url_regexes",Y8="capture_extra_attrs",Z8="capture_text_content",Q8="scroll_capture_all",K8="scroll_depth_percent_checkpoints",WO="click",JO="input",X8="pageview",eR="scroll",tR="submit",yo={};yo[H8]=[],yo[q8]=[],yo[P8]=[],yo[F8]=null,yo[G8]=[],yo[V8]=[],yo[Y8]=[],yo[Z8]=!1,yo[Q8]=!1,yo[K8]=[25,50,75,100],yo[WO]=!0,yo[JO]=!0,yo[X8]=j8,yo[eR]=!0,yo[tR]=!0;var Uw={$mp_autocapture:!0},Jte="$mp_click",ene="$mp_input_change",tne="$mp_scroll",nne="$mp_submit",ns=function(e){this.mp=e};ns.prototype.init=function(){if(!Yte()){Ma.critical("Autocapture unavailable: missing required DOM APIs");return}this.initPageviewTracking(),this.initClickTracking(),this.initInputTracking(),this.initScrollTracking(),this.initSubmitTracking()},ns.prototype.getFullConfig=function(){var e=this.mp.get_config(U8);return e?z.isObject(e)?z.extend({},yo,e):yo:{}},ns.prototype.getConfig=function(e){return this.getFullConfig()[e]},ns.prototype.currentUrlBlocked=function(){var e,t=z.info.currentUrl(),n=this.getConfig(q8)||[];if(n.length){var r=!1;for(e=0;e<n.length;e++){var o=n[e];try{if(t.match(o)){r=!0;break}}catch(u){return Ma.critical("Error while checking block URL regex: "+o,u),!0}}if(!r)return!0}var s=this.getConfig(V8)||[];if(!s||!s.length)return!1;for(e=0;e<s.length;e++)try{if(t.match(s[e]))return!0}catch(u){return Ma.critical("Error while checking block URL regex: "+s[e],u),!0}return!1},ns.prototype.pageviewTrackingConfig=function(){return this.mp.get_config(U8)?this.getConfig(X8):this.mp.get_config(Qte)},ns.prototype.trackDomEvent=function(e,t){if(!this.currentUrlBlocked()){var n=Gte(e,{allowElementCallback:this.getConfig(Wte),allowSelectors:this.getConfig(H8),blockAttrs:this.getConfig(P8),blockElementCallback:this.getConfig(F8),blockSelectors:this.getConfig(G8),captureExtraAttrs:this.getConfig(Y8),captureTextContent:this.getConfig(Z8)});n&&(z.extend(n,Uw),this.mp.track(t,n))}},ns.prototype.initClickTracking=function(){Rt.removeEventListener(Cb,this.listenerClick),this.getConfig(WO)&&(Ma.log("Initializing click tracking"),this.listenerClick=Rt.addEventListener(Cb,(function(e){this.getConfig(WO)&&this.trackDomEvent(e,Jte)}).bind(this)))},ns.prototype.initInputTracking=function(){Rt.removeEventListener(Bw,this.listenerChange),this.getConfig(JO)&&(Ma.log("Initializing input tracking"),this.listenerChange=Rt.addEventListener(Bw,(function(e){this.getConfig(JO)&&this.trackDomEvent(e,ene)}).bind(this)))},ns.prototype.initPageviewTracking=function(){if(Rt.removeEventListener(O8,this.listenerPopstate),Rt.removeEventListener(M8,this.listenerHashchange),Rt.removeEventListener(vm,this.listenerLocationchange),!!this.pageviewTrackingConfig()){Ma.log("Initializing pageview tracking");var e="",t=!1;this.currentUrlBlocked()||(t=this.mp.track_pageview(Uw)),t&&(e=z.info.currentUrl()),this.listenerPopstate=Rt.addEventListener(O8,function(){Rt.dispatchEvent(new Event(vm))}),this.listenerHashchange=Rt.addEventListener(M8,function(){Rt.dispatchEvent(new Event(vm))});var n=Rt.history.pushState;typeof n=="function"&&(Rt.history.pushState=function(o,s,u){n.call(Rt.history,o,s,u),Rt.dispatchEvent(new Event(vm))});var r=Rt.history.replaceState;typeof r=="function"&&(Rt.history.replaceState=function(o,s,u){r.call(Rt.history,o,s,u),Rt.dispatchEvent(new Event(vm))}),this.listenerLocationchange=Rt.addEventListener(vm,BO((function(){if(!this.currentUrlBlocked()){var o=z.info.currentUrl(),s=!1,u=o.split("#")[0].split("?")[0]!==e.split("#")[0].split("?")[0],d=this.pageviewTrackingConfig();if(d===j8?s=o!==e:d===Kte?s=o.split("#")[0]!==e.split("#")[0]:d===Xte&&(s=u),s){var h=this.mp.track_pageview(Uw);h&&(e=o),u&&(this.lastScrollCheckpoint=0,Ma.log("Path change: re-initializing scroll depth checkpoints"))}}}).bind(this)))}},ns.prototype.initScrollTracking=function(){Rt.removeEventListener(R8,this.listenerScroll),this.getConfig(eR)&&(Ma.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=Rt.addEventListener(R8,BO((function(){if(this.getConfig(eR)&&!this.currentUrlBlocked()){var e=this.getConfig(Q8),t=(this.getConfig(K8)||[]).slice().sort(function(h,m){return h-m}),n=Rt.scrollY,r=z.extend({$scroll_top:n},Uw);try{var o=cr.body.scrollHeight,s=Math.round(n/(o-Rt.innerHeight)*100);if(r.$scroll_height=o,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){Ma.critical("Error while calculating scroll percentage",h)}e&&this.mp.track(tne,r)}}).bind(this))))},ns.prototype.initSubmitTracking=function(){Rt.removeEventListener(VO,this.listenerSubmit),this.getConfig(tR)&&(Ma.log("Initializing submit tracking"),this.listenerSubmit=Rt.addEventListener(VO,(function(e){this.getConfig(tR)&&this.trackDomEvent(e,nne)}).bind(this)))},yte(ns);var xc=function(){};xc.prototype.create_properties=function(){},xc.prototype.event_handler=function(){},xc.prototype.after_track_handler=function(){},xc.prototype.init=function(e){return this.mp=e,this},xc.prototype.track=function(e,t,n,r){var o=this,s=z.dom_query(e);if(s.length===0){er.error("The DOM query ("+e+") returned 0 elements");return}return z.each(s,function(u){z.register_event(u,this.override_event,function(d){var h={},m=o.create_properties(n,this),y=o.mp.get_config("track_links_timeout");o.event_handler(d,this,h),window.setTimeout(o.track_callback(r,m,h,!0),y),o.mp.track(t,m,o.track_callback(r,m,h))})},this),!0},xc.prototype.track_callback=function(e,t,n,r){r=r||!1;var o=this;return function(){n.callback_fired||(n.callback_fired=!0,!(e&&e(r,t)===!1)&&o.after_track_handler(t,n,r))}},xc.prototype.create_properties=function(e,t){var n;return typeof e=="function"?n=e(t):n=z.extend({},e),n};var ym=function(){this.override_event="click"};z.inherit(ym,xc),ym.prototype.create_properties=function(e,t){var n=ym.superclass.create_properties.apply(this,arguments);return t.href&&(n.url=t.href),n},ym.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()},ym.prototype.after_track_handler=function(e,t){t.new_tab||setTimeout(function(){window.location=t.href},0)};var jw=function(){this.override_event="submit"};z.inherit(jw,xc),jw.prototype.event_handler=function(e,t,n){n.element=t,e.preventDefault()},jw.prototype.after_track_handler=function(e,t){setTimeout(function(){t.element.submit()},0)};var rd="$set",bm="$set_once",Tl="$unset",qh="$add",vu="$append",Ph="$union",Sc="$remove",rne="$delete",W8={set_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[rd]=r,n},unset_action:function(e){var t={},n=[];return z.isArray(e)||(e=[e]),z.each(e,function(r){this._is_reserved_property(r)||n.push(r)},this),t[Tl]=n,t},set_once_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[bm]=r,n},union_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=z.isArray(o)?o:[o])},this):r[e]=z.isArray(t)?t:[t],n[Ph]=r,n},append_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[vu]=r,n},remove_action:function(e,t){var n={},r={};return z.isObject(e)?z.each(e,function(o,s){this._is_reserved_property(s)||(r[s]=o)},this):r[e]=t,n[Sc]=r,n},delete_action:function(){var e={};return e[rne]="",e}},jr=function(){};z.extend(jr.prototype,W8),jr.prototype._init=function(e,t,n){this._mixpanel=e,this._group_key=t,this._group_id=n},jr.prototype.set=pm(function(e,t,n){var r=this.set_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),jr.prototype.set_once=pm(function(e,t,n){var r=this.set_once_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),jr.prototype.unset=pm(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),jr.prototype.union=pm(function(e,t,n){z.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),jr.prototype.delete=pm(function(e){var t=this.delete_action();return this._send_request(t,e)}),jr.prototype.remove=pm(function(e,t,n){var r=this.remove_action(e,t);return this._send_request(r,n)}),jr.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=z.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)},jr.prototype._is_reserved_property=function(e){return e==="$group_key"||e==="$group_id"},jr.prototype._get_config=function(e){return this._mixpanel.get_config(e)},jr.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},jr.prototype.remove=jr.prototype.remove,jr.prototype.set=jr.prototype.set,jr.prototype.set_once=jr.prototype.set_once,jr.prototype.union=jr.prototype.union,jr.prototype.unset=jr.prototype.unset,jr.prototype.toString=jr.prototype.toString;var fn=function(){};z.extend(fn.prototype,W8),fn.prototype._init=function(e){this._mixpanel=e},fn.prototype.set=nd(function(e,t,n){var r=this.set_action(e,t);return z.isObject(e)&&(n=t),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),r[rd]=z.extend({},z.info.people_properties(),r[rd]),this._send_request(r,n)}),fn.prototype.set_once=nd(function(e,t,n){var r=this.set_once_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),fn.prototype.unset=nd(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),fn.prototype.increment=nd(function(e,t,n){var r={},o={};return z.isObject(e)?(z.each(e,function(s,u){if(!this._is_reserved_property(u))if(isNaN(parseFloat(s))){er.error("Invalid increment value passed to mixpanel.people.increment - must be a number");return}else o[u]=s},this),n=t):(z.isUndefined(t)&&(t=1),o[e]=t),r[qh]=o,this._send_request(r,n)}),fn.prototype.append=nd(function(e,t,n){z.isObject(e)&&(n=t);var r=this.append_action(e,t);return this._send_request(r,n)}),fn.prototype.remove=nd(function(e,t,n){z.isObject(e)&&(n=t);var r=this.remove_action(e,t);return this._send_request(r,n)}),fn.prototype.union=nd(function(e,t,n){z.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),fn.prototype.track_charge=nd(function(e,t,n){if(!z.isNumber(e)&&(e=parseFloat(e),isNaN(e))){er.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",z.extend({$amount:e},t),n)}),fn.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},fn.prototype.delete_user=function(){if(!this._identify_called()){er.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)},fn.prototype.toString=function(){return this._mixpanel.toString()+".people"},fn.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"),o=this._mixpanel.get_property("$had_persisted_distinct_id");n&&(e.$device_id=n),r&&(e.$user_id=r),o&&(e.$had_persisted_distinct_id=o);var s=z.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),z.isUndefined(t)||(this._get_config("verbose")?t({status:-1,error:null}):t(-1)),z.truncate(s,255))},fn.prototype._get_config=function(e){return this._mixpanel.get_config(e)},fn.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},fn.prototype._enqueue=function(e){rd in e?this._mixpanel.persistence._add_to_people_queue(rd,e):bm in e?this._mixpanel.persistence._add_to_people_queue(bm,e):Tl in e?this._mixpanel.persistence._add_to_people_queue(Tl,e):qh in e?this._mixpanel.persistence._add_to_people_queue(qh,e):vu in e?this._mixpanel.persistence._add_to_people_queue(vu,e):Sc in e?this._mixpanel.persistence._add_to_people_queue(Sc,e):Ph in e?this._mixpanel.persistence._add_to_people_queue(Ph,e):er.error("Invalid call to _enqueue():",e)},fn.prototype._flush_one_queue=function(e,t,n,r){var o=this,s=z.extend({},this._mixpanel.persistence.load_queue(e)),u=s;!z.isUndefined(s)&&z.isObject(s)&&!z.isEmptyObject(s)&&(o._mixpanel.persistence._pop_from_people_queue(e,s),o._mixpanel.persistence.save(),r&&(u=r(s)),t.call(o,u,function(d,h){d===0&&o._mixpanel.persistence._add_to_people_queue(e,s),z.isUndefined(n)||n(d,h)}))},fn.prototype._flush=function(e,t,n,r,o,s,u){var d=this;this._flush_one_queue(rd,this.set,e),this._flush_one_queue(bm,this.set_once,r),this._flush_one_queue(Tl,this.unset,s,function(A){return z.keys(A)}),this._flush_one_queue(qh,this.increment,t),this._flush_one_queue(Ph,this.union,o);var h=this._mixpanel.persistence.load_queue(vu);if(!z.isUndefined(h)&&z.isArray(h)&&h.length)for(var m,y=function(A,k){A===0&&d._mixpanel.persistence._add_to_people_queue(vu,m),z.isUndefined(n)||n(A,k)},v=h.length-1;v>=0;v--)h=this._mixpanel.persistence.load_queue(vu),m=h.pop(),d._mixpanel.persistence.save(),z.isEmptyObject(m)||d.append(m,y);var x=this._mixpanel.persistence.load_queue(Sc);if(!z.isUndefined(x)&&z.isArray(x)&&x.length)for(var w,E=function(A,k){A===0&&d._mixpanel.persistence._add_to_people_queue(Sc,w),z.isUndefined(u)||u(A,k)},M=x.length-1;M>=0;M--)x=this._mixpanel.persistence.load_queue(Sc),w=x.pop(),d._mixpanel.persistence.save(),z.isEmptyObject(w)||d.remove(w,E)},fn.prototype._is_reserved_property=function(e){return e==="$distinct_id"||e==="$token"||e==="$device_id"||e==="$user_id"||e==="$had_persisted_distinct_id"},fn.prototype.set=fn.prototype.set,fn.prototype.set_once=fn.prototype.set_once,fn.prototype.unset=fn.prototype.unset,fn.prototype.increment=fn.prototype.increment,fn.prototype.append=fn.prototype.append,fn.prototype.remove=fn.prototype.remove,fn.prototype.union=fn.prototype.union,fn.prototype.track_charge=fn.prototype.track_charge,fn.prototype.clear_charges=fn.prototype.clear_charges,fn.prototype.delete_user=fn.prototype.delete_user,fn.prototype.toString=fn.prototype.toString;var nR="__mps",rR="__mpso",iR="__mpus",oR="__mpa",aR="__mpap",sR="__mpr",lR="__mpu",J8="$people_distinct_id",Hw="__alias",Eb="__timers",ine=[nR,rR,iR,oR,aR,sR,lR,J8,Hw,Eb],An=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"&&(er.critical("Unknown persistence type "+t+"; falling back to cookie"),t=e.persistence="cookie"),t==="localStorage"&&z.localStorage.is_supported()?this.storage=z.localStorage:this.storage=z.cookie,this.load(),this.update_config(e),this.upgrade(),this.save()};An.prototype.properties=function(){var e={};return this.load(),z.each(this.props,function(t,n){z.include(ine,n)||(e[n]=t)}),e},An.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=z.extend({},e))}},An.prototype.upgrade=function(){var e,t;this.storage===z.localStorage?(e=z.cookie.parse(this.name),z.cookie.remove(this.name),z.cookie.remove(this.name,!0),e&&this.register_once(e)):this.storage===z.cookie&&(t=z.localStorage.parse(this.name),z.localStorage.remove(this.name),t&&this.register_once(t))},An.prototype.save=function(){this.disabled||this.storage.set(this.name,hm(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},An.prototype.load_prop=function(e){return this.load(),this.props[e]},An.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},An.prototype.clear=function(){this.remove(),this.props={}},An.prototype.register_once=function(e,t,n){return z.isObject(e)?(typeof t>"u"&&(t="None"),this.expire_days=typeof n>"u"?this.default_expiry:n,this.load(),z.each(e,function(r,o){(!this.props.hasOwnProperty(o)||this.props[o]===t)&&(this.props[o]=r)},this),this.save(),!0):!1},An.prototype.register=function(e,t){return z.isObject(e)?(this.expire_days=typeof t>"u"?this.default_expiry:t,this.load(),z.extend(this.props,e),this.save(),!0):!1},An.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},An.prototype.update_search_keyword=function(e){this.register(z.info.searchInfo(e))},An.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:z.info.referringDomain(e)||"$direct"},"")},An.prototype.get_referrer_info=function(){return z.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},An.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)},An.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},An.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},An.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},An.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},An.prototype.get_cross_subdomain=function(){return this.cross_subdomain},An.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},An.prototype._add_to_people_queue=function(e,t){var n=this._get_queue_key(e),r=t[e],o=this._get_or_create_queue(rd),s=this._get_or_create_queue(bm),u=this._get_or_create_queue(Tl),d=this._get_or_create_queue(qh),h=this._get_or_create_queue(Ph),m=this._get_or_create_queue(Sc,[]),y=this._get_or_create_queue(vu,[]);n===nR?(z.extend(o,r),this._pop_from_people_queue(qh,r),this._pop_from_people_queue(Ph,r),this._pop_from_people_queue(Tl,r)):n===rR?(z.each(r,function(v,x){x in s||(s[x]=v)}),this._pop_from_people_queue(Tl,r)):n===iR?z.each(r,function(v){z.each([o,s,d,h],function(x){v in x&&delete x[v]}),z.each(y,function(x){v in x&&delete x[v]}),u[v]=!0}):n===oR?(z.each(r,function(v,x){x in o?o[x]+=v:(x in d||(d[x]=0),d[x]+=v)},this),this._pop_from_people_queue(Tl,r)):n===lR?(z.each(r,function(v,x){z.isArray(v)&&(x in h||(h[x]=[]),z.each(v,function(w){z.include(h[x],w)||h[x].push(w)}))}),this._pop_from_people_queue(Tl,r)):n===sR?(m.push(r),this._pop_from_people_queue(vu,r)):n===aR&&(y.push(r),this._pop_from_people_queue(Tl,r)),er.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),er.log(t),this.save()},An.prototype._pop_from_people_queue=function(e,t){var n=this.props[this._get_queue_key(e)];z.isUndefined(n)||z.each(t,function(r,o){e===vu||e===Sc?z.each(n,function(s){s[o]===r&&delete s[o]}):delete n[o]},this)},An.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},An.prototype._get_queue_key=function(e){if(e===rd)return nR;if(e===bm)return rR;if(e===Tl)return iR;if(e===qh)return oR;if(e===vu)return aR;if(e===Sc)return sR;if(e===Ph)return lR;er.error("Invalid queue:",e)},An.prototype._get_or_create_queue=function(e,t){var n=this._get_queue_key(e);return t=z.isUndefined(t)?{}:t,this.props[n]||(this.props[n]=t)},An.prototype.set_event_timer=function(e,t){var n=this.load_prop(Eb)||{};n[e]=t,this.props[Eb]=n,this.save()},An.prototype.remove_event_timer=function(e){var t=this.load_prop(Eb)||{},n=t[e];return z.isUndefined(n)||(delete this.props[Eb][e],this.save()),n};var uR,e9=function(e,t){throw new Error(e+" not available in this build.")},Uo,t9=0,one=1,ane=function(e){return e},Os="mixpanel",n9="base64",sne="json",cR="$device:",_m=Rt.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,r9=!_m&&bc.indexOf("MSIE")===-1&&bc.indexOf("Mozilla")===-1,qw=null;Jf.sendBeacon&&(qw=function(){return Jf.sendBeacon.apply(Jf,arguments)});var i9={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},o9={api_host:"https://api-js.mixpanel.com",api_routes:i9,api_method:"POST",api_transport:"XHR",api_payload_format:n9,app_host:"https://mixpanel.com",autocapture:!1,cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:ed,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:ed,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:yb,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},a9=!1,Te=function(){},fR=function(e,t,n){var r,o=n===Os?Uo:Uo[n];if(o&&uR===t9)r=o;else{if(o&&!z.isArray(o)){er.error("You have already initialized "+n);return}r=new Te}if(r._cached_groups={},r._init(e,t,n),r.people=new fn,r.people._init(r),!r.get_config("skip_first_touch_marketing")){var s=z.info.campaignParams(null),u={},d=!1;z.each(s,function(h,m){u["initial_"+m]=h,h&&(d=!0)}),d&&r.people.set_once(u)}return Al.DEBUG=Al.DEBUG||r.get_config("debug"),!z.isUndefined(o)&&z.isArray(o)&&(r._execute_array.call(r.people,o.people),r._execute_array(o)),r};Te.prototype.init=function(e,t,n){if(z.isUndefined(n)){this.report_error("You must name your new library: init(token, config, name)");return}if(n===Os){this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");return}var r=fR(e,t,n);return Uo[n]=r,r._loaded(),r},Te.prototype._init=function(e,t,n){t=t||{},this.__loaded=!0,this.config={};var r={};if(!("api_payload_format"in t)){var o=t.api_host||o9.api_host;o.match(/\.mixpanel\.com/)&&(r.api_payload_format=sne)}if(this.set_config(z.extend({},o9,r,t,{name:n,token:e,callback_fn:(n===Os?n:Os+"."+n)+"._jsc"})),this._jsc=ed,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(!z.localStorage.is_supported(!0)||!_m)this._batch_requests=!1,er.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),z.each(this.get_batcher_configs(),function(d){er.log("Clearing batch queue "+d.queue_key),z.localStorage.remove(d.queue_key)});else if(this.init_batchers(),qw&&Rt.addEventListener){var s=z.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);Rt.addEventListener("pagehide",function(d){d.persisted&&s()}),Rt.addEventListener("visibilitychange",function(){cr.visibilityState==="hidden"&&s()})}}this.persistence=this.cookie=new An(this.config),this.unpersisted_superprops={},this._gdpr_init();var u=z.UUID();this.get_distinct_id()||this.register_once({distinct_id:cR+u,$device_id:u},""),this.autocapture=new ns(this),this.autocapture.init(),this._init_tab_id(),this._check_and_start_session_recording()},Te.prototype._init_tab_id=function(){if(z.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;(z.sessionStorage.get(n)||!z.sessionStorage.get(t))&&z.sessionStorage.set(t,"$tab-"+z.UUID()),z.sessionStorage.set(n,"1"),this.tab_id=z.sessionStorage.get(t),Rt.addEventListener("beforeunload",function(){z.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.")},Te.prototype.get_tab_id=function(){return this.tab_id||null},Te.prototype._should_load_recorder=function(){var e=new pu(HO),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(GO(n[r])||n[r].tabId===t)return!0;return!1}).catch(z.bind(function(n){this.report_error("Error checking recording registry",n)},this))},Te.prototype._check_and_start_session_recording=td(function(e){if(!Rt.MutationObserver){er.critical("Browser does not support MutationObserver; skipping session recording");return}var t=z.bind(function(r){var o=z.bind(function(){this._recorder=this._recorder||new Rt.__mp_recorder(this),this._recorder.resumeRecording(r)},this);z.isUndefined(Rt.__mp_recorder)?e9(this.get_config("recorder_src"),o):o()},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)})}),Te.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},Te.prototype.stop_session_recording=function(){this._recorder&&this._recorder.stopRecording()},Te.prototype.pause_session_recording=function(){this._recorder&&this._recorder.pauseRecording()},Te.prototype.resume_session_recording=function(){this._recorder&&this._recorder.resumeRecording()},Te.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},Te.prototype.get_session_replay_url=function(){var e=null,t=this._get_session_replay_id();if(t){var n=z.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},Te.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},Te.prototype.__get_recorder=function(){return this._recorder},Te.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=z.info.campaignParams(null);z.each(e,(function(t,n){this.unregister(n)}).bind(this))}},Te.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(cr.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(z.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info(cr.referrer)},Te.prototype._dom_loaded=function(){z.each(this.__dom_loaded_queue,function(e){this._track_dom.apply(this,e)},this),this.has_opted_out_tracking()||z.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},Te.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(!a9)return this.__dom_loaded_queue.push([e,t]),!1;var n=new e().init(this);return n.track.apply(n,t)},Te.prototype._prepare_callback=function(e,t){if(z.isUndefined(e))return null;if(_m){var n=function(u){e(u,t)};return n}else{var r=this._jsc,o=""+Math.floor(Math.random()*1e8),s=this.get_config("callback_fn")+"["+o+"]";return r[o]=function(u){delete r[o],e(u,t)},s}},Te.prototype._send_request=function(e,t,n,r){var o=!0;if(r9)return this.__request_queue.push(arguments),o;var s={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},u=null;!r&&(z.isFunction(n)||typeof n=="string")&&(r=n,n=null),n=z.extend(s,n||{}),_m||(n.method="GET");var d=n.method==="POST",h=qw&&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),_m||(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+="?"+z.HTTPBuildQuery(t);var y=this;if("img"in t){var v=cr.createElement("img");v.src=e,cr.body.appendChild(v)}else if(h){try{o=qw(e,u)}catch(k){y.report_error(k),o=!1}try{r&&r(o?1:0)}catch(k){y.report_error(k)}}else if(_m)try{var x=new XMLHttpRequest;x.open(n.method,e,!0);var w=this.get_config("xhr_headers");if(d&&(w["Content-Type"]="application/x-www-form-urlencoded"),z.each(w,function(k,R){x.setRequestHeader(R,k)}),n.timeout_ms&&typeof x.timeout<"u"){x.timeout=n.timeout_ms;var E=new Date().getTime()}x.withCredentials=!0,x.onreadystatechange=function(){if(x.readyState===4)if(x.status===200){if(r)if(m){var k;try{k=z.JSONDecode(x.responseText)}catch(B){if(y.report_error(B),n.ignore_json_errors)k=x.responseText;else return}r(k)}else r(Number(x.responseText))}else{var R;if(x.timeout&&!x.status&&new Date().getTime()-E>=x.timeout?R="timeout":R="Bad HTTP status: "+x.status+" "+x.statusText,y.report_error(R),r)if(m){var D=x.responseHeaders||{};r({status:0,httpStatusCode:x.status,error:R,retryAfter:D["Retry-After"]})}else r(0)}},x.send(u)}catch(k){y.report_error(k),o=!1}else{var M=cr.createElement("script");M.type="text/javascript",M.async=!0,M.defer=!0,M.src=e;var A=cr.getElementsByTagName("script")[0];A.parentNode.insertBefore(M,A)}return o},Te.prototype._execute_array=function(e){var t,n=[],r=[],o=[];z.each(e,function(u){u&&(t=u[0],z.isArray(t)?o.push(u):typeof u=="function"?u.call(this):z.isArray(u)&&t==="alias"?n.push(u):z.isArray(u)&&t.indexOf("track")!==-1&&typeof this[t]=="function"?o.push(u):r.push(u))},this);var s=function(u,d){z.each(u,function(h){if(z.isArray(h[0])){var m=d;z.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(o,this)},Te.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},Te.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},Te.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=z.bind(function(n){return new Ms(n.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:z.bind(function(r,o,s){this._send_request(this.get_config("api_host")+n.endpoint,this._encode_data_for_request(r),o,this._prepare_callback(s,r))},this),beforeSendHook:z.bind(function(r){return this._run_hook("before_send_"+n.type,r)},this),stopAllBatchingFunc:z.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()},Te.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,z.each(this.request_batchers,function(e){e.start()}))},Te.prototype.stop_batch_senders=function(){this._batch_requests=!1,z.each(this.request_batchers,function(e){e.stop(),e.clear()})},Te.prototype.push=function(e){this._execute_array([e])},Te.prototype.disable=function(e){typeof e>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},Te.prototype._encode_data_for_request=function(e){var t=hm(e);return this.get_config("api_payload_format")===n9&&(t=z.base64Encode(t)),{data:t}},Te.prototype._track_or_batch=function(e,t){var n=z.truncate(e.data,255),r=e.endpoint,o=e.batcher,s=e.should_send_immediately,u=e.send_request_options||{};t=t||ed;var d=!0,h=z.bind(function(){return u.skip_hooks||(n=this._run_hook("before_send_"+e.type,n)),n?(er.log("MIXPANEL REQUEST:"),er.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?o.enqueue(n).then(function(m){m?t(1,n):h()}):d=h(),d&&n},Te.prototype.track=td(function(e,t,n,r){!r&&typeof n=="function"&&(r=n,n=null),n=n||{};var o=n.transport;o&&(n.transport=o);var s=n.send_immediately;if(typeof r!="function"&&(r=ed),z.isUndefined(e)){this.report_error("No event name provided to mixpanel.track");return}if(this._event_is_disabled(e)){r(0);return}t=z.extend({},t),t.token=this.get_config("token");var u=this.persistence.remove_event_timer(e);if(!z.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")?z.info.marketingParams():{};t=z.extend({},z.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");z.isArray(m)?z.each(m,function(x){delete t[x]}):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}),Te.prototype.set_group=td(function(e,t,n){z.isArray(t)||(t=[t]);var r={};return r[e]=t,this.register(r),this.people.set(e,t,n)}),Te.prototype.add_group=td(function(e,t,n){var r=this.get_property(e),o={};return r===void 0?(o[e]=[t],this.register(o)):r.indexOf(t)===-1&&(r.push(t),o[e]=r,this.register(o)),this.people.union(e,t,n)}),Te.prototype.remove_group=td(function(e,t,n){var r=this.get_property(e);if(r!==void 0){var o=r.indexOf(t);o>-1&&(r.splice(o,1),this.register({group_key:r})),r.length===0&&this.unregister(e)}return this.people.remove(e,t,n)}),Te.prototype.track_with_groups=td(function(e,t,n,r){var o=z.extend({},t||{});return z.each(n,function(s,u){s!=null&&(o[u]=s)}),this.track(e,o,r)}),Te.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},Te.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},Te.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 jr,r._init(this,e,t),this._cached_groups[n]=r),r},Te.prototype.track_pageview=td(function(e,t){typeof e!="object"&&(e={}),t=t||{};var n=t.event_name||"$mp_web_page_view",r=z.extend(z.info.mpPageViewProperties(),z.info.campaignParams(),z.info.clickParams()),o=z.extend({},r,e);return this.track(n,o)}),Te.prototype.track_links=function(){return this._track_dom.call(this,ym,arguments)},Te.prototype.track_forms=function(){return this._track_dom.call(this,jw,arguments)},Te.prototype.time_event=function(e){if(z.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 lne={persistent:!0},dR=function(e){var t;return z.isObject(e)?t=e:z.isUndefined(e)?t={}:t={days:e},z.extend({},lne,t)};Te.prototype.register=function(e,t){var n=dR(t);n.persistent?this.persistence.register(e,n.days):z.extend(this.unpersisted_superprops,e)},Te.prototype.register_once=function(e,t,n){var r=dR(n);r.persistent?this.persistence.register_once(e,t,r.days):(typeof t>"u"&&(t="None"),z.each(e,function(o,s){(!this.unpersisted_superprops.hasOwnProperty(s)||this.unpersisted_superprops[s]===t)&&(this.unpersisted_superprops[s]=o)},this))},Te.prototype.unregister=function(e,t){t=dR(t),t.persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},Te.prototype._register_single=function(e,t){var n={};n[e]=t,this.register(n)},Te.prototype.identify=function(e,t,n,r,o,s,u,d){var h=this.get_distinct_id();if(e&&h!==e){if(typeof e=="string"&&e.indexOf(cR)===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(Hw)&&(this.unregister(Hw),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,n,r,o,s,u,d),e!==h&&this.track("$identify",{distinct_id:e,$anon_distinct_id:h},{skip_hooks:!0})},Te.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var e=z.UUID();this.register_once({distinct_id:cR+e,$device_id:e},"")},Te.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},Te.prototype.alias=function(e,t){if(e===this.get_property(J8))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var n=this;return z.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Hw,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)},Te.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},Te.prototype.set_config=function(e){if(z.isObject(e)){z.extend(this.config,e);var t=e.batch_size;t&&z.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),Al.DEBUG=Al.DEBUG||this.get_config("debug"),"autocapture"in e&&this.autocapture&&this.autocapture.init()}},Te.prototype.get_config=function(e){return this.config[e]},Te.prototype._run_hook=function(e){var t=(this.config.hooks[e]||ane).apply(this,Wf.call(arguments,1));return typeof t>"u"&&(this.report_error(e+" hook did not return a value"),t=null),t},Te.prototype.get_property=function(e){return this.persistence.load_prop([e])},Te.prototype.toString=function(){var e=this.get_config("name");return e!==Os&&(e=Os+"."+e),e},Te.prototype._event_is_disabled=function(e){return z.isBlockedUA(bc)||this._flags.disable_all_events||z.include(this.__disabled_events,e)},Te.prototype._gdpr_init=function(){var e=this.get_config("opt_out_tracking_persistence_type")==="localStorage";e&&z.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")||z.cookie.get("mp_optout"))&&(z.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},Te.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()},Te.prototype._gdpr_call_func=function(e,t){return t=z.extend({track:z.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),z.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})},Te.prototype.opt_in_tracking=function(e){e=z.extend({enable_persistence:!0},e),this._gdpr_call_func(Rte,e),this._gdpr_update_persistence(e)},Te.prototype.opt_out_tracking=function(e){e=z.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(Ite,e),this._gdpr_update_persistence(e)},Te.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(Dte,e)},Te.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(x8,e)},Te.prototype.clear_opt_in_out_tracking=function(e){e=z.extend({enable_persistence:!0},e),this._gdpr_call_func($te,e),this._gdpr_update_persistence(e)},Te.prototype.report_error=function(e,t){er.error.apply(er.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(n){er.error(n)}},Te.prototype.init=Te.prototype.init,Te.prototype.reset=Te.prototype.reset,Te.prototype.disable=Te.prototype.disable,Te.prototype.time_event=Te.prototype.time_event,Te.prototype.track=Te.prototype.track,Te.prototype.track_links=Te.prototype.track_links,Te.prototype.track_forms=Te.prototype.track_forms,Te.prototype.track_pageview=Te.prototype.track_pageview,Te.prototype.register=Te.prototype.register,Te.prototype.register_once=Te.prototype.register_once,Te.prototype.unregister=Te.prototype.unregister,Te.prototype.identify=Te.prototype.identify,Te.prototype.alias=Te.prototype.alias,Te.prototype.name_tag=Te.prototype.name_tag,Te.prototype.set_config=Te.prototype.set_config,Te.prototype.get_config=Te.prototype.get_config,Te.prototype.get_property=Te.prototype.get_property,Te.prototype.get_distinct_id=Te.prototype.get_distinct_id,Te.prototype.toString=Te.prototype.toString,Te.prototype.opt_out_tracking=Te.prototype.opt_out_tracking,Te.prototype.opt_in_tracking=Te.prototype.opt_in_tracking,Te.prototype.has_opted_out_tracking=Te.prototype.has_opted_out_tracking,Te.prototype.has_opted_in_tracking=Te.prototype.has_opted_in_tracking,Te.prototype.clear_opt_in_out_tracking=Te.prototype.clear_opt_in_out_tracking,Te.prototype.get_group=Te.prototype.get_group,Te.prototype.set_group=Te.prototype.set_group,Te.prototype.add_group=Te.prototype.add_group,Te.prototype.remove_group=Te.prototype.remove_group,Te.prototype.track_with_groups=Te.prototype.track_with_groups,Te.prototype.start_batch_senders=Te.prototype.start_batch_senders,Te.prototype.stop_batch_senders=Te.prototype.stop_batch_senders,Te.prototype.start_session_recording=Te.prototype.start_session_recording,Te.prototype.stop_session_recording=Te.prototype.stop_session_recording,Te.prototype.pause_session_recording=Te.prototype.pause_session_recording,Te.prototype.resume_session_recording=Te.prototype.resume_session_recording,Te.prototype.get_session_recording_properties=Te.prototype.get_session_recording_properties,Te.prototype.get_session_replay_url=Te.prototype.get_session_replay_url,Te.prototype.get_tab_id=Te.prototype.get_tab_id,Te.prototype.DEFAULT_API_ROUTES=i9,Te.prototype.__get_recorder=Te.prototype.__get_recorder,An.prototype.properties=An.prototype.properties,An.prototype.update_search_keyword=An.prototype.update_search_keyword,An.prototype.update_referrer_info=An.prototype.update_referrer_info,An.prototype.get_cross_subdomain=An.prototype.get_cross_subdomain,An.prototype.clear=An.prototype.clear;var xm={},une=function(){z.each(xm,function(e,t){t!==Os&&(Uo[t]=e)}),Uo._=z},cne=function(){Uo.init=function(e,t,n){if(n)return Uo[n]||(Uo[n]=xm[n]=fR(e,t,n),Uo[n]._loaded()),Uo[n];var r=Uo;xm[Os]?r=xm[Os]:e&&(r=fR(e,t,Os),r._loaded(),xm[Os]=r),Uo=r,uR===one&&(Rt[Os]=Uo),une()}},fne=function(){function e(){e.done||(e.done=!0,a9=!0,r9=!1,z.each(xm,function(r){r._dom_loaded()}))}function t(){try{cr.documentElement.doScroll("left")}catch{setTimeout(t,1);return}e()}if(cr.addEventListener)cr.readyState==="complete"?e():cr.addEventListener("DOMContentLoaded",e,!1);else if(cr.attachEvent){cr.attachEvent("onreadystatechange",e);var n=!1;try{n=Rt.frameElement===null}catch{}cr.documentElement.doScroll&&n&&t()}z.register_event(Rt,"load",e,!0)};function dne(e){return e9=e,uR=t9,Uo=new Te,cne(),Uo.init(),fne(),Uo}function hne(e,t){t()}var id=dne(hne);const ci="https://debales.ai",pne="https://debales-web-app-server-prod.azurewebsites.net",s9={"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"},gne="phc_OKaClHZDmbEpVscrwceWJB5lsMYbMaV586L7pai6ZKD",Pw=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 tr(){const e=sessionStorage.getItem("debalesSessionID");if(e)return e;const t=crypto.randomUUID();return sessionStorage.setItem("debalesSessionID",t),t}function mne(){return sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:window.DebalesChat.projectId}))}function bo(){const e=localStorage.getItem(Dn(In.USER_INFO));return e?JSON.parse(e):null}function wc(e){localStorage.setItem(Dn(In.USER_INFO),JSON.stringify(e))}function jo(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,o=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+(o-r)*v,y<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}}}function vne(){return window.location.pathname}function kb(){const e=/test|demo|example|debales/i,t=bo()??"";return!!(t&&e.test(t.email))}function Fw(e){const t=vne(),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 l9=new Set,Gw=e=>{const t=s9[e];if(!t)return console.warn("No Mixpanel token found"),null;if(l9.has(e))return id;id.init(t,{debug:!1,track_pageview:!0,persistence:"localStorage"}),console.log("Mixpanel initialized");const n=bo();return n&&n.email&&id.identify(n.email),l9.add(e),id},yne=async(e,t)=>{if(kb())return;const n=window.DebalesChat.projectId??t.projectId;if(!s9[n]){console.warn("No Mixpanel token found");return}id.track(e,t)},bne=()=>{const e=localStorage.getItem("anonymousUserId");if(e)return e;const t=crypto.randomUUID();return localStorage.setItem("anonymousUserId",t),t};function Fh(e){return e?e.split("<br>").filter(n=>n.trim().length>0).map(n=>n.trim()):[""]}const _o=e=>e.toLowerCase().includes("gaiabay")||e.toLowerCase().includes("debales-testing"),_ne=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 Dn(e,t){return t!=null&&t.botId?`debales_${t.botId}_${e}`:`debales_${e}`}const u9=W.createContext(null),Ab=()=>{const e=W.useContext(u9);if(!e)throw new Error("useCart must be used within a CartProvider");return e};var xne="2.0.0",Sm="",c9="?",Vw="function",od="undefined",wm="object",hR="string",Tb="major",st="model",rt="name",nt="type",vt="vendor",ot="version",Oa="architecture",Cm="console",yn="mobile",Zr="tablet",Ho="smarttv",Mb="wearable",pR="xr",gR="embedded",Ob="inapp",f9="user-agent",mR=500,vR="brands",Gh="formFactors",yR="fullVersionList",Em="platform",bR="platformVersion",Yw="bitness",ad="sec-ch-ua",Sne=ad+"-full-version-list",wne=ad+"-arch",Cne=ad+"-"+Yw,Ene=ad+"-form-factors",kne=ad+"-"+yn,Ane=ad+"-"+st,d9=ad+"-"+Em,Tne=d9+"-version",h9=[vR,yR,yn,st,Em,bR,Oa,Gh,Yw],rs="browser",Cc="cpu",yu="device",Ec="engine",Rs="os",km="result",Zw="Amazon",Rb="Apple",p9="ASUS",g9="BlackBerry",Vh="Google",m9="Huawei",v9="Lenovo",Mne="Honor",_R="LG",Qw="Microsoft",y9="Motorola",Ib="Samsung",b9="Sharp",Kw="Sony",xR="Xiaomi",SR="Zebra",Am="Mobile ",Db=" Browser",_9="Chrome",sd="Chromecast",One="Edge",$b="Firefox",Lb="Opera",x9="Facebook",S9="Sogou",wR="Windows",Rne=typeof window!==od,Ra=Rne&&window.navigator?window.navigator:void 0,ld=Ra&&Ra.userAgentData?Ra.userAgentData:void 0,Ine=function(e,t){var n={},r=t;if(!Ww(t)){r={};for(var o in t)for(var s in t[o])r[s]=t[o][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},Xw=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},CR=function(e,t){if(typeof e===wm&&e.length>0){for(var n in e)if(kc(e[n])==kc(t))return!0;return!1}return Tm(e)?kc(t).indexOf(kc(e))!==-1:!1},Ww=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?Ww(e[n]):!1)},Tm=function(e){return typeof e===hR},ER=function(e){if(e){for(var t=[],n=Yh(/\\?\"/g,e).split(","),r=0;r<n.length;r++)if(n[r].indexOf(";")>-1){var o=Bb(n[r]).split(";v=");t[r]={brand:o[0],version:o[1]}}else t[r]=Bb(n[r]);return t}},kc=function(e){return Tm(e)?e.toLowerCase():e},kR=function(e){return Tm(e)?Yh(/[^\d\.]/g,e).split(".")[0]:void 0},Ac=function(e){for(var t in e){var n=e[t];typeof n==wm&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Yh=function(e,t){return Tm(t)?t.replace(e,Sm):t},Nb=function(e){return Yh(/\\?\"/g,e)},Bb=function(e,t){if(Tm(e))return e=Yh(/^\s\s*/,e),typeof t===od?e:e.substring(0,mR)},w9=function(e,t){if(!(!e||!t))for(var n=0,r,o,s,u,d,h;n<t.length&&!d;){var m=t[n],y=t[n+1];for(r=o=0;r<m.length&&!d&&m[r];)if(d=m[r++].exec(e),d)for(s=0;s<y.length;s++)h=d[++o],u=y[s],typeof u===wm&&u.length>0?u.length===2?typeof u[1]==Vw?this[u[0]]=u[1].call(this,h):this[u[0]]=u[1]:u.length===3?typeof u[1]===Vw&&!(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}},zb=function(e,t){for(var n in t)if(typeof t[n]===wm&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(CR(t[n][r],e))return n===c9?void 0:n}else if(CR(t[n],e))return n===c9?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},C9={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"},E9={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},k9={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[ot,[rt,Am+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[ot,[rt,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[rt,ot],[/opios[\/ ]+([\w\.]+)/i],[ot,[rt,Lb+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[ot,[rt,Lb+" GX"]],[/\bopr\/([\w\.]+)/i],[ot,[rt,Lb]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[ot,[rt,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[ot,[rt,"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],[rt,ot],[/quark(?:pc)?\/([-\w\.]+)/i],[ot,[rt,"Quark"]],[/\bddg\/([\w\.]+)/i],[ot,[rt,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[ot,[rt,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[ot,[rt,"WeChat"]],[/konqueror\/([\w\.]+)/i],[ot,[rt,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[ot,[rt,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[ot,[rt,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[ot,[rt,"Smart "+v9+Db]],[/(avast|avg)\/([\w\.]+)/i],[[rt,/(.+)/,"$1 Secure"+Db],ot],[/\bfocus\/([\w\.]+)/i],[ot,[rt,$b+" Focus"]],[/\bopt\/([\w\.]+)/i],[ot,[rt,Lb+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[ot,[rt,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[ot,[rt,"Dolphin"]],[/coast\/([\w\.]+)/i],[ot,[rt,Lb+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[ot,[rt,"MIUI"+Db]],[/fxios\/([\w\.-]+)/i],[ot,[rt,Am+$b]],[/\bqihoobrowser\/?([\w\.]*)/i],[ot,[rt,"360"]],[/\b(qq)\/([\w\.]+)/i],[[rt,/(.+)/,"$1Browser"],ot],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[rt,/(.+)/,"$1"+Db],ot],[/samsungbrowser\/([\w\.]+)/i],[ot,[rt,Ib+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[ot,[rt,S9+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[rt,S9+" Mobile"],ot],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[rt,ot],[/(lbbrowser|rekonq)/i],[rt],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[ot,rt],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[rt,x9],ot,[nt,Ob]],[/(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],[rt,ot,[nt,Ob]],[/\bgsa\/([\w\.]+) .*safari\//i],[ot,[rt,"GSA"],[nt,Ob]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[ot,[rt,"TikTok"],[nt,Ob]],[/\[(linkedin)app\]/i],[rt,[nt,Ob]],[/(chromium)[\/ ]([-\w\.]+)/i],[rt,ot],[/headlesschrome(?:\/([\w\.]+)| )/i],[ot,[rt,_9+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[rt,_9+" WebView"],ot],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[ot,[rt,"Android"+Db]],[/chrome\/([\w\.]+) mobile/i],[ot,[rt,Am+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[rt,ot],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[ot,[rt,Am+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[rt,Am+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[ot,rt],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[rt,[ot,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[rt,ot],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[rt,Am+$b],ot],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[rt,"Netscape"],ot],[/(wolvic|librewolf)\/([\w\.]+)/i],[rt,ot],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[ot,[rt,$b+" 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],[rt,[ot,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[rt,[ot,/[^\d\.]+./,Sm]]],cpu:[[/\b(?:(amd|x|x86[-_]?|wow|win)64)\b/i],[[Oa,"amd64"]],[/(ia32(?=;))/i,/((?:i[346]|x)86)[;\)]/i],[[Oa,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[Oa,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[Oa,"armhf"]],[/windows (ce|mobile); ppc;/i],[[Oa,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[Oa,/ower/,Sm,kc]],[/(sun4\w)[;\)]/i],[[Oa,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[Oa,kc]]],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],[st,[vt,Ib],[nt,Zr]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[st,[vt,Ib],[nt,yn]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[st,[vt,Rb],[nt,yn]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[st,[vt,Rb],[nt,Zr]],[/(macintosh);/i],[st,[vt,Rb]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[st,[vt,b9],[nt,yn]],[/(?:honor)([-\w ]+)[;\)]/i],[st,[vt,Mne],[nt,yn]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[st,[vt,m9],[nt,Zr]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[st,[vt,m9],[nt,yn]],[/\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],[[st,/_/g," "],[vt,xR],[nt,yn]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[st,/_/g," "],[vt,xR],[nt,Zr]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[st,[vt,"OPPO"],[nt,yn]],[/\b(opd2\d{3}a?) bui/i],[st,[vt,"OPPO"],[nt,Zr]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[st,[vt,"Vivo"],[nt,yn]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[st,[vt,"Realme"],[nt,yn]],[/\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],[st,[vt,y9],[nt,yn]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[st,[vt,y9],[nt,Zr]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[st,[vt,_R],[nt,Zr]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[st,[vt,_R],[nt,yn]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[st,[vt,v9],[nt,Zr]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[st,/_/g," "],[vt,"Nokia"],[nt,yn]],[/(pixel c)\b/i],[st,[vt,Vh],[nt,Zr]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[st,[vt,Vh],[nt,yn]],[/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],[st,[vt,Kw],[nt,yn]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[st,"Xperia Tablet"],[vt,Kw],[nt,Zr]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[st,[vt,"OnePlus"],[nt,yn]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[st,[vt,Zw],[nt,Zr]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[st,/(.+)/g,"Fire Phone $1"],[vt,Zw],[nt,yn]],[/(playbook);[-\w\),; ]+(rim)/i],[st,vt,[nt,Zr]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[st,[vt,g9],[nt,yn]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[st,[vt,p9],[nt,Zr]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[st,[vt,p9],[nt,yn]],[/(nexus 9)/i],[st,[vt,"HTC"],[nt,Zr]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[vt,[st,/_/g," "],[nt,yn]],[/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],[st,[vt,"TCL"],[nt,Zr]],[/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],[st,[vt,"TCL"],[nt,yn]],[/(itel) ((\w+))/i],[[vt,kc],st,[nt,zb,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[st,[vt,"Acer"],[nt,Zr]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[st,[vt,"Meizu"],[nt,yn]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[st,[vt,"Ulefone"],[nt,yn]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[st,[vt,"Energizer"],[nt,yn]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[st,[vt,"Cat"],[nt,yn]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[st,[vt,"Smartfren"],[nt,yn]],[/droid.+; (a(?:015|06[35]|142p?))/i],[st,[vt,"Nothing"],[nt,yn]],[/(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],[vt,st,[nt,yn]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[vt,st,[nt,Zr]],[/(surface duo)/i],[st,[vt,Qw],[nt,Zr]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[st,[vt,"Fairphone"],[nt,yn]],[/(shield[\w ]+) b/i],[st,[vt,"Nvidia"],[nt,Zr]],[/(sprint) (\w+)/i],[vt,st,[nt,yn]],[/(kin\.[onetw]{3})/i],[[st,/\./g," "],[vt,Qw],[nt,yn]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[st,[vt,SR],[nt,Zr]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[st,[vt,SR],[nt,yn]],[/smart-tv.+(samsung)/i],[vt,[nt,Ho]],[/hbbtv.+maple;(\d+)/i],[[st,/^/,"SmartTV"],[vt,Ib],[nt,Ho]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[vt,_R],[nt,Ho]],[/(apple) ?tv/i],[vt,[st,Rb+" TV"],[nt,Ho]],[/crkey.*devicetype\/chromecast/i],[[st,sd+" Third Generation"],[vt,Vh],[nt,Ho]],[/crkey.*devicetype\/([^/]*)/i],[[st,/^/,"Chromecast "],[vt,Vh],[nt,Ho]],[/fuchsia.*crkey/i],[[st,sd+" Nest Hub"],[vt,Vh],[nt,Ho]],[/crkey/i],[[st,sd],[vt,Vh],[nt,Ho]],[/droid.+aft(\w+)( bui|\))/i],[st,[vt,Zw],[nt,Ho]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[st,[vt,b9],[nt,Ho]],[/(bravia[\w ]+)( bui|\))/i],[st,[vt,Kw],[nt,Ho]],[/(mitv-\w{5}) bui/i],[st,[vt,xR],[nt,Ho]],[/Hbbtv.*(technisat) (.*);/i],[vt,st,[nt,Ho]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[vt,Bb],[st,Bb],[nt,Ho]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[nt,Ho]],[/(ouya)/i,/(nintendo) (\w+)/i],[vt,st,[nt,Cm]],[/droid.+; (shield) bui/i],[st,[vt,"Nvidia"],[nt,Cm]],[/(playstation \w+)/i],[st,[vt,Kw],[nt,Cm]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[st,[vt,Qw],[nt,Cm]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[st,[vt,Ib],[nt,Mb]],[/((pebble))app/i],[vt,st,[nt,Mb]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[st,[vt,Rb],[nt,Mb]],[/droid.+; (wt63?0{2,3})\)/i],[st,[vt,SR],[nt,Mb]],[/droid.+; (glass) \d/i],[st,[vt,Vh],[nt,pR]],[/(pico) (4|neo3(?: link|pro)?)/i],[vt,st,[nt,pR]],[/; (quest( \d| pro)?)/i],[st,[vt,x9],[nt,pR]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[vt,[nt,gR]],[/(aeobc)\b/i],[st,[vt,Zw],[nt,gR]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[st,[nt,yn]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[st,[nt,Zr]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[nt,Zr]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[nt,yn]],[/(android[-\w\. ]{0,9});.+buil/i],[st,[vt,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[ot,[rt,One+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[rt,ot],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[ot,[rt,"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],[rt,ot],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[ot,rt]],os:[[/microsoft (windows) (vista|xp)/i],[rt,ot],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[rt,[ot,zb,C9]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[ot,zb,C9],[rt,wR]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[ot,/_/g,"."],[rt,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[rt,"macOS"],[ot,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[ot,[rt,sd+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[ot,[rt,sd+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[ot,[rt,sd+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[ot,[rt,sd+" Linux"]],[/crkey\/([\d\.]+)/i],[ot,[rt,sd]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[ot,rt],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[rt,ot],[/\(bb(10);/i],[ot,[rt,g9]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[ot,[rt,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[ot,[rt,$b+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[ot,[rt,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[ot,[rt,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[rt,"Chrome OS"],ot],[/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],[rt,ot],[/(sunos) ?([\w\.\d]*)/i],[[rt,"Solaris"],ot],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[rt,ot]]},Jw=function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return Ac.call(e.init,[[rs,[rt,ot,Tb,nt]],[Cc,[Oa]],[yu,[nt,st,vt]],[Ec,[rt,ot]],[Rs,[rt,ot]]]),Ac.call(e.isIgnore,[[rs,[ot,Tb]],[Ec,[ot]],[Rs,[ot]]]),Ac.call(e.isIgnoreRgx,[[rs,/ ?browser$/i],[Rs,/ ?os$/i]]),Ac.call(e.toString,[[rs,[rt,ot]],[Cc,[Oa]],[yu,[vt,st]],[Ec,[rt,ot]],[Rs,[rt,ot]]]),e}(),Dne=function(e,t){var n=Jw.init[t],r=Jw.isIgnore[t]||0,o=Jw.isIgnoreRgx[t]||0,s=Jw.toString[t]||0;function u(){Ac.call(this,n)}return u.prototype.getItem=function(){return e},u.prototype.withClientHints=function(){return ld?ld.getHighEntropyValues(h9).then(function(d){return e.setCH(new A9(d,!1)).parseCH().get()}):e.parseCH().get()},u.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=km&&(u.prototype.is=function(d){var h=!1;for(var m in this)if(this.hasOwnProperty(m)&&!CR(r,m)&&kc(o?Yh(o,this[m]):this[m])==kc(o?Yh(o,d):d)){if(h=!0,d!=od)break}else if(d==od&&h){h=!h;break}return h},u.prototype.toString=function(){var d=Sm;for(var h in s)typeof this[s[h]]!==od&&(d+=(d?" ":Sm)+this[s[h]]);return d||od}),ld||(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 A9(e,t){if(e=e||{},Ac.call(this,h9),t)Ac.call(this,[[vR,ER(e[ad])],[yR,ER(e[Sne])],[yn,/\?1/.test(e[kne])],[st,Nb(e[Ane])],[Em,Nb(e[d9])],[bR,Nb(e[Tne])],[Oa,Nb(e[wne])],[Gh,ER(e[Ene])],[Yw,Nb(e[Cne])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==od&&(this[n]=e[n])}function T9(e,t,n,r){return this.get=function(o){return o?this.data.hasOwnProperty(o)?this.data[o]:void 0:this.data},this.set=function(o,s){return this.data[o]=s,this},this.setCH=function(o){return this.uaCH=o,this},this.detectFeature=function(){if(Ra&&Ra.userAgent==this.ua)switch(this.itemType){case rs:Ra.brave&&typeof Ra.brave.isBrave==Vw&&this.set(rt,"Brave");break;case yu:!this.get(nt)&&ld&&ld[yn]&&this.set(nt,yn),this.get(st)=="Macintosh"&&Ra&&typeof Ra.standalone!==od&&Ra.maxTouchPoints&&Ra.maxTouchPoints>2&&this.set(st,"iPad").set(nt,Zr);break;case Rs:!this.get(rt)&&ld&&ld[Em]&&this.set(rt,ld[Em]);break;case km:var o=this.data,s=function(u){return o[u].getItem().detectFeature().get()};this.set(rs,s(rs)).set(Cc,s(Cc)).set(yu,s(yu)).set(Ec,s(Ec)).set(Rs,s(Rs))}return this},this.parseUA=function(){return this.itemType!=km&&w9.call(this.data,this.ua,this.rgxMap),this.itemType==rs&&this.set(Tb,kR(this.get(ot))),this},this.parseCH=function(){var o=this.uaCH,s=this.rgxMap;switch(this.itemType){case rs:var u=o[yR]||o[vR],d;if(u)for(var h in u){var m=Yh(/(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(rt,m).set(ot,y).set(Tb,kR(y)),d=m)}break;case Cc:var v=o[Oa];v&&(v&&o[Yw]=="64"&&(v+="64"),w9.call(this.data,v+";",s));break;case yu:if(o[yn]&&this.set(nt,yn),o[st]&&this.set(st,o[st]),o[st]=="Xbox"&&this.set(nt,Cm).set(vt,Qw),o[Gh]){var x;if(typeof o[Gh]!="string")for(var w=0;!x&&w<o[Gh].length;)x=zb(o[Gh][w++],E9);else x=zb(o[Gh],E9);this.set(nt,x)}break;case Rs:var E=o[Em];if(E){var M=o[bR];E==wR&&(M=parseInt(kR(M),10)>=13?"11":"10"),this.set(rt,E).set(ot,M)}this.get(rt)==wR&&o[st]=="Xbox"&&this.set(rt,"Xbox").set(ot,void 0);break;case km:var A=this.data,k=function(R){return A[R].getItem().setCH(o).parseCH().get()};this.set(rs,k(rs)).set(Cc,k(Cc)).set(yu,k(yu)).set(Ec,k(Ec)).set(Rs,k(Rs))}return this},Ac.call(this,[["itemType",e],["ua",t],["uaCH",r],["rgxMap",n],["data",Dne(this,e)]]),this}function Tc(e,t,n){if(typeof e===wm?(Ww(e,!0)?(typeof t===wm&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===hR&&!Ww(t,!0)&&(n=t,t=void 0),n&&typeof n.append===Vw){var r={};n.forEach(function(h,m){r[m]=h}),n=r}if(!(this instanceof Tc))return new Tc(e,t,n).getResult();var o=typeof e===hR?e:n&&n[f9]?n[f9]:Ra&&Ra.userAgent?Ra.userAgent:Sm,s=new A9(n,!0),u=t?Ine(k9,t):k9,d=function(h){return h==km?function(){return new T9(h,o,u,s).set("ua",o).set(rs,this.getBrowser()).set(Cc,this.getCPU()).set(yu,this.getDevice()).set(Ec,this.getEngine()).set(Rs,this.getOS()).get()}:function(){return new T9(h,o,u[h],s).parseUA().get()}};return Ac.call(this,[["getBrowser",d(rs)],["getCPU",d(Cc)],["getDevice",d(yu)],["getEngine",d(Ec)],["getOS",d(Rs)],["getResult",d(km)],["getUA",function(){return o}],["setUA",function(h){return Tm(h)&&(o=h.length>mR?Bb(h,mR):h),this}]]).setUA(o),this}Tc.VERSION=xne,Tc.BROWSER=Xw([rt,ot,Tb,nt]),Tc.CPU=Xw([Oa]),Tc.DEVICE=Xw([st,vt,nt,Cm,yn,Ho,Zr,Mb,gR]),Tc.ENGINE=Tc.OS=Xw([rt,ot]);const Ds=class Ds{constructor(t){oo(this,"config");oo(this,"storedData");oo(this,"deviceInfo");oo(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){Ds.instance||(Ds.instance=new Ds(t))}static getInstance(){if(!Ds.instance)throw new Error("DebalesAnalytics is not initialized. Call init() first.");return Ds.instance}static async identify(t,n){return Ds.getInstance().identifyInternal(t,n)}static track(t,n){Ds.getInstance().trackInternal(t,n)}static getDistinctId(){return Ds.getInstance().storedData.distinctId}static getAnonId(){return Ds.getInstance().storedData.anonId}async identifyInternal(t,n){try{if(this.config.testing&&this.config.testing())return;let r,o,s;if(n){const{name:h,phone:m,...y}=n;r=h,o=m,s=y}const u={distinctId:this.storedData.distinctId,anonId:[this.storedData.anonId],projectName:this.config.projectName,email:t,name:r,phone:o,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:tr()+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(`${ci}${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 Tc().getResult();return{browser:n.browser.name,os:n.os.name,browserVersion:n.browser.version,osVersion:n.os.version}}};oo(Ds,"instance",null);let AR=Ds;const bu=AR;function $ne(e){D$(e,[/\r?\n|\r/g,Lne])}function Lne(){return{type:"break"}}function eC(){return function(e){$ne(e)}}const Gt={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"},fr={OPEN_STATE_CHANGE:"open_state_change"},tC=e=>{window.DebalesChat||(window.DebalesChat={isOpen:!1,projectId:e,getSessionId:()=>tr(),getChatId:()=>tr()+"_"+e,getAnonId:()=>bu.getAnonId(),isIdentified:()=>{if(ks._isIdentified())return!0;const t=bo();return!!(t&&t.email)},getIdentifiedUser:()=>bo(),getDistinctId:()=>ks.get_distinct_id(),getOldDistinctId:()=>bu.getDistinctId(),debug:!1,identify:(t,n)=>{ks._isIdentified()||ks.identify(t,{...n,project:e}),bu.identify(t,n),wc({email:t,name:n==null?void 0:n.name,phone:n==null?void 0:n.phone})},track:(t,n)=>{bu.track(t,{...n,sessionId:window.DebalesChat.getSessionId()}),ks.capture(t,{...n}),yne(t,{...n,sessionId:tr(),projectId:e})},onOpenChange:t=>{const n=r=>{t(r.detail.isOpen)};return window.addEventListener(fr.OPEN_STATE_CHANGE,n),()=>window.removeEventListener(fr.OPEN_STATE_CHANGE,n)},removeOpenChangeListener:t=>{const n=r=>{t(r.detail.isOpen)};window.removeEventListener(fr.OPEN_STATE_CHANGE,n)},open:()=>{window.DebalesChat.isOpen||window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:!0,projectId:e}}))},close:()=>{window.DebalesChat.isOpen&&window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:!1,projectId:e}}))},toggle:()=>{window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:!window.DebalesChat.isOpen,projectId:e}}))}})};var xo=(e=>(e.DEFAULT="DEFAULT",e.SHOPIFY="SHOPIFY",e.WOOCOMMERCE="WOOCOMMERCE",e.MAGENTO="MAGENTO",e.UNKNOWN="UNKNOWN",e))(xo||{});class ud{static detect(){var t,n,r,o,s,u;if(typeof window<"u"&&window.Shopify!==void 0&&window.Shopify.routes!==void 0)return xo.SHOPIFY;if(typeof window<"u"&&document.body.classList.contains("woocommerce"))return xo.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 xo.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")||(o=v.getAttribute("data-requiremodule"))!=null&&o.startsWith("Magento"))return xo.MAGENTO;if(document.cookie.split(";").some(v=>v.trim().startsWith("mage-")||v.trim().startsWith("form_key")))return xo.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 xo.MAGENTO}return xo.UNKNOWN}}const nC=V.button`
118
118
  width: max-content;
119
119
  cursor: pointer;
120
120
  border-radius: 50px !important;
@@ -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
- `,TU=({botId:e})=>{var ii,sr;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=t==null?void 0:t.isLeft,fe=oC(),Se=t==null?void 0:t.heightOption,[se,pe]=W.useState(!1);W.useEffect(()=>{const P=()=>{pe(window.matchMedia("(max-width: 768px)").matches)};return P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const[Z,ie]=Ge.useState(!1),[ye,He]=Ge.useState(!1),[U,Be]=W.useState(""),[Oe,F]=W.useState(""),[,We]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let P=bo();if(!P&&window.Thinkific){const ve=window.Thinkific.current_user;ve&&(P={name:ve.full_name,email:ve.email},wc(P))}bu.init({projectName:e,debug:!0,testing:kb}),P&&P.email&&(window.DebalesChat.identify(P.email,{name:P.name,phone:P.phone,email:P.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:P.email,first_name:P.name,phone:P.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const at=Ge.useRef(null),Qe=Dn(In.CLICKED_QUESTIONS,{botId:e}),[Bt,St]=W.useState(()=>{try{const P=sessionStorage.getItem(Qe);return P?new Set(JSON.parse(P)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(Qe,JSON.stringify(Array.from(Bt)))}catch(P){console.error("Failed to save to sessionStorage:",P)}},[Bt]);const $t=W.useCallback((P,ve)=>{P?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})),setTimeout(()=>{He(!0)},50)):(He(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})))},[]);W.useEffect(()=>{const P=ve=>{ie(ve.detail.isOpen),ve.detail.isOpen&&setTimeout(()=>He(!0),50),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen,source:ve.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]),W.useEffect(()=>{const P=ve=>{ie(ve.detail.isOpen),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]);const[qt,gt]=Ge.useState(!1),[Fe,lt]=Ge.useState(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e}),ve=sessionStorage.getItem(P);return ve?JSON.parse(ve):[]});Ge.useEffect(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(P,JSON.stringify(Fe))},[Fe,e]);const[ct,zt]=W.useState(!1),[pt,dt]=W.useState({name:"",email:"",message:""}),G=jf("exit_model"),[X,ce]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Ie,$e]=W.useState({suggestions:!1,products:!1,collections:!1,leadingQueries:!1,initialMessage:!1,cartSummary:!1,bulkItems:!1}),[Pe,wt]=W.useState(!1),[kt,ge]=W.useState(!0),[Re,ht]=W.useState(!1),[xt,At]=W.useState(!1),dn=2e3,bn=W.useCallback(P=>{const ve=P.target,ze=ve.scrollHeight-ve.scrollTop<=ve.clientHeight+0;ge(ze)},[]);Ge.useEffect(()=>{var P,ve,ze,Xe,be,ft;if(h.length>0&&!m){const Ot=h[h.length-1],he=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),te=Ot.isBot&&Ot.conversationId===u&&Ot.conversationId!==he,ke=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&Ot.conversationId===u;if(te){wt(!0),$e(et=>({...et,initialMessage:!0})),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),Ot.conversationId||""),ce({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const de=1600;let Je=de;const Ve=[{type:"collections",condition:((P=Ot.collections)==null?void 0:P.length)&&((ve=Ot.collections)==null?void 0:ve.length)>0},{type:"products",condition:((ze=Ot.products)==null?void 0:ze.length)&&((Xe=Ot.products)==null?void 0:Xe.length)>0},{type:"leadingQueries",condition:h.length>=1&&((be=Ot.leading_queries)==null?void 0:be.length)&&((ft=Ot.leading_queries)==null?void 0:ft.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(Fe==null?void 0:Fe.length)>0}].filter(et=>et.condition);if(Ve.length===0){wt(!1),$e(et=>({...et,initialMessage:!1,leadingQueries:!1}));return}Ve.forEach(({type:et},Nt)=>{setTimeout(()=>{if($e(tn=>({...tn,[et]:!0})),ce(tn=>({...tn,[et]:!0})),kt&&at.current){const tn=at.current;tn.scrollHeight-tn.scrollTop<=tn.clientHeight&&jo(at)}Nt===Ve.length-1&&wt(!1)},Je),Je+=de})}else ke&&ce(de=>({...de,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,Fe==null?void 0:Fe.length,kt,e,X]),Ge.useEffect(()=>{if(!o&&h.length>0){const P=at.current;P&&kt&&P.scrollHeight-P.scrollTop<=P.clientHeight+100&&setTimeout(()=>jo(at),100)}},[h.length,o,kt]),Ge.useEffect(()=>{const P=document.querySelector('meta[name="viewport"]'),ve=P==null?void 0:P.content;if(Z){let ze=P;const Xe=window.matchMedia("(max-width: 768px)").matches;ze?ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(ze=document.createElement("meta"),ze.name="viewport",ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(ze)),Xe&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const be=ze;return()=>{ve&&be&&(be.content=ve),Xe&&(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="")}},[Z,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(Z&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const P=ve=>{let ze=ve.target,Xe=!1;const be=at.current;if(be){for(;ze&&ze!==document.body;){if(ze===be){Xe=!0;break}if(ze.parentNode)ze=ze.parentNode;else break}if(!Xe)ve.preventDefault();else{const ft=be.scrollTop<=0,Ot=be.scrollTop+be.clientHeight>=be.scrollHeight-5;if(ft&&ve.touches[0].clientY>0||Ot&&ve.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",P,{passive:!1}),()=>{document.removeEventListener("touchmove",P)}}return()=>{}},[Z,t==null?void 0:t.mobileDisplayMode,at]),Ge.useEffect(()=>{const P=setTimeout(()=>{gt(!0)},1e3);return()=>clearTimeout(P)},[]),Ge.useEffect(()=>{o||setTimeout(()=>jo(at),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(at),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Wt=Ge.useRef(Date.now()),hn=Ge.useRef(0),Mt=Ge.useRef(window.location.pathname),Zt=Ge.useRef(M),mt=Ge.useRef(!1),It=jf("acquisition_agent");Ge.useEffect(()=>{Zt.current=M},[M]);const or=Ge.useCallback(async()=>{const P=Date.now();if(P-Wt.current>=6e3&&P-hn.current>=6e4&&!mt.current)try{mt.current=!0,console.log("fetching acquisition data");const Xe=await fetch(`${ci}/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(Xe.ok){const be=await Xe.json(),Ot=[...Zt.current.filter(he=>he.path!==Mt.current),{question:be.Popup_Message,answer:"",path:Mt.current,nameSpace:e,type:"dynamic",Follow_up_Question:be.Follow_up_Question}];A(Ot)}hn.current=P}catch(Xe){console.error("Error fetching acquisition data:",Xe)}finally{mt.current=!1}},[e]);Ge.useEffect(()=>{if(!It||(t==null?void 0:t.show_bot)===!1)return;const P=()=>{Wt.current=Date.now()};document.addEventListener("mousemove",P),document.addEventListener("mousedown",P),document.addEventListener("keypress",P),document.addEventListener("scroll",P),document.addEventListener("touchstart",P),document.addEventListener("touchmove",P);const ve=setInterval(or,1e3),ze=()=>{const be=window.location.pathname.split("?")[0],ft=Mt.current.split("?")[0];(()=>{const he=ft.split("/").filter(Boolean),te=be.split("/").filter(Boolean);return he.length!==te.length?!0:he.length===0&&te.length===0?!1:be!==ft})()&&(Mt.current=be,Wt.current=Date.now())};return window.addEventListener("popstate",ze),()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mousedown",P),document.removeEventListener("keypress",P),document.removeEventListener("scroll",P),document.removeEventListener("touchstart",P),document.removeEventListener("touchmove",P),window.removeEventListener("popstate",ze),clearInterval(ve)}},[It,or,t==null?void 0:t.show_bot]);const[Or,ar]=W.useState(!1),[Rr,Di]=W.useState(!1),[$i,bi]=W.useState(null),xr=async P=>{const ve=tr();if(He(!1),P&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ve,userRating:P,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(ze){console.error("Error submitting rating:",ze)}setTimeout(()=>{Di(!1),$t(!1,"close_button_clicked")},1e3)},Li=P=>{y(!0),Fe.forEach(ze=>{H(ze.id,ze.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:Fe,message:P});const ve=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:P,isBot:!0}];v(ve),x(ve),d(P),lt([]),y(!1)},Ni=()=>{var P;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((P=window.shiprocketCheckoutEvents)!=null&&P.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},is=async P=>{P.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),Ni()&&$t(!1,"checkout_clicked")},[Tn,dr]=W.useState([]);Ge.useEffect(()=>{const P=_ne(Fw(M));dr(P)},[M]);const Xn=Ge.useMemo(()=>Tn.map(P=>{if(Array.isArray(P)){const ve=P.filter(Xe=>!Bt.has(Xe.question));if(ve.length===0)return null;const ze={isHighlighted:P[0].isHighlighted,enable:P[0].enable,type:P[0].type};return ve.map(Xe=>({...Xe,...ze}))}else return Bt.has(P.question)?null:P}).filter(Boolean),[Tn,Bt]);Ge.useEffect(()=>{const P=Xe=>{const be=Xe.detail.formId;switch(Xe.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Ot=ve(be);Ot&&Be(Ot)},800);break;case"close":U&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{$t(!0,"klaviyo_form_closed"),F(be),r(U,void 0,void 0,!0,void 0,void 0)},1e4);break}},ve=Xe=>{const be=document.querySelector(`[data-testid="klaviyo-form-${Xe}"]`);if(console.log(`formElement text ${Xe} =>`,be==null?void 0:be.innerText,be==null?void 0:be.textContent),be instanceof HTMLElement){const ft=be.innerText||be.textContent;if(ft)return console.log("Found form text:",ft),`=> Klaviyo form content:
2309
+ `,TU=({botId:e})=>{var ii,sr;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=t==null?void 0:t.isLeft,fe=oC(),Se=t==null?void 0:t.heightOption,[se,pe]=W.useState(!1);W.useEffect(()=>{const P=()=>{pe(window.matchMedia("(max-width: 768px)").matches)};return P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const[Z,ie]=Ge.useState(!1),[ye,He]=Ge.useState(!1),[U,Be]=W.useState(""),[Oe,F]=W.useState(""),[,We]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let P=bo();if(!P&&window.Thinkific){const ve=window.Thinkific.current_user;ve&&(P={name:ve.full_name,email:ve.email},wc(P))}bu.init({projectName:e,debug:!1,testing:kb}),P&&P.email&&(window.DebalesChat.identify(P.email,{name:P.name,phone:P.phone,email:P.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:P.email,first_name:P.name,phone:P.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const at=Ge.useRef(null),Qe=Dn(In.CLICKED_QUESTIONS,{botId:e}),[Bt,St]=W.useState(()=>{try{const P=sessionStorage.getItem(Qe);return P?new Set(JSON.parse(P)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(Qe,JSON.stringify(Array.from(Bt)))}catch(P){console.error("Failed to save to sessionStorage:",P)}},[Bt]);const $t=W.useCallback((P,ve)=>{P?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})),setTimeout(()=>{He(!0)},50)):(He(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})))},[]);W.useEffect(()=>{const P=ve=>{ie(ve.detail.isOpen),ve.detail.isOpen&&setTimeout(()=>He(!0),50),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen,source:ve.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]),W.useEffect(()=>{const P=ve=>{ie(ve.detail.isOpen),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]);const[qt,gt]=Ge.useState(!1),[Fe,lt]=Ge.useState(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e}),ve=sessionStorage.getItem(P);return ve?JSON.parse(ve):[]});Ge.useEffect(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(P,JSON.stringify(Fe))},[Fe,e]);const[ct,zt]=W.useState(!1),[pt,dt]=W.useState({name:"",email:"",message:""}),G=jf("exit_model"),[X,ce]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Ie,$e]=W.useState({suggestions:!1,products:!1,collections:!1,leadingQueries:!1,initialMessage:!1,cartSummary:!1,bulkItems:!1}),[Pe,wt]=W.useState(!1),[kt,ge]=W.useState(!0),[Re,ht]=W.useState(!1),[xt,At]=W.useState(!1),dn=2e3,bn=W.useCallback(P=>{const ve=P.target,ze=ve.scrollHeight-ve.scrollTop<=ve.clientHeight+0;ge(ze)},[]);Ge.useEffect(()=>{var P,ve,ze,Xe,be,ft;if(h.length>0&&!m){const Ot=h[h.length-1],he=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),te=Ot.isBot&&Ot.conversationId===u&&Ot.conversationId!==he,ke=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&Ot.conversationId===u;if(te){wt(!0),$e(et=>({...et,initialMessage:!0})),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),Ot.conversationId||""),ce({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const de=1600;let Je=de;const Ve=[{type:"collections",condition:((P=Ot.collections)==null?void 0:P.length)&&((ve=Ot.collections)==null?void 0:ve.length)>0},{type:"products",condition:((ze=Ot.products)==null?void 0:ze.length)&&((Xe=Ot.products)==null?void 0:Xe.length)>0},{type:"leadingQueries",condition:h.length>=1&&((be=Ot.leading_queries)==null?void 0:be.length)&&((ft=Ot.leading_queries)==null?void 0:ft.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(Fe==null?void 0:Fe.length)>0}].filter(et=>et.condition);if(Ve.length===0){wt(!1),$e(et=>({...et,initialMessage:!1,leadingQueries:!1}));return}Ve.forEach(({type:et},Nt)=>{setTimeout(()=>{if($e(tn=>({...tn,[et]:!0})),ce(tn=>({...tn,[et]:!0})),kt&&at.current){const tn=at.current;tn.scrollHeight-tn.scrollTop<=tn.clientHeight&&jo(at)}Nt===Ve.length-1&&wt(!1)},Je),Je+=de})}else ke&&ce(de=>({...de,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,Fe==null?void 0:Fe.length,kt,e,X]),Ge.useEffect(()=>{if(!o&&h.length>0){const P=at.current;P&&kt&&P.scrollHeight-P.scrollTop<=P.clientHeight+100&&setTimeout(()=>jo(at),100)}},[h.length,o,kt]),Ge.useEffect(()=>{const P=document.querySelector('meta[name="viewport"]'),ve=P==null?void 0:P.content;if(Z){let ze=P;const Xe=window.matchMedia("(max-width: 768px)").matches;ze?ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(ze=document.createElement("meta"),ze.name="viewport",ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(ze)),Xe&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const be=ze;return()=>{ve&&be&&(be.content=ve),Xe&&(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="")}},[Z,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(Z&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const P=ve=>{let ze=ve.target,Xe=!1;const be=at.current;if(be){for(;ze&&ze!==document.body;){if(ze===be){Xe=!0;break}if(ze.parentNode)ze=ze.parentNode;else break}if(!Xe)ve.preventDefault();else{const ft=be.scrollTop<=0,Ot=be.scrollTop+be.clientHeight>=be.scrollHeight-5;if(ft&&ve.touches[0].clientY>0||Ot&&ve.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",P,{passive:!1}),()=>{document.removeEventListener("touchmove",P)}}return()=>{}},[Z,t==null?void 0:t.mobileDisplayMode,at]),Ge.useEffect(()=>{const P=setTimeout(()=>{gt(!0)},1e3);return()=>clearTimeout(P)},[]),Ge.useEffect(()=>{o||setTimeout(()=>jo(at),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(at),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Wt=Ge.useRef(Date.now()),hn=Ge.useRef(0),Mt=Ge.useRef(window.location.pathname),Zt=Ge.useRef(M),mt=Ge.useRef(!1),It=jf("acquisition_agent");Ge.useEffect(()=>{Zt.current=M},[M]);const or=Ge.useCallback(async()=>{const P=Date.now();if(P-Wt.current>=6e3&&P-hn.current>=6e4&&!mt.current)try{mt.current=!0,console.log("fetching acquisition data");const Xe=await fetch(`${ci}/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(Xe.ok){const be=await Xe.json(),Ot=[...Zt.current.filter(he=>he.path!==Mt.current),{question:be.Popup_Message,answer:"",path:Mt.current,nameSpace:e,type:"dynamic",Follow_up_Question:be.Follow_up_Question}];A(Ot)}hn.current=P}catch(Xe){console.error("Error fetching acquisition data:",Xe)}finally{mt.current=!1}},[e]);Ge.useEffect(()=>{if(!It||(t==null?void 0:t.show_bot)===!1)return;const P=()=>{Wt.current=Date.now()};document.addEventListener("mousemove",P),document.addEventListener("mousedown",P),document.addEventListener("keypress",P),document.addEventListener("scroll",P),document.addEventListener("touchstart",P),document.addEventListener("touchmove",P);const ve=setInterval(or,1e3),ze=()=>{const be=window.location.pathname.split("?")[0],ft=Mt.current.split("?")[0];(()=>{const he=ft.split("/").filter(Boolean),te=be.split("/").filter(Boolean);return he.length!==te.length?!0:he.length===0&&te.length===0?!1:be!==ft})()&&(Mt.current=be,Wt.current=Date.now())};return window.addEventListener("popstate",ze),()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mousedown",P),document.removeEventListener("keypress",P),document.removeEventListener("scroll",P),document.removeEventListener("touchstart",P),document.removeEventListener("touchmove",P),window.removeEventListener("popstate",ze),clearInterval(ve)}},[It,or,t==null?void 0:t.show_bot]);const[Or,ar]=W.useState(!1),[Rr,Di]=W.useState(!1),[$i,bi]=W.useState(null),xr=async P=>{const ve=tr();if(He(!1),P&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ve,userRating:P,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(ze){console.error("Error submitting rating:",ze)}setTimeout(()=>{Di(!1),$t(!1,"close_button_clicked")},1e3)},Li=P=>{y(!0),Fe.forEach(ze=>{H(ze.id,ze.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:Fe,message:P});const ve=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:P,isBot:!0}];v(ve),x(ve),d(P),lt([]),y(!1)},Ni=()=>{var P;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((P=window.shiprocketCheckoutEvents)!=null&&P.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},is=async P=>{P.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),Ni()&&$t(!1,"checkout_clicked")},[Tn,dr]=W.useState([]);Ge.useEffect(()=>{const P=_ne(Fw(M));dr(P)},[M]);const Xn=Ge.useMemo(()=>Tn.map(P=>{if(Array.isArray(P)){const ve=P.filter(Xe=>!Bt.has(Xe.question));if(ve.length===0)return null;const ze={isHighlighted:P[0].isHighlighted,enable:P[0].enable,type:P[0].type};return ve.map(Xe=>({...Xe,...ze}))}else return Bt.has(P.question)?null:P}).filter(Boolean),[Tn,Bt]);Ge.useEffect(()=>{const P=Xe=>{const be=Xe.detail.formId;switch(Xe.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Ot=ve(be);Ot&&Be(Ot)},800);break;case"close":U&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{$t(!0,"klaviyo_form_closed"),F(be),r(U,void 0,void 0,!0,void 0,void 0)},1e4);break}},ve=Xe=>{const be=document.querySelector(`[data-testid="klaviyo-form-${Xe}"]`);if(console.log(`formElement text ${Xe} =>`,be==null?void 0:be.innerText,be==null?void 0:be.textContent),be instanceof HTMLElement){const ft=be.innerText||be.textContent;if(ft)return console.log("Found form text:",ft),`=> Klaviyo form content:
2310
2310
 
2311
2311
  `+ft+`
2312
2312
 
@@ -3151,7 +3151,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3151
3151
  margin-top: 16px;
3152
3152
  display: flex;
3153
3153
  justify-content: flex-end;
3154
- `,Jse=({botId:e})=>{var ii,sr;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=t==null?void 0:t.isLeft,fe=oC(),Se=t==null?void 0:t.heightOption,pe=$h("new-suggested-question-design"),[Z,ie]=W.useState(!1),[ye,He]=W.useState(!1),[U,Be]=W.useState(!1),Oe=W.useCallback(async()=>{try{const P=await fetch(`${ci}/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(P.ok){const ve=await P.json(),ze=window.location.pathname,Xe=M.filter(be=>be.path!==ze);A([...Xe,{question:ve.Popup_Message,answer:"",path:ze,nameSpace:e,type:"dynamic",Follow_up_Question:ve.Follow_up_Question}])}else console.error("Failed to fetch new acquisition question")}catch(P){console.error("Error fetching new acquisition question:",P)}},[e,M,A]);W.useEffect(()=>{console.log("[Debug] Suggested questions updated:",M)},[M]),W.useEffect(()=>{if(console.log("[Debug] Starting suggestion cycle with timePayload:",pe),!pe){console.log("[Debug] No timePayload provided, exiting cycle");return}let P,ve,ze,Xe;const be=()=>{console.log("[Debug] Starting new cycle at:",new Date().toISOString()),P=setTimeout(()=>{console.log("[Debug] Showing notification after delay:",pe.showing_delay||2e3,"ms"),ie(!0),ve=setTimeout(()=>{console.log("[Debug] Showing message and suggestion container after delay:",pe.showing_delay||2e3,"ms"),Be(!0),He(!0),ze=setTimeout(async()=>{console.log("[Debug] Hiding message and suggestion container after:",pe.show_for||44324,"ms"),Be(!1),He(!1),console.log("[Debug] Fetching new acquisition question"),await Oe(),console.log("[Debug] New acquisition question fetched"),Xe=setTimeout(()=>{console.log("[Debug] Starting new cycle after hide timing:",pe.hide_timing||4e3,"ms"),Be(!0),ie(!0),He(!0),be()},pe.hide_timing||4e3)},pe.show_for||44324)},pe.showing_delay||2e3)},pe.showing_delay||2e3)};return be(),()=>{console.log("[Debug] Cleaning up timers"),clearTimeout(P),clearTimeout(ve),clearTimeout(ze),clearTimeout(Xe)}},[pe,Oe]);const[F,We]=W.useState(!1);W.useEffect(()=>{const P=()=>{We(window.matchMedia("(max-width: 768px)").matches)};return P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const[at,Qe]=Ge.useState(!1),[Bt,St]=Ge.useState(!1),[$t,qt]=W.useState(""),[gt,Fe]=W.useState(""),[,lt]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let P=bo();if(!P&&window.Thinkific){const ve=window.Thinkific.current_user;ve&&(P={name:ve.full_name,email:ve.email},wc(P))}bu.init({projectName:e,debug:!0,testing:kb}),P&&P.email&&(window.DebalesChat.identify(P.email,{name:P.name,phone:P.phone,email:P.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:P.email,first_name:P.name,phone:P.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const ct=Ge.useRef(null),zt=Dn(In.CLICKED_QUESTIONS,{botId:e}),[pt,dt]=W.useState(()=>{try{const P=sessionStorage.getItem(zt);return P?new Set(JSON.parse(P)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(zt,JSON.stringify(Array.from(pt)))}catch(P){console.error("Failed to save to sessionStorage:",P)}},[pt]);const G=W.useCallback((P,ve)=>{P?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})),setTimeout(()=>{St(!0)},50)):(St(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})))},[]);W.useEffect(()=>{const P=ve=>{Qe(ve.detail.isOpen),ve.detail.isOpen&&setTimeout(()=>St(!0),50),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen,source:ve.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]),W.useEffect(()=>{const P=ve=>{Qe(ve.detail.isOpen),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]);const[X,ce]=Ge.useState(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e}),ve=sessionStorage.getItem(P);return ve?JSON.parse(ve):[]});Ge.useEffect(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(P,JSON.stringify(X))},[X,e]);const[Ie,$e]=W.useState(!1),[Pe,wt]=W.useState({name:"",email:"",message:""}),kt=jf("exit_model"),[ge,Re]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[ht,xt]=W.useState(!1),[At,dn]=W.useState(!0),[bn,Wt]=W.useState(!1),[hn,Mt]=W.useState(!1),Zt=500,mt=W.useCallback(P=>{const ve=P.target,ze=ve.scrollHeight-ve.scrollTop<=ve.clientHeight+0;dn(ze)},[]);Ge.useEffect(()=>{var P,ve,ze,Xe,be,ft;if(h.length>0&&!m){const Ot=h[h.length-1],he=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),te=Ot.isBot&&Ot.conversationId===u&&Ot.conversationId!==he,ke=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&Ot.conversationId===u;if(te){xt(!0),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),Ot.conversationId||""),Re({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const de=1600;let Je=de;const Ve=[{type:"collections",condition:((P=Ot.collections)==null?void 0:P.length)&&((ve=Ot.collections)==null?void 0:ve.length)>0},{type:"products",condition:((ze=Ot.products)==null?void 0:ze.length)&&((Xe=Ot.products)==null?void 0:Xe.length)>0},{type:"leadingQueries",condition:((be=Ot.leading_queries)==null?void 0:be.length)&&((ft=Ot.leading_queries)==null?void 0:ft.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(X==null?void 0:X.length)>0}].filter(et=>et.condition);if(Ve.length===0){xt(!1);return}Ve.forEach(({type:et},Nt)=>{setTimeout(()=>{if(Re(tn=>({...tn,[et]:!0})),At&&ct.current){const tn=ct.current;tn.scrollHeight-tn.scrollTop<=tn.clientHeight&&jo(ct)}Nt===Ve.length-1&&xt(!1)},Je),Je+=de})}else ke&&Re(de=>({...de,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,X==null?void 0:X.length,At,e]),Ge.useEffect(()=>{if(!o&&h.length>0){const P=ct.current;P&&At&&P.scrollHeight-P.scrollTop<=P.clientHeight+100&&setTimeout(()=>jo(ct),100)}},[h.length,o,At]),Ge.useEffect(()=>{const P=document.querySelector('meta[name="viewport"]'),ve=P==null?void 0:P.content;if(at){let ze=P;const Xe=window.matchMedia("(max-width: 768px)").matches;ze?ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(ze=document.createElement("meta"),ze.name="viewport",ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(ze)),Xe&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const be=ze;return()=>{ve&&be&&(be.content=ve),Xe&&(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="")}},[at,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(at&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const P=ve=>{let ze=ve.target,Xe=!1;const be=ct.current;if(be){for(;ze&&ze!==document.body;){if(ze===be){Xe=!0;break}if(ze.parentNode)ze=ze.parentNode;else break}if(!Xe)ve.preventDefault();else{const ft=be.scrollTop<=0,Ot=be.scrollTop+be.clientHeight>=be.scrollHeight-5;if(ft&&ve.touches[0].clientY>0||Ot&&ve.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",P,{passive:!1}),()=>{document.removeEventListener("touchmove",P)}}return()=>{}},[at,t==null?void 0:t.mobileDisplayMode,ct]),Ge.useEffect(()=>{o||setTimeout(()=>jo(ct),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(ct),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const[It,or]=W.useState(!1),[Or,ar]=W.useState(!1),[Rr,Di]=W.useState(null),$i=async P=>{const ve=tr();if(St(!1),P&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ve,userRating:P,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(ze){console.error("Error submitting rating:",ze)}setTimeout(()=>{ar(!1),G(!1,"close_button_clicked")},1e3)},bi=P=>{y(!0),X.forEach(ze=>{H(ze.id,ze.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:X,message:P});const ve=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:P,isBot:!0}];v(ve),x(ve),d(P),ce([]),y(!1)},xr=()=>{var P;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((P=window.shiprocketCheckoutEvents)!=null&&P.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},Li=async P=>{P.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),xr()&&G(!1,"checkout_clicked")},[Ni,is]=W.useState([]);Ge.useEffect(()=>{const P=Fw(M);is(ve=>{const ze=P.filter(Xe=>!ve.some(be=>be.question===Xe.question));return[...ve,...ze]})},[M]);const Tn=Ge.useMemo(()=>Ni.map(P=>({...P,isClicked:pt.has(P.question)})),[Ni,pt]);Ge.useEffect(()=>{const P=Xe=>{const be=Xe.detail.formId;switch(Xe.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Ot=ve(be);Ot&&qt(Ot)},800);break;case"close":$t&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{G(!0,"klaviyo_form_closed"),Fe(be),r($t,void 0,void 0,!0)},1e4);break}},ve=Xe=>{const be=document.querySelector(`[data-testid="klaviyo-form-${Xe}"]`);if(console.log(`formElement text ${Xe} =>`,be==null?void 0:be.innerText,be==null?void 0:be.textContent),be instanceof HTMLElement){const ft=be.innerText||be.textContent;if(ft)return console.log("Found form text:",ft),`=> Klaviyo form content:
3154
+ `,Jse=({botId:e})=>{var ii,sr;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=t==null?void 0:t.isLeft,fe=oC(),Se=t==null?void 0:t.heightOption,pe=$h("new-suggested-question-design"),[Z,ie]=W.useState(!1),[ye,He]=W.useState(!1),[U,Be]=W.useState(!1),Oe=W.useCallback(async()=>{try{const P=await fetch(`${ci}/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(P.ok){const ve=await P.json(),ze=window.location.pathname,Xe=M.filter(be=>be.path!==ze);A([...Xe,{question:ve.Popup_Message,answer:"",path:ze,nameSpace:e,type:"dynamic",Follow_up_Question:ve.Follow_up_Question}])}else console.error("Failed to fetch new acquisition question")}catch(P){console.error("Error fetching new acquisition question:",P)}},[e,M,A]);W.useEffect(()=>{console.log("[Debug] Suggested questions updated:",M)},[M]),W.useEffect(()=>{if(console.log("[Debug] Starting suggestion cycle with timePayload:",pe),!pe){console.log("[Debug] No timePayload provided, exiting cycle");return}let P,ve,ze,Xe;const be=()=>{console.log("[Debug] Starting new cycle at:",new Date().toISOString()),P=setTimeout(()=>{console.log("[Debug] Showing notification after delay:",pe.showing_delay||2e3,"ms"),ie(!0),ve=setTimeout(()=>{console.log("[Debug] Showing message and suggestion container after delay:",pe.showing_delay||2e3,"ms"),Be(!0),He(!0),ze=setTimeout(async()=>{console.log("[Debug] Hiding message and suggestion container after:",pe.show_for||44324,"ms"),Be(!1),He(!1),console.log("[Debug] Fetching new acquisition question"),await Oe(),console.log("[Debug] New acquisition question fetched"),Xe=setTimeout(()=>{console.log("[Debug] Starting new cycle after hide timing:",pe.hide_timing||4e3,"ms"),Be(!0),ie(!0),He(!0),be()},pe.hide_timing||4e3)},pe.show_for||44324)},pe.showing_delay||2e3)},pe.showing_delay||2e3)};return be(),()=>{console.log("[Debug] Cleaning up timers"),clearTimeout(P),clearTimeout(ve),clearTimeout(ze),clearTimeout(Xe)}},[pe,Oe]);const[F,We]=W.useState(!1);W.useEffect(()=>{const P=()=>{We(window.matchMedia("(max-width: 768px)").matches)};return P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const[at,Qe]=Ge.useState(!1),[Bt,St]=Ge.useState(!1),[$t,qt]=W.useState(""),[gt,Fe]=W.useState(""),[,lt]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let P=bo();if(!P&&window.Thinkific){const ve=window.Thinkific.current_user;ve&&(P={name:ve.full_name,email:ve.email},wc(P))}bu.init({projectName:e,debug:!1,testing:kb}),P&&P.email&&(window.DebalesChat.identify(P.email,{name:P.name,phone:P.phone,email:P.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:P.email,first_name:P.name,phone:P.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const ct=Ge.useRef(null),zt=Dn(In.CLICKED_QUESTIONS,{botId:e}),[pt,dt]=W.useState(()=>{try{const P=sessionStorage.getItem(zt);return P?new Set(JSON.parse(P)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(zt,JSON.stringify(Array.from(pt)))}catch(P){console.error("Failed to save to sessionStorage:",P)}},[pt]);const G=W.useCallback((P,ve)=>{P?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})),setTimeout(()=>{St(!0)},50)):(St(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:P,source:ve,projectId:e}})))},[]);W.useEffect(()=>{const P=ve=>{Qe(ve.detail.isOpen),ve.detail.isOpen&&setTimeout(()=>St(!0),50),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen,source:ve.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]),W.useEffect(()=>{const P=ve=>{Qe(ve.detail.isOpen),window.DebalesChat.isOpen=ve.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ve.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,P),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,P)}},[]);const[X,ce]=Ge.useState(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e}),ve=sessionStorage.getItem(P);return ve?JSON.parse(ve):[]});Ge.useEffect(()=>{const P=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(P,JSON.stringify(X))},[X,e]);const[Ie,$e]=W.useState(!1),[Pe,wt]=W.useState({name:"",email:"",message:""}),kt=jf("exit_model"),[ge,Re]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[ht,xt]=W.useState(!1),[At,dn]=W.useState(!0),[bn,Wt]=W.useState(!1),[hn,Mt]=W.useState(!1),Zt=500,mt=W.useCallback(P=>{const ve=P.target,ze=ve.scrollHeight-ve.scrollTop<=ve.clientHeight+0;dn(ze)},[]);Ge.useEffect(()=>{var P,ve,ze,Xe,be,ft;if(h.length>0&&!m){const Ot=h[h.length-1],he=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),te=Ot.isBot&&Ot.conversationId===u&&Ot.conversationId!==he,ke=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&Ot.conversationId===u;if(te){xt(!0),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),Ot.conversationId||""),Re({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const de=1600;let Je=de;const Ve=[{type:"collections",condition:((P=Ot.collections)==null?void 0:P.length)&&((ve=Ot.collections)==null?void 0:ve.length)>0},{type:"products",condition:((ze=Ot.products)==null?void 0:ze.length)&&((Xe=Ot.products)==null?void 0:Xe.length)>0},{type:"leadingQueries",condition:((be=Ot.leading_queries)==null?void 0:be.length)&&((ft=Ot.leading_queries)==null?void 0:ft.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(X==null?void 0:X.length)>0}].filter(et=>et.condition);if(Ve.length===0){xt(!1);return}Ve.forEach(({type:et},Nt)=>{setTimeout(()=>{if(Re(tn=>({...tn,[et]:!0})),At&&ct.current){const tn=ct.current;tn.scrollHeight-tn.scrollTop<=tn.clientHeight&&jo(ct)}Nt===Ve.length-1&&xt(!1)},Je),Je+=de})}else ke&&Re(de=>({...de,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,X==null?void 0:X.length,At,e]),Ge.useEffect(()=>{if(!o&&h.length>0){const P=ct.current;P&&At&&P.scrollHeight-P.scrollTop<=P.clientHeight+100&&setTimeout(()=>jo(ct),100)}},[h.length,o,At]),Ge.useEffect(()=>{const P=document.querySelector('meta[name="viewport"]'),ve=P==null?void 0:P.content;if(at){let ze=P;const Xe=window.matchMedia("(max-width: 768px)").matches;ze?ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(ze=document.createElement("meta"),ze.name="viewport",ze.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(ze)),Xe&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const be=ze;return()=>{ve&&be&&(be.content=ve),Xe&&(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="")}},[at,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(at&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const P=ve=>{let ze=ve.target,Xe=!1;const be=ct.current;if(be){for(;ze&&ze!==document.body;){if(ze===be){Xe=!0;break}if(ze.parentNode)ze=ze.parentNode;else break}if(!Xe)ve.preventDefault();else{const ft=be.scrollTop<=0,Ot=be.scrollTop+be.clientHeight>=be.scrollHeight-5;if(ft&&ve.touches[0].clientY>0||Ot&&ve.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",P,{passive:!1}),()=>{document.removeEventListener("touchmove",P)}}return()=>{}},[at,t==null?void 0:t.mobileDisplayMode,ct]),Ge.useEffect(()=>{o||setTimeout(()=>jo(ct),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(ct),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const[It,or]=W.useState(!1),[Or,ar]=W.useState(!1),[Rr,Di]=W.useState(null),$i=async P=>{const ve=tr();if(St(!1),P&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ve,userRating:P,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(ze){console.error("Error submitting rating:",ze)}setTimeout(()=>{ar(!1),G(!1,"close_button_clicked")},1e3)},bi=P=>{y(!0),X.forEach(ze=>{H(ze.id,ze.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:X,message:P});const ve=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:P,isBot:!0}];v(ve),x(ve),d(P),ce([]),y(!1)},xr=()=>{var P;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((P=window.shiprocketCheckoutEvents)!=null&&P.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},Li=async P=>{P.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),xr()&&G(!1,"checkout_clicked")},[Ni,is]=W.useState([]);Ge.useEffect(()=>{const P=Fw(M);is(ve=>{const ze=P.filter(Xe=>!ve.some(be=>be.question===Xe.question));return[...ve,...ze]})},[M]);const Tn=Ge.useMemo(()=>Ni.map(P=>({...P,isClicked:pt.has(P.question)})),[Ni,pt]);Ge.useEffect(()=>{const P=Xe=>{const be=Xe.detail.formId;switch(Xe.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Ot=ve(be);Ot&&qt(Ot)},800);break;case"close":$t&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{G(!0,"klaviyo_form_closed"),Fe(be),r($t,void 0,void 0,!0)},1e4);break}},ve=Xe=>{const be=document.querySelector(`[data-testid="klaviyo-form-${Xe}"]`);if(console.log(`formElement text ${Xe} =>`,be==null?void 0:be.innerText,be==null?void 0:be.textContent),be instanceof HTMLElement){const ft=be.innerText||be.textContent;if(ft)return console.log("Found form text:",ft),`=> Klaviyo form content:
3155
3155
 
3156
3156
  `+ft+`
3157
3157
 
@@ -3976,7 +3976,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3976
3976
  margin-top: 16px;
3977
3977
  display: flex;
3978
3978
  justify-content: flex-end;
3979
- `,$le=({botId:e})=>{var Ot,he;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=t==null?void 0:t.isLeft,fe=oC(),Se=t==null?void 0:t.heightOption,pe=$h("new-suggested-question-design"),[Z,ie]=W.useState(!1),[ye,He]=W.useState(!1),[U,Be]=W.useState(!1);W.useEffect(()=>{if(!pe)return;const te=setTimeout(()=>{ie(!0);const ke=setTimeout(()=>{Be(!0),He(!0);const de=setTimeout(()=>{Be(!1),ie(!1),He(!1);const Je=setTimeout(()=>{Be(!0),ie(!0),He(!0)},pe.hide_timing||4e3);return()=>clearTimeout(Je)},pe.show_for||44324);return()=>clearTimeout(de)},pe.showing_delay||2e3);return()=>clearTimeout(ke)},pe.showing_delay||2e3);return()=>clearTimeout(te)},[pe]);const[Oe,F]=W.useState(!1);W.useEffect(()=>{const te=()=>{F(window.matchMedia("(max-width: 768px)").matches)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]);const[We,at]=Ge.useState(!1),[Qe,Bt]=Ge.useState(!1),[St,$t]=W.useState(""),[qt,gt]=W.useState(""),[,Fe]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let te=bo();if(!te&&window.Thinkific){const ke=window.Thinkific.current_user;ke&&(te={name:ke.full_name,email:ke.email},wc(te))}bu.init({projectName:e,debug:!0,testing:kb}),te&&te.email&&(window.DebalesChat.identify(te.email,{name:te.name,phone:te.phone,email:te.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:te.email,first_name:te.name,phone:te.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const lt=Ge.useRef(null),ct=Dn(In.CLICKED_QUESTIONS,{botId:e}),[zt,pt]=W.useState(()=>{try{const te=sessionStorage.getItem(ct);return te?new Set(JSON.parse(te)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(ct,JSON.stringify(Array.from(zt)))}catch(te){console.error("Failed to save to sessionStorage:",te)}},[zt]);const dt=W.useCallback((te,ke)=>{te?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:ke,projectId:e}})),setTimeout(()=>{Bt(!0)},50)):(Bt(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:ke,projectId:e}})))},[]);W.useEffect(()=>{const te=ke=>{at(ke.detail.isOpen),ke.detail.isOpen&&setTimeout(()=>Bt(!0),50),window.DebalesChat.isOpen=ke.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ke.detail.isOpen,source:ke.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,te)}},[]),W.useEffect(()=>{const te=ke=>{at(ke.detail.isOpen),window.DebalesChat.isOpen=ke.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ke.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,te)}},[]);const[G,X]=Ge.useState(()=>{const te=Dn(In.PENDING_BULK_ITEMS,{botId:e}),ke=sessionStorage.getItem(te);return ke?JSON.parse(ke):[]});Ge.useEffect(()=>{const te=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(te,JSON.stringify(G))},[G,e]);const[ce,Ie]=W.useState(!1),[$e,Pe]=W.useState({name:"",email:"",message:""}),wt=jf("exit_model"),[kt,ge]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Re,ht]=W.useState(!1),[xt,At]=W.useState(!0),[dn,bn]=W.useState(!1),[Wt,hn]=W.useState(!1),Mt=500,Zt=W.useCallback(te=>{const ke=te.target,de=ke.scrollHeight-ke.scrollTop<=ke.clientHeight+0;At(de)},[]);Ge.useEffect(()=>{var te,ke,de,Je,Ve,et;if(h.length>0&&!m){const Nt=h[h.length-1],tn=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),_i=Nt.isBot&&Nt.conversationId===u&&Nt.conversationId!==tn,Bi=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&Nt.conversationId===u;if(_i){ht(!0),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),Nt.conversationId||""),ge({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const nr=1600;let fi=nr;const So=[{type:"collections",condition:((te=Nt.collections)==null?void 0:te.length)&&((ke=Nt.collections)==null?void 0:ke.length)>0},{type:"products",condition:((de=Nt.products)==null?void 0:de.length)&&((Je=Nt.products)==null?void 0:Je.length)>0},{type:"leadingQueries",condition:((Ve=Nt.leading_queries)==null?void 0:Ve.length)&&((et=Nt.leading_queries)==null?void 0:et.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(G==null?void 0:G.length)>0}].filter(Rl=>Rl.condition);if(So.length===0){ht(!1);return}So.forEach(({type:Rl},Ir)=>{setTimeout(()=>{if(ge(Da=>({...Da,[Rl]:!0})),xt&&lt.current){const Da=lt.current;Da.scrollHeight-Da.scrollTop<=Da.clientHeight&&jo(lt)}Ir===So.length-1&&ht(!1)},fi),fi+=nr})}else Bi&&ge(nr=>({...nr,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,G==null?void 0:G.length,xt,e]),Ge.useEffect(()=>{if(!o&&h.length>0){const te=lt.current;te&&xt&&te.scrollHeight-te.scrollTop<=te.clientHeight+100&&setTimeout(()=>jo(lt),100)}},[h.length,o,xt]),Ge.useEffect(()=>{const te=document.querySelector('meta[name="viewport"]'),ke=te==null?void 0:te.content;if(We){let de=te;const Je=window.matchMedia("(max-width: 768px)").matches;de?de.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(de=document.createElement("meta"),de.name="viewport",de.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(de)),Je&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ve=de;return()=>{ke&&Ve&&(Ve.content=ke),Je&&(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="")}},[We,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(We&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const te=ke=>{let de=ke.target,Je=!1;const Ve=lt.current;if(Ve){for(;de&&de!==document.body;){if(de===Ve){Je=!0;break}if(de.parentNode)de=de.parentNode;else break}if(!Je)ke.preventDefault();else{const et=Ve.scrollTop<=0,Nt=Ve.scrollTop+Ve.clientHeight>=Ve.scrollHeight-5;if(et&&ke.touches[0].clientY>0||Nt&&ke.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",te,{passive:!1}),()=>{document.removeEventListener("touchmove",te)}}return()=>{}},[We,t==null?void 0:t.mobileDisplayMode,lt]),Ge.useEffect(()=>{o||setTimeout(()=>jo(lt),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(lt),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const mt=Ge.useRef(Date.now()),It=Ge.useRef(0),or=Ge.useRef(window.location.pathname),Or=Ge.useRef(M),ar=Ge.useRef(!1),Rr=jf("acquisition_agent");Ge.useEffect(()=>{Or.current=M},[M]);const Di=Ge.useCallback(async()=>{const te=Date.now();if(te-mt.current>=6e3&&te-It.current>=6e4&&!ar.current)try{ar.current=!0,console.log("fetching acquisition data");const Je=await fetch(`${ci}/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(Je.ok){const Ve=await Je.json(),Nt=[...Or.current.filter(tn=>tn.path!==or.current),{question:Ve.Popup_Message,answer:"",path:or.current,nameSpace:e,type:"dynamic",Follow_up_Question:Ve.Follow_up_Question}];A(Nt)}It.current=te}catch(Je){console.error("Error fetching acquisition data:",Je)}finally{ar.current=!1}},[e]);Ge.useEffect(()=>{if(!Rr||(t==null?void 0:t.show_bot)===!1)return;const te=()=>{mt.current=Date.now()};document.addEventListener("mousemove",te),document.addEventListener("mousedown",te),document.addEventListener("keypress",te),document.addEventListener("scroll",te),document.addEventListener("touchstart",te),document.addEventListener("touchmove",te);const ke=setInterval(Di,1e3),de=()=>{const Ve=window.location.pathname.split("?")[0],et=or.current.split("?")[0];(()=>{const tn=et.split("/").filter(Boolean),_i=Ve.split("/").filter(Boolean);return tn.length!==_i.length?!0:tn.length===0&&_i.length===0?!1:Ve!==et})()&&(or.current=Ve,mt.current=Date.now())};return window.addEventListener("popstate",de),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mousedown",te),document.removeEventListener("keypress",te),document.removeEventListener("scroll",te),document.removeEventListener("touchstart",te),document.removeEventListener("touchmove",te),window.removeEventListener("popstate",de),clearInterval(ke)}},[Rr,Di,t==null?void 0:t.show_bot]);const[$i,bi]=W.useState(!1),[xr,Li]=W.useState(!1),[Ni,is]=W.useState(null),Tn=async te=>{const ke=tr();if(Bt(!1),te&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ke,userRating:te,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(de){console.error("Error submitting rating:",de)}setTimeout(()=>{Li(!1),dt(!1,"close_button_clicked")},1e3)},dr=te=>{y(!0),G.forEach(de=>{H(de.id,de.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:G,message:te});const ke=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:te,isBot:!0}];v(ke),x(ke),d(te),X([]),y(!1)},Xn=()=>{var te;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((te=window.shiprocketCheckoutEvents)!=null&&te.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},hr=async te=>{te.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),Xn()&&dt(!1,"checkout_clicked")},[Hr,$n]=W.useState([]);Ge.useEffect(()=>{const te=Fw(M);$n(ke=>{const de=te.filter(Je=>!ke.some(Ve=>Ve.question===Je.question));return[...ke,...de]})},[M]);const qn=Ge.useMemo(()=>Hr.map(te=>({...te,isClicked:zt.has(te.question)})),[Hr,zt]);console.log(Hr),Ge.useEffect(()=>{const te=Je=>{const Ve=Je.detail.formId;switch(Je.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Nt=ke(Ve);Nt&&$t(Nt)},800);break;case"close":St&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{dt(!0,"klaviyo_form_closed"),gt(Ve),r(St,void 0,void 0,!0)},1e4);break}},ke=Je=>{const Ve=document.querySelector(`[data-testid="klaviyo-form-${Je}"]`);if(console.log(`formElement text ${Je} =>`,Ve==null?void 0:Ve.innerText,Ve==null?void 0:Ve.textContent),Ve instanceof HTMLElement){const et=Ve.innerText||Ve.textContent;if(et)return console.log("Found form text:",et),`=> Klaviyo form content:
3979
+ `,$le=({botId:e})=>{var Ot,he;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=t==null?void 0:t.isLeft,fe=oC(),Se=t==null?void 0:t.heightOption,pe=$h("new-suggested-question-design"),[Z,ie]=W.useState(!1),[ye,He]=W.useState(!1),[U,Be]=W.useState(!1);W.useEffect(()=>{if(!pe)return;const te=setTimeout(()=>{ie(!0);const ke=setTimeout(()=>{Be(!0),He(!0);const de=setTimeout(()=>{Be(!1),ie(!1),He(!1);const Je=setTimeout(()=>{Be(!0),ie(!0),He(!0)},pe.hide_timing||4e3);return()=>clearTimeout(Je)},pe.show_for||44324);return()=>clearTimeout(de)},pe.showing_delay||2e3);return()=>clearTimeout(ke)},pe.showing_delay||2e3);return()=>clearTimeout(te)},[pe]);const[Oe,F]=W.useState(!1);W.useEffect(()=>{const te=()=>{F(window.matchMedia("(max-width: 768px)").matches)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]);const[We,at]=Ge.useState(!1),[Qe,Bt]=Ge.useState(!1),[St,$t]=W.useState(""),[qt,gt]=W.useState(""),[,Fe]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let te=bo();if(!te&&window.Thinkific){const ke=window.Thinkific.current_user;ke&&(te={name:ke.full_name,email:ke.email},wc(te))}bu.init({projectName:e,debug:!1,testing:kb}),te&&te.email&&(window.DebalesChat.identify(te.email,{name:te.name,phone:te.phone,email:te.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:te.email,first_name:te.name,phone:te.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const lt=Ge.useRef(null),ct=Dn(In.CLICKED_QUESTIONS,{botId:e}),[zt,pt]=W.useState(()=>{try{const te=sessionStorage.getItem(ct);return te?new Set(JSON.parse(te)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(ct,JSON.stringify(Array.from(zt)))}catch(te){console.error("Failed to save to sessionStorage:",te)}},[zt]);const dt=W.useCallback((te,ke)=>{te?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:ke,projectId:e}})),setTimeout(()=>{Bt(!0)},50)):(Bt(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:ke,projectId:e}})))},[]);W.useEffect(()=>{const te=ke=>{at(ke.detail.isOpen),ke.detail.isOpen&&setTimeout(()=>Bt(!0),50),window.DebalesChat.isOpen=ke.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ke.detail.isOpen,source:ke.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,te)}},[]),W.useEffect(()=>{const te=ke=>{at(ke.detail.isOpen),window.DebalesChat.isOpen=ke.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ke.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,te)}},[]);const[G,X]=Ge.useState(()=>{const te=Dn(In.PENDING_BULK_ITEMS,{botId:e}),ke=sessionStorage.getItem(te);return ke?JSON.parse(ke):[]});Ge.useEffect(()=>{const te=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(te,JSON.stringify(G))},[G,e]);const[ce,Ie]=W.useState(!1),[$e,Pe]=W.useState({name:"",email:"",message:""}),wt=jf("exit_model"),[kt,ge]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Re,ht]=W.useState(!1),[xt,At]=W.useState(!0),[dn,bn]=W.useState(!1),[Wt,hn]=W.useState(!1),Mt=500,Zt=W.useCallback(te=>{const ke=te.target,de=ke.scrollHeight-ke.scrollTop<=ke.clientHeight+0;At(de)},[]);Ge.useEffect(()=>{var te,ke,de,Je,Ve,et;if(h.length>0&&!m){const Nt=h[h.length-1],tn=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),_i=Nt.isBot&&Nt.conversationId===u&&Nt.conversationId!==tn,Bi=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&Nt.conversationId===u;if(_i){ht(!0),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),Nt.conversationId||""),ge({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const nr=1600;let fi=nr;const So=[{type:"collections",condition:((te=Nt.collections)==null?void 0:te.length)&&((ke=Nt.collections)==null?void 0:ke.length)>0},{type:"products",condition:((de=Nt.products)==null?void 0:de.length)&&((Je=Nt.products)==null?void 0:Je.length)>0},{type:"leadingQueries",condition:((Ve=Nt.leading_queries)==null?void 0:Ve.length)&&((et=Nt.leading_queries)==null?void 0:et.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(G==null?void 0:G.length)>0}].filter(Rl=>Rl.condition);if(So.length===0){ht(!1);return}So.forEach(({type:Rl},Ir)=>{setTimeout(()=>{if(ge(Da=>({...Da,[Rl]:!0})),xt&&lt.current){const Da=lt.current;Da.scrollHeight-Da.scrollTop<=Da.clientHeight&&jo(lt)}Ir===So.length-1&&ht(!1)},fi),fi+=nr})}else Bi&&ge(nr=>({...nr,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,G==null?void 0:G.length,xt,e]),Ge.useEffect(()=>{if(!o&&h.length>0){const te=lt.current;te&&xt&&te.scrollHeight-te.scrollTop<=te.clientHeight+100&&setTimeout(()=>jo(lt),100)}},[h.length,o,xt]),Ge.useEffect(()=>{const te=document.querySelector('meta[name="viewport"]'),ke=te==null?void 0:te.content;if(We){let de=te;const Je=window.matchMedia("(max-width: 768px)").matches;de?de.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(de=document.createElement("meta"),de.name="viewport",de.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(de)),Je&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ve=de;return()=>{ke&&Ve&&(Ve.content=ke),Je&&(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="")}},[We,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(We&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const te=ke=>{let de=ke.target,Je=!1;const Ve=lt.current;if(Ve){for(;de&&de!==document.body;){if(de===Ve){Je=!0;break}if(de.parentNode)de=de.parentNode;else break}if(!Je)ke.preventDefault();else{const et=Ve.scrollTop<=0,Nt=Ve.scrollTop+Ve.clientHeight>=Ve.scrollHeight-5;if(et&&ke.touches[0].clientY>0||Nt&&ke.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",te,{passive:!1}),()=>{document.removeEventListener("touchmove",te)}}return()=>{}},[We,t==null?void 0:t.mobileDisplayMode,lt]),Ge.useEffect(()=>{o||setTimeout(()=>jo(lt),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(lt),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const mt=Ge.useRef(Date.now()),It=Ge.useRef(0),or=Ge.useRef(window.location.pathname),Or=Ge.useRef(M),ar=Ge.useRef(!1),Rr=jf("acquisition_agent");Ge.useEffect(()=>{Or.current=M},[M]);const Di=Ge.useCallback(async()=>{const te=Date.now();if(te-mt.current>=6e3&&te-It.current>=6e4&&!ar.current)try{ar.current=!0,console.log("fetching acquisition data");const Je=await fetch(`${ci}/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(Je.ok){const Ve=await Je.json(),Nt=[...Or.current.filter(tn=>tn.path!==or.current),{question:Ve.Popup_Message,answer:"",path:or.current,nameSpace:e,type:"dynamic",Follow_up_Question:Ve.Follow_up_Question}];A(Nt)}It.current=te}catch(Je){console.error("Error fetching acquisition data:",Je)}finally{ar.current=!1}},[e]);Ge.useEffect(()=>{if(!Rr||(t==null?void 0:t.show_bot)===!1)return;const te=()=>{mt.current=Date.now()};document.addEventListener("mousemove",te),document.addEventListener("mousedown",te),document.addEventListener("keypress",te),document.addEventListener("scroll",te),document.addEventListener("touchstart",te),document.addEventListener("touchmove",te);const ke=setInterval(Di,1e3),de=()=>{const Ve=window.location.pathname.split("?")[0],et=or.current.split("?")[0];(()=>{const tn=et.split("/").filter(Boolean),_i=Ve.split("/").filter(Boolean);return tn.length!==_i.length?!0:tn.length===0&&_i.length===0?!1:Ve!==et})()&&(or.current=Ve,mt.current=Date.now())};return window.addEventListener("popstate",de),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mousedown",te),document.removeEventListener("keypress",te),document.removeEventListener("scroll",te),document.removeEventListener("touchstart",te),document.removeEventListener("touchmove",te),window.removeEventListener("popstate",de),clearInterval(ke)}},[Rr,Di,t==null?void 0:t.show_bot]);const[$i,bi]=W.useState(!1),[xr,Li]=W.useState(!1),[Ni,is]=W.useState(null),Tn=async te=>{const ke=tr();if(Bt(!1),te&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ke,userRating:te,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(de){console.error("Error submitting rating:",de)}setTimeout(()=>{Li(!1),dt(!1,"close_button_clicked")},1e3)},dr=te=>{y(!0),G.forEach(de=>{H(de.id,de.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:G,message:te});const ke=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:te,isBot:!0}];v(ke),x(ke),d(te),X([]),y(!1)},Xn=()=>{var te;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((te=window.shiprocketCheckoutEvents)!=null&&te.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},hr=async te=>{te.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),Xn()&&dt(!1,"checkout_clicked")},[Hr,$n]=W.useState([]);Ge.useEffect(()=>{const te=Fw(M);$n(ke=>{const de=te.filter(Je=>!ke.some(Ve=>Ve.question===Je.question));return[...ke,...de]})},[M]);const qn=Ge.useMemo(()=>Hr.map(te=>({...te,isClicked:zt.has(te.question)})),[Hr,zt]);console.log(Hr),Ge.useEffect(()=>{const te=Je=>{const Ve=Je.detail.formId;switch(Je.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Nt=ke(Ve);Nt&&$t(Nt)},800);break;case"close":St&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{dt(!0,"klaviyo_form_closed"),gt(Ve),r(St,void 0,void 0,!0)},1e4);break}},ke=Je=>{const Ve=document.querySelector(`[data-testid="klaviyo-form-${Je}"]`);if(console.log(`formElement text ${Je} =>`,Ve==null?void 0:Ve.innerText,Ve==null?void 0:Ve.textContent),Ve instanceof HTMLElement){const et=Ve.innerText||Ve.textContent;if(et)return console.log("Found form text:",et),`=> Klaviyo form content:
3980
3980
 
3981
3981
  `+et+`
3982
3982
 
@@ -4805,7 +4805,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4805
4805
  margin-top: 16px;
4806
4806
  display: flex;
4807
4807
  justify-content: flex-end;
4808
- `,mue=({botId:e})=>{var ft,Ot;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=oC(),fe=t==null?void 0:t.heightOption,se=$h("new-suggested-question-design"),[pe,Z]=W.useState(!1),[ie,ye]=W.useState(!1),[He,U]=W.useState(!1);W.useEffect(()=>{if(!se)return;const he=setTimeout(()=>{Z(!0);const te=setTimeout(()=>{U(!0),ye(!0);const ke=setTimeout(()=>{U(!1),Z(!1),ye(!1);const de=setTimeout(()=>{U(!0),Z(!0),ye(!0)},se.hide_timing||4e3);return()=>clearTimeout(de)},se.show_for||44324);return()=>clearTimeout(ke)},se.showing_delay||2e3);return()=>clearTimeout(te)},se.showing_delay||2e3);return()=>clearTimeout(he)},[se]);const[Be,Oe]=W.useState(!1);W.useEffect(()=>{const he=()=>{Oe(window.matchMedia("(max-width: 768px)").matches)};return he(),window.addEventListener("resize",he),()=>window.removeEventListener("resize",he)},[]);const[F,We]=Ge.useState(!1),[at,Qe]=Ge.useState(!1),[Bt,St]=W.useState(""),[$t,qt]=W.useState(""),[,gt]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let he=bo();if(!he&&window.Thinkific){const te=window.Thinkific.current_user;te&&(he={name:te.full_name,email:te.email},wc(he))}bu.init({projectName:e,debug:!0,testing:kb}),he&&he.email&&(window.DebalesChat.identify(he.email,{name:he.name,phone:he.phone,email:he.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:he.email,first_name:he.name,phone:he.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const Fe=Ge.useRef(null),lt=Dn(In.CLICKED_QUESTIONS,{botId:e}),[ct,zt]=W.useState(()=>{try{const he=sessionStorage.getItem(lt);return he?new Set(JSON.parse(he)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(lt,JSON.stringify(Array.from(ct)))}catch(he){console.error("Failed to save to sessionStorage:",he)}},[ct]);const pt=W.useCallback((he,te)=>{he?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:he,source:te,projectId:e}})),setTimeout(()=>{Qe(!0)},50)):(Qe(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:he,source:te,projectId:e}})))},[]);W.useEffect(()=>{const he=te=>{We(te.detail.isOpen),te.detail.isOpen&&setTimeout(()=>Qe(!0),50),window.DebalesChat.isOpen=te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:te.detail.isOpen,source:te.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,he),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,he)}},[]),W.useEffect(()=>{const he=te=>{We(te.detail.isOpen),window.DebalesChat.isOpen=te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:te.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,he),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,he)}},[]);const[dt,G]=Ge.useState(()=>{const he=Dn(In.PENDING_BULK_ITEMS,{botId:e}),te=sessionStorage.getItem(he);return te?JSON.parse(te):[]});Ge.useEffect(()=>{const he=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(he,JSON.stringify(dt))},[dt,e]);const[X,ce]=W.useState(!1),[Ie,$e]=W.useState({name:"",email:"",message:""}),Pe=jf("exit_model"),[wt,kt]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[ge,Re]=W.useState(!1),[ht,xt]=W.useState(!0),[At,dn]=W.useState(!1),[bn,Wt]=W.useState(!1),hn=500,Mt=W.useCallback(he=>{const te=he.target,ke=te.scrollHeight-te.scrollTop<=te.clientHeight+0;xt(ke)},[]);Ge.useEffect(()=>{var he,te,ke,de,Je,Ve;if(h.length>0&&!m){const et=h[h.length-1],Nt=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),tn=et.isBot&&et.conversationId===u&&et.conversationId!==Nt,_i=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&et.conversationId===u;if(tn){Re(!0),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),et.conversationId||""),kt({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const Bi=1600;let nr=Bi;const fi=[{type:"collections",condition:((he=et.collections)==null?void 0:he.length)&&((te=et.collections)==null?void 0:te.length)>0},{type:"products",condition:((ke=et.products)==null?void 0:ke.length)&&((de=et.products)==null?void 0:de.length)>0},{type:"leadingQueries",condition:((Je=et.leading_queries)==null?void 0:Je.length)&&((Ve=et.leading_queries)==null?void 0:Ve.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(dt==null?void 0:dt.length)>0}].filter(So=>So.condition);if(fi.length===0){Re(!1);return}fi.forEach(({type:So},Rl)=>{setTimeout(()=>{if(kt(Ir=>({...Ir,[So]:!0})),ht&&Fe.current){const Ir=Fe.current;Ir.scrollHeight-Ir.scrollTop<=Ir.clientHeight&&jo(Fe)}Rl===fi.length-1&&Re(!1)},nr),nr+=Bi})}else _i&&kt(Bi=>({...Bi,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,dt==null?void 0:dt.length,ht,e]),Ge.useEffect(()=>{if(!o&&h.length>0){const he=Fe.current;he&&ht&&he.scrollHeight-he.scrollTop<=he.clientHeight+100&&setTimeout(()=>jo(Fe),100)}},[h.length,o,ht]),Ge.useEffect(()=>{const he=document.querySelector('meta[name="viewport"]'),te=he==null?void 0:he.content;if(F){let ke=he;const de=window.matchMedia("(max-width: 768px)").matches;ke?ke.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(ke=document.createElement("meta"),ke.name="viewport",ke.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(ke)),de&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Je=ke;return()=>{te&&Je&&(Je.content=te),de&&(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="")}},[F,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(F&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const he=te=>{let ke=te.target,de=!1;const Je=Fe.current;if(Je){for(;ke&&ke!==document.body;){if(ke===Je){de=!0;break}if(ke.parentNode)ke=ke.parentNode;else break}if(!de)te.preventDefault();else{const Ve=Je.scrollTop<=0,et=Je.scrollTop+Je.clientHeight>=Je.scrollHeight-5;if(Ve&&te.touches[0].clientY>0||et&&te.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",he,{passive:!1}),()=>{document.removeEventListener("touchmove",he)}}return()=>{}},[F,t==null?void 0:t.mobileDisplayMode,Fe]),Ge.useEffect(()=>{o||setTimeout(()=>jo(Fe),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(Fe),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Zt=Ge.useRef(Date.now()),mt=Ge.useRef(0),It=Ge.useRef(window.location.pathname),or=Ge.useRef(M),Or=Ge.useRef(!1),ar=jf("acquisition_agent");Ge.useEffect(()=>{or.current=M},[M]);const Rr=Ge.useCallback(async()=>{const he=Date.now();if(he-Zt.current>=6e3&&he-mt.current>=6e4&&!Or.current)try{Or.current=!0,console.log("fetching acquisition data");const de=await fetch(`${ci}/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(de.ok){const Je=await de.json(),et=[...or.current.filter(Nt=>Nt.path!==It.current),{question:Je.Popup_Message,answer:"",path:It.current,nameSpace:e,type:"dynamic",Follow_up_Question:Je.Follow_up_Question}];A(et)}mt.current=he}catch(de){console.error("Error fetching acquisition data:",de)}finally{Or.current=!1}},[e]);Ge.useEffect(()=>{if(!ar||(t==null?void 0:t.show_bot)===!1)return;const he=()=>{Zt.current=Date.now()};document.addEventListener("mousemove",he),document.addEventListener("mousedown",he),document.addEventListener("keypress",he),document.addEventListener("scroll",he),document.addEventListener("touchstart",he),document.addEventListener("touchmove",he);const te=setInterval(Rr,1e3),ke=()=>{const Je=window.location.pathname.split("?")[0],Ve=It.current.split("?")[0];(()=>{const Nt=Ve.split("/").filter(Boolean),tn=Je.split("/").filter(Boolean);return Nt.length!==tn.length?!0:Nt.length===0&&tn.length===0?!1:Je!==Ve})()&&(It.current=Je,Zt.current=Date.now())};return window.addEventListener("popstate",ke),()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mousedown",he),document.removeEventListener("keypress",he),document.removeEventListener("scroll",he),document.removeEventListener("touchstart",he),document.removeEventListener("touchmove",he),window.removeEventListener("popstate",ke),clearInterval(te)}},[ar,Rr,t==null?void 0:t.show_bot]);const[Di,$i]=W.useState(!1),[bi,xr]=W.useState(!1),[Li,Ni]=W.useState(null),is=async he=>{const te=tr();if(Qe(!1),he&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:te,userRating:he,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(ke){console.error("Error submitting rating:",ke)}setTimeout(()=>{xr(!1),pt(!1,"close_button_clicked")},1e3)},Tn=he=>{y(!0),dt.forEach(ke=>{H(ke.id,ke.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:dt,message:he});const te=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:he,isBot:!0}];v(te),x(te),d(he),G([]),y(!1)},dr=()=>{var he;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((he=window.shiprocketCheckoutEvents)!=null&&he.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},Xn=async he=>{he.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),dr()&&pt(!1,"checkout_clicked")},[hr,Hr]=W.useState([]);Ge.useEffect(()=>{const he=Fw(M);Hr(te=>{const ke=he.filter(de=>!te.some(Je=>Je.question===de.question));return[...te,...ke]})},[M]);const $n=Ge.useMemo(()=>hr.map(he=>({...he,isClicked:ct.has(he.question)})),[hr,ct]);console.log(hr),Ge.useEffect(()=>{const he=de=>{const Je=de.detail.formId;switch(de.detail.type){case"open":case"embedOpen":setTimeout(()=>{const et=te(Je);et&&St(et)},800);break;case"close":Bt&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{pt(!0,"klaviyo_form_closed"),qt(Je),r(Bt,void 0,void 0,!0)},1e4);break}},te=de=>{const Je=document.querySelector(`[data-testid="klaviyo-form-${de}"]`);if(console.log(`formElement text ${de} =>`,Je==null?void 0:Je.innerText,Je==null?void 0:Je.textContent),Je instanceof HTMLElement){const Ve=Je.innerText||Je.textContent;if(Ve)return console.log("Found form text:",Ve),`=> Klaviyo form content:
4808
+ `,mue=({botId:e})=>{var ft,Ot;const{uiData:t,storeMetaData:n,onSendMessage:r,isKlaviyoMessage:o,isLoading:s,lastedBotmessageId:u,setLastedBotmessageId:d,messages:h,isMessageLoading:m,setIsMessageLoading:y,setMessages:v,saveConversation:x,changeDisplayModel:w,loadConversation:E,suggestedQuestions:M,setSuggestedQuestions:A,showUserInfoModel:k,setShowUserInfoModel:R,isUserInfoNeeded:D,setPendingQuestion:B}=Mm(),{cart:L,addToCart:H,generateCartUrl:K,addCartAttributes:ee}=Ab(),J=$h("use-chatbot-icon-size"),Q=ud.detect(),ae=oC(),fe=t==null?void 0:t.heightOption,se=$h("new-suggested-question-design"),[pe,Z]=W.useState(!1),[ie,ye]=W.useState(!1),[He,U]=W.useState(!1);W.useEffect(()=>{if(!se)return;const he=setTimeout(()=>{Z(!0);const te=setTimeout(()=>{U(!0),ye(!0);const ke=setTimeout(()=>{U(!1),Z(!1),ye(!1);const de=setTimeout(()=>{U(!0),Z(!0),ye(!0)},se.hide_timing||4e3);return()=>clearTimeout(de)},se.show_for||44324);return()=>clearTimeout(ke)},se.showing_delay||2e3);return()=>clearTimeout(te)},se.showing_delay||2e3);return()=>clearTimeout(he)},[se]);const[Be,Oe]=W.useState(!1);W.useEffect(()=>{const he=()=>{Oe(window.matchMedia("(max-width: 768px)").matches)};return he(),window.addEventListener("resize",he),()=>window.removeEventListener("resize",he)},[]);const[F,We]=Ge.useState(!1),[at,Qe]=Ge.useState(!1),[Bt,St]=W.useState(""),[$t,qt]=W.useState(""),[,gt]=W.useState(0);Ge.useEffect(()=>{e&&tC(e)},[e]),Ge.useEffect(()=>{Gw(e)},[e]),Ge.useEffect(()=>{let he=bo();if(!he&&window.Thinkific){const te=window.Thinkific.current_user;te&&(he={name:te.full_name,email:te.email},wc(he))}bu.init({projectName:e,debug:!1,testing:kb}),he&&he.email&&(window.DebalesChat.identify(he.email,{name:he.name,phone:he.phone,email:he.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:he.email,first_name:he.name,phone:he.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const Fe=Ge.useRef(null),lt=Dn(In.CLICKED_QUESTIONS,{botId:e}),[ct,zt]=W.useState(()=>{try{const he=sessionStorage.getItem(lt);return he?new Set(JSON.parse(he)):new Set}catch{return new Set}});Ge.useEffect(()=>{try{sessionStorage.setItem(lt,JSON.stringify(Array.from(ct)))}catch(he){console.error("Failed to save to sessionStorage:",he)}},[ct]);const pt=W.useCallback((he,te)=>{he?(window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:he,source:te,projectId:e}})),setTimeout(()=>{Qe(!0)},50)):(Qe(!1),window.dispatchEvent(new CustomEvent(fr.OPEN_STATE_CHANGE,{detail:{isOpen:he,source:te,projectId:e}})))},[]);W.useEffect(()=>{const he=te=>{We(te.detail.isOpen),te.detail.isOpen&&setTimeout(()=>Qe(!0),50),window.DebalesChat.isOpen=te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:te.detail.isOpen,source:te.detail.source})};return window.addEventListener(fr.OPEN_STATE_CHANGE,he),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,he)}},[]),W.useEffect(()=>{const he=te=>{We(te.detail.isOpen),window.DebalesChat.isOpen=te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:te.detail.isOpen})};return window.addEventListener(fr.OPEN_STATE_CHANGE,he),()=>{window.removeEventListener(fr.OPEN_STATE_CHANGE,he)}},[]);const[dt,G]=Ge.useState(()=>{const he=Dn(In.PENDING_BULK_ITEMS,{botId:e}),te=sessionStorage.getItem(he);return te?JSON.parse(te):[]});Ge.useEffect(()=>{const he=Dn(In.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(he,JSON.stringify(dt))},[dt,e]);const[X,ce]=W.useState(!1),[Ie,$e]=W.useState({name:"",email:"",message:""}),Pe=jf("exit_model"),[wt,kt]=W.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[ge,Re]=W.useState(!1),[ht,xt]=W.useState(!0),[At,dn]=W.useState(!1),[bn,Wt]=W.useState(!1),hn=500,Mt=W.useCallback(he=>{const te=he.target,ke=te.scrollHeight-te.scrollTop<=te.clientHeight+0;xt(ke)},[]);Ge.useEffect(()=>{var he,te,ke,de,Je,Ve;if(h.length>0&&!m){const et=h[h.length-1],Nt=sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e})),tn=et.isBot&&et.conversationId===u&&et.conversationId!==Nt,_i=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&et.conversationId===u;if(tn){Re(!0),sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),et.conversationId||""),kt({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const Bi=1600;let nr=Bi;const fi=[{type:"collections",condition:((he=et.collections)==null?void 0:he.length)&&((te=et.collections)==null?void 0:te.length)>0},{type:"products",condition:((ke=et.products)==null?void 0:ke.length)&&((de=et.products)==null?void 0:de.length)>0},{type:"leadingQueries",condition:((Je=et.leading_queries)==null?void 0:Je.length)&&((Ve=et.leading_queries)==null?void 0:Ve.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(dt==null?void 0:dt.length)>0}].filter(So=>So.condition);if(fi.length===0){Re(!1);return}fi.forEach(({type:So},Rl)=>{setTimeout(()=>{if(kt(Ir=>({...Ir,[So]:!0})),ht&&Fe.current){const Ir=Fe.current;Ir.scrollHeight-Ir.scrollTop<=Ir.clientHeight&&jo(Fe)}Rl===fi.length-1&&Re(!1)},nr),nr+=Bi})}else _i&&kt(Bi=>({...Bi,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,dt==null?void 0:dt.length,ht,e]),Ge.useEffect(()=>{if(!o&&h.length>0){const he=Fe.current;he&&ht&&he.scrollHeight-he.scrollTop<=he.clientHeight+100&&setTimeout(()=>jo(Fe),100)}},[h.length,o,ht]),Ge.useEffect(()=>{const he=document.querySelector('meta[name="viewport"]'),te=he==null?void 0:he.content;if(F){let ke=he;const de=window.matchMedia("(max-width: 768px)").matches;ke?ke.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(ke=document.createElement("meta"),ke.name="viewport",ke.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(ke)),de&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Je=ke;return()=>{te&&Je&&(Je.content=te),de&&(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="")}},[F,t==null?void 0:t.mobileDisplayMode]),Ge.useEffect(()=>{if(F&&window.matchMedia("(max-width: 768px)").matches&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"){const he=te=>{let ke=te.target,de=!1;const Je=Fe.current;if(Je){for(;ke&&ke!==document.body;){if(ke===Je){de=!0;break}if(ke.parentNode)ke=ke.parentNode;else break}if(!de)te.preventDefault();else{const Ve=Je.scrollTop<=0,et=Je.scrollTop+Je.clientHeight>=Je.scrollHeight-5;if(Ve&&te.touches[0].clientY>0||et&&te.touches[0].clientY<0)return}}};return document.addEventListener("touchmove",he,{passive:!1}),()=>{document.removeEventListener("touchmove",he)}}return()=>{}},[F,t==null?void 0:t.mobileDisplayMode,Fe]),Ge.useEffect(()=>{o||setTimeout(()=>jo(Fe),100)},[h.length,o]),Ge.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(Fe),100)},[L==null?void 0:L.itemCount,o]),Ge.useEffect(()=>{u&&sessionStorage.setItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Zt=Ge.useRef(Date.now()),mt=Ge.useRef(0),It=Ge.useRef(window.location.pathname),or=Ge.useRef(M),Or=Ge.useRef(!1),ar=jf("acquisition_agent");Ge.useEffect(()=>{or.current=M},[M]);const Rr=Ge.useCallback(async()=>{const he=Date.now();if(he-Zt.current>=6e3&&he-mt.current>=6e4&&!Or.current)try{Or.current=!0,console.log("fetching acquisition data");const de=await fetch(`${ci}/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(de.ok){const Je=await de.json(),et=[...or.current.filter(Nt=>Nt.path!==It.current),{question:Je.Popup_Message,answer:"",path:It.current,nameSpace:e,type:"dynamic",Follow_up_Question:Je.Follow_up_Question}];A(et)}mt.current=he}catch(de){console.error("Error fetching acquisition data:",de)}finally{Or.current=!1}},[e]);Ge.useEffect(()=>{if(!ar||(t==null?void 0:t.show_bot)===!1)return;const he=()=>{Zt.current=Date.now()};document.addEventListener("mousemove",he),document.addEventListener("mousedown",he),document.addEventListener("keypress",he),document.addEventListener("scroll",he),document.addEventListener("touchstart",he),document.addEventListener("touchmove",he);const te=setInterval(Rr,1e3),ke=()=>{const Je=window.location.pathname.split("?")[0],Ve=It.current.split("?")[0];(()=>{const Nt=Ve.split("/").filter(Boolean),tn=Je.split("/").filter(Boolean);return Nt.length!==tn.length?!0:Nt.length===0&&tn.length===0?!1:Je!==Ve})()&&(It.current=Je,Zt.current=Date.now())};return window.addEventListener("popstate",ke),()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mousedown",he),document.removeEventListener("keypress",he),document.removeEventListener("scroll",he),document.removeEventListener("touchstart",he),document.removeEventListener("touchmove",he),window.removeEventListener("popstate",ke),clearInterval(te)}},[ar,Rr,t==null?void 0:t.show_bot]);const[Di,$i]=W.useState(!1),[bi,xr]=W.useState(!1),[Li,Ni]=W.useState(null),is=async he=>{const te=tr();if(Qe(!1),he&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:te,userRating:he,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(ke){console.error("Error submitting rating:",ke)}setTimeout(()=>{xr(!1),pt(!1,"close_button_clicked")},1e3)},Tn=he=>{y(!0),dt.forEach(ke=>{H(ke.id,ke.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:dt,message:he});const te=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:he,isBot:!0}];v(te),x(te),d(he),G([]),y(!1)},dr=()=>{var he;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((he=window.shiprocketCheckoutEvents)!=null&&he.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=K((t==null?void 0:t.shopifyShopDomain)??""),!1},Xn=async he=>{he.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:tr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),ee({dbls_method:"checkout_clicked"}),dr()&&pt(!1,"checkout_clicked")},[hr,Hr]=W.useState([]);Ge.useEffect(()=>{const he=Fw(M);Hr(te=>{const ke=he.filter(de=>!te.some(Je=>Je.question===de.question));return[...te,...ke]})},[M]);const $n=Ge.useMemo(()=>hr.map(he=>({...he,isClicked:ct.has(he.question)})),[hr,ct]);console.log(hr),Ge.useEffect(()=>{const he=de=>{const Je=de.detail.formId;switch(de.detail.type){case"open":case"embedOpen":setTimeout(()=>{const et=te(Je);et&&St(et)},800);break;case"close":Bt&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{pt(!0,"klaviyo_form_closed"),qt(Je),r(Bt,void 0,void 0,!0)},1e4);break}},te=de=>{const Je=document.querySelector(`[data-testid="klaviyo-form-${de}"]`);if(console.log(`formElement text ${de} =>`,Je==null?void 0:Je.innerText,Je==null?void 0:Je.textContent),Je instanceof HTMLElement){const Ve=Je.innerText||Je.textContent;if(Ve)return console.log("Found form text:",Ve),`=> Klaviyo form content:
4809
4809
 
4810
4810
  `+Ve+`
4811
4811
 
@@ -5058,4 +5058,4 @@ Learn more: https://react.dev/warnings/version-mismatch`))}(),typeof Map=="funct
5058
5058
  You might need to use a local HTTP server (instead of file://): https://react.dev/link/react-devtools-faq`:""),"font-weight:bold")}Qb.createRoot=function(i,a){if(!A(i))throw Error("Target container is not a DOM element.");dA(i);var c=!1,g="",_=L1,S=Hk,I=Mv,$=null;return a!=null&&(a.hydrate?console.warn("hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead."):typeof a=="object"&&a!==null&&a.$$typeof===Ku&&console.error(`You passed a JSX element to createRoot. You probably meant to call root.render instead. Example usage:
5059
5059
 
5060
5060
  let root = createRoot(domContainer);
5061
- root.render(<App />);`),a.unstable_strictMode===!0&&(c=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onUncaughtError!==void 0&&(_=a.onUncaughtError),a.onCaughtError!==void 0&&(S=a.onCaughtError),a.onRecoverableError!==void 0&&(I=a.onRecoverableError),a.unstable_transitionCallbacks!==void 0&&($=a.unstable_transitionCallbacks)),a=R_(i,1,!1,null,null,c,g,_,S,I,$,null),i[tc]=a.current,h_(i),new S0(a)},Qb.hydrateRoot=function(i,a,c){if(!A(i))throw Error("Target container is not a DOM element.");dA(i),a===void 0&&console.error("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");var g=!1,_="",S=L1,I=Hk,$=Mv,q=null,Y=null;return c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onUncaughtError!==void 0&&(S=c.onUncaughtError),c.onCaughtError!==void 0&&(I=c.onCaughtError),c.onRecoverableError!==void 0&&($=c.onRecoverableError),c.unstable_transitionCallbacks!==void 0&&(q=c.unstable_transitionCallbacks),c.formState!==void 0&&(Y=c.formState)),a=R_(i,1,!0,a,c??null,g,_,S,I,$,q,Y),a.context=I_(null),c=a.current,g=Qo(c),g=Re(g),_=Us(g),_.callback=null,cs(c,_,g),c=g,a.current.lanes=c,Pe(a,c),Fa(a),i[tc]=a.current,h_(i),new Xp(a)},Qb.version="19.1.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Qb}var VU;function Sue(){if(VU)return ck.exports;VU=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(),ck.exports=_ue()):ck.exports=xue(),ck.exports}var wue=Sue();const YU="debales-ai-assistant",ZU="debales-chatbot-container",Cue=W.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},o)=>{const s=W.useRef(null),[u,d]=W.useState(null),h=W.useRef(null),m=W.useRef(null),y=W.useRef({get shadowRoot(){return h.current},get container(){return u},querySelector:v=>{var x;return((x=h.current)==null?void 0:x.querySelector(v))||null},querySelectorAll:v=>{var x;return((x=h.current)==null?void 0:x.querySelectorAll(v))||null}});return W.useImperativeHandle(o,()=>y.current,[]),W.useEffect(()=>{const v=document.getElementById(YU);if(v?s.current=v:s.current&&(s.current.id=YU),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(`#${ZU}`);E&&d(E);return}const x=s.current.attachShadow({mode:"open"});if(h.current=x,t){const E=document.createElement("style");E.textContent=t,x.appendChild(E)}const w=document.createElement("div");w.id=ZU,w.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;",x.appendChild(w),d(w),r&&r(x,w)}},[t,r]),W.useEffect(()=>(u&&!m.current&&(m.current=wue.createRoot(u)),m.current&&u&&m.current.render(O.jsx(V.StyleSheetManager,{target:u,children:O.jsx(O9,{value:y.current,children:e})})),()=>{m.current&&m.current.unmount()}),[u,e]),O.jsx("div",{ref:s,style:n})});class aI{isSupported(){return ud.detect()===this.platform}createSuccessResult(t,n){return{success:!0,data:t,message:n}}createErrorResult(t){return{success:!1,error:t}}}class Eue extends aI{constructor(){super(...arguments);oo(this,"platform",xo.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,o){return console.log("DefaultCartAdapter: addToCart called",{variantId:n,quantity:r,properties:o}),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 o=new URL(`https://${n}/products/${r.handle}`);return o.searchParams.append("variant",r.product_id),Kh(o.toString())}else return Kh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}class kue extends aI{constructor(){var n,r;super();oo(this,"platform",xo.SHOPIFY);oo(this,"cartEndpoint");oo(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 o=sk(n);if(!o.isValid)return"";if(r.handle){const s=new URL(`/products/${r.handle}`,o.url);return s.searchParams.append("variant",r.product_id),Kh(s.toString())}else return Kh(r.link)}updateTrackCart({cartToken:n,sessionId:r=tr()}){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 o=r;return this.createSuccessResult(this.normalizeCartData(o),"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,o){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:o}],attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:tr(),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})}),o=await r.json();if(!r.ok){const s=o;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:tr(),...n}})});if(!r.ok){const o=await r.json();return this.createErrorResult(o.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=sk(n);if(!r.isValid)return"";const o=new URL("/cart",r.url);return o.searchParams.append("ref",`debales-ai-${new Date().toISOString()}`),o.searchParams.append("attributes[from]","debales-ai-chatbot"),o.searchParams.append("attributes[through]","add-to-cart"),o.searchParams.append("attributes[dbls_session_id]",tr()),o.searchParams.append("timestamp",Date.now().toString()),Kh(o.toString())}}class Aue extends aI{constructor(){var n,r;super();oo(this,"platform",xo.MAGENTO);oo(this,"checkoutEndpoint");oo(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 o=r.cart;return this.createSuccessResult(this.normalizeCartData(o),"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 o;try{const s=(o=document.querySelector('input[name="form_key"]'))==null?void 0:o.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 o=sk(n);if(!o.isValid)return"";if(r.handle){const s=new URL(`/${r.handle}.html`,o.url);return Kh(s.toString())}else return Kh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}const Xh=class Xh{constructor(){oo(this,"adapterCache");this.adapterCache=new Map}static getInstance(){return Xh.instance||(Xh.instance=new Xh),Xh.instance}getAdapter(t){const n=t||ud.detect(),r=this.adapterCache.get(n);if(r)return r;let o;switch(n){case xo.SHOPIFY:o=new kue;break;case xo.MAGENTO:o=new Aue;break;default:console.warn(`No specific adapter found for platform ${n}, using default adapter`),o=new Eue}return this.adapterCache.set(n,o),o}clearCache(){this.adapterCache.clear()}};oo(Xh,"instance");let sI=Xh;const Tue=({adapter:e,children:t,autoFetch:n=!0})=>{const[r,o]=W.useState(!1),[s,u]=W.useState(null),[d,h]=W.useState(null),m=W.useCallback(async()=>{try{o(!0),u(null);const R=await e.fetchCart();R.success?h(R.data):u(R.error)}catch(R){u(R instanceof Error?R.message:"Failed to fetch cart")}finally{o(!1)}},[e]),y=async(R,D,B)=>{try{u(null);const L=await e.addToCart(R,D,B);return L.success&&await m(),L}catch(L){return{success:!1,error:L instanceof Error?L.message:"Failed to add item to cart"}}},v=async R=>{try{u(null);const D=await e.removeFromCart(R);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to remove item from cart"}}},x=async R=>{try{u(null);const D=await e.updateQuantity(R);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to update quantity"}}},w=async()=>{try{u(null);const R=await e.clearCart();return R.success&&await m(),R}catch(R){return{success:!1,error:R instanceof Error?R.message:"Failed to clear cart"}}},E=R=>e.generateCartUrl(R),M=(R,D)=>e.generateProductUrl(R,D),A=async R=>e.addCartAttributes(R);W.useEffect(()=>{n&&m()},[n,m]);const k={isLoading:r,error:s,cart:d,fetchCart:m,addToCart:y,removeFromCart:v,updateQuantity:x,clearCart:w,generateCartUrl:E,generateProductUrl:M,addCartAttributes:A};return O.jsx(u9.Provider,{value:k,children:t})},_u=Object.create(null);_u.open="0",_u.close="1",_u.ping="2",_u.pong="3",_u.message="4",_u.upgrade="5",_u.noop="6";const dk=Object.create(null);Object.keys(_u).forEach(e=>{dk[_u[e]]=e});const lI={type:"error",data:"parser error"},QU=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",KU=typeof ArrayBuffer=="function",XU=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,uI=({type:e,data:t},n,r)=>QU&&t instanceof Blob?n?r(t):WU(t,r):KU&&(t instanceof ArrayBuffer||XU(t))?n?r(t):WU(new Blob([t]),r):r(_u[e]+(t||"")),WU=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function JU(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let cI;function Mue(e,t){if(QU&&e.data instanceof Blob)return e.data.arrayBuffer().then(JU).then(t);if(KU&&(e.data instanceof ArrayBuffer||XU(e.data)))return t(JU(e.data));uI(e,!1,n=>{cI||(cI=new TextEncoder),t(cI.encode(n))})}const e7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kb=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<e7.length;e++)Kb[e7.charCodeAt(e)]=e;const Oue=e=>{let t=e.length*.75,n=e.length,r,o=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=Kb[e.charCodeAt(r)],u=Kb[e.charCodeAt(r+1)],d=Kb[e.charCodeAt(r+2)],h=Kb[e.charCodeAt(r+3)],y[o++]=s<<2|u>>4,y[o++]=(u&15)<<4|d>>2,y[o++]=(d&3)<<6|h&63;return m},Rue=typeof ArrayBuffer=="function",fI=(e,t)=>{if(typeof e!="string")return{type:"message",data:t7(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:Iue(e.substring(1),t)}:dk[n]?e.length>1?{type:dk[n],data:e.substring(1)}:{type:dk[n]}:lI},Iue=(e,t)=>{if(Rue){const n=Oue(e);return t7(n,t)}else return{base64:!0,data:e}},t7=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},n7="",Due=(e,t)=>{const n=e.length,r=new Array(n);let o=0;e.forEach((s,u)=>{uI(s,!1,d=>{r[u]=d,++o===n&&t(r.join(n7))})})},$ue=(e,t)=>{const n=e.split(n7),r=[];for(let o=0;o<n.length;o++){const s=fI(n[o],t);if(r.push(s),s.type==="error")break}return r};function Lue(){return new TransformStream({transform(e,t){Mue(e,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const s=new DataView(o.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{o=new Uint8Array(9);const s=new DataView(o.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let dI;function hk(e){return e.reduce((t,n)=>t+n.length,0)}function pk(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let o=0;o<t;o++)n[o]=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 Nue(e,t){dI||(dI=new TextDecoder);const n=[];let r=0,o=-1,s=!1;return new TransformStream({transform(u,d){for(n.push(u);;){if(r===0){if(hk(n)<1)break;const h=pk(n,1);s=(h[0]&128)===128,o=h[0]&127,o<126?r=3:o===126?r=1:r=2}else if(r===1){if(hk(n)<2)break;const h=pk(n,2);o=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(hk(n)<8)break;const h=pk(n,8),m=new DataView(h.buffer,h.byteOffset,h.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){d.enqueue(lI);break}o=y*Math.pow(2,32)+m.getUint32(4),r=3}else{if(hk(n)<o)break;const h=pk(n,o);d.enqueue(fI(s?h:dI.decode(h),t)),r=0}if(o===0||o>e){d.enqueue(lI);break}}}})}const r7=4;function Ii(e){if(e)return Bue(e)}function Bue(e){for(var t in Ii.prototype)e[t]=Ii.prototype[t];return e}Ii.prototype.on=Ii.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Ii.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},Ii.prototype.off=Ii.prototype.removeListener=Ii.prototype.removeAllListeners=Ii.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,o=0;o<n.length;o++)if(r=n[o],r===t||r.fn===t){n.splice(o,1);break}return n.length===0&&delete this._callbacks["$"+e],this},Ii.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,o=n.length;r<o;++r)n[r].apply(this,t)}return this},Ii.prototype.emitReserved=Ii.prototype.emit,Ii.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Ii.prototype.hasListeners=function(e){return!!this.listeners(e).length};const gk=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Is=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),zue="arraybuffer";function ede(){}function i7(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const Uue=Is.setTimeout,jue=Is.clearTimeout;function mk(e,t){t.useNativeTimers?(e.setTimeoutFn=Uue.bind(Is),e.clearTimeoutFn=jue.bind(Is)):(e.setTimeoutFn=Is.setTimeout.bind(Is),e.clearTimeoutFn=Is.clearTimeout.bind(Is))}const Hue=1.33;function que(e){return typeof e=="string"?Pue(e):Math.ceil((e.byteLength||e.size)*Hue)}function Pue(e){let t=0,n=0;for(let r=0,o=e.length;r<o;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 o7(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Fue(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Gue(e){let t={},n=e.split("&");for(let r=0,o=n.length;r<o;r++){let s=n[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}class Vue extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class hI extends Ii{constructor(t){super(),this.writable=!1,mk(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 Vue(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=fI(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=Fue(t);return n.length?"?"+n:""}}class Yue extends hI{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)};$ue(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,Due(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]=o7()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let a7=!1;try{a7=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Zue=a7;function Que(){}class Kue extends Yue{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",(o,s)=>{this.onError("xhr post error",o,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 xu extends Ii{constructor(t,n,r){super(),this.createRequest=t,mk(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=i7(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 o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&r.setRequestHeader(o,this._opts.extraHeaders[o])}}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 o;r.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.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(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=xu.requestsCount++,xu.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=Que,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete xu.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(xu.requestsCount=0,xu.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",s7);else if(typeof addEventListener=="function"){const e="onpagehide"in Is?"pagehide":"unload";addEventListener(e,s7,!1)}}function s7(){for(let e in xu.requests)xu.requests.hasOwnProperty(e)&&xu.requests[e].abort()}const Xue=function(){const e=l7({xdomain:!1});return e&&e.responseType!==null}();class Wue extends Kue{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Xue&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new xu(l7,this.uri(),t)}}function l7(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Zue))return new XMLHttpRequest}catch{}if(!t)try{return new Is[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const u7=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Jue extends hI{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=u7?{}:i7(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(o){return this.emitReserved("error",o)}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],o=n===t.length-1;uI(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}o&&gk(()=>{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]=o7()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const pI=Is.WebSocket||Is.MozWebSocket;class ece extends Jue{createSocket(t,n,r){return u7?new pI(t,n,r):n?new pI(t,n):new pI(t)}doWrite(t,n){this.ws.send(n)}}class tce extends hI{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=Nue(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=Lue();o.readable.pipeTo(t.writable),this._writer=o.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],o=n===t.length-1;this._writer.write(r).then(()=>{o&&gk(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const nce={websocket:ece,webtransport:tce,polling:Wue},rce=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ice=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function gI(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 o=rce.exec(e||""),s={},u=14;for(;u--;)s[ice[u]]=o[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=oce(s,s.path),s.queryKey=ace(s,s.query),s}function oce(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 ace(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,s){o&&(n[o]=s)}),n}const mI=typeof addEventListener=="function"&&typeof removeEventListener=="function",vk=[];mI&&addEventListener("offline",()=>{vk.forEach(e=>e())},!1);class cd extends Ii{constructor(t,n){if(super(),this.binaryType=zue,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=gI(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=gI(n.host).host);mk(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 o=r.prototype.name;this.transports.push(o),this._transportsByName[o]=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=Gue(this.opts.query)),mI&&(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"})},vk.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=r7,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&&cd.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",cd.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 o=this.writeBuffer[r].data;if(o&&(n+=que(o)),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,gk(()=>{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,o){if(typeof n=="function"&&(o=n,n=void 0),typeof r=="function"&&(o=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),o&&this.once("flush",o),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(cd.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(),mI&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=vk.indexOf(this._offlineEventListener);r!==-1&&vk.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}cd.protocol=r7;class sce extends cd{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;cd.priorWebsocketSuccess=!1;const o=()=>{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;cd.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 x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function s(){r||(r=!0,y(),n.close(),n=null)}const u=v=>{const x=new Error("probe error: "+v);x.transport=n.name,s(),this.emitReserved("upgradeError",x)};function d(){u("transport closed")}function h(){u("socket closed")}function m(v){n&&v.name!==n.name&&s()}const y=()=>{n.removeListener("open",o),n.removeListener("error",u),n.removeListener("close",d),this.off("close",h),this.off("upgrading",m)};n.once("open",o),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 lce=class extends sce{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(o=>nce[o]).filter(o=>!!o)),super(t,r)}};function uce(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=gI(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 cce=typeof ArrayBuffer=="function",fce=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,c7=Object.prototype.toString,dce=typeof Blob=="function"||typeof Blob<"u"&&c7.call(Blob)==="[object BlobConstructor]",hce=typeof File=="function"||typeof File<"u"&&c7.call(File)==="[object FileConstructor]";function vI(e){return cce&&(e instanceof ArrayBuffer||fce(e))||dce&&e instanceof Blob||hce&&e instanceof File}function yk(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(yk(e[n]))return!0;return!1}if(vI(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return yk(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&yk(e[n]))return!0;return!1}function pce(e){const t=[],n=e.data,r=e;return r.data=yI(n,t),r.attachments=t.length,{packet:r,buffers:t}}function yI(e,t){if(!e)return e;if(vI(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]=yI(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]=yI(e[r],t));return n}return e}function gce(e,t){return e.data=bI(e.data,t),delete e.attachments,e}function bI(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]=bI(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=bI(e[n],t));return e}const mce=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],vce=5;var Hn;(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"})(Hn||(Hn={}));class yce{constructor(t){this.replacer=t}encode(t){return(t.type===Hn.EVENT||t.type===Hn.ACK)&&yk(t)?this.encodeAsBinary({type:t.type===Hn.EVENT?Hn.BINARY_EVENT:Hn.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Hn.BINARY_EVENT||t.type===Hn.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=pce(t),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function f7(e){return Object.prototype.toString.call(e)==="[object Object]"}class _I extends Ii{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===Hn.BINARY_EVENT;r||n.type===Hn.BINARY_ACK?(n.type=r?Hn.EVENT:Hn.ACK,this.reconstructor=new bce(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(vI(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(Hn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Hn.BINARY_EVENT||r.type===Hn.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 o=t.charAt(n+1);if(o!==""&&Number(o)==o){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(_I.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 Hn.CONNECT:return f7(n);case Hn.DISCONNECT:return n===void 0;case Hn.CONNECT_ERROR:return typeof n=="string"||f7(n);case Hn.EVENT:case Hn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&mce.indexOf(n[0])===-1);case Hn.ACK:case Hn.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class bce{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=gce(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const _ce=Object.freeze(Object.defineProperty({__proto__:null,Decoder:_I,Encoder:yce,get PacketType(){return Hn},protocol:vce},Symbol.toStringTag,{value:"Module"}));function Ol(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const xce=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class d7 extends Ii{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=[Ol(t,"open",this.onopen.bind(this)),Ol(t,"packet",this.onpacket.bind(this)),Ol(t,"error",this.onerror.bind(this)),Ol(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,o,s;if(xce.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:Hn.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=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.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 o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===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"))},o),u=(...d)=>{this.io.clearTimeoutFn(s),n.apply(this,d)};u.withError=!0,this.acks[t]=u}emitWithAck(t,...n){return new Promise((r,o)=>{const s=(u,d)=>u?o(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((o,...s)=>r!==this._queue[0]?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(o)):(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:Hn.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 Hn.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 Hn.EVENT:case Hn.BINARY_EVENT:this.onevent(t);break;case Hn.ACK:case Hn.BINARY_ACK:this.onack(t);break;case Hn.DISCONNECT:this.ondisconnect();break;case Hn.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(...o){r||(r=!0,n.packet({type:Hn.ACK,id:t,data:o}))}}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:Hn.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 Qm(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}Qm.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},Qm.prototype.reset=function(){this.attempts=0},Qm.prototype.setMin=function(e){this.ms=e},Qm.prototype.setMax=function(e){this.max=e},Qm.prototype.setJitter=function(e){this.jitter=e};class xI extends Ii{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,mk(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 Qm({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const o=n.parser||_ce;this.encoder=new o.Encoder,this.decoder=new o.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 lce(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=Ol(n,"open",function(){r.onopen(),t&&t()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),t?t(d):this.maybeReconnectOnOpen()},u=Ol(n,"error",s);if(this._timeout!==!1){const d=this._timeout,h=this.setTimeoutFn(()=>{o(),s(new Error("timeout")),n.close()},d);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(o),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(Ol(t,"ping",this.onping.bind(this)),Ol(t,"data",this.ondata.bind(this)),Ol(t,"error",this.onerror.bind(this)),Ol(t,"close",this.onclose.bind(this)),Ol(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){gk(()=>{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 d7(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(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):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 Xb={};function bk(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=uce(e,t.path||"/socket.io"),r=n.source,o=n.id,s=n.path,u=Xb[o]&&s in Xb[o].nsps,d=t.forceNew||t["force new connection"]||t.multiplex===!1||u;let h;return d?h=new xI(r,t):(Xb[o]||(Xb[o]=new xI(r,t)),h=Xb[o]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}Object.assign(bk,{Manager:xI,Socket:d7,io:bk,connect:bk});const Wh=class Wh{constructor(){oo(this,"socket",null);oo(this,"isConnected",!1);oo(this,"eventListeners",new Map)}static getInstance(){return Wh.instance||(Wh.instance=new Wh),Wh.instance}connect(t){return this.socket?this.socket:(this.socket=bk(`${pne}${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,o;this.eventListeners.has(t)||this.eventListeners.set(t,[]),(r=this.eventListeners.get(t))==null||r.push(n),(o=this.socket)==null||o.on(t,n)}off(t,n){var o;const r=this.eventListeners.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1),(o=this.socket)==null||o.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(o=>o(...n))}};oo(Wh,"instance");let SI=Wh;const Su=SI.getInstance();var Sce={MESSAGE:"MESSAGE"},wce={USER:"USER"};function _k(e,t){window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:t}))}const h7=(e,t)=>{const n=JSON.stringify(t);window.localStorage.setItem(e,n),_k(e,n)},Cce=e=>{window.localStorage.removeItem(e),_k(e,null)},p7=e=>window.localStorage.getItem(e),Ece=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),kce=()=>{throw Error("useLocalStorage is a client-only hook")};function Ace(e,t){const n=()=>p7(e),r=Ge.useSyncExternalStore(Ece,n,kce),o=Ge.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Cce(e):h7(e,u)}catch(u){console.warn(u)}},[e,r]);return Ge.useEffect(()=>{p7(e)===null&&h7(e,t)},[e,t]),[r?JSON.parse(r):t,o]}const g7=(e,t)=>{const n=JSON.stringify(t);window.sessionStorage.setItem(e,n),_k(e,n)},Tce=e=>{window.sessionStorage.removeItem(e),_k(e,null)},m7=e=>window.sessionStorage.getItem(e),Mce=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Oce=()=>{throw Error("useSessionStorage is a client-only hook")};function Rce(e,t){const n=()=>m7(e),r=Ge.useSyncExternalStore(Mce,n,Oce),o=Ge.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Tce(e):g7(e,u)}catch(u){console.warn(u)}},[e,r]);return Ge.useEffect(()=>{m7(e)===null&&g7(e,t)},[e,t]),[r?JSON.parse(r):t,o]}const Ice=({children:e,nameSpace:t})=>{const[n,r]=W.useState(""),[o,s]=W.useState([]),[u,d]=W.useState(!1),[h,m]=W.useState(!1),[y,v]=W.useState([]),[x,w]=W.useState(!1),[E,M]=W.useState(!1),[A,k]=W.useState([]),[R,D]=Ace(Dn(In.USER_INFO),null),[B,L]=Rce(Dn(In.IS_FORM_CLOSED_BY_USER),!1),[H,K]=W.useState(null),ee=jf("web-socket"),[J,Q]=W.useState([]),[ae,fe]=W.useState(null),[Se,se]=W.useState(!1),[pe,Z]=W.useState(sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:t}))),ie=bne(),ye=tr(),[He,U]=W.useState(null),[Be,Oe]=W.useState(null);W.useEffect(()=>{if(ee){const gt=Su.connect("/api/v1/chat");fe(gt);const Fe=()=>{console.debug("connected to websocket"),se(!0)},lt=()=>{console.debug("disconnected from websocket"),se(!1)},ct=pt=>{console.debug("response from websocket",pt);const dt=pt.conversationId??crypto.randomUUID().toString();Z(dt),pt.Variants_quantity&&k(X=>[...X,...pt.Variants_quantity]);const G=[...o,{text:pt.response,products:pt.products,conversationId:dt,rating:"neutral",leading_queries:pt.leading_queries,collections:pt.collections,variants:pt.variants,shop:pt.shop,Variants_quantity:pt.Variants_quantity,monthlyChatLimitReached:pt.monthlyChatLimitReached,isBot:!0}];s(G),F(G),v(X=>[...X,[o[o.length-1].text,pt.response]]),m(!1)},zt=pt=>{if(pt.event==="error"){const dt={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},G=[...o,dt];s(G),F(G),m(!1)}};return Su.on("connect",Fe),Su.on("disconnect",lt),Su.on("response",ct),Su.on("system",zt),()=>{Su.off("connect",Fe),Su.off("disconnect",lt),Su.off("response",ct),Su.off("system",zt)}}},[ee,o]);const F=gt=>{sessionStorage.setItem(Dn(In.CHAT_HISTORY,{botId:window.DebalesChat.projectId}),JSON.stringify(gt))},We=()=>{const gt=sessionStorage.getItem(Dn(In.CHAT_HISTORY,{botId:window.DebalesChat.projectId}));return gt?JSON.parse(gt):[]},at=W.useCallback(async()=>{if(t)try{d(!0);const gt=await fetch(`${ci}/api/wordpress/UiData?value=${t}`),Fe=await gt.json();if(!gt.ok)throw new Error("failed to fetch data"+Fe.error);const lt=document.getElementById("debales-ai-assistant");lt&&(lt.style.zIndex=String(Fe.zIndex??2031483602)),Oe(Fe),Fe!=null&&Fe.shopifyShopDomain&&Bne(Fe.shopifyShopDomain).then(zt=>{U(zt)}),Q(Fe.suggestedQuestions);const ct=We();if(ct.length>0)s(ct);else{const zt={text:Fe.initialMessage||"Hi, I am an AI Assistant. How can I help you?",isBot:!0};s([zt])}}catch(gt){console.error(gt)}finally{d(!1)}},[t]);W.useEffect(()=>{at()},[at]);const Qe=W.useMemo(()=>{var gt;return!!(!B&&((gt=Be==null?void 0:Be.pluginConfig)!=null&&gt.collectedUserInfo)&&(Be.pluginConfig.collectedUserInfo.name||Be.pluginConfig.collectedUserInfo.email||Be.pluginConfig.collectedUserInfo.phone)&&!R)},[Be,R,B]),Bt=W.useCallback(async(gt,Fe,lt,ct,zt,pt)=>{if(!gt||gt.trim()===""||h&&!lt)return;let dt=[...o];ct?ct&&o.length<=2?(w(!0),dt=[]):w(!1):(dt.push({text:gt,isBot:!1}),w(!1));const G=tr();m(!0);try{s(dt),F(dt);const X=await fetch(`${ci}/api/wordpress/ChatWithBot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:G,userMessage:gt,nameSpace:t,chat_history:y,leading_queries:zt,answer:Fe,products:lt,userInfo:JSON.stringify(R),anonymousUserId:ie,distinctId:bu.getDistinctId(),timestamp:new Date().toISOString(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,followUpQuestion:pt})});if(!X.ok)throw new Error("Network response was not ok");const ce=await X.json(),Ie=ce.conversationId??crypto.randomUUID().toString();Z(Ie),ce.Variants_quantity&&k(Pe=>[...Pe,...ce.Variants_quantity]);const $e=[...dt,{text:ce.response,products:ce.products,conversationId:Ie,rating:"neutral",leading_queries:ce.leading_queries,collections:ce.collections,variants:ce.variants,shop:ce.shop,Variants_quantity:ce.Variants_quantity,monthlyChatLimitReached:ce.monthlyChatLimitReached,isBot:!0}];s($e),F($e),v(Pe=>[...Pe,[gt,ce.response]])}catch(X){console.error(X);const ce={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},Ie=[...dt,ce];ct||(s(Ie),F(Ie))}finally{m(!1)}},[o,h,y,t,ie,R]),St=W.useCallback(gt=>{Be&&Oe(Fe=>Fe?{...Fe,mobileDisplayMode:gt}:null)},[Be]),$t=W.useCallback(async(gt,Fe,lt,ct,zt,pt)=>{if(!gt||gt.trim()===""||h&&!lt)return;let dt=[...o];if(ct?ct&&o.length<=2?(w(!0),dt=[]):w(!1):(dt.push({text:gt,isBot:!1}),w(!1)),m(!0),s(dt),F(dt),ae&&Se){const G={type:Sce.MESSAGE,role:wce.USER,query:gt,nameSpace:t,leadingQueries:zt,answer:Fe,products:lt,userInfo:R,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),sessionId:ye,anonymousUserId:ie,distinctId:bu.getDistinctId(),followUpQuestion:pt};Su.emit("chat",G)}else Bt(gt,Fe,lt,ct,zt,pt)},[o,h,t,ie,ae,Se,ye,Bt,R]),qt={sessionId:ye,messages:o,isLoading:u,isMessageLoading:h,isKlaviyoMessage:x,showUserInfoModel:E,pendingBulkItems:A,lastedBotmessageId:pe,uiData:Be,storeMetaData:He,suggestedQuestions:J,isUserInfoNeeded:Qe,input:n,pendingQuestion:H,userInfo:R,isFormClosedByUser:B,onSendMessage:ee?$t:Bt,setMessages:s,setIsLoading:d,setIsMessageLoading:m,setIsKlaviyoMessage:w,setShowUserInfoModel:M,setPendingBulkItems:k,setLastedBotmessageId:Z,fetchUiInfo:at,changeDisplayModel:St,saveConversation:F,loadConversation:We,setSuggestedQuestions:Q,setUserInfo:D,setInput:r,setPendingQuestion:K,setIsFormClosedByUser:L};return O.jsx(R9.Provider,{value:qt,children:e})};function Dce(e){const t=sI.getInstance().getAdapter();return O.jsx(Ice,{nameSpace:e.botId,children:O.jsx(EP,{apiKey:gne,options:{capture_pageview:e.botId!=="burgerbaeclothing",capture_pageleave:e.botId!=="burgerbaeclothing",api_host:ci+"/ingest",ui_host:"https://us.posthog.com",loaded:n=>{n.register({platform:ud.detect(),project:e.botId,sessionId:tr()}),n.group("project",e.botId,{platform:ud.detect()});const r=bo();r&&r.email&&!n._isIdentified()&&n.identify(r.email,{name:r.name,phone:r.phone,email:r.email,project:e.botId})},debug:!0},children:O.jsx(Tue,{adapter:t,children:e.children})})})}function $ce(e){return O.jsx(Cue,{children:O.jsx(Dce,{botId:e.botId,children:O.jsx(vue,{...e})})})}return $ce});
5061
+ root.render(<App />);`),a.unstable_strictMode===!0&&(c=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onUncaughtError!==void 0&&(_=a.onUncaughtError),a.onCaughtError!==void 0&&(S=a.onCaughtError),a.onRecoverableError!==void 0&&(I=a.onRecoverableError),a.unstable_transitionCallbacks!==void 0&&($=a.unstable_transitionCallbacks)),a=R_(i,1,!1,null,null,c,g,_,S,I,$,null),i[tc]=a.current,h_(i),new S0(a)},Qb.hydrateRoot=function(i,a,c){if(!A(i))throw Error("Target container is not a DOM element.");dA(i),a===void 0&&console.error("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");var g=!1,_="",S=L1,I=Hk,$=Mv,q=null,Y=null;return c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onUncaughtError!==void 0&&(S=c.onUncaughtError),c.onCaughtError!==void 0&&(I=c.onCaughtError),c.onRecoverableError!==void 0&&($=c.onRecoverableError),c.unstable_transitionCallbacks!==void 0&&(q=c.unstable_transitionCallbacks),c.formState!==void 0&&(Y=c.formState)),a=R_(i,1,!0,a,c??null,g,_,S,I,$,q,Y),a.context=I_(null),c=a.current,g=Qo(c),g=Re(g),_=Us(g),_.callback=null,cs(c,_,g),c=g,a.current.lanes=c,Pe(a,c),Fa(a),i[tc]=a.current,h_(i),new Xp(a)},Qb.version="19.1.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Qb}var VU;function Sue(){if(VU)return ck.exports;VU=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(),ck.exports=_ue()):ck.exports=xue(),ck.exports}var wue=Sue();const YU="debales-ai-assistant",ZU="debales-chatbot-container",Cue=W.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},o)=>{const s=W.useRef(null),[u,d]=W.useState(null),h=W.useRef(null),m=W.useRef(null),y=W.useRef({get shadowRoot(){return h.current},get container(){return u},querySelector:v=>{var x;return((x=h.current)==null?void 0:x.querySelector(v))||null},querySelectorAll:v=>{var x;return((x=h.current)==null?void 0:x.querySelectorAll(v))||null}});return W.useImperativeHandle(o,()=>y.current,[]),W.useEffect(()=>{const v=document.getElementById(YU);if(v?s.current=v:s.current&&(s.current.id=YU),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(`#${ZU}`);E&&d(E);return}const x=s.current.attachShadow({mode:"open"});if(h.current=x,t){const E=document.createElement("style");E.textContent=t,x.appendChild(E)}const w=document.createElement("div");w.id=ZU,w.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;",x.appendChild(w),d(w),r&&r(x,w)}},[t,r]),W.useEffect(()=>(u&&!m.current&&(m.current=wue.createRoot(u)),m.current&&u&&m.current.render(O.jsx(V.StyleSheetManager,{target:u,children:O.jsx(O9,{value:y.current,children:e})})),()=>{m.current&&m.current.unmount()}),[u,e]),O.jsx("div",{ref:s,style:n})});class aI{isSupported(){return ud.detect()===this.platform}createSuccessResult(t,n){return{success:!0,data:t,message:n}}createErrorResult(t){return{success:!1,error:t}}}class Eue extends aI{constructor(){super(...arguments);oo(this,"platform",xo.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,o){return console.log("DefaultCartAdapter: addToCart called",{variantId:n,quantity:r,properties:o}),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 o=new URL(`https://${n}/products/${r.handle}`);return o.searchParams.append("variant",r.product_id),Kh(o.toString())}else return Kh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}class kue extends aI{constructor(){var n,r;super();oo(this,"platform",xo.SHOPIFY);oo(this,"cartEndpoint");oo(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 o=sk(n);if(!o.isValid)return"";if(r.handle){const s=new URL(`/products/${r.handle}`,o.url);return s.searchParams.append("variant",r.product_id),Kh(s.toString())}else return Kh(r.link)}updateTrackCart({cartToken:n,sessionId:r=tr()}){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 o=r;return this.createSuccessResult(this.normalizeCartData(o),"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,o){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:o}],attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:tr(),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})}),o=await r.json();if(!r.ok){const s=o;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:tr(),...n}})});if(!r.ok){const o=await r.json();return this.createErrorResult(o.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=sk(n);if(!r.isValid)return"";const o=new URL("/cart",r.url);return o.searchParams.append("ref",`debales-ai-${new Date().toISOString()}`),o.searchParams.append("attributes[from]","debales-ai-chatbot"),o.searchParams.append("attributes[through]","add-to-cart"),o.searchParams.append("attributes[dbls_session_id]",tr()),o.searchParams.append("timestamp",Date.now().toString()),Kh(o.toString())}}class Aue extends aI{constructor(){var n,r;super();oo(this,"platform",xo.MAGENTO);oo(this,"checkoutEndpoint");oo(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 o=r.cart;return this.createSuccessResult(this.normalizeCartData(o),"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 o;try{const s=(o=document.querySelector('input[name="form_key"]'))==null?void 0:o.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 o=sk(n);if(!o.isValid)return"";if(r.handle){const s=new URL(`/${r.handle}.html`,o.url);return Kh(s.toString())}else return Kh(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}const Xh=class Xh{constructor(){oo(this,"adapterCache");this.adapterCache=new Map}static getInstance(){return Xh.instance||(Xh.instance=new Xh),Xh.instance}getAdapter(t){const n=t||ud.detect(),r=this.adapterCache.get(n);if(r)return r;let o;switch(n){case xo.SHOPIFY:o=new kue;break;case xo.MAGENTO:o=new Aue;break;default:console.warn(`No specific adapter found for platform ${n}, using default adapter`),o=new Eue}return this.adapterCache.set(n,o),o}clearCache(){this.adapterCache.clear()}};oo(Xh,"instance");let sI=Xh;const Tue=({adapter:e,children:t,autoFetch:n=!0})=>{const[r,o]=W.useState(!1),[s,u]=W.useState(null),[d,h]=W.useState(null),m=W.useCallback(async()=>{try{o(!0),u(null);const R=await e.fetchCart();R.success?h(R.data):u(R.error)}catch(R){u(R instanceof Error?R.message:"Failed to fetch cart")}finally{o(!1)}},[e]),y=async(R,D,B)=>{try{u(null);const L=await e.addToCart(R,D,B);return L.success&&await m(),L}catch(L){return{success:!1,error:L instanceof Error?L.message:"Failed to add item to cart"}}},v=async R=>{try{u(null);const D=await e.removeFromCart(R);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to remove item from cart"}}},x=async R=>{try{u(null);const D=await e.updateQuantity(R);return D.success&&await m(),D}catch(D){return{success:!1,error:D instanceof Error?D.message:"Failed to update quantity"}}},w=async()=>{try{u(null);const R=await e.clearCart();return R.success&&await m(),R}catch(R){return{success:!1,error:R instanceof Error?R.message:"Failed to clear cart"}}},E=R=>e.generateCartUrl(R),M=(R,D)=>e.generateProductUrl(R,D),A=async R=>e.addCartAttributes(R);W.useEffect(()=>{n&&m()},[n,m]);const k={isLoading:r,error:s,cart:d,fetchCart:m,addToCart:y,removeFromCart:v,updateQuantity:x,clearCart:w,generateCartUrl:E,generateProductUrl:M,addCartAttributes:A};return O.jsx(u9.Provider,{value:k,children:t})},_u=Object.create(null);_u.open="0",_u.close="1",_u.ping="2",_u.pong="3",_u.message="4",_u.upgrade="5",_u.noop="6";const dk=Object.create(null);Object.keys(_u).forEach(e=>{dk[_u[e]]=e});const lI={type:"error",data:"parser error"},QU=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",KU=typeof ArrayBuffer=="function",XU=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,uI=({type:e,data:t},n,r)=>QU&&t instanceof Blob?n?r(t):WU(t,r):KU&&(t instanceof ArrayBuffer||XU(t))?n?r(t):WU(new Blob([t]),r):r(_u[e]+(t||"")),WU=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function JU(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let cI;function Mue(e,t){if(QU&&e.data instanceof Blob)return e.data.arrayBuffer().then(JU).then(t);if(KU&&(e.data instanceof ArrayBuffer||XU(e.data)))return t(JU(e.data));uI(e,!1,n=>{cI||(cI=new TextEncoder),t(cI.encode(n))})}const e7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kb=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<e7.length;e++)Kb[e7.charCodeAt(e)]=e;const Oue=e=>{let t=e.length*.75,n=e.length,r,o=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=Kb[e.charCodeAt(r)],u=Kb[e.charCodeAt(r+1)],d=Kb[e.charCodeAt(r+2)],h=Kb[e.charCodeAt(r+3)],y[o++]=s<<2|u>>4,y[o++]=(u&15)<<4|d>>2,y[o++]=(d&3)<<6|h&63;return m},Rue=typeof ArrayBuffer=="function",fI=(e,t)=>{if(typeof e!="string")return{type:"message",data:t7(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:Iue(e.substring(1),t)}:dk[n]?e.length>1?{type:dk[n],data:e.substring(1)}:{type:dk[n]}:lI},Iue=(e,t)=>{if(Rue){const n=Oue(e);return t7(n,t)}else return{base64:!0,data:e}},t7=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},n7="",Due=(e,t)=>{const n=e.length,r=new Array(n);let o=0;e.forEach((s,u)=>{uI(s,!1,d=>{r[u]=d,++o===n&&t(r.join(n7))})})},$ue=(e,t)=>{const n=e.split(n7),r=[];for(let o=0;o<n.length;o++){const s=fI(n[o],t);if(r.push(s),s.type==="error")break}return r};function Lue(){return new TransformStream({transform(e,t){Mue(e,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const s=new DataView(o.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{o=new Uint8Array(9);const s=new DataView(o.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let dI;function hk(e){return e.reduce((t,n)=>t+n.length,0)}function pk(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let o=0;o<t;o++)n[o]=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 Nue(e,t){dI||(dI=new TextDecoder);const n=[];let r=0,o=-1,s=!1;return new TransformStream({transform(u,d){for(n.push(u);;){if(r===0){if(hk(n)<1)break;const h=pk(n,1);s=(h[0]&128)===128,o=h[0]&127,o<126?r=3:o===126?r=1:r=2}else if(r===1){if(hk(n)<2)break;const h=pk(n,2);o=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(hk(n)<8)break;const h=pk(n,8),m=new DataView(h.buffer,h.byteOffset,h.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){d.enqueue(lI);break}o=y*Math.pow(2,32)+m.getUint32(4),r=3}else{if(hk(n)<o)break;const h=pk(n,o);d.enqueue(fI(s?h:dI.decode(h),t)),r=0}if(o===0||o>e){d.enqueue(lI);break}}}})}const r7=4;function Ii(e){if(e)return Bue(e)}function Bue(e){for(var t in Ii.prototype)e[t]=Ii.prototype[t];return e}Ii.prototype.on=Ii.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Ii.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},Ii.prototype.off=Ii.prototype.removeListener=Ii.prototype.removeAllListeners=Ii.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,o=0;o<n.length;o++)if(r=n[o],r===t||r.fn===t){n.splice(o,1);break}return n.length===0&&delete this._callbacks["$"+e],this},Ii.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,o=n.length;r<o;++r)n[r].apply(this,t)}return this},Ii.prototype.emitReserved=Ii.prototype.emit,Ii.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Ii.prototype.hasListeners=function(e){return!!this.listeners(e).length};const gk=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Is=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),zue="arraybuffer";function ede(){}function i7(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const Uue=Is.setTimeout,jue=Is.clearTimeout;function mk(e,t){t.useNativeTimers?(e.setTimeoutFn=Uue.bind(Is),e.clearTimeoutFn=jue.bind(Is)):(e.setTimeoutFn=Is.setTimeout.bind(Is),e.clearTimeoutFn=Is.clearTimeout.bind(Is))}const Hue=1.33;function que(e){return typeof e=="string"?Pue(e):Math.ceil((e.byteLength||e.size)*Hue)}function Pue(e){let t=0,n=0;for(let r=0,o=e.length;r<o;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 o7(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Fue(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Gue(e){let t={},n=e.split("&");for(let r=0,o=n.length;r<o;r++){let s=n[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}class Vue extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class hI extends Ii{constructor(t){super(),this.writable=!1,mk(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 Vue(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=fI(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=Fue(t);return n.length?"?"+n:""}}class Yue extends hI{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)};$ue(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,Due(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]=o7()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let a7=!1;try{a7=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Zue=a7;function Que(){}class Kue extends Yue{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",(o,s)=>{this.onError("xhr post error",o,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 xu extends Ii{constructor(t,n,r){super(),this.createRequest=t,mk(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=i7(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 o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&r.setRequestHeader(o,this._opts.extraHeaders[o])}}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 o;r.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.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(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=xu.requestsCount++,xu.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=Que,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete xu.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(xu.requestsCount=0,xu.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",s7);else if(typeof addEventListener=="function"){const e="onpagehide"in Is?"pagehide":"unload";addEventListener(e,s7,!1)}}function s7(){for(let e in xu.requests)xu.requests.hasOwnProperty(e)&&xu.requests[e].abort()}const Xue=function(){const e=l7({xdomain:!1});return e&&e.responseType!==null}();class Wue extends Kue{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Xue&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new xu(l7,this.uri(),t)}}function l7(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Zue))return new XMLHttpRequest}catch{}if(!t)try{return new Is[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const u7=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Jue extends hI{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=u7?{}:i7(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(o){return this.emitReserved("error",o)}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],o=n===t.length-1;uI(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}o&&gk(()=>{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]=o7()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const pI=Is.WebSocket||Is.MozWebSocket;class ece extends Jue{createSocket(t,n,r){return u7?new pI(t,n,r):n?new pI(t,n):new pI(t)}doWrite(t,n){this.ws.send(n)}}class tce extends hI{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=Nue(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=Lue();o.readable.pipeTo(t.writable),this._writer=o.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],o=n===t.length-1;this._writer.write(r).then(()=>{o&&gk(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const nce={websocket:ece,webtransport:tce,polling:Wue},rce=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ice=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function gI(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 o=rce.exec(e||""),s={},u=14;for(;u--;)s[ice[u]]=o[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=oce(s,s.path),s.queryKey=ace(s,s.query),s}function oce(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 ace(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,s){o&&(n[o]=s)}),n}const mI=typeof addEventListener=="function"&&typeof removeEventListener=="function",vk=[];mI&&addEventListener("offline",()=>{vk.forEach(e=>e())},!1);class cd extends Ii{constructor(t,n){if(super(),this.binaryType=zue,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=gI(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=gI(n.host).host);mk(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 o=r.prototype.name;this.transports.push(o),this._transportsByName[o]=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=Gue(this.opts.query)),mI&&(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"})},vk.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=r7,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&&cd.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",cd.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 o=this.writeBuffer[r].data;if(o&&(n+=que(o)),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,gk(()=>{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,o){if(typeof n=="function"&&(o=n,n=void 0),typeof r=="function"&&(o=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),o&&this.once("flush",o),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(cd.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(),mI&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=vk.indexOf(this._offlineEventListener);r!==-1&&vk.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}cd.protocol=r7;class sce extends cd{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;cd.priorWebsocketSuccess=!1;const o=()=>{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;cd.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 x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function s(){r||(r=!0,y(),n.close(),n=null)}const u=v=>{const x=new Error("probe error: "+v);x.transport=n.name,s(),this.emitReserved("upgradeError",x)};function d(){u("transport closed")}function h(){u("socket closed")}function m(v){n&&v.name!==n.name&&s()}const y=()=>{n.removeListener("open",o),n.removeListener("error",u),n.removeListener("close",d),this.off("close",h),this.off("upgrading",m)};n.once("open",o),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 lce=class extends sce{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(o=>nce[o]).filter(o=>!!o)),super(t,r)}};function uce(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=gI(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 cce=typeof ArrayBuffer=="function",fce=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,c7=Object.prototype.toString,dce=typeof Blob=="function"||typeof Blob<"u"&&c7.call(Blob)==="[object BlobConstructor]",hce=typeof File=="function"||typeof File<"u"&&c7.call(File)==="[object FileConstructor]";function vI(e){return cce&&(e instanceof ArrayBuffer||fce(e))||dce&&e instanceof Blob||hce&&e instanceof File}function yk(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(yk(e[n]))return!0;return!1}if(vI(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return yk(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&yk(e[n]))return!0;return!1}function pce(e){const t=[],n=e.data,r=e;return r.data=yI(n,t),r.attachments=t.length,{packet:r,buffers:t}}function yI(e,t){if(!e)return e;if(vI(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]=yI(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]=yI(e[r],t));return n}return e}function gce(e,t){return e.data=bI(e.data,t),delete e.attachments,e}function bI(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]=bI(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=bI(e[n],t));return e}const mce=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],vce=5;var Hn;(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"})(Hn||(Hn={}));class yce{constructor(t){this.replacer=t}encode(t){return(t.type===Hn.EVENT||t.type===Hn.ACK)&&yk(t)?this.encodeAsBinary({type:t.type===Hn.EVENT?Hn.BINARY_EVENT:Hn.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Hn.BINARY_EVENT||t.type===Hn.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=pce(t),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function f7(e){return Object.prototype.toString.call(e)==="[object Object]"}class _I extends Ii{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===Hn.BINARY_EVENT;r||n.type===Hn.BINARY_ACK?(n.type=r?Hn.EVENT:Hn.ACK,this.reconstructor=new bce(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(vI(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(Hn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Hn.BINARY_EVENT||r.type===Hn.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 o=t.charAt(n+1);if(o!==""&&Number(o)==o){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(_I.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 Hn.CONNECT:return f7(n);case Hn.DISCONNECT:return n===void 0;case Hn.CONNECT_ERROR:return typeof n=="string"||f7(n);case Hn.EVENT:case Hn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&mce.indexOf(n[0])===-1);case Hn.ACK:case Hn.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class bce{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=gce(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const _ce=Object.freeze(Object.defineProperty({__proto__:null,Decoder:_I,Encoder:yce,get PacketType(){return Hn},protocol:vce},Symbol.toStringTag,{value:"Module"}));function Ol(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const xce=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class d7 extends Ii{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=[Ol(t,"open",this.onopen.bind(this)),Ol(t,"packet",this.onpacket.bind(this)),Ol(t,"error",this.onerror.bind(this)),Ol(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,o,s;if(xce.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:Hn.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=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.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 o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===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"))},o),u=(...d)=>{this.io.clearTimeoutFn(s),n.apply(this,d)};u.withError=!0,this.acks[t]=u}emitWithAck(t,...n){return new Promise((r,o)=>{const s=(u,d)=>u?o(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((o,...s)=>r!==this._queue[0]?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(o)):(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:Hn.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 Hn.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 Hn.EVENT:case Hn.BINARY_EVENT:this.onevent(t);break;case Hn.ACK:case Hn.BINARY_ACK:this.onack(t);break;case Hn.DISCONNECT:this.ondisconnect();break;case Hn.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(...o){r||(r=!0,n.packet({type:Hn.ACK,id:t,data:o}))}}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:Hn.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 Qm(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}Qm.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},Qm.prototype.reset=function(){this.attempts=0},Qm.prototype.setMin=function(e){this.ms=e},Qm.prototype.setMax=function(e){this.max=e},Qm.prototype.setJitter=function(e){this.jitter=e};class xI extends Ii{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,mk(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 Qm({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const o=n.parser||_ce;this.encoder=new o.Encoder,this.decoder=new o.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 lce(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=Ol(n,"open",function(){r.onopen(),t&&t()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),t?t(d):this.maybeReconnectOnOpen()},u=Ol(n,"error",s);if(this._timeout!==!1){const d=this._timeout,h=this.setTimeoutFn(()=>{o(),s(new Error("timeout")),n.close()},d);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(o),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(Ol(t,"ping",this.onping.bind(this)),Ol(t,"data",this.ondata.bind(this)),Ol(t,"error",this.onerror.bind(this)),Ol(t,"close",this.onclose.bind(this)),Ol(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){gk(()=>{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 d7(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(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):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 Xb={};function bk(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=uce(e,t.path||"/socket.io"),r=n.source,o=n.id,s=n.path,u=Xb[o]&&s in Xb[o].nsps,d=t.forceNew||t["force new connection"]||t.multiplex===!1||u;let h;return d?h=new xI(r,t):(Xb[o]||(Xb[o]=new xI(r,t)),h=Xb[o]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}Object.assign(bk,{Manager:xI,Socket:d7,io:bk,connect:bk});const Wh=class Wh{constructor(){oo(this,"socket",null);oo(this,"isConnected",!1);oo(this,"eventListeners",new Map)}static getInstance(){return Wh.instance||(Wh.instance=new Wh),Wh.instance}connect(t){return this.socket?this.socket:(this.socket=bk(`${pne}${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,o;this.eventListeners.has(t)||this.eventListeners.set(t,[]),(r=this.eventListeners.get(t))==null||r.push(n),(o=this.socket)==null||o.on(t,n)}off(t,n){var o;const r=this.eventListeners.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1),(o=this.socket)==null||o.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(o=>o(...n))}};oo(Wh,"instance");let SI=Wh;const Su=SI.getInstance();var Sce={MESSAGE:"MESSAGE"},wce={USER:"USER"};function _k(e,t){window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:t}))}const h7=(e,t)=>{const n=JSON.stringify(t);window.localStorage.setItem(e,n),_k(e,n)},Cce=e=>{window.localStorage.removeItem(e),_k(e,null)},p7=e=>window.localStorage.getItem(e),Ece=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),kce=()=>{throw Error("useLocalStorage is a client-only hook")};function Ace(e,t){const n=()=>p7(e),r=Ge.useSyncExternalStore(Ece,n,kce),o=Ge.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Cce(e):h7(e,u)}catch(u){console.warn(u)}},[e,r]);return Ge.useEffect(()=>{p7(e)===null&&h7(e,t)},[e,t]),[r?JSON.parse(r):t,o]}const g7=(e,t)=>{const n=JSON.stringify(t);window.sessionStorage.setItem(e,n),_k(e,n)},Tce=e=>{window.sessionStorage.removeItem(e),_k(e,null)},m7=e=>window.sessionStorage.getItem(e),Mce=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Oce=()=>{throw Error("useSessionStorage is a client-only hook")};function Rce(e,t){const n=()=>m7(e),r=Ge.useSyncExternalStore(Mce,n,Oce),o=Ge.useCallback(s=>{try{const u=typeof s=="function"?s(JSON.parse(r)):s;u==null?Tce(e):g7(e,u)}catch(u){console.warn(u)}},[e,r]);return Ge.useEffect(()=>{m7(e)===null&&g7(e,t)},[e,t]),[r?JSON.parse(r):t,o]}const Ice=({children:e,nameSpace:t})=>{const[n,r]=W.useState(""),[o,s]=W.useState([]),[u,d]=W.useState(!1),[h,m]=W.useState(!1),[y,v]=W.useState([]),[x,w]=W.useState(!1),[E,M]=W.useState(!1),[A,k]=W.useState([]),[R,D]=Ace(Dn(In.USER_INFO),null),[B,L]=Rce(Dn(In.IS_FORM_CLOSED_BY_USER),!1),[H,K]=W.useState(null),ee=jf("web-socket"),[J,Q]=W.useState([]),[ae,fe]=W.useState(null),[Se,se]=W.useState(!1),[pe,Z]=W.useState(sessionStorage.getItem(Dn(In.LAST_SHOWN_MESSAGE_ID,{botId:t}))),ie=bne(),ye=tr(),[He,U]=W.useState(null),[Be,Oe]=W.useState(null);W.useEffect(()=>{if(ee){const gt=Su.connect("/api/v1/chat");fe(gt);const Fe=()=>{console.debug("connected to websocket"),se(!0)},lt=()=>{console.debug("disconnected from websocket"),se(!1)},ct=pt=>{console.debug("response from websocket",pt);const dt=pt.conversationId??crypto.randomUUID().toString();Z(dt),pt.Variants_quantity&&k(X=>[...X,...pt.Variants_quantity]);const G=[...o,{text:pt.response,products:pt.products,conversationId:dt,rating:"neutral",leading_queries:pt.leading_queries,collections:pt.collections,variants:pt.variants,shop:pt.shop,Variants_quantity:pt.Variants_quantity,monthlyChatLimitReached:pt.monthlyChatLimitReached,isBot:!0}];s(G),F(G),v(X=>[...X,[o[o.length-1].text,pt.response]]),m(!1)},zt=pt=>{if(pt.event==="error"){const dt={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},G=[...o,dt];s(G),F(G),m(!1)}};return Su.on("connect",Fe),Su.on("disconnect",lt),Su.on("response",ct),Su.on("system",zt),()=>{Su.off("connect",Fe),Su.off("disconnect",lt),Su.off("response",ct),Su.off("system",zt)}}},[ee,o]);const F=gt=>{sessionStorage.setItem(Dn(In.CHAT_HISTORY,{botId:window.DebalesChat.projectId}),JSON.stringify(gt))},We=()=>{const gt=sessionStorage.getItem(Dn(In.CHAT_HISTORY,{botId:window.DebalesChat.projectId}));return gt?JSON.parse(gt):[]},at=W.useCallback(async()=>{if(t)try{d(!0);const gt=await fetch(`${ci}/api/wordpress/UiData?value=${t}`),Fe=await gt.json();if(!gt.ok)throw new Error("failed to fetch data"+Fe.error);const lt=document.getElementById("debales-ai-assistant");lt&&(lt.style.zIndex=String(Fe.zIndex??2031483602)),Oe(Fe),Fe!=null&&Fe.shopifyShopDomain&&Bne(Fe.shopifyShopDomain).then(zt=>{U(zt)}),Q(Fe.suggestedQuestions);const ct=We();if(ct.length>0)s(ct);else{const zt={text:Fe.initialMessage||"Hi, I am an AI Assistant. How can I help you?",isBot:!0};s([zt])}}catch(gt){console.error(gt)}finally{d(!1)}},[t]);W.useEffect(()=>{at()},[at]);const Qe=W.useMemo(()=>{var gt;return!!(!B&&((gt=Be==null?void 0:Be.pluginConfig)!=null&&gt.collectedUserInfo)&&(Be.pluginConfig.collectedUserInfo.name||Be.pluginConfig.collectedUserInfo.email||Be.pluginConfig.collectedUserInfo.phone)&&!R)},[Be,R,B]),Bt=W.useCallback(async(gt,Fe,lt,ct,zt,pt)=>{if(!gt||gt.trim()===""||h&&!lt)return;let dt=[...o];ct?ct&&o.length<=2?(w(!0),dt=[]):w(!1):(dt.push({text:gt,isBot:!1}),w(!1));const G=tr();m(!0);try{s(dt),F(dt);const X=await fetch(`${ci}/api/wordpress/ChatWithBot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:G,userMessage:gt,nameSpace:t,chat_history:y,leading_queries:zt,answer:Fe,products:lt,userInfo:JSON.stringify(R),anonymousUserId:ie,distinctId:bu.getDistinctId(),timestamp:new Date().toISOString(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,followUpQuestion:pt})});if(!X.ok)throw new Error("Network response was not ok");const ce=await X.json(),Ie=ce.conversationId??crypto.randomUUID().toString();Z(Ie),ce.Variants_quantity&&k(Pe=>[...Pe,...ce.Variants_quantity]);const $e=[...dt,{text:ce.response,products:ce.products,conversationId:Ie,rating:"neutral",leading_queries:ce.leading_queries,collections:ce.collections,variants:ce.variants,shop:ce.shop,Variants_quantity:ce.Variants_quantity,monthlyChatLimitReached:ce.monthlyChatLimitReached,isBot:!0}];s($e),F($e),v(Pe=>[...Pe,[gt,ce.response]])}catch(X){console.error(X);const ce={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},Ie=[...dt,ce];ct||(s(Ie),F(Ie))}finally{m(!1)}},[o,h,y,t,ie,R]),St=W.useCallback(gt=>{Be&&Oe(Fe=>Fe?{...Fe,mobileDisplayMode:gt}:null)},[Be]),$t=W.useCallback(async(gt,Fe,lt,ct,zt,pt)=>{if(!gt||gt.trim()===""||h&&!lt)return;let dt=[...o];if(ct?ct&&o.length<=2?(w(!0),dt=[]):w(!1):(dt.push({text:gt,isBot:!1}),w(!1)),m(!0),s(dt),F(dt),ae&&Se){const G={type:Sce.MESSAGE,role:wce.USER,query:gt,nameSpace:t,leadingQueries:zt,answer:Fe,products:lt,userInfo:R,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),sessionId:ye,anonymousUserId:ie,distinctId:bu.getDistinctId(),followUpQuestion:pt};Su.emit("chat",G)}else Bt(gt,Fe,lt,ct,zt,pt)},[o,h,t,ie,ae,Se,ye,Bt,R]),qt={sessionId:ye,messages:o,isLoading:u,isMessageLoading:h,isKlaviyoMessage:x,showUserInfoModel:E,pendingBulkItems:A,lastedBotmessageId:pe,uiData:Be,storeMetaData:He,suggestedQuestions:J,isUserInfoNeeded:Qe,input:n,pendingQuestion:H,userInfo:R,isFormClosedByUser:B,onSendMessage:ee?$t:Bt,setMessages:s,setIsLoading:d,setIsMessageLoading:m,setIsKlaviyoMessage:w,setShowUserInfoModel:M,setPendingBulkItems:k,setLastedBotmessageId:Z,fetchUiInfo:at,changeDisplayModel:St,saveConversation:F,loadConversation:We,setSuggestedQuestions:Q,setUserInfo:D,setInput:r,setPendingQuestion:K,setIsFormClosedByUser:L};return O.jsx(R9.Provider,{value:qt,children:e})};function Dce(e){const t=sI.getInstance().getAdapter();return O.jsx(Ice,{nameSpace:e.botId,children:O.jsx(EP,{apiKey:gne,options:{capture_pageview:e.botId!=="burgerbaeclothing",capture_pageleave:e.botId!=="burgerbaeclothing",api_host:ci+"/ingest",ui_host:"https://us.posthog.com",loaded:n=>{n.register({platform:ud.detect(),project:e.botId,sessionId:tr()}),n.group("project",e.botId,{platform:ud.detect()});const r=bo();r&&r.email&&!n._isIdentified()&&n.identify(r.email,{name:r.name,phone:r.phone,email:r.email,project:e.botId})},debug:!1},children:O.jsx(Tue,{adapter:t,children:e.children})})})}function $ce(e){return O.jsx(Cue,{children:O.jsx(Dce,{botId:e.botId,children:O.jsx(vue,{...e})})})}return $ce});