@debales/ai 1.1.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/ai-browser.js +27 -27
- package/dist/module/ai.js +8 -8
- package/dist/module/ai.umd.js +6 -6
- package/package.json +3 -3
package/dist/module/ai.umd.js
CHANGED
|
@@ -114,7 +114,7 @@ or you can use record.mirror to access the mirror instance during recording.`,_N
|
|
|
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 Dt.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 l8=["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<l8.length;t++)if(e.indexOf(l8[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{tr.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},z.cookie={get:function(e){for(var t=e+"=",n=ur.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=f8(ur.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"),ur.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=f8(ur.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 ur.cookie=x,x},remove:function(e,t,n){z.cookie.set(e,"",-1,t,!1,!1,n)}};var u8=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,vb=function(e,t){return zO!==null&&!t?zO:zO=u8(e||Dt.localStorage)},UO=null,bte=function(e,t){return UO!==null&&!t?UO:UO=u8(e||Dt.sessionStorage)};function c8(e,t,n){var r=function(o){tr.error(t+" error: "+o)};return{is_supported:function(o){var s=n(e,o);return s||tr.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=c8(Dt.localStorage,"localStorage",vb),z.sessionStorage=c8(Dt.sessionStorage,"sessionStorage",bte),z.register_event=function(){var e=function(r,o,s,u,d){if(!r){tr.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(Dt.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(!ur.getElementsByTagName)return[];var s=o.split(" "),u,d,h,m,y,v,x,w,E,M,A=[ur];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],I=ur.getElementById(k);if(!I||h&&I.nodeName.toLowerCase()!=h)return[];A=[I];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 L=u.match(_te);if(L){h=L[1];var B=L[2],H=L[3],Q=L[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 J;switch(H){case"=":J=function(W){return W.getAttribute(B)==Q};break;case"~":J=function(W){return W.getAttribute(B).match(new RegExp("\\b"+Q+"\\b"))};break;case"|":J=function(W){return W.getAttribute(B).match(new RegExp("^"+Q+"-?"))};break;case"^":J=function(W){return W.getAttribute(B).indexOf(Q)===0};break;case"$":J=function(W){return W.getAttribute(B).lastIndexOf(Q)==W.getAttribute(B).length-Q.length};break;case"*":J=function(W){return W.getAttribute(B).indexOf(Q)>-1};break;default:J=function(W){return W.getAttribute(B)}}for(A=[],M=0,x=0;x<m.length;x++)J(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(ur.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(ur.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 Dt.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:ur.referrer,$referring_domain:z.info.referringDomain(ur.referrer),$device:z.info.device(bc)}),{$current_url:z.info.currentUrl(),$browser_version:z.info.browserVersion(bc,Jf.vendor,Lw),$screen_height:i8.height,$screen_width:i8.width,mp_lib:"web",$lib_version:kl.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:ur.title,current_domain:Dt.location.hostname,current_url_path:Dt.location.pathname,current_url_protocol:Dt.location.protocol,current_url_search:Dt.location.search})}};var wte=function(e,t){var n=null,r=[];return function(o){var s=this;return r.push(o),n||(n=new or(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,f8=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=Dt.navigator.onLine;return z.isUndefined(e)||e},ed=function(){},pm=null,Nw=null;typeof JSON<"u"&&(pm=JSON.stringify,Nw=JSON.parse),pm=pm||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",d8="mixpanelRecordingEvents",HO="mixpanelRecordingRegistry",Tte=1,Mte=[d8,HO],hu=function(e){this.dbPromise=null,this.storeName=e};hu.prototype._openDb=function(){return new or(function(e,t){var n=Dt.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)})}})},hu.prototype.init=function(){return Dt.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof Dt.IDBDatabase?or.resolve():or.reject(e)})):or.reject("indexedDB is not supported in this browser")},hu.prototype.makeTransaction=function(e,t){var n=this.storeName,r=function(o){return new or(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)):or.reject(o)}).bind(this))},hu.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(n){n.put(t,e)})},hu.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},hu.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},hu.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){g8(!0,e,t)}function Ite(e,t){g8(!1,e,t)}function Dte(e,t){return p8(e,t)==="1"}function h8(e,t){if(Lte(t))return tr.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=p8(e,t)==="0";return n&&tr.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 gm(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 p8(e,t){return qO(t).get(PO(e,t))}function Lte(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||Dt,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 g8(e,t,n){if(!z.isString(t)||!t.length){tr.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=h8(r,{ignoreDnt:o,persistenceType:s,persistencePrefix:u,window:d}))}catch(m){tr.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=hm("lock"),m8=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||Dt.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||or};m8.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(L){o(L)}},h*(Math.random()+.1))},M=function(D,L){D()?L():E(function(){M(D,L)})},A=function(){var D=y.getItem(x);return D&&D!==s?!1:(y.setItem(x,s),y.getItem(x)===s?!0:(vb(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){I();return}E(function(){if(y.getItem(x)!==s){k();return}M(function(){return!y.getItem(w)},I)})})},I=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(L){D(),r(L)}).catch(function(L){D(),o(L)})};try{if(vb(y,!0))k();else throw new Error("localStorage support check failed")}catch(D){o(D)}},this))};var yb=function(e){this.storage=e||Dt.localStorage};yb.prototype.init=function(){return or.resolve()},yb.prototype.setItem=function(e,t){return new or(z.bind(function(n,r){try{this.storage.setItem(e,pm(t))}catch(o){r(o)}n()},this))},yb.prototype.getItem=function(e){return new or(z.bind(function(t,n){var r;try{r=Nw(this.storage.getItem(e))}catch(o){n(o)}t(r)},this))},yb.prototype.removeItem=function(e){return new or(z.bind(function(t,n){try{this.storage.removeItem(e)}catch(r){n(r)}t()},this))};var v8=hm("batch"),pu=function(e,t){t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new yb,this.lock=new m8(e,{storage:t.sharedLockStorage||Dt.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||z.bind(v8.error,v8),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)};pu.prototype.ensureInit=function(){return this.initialized?or.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))},pu.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),or.resolve(!0))},pu.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))},pu.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)):or.resolve(t)};var y8=function(e,t){var n=[];return z.each(e,function(r){r.id&&!t[r.id]&&n.push(r)}),n};pu.prototype.removeItemsByID=function(e){var t={};if(z.each(e,function(r){t[r]=!0}),this.memQueue=y8(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=y8(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),vb(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 or.resolve(!0)};var b8=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};pu.prototype.updatePayloads=function(e){return this.memQueue=b8(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=b8(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)):or.resolve(!0)},pu.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))},pu.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))},pu.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(z.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):or.resolve()};var Bte=10*60*1e3,bb=hm("batch"),Ts=function(e,t){this.errorReporter=t.errorReporter,this.queue=new pu(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};Ts.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},Ts.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},Ts.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},Ts.prototype.clear=function(){return this.queue.clear()},Ts.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},Ts.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},Ts.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(z.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},Ts.prototype.sendRequestPromise=function(e,t){return new or(z.bind(function(n){this.sendRequest(e,t,n)},this))},Ts.prototype.flush=function(e){if(this.requestInProgress)return bb.log("Flush: Request already in progress"),or.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:kl.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(),or.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(),or.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),or.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),or.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(),or.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"),bb.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))},Ts.prototype.reportError=function(e,t){if(bb.error.apply(bb.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(n){bb.error(n)}};var GO=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},zte=250,mm=hm("recorder"),_8=Dt.CompressionStream,Ute={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},jte=new Set([an.MouseMove,an.MouseInteraction,an.Scroll,an.ViewportResize,an.Input,an.TouchMove,an.MediaInteraction,an.Drag,an.Selection]);function Hte(e){return e.type===qn.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=gb,this.recordMinMs=0;var t=vb(e.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new hu(d8),this.batcher=new Ts(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){mm.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>gb&&(this.recordMaxMs=gb,mm.critical("record_max_ms cannot be greater than "+gb+"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,mm.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);Dt.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===qn.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:kl.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),_8){var E=new Blob([v],{type:"application/json"}).stream(),M=E.pipeThrough(new _8("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){mm.error.apply(mm.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(n){mm.error(n)}};var vm=function(e){this.idb=new hu(HO),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};vm.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},vm.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."),or.resolve())},vm.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))},vm.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))},vm.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 or.all(t)}).bind(this)).catch(this.handleError.bind(this))};var _b=hm("recorder"),_c=function(e,t,n){this.mixpanelInstance=e,this.rrwebRecord=t||Qf,this.sharedLockStorage=n,this.recordingRegistry=new vm({mixpanelInstance:this.mixpanelInstance,errorReporter:_b.error,sharedLockStorage:n}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null};_c.prototype.startRecording=function(e){if(e=e||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){_b.log("Recording already in progress, skipping startRecording.");return}var t=(function(){_b.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),n=(function(){_b.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):or.resolve()},_c.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),or.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(t){return t?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):(_b.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()}}),Dt.__mp_recorder=_c;var Bw="change",xb="click",x8="hashchange",ym="mp_locationchange",S8="popstate",w8="scrollend",VO="submit",qte=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],C8=["mp-include"],YO=["mp-no-track"],E8=YO.concat(["mp-sensitive"]),Pte=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],Ma=hm("autocapture");function ZO(e){for(var t={},n=k8(e).split(" "),r=0;r<n.length;r++){var o=n[r];o&&(t[o]=!0)}return t}function k8(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&&!M8(e));return e}function A8(e,t,n,r,o,s){var u={$classes:k8(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(L){m[L]=!0});var y=null,v=typeof e.target>"u"?e.srcElement:e.target;if(O8(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&&!gu(w,"body");)x.push(w.parentNode),w=w.parentNode;var E=[],M,A=!1;if(z.each(x,function(L){var B=XO(L,e,n,r);!m.href&&L.tagName.toLowerCase()==="a"&&(M=L.getAttribute("href"),M=B&&zw(M)&&M),KO(L,e,s,u)&&(A=!0),E.push(A8(L,e,m,h,n,r))},this),!A){var k=ur.documentElement;if(y={$event_type:e.type,$host:Dt.location.host,$pathname:Dt.location.pathname,$elements:E,$el_attr__href:M,$viewportHeight:Math.max(k.clientHeight,Dt.innerHeight||0),$viewportWidth:Math.max(k.clientWidth,Dt.innerWidth||0)},z.each(h,function(L){if(!m[L]&&v.hasAttribute(L)){var B=v.getAttribute(L);zw(B)&&(y["$el_attr__"+L]=B)}}),d&&(I=T8(v,e,n,r),I&&I.length&&(y.$el_text=I)),e.type===xb&&(z.each(qte,function(L){L in e&&(y["$"+L]=e[L])}),v=Vte(e)),d){var I=T8(v,e,n,r);I&&I.length&&(y.$el_text=I)}if(v){if(!QO(v,e,n,r)||KO(v,e,s,u))return null;var D=A8(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 T8(e,t,n,r){var o="";return XO(e,t,n,r)&&e.childNodes&&e.childNodes.length&&z.each(e.childNodes,function(s){O8(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(gu(o,"a")||gu(o,"button")||gu(o,"input")||gu(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 M8(e){return e&&e.nodeType===1}function gu(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function O8(e){return e&&e.nodeType===3}function Yte(){try{var e=ur.createElement("div");return!!e.matches}catch{return!1}}function Zte(e,t){if(!e||gu(e,"html")||!M8(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===xb;case"select":case"textarea":return t.type===Bw;default:return t.type===xb}}function XO(e,t,n,r){var o;if(!QO(e,t,n,r))return!1;for(var s=e;s.parentNode&&!gu(s,"body");s=s.parentNode){var u=ZO(s);for(o=0;o<E8.length;o++)if(u[E8[o]])return!1}var d=ZO(e);for(o=0;o<C8.length;o++)if(d[C8[o]])return!0;if(gu(e,"input")||gu(e,"select")||gu(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 R8="autocapture",Qte="track_pageview",I8="full-url",Kte="url-with-path-and-query-string",Xte="url-with-path",Wte="allow_element_callback",D8="allow_selectors",$8="allow_url_regexes",L8="block_attrs",N8="block_element_callback",B8="block_selectors",z8="block_url_regexes",U8="capture_extra_attrs",j8="capture_text_content",H8="scroll_capture_all",q8="scroll_depth_percent_checkpoints",WO="click",JO="input",P8="pageview",eR="scroll",tR="submit",vo={};vo[D8]=[],vo[$8]=[],vo[L8]=[],vo[N8]=null,vo[B8]=[],vo[z8]=[],vo[U8]=[],vo[j8]=!1,vo[H8]=!1,vo[q8]=[25,50,75,100],vo[WO]=!0,vo[JO]=!0,vo[P8]=I8,vo[eR]=!0,vo[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(R8);return e?z.isObject(e)?z.extend({},vo,e):vo:{}},ns.prototype.getConfig=function(e){return this.getFullConfig()[e]},ns.prototype.currentUrlBlocked=function(){var e,t=z.info.currentUrl(),n=this.getConfig($8)||[];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(z8)||[];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(R8)?this.getConfig(P8):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(D8),blockAttrs:this.getConfig(L8),blockElementCallback:this.getConfig(N8),blockSelectors:this.getConfig(B8),captureExtraAttrs:this.getConfig(U8),captureTextContent:this.getConfig(j8)});n&&(z.extend(n,Uw),this.mp.track(t,n))}},ns.prototype.initClickTracking=function(){Dt.removeEventListener(xb,this.listenerClick),this.getConfig(WO)&&(Ma.log("Initializing click tracking"),this.listenerClick=Dt.addEventListener(xb,(function(e){this.getConfig(WO)&&this.trackDomEvent(e,Jte)}).bind(this)))},ns.prototype.initInputTracking=function(){Dt.removeEventListener(Bw,this.listenerChange),this.getConfig(JO)&&(Ma.log("Initializing input tracking"),this.listenerChange=Dt.addEventListener(Bw,(function(e){this.getConfig(JO)&&this.trackDomEvent(e,ene)}).bind(this)))},ns.prototype.initPageviewTracking=function(){if(Dt.removeEventListener(S8,this.listenerPopstate),Dt.removeEventListener(x8,this.listenerHashchange),Dt.removeEventListener(ym,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=Dt.addEventListener(S8,function(){Dt.dispatchEvent(new Event(ym))}),this.listenerHashchange=Dt.addEventListener(x8,function(){Dt.dispatchEvent(new Event(ym))});var n=Dt.history.pushState;typeof n=="function"&&(Dt.history.pushState=function(o,s,u){n.call(Dt.history,o,s,u),Dt.dispatchEvent(new Event(ym))});var r=Dt.history.replaceState;typeof r=="function"&&(Dt.history.replaceState=function(o,s,u){r.call(Dt.history,o,s,u),Dt.dispatchEvent(new Event(ym))}),this.listenerLocationchange=Dt.addEventListener(ym,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===I8?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(){Dt.removeEventListener(w8,this.listenerScroll),this.getConfig(eR)&&(Ma.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=Dt.addEventListener(w8,BO((function(){if(this.getConfig(eR)&&!this.currentUrlBlocked()){var e=this.getConfig(H8),t=(this.getConfig(q8)||[]).slice().sort(function(h,m){return h-m}),n=Dt.scrollY,r=z.extend({$scroll_top:n},Uw);try{var o=ur.body.scrollHeight,s=Math.round(n/(o-Dt.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(){Dt.removeEventListener(VO,this.listenerSubmit),this.getConfig(tR)&&(Ma.log("Initializing submit tracking"),this.listenerSubmit=Dt.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){tr.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 bm=function(){this.override_event="click"};z.inherit(bm,xc),bm.prototype.create_properties=function(e,t){var n=bm.superclass.create_properties.apply(this,arguments);return t.href&&(n.url=t.href),n},bm.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()},bm.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",_m="$set_once",Al="$unset",qh="$add",mu="$append",Ph="$union",Sc="$remove",rne="$delete",F8={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[Al]=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[_m]=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[mu]=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}},Ur=function(){};z.extend(Ur.prototype,F8),Ur.prototype._init=function(e,t,n){this._mixpanel=e,this._group_key=t,this._group_id=n},Ur.prototype.set=gm(function(e,t,n){var r=this.set_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),Ur.prototype.set_once=gm(function(e,t,n){var r=this.set_once_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),Ur.prototype.unset=gm(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),Ur.prototype.union=gm(function(e,t,n){z.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),Ur.prototype.delete=gm(function(e){var t=this.delete_action();return this._send_request(t,e)}),Ur.prototype.remove=gm(function(e,t,n){var r=this.remove_action(e,t);return this._send_request(r,n)}),Ur.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)},Ur.prototype._is_reserved_property=function(e){return e==="$group_key"||e==="$group_id"},Ur.prototype._get_config=function(e){return this._mixpanel.get_config(e)},Ur.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},Ur.prototype.remove=Ur.prototype.remove,Ur.prototype.set=Ur.prototype.set,Ur.prototype.set_once=Ur.prototype.set_once,Ur.prototype.union=Ur.prototype.union,Ur.prototype.unset=Ur.prototype.unset,Ur.prototype.toString=Ur.prototype.toString;var dn=function(){};z.extend(dn.prototype,F8),dn.prototype._init=function(e){this._mixpanel=e},dn.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)}),dn.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)}),dn.prototype.unset=nd(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),dn.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))){tr.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)}),dn.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)}),dn.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)}),dn.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)}),dn.prototype.track_charge=nd(function(e,t,n){if(!z.isNumber(e)&&(e=parseFloat(e),isNaN(e))){tr.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",z.extend({$amount:e},t),n)}),dn.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},dn.prototype.delete_user=function(){if(!this._identify_called()){tr.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)},dn.prototype.toString=function(){return this._mixpanel.toString()+".people"},dn.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))},dn.prototype._get_config=function(e){return this._mixpanel.get_config(e)},dn.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},dn.prototype._enqueue=function(e){rd in e?this._mixpanel.persistence._add_to_people_queue(rd,e):_m in e?this._mixpanel.persistence._add_to_people_queue(_m,e):Al in e?this._mixpanel.persistence._add_to_people_queue(Al,e):qh in e?this._mixpanel.persistence._add_to_people_queue(qh,e):mu in e?this._mixpanel.persistence._add_to_people_queue(mu,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):tr.error("Invalid call to _enqueue():",e)},dn.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)}))},dn.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(_m,this.set_once,r),this._flush_one_queue(Al,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(mu);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(mu,m),z.isUndefined(n)||n(A,k)},v=h.length-1;v>=0;v--)h=this._mixpanel.persistence.load_queue(mu),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)},dn.prototype._is_reserved_property=function(e){return e==="$distinct_id"||e==="$token"||e==="$device_id"||e==="$user_id"||e==="$had_persisted_distinct_id"},dn.prototype.set=dn.prototype.set,dn.prototype.set_once=dn.prototype.set_once,dn.prototype.unset=dn.prototype.unset,dn.prototype.increment=dn.prototype.increment,dn.prototype.append=dn.prototype.append,dn.prototype.remove=dn.prototype.remove,dn.prototype.union=dn.prototype.union,dn.prototype.track_charge=dn.prototype.track_charge,dn.prototype.clear_charges=dn.prototype.clear_charges,dn.prototype.delete_user=dn.prototype.delete_user,dn.prototype.toString=dn.prototype.toString;var nR="__mps",rR="__mpso",iR="__mpus",oR="__mpa",aR="__mpap",sR="__mpr",lR="__mpu",G8="$people_distinct_id",Hw="__alias",Sb="__timers",ine=[nR,rR,iR,oR,aR,sR,lR,G8,Hw,Sb],Mn=function(e){this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="mp_"+e.persistence_name:this.name="mp_"+e.token+"_mixpanel";var t=e.persistence;t!=="cookie"&&t!=="localStorage"&&(tr.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()};Mn.prototype.properties=function(){var e={};return this.load(),z.each(this.props,function(t,n){z.include(ine,n)||(e[n]=t)}),e},Mn.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=z.extend({},e))}},Mn.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))},Mn.prototype.save=function(){this.disabled||this.storage.set(this.name,pm(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},Mn.prototype.load_prop=function(e){return this.load(),this.props[e]},Mn.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},Mn.prototype.clear=function(){this.remove(),this.props={}},Mn.prototype.register_once=function(e,t,n){return 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},Mn.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},Mn.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},Mn.prototype.update_search_keyword=function(e){this.register(z.info.searchInfo(e))},Mn.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:z.info.referringDomain(e)||"$direct"},"")},Mn.prototype.get_referrer_info=function(){return z.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},Mn.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cookie_domain(e.cookie_domain),this.set_cross_site(e.cross_site_cookie),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},Mn.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},Mn.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},Mn.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},Mn.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},Mn.prototype.get_cross_subdomain=function(){return this.cross_subdomain},Mn.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},Mn.prototype._add_to_people_queue=function(e,t){var n=this._get_queue_key(e),r=t[e],o=this._get_or_create_queue(rd),s=this._get_or_create_queue(_m),u=this._get_or_create_queue(Al),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(mu,[]);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(Al,r)):n===rR?(z.each(r,function(v,x){x in s||(s[x]=v)}),this._pop_from_people_queue(Al,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(Al,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(Al,r)):n===sR?(m.push(r),this._pop_from_people_queue(mu,r)):n===aR&&(y.push(r),this._pop_from_people_queue(Al,r)),tr.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),tr.log(t),this.save()},Mn.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===mu||e===Sc?z.each(n,function(s){s[o]===r&&delete s[o]}):delete n[o]},this)},Mn.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},Mn.prototype._get_queue_key=function(e){if(e===rd)return nR;if(e===_m)return rR;if(e===Al)return iR;if(e===qh)return oR;if(e===mu)return aR;if(e===Sc)return sR;if(e===Ph)return lR;tr.error("Invalid queue:",e)},Mn.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)},Mn.prototype.set_event_timer=function(e,t){var n=this.load_prop(Sb)||{};n[e]=t,this.props[Sb]=n,this.save()},Mn.prototype.remove_event_timer=function(e){var t=this.load_prop(Sb)||{},n=t[e];return z.isUndefined(n)||(delete this.props[Sb][e],this.save()),n};var uR,V8=function(e,t){throw new Error(e+" not available in this build.")},Uo,Y8=0,one=1,ane=function(e){return e},Ms="mixpanel",Z8="base64",sne="json",cR="$device:",xm=Dt.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,Q8=!xm&&bc.indexOf("MSIE")===-1&&bc.indexOf("Mozilla")===-1,qw=null;Jf.sendBeacon&&(qw=function(){return Jf.sendBeacon.apply(Jf,arguments)});var K8={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},X8={api_host:"https://api-js.mixpanel.com",api_routes:K8,api_method:"POST",api_transport:"XHR",api_payload_format:Z8,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:gb,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},W8=!1,ke=function(){},fR=function(e,t,n){var r,o=n===Ms?Uo:Uo[n];if(o&&uR===Y8)r=o;else{if(o&&!z.isArray(o)){tr.error("You have already initialized "+n);return}r=new ke}if(r._cached_groups={},r._init(e,t,n),r.people=new dn,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 kl.DEBUG=kl.DEBUG||r.get_config("debug"),!z.isUndefined(o)&&z.isArray(o)&&(r._execute_array.call(r.people,o.people),r._execute_array(o)),r};ke.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===Ms){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},ke.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||X8.api_host;o.match(/\.mixpanel\.com/)&&(r.api_payload_format=sne)}if(this.set_config(z.extend({},X8,r,t,{name:n,token:e,callback_fn:(n===Ms?n:Ms+"."+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)||!xm)this._batch_requests=!1,tr.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),z.each(this.get_batcher_configs(),function(d){tr.log("Clearing batch queue "+d.queue_key),z.localStorage.remove(d.queue_key)});else if(this.init_batchers(),qw&&Dt.addEventListener){var s=z.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);Dt.addEventListener("pagehide",function(d){d.persisted&&s()}),Dt.addEventListener("visibilitychange",function(){ur.visibilityState==="hidden"&&s()})}}this.persistence=this.cookie=new Mn(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()},ke.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),Dt.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.")},ke.prototype.get_tab_id=function(){return this.tab_id||null},ke.prototype._should_load_recorder=function(){var e=new hu(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))},ke.prototype._check_and_start_session_recording=td(function(e){if(!Dt.MutationObserver){tr.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 Dt.__mp_recorder(this),this._recorder.resumeRecording(r)},this);z.isUndefined(Dt.__mp_recorder)?V8(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)})}),ke.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},ke.prototype.stop_session_recording=function(){this._recorder&&this._recorder.stopRecording()},ke.prototype.pause_session_recording=function(){this._recorder&&this._recorder.pauseRecording()},ke.prototype.resume_session_recording=function(){this._recorder&&this._recorder.resumeRecording()},ke.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},ke.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},ke.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},ke.prototype.__get_recorder=function(){return this._recorder},ke.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))}},ke.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(ur.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(ur.referrer)},ke.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},ke.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(!W8)return this.__dom_loaded_queue.push([e,t]),!1;var n=new e().init(this);return n.track.apply(n,t)},ke.prototype._prepare_callback=function(e,t){if(z.isUndefined(e))return null;if(xm){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}},ke.prototype._send_request=function(e,t,n,r){var o=!0;if(Q8)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||{}),xm||(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),xm||(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=ur.createElement("img");v.src=e,ur.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(xm)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,I){x.setRequestHeader(I,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(L){if(y.report_error(L),n.ignore_json_errors)k=x.responseText;else return}r(k)}else r(Number(x.responseText))}else{var I;if(x.timeout&&!x.status&&new Date().getTime()-E>=x.timeout?I="timeout":I="Bad HTTP status: "+x.status+" "+x.statusText,y.report_error(I),r)if(m){var D=x.responseHeaders||{};r({status:0,httpStatusCode:x.status,error:I,retryAfter:D["Retry-After"]})}else r(0)}},x.send(u)}catch(k){y.report_error(k),o=!1}else{var M=ur.createElement("script");M.type="text/javascript",M.async=!0,M.defer=!0,M.src=e;var A=ur.getElementsByTagName("script")[0];A.parentNode.insertBefore(M,A)}return o},ke.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)},ke.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},ke.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},ke.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=z.bind(function(n){return new Ts(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()},ke.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()}))},ke.prototype.stop_batch_senders=function(){this._batch_requests=!1,z.each(this.request_batchers,function(e){e.stop(),e.clear()})},ke.prototype.push=function(e){this._execute_array([e])},ke.prototype.disable=function(e){typeof e>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},ke.prototype._encode_data_for_request=function(e){var t=pm(e);return this.get_config("api_payload_format")===Z8&&(t=z.base64Encode(t)),{data:t}},ke.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?(tr.log("MIXPANEL REQUEST:"),tr.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},ke.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}),ke.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)}),ke.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)}),ke.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)}),ke.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)}),ke.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},ke.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},ke.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 Ur,r._init(this,e,t),this._cached_groups[n]=r),r},ke.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)}),ke.prototype.track_links=function(){return this._track_dom.call(this,bm,arguments)},ke.prototype.track_forms=function(){return this._track_dom.call(this,jw,arguments)},ke.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)};ke.prototype.register=function(e,t){var n=dR(t);n.persistent?this.persistence.register(e,n.days):z.extend(this.unpersisted_superprops,e)},ke.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))},ke.prototype.unregister=function(e,t){t=dR(t),t.persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},ke.prototype._register_single=function(e,t){var n={};n[e]=t,this.register(n)},ke.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})},ke.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},"")},ke.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},ke.prototype.alias=function(e,t){if(e===this.get_property(G8))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)},ke.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},ke.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),kl.DEBUG=kl.DEBUG||this.get_config("debug"),"autocapture"in e&&this.autocapture&&this.autocapture.init()}},ke.prototype.get_config=function(e){return this.config[e]},ke.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},ke.prototype.get_property=function(e){return this.persistence.load_prop([e])},ke.prototype.toString=function(){var e=this.get_config("name");return e!==Ms&&(e=Ms+"."+e),e},ke.prototype._event_is_disabled=function(e){return z.isBlockedUA(bc)||this._flags.disable_all_events||z.include(this.__disabled_events,e)},ke.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")}))},ke.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()},ke.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})},ke.prototype.opt_in_tracking=function(e){e=z.extend({enable_persistence:!0},e),this._gdpr_call_func(Rte,e),this._gdpr_update_persistence(e)},ke.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)},ke.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(Dte,e)},ke.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(h8,e)},ke.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)},ke.prototype.report_error=function(e,t){tr.error.apply(tr.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(n){tr.error(n)}},ke.prototype.init=ke.prototype.init,ke.prototype.reset=ke.prototype.reset,ke.prototype.disable=ke.prototype.disable,ke.prototype.time_event=ke.prototype.time_event,ke.prototype.track=ke.prototype.track,ke.prototype.track_links=ke.prototype.track_links,ke.prototype.track_forms=ke.prototype.track_forms,ke.prototype.track_pageview=ke.prototype.track_pageview,ke.prototype.register=ke.prototype.register,ke.prototype.register_once=ke.prototype.register_once,ke.prototype.unregister=ke.prototype.unregister,ke.prototype.identify=ke.prototype.identify,ke.prototype.alias=ke.prototype.alias,ke.prototype.name_tag=ke.prototype.name_tag,ke.prototype.set_config=ke.prototype.set_config,ke.prototype.get_config=ke.prototype.get_config,ke.prototype.get_property=ke.prototype.get_property,ke.prototype.get_distinct_id=ke.prototype.get_distinct_id,ke.prototype.toString=ke.prototype.toString,ke.prototype.opt_out_tracking=ke.prototype.opt_out_tracking,ke.prototype.opt_in_tracking=ke.prototype.opt_in_tracking,ke.prototype.has_opted_out_tracking=ke.prototype.has_opted_out_tracking,ke.prototype.has_opted_in_tracking=ke.prototype.has_opted_in_tracking,ke.prototype.clear_opt_in_out_tracking=ke.prototype.clear_opt_in_out_tracking,ke.prototype.get_group=ke.prototype.get_group,ke.prototype.set_group=ke.prototype.set_group,ke.prototype.add_group=ke.prototype.add_group,ke.prototype.remove_group=ke.prototype.remove_group,ke.prototype.track_with_groups=ke.prototype.track_with_groups,ke.prototype.start_batch_senders=ke.prototype.start_batch_senders,ke.prototype.stop_batch_senders=ke.prototype.stop_batch_senders,ke.prototype.start_session_recording=ke.prototype.start_session_recording,ke.prototype.stop_session_recording=ke.prototype.stop_session_recording,ke.prototype.pause_session_recording=ke.prototype.pause_session_recording,ke.prototype.resume_session_recording=ke.prototype.resume_session_recording,ke.prototype.get_session_recording_properties=ke.prototype.get_session_recording_properties,ke.prototype.get_session_replay_url=ke.prototype.get_session_replay_url,ke.prototype.get_tab_id=ke.prototype.get_tab_id,ke.prototype.DEFAULT_API_ROUTES=K8,ke.prototype.__get_recorder=ke.prototype.__get_recorder,Mn.prototype.properties=Mn.prototype.properties,Mn.prototype.update_search_keyword=Mn.prototype.update_search_keyword,Mn.prototype.update_referrer_info=Mn.prototype.update_referrer_info,Mn.prototype.get_cross_subdomain=Mn.prototype.get_cross_subdomain,Mn.prototype.clear=Mn.prototype.clear;var Sm={},une=function(){z.each(Sm,function(e,t){t!==Ms&&(Uo[t]=e)}),Uo._=z},cne=function(){Uo.init=function(e,t,n){if(n)return Uo[n]||(Uo[n]=Sm[n]=fR(e,t,n),Uo[n]._loaded()),Uo[n];var r=Uo;Sm[Ms]?r=Sm[Ms]:e&&(r=fR(e,t,Ms),r._loaded(),Sm[Ms]=r),Uo=r,uR===one&&(Dt[Ms]=Uo),une()}},fne=function(){function e(){e.done||(e.done=!0,W8=!0,Q8=!1,z.each(Sm,function(r){r._dom_loaded()}))}function t(){try{ur.documentElement.doScroll("left")}catch{setTimeout(t,1);return}e()}if(ur.addEventListener)ur.readyState==="complete"?e():ur.addEventListener("DOMContentLoaded",e,!1);else if(ur.attachEvent){ur.attachEvent("onreadystatechange",e);var n=!1;try{n=Dt.frameElement===null}catch{}ur.documentElement.doScroll&&n&&t()}z.register_event(Dt,"load",e,!0)};function dne(e){return V8=e,uR=Y8,Uo=new ke,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",J8={"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 nr(){const e=sessionStorage.getItem("debalesSessionID");if(e)return e;const t=crypto.randomUUID();return sessionStorage.setItem("debalesSessionID",t),t}function mne(){return sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:window.DebalesChat.projectId}))}function yo(){const e=localStorage.getItem($n(Dn.USER_INFO));return e?JSON.parse(e):null}function wc(e){localStorage.setItem($n(Dn.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 wb(){const e=/test|demo|example|debales/i,t=yo()??"";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 e9=new Set,Gw=e=>{const t=J8[e];if(!t)return console.warn("No Mixpanel token found"),null;if(e9.has(e))return id;id.init(t,{debug:!0,track_pageview:!0,persistence:"localStorage"}),console.log("Mixpanel initialized");const n=yo();return n&&n.email&&id.identify(n.email),e9.add(e),id},yne=async(e,t)=>{if(wb())return;const n=window.DebalesChat.projectId??t.projectId;if(!J8[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 bo=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 $n(e,t){return t!=null&&t.botId?`debales_${t.botId}_${e}`:`debales_${e}`}const t9=X.createContext(null),Cb=()=>{const e=X.useContext(t9);if(!e)throw new Error("useCart must be used within a CartProvider");return e};var xne="2.0.0",wm="",n9="?",Vw="function",od="undefined",Cm="object",hR="string",Eb="major",st="model",it="name",rt="type",ht="vendor",at="version",Oa="architecture",Em="console",yn="mobile",Zr="tablet",Ho="smarttv",kb="wearable",pR="xr",gR="embedded",Ab="inapp",r9="user-agent",mR=500,vR="brands",Gh="formFactors",yR="fullVersionList",km="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,i9=ad+"-"+km,Tne=i9+"-version",o9=[vR,yR,yn,st,km,bR,Oa,Gh,Yw],rs="browser",Cc="cpu",vu="device",Ec="engine",Os="os",Am="result",Zw="Amazon",Tb="Apple",a9="ASUS",s9="BlackBerry",Vh="Google",l9="Huawei",u9="Lenovo",Mne="Honor",_R="LG",Qw="Microsoft",c9="Motorola",Mb="Samsung",f9="Sharp",Kw="Sony",xR="Xiaomi",SR="Zebra",Tm="Mobile ",Ob=" Browser",d9="Chrome",sd="Chromecast",One="Edge",Rb="Firefox",Ib="Opera",h9="Facebook",p9="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===Cm&&e.length>0){for(var n in e)if(kc(e[n])==kc(t))return!0;return!1}return Mm(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)},Mm=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=$b(n[r]).split(";v=");t[r]={brand:o[0],version:o[1]}}else t[r]=$b(n[r]);return t}},kc=function(e){return Mm(e)?e.toLowerCase():e},kR=function(e){return Mm(e)?Yh(/[^\d\.]/g,e).split(".")[0]:void 0},Ac=function(e){for(var t in e){var n=e[t];typeof n==Cm&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Yh=function(e,t){return Mm(t)?t.replace(e,wm):t},Db=function(e){return Yh(/\\?\"/g,e)},$b=function(e,t){if(Mm(e))return e=Yh(/^\s\s*/,e),typeof t===od?e:e.substring(0,mR)},g9=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===Cm&&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}},Lb=function(e,t){for(var n in t)if(typeof t[n]===Cm&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(CR(t[n][r],e))return n===n9?void 0:n}else if(CR(t[n],e))return n===n9?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},m9={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"},v9={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},y9={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[at,[it,Tm+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[at,[it,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[it,at],[/opios[\/ ]+([\w\.]+)/i],[at,[it,Ib+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[at,[it,Ib+" GX"]],[/\bopr\/([\w\.]+)/i],[at,[it,Ib]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[at,[it,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[at,[it,"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],[it,at],[/quark(?:pc)?\/([-\w\.]+)/i],[at,[it,"Quark"]],[/\bddg\/([\w\.]+)/i],[at,[it,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[at,[it,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[at,[it,"WeChat"]],[/konqueror\/([\w\.]+)/i],[at,[it,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[at,[it,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[at,[it,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[at,[it,"Smart "+u9+Ob]],[/(avast|avg)\/([\w\.]+)/i],[[it,/(.+)/,"$1 Secure"+Ob],at],[/\bfocus\/([\w\.]+)/i],[at,[it,Rb+" Focus"]],[/\bopt\/([\w\.]+)/i],[at,[it,Ib+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[at,[it,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[at,[it,"Dolphin"]],[/coast\/([\w\.]+)/i],[at,[it,Ib+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[at,[it,"MIUI"+Ob]],[/fxios\/([\w\.-]+)/i],[at,[it,Tm+Rb]],[/\bqihoobrowser\/?([\w\.]*)/i],[at,[it,"360"]],[/\b(qq)\/([\w\.]+)/i],[[it,/(.+)/,"$1Browser"],at],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[it,/(.+)/,"$1"+Ob],at],[/samsungbrowser\/([\w\.]+)/i],[at,[it,Mb+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[at,[it,p9+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[it,p9+" Mobile"],at],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[it,at],[/(lbbrowser|rekonq)/i],[it],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[at,it],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[it,h9],at,[rt,Ab]],[/(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],[it,at,[rt,Ab]],[/\bgsa\/([\w\.]+) .*safari\//i],[at,[it,"GSA"],[rt,Ab]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[at,[it,"TikTok"],[rt,Ab]],[/\[(linkedin)app\]/i],[it,[rt,Ab]],[/(chromium)[\/ ]([-\w\.]+)/i],[it,at],[/headlesschrome(?:\/([\w\.]+)| )/i],[at,[it,d9+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[it,d9+" WebView"],at],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[at,[it,"Android"+Ob]],[/chrome\/([\w\.]+) mobile/i],[at,[it,Tm+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[it,at],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[at,[it,Tm+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[it,Tm+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[at,it],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[it,[at,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[it,at],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[it,Tm+Rb],at],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[it,"Netscape"],at],[/(wolvic|librewolf)\/([\w\.]+)/i],[it,at],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[at,[it,Rb+" 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],[it,[at,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[it,[at,/[^\d\.]+./,wm]]],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/,wm,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,[ht,Mb],[rt,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,[ht,Mb],[rt,yn]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[st,[ht,Tb],[rt,yn]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[st,[ht,Tb],[rt,Zr]],[/(macintosh);/i],[st,[ht,Tb]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[st,[ht,f9],[rt,yn]],[/(?:honor)([-\w ]+)[;\)]/i],[st,[ht,Mne],[rt,yn]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[st,[ht,l9],[rt,Zr]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[st,[ht,l9],[rt,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," "],[ht,xR],[rt,yn]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[st,/_/g," "],[ht,xR],[rt,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,[ht,"OPPO"],[rt,yn]],[/\b(opd2\d{3}a?) bui/i],[st,[ht,"OPPO"],[rt,Zr]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[st,[ht,"Vivo"],[rt,yn]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[st,[ht,"Realme"],[rt,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,[ht,c9],[rt,yn]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[st,[ht,c9],[rt,Zr]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[st,[ht,_R],[rt,Zr]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[st,[ht,_R],[rt,yn]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[st,[ht,u9],[rt,Zr]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[st,/_/g," "],[ht,"Nokia"],[rt,yn]],[/(pixel c)\b/i],[st,[ht,Vh],[rt,Zr]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[st,[ht,Vh],[rt,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,[ht,Kw],[rt,yn]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[st,"Xperia Tablet"],[ht,Kw],[rt,Zr]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[st,[ht,"OnePlus"],[rt,yn]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[st,[ht,Zw],[rt,Zr]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[st,/(.+)/g,"Fire Phone $1"],[ht,Zw],[rt,yn]],[/(playbook);[-\w\),; ]+(rim)/i],[st,ht,[rt,Zr]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[st,[ht,s9],[rt,yn]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[st,[ht,a9],[rt,Zr]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[st,[ht,a9],[rt,yn]],[/(nexus 9)/i],[st,[ht,"HTC"],[rt,Zr]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[ht,[st,/_/g," "],[rt,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,[ht,"TCL"],[rt,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,[ht,"TCL"],[rt,yn]],[/(itel) ((\w+))/i],[[ht,kc],st,[rt,Lb,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[st,[ht,"Acer"],[rt,Zr]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[st,[ht,"Meizu"],[rt,yn]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[st,[ht,"Ulefone"],[rt,yn]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[st,[ht,"Energizer"],[rt,yn]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[st,[ht,"Cat"],[rt,yn]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[st,[ht,"Smartfren"],[rt,yn]],[/droid.+; (a(?:015|06[35]|142p?))/i],[st,[ht,"Nothing"],[rt,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],[ht,st,[rt,yn]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[ht,st,[rt,Zr]],[/(surface duo)/i],[st,[ht,Qw],[rt,Zr]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[st,[ht,"Fairphone"],[rt,yn]],[/(shield[\w ]+) b/i],[st,[ht,"Nvidia"],[rt,Zr]],[/(sprint) (\w+)/i],[ht,st,[rt,yn]],[/(kin\.[onetw]{3})/i],[[st,/\./g," "],[ht,Qw],[rt,yn]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[st,[ht,SR],[rt,Zr]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[st,[ht,SR],[rt,yn]],[/smart-tv.+(samsung)/i],[ht,[rt,Ho]],[/hbbtv.+maple;(\d+)/i],[[st,/^/,"SmartTV"],[ht,Mb],[rt,Ho]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[ht,_R],[rt,Ho]],[/(apple) ?tv/i],[ht,[st,Tb+" TV"],[rt,Ho]],[/crkey.*devicetype\/chromecast/i],[[st,sd+" Third Generation"],[ht,Vh],[rt,Ho]],[/crkey.*devicetype\/([^/]*)/i],[[st,/^/,"Chromecast "],[ht,Vh],[rt,Ho]],[/fuchsia.*crkey/i],[[st,sd+" Nest Hub"],[ht,Vh],[rt,Ho]],[/crkey/i],[[st,sd],[ht,Vh],[rt,Ho]],[/droid.+aft(\w+)( bui|\))/i],[st,[ht,Zw],[rt,Ho]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[st,[ht,f9],[rt,Ho]],[/(bravia[\w ]+)( bui|\))/i],[st,[ht,Kw],[rt,Ho]],[/(mitv-\w{5}) bui/i],[st,[ht,xR],[rt,Ho]],[/Hbbtv.*(technisat) (.*);/i],[ht,st,[rt,Ho]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[ht,$b],[st,$b],[rt,Ho]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[rt,Ho]],[/(ouya)/i,/(nintendo) (\w+)/i],[ht,st,[rt,Em]],[/droid.+; (shield) bui/i],[st,[ht,"Nvidia"],[rt,Em]],[/(playstation \w+)/i],[st,[ht,Kw],[rt,Em]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[st,[ht,Qw],[rt,Em]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[st,[ht,Mb],[rt,kb]],[/((pebble))app/i],[ht,st,[rt,kb]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[st,[ht,Tb],[rt,kb]],[/droid.+; (wt63?0{2,3})\)/i],[st,[ht,SR],[rt,kb]],[/droid.+; (glass) \d/i],[st,[ht,Vh],[rt,pR]],[/(pico) (4|neo3(?: link|pro)?)/i],[ht,st,[rt,pR]],[/; (quest( \d| pro)?)/i],[st,[ht,h9],[rt,pR]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[ht,[rt,gR]],[/(aeobc)\b/i],[st,[ht,Zw],[rt,gR]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[st,[rt,yn]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[st,[rt,Zr]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[rt,Zr]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[rt,yn]],[/(android[-\w\. ]{0,9});.+buil/i],[st,[ht,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[at,[it,One+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[it,at],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[at,[it,"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],[it,at],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[at,it]],os:[[/microsoft (windows) (vista|xp)/i],[it,at],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[it,[at,Lb,m9]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[at,Lb,m9],[it,wR]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[at,/_/g,"."],[it,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[it,"macOS"],[at,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[at,[it,sd+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[at,[it,sd+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[at,[it,sd+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[at,[it,sd+" Linux"]],[/crkey\/([\d\.]+)/i],[at,[it,sd]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[at,it],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[it,at],[/\(bb(10);/i],[at,[it,s9]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[at,[it,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[at,[it,Rb+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[at,[it,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[at,[it,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[it,"Chrome OS"],at],[/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],[it,at],[/(sunos) ?([\w\.\d]*)/i],[[it,"Solaris"],at],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[it,at]]},Jw=function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return Ac.call(e.init,[[rs,[it,at,Eb,rt]],[Cc,[Oa]],[vu,[rt,st,ht]],[Ec,[it,at]],[Os,[it,at]]]),Ac.call(e.isIgnore,[[rs,[at,Eb]],[Ec,[at]],[Os,[at]]]),Ac.call(e.isIgnoreRgx,[[rs,/ ?browser$/i],[Os,/ ?os$/i]]),Ac.call(e.toString,[[rs,[it,at]],[Cc,[Oa]],[vu,[ht,st]],[Ec,[it,at]],[Os,[it,at]]]),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(o9).then(function(d){return e.setCH(new b9(d,!1)).parseCH().get()}):e.parseCH().get()},u.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Am&&(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=wm;for(var h in s)typeof this[s[h]]!==od&&(d+=(d?" ":wm)+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 b9(e,t){if(e=e||{},Ac.call(this,o9),t)Ac.call(this,[[vR,ER(e[ad])],[yR,ER(e[Sne])],[yn,/\?1/.test(e[kne])],[st,Db(e[Ane])],[km,Db(e[i9])],[bR,Db(e[Tne])],[Oa,Db(e[wne])],[Gh,ER(e[Ene])],[Yw,Db(e[Cne])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==od&&(this[n]=e[n])}function _9(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(it,"Brave");break;case vu:!this.get(rt)&&ld&&ld[yn]&&this.set(rt,yn),this.get(st)=="Macintosh"&&Ra&&typeof Ra.standalone!==od&&Ra.maxTouchPoints&&Ra.maxTouchPoints>2&&this.set(st,"iPad").set(rt,Zr);break;case Os:!this.get(it)&&ld&&ld[km]&&this.set(it,ld[km]);break;case Am:var o=this.data,s=function(u){return o[u].getItem().detectFeature().get()};this.set(rs,s(rs)).set(Cc,s(Cc)).set(vu,s(vu)).set(Ec,s(Ec)).set(Os,s(Os))}return this},this.parseUA=function(){return this.itemType!=Am&&g9.call(this.data,this.ua,this.rgxMap),this.itemType==rs&&this.set(Eb,kR(this.get(at))),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(it,m).set(at,y).set(Eb,kR(y)),d=m)}break;case Cc:var v=o[Oa];v&&(v&&o[Yw]=="64"&&(v+="64"),g9.call(this.data,v+";",s));break;case vu:if(o[yn]&&this.set(rt,yn),o[st]&&this.set(st,o[st]),o[st]=="Xbox"&&this.set(rt,Em).set(ht,Qw),o[Gh]){var x;if(typeof o[Gh]!="string")for(var w=0;!x&&w<o[Gh].length;)x=Lb(o[Gh][w++],v9);else x=Lb(o[Gh],v9);this.set(rt,x)}break;case Os:var E=o[km];if(E){var M=o[bR];E==wR&&(M=parseInt(kR(M),10)>=13?"11":"10"),this.set(it,E).set(at,M)}this.get(it)==wR&&o[st]=="Xbox"&&this.set(it,"Xbox").set(at,void 0);break;case Am:var A=this.data,k=function(I){return A[I].getItem().setCH(o).parseCH().get()};this.set(rs,k(rs)).set(Cc,k(Cc)).set(vu,k(vu)).set(Ec,k(Ec)).set(Os,k(Os))}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===Cm?(Ww(e,!0)?(typeof t===Cm&&(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[r9]?n[r9]:Ra&&Ra.userAgent?Ra.userAgent:wm,s=new b9(n,!0),u=t?Ine(y9,t):y9,d=function(h){return h==Am?function(){return new _9(h,o,u,s).set("ua",o).set(rs,this.getBrowser()).set(Cc,this.getCPU()).set(vu,this.getDevice()).set(Ec,this.getEngine()).set(Os,this.getOS()).get()}:function(){return new _9(h,o,u[h],s).parseUA().get()}};return Ac.call(this,[["getBrowser",d(rs)],["getCPU",d(Cc)],["getDevice",d(vu)],["getEngine",d(Ec)],["getOS",d(Os)],["getResult",d(Am)],["getUA",function(){return o}],["setUA",function(h){return Mm(h)&&(o=h.length>mR?$b(h,mR):h),this}]]).setUA(o),this}Tc.VERSION=xne,Tc.BROWSER=Xw([it,at,Eb,rt]),Tc.CPU=Xw([Oa]),Tc.DEVICE=Xw([st,ht,rt,Em,yn,Ho,Zr,kb,gR]),Tc.ENGINE=Tc.OS=Xw([it,at]);const Is=class Is{constructor(t){ro(this,"config");ro(this,"storedData");ro(this,"deviceInfo");ro(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){Is.instance||(Is.instance=new Is(t))}static getInstance(){if(!Is.instance)throw new Error("DebalesAnalytics is not initialized. Call init() first.");return Is.instance}static async identify(t,n){return Is.getInstance().identifyInternal(t,n)}static track(t,n){Is.getInstance().trackInternal(t,n)}static getDistinctId(){return Is.getInstance().storedData.distinctId}static getAnonId(){return Is.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:nr()+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}}};ro(Is,"instance",null);let AR=Is;const yu=AR;function $ne(e){E6(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"},cr={OPEN_STATE_CHANGE:"open_state_change"},tC=e=>{window.DebalesChat||(window.DebalesChat={isOpen:!1,projectId:e,getSessionId:()=>nr(),getChatId:()=>nr()+"_"+e,getAnonId:()=>yu.getAnonId(),isIdentified:()=>{if(Es._isIdentified())return!0;const t=yo();return!!(t&&t.email)},getIdentifiedUser:()=>yo(),getDistinctId:()=>Es.get_distinct_id(),getOldDistinctId:()=>yu.getDistinctId(),debug:!1,identify:(t,n)=>{Es._isIdentified()||Es.identify(t,{...n,project:e}),yu.identify(t,n),wc({email:t,name:n==null?void 0:n.name,phone:n==null?void 0:n.phone})},track:(t,n)=>{yu.track(t,{...n,sessionId:window.DebalesChat.getSessionId()}),Es.capture(t,{...n}),yne(t,{...n,sessionId:nr(),projectId:e})},onOpenChange:t=>{const n=r=>{t(r.detail.isOpen)};return window.addEventListener(cr.OPEN_STATE_CHANGE,n),()=>window.removeEventListener(cr.OPEN_STATE_CHANGE,n)},removeOpenChangeListener:t=>{const n=r=>{t(r.detail.isOpen)};window.removeEventListener(cr.OPEN_STATE_CHANGE,n)},open:()=>{window.DebalesChat.isOpen||window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:!0,projectId:e}}))},close:()=>{window.DebalesChat.isOpen&&window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:!1,projectId:e}}))},toggle:()=>{window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:!window.DebalesChat.isOpen,projectId:e}}))}})};var _o=(e=>(e.DEFAULT="DEFAULT",e.SHOPIFY="SHOPIFY",e.WOOCOMMERCE="WOOCOMMERCE",e.MAGENTO="MAGENTO",e.UNKNOWN="UNKNOWN",e))(_o||{});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 _o.SHOPIFY;if(typeof window<"u"&&document.body.classList.contains("woocommerce"))return _o.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 _o.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 _o.MAGENTO;if(document.cookie.split(";").some(v=>v.trim().startsWith("mage-")||v.trim().startsWith("form_key")))return _o.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 _o.MAGENTO}return _o.UNKNOWN}}const nC=F.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 Dt.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 l8=["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<l8.length;t++)if(e.indexOf(l8[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{tr.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},z.cookie={get:function(e){for(var t=e+"=",n=ur.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=f8(ur.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"),ur.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=f8(ur.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 ur.cookie=x,x},remove:function(e,t,n){z.cookie.set(e,"",-1,t,!1,!1,n)}};var u8=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,vb=function(e,t){return zO!==null&&!t?zO:zO=u8(e||Dt.localStorage)},UO=null,bte=function(e,t){return UO!==null&&!t?UO:UO=u8(e||Dt.sessionStorage)};function c8(e,t,n){var r=function(o){tr.error(t+" error: "+o)};return{is_supported:function(o){var s=n(e,o);return s||tr.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=c8(Dt.localStorage,"localStorage",vb),z.sessionStorage=c8(Dt.sessionStorage,"sessionStorage",bte),z.register_event=function(){var e=function(r,o,s,u,d){if(!r){tr.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(Dt.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(!ur.getElementsByTagName)return[];var s=o.split(" "),u,d,h,m,y,v,x,w,E,M,A=[ur];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],I=ur.getElementById(k);if(!I||h&&I.nodeName.toLowerCase()!=h)return[];A=[I];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 L=u.match(_te);if(L){h=L[1];var B=L[2],H=L[3],Q=L[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 J;switch(H){case"=":J=function(W){return W.getAttribute(B)==Q};break;case"~":J=function(W){return W.getAttribute(B).match(new RegExp("\\b"+Q+"\\b"))};break;case"|":J=function(W){return W.getAttribute(B).match(new RegExp("^"+Q+"-?"))};break;case"^":J=function(W){return W.getAttribute(B).indexOf(Q)===0};break;case"$":J=function(W){return W.getAttribute(B).lastIndexOf(Q)==W.getAttribute(B).length-Q.length};break;case"*":J=function(W){return W.getAttribute(B).indexOf(Q)>-1};break;default:J=function(W){return W.getAttribute(B)}}for(A=[],M=0,x=0;x<m.length;x++)J(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(ur.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(ur.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 Dt.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:ur.referrer,$referring_domain:z.info.referringDomain(ur.referrer),$device:z.info.device(bc)}),{$current_url:z.info.currentUrl(),$browser_version:z.info.browserVersion(bc,Jf.vendor,Lw),$screen_height:i8.height,$screen_width:i8.width,mp_lib:"web",$lib_version:kl.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:ur.title,current_domain:Dt.location.hostname,current_url_path:Dt.location.pathname,current_url_protocol:Dt.location.protocol,current_url_search:Dt.location.search})}};var wte=function(e,t){var n=null,r=[];return function(o){var s=this;return r.push(o),n||(n=new or(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,f8=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=Dt.navigator.onLine;return z.isUndefined(e)||e},ed=function(){},pm=null,Nw=null;typeof JSON<"u"&&(pm=JSON.stringify,Nw=JSON.parse),pm=pm||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",d8="mixpanelRecordingEvents",HO="mixpanelRecordingRegistry",Tte=1,Mte=[d8,HO],hu=function(e){this.dbPromise=null,this.storeName=e};hu.prototype._openDb=function(){return new or(function(e,t){var n=Dt.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)})}})},hu.prototype.init=function(){return Dt.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof Dt.IDBDatabase?or.resolve():or.reject(e)})):or.reject("indexedDB is not supported in this browser")},hu.prototype.makeTransaction=function(e,t){var n=this.storeName,r=function(o){return new or(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)):or.reject(o)}).bind(this))},hu.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(n){n.put(t,e)})},hu.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(n){t=n.get(e)}).then(function(){return t.result})},hu.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},hu.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){g8(!0,e,t)}function Ite(e,t){g8(!1,e,t)}function Dte(e,t){return p8(e,t)==="1"}function h8(e,t){if(Lte(t))return tr.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=p8(e,t)==="0";return n&&tr.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 gm(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 p8(e,t){return qO(t).get(PO(e,t))}function Lte(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||Dt,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 g8(e,t,n){if(!z.isString(t)||!t.length){tr.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=h8(r,{ignoreDnt:o,persistenceType:s,persistencePrefix:u,window:d}))}catch(m){tr.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=hm("lock"),m8=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||Dt.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||or};m8.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(L){o(L)}},h*(Math.random()+.1))},M=function(D,L){D()?L():E(function(){M(D,L)})},A=function(){var D=y.getItem(x);return D&&D!==s?!1:(y.setItem(x,s),y.getItem(x)===s?!0:(vb(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){I();return}E(function(){if(y.getItem(x)!==s){k();return}M(function(){return!y.getItem(w)},I)})})},I=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(L){D(),r(L)}).catch(function(L){D(),o(L)})};try{if(vb(y,!0))k();else throw new Error("localStorage support check failed")}catch(D){o(D)}},this))};var yb=function(e){this.storage=e||Dt.localStorage};yb.prototype.init=function(){return or.resolve()},yb.prototype.setItem=function(e,t){return new or(z.bind(function(n,r){try{this.storage.setItem(e,pm(t))}catch(o){r(o)}n()},this))},yb.prototype.getItem=function(e){return new or(z.bind(function(t,n){var r;try{r=Nw(this.storage.getItem(e))}catch(o){n(o)}t(r)},this))},yb.prototype.removeItem=function(e){return new or(z.bind(function(t,n){try{this.storage.removeItem(e)}catch(r){n(r)}t()},this))};var v8=hm("batch"),pu=function(e,t){t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new yb,this.lock=new m8(e,{storage:t.sharedLockStorage||Dt.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||z.bind(v8.error,v8),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)};pu.prototype.ensureInit=function(){return this.initialized?or.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))},pu.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),or.resolve(!0))},pu.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))},pu.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)):or.resolve(t)};var y8=function(e,t){var n=[];return z.each(e,function(r){r.id&&!t[r.id]&&n.push(r)}),n};pu.prototype.removeItemsByID=function(e){var t={};if(z.each(e,function(r){t[r]=!0}),this.memQueue=y8(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=y8(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),vb(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 or.resolve(!0)};var b8=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};pu.prototype.updatePayloads=function(e){return this.memQueue=b8(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=b8(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)):or.resolve(!0)},pu.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))},pu.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))},pu.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(z.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):or.resolve()};var Bte=10*60*1e3,bb=hm("batch"),Ts=function(e,t){this.errorReporter=t.errorReporter,this.queue=new pu(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};Ts.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},Ts.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},Ts.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},Ts.prototype.clear=function(){return this.queue.clear()},Ts.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},Ts.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},Ts.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(z.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},Ts.prototype.sendRequestPromise=function(e,t){return new or(z.bind(function(n){this.sendRequest(e,t,n)},this))},Ts.prototype.flush=function(e){if(this.requestInProgress)return bb.log("Flush: Request already in progress"),or.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:kl.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(),or.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(),or.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),or.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),or.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(),or.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"),bb.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))},Ts.prototype.reportError=function(e,t){if(bb.error.apply(bb.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(n){bb.error(n)}};var GO=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},zte=250,mm=hm("recorder"),_8=Dt.CompressionStream,Ute={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},jte=new Set([an.MouseMove,an.MouseInteraction,an.Scroll,an.ViewportResize,an.Input,an.TouchMove,an.MediaInteraction,an.Drag,an.Selection]);function Hte(e){return e.type===qn.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=gb,this.recordMinMs=0;var t=vb(e.sharedLockStorage,!0);this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new hu(d8),this.batcher=new Ts(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){mm.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>gb&&(this.recordMaxMs=gb,mm.critical("record_max_ms cannot be greater than "+gb+"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,mm.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);Dt.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===qn.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:kl.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),_8){var E=new Blob([v],{type:"application/json"}).stream(),M=E.pipeThrough(new _8("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){mm.error.apply(mm.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(n){mm.error(n)}};var vm=function(e){this.idb=new hu(HO),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};vm.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},vm.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."),or.resolve())},vm.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))},vm.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))},vm.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 or.all(t)}).bind(this)).catch(this.handleError.bind(this))};var _b=hm("recorder"),_c=function(e,t,n){this.mixpanelInstance=e,this.rrwebRecord=t||Qf,this.sharedLockStorage=n,this.recordingRegistry=new vm({mixpanelInstance:this.mixpanelInstance,errorReporter:_b.error,sharedLockStorage:n}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null};_c.prototype.startRecording=function(e){if(e=e||{},this.activeRecording&&!this.activeRecording.isRrwebStopped()){_b.log("Recording already in progress, skipping startRecording.");return}var t=(function(){_b.log("Idle timeout reached, restarting recording."),this.resetRecording()}).bind(this),n=(function(){_b.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):or.resolve()},_c.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),or.resolve(null)):this.recordingRegistry.getActiveRecording().then((function(t){return t?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):(_b.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()}}),Dt.__mp_recorder=_c;var Bw="change",xb="click",x8="hashchange",ym="mp_locationchange",S8="popstate",w8="scrollend",VO="submit",qte=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],C8=["mp-include"],YO=["mp-no-track"],E8=YO.concat(["mp-sensitive"]),Pte=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],Ma=hm("autocapture");function ZO(e){for(var t={},n=k8(e).split(" "),r=0;r<n.length;r++){var o=n[r];o&&(t[o]=!0)}return t}function k8(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&&!M8(e));return e}function A8(e,t,n,r,o,s){var u={$classes:k8(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(L){m[L]=!0});var y=null,v=typeof e.target>"u"?e.srcElement:e.target;if(O8(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&&!gu(w,"body");)x.push(w.parentNode),w=w.parentNode;var E=[],M,A=!1;if(z.each(x,function(L){var B=XO(L,e,n,r);!m.href&&L.tagName.toLowerCase()==="a"&&(M=L.getAttribute("href"),M=B&&zw(M)&&M),KO(L,e,s,u)&&(A=!0),E.push(A8(L,e,m,h,n,r))},this),!A){var k=ur.documentElement;if(y={$event_type:e.type,$host:Dt.location.host,$pathname:Dt.location.pathname,$elements:E,$el_attr__href:M,$viewportHeight:Math.max(k.clientHeight,Dt.innerHeight||0),$viewportWidth:Math.max(k.clientWidth,Dt.innerWidth||0)},z.each(h,function(L){if(!m[L]&&v.hasAttribute(L)){var B=v.getAttribute(L);zw(B)&&(y["$el_attr__"+L]=B)}}),d&&(I=T8(v,e,n,r),I&&I.length&&(y.$el_text=I)),e.type===xb&&(z.each(qte,function(L){L in e&&(y["$"+L]=e[L])}),v=Vte(e)),d){var I=T8(v,e,n,r);I&&I.length&&(y.$el_text=I)}if(v){if(!QO(v,e,n,r)||KO(v,e,s,u))return null;var D=A8(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 T8(e,t,n,r){var o="";return XO(e,t,n,r)&&e.childNodes&&e.childNodes.length&&z.each(e.childNodes,function(s){O8(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(gu(o,"a")||gu(o,"button")||gu(o,"input")||gu(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 M8(e){return e&&e.nodeType===1}function gu(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function O8(e){return e&&e.nodeType===3}function Yte(){try{var e=ur.createElement("div");return!!e.matches}catch{return!1}}function Zte(e,t){if(!e||gu(e,"html")||!M8(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===xb;case"select":case"textarea":return t.type===Bw;default:return t.type===xb}}function XO(e,t,n,r){var o;if(!QO(e,t,n,r))return!1;for(var s=e;s.parentNode&&!gu(s,"body");s=s.parentNode){var u=ZO(s);for(o=0;o<E8.length;o++)if(u[E8[o]])return!1}var d=ZO(e);for(o=0;o<C8.length;o++)if(d[C8[o]])return!0;if(gu(e,"input")||gu(e,"select")||gu(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 R8="autocapture",Qte="track_pageview",I8="full-url",Kte="url-with-path-and-query-string",Xte="url-with-path",Wte="allow_element_callback",D8="allow_selectors",$8="allow_url_regexes",L8="block_attrs",N8="block_element_callback",B8="block_selectors",z8="block_url_regexes",U8="capture_extra_attrs",j8="capture_text_content",H8="scroll_capture_all",q8="scroll_depth_percent_checkpoints",WO="click",JO="input",P8="pageview",eR="scroll",tR="submit",vo={};vo[D8]=[],vo[$8]=[],vo[L8]=[],vo[N8]=null,vo[B8]=[],vo[z8]=[],vo[U8]=[],vo[j8]=!1,vo[H8]=!1,vo[q8]=[25,50,75,100],vo[WO]=!0,vo[JO]=!0,vo[P8]=I8,vo[eR]=!0,vo[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(R8);return e?z.isObject(e)?z.extend({},vo,e):vo:{}},ns.prototype.getConfig=function(e){return this.getFullConfig()[e]},ns.prototype.currentUrlBlocked=function(){var e,t=z.info.currentUrl(),n=this.getConfig($8)||[];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(z8)||[];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(R8)?this.getConfig(P8):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(D8),blockAttrs:this.getConfig(L8),blockElementCallback:this.getConfig(N8),blockSelectors:this.getConfig(B8),captureExtraAttrs:this.getConfig(U8),captureTextContent:this.getConfig(j8)});n&&(z.extend(n,Uw),this.mp.track(t,n))}},ns.prototype.initClickTracking=function(){Dt.removeEventListener(xb,this.listenerClick),this.getConfig(WO)&&(Ma.log("Initializing click tracking"),this.listenerClick=Dt.addEventListener(xb,(function(e){this.getConfig(WO)&&this.trackDomEvent(e,Jte)}).bind(this)))},ns.prototype.initInputTracking=function(){Dt.removeEventListener(Bw,this.listenerChange),this.getConfig(JO)&&(Ma.log("Initializing input tracking"),this.listenerChange=Dt.addEventListener(Bw,(function(e){this.getConfig(JO)&&this.trackDomEvent(e,ene)}).bind(this)))},ns.prototype.initPageviewTracking=function(){if(Dt.removeEventListener(S8,this.listenerPopstate),Dt.removeEventListener(x8,this.listenerHashchange),Dt.removeEventListener(ym,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=Dt.addEventListener(S8,function(){Dt.dispatchEvent(new Event(ym))}),this.listenerHashchange=Dt.addEventListener(x8,function(){Dt.dispatchEvent(new Event(ym))});var n=Dt.history.pushState;typeof n=="function"&&(Dt.history.pushState=function(o,s,u){n.call(Dt.history,o,s,u),Dt.dispatchEvent(new Event(ym))});var r=Dt.history.replaceState;typeof r=="function"&&(Dt.history.replaceState=function(o,s,u){r.call(Dt.history,o,s,u),Dt.dispatchEvent(new Event(ym))}),this.listenerLocationchange=Dt.addEventListener(ym,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===I8?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(){Dt.removeEventListener(w8,this.listenerScroll),this.getConfig(eR)&&(Ma.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0,this.listenerScroll=Dt.addEventListener(w8,BO((function(){if(this.getConfig(eR)&&!this.currentUrlBlocked()){var e=this.getConfig(H8),t=(this.getConfig(q8)||[]).slice().sort(function(h,m){return h-m}),n=Dt.scrollY,r=z.extend({$scroll_top:n},Uw);try{var o=ur.body.scrollHeight,s=Math.round(n/(o-Dt.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(){Dt.removeEventListener(VO,this.listenerSubmit),this.getConfig(tR)&&(Ma.log("Initializing submit tracking"),this.listenerSubmit=Dt.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){tr.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 bm=function(){this.override_event="click"};z.inherit(bm,xc),bm.prototype.create_properties=function(e,t){var n=bm.superclass.create_properties.apply(this,arguments);return t.href&&(n.url=t.href),n},bm.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()},bm.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",_m="$set_once",Al="$unset",qh="$add",mu="$append",Ph="$union",Sc="$remove",rne="$delete",F8={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[Al]=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[_m]=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[mu]=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}},Ur=function(){};z.extend(Ur.prototype,F8),Ur.prototype._init=function(e,t,n){this._mixpanel=e,this._group_key=t,this._group_id=n},Ur.prototype.set=gm(function(e,t,n){var r=this.set_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),Ur.prototype.set_once=gm(function(e,t,n){var r=this.set_once_action(e,t);return z.isObject(e)&&(n=t),this._send_request(r,n)}),Ur.prototype.unset=gm(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),Ur.prototype.union=gm(function(e,t,n){z.isObject(e)&&(n=t);var r=this.union_action(e,t);return this._send_request(r,n)}),Ur.prototype.delete=gm(function(e){var t=this.delete_action();return this._send_request(t,e)}),Ur.prototype.remove=gm(function(e,t,n){var r=this.remove_action(e,t);return this._send_request(r,n)}),Ur.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)},Ur.prototype._is_reserved_property=function(e){return e==="$group_key"||e==="$group_id"},Ur.prototype._get_config=function(e){return this._mixpanel.get_config(e)},Ur.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},Ur.prototype.remove=Ur.prototype.remove,Ur.prototype.set=Ur.prototype.set,Ur.prototype.set_once=Ur.prototype.set_once,Ur.prototype.union=Ur.prototype.union,Ur.prototype.unset=Ur.prototype.unset,Ur.prototype.toString=Ur.prototype.toString;var dn=function(){};z.extend(dn.prototype,F8),dn.prototype._init=function(e){this._mixpanel=e},dn.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)}),dn.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)}),dn.prototype.unset=nd(function(e,t){var n=this.unset_action(e);return this._send_request(n,t)}),dn.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))){tr.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)}),dn.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)}),dn.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)}),dn.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)}),dn.prototype.track_charge=nd(function(e,t,n){if(!z.isNumber(e)&&(e=parseFloat(e),isNaN(e))){tr.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",z.extend({$amount:e},t),n)}),dn.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},dn.prototype.delete_user=function(){if(!this._identify_called()){tr.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)},dn.prototype.toString=function(){return this._mixpanel.toString()+".people"},dn.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))},dn.prototype._get_config=function(e){return this._mixpanel.get_config(e)},dn.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0},dn.prototype._enqueue=function(e){rd in e?this._mixpanel.persistence._add_to_people_queue(rd,e):_m in e?this._mixpanel.persistence._add_to_people_queue(_m,e):Al in e?this._mixpanel.persistence._add_to_people_queue(Al,e):qh in e?this._mixpanel.persistence._add_to_people_queue(qh,e):mu in e?this._mixpanel.persistence._add_to_people_queue(mu,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):tr.error("Invalid call to _enqueue():",e)},dn.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)}))},dn.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(_m,this.set_once,r),this._flush_one_queue(Al,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(mu);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(mu,m),z.isUndefined(n)||n(A,k)},v=h.length-1;v>=0;v--)h=this._mixpanel.persistence.load_queue(mu),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)},dn.prototype._is_reserved_property=function(e){return e==="$distinct_id"||e==="$token"||e==="$device_id"||e==="$user_id"||e==="$had_persisted_distinct_id"},dn.prototype.set=dn.prototype.set,dn.prototype.set_once=dn.prototype.set_once,dn.prototype.unset=dn.prototype.unset,dn.prototype.increment=dn.prototype.increment,dn.prototype.append=dn.prototype.append,dn.prototype.remove=dn.prototype.remove,dn.prototype.union=dn.prototype.union,dn.prototype.track_charge=dn.prototype.track_charge,dn.prototype.clear_charges=dn.prototype.clear_charges,dn.prototype.delete_user=dn.prototype.delete_user,dn.prototype.toString=dn.prototype.toString;var nR="__mps",rR="__mpso",iR="__mpus",oR="__mpa",aR="__mpap",sR="__mpr",lR="__mpu",G8="$people_distinct_id",Hw="__alias",Sb="__timers",ine=[nR,rR,iR,oR,aR,sR,lR,G8,Hw,Sb],Mn=function(e){this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="mp_"+e.persistence_name:this.name="mp_"+e.token+"_mixpanel";var t=e.persistence;t!=="cookie"&&t!=="localStorage"&&(tr.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()};Mn.prototype.properties=function(){var e={};return this.load(),z.each(this.props,function(t,n){z.include(ine,n)||(e[n]=t)}),e},Mn.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=z.extend({},e))}},Mn.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))},Mn.prototype.save=function(){this.disabled||this.storage.set(this.name,pm(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},Mn.prototype.load_prop=function(e){return this.load(),this.props[e]},Mn.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},Mn.prototype.clear=function(){this.remove(),this.props={}},Mn.prototype.register_once=function(e,t,n){return 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},Mn.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},Mn.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},Mn.prototype.update_search_keyword=function(e){this.register(z.info.searchInfo(e))},Mn.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:z.info.referringDomain(e)||"$direct"},"")},Mn.prototype.get_referrer_info=function(){return z.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},Mn.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cookie_domain(e.cookie_domain),this.set_cross_site(e.cross_site_cookie),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},Mn.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},Mn.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},Mn.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},Mn.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},Mn.prototype.get_cross_subdomain=function(){return this.cross_subdomain},Mn.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},Mn.prototype._add_to_people_queue=function(e,t){var n=this._get_queue_key(e),r=t[e],o=this._get_or_create_queue(rd),s=this._get_or_create_queue(_m),u=this._get_or_create_queue(Al),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(mu,[]);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(Al,r)):n===rR?(z.each(r,function(v,x){x in s||(s[x]=v)}),this._pop_from_people_queue(Al,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(Al,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(Al,r)):n===sR?(m.push(r),this._pop_from_people_queue(mu,r)):n===aR&&(y.push(r),this._pop_from_people_queue(Al,r)),tr.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),tr.log(t),this.save()},Mn.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===mu||e===Sc?z.each(n,function(s){s[o]===r&&delete s[o]}):delete n[o]},this)},Mn.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},Mn.prototype._get_queue_key=function(e){if(e===rd)return nR;if(e===_m)return rR;if(e===Al)return iR;if(e===qh)return oR;if(e===mu)return aR;if(e===Sc)return sR;if(e===Ph)return lR;tr.error("Invalid queue:",e)},Mn.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)},Mn.prototype.set_event_timer=function(e,t){var n=this.load_prop(Sb)||{};n[e]=t,this.props[Sb]=n,this.save()},Mn.prototype.remove_event_timer=function(e){var t=this.load_prop(Sb)||{},n=t[e];return z.isUndefined(n)||(delete this.props[Sb][e],this.save()),n};var uR,V8=function(e,t){throw new Error(e+" not available in this build.")},Uo,Y8=0,one=1,ane=function(e){return e},Ms="mixpanel",Z8="base64",sne="json",cR="$device:",xm=Dt.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,Q8=!xm&&bc.indexOf("MSIE")===-1&&bc.indexOf("Mozilla")===-1,qw=null;Jf.sendBeacon&&(qw=function(){return Jf.sendBeacon.apply(Jf,arguments)});var K8={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},X8={api_host:"https://api-js.mixpanel.com",api_routes:K8,api_method:"POST",api_transport:"XHR",api_payload_format:Z8,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:gb,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},W8=!1,ke=function(){},fR=function(e,t,n){var r,o=n===Ms?Uo:Uo[n];if(o&&uR===Y8)r=o;else{if(o&&!z.isArray(o)){tr.error("You have already initialized "+n);return}r=new ke}if(r._cached_groups={},r._init(e,t,n),r.people=new dn,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 kl.DEBUG=kl.DEBUG||r.get_config("debug"),!z.isUndefined(o)&&z.isArray(o)&&(r._execute_array.call(r.people,o.people),r._execute_array(o)),r};ke.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===Ms){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},ke.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||X8.api_host;o.match(/\.mixpanel\.com/)&&(r.api_payload_format=sne)}if(this.set_config(z.extend({},X8,r,t,{name:n,token:e,callback_fn:(n===Ms?n:Ms+"."+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)||!xm)this._batch_requests=!1,tr.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),z.each(this.get_batcher_configs(),function(d){tr.log("Clearing batch queue "+d.queue_key),z.localStorage.remove(d.queue_key)});else if(this.init_batchers(),qw&&Dt.addEventListener){var s=z.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);Dt.addEventListener("pagehide",function(d){d.persisted&&s()}),Dt.addEventListener("visibilitychange",function(){ur.visibilityState==="hidden"&&s()})}}this.persistence=this.cookie=new Mn(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()},ke.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),Dt.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.")},ke.prototype.get_tab_id=function(){return this.tab_id||null},ke.prototype._should_load_recorder=function(){var e=new hu(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))},ke.prototype._check_and_start_session_recording=td(function(e){if(!Dt.MutationObserver){tr.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 Dt.__mp_recorder(this),this._recorder.resumeRecording(r)},this);z.isUndefined(Dt.__mp_recorder)?V8(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)})}),ke.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},ke.prototype.stop_session_recording=function(){this._recorder&&this._recorder.stopRecording()},ke.prototype.pause_session_recording=function(){this._recorder&&this._recorder.pauseRecording()},ke.prototype.resume_session_recording=function(){this._recorder&&this._recorder.resumeRecording()},ke.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},ke.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},ke.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},ke.prototype.__get_recorder=function(){return this._recorder},ke.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))}},ke.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(ur.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(ur.referrer)},ke.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},ke.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(!W8)return this.__dom_loaded_queue.push([e,t]),!1;var n=new e().init(this);return n.track.apply(n,t)},ke.prototype._prepare_callback=function(e,t){if(z.isUndefined(e))return null;if(xm){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}},ke.prototype._send_request=function(e,t,n,r){var o=!0;if(Q8)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||{}),xm||(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),xm||(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=ur.createElement("img");v.src=e,ur.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(xm)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,I){x.setRequestHeader(I,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(L){if(y.report_error(L),n.ignore_json_errors)k=x.responseText;else return}r(k)}else r(Number(x.responseText))}else{var I;if(x.timeout&&!x.status&&new Date().getTime()-E>=x.timeout?I="timeout":I="Bad HTTP status: "+x.status+" "+x.statusText,y.report_error(I),r)if(m){var D=x.responseHeaders||{};r({status:0,httpStatusCode:x.status,error:I,retryAfter:D["Retry-After"]})}else r(0)}},x.send(u)}catch(k){y.report_error(k),o=!1}else{var M=ur.createElement("script");M.type="text/javascript",M.async=!0,M.defer=!0,M.src=e;var A=ur.getElementsByTagName("script")[0];A.parentNode.insertBefore(M,A)}return o},ke.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)},ke.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},ke.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},ke.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=z.bind(function(n){return new Ts(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()},ke.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()}))},ke.prototype.stop_batch_senders=function(){this._batch_requests=!1,z.each(this.request_batchers,function(e){e.stop(),e.clear()})},ke.prototype.push=function(e){this._execute_array([e])},ke.prototype.disable=function(e){typeof e>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},ke.prototype._encode_data_for_request=function(e){var t=pm(e);return this.get_config("api_payload_format")===Z8&&(t=z.base64Encode(t)),{data:t}},ke.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?(tr.log("MIXPANEL REQUEST:"),tr.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},ke.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}),ke.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)}),ke.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)}),ke.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)}),ke.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)}),ke.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},ke.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},ke.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 Ur,r._init(this,e,t),this._cached_groups[n]=r),r},ke.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)}),ke.prototype.track_links=function(){return this._track_dom.call(this,bm,arguments)},ke.prototype.track_forms=function(){return this._track_dom.call(this,jw,arguments)},ke.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)};ke.prototype.register=function(e,t){var n=dR(t);n.persistent?this.persistence.register(e,n.days):z.extend(this.unpersisted_superprops,e)},ke.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))},ke.prototype.unregister=function(e,t){t=dR(t),t.persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},ke.prototype._register_single=function(e,t){var n={};n[e]=t,this.register(n)},ke.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})},ke.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},"")},ke.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},ke.prototype.alias=function(e,t){if(e===this.get_property(G8))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)},ke.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},ke.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),kl.DEBUG=kl.DEBUG||this.get_config("debug"),"autocapture"in e&&this.autocapture&&this.autocapture.init()}},ke.prototype.get_config=function(e){return this.config[e]},ke.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},ke.prototype.get_property=function(e){return this.persistence.load_prop([e])},ke.prototype.toString=function(){var e=this.get_config("name");return e!==Ms&&(e=Ms+"."+e),e},ke.prototype._event_is_disabled=function(e){return z.isBlockedUA(bc)||this._flags.disable_all_events||z.include(this.__disabled_events,e)},ke.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")}))},ke.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()},ke.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})},ke.prototype.opt_in_tracking=function(e){e=z.extend({enable_persistence:!0},e),this._gdpr_call_func(Rte,e),this._gdpr_update_persistence(e)},ke.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)},ke.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(Dte,e)},ke.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(h8,e)},ke.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)},ke.prototype.report_error=function(e,t){tr.error.apply(tr.error,arguments);try{!t&&!(e instanceof Error)&&(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(n){tr.error(n)}},ke.prototype.init=ke.prototype.init,ke.prototype.reset=ke.prototype.reset,ke.prototype.disable=ke.prototype.disable,ke.prototype.time_event=ke.prototype.time_event,ke.prototype.track=ke.prototype.track,ke.prototype.track_links=ke.prototype.track_links,ke.prototype.track_forms=ke.prototype.track_forms,ke.prototype.track_pageview=ke.prototype.track_pageview,ke.prototype.register=ke.prototype.register,ke.prototype.register_once=ke.prototype.register_once,ke.prototype.unregister=ke.prototype.unregister,ke.prototype.identify=ke.prototype.identify,ke.prototype.alias=ke.prototype.alias,ke.prototype.name_tag=ke.prototype.name_tag,ke.prototype.set_config=ke.prototype.set_config,ke.prototype.get_config=ke.prototype.get_config,ke.prototype.get_property=ke.prototype.get_property,ke.prototype.get_distinct_id=ke.prototype.get_distinct_id,ke.prototype.toString=ke.prototype.toString,ke.prototype.opt_out_tracking=ke.prototype.opt_out_tracking,ke.prototype.opt_in_tracking=ke.prototype.opt_in_tracking,ke.prototype.has_opted_out_tracking=ke.prototype.has_opted_out_tracking,ke.prototype.has_opted_in_tracking=ke.prototype.has_opted_in_tracking,ke.prototype.clear_opt_in_out_tracking=ke.prototype.clear_opt_in_out_tracking,ke.prototype.get_group=ke.prototype.get_group,ke.prototype.set_group=ke.prototype.set_group,ke.prototype.add_group=ke.prototype.add_group,ke.prototype.remove_group=ke.prototype.remove_group,ke.prototype.track_with_groups=ke.prototype.track_with_groups,ke.prototype.start_batch_senders=ke.prototype.start_batch_senders,ke.prototype.stop_batch_senders=ke.prototype.stop_batch_senders,ke.prototype.start_session_recording=ke.prototype.start_session_recording,ke.prototype.stop_session_recording=ke.prototype.stop_session_recording,ke.prototype.pause_session_recording=ke.prototype.pause_session_recording,ke.prototype.resume_session_recording=ke.prototype.resume_session_recording,ke.prototype.get_session_recording_properties=ke.prototype.get_session_recording_properties,ke.prototype.get_session_replay_url=ke.prototype.get_session_replay_url,ke.prototype.get_tab_id=ke.prototype.get_tab_id,ke.prototype.DEFAULT_API_ROUTES=K8,ke.prototype.__get_recorder=ke.prototype.__get_recorder,Mn.prototype.properties=Mn.prototype.properties,Mn.prototype.update_search_keyword=Mn.prototype.update_search_keyword,Mn.prototype.update_referrer_info=Mn.prototype.update_referrer_info,Mn.prototype.get_cross_subdomain=Mn.prototype.get_cross_subdomain,Mn.prototype.clear=Mn.prototype.clear;var Sm={},une=function(){z.each(Sm,function(e,t){t!==Ms&&(Uo[t]=e)}),Uo._=z},cne=function(){Uo.init=function(e,t,n){if(n)return Uo[n]||(Uo[n]=Sm[n]=fR(e,t,n),Uo[n]._loaded()),Uo[n];var r=Uo;Sm[Ms]?r=Sm[Ms]:e&&(r=fR(e,t,Ms),r._loaded(),Sm[Ms]=r),Uo=r,uR===one&&(Dt[Ms]=Uo),une()}},fne=function(){function e(){e.done||(e.done=!0,W8=!0,Q8=!1,z.each(Sm,function(r){r._dom_loaded()}))}function t(){try{ur.documentElement.doScroll("left")}catch{setTimeout(t,1);return}e()}if(ur.addEventListener)ur.readyState==="complete"?e():ur.addEventListener("DOMContentLoaded",e,!1);else if(ur.attachEvent){ur.attachEvent("onreadystatechange",e);var n=!1;try{n=Dt.frameElement===null}catch{}ur.documentElement.doScroll&&n&&t()}z.register_event(Dt,"load",e,!0)};function dne(e){return V8=e,uR=Y8,Uo=new ke,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",J8={"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 nr(){const e=sessionStorage.getItem("debalesSessionID");if(e)return e;const t=crypto.randomUUID();return sessionStorage.setItem("debalesSessionID",t),t}function mne(){return sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:window.DebalesChat.projectId}))}function yo(){const e=localStorage.getItem($n(Dn.USER_INFO));return e?JSON.parse(e):null}function wc(e){localStorage.setItem($n(Dn.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 wb(){const e=/test|demo|example|debales/i,t=yo()??"";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 e9=new Set,Gw=e=>{const t=J8[e];if(!t)return console.warn("No Mixpanel token found"),null;if(e9.has(e))return id;id.init(t,{debug:!1,track_pageview:!0,persistence:"localStorage"}),console.log("Mixpanel initialized");const n=yo();return n&&n.email&&id.identify(n.email),e9.add(e),id},yne=async(e,t)=>{if(wb())return;const n=window.DebalesChat.projectId??t.projectId;if(!J8[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 bo=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 $n(e,t){return t!=null&&t.botId?`debales_${t.botId}_${e}`:`debales_${e}`}const t9=X.createContext(null),Cb=()=>{const e=X.useContext(t9);if(!e)throw new Error("useCart must be used within a CartProvider");return e};var xne="2.0.0",wm="",n9="?",Vw="function",od="undefined",Cm="object",hR="string",Eb="major",st="model",it="name",rt="type",ht="vendor",at="version",Oa="architecture",Em="console",yn="mobile",Zr="tablet",Ho="smarttv",kb="wearable",pR="xr",gR="embedded",Ab="inapp",r9="user-agent",mR=500,vR="brands",Gh="formFactors",yR="fullVersionList",km="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,i9=ad+"-"+km,Tne=i9+"-version",o9=[vR,yR,yn,st,km,bR,Oa,Gh,Yw],rs="browser",Cc="cpu",vu="device",Ec="engine",Os="os",Am="result",Zw="Amazon",Tb="Apple",a9="ASUS",s9="BlackBerry",Vh="Google",l9="Huawei",u9="Lenovo",Mne="Honor",_R="LG",Qw="Microsoft",c9="Motorola",Mb="Samsung",f9="Sharp",Kw="Sony",xR="Xiaomi",SR="Zebra",Tm="Mobile ",Ob=" Browser",d9="Chrome",sd="Chromecast",One="Edge",Rb="Firefox",Ib="Opera",h9="Facebook",p9="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===Cm&&e.length>0){for(var n in e)if(kc(e[n])==kc(t))return!0;return!1}return Mm(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)},Mm=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=$b(n[r]).split(";v=");t[r]={brand:o[0],version:o[1]}}else t[r]=$b(n[r]);return t}},kc=function(e){return Mm(e)?e.toLowerCase():e},kR=function(e){return Mm(e)?Yh(/[^\d\.]/g,e).split(".")[0]:void 0},Ac=function(e){for(var t in e){var n=e[t];typeof n==Cm&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Yh=function(e,t){return Mm(t)?t.replace(e,wm):t},Db=function(e){return Yh(/\\?\"/g,e)},$b=function(e,t){if(Mm(e))return e=Yh(/^\s\s*/,e),typeof t===od?e:e.substring(0,mR)},g9=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===Cm&&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}},Lb=function(e,t){for(var n in t)if(typeof t[n]===Cm&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(CR(t[n][r],e))return n===n9?void 0:n}else if(CR(t[n],e))return n===n9?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},m9={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"},v9={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},y9={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[at,[it,Tm+"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[at,[it,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[it,at],[/opios[\/ ]+([\w\.]+)/i],[at,[it,Ib+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[at,[it,Ib+" GX"]],[/\bopr\/([\w\.]+)/i],[at,[it,Ib]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[at,[it,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[at,[it,"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],[it,at],[/quark(?:pc)?\/([-\w\.]+)/i],[at,[it,"Quark"]],[/\bddg\/([\w\.]+)/i],[at,[it,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[at,[it,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[at,[it,"WeChat"]],[/konqueror\/([\w\.]+)/i],[at,[it,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[at,[it,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[at,[it,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[at,[it,"Smart "+u9+Ob]],[/(avast|avg)\/([\w\.]+)/i],[[it,/(.+)/,"$1 Secure"+Ob],at],[/\bfocus\/([\w\.]+)/i],[at,[it,Rb+" Focus"]],[/\bopt\/([\w\.]+)/i],[at,[it,Ib+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[at,[it,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[at,[it,"Dolphin"]],[/coast\/([\w\.]+)/i],[at,[it,Ib+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[at,[it,"MIUI"+Ob]],[/fxios\/([\w\.-]+)/i],[at,[it,Tm+Rb]],[/\bqihoobrowser\/?([\w\.]*)/i],[at,[it,"360"]],[/\b(qq)\/([\w\.]+)/i],[[it,/(.+)/,"$1Browser"],at],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[it,/(.+)/,"$1"+Ob],at],[/samsungbrowser\/([\w\.]+)/i],[at,[it,Mb+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[at,[it,p9+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[it,p9+" Mobile"],at],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[it,at],[/(lbbrowser|rekonq)/i],[it],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[at,it],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[it,h9],at,[rt,Ab]],[/(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],[it,at,[rt,Ab]],[/\bgsa\/([\w\.]+) .*safari\//i],[at,[it,"GSA"],[rt,Ab]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[at,[it,"TikTok"],[rt,Ab]],[/\[(linkedin)app\]/i],[it,[rt,Ab]],[/(chromium)[\/ ]([-\w\.]+)/i],[it,at],[/headlesschrome(?:\/([\w\.]+)| )/i],[at,[it,d9+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[it,d9+" WebView"],at],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[at,[it,"Android"+Ob]],[/chrome\/([\w\.]+) mobile/i],[at,[it,Tm+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[it,at],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[at,[it,Tm+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[it,Tm+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[at,it],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[it,[at,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[it,at],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[it,Tm+Rb],at],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[it,"Netscape"],at],[/(wolvic|librewolf)\/([\w\.]+)/i],[it,at],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[at,[it,Rb+" 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],[it,[at,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[it,[at,/[^\d\.]+./,wm]]],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/,wm,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,[ht,Mb],[rt,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,[ht,Mb],[rt,yn]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[st,[ht,Tb],[rt,yn]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[st,[ht,Tb],[rt,Zr]],[/(macintosh);/i],[st,[ht,Tb]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[st,[ht,f9],[rt,yn]],[/(?:honor)([-\w ]+)[;\)]/i],[st,[ht,Mne],[rt,yn]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[st,[ht,l9],[rt,Zr]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[st,[ht,l9],[rt,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," "],[ht,xR],[rt,yn]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[st,/_/g," "],[ht,xR],[rt,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,[ht,"OPPO"],[rt,yn]],[/\b(opd2\d{3}a?) bui/i],[st,[ht,"OPPO"],[rt,Zr]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[st,[ht,"Vivo"],[rt,yn]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[st,[ht,"Realme"],[rt,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,[ht,c9],[rt,yn]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[st,[ht,c9],[rt,Zr]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[st,[ht,_R],[rt,Zr]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[st,[ht,_R],[rt,yn]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[st,[ht,u9],[rt,Zr]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[st,/_/g," "],[ht,"Nokia"],[rt,yn]],[/(pixel c)\b/i],[st,[ht,Vh],[rt,Zr]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[st,[ht,Vh],[rt,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,[ht,Kw],[rt,yn]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[st,"Xperia Tablet"],[ht,Kw],[rt,Zr]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[st,[ht,"OnePlus"],[rt,yn]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[st,[ht,Zw],[rt,Zr]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[st,/(.+)/g,"Fire Phone $1"],[ht,Zw],[rt,yn]],[/(playbook);[-\w\),; ]+(rim)/i],[st,ht,[rt,Zr]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[st,[ht,s9],[rt,yn]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[st,[ht,a9],[rt,Zr]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[st,[ht,a9],[rt,yn]],[/(nexus 9)/i],[st,[ht,"HTC"],[rt,Zr]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[ht,[st,/_/g," "],[rt,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,[ht,"TCL"],[rt,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,[ht,"TCL"],[rt,yn]],[/(itel) ((\w+))/i],[[ht,kc],st,[rt,Lb,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[st,[ht,"Acer"],[rt,Zr]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[st,[ht,"Meizu"],[rt,yn]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[st,[ht,"Ulefone"],[rt,yn]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[st,[ht,"Energizer"],[rt,yn]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[st,[ht,"Cat"],[rt,yn]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[st,[ht,"Smartfren"],[rt,yn]],[/droid.+; (a(?:015|06[35]|142p?))/i],[st,[ht,"Nothing"],[rt,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],[ht,st,[rt,yn]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[ht,st,[rt,Zr]],[/(surface duo)/i],[st,[ht,Qw],[rt,Zr]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[st,[ht,"Fairphone"],[rt,yn]],[/(shield[\w ]+) b/i],[st,[ht,"Nvidia"],[rt,Zr]],[/(sprint) (\w+)/i],[ht,st,[rt,yn]],[/(kin\.[onetw]{3})/i],[[st,/\./g," "],[ht,Qw],[rt,yn]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[st,[ht,SR],[rt,Zr]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[st,[ht,SR],[rt,yn]],[/smart-tv.+(samsung)/i],[ht,[rt,Ho]],[/hbbtv.+maple;(\d+)/i],[[st,/^/,"SmartTV"],[ht,Mb],[rt,Ho]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[ht,_R],[rt,Ho]],[/(apple) ?tv/i],[ht,[st,Tb+" TV"],[rt,Ho]],[/crkey.*devicetype\/chromecast/i],[[st,sd+" Third Generation"],[ht,Vh],[rt,Ho]],[/crkey.*devicetype\/([^/]*)/i],[[st,/^/,"Chromecast "],[ht,Vh],[rt,Ho]],[/fuchsia.*crkey/i],[[st,sd+" Nest Hub"],[ht,Vh],[rt,Ho]],[/crkey/i],[[st,sd],[ht,Vh],[rt,Ho]],[/droid.+aft(\w+)( bui|\))/i],[st,[ht,Zw],[rt,Ho]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[st,[ht,f9],[rt,Ho]],[/(bravia[\w ]+)( bui|\))/i],[st,[ht,Kw],[rt,Ho]],[/(mitv-\w{5}) bui/i],[st,[ht,xR],[rt,Ho]],[/Hbbtv.*(technisat) (.*);/i],[ht,st,[rt,Ho]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[ht,$b],[st,$b],[rt,Ho]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[rt,Ho]],[/(ouya)/i,/(nintendo) (\w+)/i],[ht,st,[rt,Em]],[/droid.+; (shield) bui/i],[st,[ht,"Nvidia"],[rt,Em]],[/(playstation \w+)/i],[st,[ht,Kw],[rt,Em]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[st,[ht,Qw],[rt,Em]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[st,[ht,Mb],[rt,kb]],[/((pebble))app/i],[ht,st,[rt,kb]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[st,[ht,Tb],[rt,kb]],[/droid.+; (wt63?0{2,3})\)/i],[st,[ht,SR],[rt,kb]],[/droid.+; (glass) \d/i],[st,[ht,Vh],[rt,pR]],[/(pico) (4|neo3(?: link|pro)?)/i],[ht,st,[rt,pR]],[/; (quest( \d| pro)?)/i],[st,[ht,h9],[rt,pR]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[ht,[rt,gR]],[/(aeobc)\b/i],[st,[ht,Zw],[rt,gR]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[st,[rt,yn]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[st,[rt,Zr]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[rt,Zr]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[rt,yn]],[/(android[-\w\. ]{0,9});.+buil/i],[st,[ht,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[at,[it,One+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[it,at],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[at,[it,"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],[it,at],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[at,it]],os:[[/microsoft (windows) (vista|xp)/i],[it,at],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[it,[at,Lb,m9]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[at,Lb,m9],[it,wR]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[at,/_/g,"."],[it,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[it,"macOS"],[at,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[at,[it,sd+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[at,[it,sd+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[at,[it,sd+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[at,[it,sd+" Linux"]],[/crkey\/([\d\.]+)/i],[at,[it,sd]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[at,it],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[it,at],[/\(bb(10);/i],[at,[it,s9]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[at,[it,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[at,[it,Rb+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[at,[it,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[at,[it,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[it,"Chrome OS"],at],[/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],[it,at],[/(sunos) ?([\w\.\d]*)/i],[[it,"Solaris"],at],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[it,at]]},Jw=function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return Ac.call(e.init,[[rs,[it,at,Eb,rt]],[Cc,[Oa]],[vu,[rt,st,ht]],[Ec,[it,at]],[Os,[it,at]]]),Ac.call(e.isIgnore,[[rs,[at,Eb]],[Ec,[at]],[Os,[at]]]),Ac.call(e.isIgnoreRgx,[[rs,/ ?browser$/i],[Os,/ ?os$/i]]),Ac.call(e.toString,[[rs,[it,at]],[Cc,[Oa]],[vu,[ht,st]],[Ec,[it,at]],[Os,[it,at]]]),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(o9).then(function(d){return e.setCH(new b9(d,!1)).parseCH().get()}):e.parseCH().get()},u.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Am&&(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=wm;for(var h in s)typeof this[s[h]]!==od&&(d+=(d?" ":wm)+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 b9(e,t){if(e=e||{},Ac.call(this,o9),t)Ac.call(this,[[vR,ER(e[ad])],[yR,ER(e[Sne])],[yn,/\?1/.test(e[kne])],[st,Db(e[Ane])],[km,Db(e[i9])],[bR,Db(e[Tne])],[Oa,Db(e[wne])],[Gh,ER(e[Ene])],[Yw,Db(e[Cne])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==od&&(this[n]=e[n])}function _9(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(it,"Brave");break;case vu:!this.get(rt)&&ld&&ld[yn]&&this.set(rt,yn),this.get(st)=="Macintosh"&&Ra&&typeof Ra.standalone!==od&&Ra.maxTouchPoints&&Ra.maxTouchPoints>2&&this.set(st,"iPad").set(rt,Zr);break;case Os:!this.get(it)&&ld&&ld[km]&&this.set(it,ld[km]);break;case Am:var o=this.data,s=function(u){return o[u].getItem().detectFeature().get()};this.set(rs,s(rs)).set(Cc,s(Cc)).set(vu,s(vu)).set(Ec,s(Ec)).set(Os,s(Os))}return this},this.parseUA=function(){return this.itemType!=Am&&g9.call(this.data,this.ua,this.rgxMap),this.itemType==rs&&this.set(Eb,kR(this.get(at))),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(it,m).set(at,y).set(Eb,kR(y)),d=m)}break;case Cc:var v=o[Oa];v&&(v&&o[Yw]=="64"&&(v+="64"),g9.call(this.data,v+";",s));break;case vu:if(o[yn]&&this.set(rt,yn),o[st]&&this.set(st,o[st]),o[st]=="Xbox"&&this.set(rt,Em).set(ht,Qw),o[Gh]){var x;if(typeof o[Gh]!="string")for(var w=0;!x&&w<o[Gh].length;)x=Lb(o[Gh][w++],v9);else x=Lb(o[Gh],v9);this.set(rt,x)}break;case Os:var E=o[km];if(E){var M=o[bR];E==wR&&(M=parseInt(kR(M),10)>=13?"11":"10"),this.set(it,E).set(at,M)}this.get(it)==wR&&o[st]=="Xbox"&&this.set(it,"Xbox").set(at,void 0);break;case Am:var A=this.data,k=function(I){return A[I].getItem().setCH(o).parseCH().get()};this.set(rs,k(rs)).set(Cc,k(Cc)).set(vu,k(vu)).set(Ec,k(Ec)).set(Os,k(Os))}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===Cm?(Ww(e,!0)?(typeof t===Cm&&(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[r9]?n[r9]:Ra&&Ra.userAgent?Ra.userAgent:wm,s=new b9(n,!0),u=t?Ine(y9,t):y9,d=function(h){return h==Am?function(){return new _9(h,o,u,s).set("ua",o).set(rs,this.getBrowser()).set(Cc,this.getCPU()).set(vu,this.getDevice()).set(Ec,this.getEngine()).set(Os,this.getOS()).get()}:function(){return new _9(h,o,u[h],s).parseUA().get()}};return Ac.call(this,[["getBrowser",d(rs)],["getCPU",d(Cc)],["getDevice",d(vu)],["getEngine",d(Ec)],["getOS",d(Os)],["getResult",d(Am)],["getUA",function(){return o}],["setUA",function(h){return Mm(h)&&(o=h.length>mR?$b(h,mR):h),this}]]).setUA(o),this}Tc.VERSION=xne,Tc.BROWSER=Xw([it,at,Eb,rt]),Tc.CPU=Xw([Oa]),Tc.DEVICE=Xw([st,ht,rt,Em,yn,Ho,Zr,kb,gR]),Tc.ENGINE=Tc.OS=Xw([it,at]);const Is=class Is{constructor(t){ro(this,"config");ro(this,"storedData");ro(this,"deviceInfo");ro(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){Is.instance||(Is.instance=new Is(t))}static getInstance(){if(!Is.instance)throw new Error("DebalesAnalytics is not initialized. Call init() first.");return Is.instance}static async identify(t,n){return Is.getInstance().identifyInternal(t,n)}static track(t,n){Is.getInstance().trackInternal(t,n)}static getDistinctId(){return Is.getInstance().storedData.distinctId}static getAnonId(){return Is.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:nr()+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}}};ro(Is,"instance",null);let AR=Is;const yu=AR;function $ne(e){E6(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"},cr={OPEN_STATE_CHANGE:"open_state_change"},tC=e=>{window.DebalesChat||(window.DebalesChat={isOpen:!1,projectId:e,getSessionId:()=>nr(),getChatId:()=>nr()+"_"+e,getAnonId:()=>yu.getAnonId(),isIdentified:()=>{if(Es._isIdentified())return!0;const t=yo();return!!(t&&t.email)},getIdentifiedUser:()=>yo(),getDistinctId:()=>Es.get_distinct_id(),getOldDistinctId:()=>yu.getDistinctId(),debug:!1,identify:(t,n)=>{Es._isIdentified()||Es.identify(t,{...n,project:e}),yu.identify(t,n),wc({email:t,name:n==null?void 0:n.name,phone:n==null?void 0:n.phone})},track:(t,n)=>{yu.track(t,{...n,sessionId:window.DebalesChat.getSessionId()}),Es.capture(t,{...n}),yne(t,{...n,sessionId:nr(),projectId:e})},onOpenChange:t=>{const n=r=>{t(r.detail.isOpen)};return window.addEventListener(cr.OPEN_STATE_CHANGE,n),()=>window.removeEventListener(cr.OPEN_STATE_CHANGE,n)},removeOpenChangeListener:t=>{const n=r=>{t(r.detail.isOpen)};window.removeEventListener(cr.OPEN_STATE_CHANGE,n)},open:()=>{window.DebalesChat.isOpen||window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:!0,projectId:e}}))},close:()=>{window.DebalesChat.isOpen&&window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:!1,projectId:e}}))},toggle:()=>{window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:!window.DebalesChat.isOpen,projectId:e}}))}})};var _o=(e=>(e.DEFAULT="DEFAULT",e.SHOPIFY="SHOPIFY",e.WOOCOMMERCE="WOOCOMMERCE",e.MAGENTO="MAGENTO",e.UNKNOWN="UNKNOWN",e))(_o||{});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 _o.SHOPIFY;if(typeof window<"u"&&document.body.classList.contains("woocommerce"))return _o.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 _o.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 _o.MAGENTO;if(document.cookie.split(";").some(v=>v.trim().startsWith("mage-")||v.trim().startsWith("form_key")))return _o.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 _o.MAGENTO}return _o.UNKNOWN}}const nC=F.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
|
-
`,SU=({botId:e})=>{var ii,ve;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:I,isUserInfoNeeded:D,setPendingQuestion:L}=Om(),{cart:B,addToCart:H,generateCartUrl:Q,addCartAttributes:J}=Cb(),W=$h("use-chatbot-icon-size"),Y=ud.detect(),se=t==null?void 0:t.isLeft,fe=oC(),xe=t==null?void 0:t.heightOption,[ae,ye]=X.useState(!1);X.useEffect(()=>{const ee=()=>{ye(window.matchMedia("(max-width: 768px)").matches)};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]);const[Z,oe]=Ke.useState(!1),[me,qe]=Ke.useState(!1),[U,$e]=X.useState(""),[Ie,P]=X.useState(""),[,Xe]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let ee=yo();if(!ee&&window.Thinkific){const Be=window.Thinkific.current_user;Be&&(ee={name:Be.full_name,email:Be.email},wc(ee))}yu.init({projectName:e,debug:!0,testing:wb}),ee&&ee.email&&(window.DebalesChat.identify(ee.email,{name:ee.name,phone:ee.phone,email:ee.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:ee.email,first_name:ee.name,phone:ee.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const _t=Ke.useRef(null),Pe=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[zt,Et]=X.useState(()=>{try{const ee=sessionStorage.getItem(Pe);return ee?new Set(JSON.parse(ee)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(Pe,JSON.stringify(Array.from(zt)))}catch(ee){console.error("Failed to save to sessionStorage:",ee)}},[zt]);const $t=X.useCallback((ee,Be)=>{ee?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:ee,source:Be,projectId:e}})),setTimeout(()=>{qe(!0)},50)):(qe(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:ee,source:Be,projectId:e}})))},[]);X.useEffect(()=>{const ee=Be=>{oe(Be.detail.isOpen),Be.detail.isOpen&&setTimeout(()=>qe(!0),50),window.DebalesChat.isOpen=Be.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:Be.detail.isOpen,source:Be.detail.source})};return window.addEventListener(cr.OPEN_STATE_CHANGE,ee),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,ee)}},[]),X.useEffect(()=>{const ee=Be=>{oe(Be.detail.isOpen),window.DebalesChat.isOpen=Be.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:Be.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,ee),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,ee)}},[]);const[Ut,dt]=Ke.useState(!1),[Ge,ct]=Ke.useState(()=>{const ee=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),Be=sessionStorage.getItem(ee);return Be?JSON.parse(Be):[]});Ke.useEffect(()=>{const ee=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(ee,JSON.stringify(Ge))},[Ge,e]);const[St,Mt]=X.useState(!1),[pt,ut]=X.useState({name:"",email:"",message:""}),G=jf("exit_model"),[K,le]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Re,Ne]=X.useState({suggestions:!1,products:!1,collections:!1,leadingQueries:!1,initialMessage:!1,cartSummary:!1,bulkItems:!1}),[Ze,vt]=X.useState(!1),[kt,pe]=X.useState(!0),[Me,ft]=X.useState(!1),[xt,Ot]=X.useState(!1),nn=2e3,wn=X.useCallback(ee=>{const Be=ee.target,et=Be.scrollHeight-Be.scrollTop<=Be.clientHeight+0;pe(et)},[]);Ke.useEffect(()=>{var ee,Be,et,Ae,Ue,wt;if(h.length>0&&!m){const Qt=h[h.length-1],de=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),te=Qt.isBot&&Qt.conversationId===u&&Qt.conversationId!==de,Te=(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0&&Qt.conversationId===u;if(te){vt(!0),Ne(tt=>({...tt,initialMessage:!0})),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),Qt.conversationId||""),le({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const he=1600;let Je=he;const We=[{type:"collections",condition:((ee=Qt.collections)==null?void 0:ee.length)&&((Be=Qt.collections)==null?void 0:Be.length)>0},{type:"products",condition:((et=Qt.products)==null?void 0:et.length)&&((Ae=Qt.products)==null?void 0:Ae.length)>0},{type:"leadingQueries",condition:h.length>=1&&((Ue=Qt.leading_queries)==null?void 0:Ue.length)&&((wt=Qt.leading_queries)==null?void 0:wt.length)>0},{type:"cartSummary",condition:(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0},{type:"bulkItems",condition:(Ge==null?void 0:Ge.length)>0}].filter(tt=>tt.condition);if(We.length===0){vt(!1),Ne(tt=>({...tt,initialMessage:!1,leadingQueries:!1}));return}We.forEach(({type:tt},Lt)=>{setTimeout(()=>{if(Ne(bn=>({...bn,[tt]:!0})),le(bn=>({...bn,[tt]:!0})),kt&&_t.current){const bn=_t.current;bn.scrollHeight-bn.scrollTop<=bn.clientHeight&&jo(_t)}Lt===We.length-1&&vt(!1)},Je),Je+=he})}else Te&&le(he=>({...he,cartSummary:!0}))}},[h,m,u,B==null?void 0:B.itemCount,Ge==null?void 0:Ge.length,kt,e,K]),Ke.useEffect(()=>{if(!o&&h.length>0){const ee=_t.current;ee&&kt&&ee.scrollHeight-ee.scrollTop<=ee.clientHeight+100&&setTimeout(()=>jo(_t),100)}},[h.length,o,kt]),Ke.useEffect(()=>{const ee=document.querySelector('meta[name="viewport"]'),Be=ee==null?void 0:ee.content;if(Z){let et=ee;const Ae=window.matchMedia("(max-width: 768px)").matches;et?et.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(et=document.createElement("meta"),et.name="viewport",et.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(et)),Ae&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ue=et;return()=>{Be&&Ue&&(Ue.content=Be),Ae&&(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]),Ke.useEffect(()=>{const ee=setTimeout(()=>{dt(!0)},1e3);return()=>clearTimeout(ee)},[]),Ke.useEffect(()=>{o||setTimeout(()=>jo(_t),100)},[h.length,o]),Ke.useEffect(()=>{B!=null&&B.itemCount&&B.itemCount===0&&!o&&setTimeout(()=>jo(_t),100)},[B==null?void 0:B.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Jt=Ke.useRef(Date.now()),hn=Ke.useRef(0),Rt=Ke.useRef(window.location.pathname),Vt=Ke.useRef(M),gt=Ke.useRef(!1),It=jf("acquisition_agent");Ke.useEffect(()=>{Vt.current=M},[M]);const fr=Ke.useCallback(async()=>{const ee=Date.now();if(ee-Jt.current>=6e3&&ee-hn.current>=6e4&&!gt.current)try{gt.current=!0,console.log("fetching acquisition data");const Ae=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(Ae.ok){const Ue=await Ae.json(),Qt=[...Vt.current.filter(de=>de.path!==Rt.current),{question:Ue.Popup_Message,answer:"",path:Rt.current,nameSpace:e,type:"dynamic",Follow_up_Question:Ue.Follow_up_Question}];A(Qt)}hn.current=ee}catch(Ae){console.error("Error fetching acquisition data:",Ae)}finally{gt.current=!1}},[e]);Ke.useEffect(()=>{if(!It||(t==null?void 0:t.show_bot)===!1)return;const ee=()=>{Jt.current=Date.now()};document.addEventListener("mousemove",ee),document.addEventListener("mousedown",ee),document.addEventListener("keypress",ee),document.addEventListener("scroll",ee),document.addEventListener("touchstart",ee),document.addEventListener("touchmove",ee);const Be=setInterval(fr,1e3),et=()=>{const Ue=window.location.pathname.split("?")[0],wt=Rt.current.split("?")[0];(()=>{const de=wt.split("/").filter(Boolean),te=Ue.split("/").filter(Boolean);return de.length!==te.length?!0:de.length===0&&te.length===0?!1:Ue!==wt})()&&(Rt.current=Ue,Jt.current=Date.now())};return window.addEventListener("popstate",et),()=>{document.removeEventListener("mousemove",ee),document.removeEventListener("mousedown",ee),document.removeEventListener("keypress",ee),document.removeEventListener("scroll",ee),document.removeEventListener("touchstart",ee),document.removeEventListener("touchmove",ee),window.removeEventListener("popstate",et),clearInterval(Be)}},[It,fr,t==null?void 0:t.show_bot]);const[Er,yr]=X.useState(!1),[_r,Ii]=X.useState(!1),[Di,bi]=X.useState(null),xr=async ee=>{const Be=nr();if(qe(!1),ee&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Be,userRating:ee,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(et){console.error("Error submitting rating:",et)}setTimeout(()=>{Ii(!1),$t(!1,"close_button_clicked")},1e3)},$i=ee=>{y(!0),Ge.forEach(et=>{H(et.id,et.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:Ge,message:ee});const Be=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:ee,isBot:!0}];v(Be),x(Be),d(ee),ct([]),y(!1)},Ia=()=>{var ee;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((ee=window.shiprocketCheckoutEvents)!=null&&ee.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1},oo=async ee=>{ee.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(B==null?void 0:B.total),cart:B}),J({dbls_method:"checkout_clicked"}),Ia()&&$t(!1,"checkout_clicked")},[Wn,ar]=X.useState([]);Ke.useEffect(()=>{const ee=_ne(Fw(M));ar(ee)},[M]);const Ln=Ke.useMemo(()=>Wn.map(ee=>{if(Array.isArray(ee)){const Be=ee.filter(Ae=>!zt.has(Ae.question));if(Be.length===0)return null;const et={isHighlighted:ee[0].isHighlighted,enable:ee[0].enable,type:ee[0].type};return Be.map(Ae=>({...Ae,...et}))}else return zt.has(ee.question)?null:ee}).filter(Boolean),[Wn,zt]);Ke.useEffect(()=>{const ee=Ae=>{const Ue=Ae.detail.formId;switch(Ae.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Qt=Be(Ue);Qt&&$e(Qt)},800);break;case"close":U&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{$t(!0,"klaviyo_form_closed"),P(Ue),r(U,void 0,void 0,!0,void 0,void 0)},1e4);break}},Be=Ae=>{const Ue=document.querySelector(`[data-testid="klaviyo-form-${Ae}"]`);if(console.log(`formElement text ${Ae} =>`,Ue==null?void 0:Ue.innerText,Ue==null?void 0:Ue.textContent),Ue instanceof HTMLElement){const wt=Ue.innerText||Ue.textContent;if(wt)return console.log("Found form text:",wt),`=> Klaviyo form content:
|
|
2309
|
+
`,SU=({botId:e})=>{var ii,ve;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:I,isUserInfoNeeded:D,setPendingQuestion:L}=Om(),{cart:B,addToCart:H,generateCartUrl:Q,addCartAttributes:J}=Cb(),W=$h("use-chatbot-icon-size"),Y=ud.detect(),se=t==null?void 0:t.isLeft,fe=oC(),xe=t==null?void 0:t.heightOption,[ae,ye]=X.useState(!1);X.useEffect(()=>{const ee=()=>{ye(window.matchMedia("(max-width: 768px)").matches)};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]);const[Z,oe]=Ke.useState(!1),[me,qe]=Ke.useState(!1),[U,$e]=X.useState(""),[Ie,P]=X.useState(""),[,Xe]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let ee=yo();if(!ee&&window.Thinkific){const Be=window.Thinkific.current_user;Be&&(ee={name:Be.full_name,email:Be.email},wc(ee))}yu.init({projectName:e,debug:!1,testing:wb}),ee&&ee.email&&(window.DebalesChat.identify(ee.email,{name:ee.name,phone:ee.phone,email:ee.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:ee.email,first_name:ee.name,phone:ee.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const _t=Ke.useRef(null),Pe=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[zt,Et]=X.useState(()=>{try{const ee=sessionStorage.getItem(Pe);return ee?new Set(JSON.parse(ee)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(Pe,JSON.stringify(Array.from(zt)))}catch(ee){console.error("Failed to save to sessionStorage:",ee)}},[zt]);const $t=X.useCallback((ee,Be)=>{ee?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:ee,source:Be,projectId:e}})),setTimeout(()=>{qe(!0)},50)):(qe(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:ee,source:Be,projectId:e}})))},[]);X.useEffect(()=>{const ee=Be=>{oe(Be.detail.isOpen),Be.detail.isOpen&&setTimeout(()=>qe(!0),50),window.DebalesChat.isOpen=Be.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:Be.detail.isOpen,source:Be.detail.source})};return window.addEventListener(cr.OPEN_STATE_CHANGE,ee),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,ee)}},[]),X.useEffect(()=>{const ee=Be=>{oe(Be.detail.isOpen),window.DebalesChat.isOpen=Be.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:Be.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,ee),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,ee)}},[]);const[Ut,dt]=Ke.useState(!1),[Ge,ct]=Ke.useState(()=>{const ee=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),Be=sessionStorage.getItem(ee);return Be?JSON.parse(Be):[]});Ke.useEffect(()=>{const ee=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(ee,JSON.stringify(Ge))},[Ge,e]);const[St,Mt]=X.useState(!1),[pt,ut]=X.useState({name:"",email:"",message:""}),G=jf("exit_model"),[K,le]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Re,Ne]=X.useState({suggestions:!1,products:!1,collections:!1,leadingQueries:!1,initialMessage:!1,cartSummary:!1,bulkItems:!1}),[Ze,vt]=X.useState(!1),[kt,pe]=X.useState(!0),[Me,ft]=X.useState(!1),[xt,Ot]=X.useState(!1),nn=2e3,wn=X.useCallback(ee=>{const Be=ee.target,et=Be.scrollHeight-Be.scrollTop<=Be.clientHeight+0;pe(et)},[]);Ke.useEffect(()=>{var ee,Be,et,Ae,Ue,wt;if(h.length>0&&!m){const Qt=h[h.length-1],de=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),te=Qt.isBot&&Qt.conversationId===u&&Qt.conversationId!==de,Te=(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0&&Qt.conversationId===u;if(te){vt(!0),Ne(tt=>({...tt,initialMessage:!0})),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),Qt.conversationId||""),le({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const he=1600;let Je=he;const We=[{type:"collections",condition:((ee=Qt.collections)==null?void 0:ee.length)&&((Be=Qt.collections)==null?void 0:Be.length)>0},{type:"products",condition:((et=Qt.products)==null?void 0:et.length)&&((Ae=Qt.products)==null?void 0:Ae.length)>0},{type:"leadingQueries",condition:h.length>=1&&((Ue=Qt.leading_queries)==null?void 0:Ue.length)&&((wt=Qt.leading_queries)==null?void 0:wt.length)>0},{type:"cartSummary",condition:(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0},{type:"bulkItems",condition:(Ge==null?void 0:Ge.length)>0}].filter(tt=>tt.condition);if(We.length===0){vt(!1),Ne(tt=>({...tt,initialMessage:!1,leadingQueries:!1}));return}We.forEach(({type:tt},Lt)=>{setTimeout(()=>{if(Ne(bn=>({...bn,[tt]:!0})),le(bn=>({...bn,[tt]:!0})),kt&&_t.current){const bn=_t.current;bn.scrollHeight-bn.scrollTop<=bn.clientHeight&&jo(_t)}Lt===We.length-1&&vt(!1)},Je),Je+=he})}else Te&&le(he=>({...he,cartSummary:!0}))}},[h,m,u,B==null?void 0:B.itemCount,Ge==null?void 0:Ge.length,kt,e,K]),Ke.useEffect(()=>{if(!o&&h.length>0){const ee=_t.current;ee&&kt&&ee.scrollHeight-ee.scrollTop<=ee.clientHeight+100&&setTimeout(()=>jo(_t),100)}},[h.length,o,kt]),Ke.useEffect(()=>{const ee=document.querySelector('meta[name="viewport"]'),Be=ee==null?void 0:ee.content;if(Z){let et=ee;const Ae=window.matchMedia("(max-width: 768px)").matches;et?et.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(et=document.createElement("meta"),et.name="viewport",et.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(et)),Ae&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ue=et;return()=>{Be&&Ue&&(Ue.content=Be),Ae&&(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]),Ke.useEffect(()=>{const ee=setTimeout(()=>{dt(!0)},1e3);return()=>clearTimeout(ee)},[]),Ke.useEffect(()=>{o||setTimeout(()=>jo(_t),100)},[h.length,o]),Ke.useEffect(()=>{B!=null&&B.itemCount&&B.itemCount===0&&!o&&setTimeout(()=>jo(_t),100)},[B==null?void 0:B.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Jt=Ke.useRef(Date.now()),hn=Ke.useRef(0),Rt=Ke.useRef(window.location.pathname),Vt=Ke.useRef(M),gt=Ke.useRef(!1),It=jf("acquisition_agent");Ke.useEffect(()=>{Vt.current=M},[M]);const fr=Ke.useCallback(async()=>{const ee=Date.now();if(ee-Jt.current>=6e3&&ee-hn.current>=6e4&&!gt.current)try{gt.current=!0,console.log("fetching acquisition data");const Ae=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(Ae.ok){const Ue=await Ae.json(),Qt=[...Vt.current.filter(de=>de.path!==Rt.current),{question:Ue.Popup_Message,answer:"",path:Rt.current,nameSpace:e,type:"dynamic",Follow_up_Question:Ue.Follow_up_Question}];A(Qt)}hn.current=ee}catch(Ae){console.error("Error fetching acquisition data:",Ae)}finally{gt.current=!1}},[e]);Ke.useEffect(()=>{if(!It||(t==null?void 0:t.show_bot)===!1)return;const ee=()=>{Jt.current=Date.now()};document.addEventListener("mousemove",ee),document.addEventListener("mousedown",ee),document.addEventListener("keypress",ee),document.addEventListener("scroll",ee),document.addEventListener("touchstart",ee),document.addEventListener("touchmove",ee);const Be=setInterval(fr,1e3),et=()=>{const Ue=window.location.pathname.split("?")[0],wt=Rt.current.split("?")[0];(()=>{const de=wt.split("/").filter(Boolean),te=Ue.split("/").filter(Boolean);return de.length!==te.length?!0:de.length===0&&te.length===0?!1:Ue!==wt})()&&(Rt.current=Ue,Jt.current=Date.now())};return window.addEventListener("popstate",et),()=>{document.removeEventListener("mousemove",ee),document.removeEventListener("mousedown",ee),document.removeEventListener("keypress",ee),document.removeEventListener("scroll",ee),document.removeEventListener("touchstart",ee),document.removeEventListener("touchmove",ee),window.removeEventListener("popstate",et),clearInterval(Be)}},[It,fr,t==null?void 0:t.show_bot]);const[Er,yr]=X.useState(!1),[_r,Ii]=X.useState(!1),[Di,bi]=X.useState(null),xr=async ee=>{const Be=nr();if(qe(!1),ee&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Be,userRating:ee,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(et){console.error("Error submitting rating:",et)}setTimeout(()=>{Ii(!1),$t(!1,"close_button_clicked")},1e3)},$i=ee=>{y(!0),Ge.forEach(et=>{H(et.id,et.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:Ge,message:ee});const Be=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:ee,isBot:!0}];v(Be),x(Be),d(ee),ct([]),y(!1)},Ia=()=>{var ee;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((ee=window.shiprocketCheckoutEvents)!=null&&ee.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1},oo=async ee=>{ee.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(B==null?void 0:B.total),cart:B}),J({dbls_method:"checkout_clicked"}),Ia()&&$t(!1,"checkout_clicked")},[Wn,ar]=X.useState([]);Ke.useEffect(()=>{const ee=_ne(Fw(M));ar(ee)},[M]);const Ln=Ke.useMemo(()=>Wn.map(ee=>{if(Array.isArray(ee)){const Be=ee.filter(Ae=>!zt.has(Ae.question));if(Be.length===0)return null;const et={isHighlighted:ee[0].isHighlighted,enable:ee[0].enable,type:ee[0].type};return Be.map(Ae=>({...Ae,...et}))}else return zt.has(ee.question)?null:ee}).filter(Boolean),[Wn,zt]);Ke.useEffect(()=>{const ee=Ae=>{const Ue=Ae.detail.formId;switch(Ae.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Qt=Be(Ue);Qt&&$e(Qt)},800);break;case"close":U&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{$t(!0,"klaviyo_form_closed"),P(Ue),r(U,void 0,void 0,!0,void 0,void 0)},1e4);break}},Be=Ae=>{const Ue=document.querySelector(`[data-testid="klaviyo-form-${Ae}"]`);if(console.log(`formElement text ${Ae} =>`,Ue==null?void 0:Ue.innerText,Ue==null?void 0:Ue.textContent),Ue instanceof HTMLElement){const wt=Ue.innerText||Ue.textContent;if(wt)return console.log("Found form text:",wt),`=> Klaviyo form content:
|
|
2310
2310
|
|
|
2311
2311
|
`+wt+`
|
|
2312
2312
|
|
|
@@ -3152,7 +3152,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3152
3152
|
margin-top: 16px;
|
|
3153
3153
|
display: flex;
|
|
3154
3154
|
justify-content: flex-end;
|
|
3155
|
-
`,Jse=({botId:e})=>{var yt,ii;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,showUserInfoModel:A,setShowUserInfoModel:k,isUserInfoNeeded:I,setPendingQuestion:D}=Om(),{cart:L,addToCart:B,generateCartUrl:H,addCartAttributes:Q}=Cb(),J=$h("use-chatbot-icon-size"),W=ud.detect(),Y=t==null?void 0:t.isLeft,se=oC(),fe=t==null?void 0:t.heightOption,ae=$h("new-suggested-question-design"),[ye,Z]=X.useState(!1),[oe,me]=X.useState(!1),[qe,U]=X.useState(!1),[$e,Ie]=X.useState([]),P=X.useCallback(async()=>{try{const ve=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(ve.ok){const ee=await ve.json(),Be=window.location.pathname,et=3,Ae=[...$e],Ue={question:ee.Popup_Message,answer:"",path:Be,nameSpace:e,type:"dynamic",Follow_up_Question:ee.Follow_up_Question};Ae.length>=et&&Ae.shift(),Ae.push(Ue),Ie(Ae),console.log("updated quesitons",Ae)}else console.error("Failed to fetch new acquisition question")}catch(ve){console.error("Error fetching new acquisition question:",ve)}},[e,$e]);X.useEffect(()=>{if(!ae)return;let ve,ee,Be,et;const Ae=()=>{ve=setTimeout(()=>{Z(!0),ee=setTimeout(()=>{U(!0),me(!0),Be=setTimeout(async()=>{U(!1),me(!1),await P(),et=setTimeout(()=>{U(!0),Z(!0),me(!0),Ae()},ae.hide_timing||4e3)},ae.show_for||44324)},ae.showing_delay||2e3)},ae.showing_delay||2e3)};return Ae(),()=>{console.log("[Debug] Cleaning up timers"),clearTimeout(ve),clearTimeout(ee),clearTimeout(Be),clearTimeout(et)}},[ae,P]);const[Xe,_t]=X.useState(!1);X.useEffect(()=>{const ve=()=>{_t(window.matchMedia("(max-width: 768px)").matches)};return ve(),window.addEventListener("resize",ve),()=>window.removeEventListener("resize",ve)},[]);const[Pe,zt]=Ke.useState(!1),[Et,$t]=Ke.useState(!1),[Ut,dt]=X.useState(""),[Ge,ct]=X.useState(""),[,St]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let ve=yo();if(!ve&&window.Thinkific){const ee=window.Thinkific.current_user;ee&&(ve={name:ee.full_name,email:ee.email},wc(ve))}yu.init({projectName:e,debug:!
|
|
3155
|
+
`,Jse=({botId:e})=>{var yt,ii;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,showUserInfoModel:A,setShowUserInfoModel:k,isUserInfoNeeded:I,setPendingQuestion:D}=Om(),{cart:L,addToCart:B,generateCartUrl:H,addCartAttributes:Q}=Cb(),J=$h("use-chatbot-icon-size"),W=ud.detect(),Y=t==null?void 0:t.isLeft,se=oC(),fe=t==null?void 0:t.heightOption,ae=$h("new-suggested-question-design"),[ye,Z]=X.useState(!1),[oe,me]=X.useState(!1),[qe,U]=X.useState(!1),[$e,Ie]=X.useState([]),P=X.useCallback(async()=>{try{const ve=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(ve.ok){const ee=await ve.json(),Be=window.location.pathname,et=3,Ae=[...$e],Ue={question:ee.Popup_Message,answer:"",path:Be,nameSpace:e,type:"dynamic",Follow_up_Question:ee.Follow_up_Question};Ae.length>=et&&Ae.shift(),Ae.push(Ue),Ie(Ae),console.log("updated quesitons",Ae)}else console.error("Failed to fetch new acquisition question")}catch(ve){console.error("Error fetching new acquisition question:",ve)}},[e,$e]);X.useEffect(()=>{if(!ae)return;let ve,ee,Be,et;const Ae=()=>{ve=setTimeout(()=>{Z(!0),ee=setTimeout(()=>{U(!0),me(!0),Be=setTimeout(async()=>{U(!1),me(!1),await P(),et=setTimeout(()=>{U(!0),Z(!0),me(!0),Ae()},ae.hide_timing||4e3)},ae.show_for||44324)},ae.showing_delay||2e3)},ae.showing_delay||2e3)};return Ae(),()=>{console.log("[Debug] Cleaning up timers"),clearTimeout(ve),clearTimeout(ee),clearTimeout(Be),clearTimeout(et)}},[ae,P]);const[Xe,_t]=X.useState(!1);X.useEffect(()=>{const ve=()=>{_t(window.matchMedia("(max-width: 768px)").matches)};return ve(),window.addEventListener("resize",ve),()=>window.removeEventListener("resize",ve)},[]);const[Pe,zt]=Ke.useState(!1),[Et,$t]=Ke.useState(!1),[Ut,dt]=X.useState(""),[Ge,ct]=X.useState(""),[,St]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let ve=yo();if(!ve&&window.Thinkific){const ee=window.Thinkific.current_user;ee&&(ve={name:ee.full_name,email:ee.email},wc(ve))}yu.init({projectName:e,debug:!1,testing:wb}),ve&&ve.email&&(window.DebalesChat.identify(ve.email,{name:ve.name,phone:ve.phone,email:ve.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:ve.email,first_name:ve.name,phone:ve.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const Mt=Ke.useRef(null),pt=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[ut,G]=X.useState(()=>{try{const ve=sessionStorage.getItem(pt);return ve?new Set(JSON.parse(ve)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(pt,JSON.stringify(Array.from(ut)))}catch(ve){console.error("Failed to save to sessionStorage:",ve)}},[ut]);const K=X.useCallback((ve,ee)=>{ve?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:ve,source:ee,projectId:e}})),setTimeout(()=>{$t(!0)},50)):($t(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:ve,source:ee,projectId:e}})))},[]);X.useEffect(()=>{const ve=ee=>{zt(ee.detail.isOpen),ee.detail.isOpen&&setTimeout(()=>$t(!0),50),window.DebalesChat.isOpen=ee.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ee.detail.isOpen,source:ee.detail.source})};return window.addEventListener(cr.OPEN_STATE_CHANGE,ve),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,ve)}},[]),X.useEffect(()=>{const ve=ee=>{zt(ee.detail.isOpen),window.DebalesChat.isOpen=ee.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:ee.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,ve),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,ve)}},[]);const[le,Re]=Ke.useState(()=>{const ve=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),ee=sessionStorage.getItem(ve);return ee?JSON.parse(ee):[]});Ke.useEffect(()=>{const ve=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(ve,JSON.stringify(le))},[le,e]);const[Ne,Ze]=X.useState(!1),[vt,kt]=X.useState({name:"",email:"",message:""}),pe=jf("exit_model"),[Me,ft]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[xt,Ot]=X.useState(!1),[nn,wn]=X.useState(!0),[Jt,hn]=X.useState(!1),[Rt,Vt]=X.useState(!1),gt=500,It=X.useCallback(ve=>{const ee=ve.target,Be=ee.scrollHeight-ee.scrollTop<=ee.clientHeight+0;wn(Be)},[]);Ke.useEffect(()=>{var ve,ee,Be,et,Ae,Ue;if(h.length>0&&!m){const wt=h[h.length-1],Qt=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),de=wt.isBot&&wt.conversationId===u&&wt.conversationId!==Qt,te=(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0&&wt.conversationId===u;if(de){Ot(!0),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),wt.conversationId||""),ft({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const Te=1600;let he=Te;const Je=[{type:"collections",condition:((ve=wt.collections)==null?void 0:ve.length)&&((ee=wt.collections)==null?void 0:ee.length)>0},{type:"products",condition:((Be=wt.products)==null?void 0:Be.length)&&((et=wt.products)==null?void 0:et.length)>0},{type:"leadingQueries",condition:((Ae=wt.leading_queries)==null?void 0:Ae.length)&&((Ue=wt.leading_queries)==null?void 0:Ue.length)>0},{type:"cartSummary",condition:(L==null?void 0:L.itemCount)&&(L==null?void 0:L.itemCount)>0},{type:"bulkItems",condition:(le==null?void 0:le.length)>0}].filter(We=>We.condition);if(Je.length===0){Ot(!1);return}Je.forEach(({type:We},tt)=>{setTimeout(()=>{if(ft(Lt=>({...Lt,[We]:!0})),nn&&Mt.current){const Lt=Mt.current;Lt.scrollHeight-Lt.scrollTop<=Lt.clientHeight&&jo(Mt)}tt===Je.length-1&&Ot(!1)},he),he+=Te})}else te&&ft(Te=>({...Te,cartSummary:!0}))}},[h,m,u,L==null?void 0:L.itemCount,le==null?void 0:le.length,nn,e]),Ke.useEffect(()=>{if(!o&&h.length>0){const ve=Mt.current;ve&&nn&&ve.scrollHeight-ve.scrollTop<=ve.clientHeight+100&&setTimeout(()=>jo(Mt),100)}},[h.length,o,nn]),Ke.useEffect(()=>{const ve=document.querySelector('meta[name="viewport"]'),ee=ve==null?void 0:ve.content;if(Pe){let Be=ve;const et=window.matchMedia("(max-width: 768px)").matches;Be?Be.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(Be=document.createElement("meta"),Be.name="viewport",Be.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(Be)),et&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Ae=Be;return()=>{ee&&Ae&&(Ae.content=ee),et&&(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="")}},[Pe,t==null?void 0:t.mobileDisplayMode]),Ke.useEffect(()=>{o||setTimeout(()=>jo(Mt),100)},[h.length,o]),Ke.useEffect(()=>{L!=null&&L.itemCount&&L.itemCount===0&&!o&&setTimeout(()=>jo(Mt),100)},[L==null?void 0:L.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const[fr,Er]=X.useState(!1),[yr,_r]=X.useState(!1),[Ii,Di]=X.useState(null),bi=async ve=>{const ee=nr();if($t(!1),ve&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:ee,userRating:ve,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(Be){console.error("Error submitting rating:",Be)}setTimeout(()=>{_r(!1),K(!1,"close_button_clicked")},1e3)},xr=ve=>{y(!0),le.forEach(Be=>{B(Be.id,Be.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:le,message:ve});const ee=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:ve,isBot:!0}];v(ee),x(ee),d(ve),Re([]),y(!1)},$i=()=>{var ve;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((ve=window.shiprocketCheckoutEvents)!=null&&ve.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=H((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=H((t==null?void 0:t.shopifyShopDomain)??""),!1},Ia=async ve=>{ve.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(L==null?void 0:L.total),cart:L}),Q({dbls_method:"checkout_clicked"}),$i()&&K(!1,"checkout_clicked")};Ke.useEffect(()=>{const ve=Fw(M);Ie(ee=>[...ve.filter(et=>!ee.some(Ae=>Ae.question===et.question))])},[M]);const oo=Ke.useMemo(()=>$e.map(ve=>({...ve,isClicked:ut.has(ve.question)})),[$e,ut]);Ke.useEffect(()=>{const ve=et=>{const Ae=et.detail.formId;switch(et.detail.type){case"open":case"embedOpen":setTimeout(()=>{const wt=ee(Ae);wt&&dt(wt)},800);break;case"close":Ut&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{K(!0,"klaviyo_form_closed"),ct(Ae),r(Ut,void 0,void 0,!0)},1e4);break}},ee=et=>{const Ae=document.querySelector(`[data-testid="klaviyo-form-${et}"]`);if(console.log(`formElement text ${et} =>`,Ae==null?void 0:Ae.innerText,Ae==null?void 0:Ae.textContent),Ae instanceof HTMLElement){const Ue=Ae.innerText||Ae.textContent;if(Ue)return console.log("Found form text:",Ue),`=> Klaviyo form content:
|
|
3156
3156
|
|
|
3157
3157
|
`+Ue+`
|
|
3158
3158
|
|
|
@@ -3978,7 +3978,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3978
3978
|
margin-top: 16px;
|
|
3979
3979
|
display: flex;
|
|
3980
3980
|
justify-content: flex-end;
|
|
3981
|
-
`,$le=({botId:e})=>{var Qt,de;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:I,isUserInfoNeeded:D,setPendingQuestion:L}=Om(),{cart:B,addToCart:H,generateCartUrl:Q,addCartAttributes:J}=Cb(),W=$h("use-chatbot-icon-size"),Y=ud.detect(),se=t==null?void 0:t.isLeft,fe=oC(),xe=t==null?void 0:t.heightOption,ye=$h("new-suggested-question-design"),[Z,oe]=X.useState(!1),[me,qe]=X.useState(!1),[U,$e]=X.useState(!1);X.useEffect(()=>{if(!ye)return;const te=setTimeout(()=>{oe(!0);const Te=setTimeout(()=>{$e(!0),qe(!0);const he=setTimeout(()=>{$e(!1),oe(!1),qe(!1);const Je=setTimeout(()=>{$e(!0),oe(!0),qe(!0)},ye.hide_timing||4e3);return()=>clearTimeout(Je)},ye.show_for||44324);return()=>clearTimeout(he)},ye.showing_delay||2e3);return()=>clearTimeout(Te)},ye.showing_delay||2e3);return()=>clearTimeout(te)},[ye]);const[Ie,P]=X.useState(!1);X.useEffect(()=>{const te=()=>{P(window.matchMedia("(max-width: 768px)").matches)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]);const[Xe,_t]=Ke.useState(!1),[Pe,zt]=Ke.useState(!1),[Et,$t]=X.useState(""),[Ut,dt]=X.useState(""),[,Ge]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let te=yo();if(!te&&window.Thinkific){const Te=window.Thinkific.current_user;Te&&(te={name:Te.full_name,email:Te.email},wc(te))}yu.init({projectName:e,debug:!0,testing:wb}),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 ct=Ke.useRef(null),St=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[Mt,pt]=X.useState(()=>{try{const te=sessionStorage.getItem(St);return te?new Set(JSON.parse(te)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(St,JSON.stringify(Array.from(Mt)))}catch(te){console.error("Failed to save to sessionStorage:",te)}},[Mt]);const ut=X.useCallback((te,Te)=>{te?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:Te,projectId:e}})),setTimeout(()=>{zt(!0)},50)):(zt(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:Te,projectId:e}})))},[]);X.useEffect(()=>{const te=Te=>{_t(Te.detail.isOpen),Te.detail.isOpen&&setTimeout(()=>zt(!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(cr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,te)}},[]),X.useEffect(()=>{const te=Te=>{_t(Te.detail.isOpen),window.DebalesChat.isOpen=Te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:Te.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,te)}},[]);const[G,K]=Ke.useState(()=>{const te=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),Te=sessionStorage.getItem(te);return Te?JSON.parse(Te):[]});Ke.useEffect(()=>{const te=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(te,JSON.stringify(G))},[G,e]);const[le,Re]=X.useState(!1),[Ne,Ze]=X.useState({name:"",email:"",message:""}),vt=jf("exit_model"),[kt,pe]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Me,ft]=X.useState(!1),[xt,Ot]=X.useState(!0),[nn,wn]=X.useState(!1),[Jt,hn]=X.useState(!1),Rt=500,Vt=X.useCallback(te=>{const Te=te.target,he=Te.scrollHeight-Te.scrollTop<=Te.clientHeight+0;Ot(he)},[]);Ke.useEffect(()=>{var te,Te,he,Je,We,tt;if(h.length>0&&!m){const Lt=h[h.length-1],bn=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),Li=Lt.isBot&&Lt.conversationId===u&&Lt.conversationId!==bn,Ni=(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0&&Lt.conversationId===u;if(Li){ft(!0),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),Lt.conversationId||""),pe({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const rr=1600;let fi=rr;const So=[{type:"collections",condition:((te=Lt.collections)==null?void 0:te.length)&&((Te=Lt.collections)==null?void 0:Te.length)>0},{type:"products",condition:((he=Lt.products)==null?void 0:he.length)&&((Je=Lt.products)==null?void 0:Je.length)>0},{type:"leadingQueries",condition:((We=Lt.leading_queries)==null?void 0:We.length)&&((tt=Lt.leading_queries)==null?void 0:tt.length)>0},{type:"cartSummary",condition:(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0},{type:"bulkItems",condition:(G==null?void 0:G.length)>0}].filter(Ol=>Ol.condition);if(So.length===0){ft(!1);return}So.forEach(({type:Ol},Rr)=>{setTimeout(()=>{if(pe(Da=>({...Da,[Ol]:!0})),xt&&ct.current){const Da=ct.current;Da.scrollHeight-Da.scrollTop<=Da.clientHeight&&jo(ct)}Rr===So.length-1&&ft(!1)},fi),fi+=rr})}else Ni&&pe(rr=>({...rr,cartSummary:!0}))}},[h,m,u,B==null?void 0:B.itemCount,G==null?void 0:G.length,xt,e]),Ke.useEffect(()=>{if(!o&&h.length>0){const te=ct.current;te&&xt&&te.scrollHeight-te.scrollTop<=te.clientHeight+100&&setTimeout(()=>jo(ct),100)}},[h.length,o,xt]),Ke.useEffect(()=>{const te=document.querySelector('meta[name="viewport"]'),Te=te==null?void 0:te.content;if(Xe){let he=te;const Je=window.matchMedia("(max-width: 768px)").matches;he?he.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(he=document.createElement("meta"),he.name="viewport",he.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(he)),Je&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const We=he;return()=>{Te&&We&&(We.content=Te),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="")}},[Xe,t==null?void 0:t.mobileDisplayMode]),Ke.useEffect(()=>{o||setTimeout(()=>jo(ct),100)},[h.length,o]),Ke.useEffect(()=>{B!=null&&B.itemCount&&B.itemCount===0&&!o&&setTimeout(()=>jo(ct),100)},[B==null?void 0:B.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const gt=Ke.useRef(Date.now()),It=Ke.useRef(0),fr=Ke.useRef(window.location.pathname),Er=Ke.useRef(M),yr=Ke.useRef(!1),_r=jf("acquisition_agent");Ke.useEffect(()=>{Er.current=M},[M]);const Ii=Ke.useCallback(async()=>{const te=Date.now();if(te-gt.current>=6e3&&te-It.current>=6e4&&!yr.current)try{yr.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 We=await Je.json(),Lt=[...Er.current.filter(bn=>bn.path!==fr.current),{question:We.Popup_Message,answer:"",path:fr.current,nameSpace:e,type:"dynamic",Follow_up_Question:We.Follow_up_Question}];A(Lt)}It.current=te}catch(Je){console.error("Error fetching acquisition data:",Je)}finally{yr.current=!1}},[e]);Ke.useEffect(()=>{if(!_r||(t==null?void 0:t.show_bot)===!1)return;const te=()=>{gt.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 Te=setInterval(Ii,1e3),he=()=>{const We=window.location.pathname.split("?")[0],tt=fr.current.split("?")[0];(()=>{const bn=tt.split("/").filter(Boolean),Li=We.split("/").filter(Boolean);return bn.length!==Li.length?!0:bn.length===0&&Li.length===0?!1:We!==tt})()&&(fr.current=We,gt.current=Date.now())};return window.addEventListener("popstate",he),()=>{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",he),clearInterval(Te)}},[_r,Ii,t==null?void 0:t.show_bot]);const[Di,bi]=X.useState(!1),[xr,$i]=X.useState(!1),[Ia,oo]=X.useState(null),Wn=async te=>{const Te=nr();if(zt(!1),te&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Te,userRating:te,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(he){console.error("Error submitting rating:",he)}setTimeout(()=>{$i(!1),ut(!1,"close_button_clicked")},1e3)},ar=te=>{y(!0),G.forEach(he=>{H(he.id,he.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:G,message:te});const Te=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:te,isBot:!0}];v(Te),x(Te),d(te),K([]),y(!1)},Ln=()=>{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=Q((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1},jr=async te=>{te.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(B==null?void 0:B.total),cart:B}),J({dbls_method:"checkout_clicked"}),Ln()&&ut(!1,"checkout_clicked")},[Hr,Nn]=X.useState([]);Ke.useEffect(()=>{const te=Fw(M);Nn(Te=>{const he=te.filter(Je=>!Te.some(We=>We.question===Je.question));return[...Te,...he]})},[M]);const En=Ke.useMemo(()=>Hr.map(te=>({...te,isClicked:Mt.has(te.question)})),[Hr,Mt]);console.log(Hr),Ke.useEffect(()=>{const te=Je=>{const We=Je.detail.formId;switch(Je.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Lt=Te(We);Lt&&$t(Lt)},800);break;case"close":Et&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{ut(!0,"klaviyo_form_closed"),dt(We),r(Et,void 0,void 0,!0)},1e4);break}},Te=Je=>{const We=document.querySelector(`[data-testid="klaviyo-form-${Je}"]`);if(console.log(`formElement text ${Je} =>`,We==null?void 0:We.innerText,We==null?void 0:We.textContent),We instanceof HTMLElement){const tt=We.innerText||We.textContent;if(tt)return console.log("Found form text:",tt),`=> Klaviyo form content:
|
|
3981
|
+
`,$le=({botId:e})=>{var Qt,de;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:I,isUserInfoNeeded:D,setPendingQuestion:L}=Om(),{cart:B,addToCart:H,generateCartUrl:Q,addCartAttributes:J}=Cb(),W=$h("use-chatbot-icon-size"),Y=ud.detect(),se=t==null?void 0:t.isLeft,fe=oC(),xe=t==null?void 0:t.heightOption,ye=$h("new-suggested-question-design"),[Z,oe]=X.useState(!1),[me,qe]=X.useState(!1),[U,$e]=X.useState(!1);X.useEffect(()=>{if(!ye)return;const te=setTimeout(()=>{oe(!0);const Te=setTimeout(()=>{$e(!0),qe(!0);const he=setTimeout(()=>{$e(!1),oe(!1),qe(!1);const Je=setTimeout(()=>{$e(!0),oe(!0),qe(!0)},ye.hide_timing||4e3);return()=>clearTimeout(Je)},ye.show_for||44324);return()=>clearTimeout(he)},ye.showing_delay||2e3);return()=>clearTimeout(Te)},ye.showing_delay||2e3);return()=>clearTimeout(te)},[ye]);const[Ie,P]=X.useState(!1);X.useEffect(()=>{const te=()=>{P(window.matchMedia("(max-width: 768px)").matches)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]);const[Xe,_t]=Ke.useState(!1),[Pe,zt]=Ke.useState(!1),[Et,$t]=X.useState(""),[Ut,dt]=X.useState(""),[,Ge]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let te=yo();if(!te&&window.Thinkific){const Te=window.Thinkific.current_user;Te&&(te={name:Te.full_name,email:Te.email},wc(te))}yu.init({projectName:e,debug:!1,testing:wb}),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 ct=Ke.useRef(null),St=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[Mt,pt]=X.useState(()=>{try{const te=sessionStorage.getItem(St);return te?new Set(JSON.parse(te)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(St,JSON.stringify(Array.from(Mt)))}catch(te){console.error("Failed to save to sessionStorage:",te)}},[Mt]);const ut=X.useCallback((te,Te)=>{te?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:Te,projectId:e}})),setTimeout(()=>{zt(!0)},50)):(zt(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:te,source:Te,projectId:e}})))},[]);X.useEffect(()=>{const te=Te=>{_t(Te.detail.isOpen),Te.detail.isOpen&&setTimeout(()=>zt(!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(cr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,te)}},[]),X.useEffect(()=>{const te=Te=>{_t(Te.detail.isOpen),window.DebalesChat.isOpen=Te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:Te.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,te),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,te)}},[]);const[G,K]=Ke.useState(()=>{const te=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),Te=sessionStorage.getItem(te);return Te?JSON.parse(Te):[]});Ke.useEffect(()=>{const te=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(te,JSON.stringify(G))},[G,e]);const[le,Re]=X.useState(!1),[Ne,Ze]=X.useState({name:"",email:"",message:""}),vt=jf("exit_model"),[kt,pe]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[Me,ft]=X.useState(!1),[xt,Ot]=X.useState(!0),[nn,wn]=X.useState(!1),[Jt,hn]=X.useState(!1),Rt=500,Vt=X.useCallback(te=>{const Te=te.target,he=Te.scrollHeight-Te.scrollTop<=Te.clientHeight+0;Ot(he)},[]);Ke.useEffect(()=>{var te,Te,he,Je,We,tt;if(h.length>0&&!m){const Lt=h[h.length-1],bn=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),Li=Lt.isBot&&Lt.conversationId===u&&Lt.conversationId!==bn,Ni=(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0&&Lt.conversationId===u;if(Li){ft(!0),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),Lt.conversationId||""),pe({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const rr=1600;let fi=rr;const So=[{type:"collections",condition:((te=Lt.collections)==null?void 0:te.length)&&((Te=Lt.collections)==null?void 0:Te.length)>0},{type:"products",condition:((he=Lt.products)==null?void 0:he.length)&&((Je=Lt.products)==null?void 0:Je.length)>0},{type:"leadingQueries",condition:((We=Lt.leading_queries)==null?void 0:We.length)&&((tt=Lt.leading_queries)==null?void 0:tt.length)>0},{type:"cartSummary",condition:(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0},{type:"bulkItems",condition:(G==null?void 0:G.length)>0}].filter(Ol=>Ol.condition);if(So.length===0){ft(!1);return}So.forEach(({type:Ol},Rr)=>{setTimeout(()=>{if(pe(Da=>({...Da,[Ol]:!0})),xt&&ct.current){const Da=ct.current;Da.scrollHeight-Da.scrollTop<=Da.clientHeight&&jo(ct)}Rr===So.length-1&&ft(!1)},fi),fi+=rr})}else Ni&&pe(rr=>({...rr,cartSummary:!0}))}},[h,m,u,B==null?void 0:B.itemCount,G==null?void 0:G.length,xt,e]),Ke.useEffect(()=>{if(!o&&h.length>0){const te=ct.current;te&&xt&&te.scrollHeight-te.scrollTop<=te.clientHeight+100&&setTimeout(()=>jo(ct),100)}},[h.length,o,xt]),Ke.useEffect(()=>{const te=document.querySelector('meta[name="viewport"]'),Te=te==null?void 0:te.content;if(Xe){let he=te;const Je=window.matchMedia("(max-width: 768px)").matches;he?he.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(he=document.createElement("meta"),he.name="viewport",he.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(he)),Je&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const We=he;return()=>{Te&&We&&(We.content=Te),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="")}},[Xe,t==null?void 0:t.mobileDisplayMode]),Ke.useEffect(()=>{o||setTimeout(()=>jo(ct),100)},[h.length,o]),Ke.useEffect(()=>{B!=null&&B.itemCount&&B.itemCount===0&&!o&&setTimeout(()=>jo(ct),100)},[B==null?void 0:B.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const gt=Ke.useRef(Date.now()),It=Ke.useRef(0),fr=Ke.useRef(window.location.pathname),Er=Ke.useRef(M),yr=Ke.useRef(!1),_r=jf("acquisition_agent");Ke.useEffect(()=>{Er.current=M},[M]);const Ii=Ke.useCallback(async()=>{const te=Date.now();if(te-gt.current>=6e3&&te-It.current>=6e4&&!yr.current)try{yr.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 We=await Je.json(),Lt=[...Er.current.filter(bn=>bn.path!==fr.current),{question:We.Popup_Message,answer:"",path:fr.current,nameSpace:e,type:"dynamic",Follow_up_Question:We.Follow_up_Question}];A(Lt)}It.current=te}catch(Je){console.error("Error fetching acquisition data:",Je)}finally{yr.current=!1}},[e]);Ke.useEffect(()=>{if(!_r||(t==null?void 0:t.show_bot)===!1)return;const te=()=>{gt.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 Te=setInterval(Ii,1e3),he=()=>{const We=window.location.pathname.split("?")[0],tt=fr.current.split("?")[0];(()=>{const bn=tt.split("/").filter(Boolean),Li=We.split("/").filter(Boolean);return bn.length!==Li.length?!0:bn.length===0&&Li.length===0?!1:We!==tt})()&&(fr.current=We,gt.current=Date.now())};return window.addEventListener("popstate",he),()=>{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",he),clearInterval(Te)}},[_r,Ii,t==null?void 0:t.show_bot]);const[Di,bi]=X.useState(!1),[xr,$i]=X.useState(!1),[Ia,oo]=X.useState(null),Wn=async te=>{const Te=nr();if(zt(!1),te&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Te,userRating:te,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(he){console.error("Error submitting rating:",he)}setTimeout(()=>{$i(!1),ut(!1,"close_button_clicked")},1e3)},ar=te=>{y(!0),G.forEach(he=>{H(he.id,he.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:G,message:te});const Te=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:te,isBot:!0}];v(Te),x(Te),d(te),K([]),y(!1)},Ln=()=>{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=Q((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1},jr=async te=>{te.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(B==null?void 0:B.total),cart:B}),J({dbls_method:"checkout_clicked"}),Ln()&&ut(!1,"checkout_clicked")},[Hr,Nn]=X.useState([]);Ke.useEffect(()=>{const te=Fw(M);Nn(Te=>{const he=te.filter(Je=>!Te.some(We=>We.question===Je.question));return[...Te,...he]})},[M]);const En=Ke.useMemo(()=>Hr.map(te=>({...te,isClicked:Mt.has(te.question)})),[Hr,Mt]);console.log(Hr),Ke.useEffect(()=>{const te=Je=>{const We=Je.detail.formId;switch(Je.detail.type){case"open":case"embedOpen":setTimeout(()=>{const Lt=Te(We);Lt&&$t(Lt)},800);break;case"close":Et&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{ut(!0,"klaviyo_form_closed"),dt(We),r(Et,void 0,void 0,!0)},1e4);break}},Te=Je=>{const We=document.querySelector(`[data-testid="klaviyo-form-${Je}"]`);if(console.log(`formElement text ${Je} =>`,We==null?void 0:We.innerText,We==null?void 0:We.textContent),We instanceof HTMLElement){const tt=We.innerText||We.textContent;if(tt)return console.log("Found form text:",tt),`=> Klaviyo form content:
|
|
3982
3982
|
|
|
3983
3983
|
`+tt+`
|
|
3984
3984
|
|
|
@@ -4828,7 +4828,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4828
4828
|
margin-top: 16px;
|
|
4829
4829
|
display: flex;
|
|
4830
4830
|
justify-content: flex-end;
|
|
4831
|
-
`,mue=({botId:e})=>{var wt,Qt;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:I,isUserInfoNeeded:D,setPendingQuestion:L}=Om(),{cart:B,addToCart:H,generateCartUrl:Q,addCartAttributes:J}=Cb(),W=$h("use-chatbot-icon-size"),Y=ud.detect(),se=oC(),fe=t==null?void 0:t.heightOption,ae=$h("new-suggested-question-design"),[ye,Z]=X.useState(!1),[oe,me]=X.useState(!1),[qe,U]=X.useState(!1);X.useEffect(()=>{if(!ae)return;const de=setTimeout(()=>{Z(!0);const te=setTimeout(()=>{U(!0),me(!0);const Te=setTimeout(()=>{U(!1),Z(!1),me(!1);const he=setTimeout(()=>{U(!0),Z(!0),me(!0)},ae.hide_timing||4e3);return()=>clearTimeout(he)},ae.show_for||44324);return()=>clearTimeout(Te)},ae.showing_delay||2e3);return()=>clearTimeout(te)},ae.showing_delay||2e3);return()=>clearTimeout(de)},[ae]);const[$e,Ie]=X.useState(!1);X.useEffect(()=>{const de=()=>{Ie(window.matchMedia("(max-width: 768px)").matches)};return de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[]);const[P,Xe]=Ke.useState(!1),[_t,Pe]=Ke.useState(!1),[zt,Et]=X.useState(""),[$t,Ut]=X.useState(""),[,dt]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let de=yo();if(!de&&window.Thinkific){const te=window.Thinkific.current_user;te&&(de={name:te.full_name,email:te.email},wc(de))}yu.init({projectName:e,debug:!0,testing:wb}),de&&de.email&&(window.DebalesChat.identify(de.email,{name:de.name,phone:de.phone,email:de.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:de.email,first_name:de.name,phone:de.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const Ge=Ke.useRef(null),ct=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[St,Mt]=X.useState(()=>{try{const de=sessionStorage.getItem(ct);return de?new Set(JSON.parse(de)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(ct,JSON.stringify(Array.from(St)))}catch(de){console.error("Failed to save to sessionStorage:",de)}},[St]);const pt=X.useCallback((de,te)=>{de?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:de,source:te,projectId:e}})),setTimeout(()=>{Pe(!0)},50)):(Pe(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:de,source:te,projectId:e}})))},[]);X.useEffect(()=>{const de=te=>{Xe(te.detail.isOpen),te.detail.isOpen&&setTimeout(()=>Pe(!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(cr.OPEN_STATE_CHANGE,de),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,de)}},[]),X.useEffect(()=>{const de=te=>{Xe(te.detail.isOpen),window.DebalesChat.isOpen=te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:te.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,de),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,de)}},[]);const[ut,G]=Ke.useState(()=>{const de=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),te=sessionStorage.getItem(de);return te?JSON.parse(te):[]});Ke.useEffect(()=>{const de=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(de,JSON.stringify(ut))},[ut,e]);const[K,le]=X.useState(!1),[Re,Ne]=X.useState({name:"",email:"",message:""}),Ze=jf("exit_model"),[vt,kt]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[pe,Me]=X.useState(!1),[ft,xt]=X.useState(!0),[Ot,nn]=X.useState(!1),[wn,Jt]=X.useState(!1),hn=500,Rt=X.useCallback(de=>{const te=de.target,Te=te.scrollHeight-te.scrollTop<=te.clientHeight+0;xt(Te)},[]);Ke.useEffect(()=>{var de,te,Te,he,Je,We;if(h.length>0&&!m){const tt=h[h.length-1],Lt=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),bn=tt.isBot&&tt.conversationId===u&&tt.conversationId!==Lt,Li=(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0&&tt.conversationId===u;if(bn){Me(!0),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),tt.conversationId||""),kt({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const Ni=1600;let rr=Ni;const fi=[{type:"collections",condition:((de=tt.collections)==null?void 0:de.length)&&((te=tt.collections)==null?void 0:te.length)>0},{type:"products",condition:((Te=tt.products)==null?void 0:Te.length)&&((he=tt.products)==null?void 0:he.length)>0},{type:"leadingQueries",condition:((Je=tt.leading_queries)==null?void 0:Je.length)&&((We=tt.leading_queries)==null?void 0:We.length)>0},{type:"cartSummary",condition:(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0},{type:"bulkItems",condition:(ut==null?void 0:ut.length)>0}].filter(So=>So.condition);if(fi.length===0){Me(!1);return}fi.forEach(({type:So},Ol)=>{setTimeout(()=>{if(kt(Rr=>({...Rr,[So]:!0})),ft&&Ge.current){const Rr=Ge.current;Rr.scrollHeight-Rr.scrollTop<=Rr.clientHeight&&jo(Ge)}Ol===fi.length-1&&Me(!1)},rr),rr+=Ni})}else Li&&kt(Ni=>({...Ni,cartSummary:!0}))}},[h,m,u,B==null?void 0:B.itemCount,ut==null?void 0:ut.length,ft,e]),Ke.useEffect(()=>{if(!o&&h.length>0){const de=Ge.current;de&&ft&&de.scrollHeight-de.scrollTop<=de.clientHeight+100&&setTimeout(()=>jo(Ge),100)}},[h.length,o,ft]),Ke.useEffect(()=>{const de=document.querySelector('meta[name="viewport"]'),te=de==null?void 0:de.content;if(P){let Te=de;const he=window.matchMedia("(max-width: 768px)").matches;Te?Te.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(Te=document.createElement("meta"),Te.name="viewport",Te.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(Te)),he&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Je=Te;return()=>{te&&Je&&(Je.content=te),he&&(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="")}},[P,t==null?void 0:t.mobileDisplayMode]),Ke.useEffect(()=>{o||setTimeout(()=>jo(Ge),100)},[h.length,o]),Ke.useEffect(()=>{B!=null&&B.itemCount&&B.itemCount===0&&!o&&setTimeout(()=>jo(Ge),100)},[B==null?void 0:B.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Vt=Ke.useRef(Date.now()),gt=Ke.useRef(0),It=Ke.useRef(window.location.pathname),fr=Ke.useRef(M),Er=Ke.useRef(!1),yr=jf("acquisition_agent");Ke.useEffect(()=>{fr.current=M},[M]);const _r=Ke.useCallback(async()=>{const de=Date.now();if(de-Vt.current>=6e3&&de-gt.current>=6e4&&!Er.current)try{Er.current=!0,console.log("fetching acquisition data");const he=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(he.ok){const Je=await he.json(),tt=[...fr.current.filter(Lt=>Lt.path!==It.current),{question:Je.Popup_Message,answer:"",path:It.current,nameSpace:e,type:"dynamic",Follow_up_Question:Je.Follow_up_Question}];A(tt)}gt.current=de}catch(he){console.error("Error fetching acquisition data:",he)}finally{Er.current=!1}},[e]);Ke.useEffect(()=>{if(!yr||(t==null?void 0:t.show_bot)===!1)return;const de=()=>{Vt.current=Date.now()};document.addEventListener("mousemove",de),document.addEventListener("mousedown",de),document.addEventListener("keypress",de),document.addEventListener("scroll",de),document.addEventListener("touchstart",de),document.addEventListener("touchmove",de);const te=setInterval(_r,1e3),Te=()=>{const Je=window.location.pathname.split("?")[0],We=It.current.split("?")[0];(()=>{const Lt=We.split("/").filter(Boolean),bn=Je.split("/").filter(Boolean);return Lt.length!==bn.length?!0:Lt.length===0&&bn.length===0?!1:Je!==We})()&&(It.current=Je,Vt.current=Date.now())};return window.addEventListener("popstate",Te),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mousedown",de),document.removeEventListener("keypress",de),document.removeEventListener("scroll",de),document.removeEventListener("touchstart",de),document.removeEventListener("touchmove",de),window.removeEventListener("popstate",Te),clearInterval(te)}},[yr,_r,t==null?void 0:t.show_bot]);const[Ii,Di]=X.useState(!1),[bi,xr]=X.useState(!1),[$i,Ia]=X.useState(null),oo=async de=>{const te=nr();if(Pe(!1),de&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:te,userRating:de,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(Te){console.error("Error submitting rating:",Te)}setTimeout(()=>{xr(!1),pt(!1,"close_button_clicked")},1e3)},Wn=de=>{y(!0),ut.forEach(Te=>{H(Te.id,Te.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:ut,message:de});const te=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:de,isBot:!0}];v(te),x(te),d(de),G([]),y(!1)},ar=()=>{var de;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((de=window.shiprocketCheckoutEvents)!=null&&de.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1},Ln=async de=>{de.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(B==null?void 0:B.total),cart:B}),J({dbls_method:"checkout_clicked"}),ar()&&pt(!1,"checkout_clicked")},[jr,Hr]=X.useState([]);Ke.useEffect(()=>{const de=Fw(M);Hr(te=>{const Te=de.filter(he=>!te.some(Je=>Je.question===he.question));return[...te,...Te]})},[M]);const Nn=Ke.useMemo(()=>jr.map(de=>({...de,isClicked:St.has(de.question)})),[jr,St]);console.log(jr),Ke.useEffect(()=>{const de=he=>{const Je=he.detail.formId;switch(he.detail.type){case"open":case"embedOpen":setTimeout(()=>{const tt=te(Je);tt&&Et(tt)},800);break;case"close":zt&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{pt(!0,"klaviyo_form_closed"),Ut(Je),r(zt,void 0,void 0,!0)},1e4);break}},te=he=>{const Je=document.querySelector(`[data-testid="klaviyo-form-${he}"]`);if(console.log(`formElement text ${he} =>`,Je==null?void 0:Je.innerText,Je==null?void 0:Je.textContent),Je instanceof HTMLElement){const We=Je.innerText||Je.textContent;if(We)return console.log("Found form text:",We),`=> Klaviyo form content:
|
|
4831
|
+
`,mue=({botId:e})=>{var wt,Qt;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:I,isUserInfoNeeded:D,setPendingQuestion:L}=Om(),{cart:B,addToCart:H,generateCartUrl:Q,addCartAttributes:J}=Cb(),W=$h("use-chatbot-icon-size"),Y=ud.detect(),se=oC(),fe=t==null?void 0:t.heightOption,ae=$h("new-suggested-question-design"),[ye,Z]=X.useState(!1),[oe,me]=X.useState(!1),[qe,U]=X.useState(!1);X.useEffect(()=>{if(!ae)return;const de=setTimeout(()=>{Z(!0);const te=setTimeout(()=>{U(!0),me(!0);const Te=setTimeout(()=>{U(!1),Z(!1),me(!1);const he=setTimeout(()=>{U(!0),Z(!0),me(!0)},ae.hide_timing||4e3);return()=>clearTimeout(he)},ae.show_for||44324);return()=>clearTimeout(Te)},ae.showing_delay||2e3);return()=>clearTimeout(te)},ae.showing_delay||2e3);return()=>clearTimeout(de)},[ae]);const[$e,Ie]=X.useState(!1);X.useEffect(()=>{const de=()=>{Ie(window.matchMedia("(max-width: 768px)").matches)};return de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[]);const[P,Xe]=Ke.useState(!1),[_t,Pe]=Ke.useState(!1),[zt,Et]=X.useState(""),[$t,Ut]=X.useState(""),[,dt]=X.useState(0);Ke.useEffect(()=>{e&&tC(e)},[e]),Ke.useEffect(()=>{Gw(e)},[e]),Ke.useEffect(()=>{let de=yo();if(!de&&window.Thinkific){const te=window.Thinkific.current_user;te&&(de={name:te.full_name,email:te.email},wc(de))}yu.init({projectName:e,debug:!1,testing:wb}),de&&de.email&&(window.DebalesChat.identify(de.email,{name:de.name,phone:de.phone,email:de.email}),t!=null&&t.KlaviyoIntegration&&window.klaviyo&&window.klaviyo.identify({email:de.email,first_name:de.name,phone:de.phone,from:"Debales-Chatbot"}))},[e,t==null?void 0:t.KlaviyoIntegration]);const Ge=Ke.useRef(null),ct=$n(Dn.CLICKED_QUESTIONS,{botId:e}),[St,Mt]=X.useState(()=>{try{const de=sessionStorage.getItem(ct);return de?new Set(JSON.parse(de)):new Set}catch{return new Set}});Ke.useEffect(()=>{try{sessionStorage.setItem(ct,JSON.stringify(Array.from(St)))}catch(de){console.error("Failed to save to sessionStorage:",de)}},[St]);const pt=X.useCallback((de,te)=>{de?(window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:de,source:te,projectId:e}})),setTimeout(()=>{Pe(!0)},50)):(Pe(!1),window.dispatchEvent(new CustomEvent(cr.OPEN_STATE_CHANGE,{detail:{isOpen:de,source:te,projectId:e}})))},[]);X.useEffect(()=>{const de=te=>{Xe(te.detail.isOpen),te.detail.isOpen&&setTimeout(()=>Pe(!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(cr.OPEN_STATE_CHANGE,de),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,de)}},[]),X.useEffect(()=>{const de=te=>{Xe(te.detail.isOpen),window.DebalesChat.isOpen=te.detail.isOpen,window.DebalesChat.track(Gt.OPEN_STATE_CHANGE,{isOpen:te.detail.isOpen})};return window.addEventListener(cr.OPEN_STATE_CHANGE,de),()=>{window.removeEventListener(cr.OPEN_STATE_CHANGE,de)}},[]);const[ut,G]=Ke.useState(()=>{const de=$n(Dn.PENDING_BULK_ITEMS,{botId:e}),te=sessionStorage.getItem(de);return te?JSON.parse(te):[]});Ke.useEffect(()=>{const de=$n(Dn.PENDING_BULK_ITEMS,{botId:e});sessionStorage.setItem(de,JSON.stringify(ut))},[ut,e]);const[K,le]=X.useState(!1),[Re,Ne]=X.useState({name:"",email:"",message:""}),Ze=jf("exit_model"),[vt,kt]=X.useState({text:!0,leadingQueries:!0,collections:!0,products:!0,variants:!0,cartSummary:!0,bulkItems:!0}),[pe,Me]=X.useState(!1),[ft,xt]=X.useState(!0),[Ot,nn]=X.useState(!1),[wn,Jt]=X.useState(!1),hn=500,Rt=X.useCallback(de=>{const te=de.target,Te=te.scrollHeight-te.scrollTop<=te.clientHeight+0;xt(Te)},[]);Ke.useEffect(()=>{var de,te,Te,he,Je,We;if(h.length>0&&!m){const tt=h[h.length-1],Lt=sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e})),bn=tt.isBot&&tt.conversationId===u&&tt.conversationId!==Lt,Li=(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0&&tt.conversationId===u;if(bn){Me(!0),sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),tt.conversationId||""),kt({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1});const Ni=1600;let rr=Ni;const fi=[{type:"collections",condition:((de=tt.collections)==null?void 0:de.length)&&((te=tt.collections)==null?void 0:te.length)>0},{type:"products",condition:((Te=tt.products)==null?void 0:Te.length)&&((he=tt.products)==null?void 0:he.length)>0},{type:"leadingQueries",condition:((Je=tt.leading_queries)==null?void 0:Je.length)&&((We=tt.leading_queries)==null?void 0:We.length)>0},{type:"cartSummary",condition:(B==null?void 0:B.itemCount)&&(B==null?void 0:B.itemCount)>0},{type:"bulkItems",condition:(ut==null?void 0:ut.length)>0}].filter(So=>So.condition);if(fi.length===0){Me(!1);return}fi.forEach(({type:So},Ol)=>{setTimeout(()=>{if(kt(Rr=>({...Rr,[So]:!0})),ft&&Ge.current){const Rr=Ge.current;Rr.scrollHeight-Rr.scrollTop<=Rr.clientHeight&&jo(Ge)}Ol===fi.length-1&&Me(!1)},rr),rr+=Ni})}else Li&&kt(Ni=>({...Ni,cartSummary:!0}))}},[h,m,u,B==null?void 0:B.itemCount,ut==null?void 0:ut.length,ft,e]),Ke.useEffect(()=>{if(!o&&h.length>0){const de=Ge.current;de&&ft&&de.scrollHeight-de.scrollTop<=de.clientHeight+100&&setTimeout(()=>jo(Ge),100)}},[h.length,o,ft]),Ke.useEffect(()=>{const de=document.querySelector('meta[name="viewport"]'),te=de==null?void 0:de.content;if(P){let Te=de;const he=window.matchMedia("(max-width: 768px)").matches;Te?Te.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no":(Te=document.createElement("meta"),Te.name="viewport",Te.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(Te)),he&&(t==null?void 0:t.mobileDisplayMode)==="full-screen"&&(document.body.style.overflow="hidden");const Je=Te;return()=>{te&&Je&&(Je.content=te),he&&(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="")}},[P,t==null?void 0:t.mobileDisplayMode]),Ke.useEffect(()=>{o||setTimeout(()=>jo(Ge),100)},[h.length,o]),Ke.useEffect(()=>{B!=null&&B.itemCount&&B.itemCount===0&&!o&&setTimeout(()=>jo(Ge),100)},[B==null?void 0:B.itemCount,o]),Ke.useEffect(()=>{u&&sessionStorage.setItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:e}),u)},[u,e]);const Vt=Ke.useRef(Date.now()),gt=Ke.useRef(0),It=Ke.useRef(window.location.pathname),fr=Ke.useRef(M),Er=Ke.useRef(!1),yr=jf("acquisition_agent");Ke.useEffect(()=>{fr.current=M},[M]);const _r=Ke.useCallback(async()=>{const de=Date.now();if(de-Vt.current>=6e3&&de-gt.current>=6e4&&!Er.current)try{Er.current=!0,console.log("fetching acquisition data");const he=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(he.ok){const Je=await he.json(),tt=[...fr.current.filter(Lt=>Lt.path!==It.current),{question:Je.Popup_Message,answer:"",path:It.current,nameSpace:e,type:"dynamic",Follow_up_Question:Je.Follow_up_Question}];A(tt)}gt.current=de}catch(he){console.error("Error fetching acquisition data:",he)}finally{Er.current=!1}},[e]);Ke.useEffect(()=>{if(!yr||(t==null?void 0:t.show_bot)===!1)return;const de=()=>{Vt.current=Date.now()};document.addEventListener("mousemove",de),document.addEventListener("mousedown",de),document.addEventListener("keypress",de),document.addEventListener("scroll",de),document.addEventListener("touchstart",de),document.addEventListener("touchmove",de);const te=setInterval(_r,1e3),Te=()=>{const Je=window.location.pathname.split("?")[0],We=It.current.split("?")[0];(()=>{const Lt=We.split("/").filter(Boolean),bn=Je.split("/").filter(Boolean);return Lt.length!==bn.length?!0:Lt.length===0&&bn.length===0?!1:Je!==We})()&&(It.current=Je,Vt.current=Date.now())};return window.addEventListener("popstate",Te),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mousedown",de),document.removeEventListener("keypress",de),document.removeEventListener("scroll",de),document.removeEventListener("touchstart",de),document.removeEventListener("touchmove",de),window.removeEventListener("popstate",Te),clearInterval(te)}},[yr,_r,t==null?void 0:t.show_bot]);const[Ii,Di]=X.useState(!1),[bi,xr]=X.useState(!1),[$i,Ia]=X.useState(null),oo=async de=>{const te=nr();if(Pe(!1),de&&h.length>1)try{(await fetch(`${ci}/api/wordpress/userRating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:te,userRating:de,nameSpace:e})})).ok||console.error("Error submitting rating")}catch(Te){console.error("Error submitting rating:",Te)}setTimeout(()=>{xr(!1),pt(!1,"close_button_clicked")},1e3)},Wn=de=>{y(!0),ut.forEach(Te=>{H(Te.id,Te.quantity)}),window.DebalesChat.track(Gt.ADD_BULK_ITEM,{products:ut,message:de});const te=[...h,{text:"🎉 Bulk items added to cart successfully.",leading_queries:["Get GST Invoice for the order","Explore more products"],conversationId:de,isBot:!0}];v(te),x(te),d(de),G([]),y(!1)},ar=()=>{var de;switch(e){case"minature":case"bodytales":case"imemyselfcare-com":if(window.triggerGokwikCustomCheckout)return window.triggerGokwikCustomCheckout(),!0;break;case"athflex":if((de=window.shiprocketCheckoutEvents)!=null&&de.buyCart)return window.shiprocketCheckoutEvents.buyCart(),!0;break;case"www":if(window.openRzpCheckout)return window.openRzpCheckout(),!0;break;default:return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1}return window.location.href=Q((t==null?void 0:t.shopifyShopDomain)??""),!1},Ln=async de=>{de.preventDefault(),window.DebalesChat.track(Gt.CHECKOUT_CLICKED,{chatId:nr()+e,cartValue:Number(B==null?void 0:B.total),cart:B}),J({dbls_method:"checkout_clicked"}),ar()&&pt(!1,"checkout_clicked")},[jr,Hr]=X.useState([]);Ke.useEffect(()=>{const de=Fw(M);Hr(te=>{const Te=de.filter(he=>!te.some(Je=>Je.question===he.question));return[...te,...Te]})},[M]);const Nn=Ke.useMemo(()=>jr.map(de=>({...de,isClicked:St.has(de.question)})),[jr,St]);console.log(jr),Ke.useEffect(()=>{const de=he=>{const Je=he.detail.formId;switch(he.detail.type){case"open":case"embedOpen":setTimeout(()=>{const tt=te(Je);tt&&Et(tt)},800);break;case"close":zt&&(t==null?void 0:t.KlaviyoFormIntegration)===!0&&setTimeout(()=>{pt(!0,"klaviyo_form_closed"),Ut(Je),r(zt,void 0,void 0,!0)},1e4);break}},te=he=>{const Je=document.querySelector(`[data-testid="klaviyo-form-${he}"]`);if(console.log(`formElement text ${he} =>`,Je==null?void 0:Je.innerText,Je==null?void 0:Je.textContent),Je instanceof HTMLElement){const We=Je.innerText||Je.textContent;if(We)return console.log("Found form text:",We),`=> Klaviyo form content:
|
|
4832
4832
|
|
|
4833
4833
|
`+We+`
|
|
4834
4834
|
|
|
@@ -5081,4 +5081,4 @@ Learn more: https://react.dev/warnings/version-mismatch`))}(),typeof Map=="funct
|
|
|
5081
5081
|
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,R=kv,$=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:
|
|
5082
5082
|
|
|
5083
5083
|
let root = createRoot(domContainer);
|
|
5084
|
-
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&&(R=a.onRecoverableError),a.unstable_transitionCallbacks!==void 0&&($=a.unstable_transitionCallbacks)),a=R_(i,1,!1,null,null,c,g,_,S,R,$,null),i[tc]=a.current,h_(i),new b0(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,R=Hk,$=kv,q=null,V=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&&(R=c.onCaughtError),c.onRecoverableError!==void 0&&($=c.onRecoverableError),c.unstable_transitionCallbacks!==void 0&&(q=c.unstable_transitionCallbacks),c.formState!==void 0&&(V=c.formState)),a=R_(i,1,!0,a,c??null,g,_,S,R,$,q,V),a.context=I_(null),c=a.current,g=Qo(c),g=Me(g),_=zs(g),_.callback=null,us(c,_,g),c=g,a.current.lanes=c,Ze(a,c),Fa(a),i[tc]=a.current,h_(i),new Wp(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=X.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},o)=>{const s=X.useRef(null),[u,d]=X.useState(null),h=X.useRef(null),m=X.useRef(null),y=X.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 X.useImperativeHandle(o,()=>y.current,[]),X.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]),X.useEffect(()=>(u&&!m.current&&(m.current=wue.createRoot(u)),m.current&&u&&m.current.render(O.jsx(F.StyleSheetManager,{target:u,children:O.jsx(S9,{value:y.current,children:e})})),()=>{m.current&&m.current.unmount()}),[u,e]),O.jsx("div",{ref:s,style:n})});class WR{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 WR{constructor(){super(...arguments);ro(this,"platform",_o.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 WR{constructor(){var n,r;super();ro(this,"platform",_o.SHOPIFY);ro(this,"cartEndpoint");ro(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=nr()}){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:nr(),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:nr(),...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]",nr()),o.searchParams.append("timestamp",Date.now().toString()),Kh(o.toString())}}class Aue extends WR{constructor(){var n,r;super();ro(this,"platform",_o.MAGENTO);ro(this,"checkoutEndpoint");ro(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 Wh=class Wh{constructor(){ro(this,"adapterCache");this.adapterCache=new Map}static getInstance(){return Wh.instance||(Wh.instance=new Wh),Wh.instance}getAdapter(t){const n=t||ud.detect(),r=this.adapterCache.get(n);if(r)return r;let o;switch(n){case _o.SHOPIFY:o=new kue;break;case _o.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()}};ro(Wh,"instance");let JR=Wh;const Tue=({adapter:e,children:t,autoFetch:n=!0})=>{const[r,o]=X.useState(!1),[s,u]=X.useState(null),[d,h]=X.useState(null),m=X.useCallback(async()=>{try{o(!0),u(null);const I=await e.fetchCart();I.success?h(I.data):u(I.error)}catch(I){u(I instanceof Error?I.message:"Failed to fetch cart")}finally{o(!1)}},[e]),y=async(I,D,L)=>{try{u(null);const B=await e.addToCart(I,D,L);return B.success&&await m(),B}catch(B){return{success:!1,error:B instanceof Error?B.message:"Failed to add item to cart"}}},v=async I=>{try{u(null);const D=await e.removeFromCart(I);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 I=>{try{u(null);const D=await e.updateQuantity(I);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 I=await e.clearCart();return I.success&&await m(),I}catch(I){return{success:!1,error:I instanceof Error?I.message:"Failed to clear cart"}}},E=I=>e.generateCartUrl(I),M=(I,D)=>e.generateProductUrl(I,D),A=async I=>e.addCartAttributes(I);X.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(t9.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 eI={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,tI=({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 nI;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));tI(e,!1,n=>{nI||(nI=new TextEncoder),t(nI.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",rI=(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]}:eI},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)=>{tI(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=rI(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 iI;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){iI||(iI=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(eI);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(rI(s?h:iI.decode(h),t)),r=0}if(o===0||o>e){d.enqueue(eI);break}}}})}const r7=4;function Ri(e){if(e)return Bue(e)}function Bue(e){for(var t in Ri.prototype)e[t]=Ri.prototype[t];return e}Ri.prototype.on=Ri.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Ri.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},Ri.prototype.off=Ri.prototype.removeListener=Ri.prototype.removeAllListeners=Ri.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},Ri.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},Ri.prototype.emitReserved=Ri.prototype.emit,Ri.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Ri.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),Rs=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=Rs.setTimeout,jue=Rs.clearTimeout;function mk(e,t){t.useNativeTimers?(e.setTimeoutFn=Uue.bind(Rs),e.clearTimeoutFn=jue.bind(Rs)):(e.setTimeoutFn=Rs.setTimeout.bind(Rs),e.clearTimeoutFn=Rs.clearTimeout.bind(Rs))}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 oI extends Ri{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=rI(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 oI{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 Ri{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 Rs?"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 Rs[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const u7=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Jue extends oI{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;tI(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 aI=Rs.WebSocket||Rs.MozWebSocket;class ece extends Jue{createSocket(t,n,r){return u7?new aI(t,n,r):n?new aI(t,n):new aI(t)}doWrite(t,n){this.ws.send(n)}}class tce extends oI{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 sI(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 lI=typeof addEventListener=="function"&&typeof removeEventListener=="function",vk=[];lI&&addEventListener("offline",()=>{vk.forEach(e=>e())},!1);class cd extends Ri{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=sI(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=sI(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)),lI&&(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(),lI&&(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=sI(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 uI(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(uI(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=cI(n,t),r.attachments=t.length,{packet:r,buffers:t}}function cI(e,t){if(!e)return e;if(uI(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]=cI(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]=cI(e[r],t));return n}return e}function gce(e,t){return e.data=fI(e.data,t),delete e.attachments,e}function fI(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]=fI(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=fI(e[n],t));return e}const mce=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],vce=5;var Pn;(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"})(Pn||(Pn={}));class yce{constructor(t){this.replacer=t}encode(t){return(t.type===Pn.EVENT||t.type===Pn.ACK)&&yk(t)?this.encodeAsBinary({type:t.type===Pn.EVENT?Pn.BINARY_EVENT:Pn.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Pn.BINARY_EVENT||t.type===Pn.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 dI extends Ri{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===Pn.BINARY_EVENT;r||n.type===Pn.BINARY_ACK?(n.type=r?Pn.EVENT:Pn.ACK,this.reconstructor=new bce(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(uI(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(Pn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Pn.BINARY_EVENT||r.type===Pn.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(dI.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 Pn.CONNECT:return f7(n);case Pn.DISCONNECT:return n===void 0;case Pn.CONNECT_ERROR:return typeof n=="string"||f7(n);case Pn.EVENT:case Pn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&mce.indexOf(n[0])===-1);case Pn.ACK:case Pn.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:dI,Encoder:yce,get PacketType(){return Pn},protocol:vce},Symbol.toStringTag,{value:"Module"}));function Ml(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 Ri{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=[Ml(t,"open",this.onopen.bind(this)),Ml(t,"packet",this.onpacket.bind(this)),Ml(t,"error",this.onerror.bind(this)),Ml(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:Pn.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:Pn.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 Pn.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 Pn.EVENT:case Pn.BINARY_EVENT:this.onevent(t);break;case Pn.ACK:case Pn.BINARY_ACK:this.onack(t);break;case Pn.DISCONNECT:this.ondisconnect();break;case Pn.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:Pn.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:Pn.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 Vm(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}Vm.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},Vm.prototype.reset=function(){this.attempts=0},Vm.prototype.setMin=function(e){this.ms=e},Vm.prototype.setMax=function(e){this.max=e},Vm.prototype.setJitter=function(e){this.jitter=e};class hI extends Ri{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 Vm({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=Ml(n,"open",function(){r.onopen(),t&&t()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),t?t(d):this.maybeReconnectOnOpen()},u=Ml(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(Ml(t,"ping",this.onping.bind(this)),Ml(t,"data",this.ondata.bind(this)),Ml(t,"error",this.onerror.bind(this)),Ml(t,"close",this.onclose.bind(this)),Ml(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 hI(r,t):(Xb[o]||(Xb[o]=new hI(r,t)),h=Xb[o]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}Object.assign(bk,{Manager:hI,Socket:d7,io:bk,connect:bk});const Jh=class Jh{constructor(){ro(this,"socket",null);ro(this,"isConnected",!1);ro(this,"eventListeners",new Map)}static getInstance(){return Jh.instance||(Jh.instance=new Jh),Jh.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))}};ro(Jh,"instance");let pI=Jh;const Su=pI.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=Ke.useSyncExternalStore(Ece,n,kce),o=Ke.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 Ke.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=Ke.useSyncExternalStore(Mce,n,Oce),o=Ke.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 Ke.useEffect(()=>{m7(e)===null&&g7(e,t)},[e,t]),[r?JSON.parse(r):t,o]}const Ice=({children:e,nameSpace:t})=>{const[n,r]=X.useState(""),[o,s]=X.useState([]),[u,d]=X.useState(!1),[h,m]=X.useState(!1),[y,v]=X.useState([]),[x,w]=X.useState(!1),[E,M]=X.useState(!1),[A,k]=X.useState([]),[I,D]=Ace($n(Dn.USER_INFO),null),[L,B]=Rce($n(Dn.IS_FORM_CLOSED_BY_USER),!1),[H,Q]=X.useState(null),J=jf("web-socket"),[W,Y]=X.useState([]),[se,fe]=X.useState(null),[xe,ae]=X.useState(!1),[ye,Z]=X.useState(sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:t}))),oe=bne(),me=nr(),[qe,U]=X.useState(null),[$e,Ie]=X.useState(null);X.useEffect(()=>{if(J){const dt=Su.connect("/api/v1/chat");fe(dt);const Ge=()=>{console.debug("connected to websocket"),ae(!0)},ct=()=>{console.debug("disconnected from websocket"),ae(!1)},St=pt=>{console.debug("response from websocket",pt);const ut=pt.conversationId??crypto.randomUUID().toString();Z(ut),pt.Variants_quantity&&k(K=>[...K,...pt.Variants_quantity]);const G=[...o,{text:pt.response,products:pt.products,conversationId:ut,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),P(G),v(K=>[...K,[o[o.length-1].text,pt.response]]),m(!1)},Mt=pt=>{if(pt.event==="error"){const ut={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},G=[...o,ut];s(G),P(G),m(!1)}};return Su.on("connect",Ge),Su.on("disconnect",ct),Su.on("response",St),Su.on("system",Mt),()=>{Su.off("connect",Ge),Su.off("disconnect",ct),Su.off("response",St),Su.off("system",Mt)}}},[J,o]);const P=dt=>{sessionStorage.setItem($n(Dn.CHAT_HISTORY,{botId:window.DebalesChat.projectId}),JSON.stringify(dt))},Xe=()=>{const dt=sessionStorage.getItem($n(Dn.CHAT_HISTORY,{botId:window.DebalesChat.projectId}));return dt?JSON.parse(dt):[]},_t=X.useCallback(async()=>{if(t)try{d(!0);const dt=await fetch(`${ci}/api/wordpress/UiData?value=${t}`),Ge=await dt.json();if(!dt.ok)throw new Error("failed to fetch data"+Ge.error);const ct=document.getElementById("debales-ai-assistant");ct&&(ct.style.zIndex=String(Ge.zIndex??2031483602)),Ie(Ge),Ge!=null&&Ge.shopifyShopDomain&&Bne(Ge.shopifyShopDomain).then(Mt=>{U(Mt)}),Y(Ge.suggestedQuestions);const St=Xe();if(St.length>0)s(St);else{const Mt={text:Ge.initialMessage||"Hi, I am an AI Assistant. How can I help you?",isBot:!0};s([Mt])}}catch(dt){console.error(dt)}finally{d(!1)}},[t]);X.useEffect(()=>{_t()},[_t]);const Pe=X.useMemo(()=>{var dt;return!!(!L&&((dt=$e==null?void 0:$e.pluginConfig)!=null&&dt.collectedUserInfo)&&($e.pluginConfig.collectedUserInfo.name||$e.pluginConfig.collectedUserInfo.email||$e.pluginConfig.collectedUserInfo.phone)&&!I)},[$e,I,L]),zt=X.useCallback(async(dt,Ge,ct,St,Mt,pt)=>{if(!dt||dt.trim()===""||h&&!ct)return;let ut=[...o];St?St&&o.length<=2?(w(!0),ut=[]):w(!1):(ut.push({text:dt,isBot:!1}),w(!1));const G=nr();m(!0);try{s(ut),P(ut);const K=await fetch(`${ci}/api/wordpress/ChatWithBot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:G,userMessage:dt,nameSpace:t,chat_history:y,leading_queries:Mt,answer:Ge,products:ct,userInfo:JSON.stringify(I),anonymousUserId:oe,distinctId:yu.getDistinctId(),timestamp:new Date().toISOString(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,followUpQuestion:pt})});if(!K.ok)throw new Error("Network response was not ok");const le=await K.json(),Re=le.conversationId??crypto.randomUUID().toString();Z(Re),le.Variants_quantity&&k(Ze=>[...Ze,...le.Variants_quantity]);const Ne=[...ut,{text:le.response,products:le.products,conversationId:Re,rating:"neutral",leading_queries:le.leading_queries,collections:le.collections,variants:le.variants,shop:le.shop,Variants_quantity:le.Variants_quantity,monthlyChatLimitReached:le.monthlyChatLimitReached,isBot:!0}];s(Ne),P(Ne),v(Ze=>[...Ze,[dt,le.response]])}catch(K){console.error(K);const le={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},Re=[...ut,le];St||(s(Re),P(Re))}finally{m(!1)}},[o,h,y,t,oe,I]),Et=X.useCallback(dt=>{$e&&Ie(Ge=>Ge?{...Ge,mobileDisplayMode:dt}:null)},[$e]),$t=X.useCallback(async(dt,Ge,ct,St,Mt,pt)=>{if(!dt||dt.trim()===""||h&&!ct)return;let ut=[...o];if(St?St&&o.length<=2?(w(!0),ut=[]):w(!1):(ut.push({text:dt,isBot:!1}),w(!1)),m(!0),s(ut),P(ut),se&&xe){const G={type:Sce.MESSAGE,role:wce.USER,query:dt,nameSpace:t,leadingQueries:Mt,answer:Ge,products:ct,userInfo:I,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),sessionId:me,anonymousUserId:oe,distinctId:yu.getDistinctId(),followUpQuestion:pt};Su.emit("chat",G)}else zt(dt,Ge,ct,St,Mt,pt)},[o,h,t,oe,se,xe,me,zt,I]),Ut={sessionId:me,messages:o,isLoading:u,isMessageLoading:h,isKlaviyoMessage:x,showUserInfoModel:E,pendingBulkItems:A,lastedBotmessageId:ye,uiData:$e,storeMetaData:qe,suggestedQuestions:W,isUserInfoNeeded:Pe,input:n,pendingQuestion:H,userInfo:I,isFormClosedByUser:L,onSendMessage:J?$t:zt,setMessages:s,setIsLoading:d,setIsMessageLoading:m,setIsKlaviyoMessage:w,setShowUserInfoModel:M,setPendingBulkItems:k,setLastedBotmessageId:Z,fetchUiInfo:_t,changeDisplayModel:Et,saveConversation:P,loadConversation:Xe,setSuggestedQuestions:Y,setUserInfo:D,setInput:r,setPendingQuestion:Q,setIsFormClosedByUser:B};return O.jsx(w9.Provider,{value:Ut,children:e})};function Dce(e){const t=JR.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:nr()}),n.group("project",e.botId,{platform:ud.detect()});const r=yo();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});
|
|
5084
|
+
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&&(R=a.onRecoverableError),a.unstable_transitionCallbacks!==void 0&&($=a.unstable_transitionCallbacks)),a=R_(i,1,!1,null,null,c,g,_,S,R,$,null),i[tc]=a.current,h_(i),new b0(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,R=Hk,$=kv,q=null,V=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&&(R=c.onCaughtError),c.onRecoverableError!==void 0&&($=c.onRecoverableError),c.unstable_transitionCallbacks!==void 0&&(q=c.unstable_transitionCallbacks),c.formState!==void 0&&(V=c.formState)),a=R_(i,1,!0,a,c??null,g,_,S,R,$,q,V),a.context=I_(null),c=a.current,g=Qo(c),g=Me(g),_=zs(g),_.callback=null,us(c,_,g),c=g,a.current.lanes=c,Ze(a,c),Fa(a),i[tc]=a.current,h_(i),new Wp(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=X.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},o)=>{const s=X.useRef(null),[u,d]=X.useState(null),h=X.useRef(null),m=X.useRef(null),y=X.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 X.useImperativeHandle(o,()=>y.current,[]),X.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]),X.useEffect(()=>(u&&!m.current&&(m.current=wue.createRoot(u)),m.current&&u&&m.current.render(O.jsx(F.StyleSheetManager,{target:u,children:O.jsx(S9,{value:y.current,children:e})})),()=>{m.current&&m.current.unmount()}),[u,e]),O.jsx("div",{ref:s,style:n})});class WR{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 WR{constructor(){super(...arguments);ro(this,"platform",_o.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 WR{constructor(){var n,r;super();ro(this,"platform",_o.SHOPIFY);ro(this,"cartEndpoint");ro(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=nr()}){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:nr(),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:nr(),...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]",nr()),o.searchParams.append("timestamp",Date.now().toString()),Kh(o.toString())}}class Aue extends WR{constructor(){var n,r;super();ro(this,"platform",_o.MAGENTO);ro(this,"checkoutEndpoint");ro(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 Wh=class Wh{constructor(){ro(this,"adapterCache");this.adapterCache=new Map}static getInstance(){return Wh.instance||(Wh.instance=new Wh),Wh.instance}getAdapter(t){const n=t||ud.detect(),r=this.adapterCache.get(n);if(r)return r;let o;switch(n){case _o.SHOPIFY:o=new kue;break;case _o.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()}};ro(Wh,"instance");let JR=Wh;const Tue=({adapter:e,children:t,autoFetch:n=!0})=>{const[r,o]=X.useState(!1),[s,u]=X.useState(null),[d,h]=X.useState(null),m=X.useCallback(async()=>{try{o(!0),u(null);const I=await e.fetchCart();I.success?h(I.data):u(I.error)}catch(I){u(I instanceof Error?I.message:"Failed to fetch cart")}finally{o(!1)}},[e]),y=async(I,D,L)=>{try{u(null);const B=await e.addToCart(I,D,L);return B.success&&await m(),B}catch(B){return{success:!1,error:B instanceof Error?B.message:"Failed to add item to cart"}}},v=async I=>{try{u(null);const D=await e.removeFromCart(I);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 I=>{try{u(null);const D=await e.updateQuantity(I);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 I=await e.clearCart();return I.success&&await m(),I}catch(I){return{success:!1,error:I instanceof Error?I.message:"Failed to clear cart"}}},E=I=>e.generateCartUrl(I),M=(I,D)=>e.generateProductUrl(I,D),A=async I=>e.addCartAttributes(I);X.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(t9.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 eI={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,tI=({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 nI;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));tI(e,!1,n=>{nI||(nI=new TextEncoder),t(nI.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",rI=(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]}:eI},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)=>{tI(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=rI(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 iI;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){iI||(iI=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(eI);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(rI(s?h:iI.decode(h),t)),r=0}if(o===0||o>e){d.enqueue(eI);break}}}})}const r7=4;function Ri(e){if(e)return Bue(e)}function Bue(e){for(var t in Ri.prototype)e[t]=Ri.prototype[t];return e}Ri.prototype.on=Ri.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Ri.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},Ri.prototype.off=Ri.prototype.removeListener=Ri.prototype.removeAllListeners=Ri.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},Ri.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},Ri.prototype.emitReserved=Ri.prototype.emit,Ri.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Ri.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),Rs=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=Rs.setTimeout,jue=Rs.clearTimeout;function mk(e,t){t.useNativeTimers?(e.setTimeoutFn=Uue.bind(Rs),e.clearTimeoutFn=jue.bind(Rs)):(e.setTimeoutFn=Rs.setTimeout.bind(Rs),e.clearTimeoutFn=Rs.clearTimeout.bind(Rs))}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 oI extends Ri{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=rI(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 oI{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 Ri{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 Rs?"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 Rs[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const u7=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Jue extends oI{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;tI(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 aI=Rs.WebSocket||Rs.MozWebSocket;class ece extends Jue{createSocket(t,n,r){return u7?new aI(t,n,r):n?new aI(t,n):new aI(t)}doWrite(t,n){this.ws.send(n)}}class tce extends oI{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 sI(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 lI=typeof addEventListener=="function"&&typeof removeEventListener=="function",vk=[];lI&&addEventListener("offline",()=>{vk.forEach(e=>e())},!1);class cd extends Ri{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=sI(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=sI(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)),lI&&(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(),lI&&(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=sI(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 uI(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(uI(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=cI(n,t),r.attachments=t.length,{packet:r,buffers:t}}function cI(e,t){if(!e)return e;if(uI(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]=cI(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]=cI(e[r],t));return n}return e}function gce(e,t){return e.data=fI(e.data,t),delete e.attachments,e}function fI(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]=fI(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=fI(e[n],t));return e}const mce=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],vce=5;var Pn;(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"})(Pn||(Pn={}));class yce{constructor(t){this.replacer=t}encode(t){return(t.type===Pn.EVENT||t.type===Pn.ACK)&&yk(t)?this.encodeAsBinary({type:t.type===Pn.EVENT?Pn.BINARY_EVENT:Pn.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Pn.BINARY_EVENT||t.type===Pn.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 dI extends Ri{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===Pn.BINARY_EVENT;r||n.type===Pn.BINARY_ACK?(n.type=r?Pn.EVENT:Pn.ACK,this.reconstructor=new bce(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(uI(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(Pn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Pn.BINARY_EVENT||r.type===Pn.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(dI.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 Pn.CONNECT:return f7(n);case Pn.DISCONNECT:return n===void 0;case Pn.CONNECT_ERROR:return typeof n=="string"||f7(n);case Pn.EVENT:case Pn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&mce.indexOf(n[0])===-1);case Pn.ACK:case Pn.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:dI,Encoder:yce,get PacketType(){return Pn},protocol:vce},Symbol.toStringTag,{value:"Module"}));function Ml(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 Ri{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=[Ml(t,"open",this.onopen.bind(this)),Ml(t,"packet",this.onpacket.bind(this)),Ml(t,"error",this.onerror.bind(this)),Ml(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:Pn.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:Pn.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 Pn.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 Pn.EVENT:case Pn.BINARY_EVENT:this.onevent(t);break;case Pn.ACK:case Pn.BINARY_ACK:this.onack(t);break;case Pn.DISCONNECT:this.ondisconnect();break;case Pn.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:Pn.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:Pn.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 Vm(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}Vm.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},Vm.prototype.reset=function(){this.attempts=0},Vm.prototype.setMin=function(e){this.ms=e},Vm.prototype.setMax=function(e){this.max=e},Vm.prototype.setJitter=function(e){this.jitter=e};class hI extends Ri{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 Vm({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=Ml(n,"open",function(){r.onopen(),t&&t()}),s=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),t?t(d):this.maybeReconnectOnOpen()},u=Ml(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(Ml(t,"ping",this.onping.bind(this)),Ml(t,"data",this.ondata.bind(this)),Ml(t,"error",this.onerror.bind(this)),Ml(t,"close",this.onclose.bind(this)),Ml(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 hI(r,t):(Xb[o]||(Xb[o]=new hI(r,t)),h=Xb[o]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}Object.assign(bk,{Manager:hI,Socket:d7,io:bk,connect:bk});const Jh=class Jh{constructor(){ro(this,"socket",null);ro(this,"isConnected",!1);ro(this,"eventListeners",new Map)}static getInstance(){return Jh.instance||(Jh.instance=new Jh),Jh.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))}};ro(Jh,"instance");let pI=Jh;const Su=pI.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=Ke.useSyncExternalStore(Ece,n,kce),o=Ke.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 Ke.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=Ke.useSyncExternalStore(Mce,n,Oce),o=Ke.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 Ke.useEffect(()=>{m7(e)===null&&g7(e,t)},[e,t]),[r?JSON.parse(r):t,o]}const Ice=({children:e,nameSpace:t})=>{const[n,r]=X.useState(""),[o,s]=X.useState([]),[u,d]=X.useState(!1),[h,m]=X.useState(!1),[y,v]=X.useState([]),[x,w]=X.useState(!1),[E,M]=X.useState(!1),[A,k]=X.useState([]),[I,D]=Ace($n(Dn.USER_INFO),null),[L,B]=Rce($n(Dn.IS_FORM_CLOSED_BY_USER),!1),[H,Q]=X.useState(null),J=jf("web-socket"),[W,Y]=X.useState([]),[se,fe]=X.useState(null),[xe,ae]=X.useState(!1),[ye,Z]=X.useState(sessionStorage.getItem($n(Dn.LAST_SHOWN_MESSAGE_ID,{botId:t}))),oe=bne(),me=nr(),[qe,U]=X.useState(null),[$e,Ie]=X.useState(null);X.useEffect(()=>{if(J){const dt=Su.connect("/api/v1/chat");fe(dt);const Ge=()=>{console.debug("connected to websocket"),ae(!0)},ct=()=>{console.debug("disconnected from websocket"),ae(!1)},St=pt=>{console.debug("response from websocket",pt);const ut=pt.conversationId??crypto.randomUUID().toString();Z(ut),pt.Variants_quantity&&k(K=>[...K,...pt.Variants_quantity]);const G=[...o,{text:pt.response,products:pt.products,conversationId:ut,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),P(G),v(K=>[...K,[o[o.length-1].text,pt.response]]),m(!1)},Mt=pt=>{if(pt.event==="error"){const ut={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},G=[...o,ut];s(G),P(G),m(!1)}};return Su.on("connect",Ge),Su.on("disconnect",ct),Su.on("response",St),Su.on("system",Mt),()=>{Su.off("connect",Ge),Su.off("disconnect",ct),Su.off("response",St),Su.off("system",Mt)}}},[J,o]);const P=dt=>{sessionStorage.setItem($n(Dn.CHAT_HISTORY,{botId:window.DebalesChat.projectId}),JSON.stringify(dt))},Xe=()=>{const dt=sessionStorage.getItem($n(Dn.CHAT_HISTORY,{botId:window.DebalesChat.projectId}));return dt?JSON.parse(dt):[]},_t=X.useCallback(async()=>{if(t)try{d(!0);const dt=await fetch(`${ci}/api/wordpress/UiData?value=${t}`),Ge=await dt.json();if(!dt.ok)throw new Error("failed to fetch data"+Ge.error);const ct=document.getElementById("debales-ai-assistant");ct&&(ct.style.zIndex=String(Ge.zIndex??2031483602)),Ie(Ge),Ge!=null&&Ge.shopifyShopDomain&&Bne(Ge.shopifyShopDomain).then(Mt=>{U(Mt)}),Y(Ge.suggestedQuestions);const St=Xe();if(St.length>0)s(St);else{const Mt={text:Ge.initialMessage||"Hi, I am an AI Assistant. How can I help you?",isBot:!0};s([Mt])}}catch(dt){console.error(dt)}finally{d(!1)}},[t]);X.useEffect(()=>{_t()},[_t]);const Pe=X.useMemo(()=>{var dt;return!!(!L&&((dt=$e==null?void 0:$e.pluginConfig)!=null&&dt.collectedUserInfo)&&($e.pluginConfig.collectedUserInfo.name||$e.pluginConfig.collectedUserInfo.email||$e.pluginConfig.collectedUserInfo.phone)&&!I)},[$e,I,L]),zt=X.useCallback(async(dt,Ge,ct,St,Mt,pt)=>{if(!dt||dt.trim()===""||h&&!ct)return;let ut=[...o];St?St&&o.length<=2?(w(!0),ut=[]):w(!1):(ut.push({text:dt,isBot:!1}),w(!1));const G=nr();m(!0);try{s(ut),P(ut);const K=await fetch(`${ci}/api/wordpress/ChatWithBot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:G,userMessage:dt,nameSpace:t,chat_history:y,leading_queries:Mt,answer:Ge,products:ct,userInfo:JSON.stringify(I),anonymousUserId:oe,distinctId:yu.getDistinctId(),timestamp:new Date().toISOString(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,followUpQuestion:pt})});if(!K.ok)throw new Error("Network response was not ok");const le=await K.json(),Re=le.conversationId??crypto.randomUUID().toString();Z(Re),le.Variants_quantity&&k(Ze=>[...Ze,...le.Variants_quantity]);const Ne=[...ut,{text:le.response,products:le.products,conversationId:Re,rating:"neutral",leading_queries:le.leading_queries,collections:le.collections,variants:le.variants,shop:le.shop,Variants_quantity:le.Variants_quantity,monthlyChatLimitReached:le.monthlyChatLimitReached,isBot:!0}];s(Ne),P(Ne),v(Ze=>[...Ze,[dt,le.response]])}catch(K){console.error(K);const le={text:"I am facing some network issues. Can you please check your network and try again?",isBot:!0},Re=[...ut,le];St||(s(Re),P(Re))}finally{m(!1)}},[o,h,y,t,oe,I]),Et=X.useCallback(dt=>{$e&&Ie(Ge=>Ge?{...Ge,mobileDisplayMode:dt}:null)},[$e]),$t=X.useCallback(async(dt,Ge,ct,St,Mt,pt)=>{if(!dt||dt.trim()===""||h&&!ct)return;let ut=[...o];if(St?St&&o.length<=2?(w(!0),ut=[]):w(!1):(ut.push({text:dt,isBot:!1}),w(!1)),m(!0),s(ut),P(ut),se&&xe){const G={type:Sce.MESSAGE,role:wce.USER,query:dt,nameSpace:t,leadingQueries:Mt,answer:Ge,products:ct,userInfo:I,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,timestamp:new Date().toISOString(),sessionId:me,anonymousUserId:oe,distinctId:yu.getDistinctId(),followUpQuestion:pt};Su.emit("chat",G)}else zt(dt,Ge,ct,St,Mt,pt)},[o,h,t,oe,se,xe,me,zt,I]),Ut={sessionId:me,messages:o,isLoading:u,isMessageLoading:h,isKlaviyoMessage:x,showUserInfoModel:E,pendingBulkItems:A,lastedBotmessageId:ye,uiData:$e,storeMetaData:qe,suggestedQuestions:W,isUserInfoNeeded:Pe,input:n,pendingQuestion:H,userInfo:I,isFormClosedByUser:L,onSendMessage:J?$t:zt,setMessages:s,setIsLoading:d,setIsMessageLoading:m,setIsKlaviyoMessage:w,setShowUserInfoModel:M,setPendingBulkItems:k,setLastedBotmessageId:Z,fetchUiInfo:_t,changeDisplayModel:Et,saveConversation:P,loadConversation:Xe,setSuggestedQuestions:Y,setUserInfo:D,setInput:r,setPendingQuestion:Q,setIsFormClosedByUser:B};return O.jsx(w9.Provider,{value:Ut,children:e})};function Dce(e){const t=JR.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:nr()}),n.group("project",e.botId,{platform:ud.detect()});const r=yo();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});
|