@v-tilt/browser 1.8.0 → 1.10.0
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/all-external-dependencies.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/autocapture-types.d.ts +130 -0
- package/dist/autocapture-utils.d.ts +78 -0
- package/dist/autocapture.d.ts +84 -0
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/core/capture.d.ts +70 -0
- package/dist/core/feature-manager.d.ts +95 -0
- package/dist/core/identity.d.ts +77 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/remote-config.d.ts +50 -0
- package/dist/extensions/chat/chat-wrapper.d.ts +36 -10
- package/dist/extensions/chat/chat.d.ts +1 -1
- package/dist/extensions/chat/types.d.ts +23 -11
- package/dist/extensions/history-autocapture.d.ts +34 -7
- package/dist/extensions/replay/session-recording-wrapper.d.ts +42 -11
- package/dist/extensions/replay/types.d.ts +1 -1
- package/dist/extensions/web-vitals/index.d.ts +7 -0
- package/dist/extensions/web-vitals/web-vitals-manager.d.ts +81 -0
- package/dist/external-scripts-loader.js.map +1 -1
- package/dist/feature.d.ts +231 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +904 -317
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +904 -317
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/types.d.ts +50 -2
- package/dist/utils/event-emitter.d.ts +106 -0
- package/dist/utils/globals.d.ts +24 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/safewrap.d.ts +101 -0
- package/dist/utils/type-guards.d.ts +70 -0
- package/dist/vtilt.d.ts +66 -329
- package/dist/web-vitals.d.ts +39 -53
- package/dist/web-vitals.js.map +1 -1
- package/package.json +65 -65
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,n)}function t(t){return function(){var i=this,r=arguments;return new Promise(function(n,s){var o=t.apply(i,r);function a(t){e(o,n,s,a,l,"next",t)}function l(t){e(o,n,s,a,l,"throw",t)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}var r="1.8.0",n="__vt_session",s="__vt_window_id",o="__vt_primary_window",a="__vt_user_state",l="__vt_device_id",d="__vt_anonymous_id",u="__vt_remote_config",h="__vt_distinct_id",c="__vt_user_properties",g="localStorage",v="localStorage+cookie",_="sessionStorage",f="memory",p="$initial_person_info";class m{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!document.currentScript)return i({token:e.token||""},e);var t=document.currentScript,r=i({token:""},e);r.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,r.script_host=t.getAttribute("data-script-host")||e.script_host,r.proxy=t.getAttribute("data-proxy")||e.proxy,r.proxyUrl=t.getAttribute("data-proxy-url")||e.proxyUrl,r.token=t.getAttribute("data-token")||e.token||"",r.projectId=t.getAttribute("data-project-id")||e.projectId||"",r.domain=t.getAttribute("data-domain")||e.domain,r.storage=t.getAttribute("data-storage")||e.storage,r.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var n="true"===t.getAttribute("data-capture-performance");if(r.capture_performance=!!n||e.capture_performance,r.proxy&&r.proxyUrl)throw console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them."),new Error("Both data-proxy and data-proxy-url are specified. Please use only one of them.");for(var s of(r.globalAttributes=i({},e.globalAttributes),Array.from(t.attributes)))s.name.startsWith("data-vt-")&&(r.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return r}getConfig(){return i({},this.config)}updateConfig(e){this.config=i({},this.config,e)}}function y(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function b(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function w(e,t,i){if(e)if(Array.isArray(e))e.forEach((e,r)=>{t.call(i,e,r)});else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(i,e[r],r)}function S(e,t,i,r){var{capture:n=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:n,passive:s})}function C(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function I(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var n of i)for(var s of n)e.push(s);return e}var T="undefined"!=typeof window?window:void 0,L="undefined"!=typeof globalThis?globalThis:T,k=null==L?void 0:L.navigator,M=null==L?void 0:L.document,E=null==L?void 0:L.location,R=null==L?void 0:L.fetch,x=(null==L?void 0:L.XMLHttpRequest)&&"withCredentials"in new L.XMLHttpRequest?L.XMLHttpRequest:void 0;null==L||L.AbortController;var P=null==k?void 0:k.userAgent,A=null!=T?T:{},z=[d,l,h,a],O=31536e3,$=["herokuapp.com","vercel.app","netlify.app"];function q(e){var t;if(!e||"undefined"==typeof document)return"";var i=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!i)return"";var r=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return r?"."+r[0]:""}class U{constructor(e){var t,i,r;this.memoryStorage=new Map,this._localStorageSupported=null,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var i=t.split(".").slice(-2).join(".");return!$.includes(i)}(),this.sameSite=null!==(i=e.sameSite)&&void 0!==i?i:"Lax",this.secure=null!==(r=e.secure)&&void 0!==r?r:"undefined"!=typeof location&&"https:"===location.protocol}isLocalStorageSupported(){if(null!==this._localStorageSupported)return this._localStorageSupported;if(void 0===T||!T.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";T.localStorage.setItem(e,"1");var t="1"===T.localStorage.getItem(e);return T.localStorage.removeItem(e),this._localStorageSupported=t,t||console.warn("[vTilt] localStorage unavailable, using cookies"),t}catch(e){return this._localStorageSupported=!1,console.warn("[vTilt] localStorage unavailable, using cookies"),!1}}isCriticalProperty(e){return z.includes(e)}get(e){var t;try{switch(this.method){case f:return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;case v:return this.getLocalStoragePlusCookie(e);case g:return this.getLocalStorage(e);case _:return this.readFromSessionStorage(e);default:return this.getCookie(e)}}catch(t){return console.warn('[vTilt] Storage get error for "'+e+'":',t),null}}set(e,t,i){try{switch(this.method){case f:this.memoryStorage.set(e,t);break;case v:this.setLocalStoragePlusCookie(e,t,i);break;case g:this.setLocalStorage(e,t);break;case _:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=i?i:O)}}catch(t){console.warn('[vTilt] Storage set error for "'+e+'":',t)}}remove(e){try{switch(this.method){case f:this.memoryStorage.delete(e);break;case v:this.removeLocalStoragePlusCookie(e);break;case g:this.removeLocalStorage(e);break;case _:this.removeFromSessionStorage(e);break;default:this.removeCookie(e)}}catch(t){console.warn('[vTilt] Storage remove error for "'+e+'":',t)}}getLocalStoragePlusCookie(e){if(this.isCriticalProperty(e)){var t=this.getCookie(e),i=this.getLocalStorage(e);if(null!==t){if(i!==t&&this.isLocalStorageSupported())try{null==T||T.localStorage.setItem(e,t)}catch(e){}return t}return i}return this.getLocalStorage(e)}setLocalStoragePlusCookie(e,t,i){this.setLocalStorage(e,t),this.isCriticalProperty(e)&&this.setCookie(e,t,null!=i?i:O)}removeLocalStoragePlusCookie(e){this.removeLocalStorage(e),this.isCriticalProperty(e)&&this.removeCookie(e)}getLocalStorage(e){var t;if(!this.isLocalStorageSupported())return null;try{return null!==(t=null==T?void 0:T.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==T||T.localStorage.setItem(e,t)}catch(e){console.warn("[vTilt] localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==T||T.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==T?void 0:T.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==T||T.sessionStorage.setItem(e,t)}catch(e){console.warn("[vTilt] sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==T||T.sessionStorage.removeItem(e)}catch(e){}}getCookie(e){if("undefined"==typeof document)return null;var t=e+"=";for(var i of document.cookie.split(";")){var r=i.trim();if(r.startsWith(t))try{return decodeURIComponent(r.slice(t.length))}catch(e){return r.slice(t.length)}}return null}setCookie(e,t,i){if("undefined"!=typeof document){var r=q(this.cross_subdomain),n=e+"="+encodeURIComponent(t)+"; Max-Age="+i+"; path=/; SameSite="+this.sameSite;this.secure&&(n+="; Secure"),r&&(n+="; domain="+r),document.cookie=n}}removeCookie(e){if("undefined"!=typeof document){var t=q(this.cross_subdomain);document.cookie=e+"=; Max-Age=0; path=/"+(t?"; domain="+t:""),document.cookie=e+"=; Max-Age=0; path=/"}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var i=JSON.parse(t);return i.expiry&&Date.now()>i.expiry?(this.remove(e),null):i.value}catch(e){return null}}setWithExpiry(e,t,r){var n=i({value:t},r?{expiry:Date.now()+r}:{});this.set(e,JSON.stringify(n))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,i){this.set(e,JSON.stringify(t),i)}canUseSessionStorage(){if(void 0===T||!(null==T?void 0:T.sessionStorage))return!1;try{var e="__vt_ss_test__";return T.sessionStorage.setItem(e,"1"),T.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==T?void 0:T.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class D{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=y(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||y();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(y())}_getSessionIdRaw(){return this.storage.get(n)}_storeSessionId(e){this.storage.set(n,e,1800)}_clearSessionId(){this.storage.remove(n)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(s);if(t)return this._windowId=t,t}var i=y();return this._setWindowId(i),i}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(s,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(o),i=e.getItem(s);i&&!t?this._windowId=i:(i&&e.removeItem(s),this._setWindowId(y())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=y()}_listenToUnload(){var e=this.storage.getSessionStorage();T&&e&&S(T,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"})}}function B(e){if(!M)return null;var t=M.createElement("a");return t.href=e,t}function j(e,t){for(var i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<i.length;r++){var n=i[r].split("=");if(n[0]===t){if(n.length<2)return"";var s=n[1];try{s=decodeURIComponent(s)}catch(e){}return s.replace(/\+/g," ")}}return""}function N(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],d=(a||"").split("&"),u=[],h=0;h<d.length;h++){var c=d[h].split("="),g=c[0],v=c.slice(1).join("=");-1!==t.indexOf(g)?u.push(g+"="+i):g&&u.push(g+(v?"="+v:""))}var _=u.join("&");return l+(_?"?"+_:"")+(s?"#"+s:"")}function F(e){return"function"==typeof e}var V="Mobile",W="iOS",J="Android",H="Tablet",Q=J+" "+H,G="iPad",X="Apple",K=X+" Watch",Z="Safari",Y="BlackBerry",ee="Samsung",te=ee+"Browser",ie=ee+" Internet",re="Chrome",ne=re+" OS",se=re+" "+W,oe="Internet Explorer",ae=oe+" "+V,le="Opera",de=le+" Mini",ue="Edge",he="Microsoft "+ue,ce="Firefox",ge=ce+" "+W,ve="Nintendo",_e="PlayStation",fe="Xbox",pe=J+" "+V,me=V+" "+Z,ye="Windows",be=ye+" Phone",we="Nokia",Se="Ouya",Ce="Generic",Ie=Ce+" "+V.toLowerCase(),Te=Ce+" "+H.toLowerCase(),Le="Konqueror",ke="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+ke),Ee=new RegExp(fe,"i"),Re=new RegExp(_e+" \\w+","i"),xe=new RegExp(ve+" \\w+","i"),Pe=new RegExp(Y+"|PlayBook|BB10","i"),Ae={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function ze(e,t){return e.toLowerCase().includes(t.toLowerCase())}var Oe=(e,t)=>t&&ze(t,X)||function(e){return ze(e,Z)&&!ze(e,re)&&!ze(e,J)}(e),$e=function(e,t){return t=t||"",ze(e," OPR/")&&ze(e,"Mini")?de:ze(e," OPR/")?le:Pe.test(e)?Y:ze(e,"IE"+V)||ze(e,"WPDesktop")?ae:ze(e,te)?ie:ze(e,ue)||ze(e,"Edg/")?he:ze(e,"FBIOS")?"Facebook "+V:ze(e,"UCWEB")||ze(e,"UCBrowser")?"UC Browser":ze(e,"CriOS")?se:ze(e,"CrMo")||ze(e,re)?re:ze(e,J)&&ze(e,Z)?pe:ze(e,"FxiOS")?ge:ze(e.toLowerCase(),Le.toLowerCase())?Le:Oe(e,t)?ze(e,V)?me:Z:ze(e,ce)?ce:ze(e,"MSIE")||ze(e,"Trident/")?oe:ze(e,"Gecko")?ce:""},qe={[ae]:[new RegExp("rv:"+ke)],[he]:[new RegExp(ue+"?\\/"+ke)],[re]:[new RegExp("("+re+"|CrMo)\\/"+ke)],[se]:[new RegExp("CriOS\\/"+ke)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ke)],[Z]:[Me],[me]:[Me],[le]:[new RegExp("(Opera|OPR)\\/"+ke)],[ce]:[new RegExp(ce+"\\/"+ke)],[ge]:[new RegExp("FxiOS\\/"+ke)],[Le]:[new RegExp("Konqueror[:/]?"+ke,"i")],[Y]:[new RegExp(Y+" "+ke),Me],[pe]:[new RegExp("android\\s"+ke,"i")],[ie]:[new RegExp(te+"\\/"+ke)],[oe]:[new RegExp("(rv:|MSIE )"+ke)],Mozilla:[new RegExp("rv:"+ke)]},Ue=function(e,t){var i=$e(e,t),r=qe[i];if(void 0===r)return null;for(var n=0;n<r.length;n++){var s=r[n],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},De=[[new RegExp(fe+"; "+fe+" (.*?)[);]","i"),e=>[fe,e&&e[1]||""]],[new RegExp(ve,"i"),[ve,""]],[new RegExp(_e,"i"),[_e,""]],[Pe,[Y,""]],[new RegExp(ye,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[be,""];if(new RegExp(V).test(t)&&!/IEMobile\b/.test(t))return[ye+" "+V,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=Ae[r]||"";return/arm/i.test(t)&&(n="RT"),[ye,n]}return[ye,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[W,t.join(".")]}return[W,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+J+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+J+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[J,t.join(".")]}return[J,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ne,""]],[/Linux|debian/i,["Linux",""]]],Be=function(e){return xe.test(e)?ve:Re.test(e)?_e:Ee.test(e)?fe:new RegExp(Se,"i").test(e)?Se:new RegExp("("+be+"|WPDesktop)","i").test(e)?be:/iPad/.test(e)?G:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?K:Pe.test(e)?Y:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(we,"i").test(e)?we:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(V).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?J:Q:J:new RegExp("(pda|"+V+")","i").test(e)?Ie:new RegExp(H,"i").test(e)&&!new RegExp(H+" pc","i").test(e)?Te:""},je="https?://(.*)",Ne=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Fe=I(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ne),Ve="<masked>";function We(e){var t=function(e){return e?0===e.search(je+"google.([^/?]*)")?"google":0===e.search(je+"bing.com")?"bing":0===e.search(je+"yahoo.com")?"yahoo":0===e.search(je+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var n=M?j(M.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function Je(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function He(){return(null==M?void 0:M.referrer)||"$direct"}function Qe(){var e;return(null==M?void 0:M.referrer)&&(null===(e=B(M.referrer))||void 0===e?void 0:e.host)||"$direct"}function Ge(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=B(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=B(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Fe.concat([]),i={};return w(t,function(t){var r=j(e,t);i[t]=r||null}),i}(r);C(n,o)}i&&C(n,We(i));return n}function Xe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Ke(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Ze(e,t){if(!P)return{};var i,n,s,[o,a]=function(e){for(var t=0;t<De.length;t++){var[i,r]=De[t],n=i.exec(e),s=n&&(F(r)?r(n,e):r);if(s)return s}return["",""]}(P);return C(function(e){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=e[i];null!=r&&""!==r&&(t[i]=r)}return t}({$os:o,$os_version:a,$browser:$e(P,navigator.vendor),$device:Be(P),$device_type:(n=P,s=Be(n),s===G||s===Q||"Kobo"===s||"Kindle Fire"===s||s===Te?H:s===ve||s===fe||s===_e||s===Se?"Console":s===K?"Wearable":s?V:"Desktop"),$timezone:Xe(),$timezone_offset:Ke()}),{$current_url:N(null==E?void 0:E.href,[],Ve),$host:null==E?void 0:E.host,$pathname:null==E?void 0:E.pathname,$raw_user_agent:P.length>1e3?P.substring(0,997)+"...":P,$browser_version:Ue(P,navigator.vendor),$browser_language:Je(),$browser_language_prefix:(i=Je(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==T?void 0:T.screen.height,$screen_width:null==T?void 0:T.screen.width,$viewport_height:null==T?void 0:T.innerHeight,$viewport_width:null==T?void 0:T.innerWidth,$lib:"web",$lib_version:r,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}class Ye{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){return this.userIdentity.anonymous_id||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(d,this.userIdentity.anonymous_id,O)),this.userIdentity.anonymous_id}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}identify(e,t,r){if("number"==typeof e&&(e=e.toString(),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.isDistinctIdStringLike(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this.userIdentity.distinct_id;if(this.userIdentity.distinct_id=e,!this.userIdentity.device_id){var s=n||this.userIdentity.anonymous_id;this.userIdentity.device_id=s,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:s})}e!==n&&(this.userIdentity.distinct_id=e);var o="anonymous"===this.userIdentity.user_state;e!==n&&o?(this.userIdentity.user_state="identified",t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):t||r?("anonymous"===this.userIdentity.user_state&&(this.userIdentity.user_state="identified"),t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):e!==n&&(this.userIdentity.user_state="identified",this.saveUserIdentity())}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){if(!e&&!t)return!1;var r=this.userIdentity.distinct_id||this.userIdentity.anonymous_id,n=this.getPersonPropertiesHash(r,e,t);return this._cachedPersonProperties===n?(console.info("VTilt: A duplicate setUserProperties call was made with the same properties. It has been ignored."),!1):(e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity(),this._cachedPersonProperties=n,!0)}reset(e){var t=this.generateAnonymousId(),r=this.userIdentity.device_id,n=e?this.generateDeviceId():r;this.userIdentity={distinct_id:null,anonymous_id:t,device_id:n,properties:{},user_state:"anonymous"},this._cachedPersonProperties=null,this.saveUserIdentity(),this.userIdentity.properties=i({},this.userIdentity.properties,{$last_vtilt_reset:(new Date).toISOString()}),this.saveUserIdentity()}setDistinctId(e){this.userIdentity.distinct_id=e,this.saveUserIdentity()}setUserState(e){this.userIdentity.user_state=e,this.saveUserIdentity()}updateUserProperties(e,t){e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity()}ensureDeviceId(e){this.userIdentity.device_id||(this.userIdentity.device_id=e,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:e}),this.saveUserIdentity())}createAlias(e,t){return this.isValidDistinctId(e)?(void 0===t&&(t=this.getDistinctId()||this.getAnonymousId()),this.isValidDistinctId(t)?e===t?(console.warn("alias matches current distinct_id - should use identify instead"),null):{distinct_id:e,original:t}:(console.warn("Invalid original distinct ID"),null)):(console.warn("Invalid alias provided"),null)}isDistinctIdStringLikePublic(e){return this.isDistinctIdStringLike(e)}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[p]){var i=function(e,t){var i=e?I([],Ne,t||[]):[],r=null==E?void 0:E.href.substring(0,1e3);return{r:He().substring(0,1e3),u:r?N(r,i,Ve):void 0}}(e,t);this.register_once({[p]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[p];return i?(e=Ge(i),t={},w(e,function(e,i){var r;t["$initial_"+(r=String(i),r.startsWith("$")?r.substring(1):r)]=e}),t):{}}update_referrer_info(){var e={$referrer:He(),$referring_domain:Qe()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(d),t=this.storage.get(l),i=this.storage.get(h),r=this.storage.get(a),n=this.getStoredUserProperties(),s=e||this.generateAnonymousId(),o=t||this.generateDeviceId(),u=i||null,c=r||"anonymous",g=s||this.generateAnonymousId();return e||this.storage.set(d,g,O),t||this.storage.set(l,o,O),r||this.storage.set(a,c,O),{distinct_id:u,anonymous_id:g,device_id:o,properties:n,user_state:c}}saveUserIdentity(){this.storage.set(d,this.userIdentity.anonymous_id,O),this.storage.set(l,this.userIdentity.device_id,O),this.storage.set(a,this.userIdentity.user_state,O),this.userIdentity.distinct_id?this.storage.set(h,this.userIdentity.distinct_id,O):this.storage.remove(h),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(c)||{}}setStoredUserProperties(e){this.storage.setJSON(c,e,O)}register_once(e,t){var i=this.getStoredUserProperties(),r=!1;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(n in i||(i[n]=e[n],r=!0));if(t)for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(s in i||(i[s]=t[s],r=!0));r&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+y()}generateDeviceId(){return"device_"+y()}getPersonPropertiesHash(e,t,i){return JSON.stringify({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}isValidDistinctId(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return!["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none"].includes(t)&&0!==e.trim().length}isDistinctIdStringLike(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"].includes(t)}updateStorageMethod(e,t){this.storage=new U({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var et=["LCP","CLS","FCP","INP","TTFB"],tt=["LCP","CLS","FCP","INP"],it=9e5,rt="[WebVitals]";class nt{constructor(e,t){this.initialized=!1,this.instance=t,this.buffer=this.createEmptyBuffer(),this.config=this.parseConfig(e.capture_performance),this.isEnabled&&T&&this.startIfEnabled()}parseConfig(e){return"boolean"==typeof e?{web_vitals:e}:"object"==typeof e&&null!==e?e:{web_vitals:!1}}get isEnabled(){var e=null==E?void 0:E.protocol;return("http:"===e||"https:"===e)&&!1!==this.config.web_vitals}get allowedMetrics(){return this.config.web_vitals_allowed_metrics||tt}get flushTimeoutMs(){return this.config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this.config.__web_vitals_max_value;return void 0===e?it:0===e?0:e<6e4?it:e}createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}getWebVitalsCallbacks(){var e;return null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}startIfEnabled(){if(this.isEnabled&&!this.initialized){var e=this.getWebVitalsCallbacks();e?this.startCapturing(e):this.loadWebVitals()}}loadWebVitals(){var e,t=null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this.instance,"web-vitals",e=>{if(e)console.error(rt+" Failed to load web-vitals:",e);else{var t=this.getWebVitalsCallbacks();t?this.startCapturing(t):console.error(rt+" web-vitals loaded but callbacks not registered")}}):console.warn(rt+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}startCapturing(e){if(!this.initialized){var t=this.allowedMetrics,i=this.addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(i),t.includes("CLS")&&e.onCLS&&e.onCLS(i,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(i),t.includes("INP")&&e.onINP&&e.onINP(i),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(i),this.initialized=!0}}getCurrentUrl(){var e;return null===(e=null==T?void 0:T.location)||void 0===e?void 0:e.href}getCurrentPathname(){return null==E?void 0:E.pathname}addToBuffer(e){try{if(!T||!M||!E)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(rt+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(rt+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this.getCurrentUrl(),r=this.getCurrentPathname();if(!t)return void console.warn(rt+" Could not determine current URL");this.buffer.url&&this.buffer.url!==t&&this.flush(),this.buffer.url||(this.buffer.url=t,this.buffer.pathname=r),this.buffer.firstMetricTimestamp||(this.buffer.firstMetricTimestamp=Date.now());var n=this.cleanAttribution(e.attribution),s=this.instance.getSessionId(),o=this.getWindowId(),a=i({},e,{attribution:n,timestamp:Date.now(),$current_url:t,$session_id:s,$window_id:o}),l=this.buffer.metrics.findIndex(t=>t.name===e.name);l>=0?this.buffer.metrics[l]=a:this.buffer.metrics.push(a),this.scheduleFlush(),this.buffer.metrics.length>=this.allowedMetrics.length&&this.flush()}catch(e){console.error(rt+" Error adding metric to buffer:",e)}}cleanAttribution(e){if(e){var t=i({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}getWindowId(){var e;try{return(null===(e=this.instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}scheduleFlush(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flush()},this.flushTimeoutMs)}flush(){if(this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0),0!==this.buffer.metrics.length){try{var e={$pathname:this.buffer.pathname,$current_url:this.buffer.url};for(var t of this.buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this.instance.capture("$web_vitals",e)}catch(e){console.error(rt+" Error flushing metrics:",e)}this.buffer=this.createEmptyBuffer()}}}function st(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return F(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ot{constructor(e){var t;this._instance=e,this._lastPathname=(null===(t=null==T?void 0:T.location)||void 0===t?void 0:t.pathname)||""}get isEnabled(){return!0}startIfEnabled(){this.isEnabled&&this.monitorHistoryChanges()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0}monitorHistoryChanges(){var e,t;if(T&&E&&(this._lastPathname=E.pathname||"",T.history)){var i=this;(null===(e=T.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||st(T.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("pushState")}),(null===(t=T.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||st(T.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("replaceState")}),this._setupPopstateListener()}}_capturePageview(e){var t;try{var i=null===(t=null==T?void 0:T.location)||void 0===t?void 0:t.pathname;if(!i||!E||!M)return;if(i!==this._lastPathname&&this.isEnabled){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}catch(t){console.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener&&T){var e=()=>{this._capturePageview("popstate")};S(T,"popstate",e),this._popstateListener=()=>{T&&T.removeEventListener("popstate",e)}}}}var at="[SessionRecording]";class lt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._config=t}get started(){var e;return!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.isStarted)}get status(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.sessionId)||""}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),console.info(at+" starting")):this.stopRecording()}}stopRecording(){var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.stop()}log(e,t){var i;void 0===t&&(t="log"),(null===(i=this._lazyLoadedRecording)||void 0===i?void 0:i.log)?this._lazyLoadedRecording.log(e,t):console.warn(at+" log called before recorder was ready")}updateConfig(e){var t;this._config=i({},this._config,e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config)}get _isRecordingEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!T&&i&&r}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,n;if(this._isRecordingEnabled)if((null===(i=null===(t=null==A?void 0:A.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=A.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(n=A.__VTiltExtensions__)||void 0===n?void 0:n.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(at+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(at+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=A.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(at+" initSessionRecording not available after script load")}}var dt=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(dt||{}),ut=Uint8Array,ht=Uint16Array,ct=Int32Array,gt=new ut([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),vt=new ut([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_t=new ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=function(e,t){for(var i=new ht(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new ct(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return{b:i,r:n}},pt=ft(gt,2),mt=pt.b,yt=pt.r;mt[28]=258,yt[258]=28;for(var bt=ft(vt,0).r,wt=new ht(32768),St=0;St<32768;++St){var Ct=(43690&St)>>1|(21845&St)<<1;Ct=(61680&(Ct=(52428&Ct)>>2|(13107&Ct)<<2))>>4|(3855&Ct)<<4,wt[St]=((65280&Ct)>>8|(255&Ct)<<8)>>1}var It=function(e,t,i){for(var r=e.length,n=0,s=new ht(t);n<r;++n)e[n]&&++s[e[n]-1];var o,a=new ht(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new ht(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var d=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,c=h|(1<<u)-1;h<=c;++h)o[wt[h]>>l]=d}else for(o=new ht(r),n=0;n<r;++n)e[n]&&(o[n]=wt[a[e[n]-1]++]>>15-e[n]);return o},Tt=new ut(288);for(St=0;St<144;++St)Tt[St]=8;for(St=144;St<256;++St)Tt[St]=9;for(St=256;St<280;++St)Tt[St]=7;for(St=280;St<288;++St)Tt[St]=8;var Lt=new ut(32);for(St=0;St<32;++St)Lt[St]=5;var kt=It(Tt,9,0),Mt=It(Lt,5,0),Et=function(e){return(e+7)/8|0},Rt=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new ut(e.subarray(t,i))},xt=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},Pt=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},At=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return{t:Bt,l:0};if(1==n){var o=new ut(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],d=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f<i[h].f?d++:h++],l=i[d!=u&&i[d].f<i[h].f?d++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var c=s[0].s;for(r=1;r<n;++r)s[r].s>c&&(c=s[r].s);var g=new ht(c+1),v=zt(i[u-1],g,0);if(v>t){r=0;var _=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(g[m]>t))break;_+=p-(1<<v-g[m]),g[m]=t}for(_>>=f;_>0;){var y=s[r].s;g[y]<t?_-=1<<t-g[y]++-1:++r}for(;r>=0&&_;--r){var b=s[r].s;g[b]==t&&(--g[b],++_)}v=t}return{t:new ut(g),l:v}},zt=function(e,t,i){return-1==e.s?Math.max(zt(e.l,t,i+1),zt(e.r,t,i+1)):t[e.s]=i},Ot=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ht(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return{c:i.subarray(0,r),n:t}},$t=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},qt=function(e,t,i){var r=i.length,n=Et(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s<r;++s)e[n+s+4]=i[s];return 8*(n+4+r)},Ut=function(e,t,i,r,n,s,o,a,l,d,u){xt(t,u++,i),++n[256];for(var h=At(n,15),c=h.t,g=h.l,v=At(s,15),_=v.t,f=v.l,p=Ot(c),m=p.c,y=p.n,b=Ot(_),w=b.c,S=b.n,C=new ht(19),I=0;I<m.length;++I)++C[31&m[I]];for(I=0;I<w.length;++I)++C[31&w[I]];for(var T=At(C,7),L=T.t,k=T.l,M=19;M>4&&!L[_t[M-1]];--M);var E,R,x,P,A=d+5<<3,z=$t(n,Tt)+$t(s,Lt)+o,O=$t(n,c)+$t(s,_)+o+14+3*M+$t(C,L)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&A<=z&&A<=O)return qt(t,u,e.subarray(l,l+d));if(xt(t,u,1+(O<z)),u+=2,O<z){E=It(c,g,0),R=c,x=It(_,f,0),P=_;var $=It(L,k,0);xt(t,u,y-257),xt(t,u+5,S-1),xt(t,u+10,M-4),u+=14;for(I=0;I<M;++I)xt(t,u+3*I,L[_t[I]]);u+=3*M;for(var q=[m,w],U=0;U<2;++U){var D=q[U];for(I=0;I<D.length;++I){var B=31&D[I];xt(t,u,$[B]),u+=L[B],B>15&&(xt(t,u,D[I]>>5&127),u+=D[I]>>12)}}}else E=kt,R=Tt,x=Mt,P=Lt;for(I=0;I<a;++I){var j=r[I];if(j>255){Pt(t,u,E[(B=j>>18&31)+257]),u+=R[B+257],B>7&&(xt(t,u,j>>23&31),u+=gt[B]);var N=31&j;Pt(t,u,x[N]),u+=P[N],N>3&&(Pt(t,u,j>>5&8191),u+=vt[N])}else Pt(t,u,E[j]),u+=R[j]}return Pt(t,u,E[256]),u+R[256]},Dt=new ct([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bt=new ut(0),jt=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&-306674912)^i>>>1;e[t]=i}return e}(),Nt=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new ut(s.length+e.length);o.set(s),o.set(e,s.length),e=o,n.w=s.length}return function(e,t,i,r,n,s){var o=s.z||e.length,a=new ut(r+o+5*(1+Math.ceil(o/7e3))+n),l=a.subarray(r,a.length-n),d=s.l,u=7&(s.r||0);if(t){u&&(l[0]=s.r>>3);for(var h=Dt[t-1],c=h>>13,g=8191&h,v=(1<<i)-1,_=s.p||new ht(32768),f=s.h||new ht(v+1),p=Math.ceil(i/3),m=2*p,y=function(t){return(e[t]^e[t+1]<<p^e[t+2]<<m)&v},b=new ct(25e3),w=new ht(288),S=new ht(32),C=0,I=0,T=s.i||0,L=0,k=s.w||0,M=0;T+2<o;++T){var E=y(T),R=32767&T,x=f[E];if(_[R]=x,f[E]=R,k<=T){var P=o-T;if((C>7e3||L>24576)&&(P>423||!d)){u=Ut(e,l,0,b,w,S,I,L,M,T-M,u),L=C=I=0,M=T;for(var A=0;A<286;++A)w[A]=0;for(A=0;A<30;++A)S[A]=0}var z=2,O=0,$=g,q=R-x&32767;if(P>2&&E==y(T-q))for(var U=Math.min(c,P)-1,D=Math.min(32767,T),B=Math.min(258,P);q<=D&&--$&&R!=x;){if(e[T+z]==e[T+z-q]){for(var j=0;j<B&&e[T+j]==e[T+j-q];++j);if(j>z){if(z=j,O=q,j>U)break;var N=Math.min(q,j-2),F=0;for(A=0;A<N;++A){var V=T-q+A&32767,W=V-_[V]&32767;W>F&&(F=W,x=V)}}}q+=(R=x)-(x=_[R])&32767}if(O){b[L++]=268435456|yt[z]<<18|bt[O];var J=31&yt[z],H=31&bt[O];I+=gt[J]+vt[H],++w[257+J],++S[H],k=T+z,++C}else b[L++]=e[T],++w[e[T]]}}for(T=Math.max(T,k);T<o;++T)b[L++]=e[T],++w[e[T]];u=Ut(e,l,d,b,w,S,I,L,M,T-M,u),d||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=f,s.p=_,s.i=T,s.w=k)}else{for(T=s.w||0;T<o+d;T+=65535){var Q=T+65535;Q>=o&&(l[u/8|0]=d,Q=o),u=qt(l,u+1,e.subarray(T,Q))}s.i=o}return Rt(a,0,r+Et(u)+n)}(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,i,r,n)},Ft=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Vt(e,t){t||(t={});var i=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=jt[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var n,s=Nt(e,t,10+((n=t).filename?n.filename.length+1:0),8),o=s.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ft(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(s,t),Ft(s,o-8,i.d()),Ft(s,o-4,r),s}var Wt="undefined"!=typeof TextEncoder&&new TextEncoder,Jt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Jt.decode(Bt,{stream:!0})}catch(e){}dt.MouseMove,dt.MouseInteraction,dt.Scroll,dt.ViewportResize,dt.Input,dt.TouchMove,dt.MediaInteraction,dt.Drag;var Ht="[Chat]";class Qt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t}get isOpen(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isOpen)&&void 0!==t&&t}get isConnected(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isLoading(){var e,t;return this._isLoading||null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isLoading)&&void 0!==t&&t}get unreadCount(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.unreadCount)&&void 0!==t?t:0}get channel(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channel)&&void 0!==t?t:null}get channels(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channels)&&void 0!==t?t:[]}get currentView(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.currentView)&&void 0!==t?t:"list"}open(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.open()})}close(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.close()}toggle(){this._lazyLoadedChat?this._lazyLoadedChat.toggle():this.open()}show(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.show()})}hide(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.hide()}getChannels(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.getChannels()})}selectChannel(e){this._lazyLoadAndThen(()=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.selectChannel(e)})}createChannel(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.createChannel()})}goToChannelList(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.goToChannelList()}sendMessage(e){this._lazyLoadedChat?this._lazyLoadedChat.sendMessage(e):(this._pendingMessages.push(e),this._lazyLoadAndThen(()=>{this._pendingMessages.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.sendMessage(e)}),this._pendingMessages=[]}))}markAsRead(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.markAsRead()}onMessage(e){return this._messageCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onMessage(e):()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onTyping(e):()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onConnectionChange(e):()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}startIfEnabled(){var e=this;return t(function*(){var t,i,r,n;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Ht+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e._isChatEnabled?(null!==(r=null!==(t=e._config.preload)&&void 0!==t?t:null===(i=e._serverConfig)||void 0===i?void 0:i.enabled)&&void 0!==r&&r&&e._schedulePreload(),(null===(n=e._serverConfig)||void 0===n?void 0:n.enabled)&&e._showBubble(),console.info(Ht+" ready (lazy-load on demand)")):console.info(Ht+" not enabled (check dashboard settings)")):console.info(Ht+" disabled by code config")})()}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,r,n,s,o,a,l,d,u,h,c,g,v,_,f,p,m=this._serverConfig,y=this._config;return{enabled:null!==(t=null!==(e=y.enabled)&&void 0!==e?e:null==m?void 0:m.enabled)&&void 0!==t&&t,autoConfig:null===(i=y.autoConfig)||void 0===i||i,position:null!==(n=null!==(r=y.position)&&void 0!==r?r:null==m?void 0:m.position)&&void 0!==n?n:"bottom-right",greeting:null!==(s=y.greeting)&&void 0!==s?s:null==m?void 0:m.greeting,color:null!==(a=null!==(o=y.color)&&void 0!==o?o:null==m?void 0:m.color)&&void 0!==a?a:"#6366f1",aiMode:null===(d=null!==(l=y.aiMode)&&void 0!==l?l:null==m?void 0:m.ai_enabled)||void 0===d||d,aiGreeting:null!==(u=y.aiGreeting)&&void 0!==u?u:null==m?void 0:m.ai_greeting,preload:null!==(h=y.preload)&&void 0!==h&&h,theme:null!==(c=y.theme)&&void 0!==c?c:{primaryColor:null!==(v=null!==(g=y.color)&&void 0!==g?g:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(_=y.offlineMessage)&&void 0!==_?_:null==m?void 0:m.offline_message,collectEmailOffline:null===(p=null!==(f=y.collectEmailOffline)&&void 0!==f?f:null==m?void 0:m.collect_email_offline)||void 0===p||p}}destroy(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[]}get _isChatEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}_fetchServerSettings(){var e=this;return t(function*(){if(!e._configFetched){var t=e._instance.getConfig(),i=t.token,r=t.api_host;if(!i||!r)return console.warn(Ht+" Cannot fetch settings: missing token or api_host"),void(e._configFetched=!0);try{var n=r+"/api/chat/settings?token="+encodeURIComponent(i),s=yield fetch(n);if(!s.ok)return console.warn(Ht+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Ht+" Loaded settings from dashboard")}catch(t){console.warn(Ht+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==T?void 0:T.document)&&!document.getElementById("vtilt-chat-bubble")){var e=this.getMergedConfig(),t=e.position||"bottom-right",i=e.color||"#6366f1",r=document.createElement("div");r.id="vtilt-chat-bubble",r.setAttribute("style",("\n position: fixed;\n bottom: 20px;\n "+("bottom-right"===t?"right: 20px;":"left: 20px;")+"\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: "+i+";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n z-index: 999999;\n ").trim()),r.innerHTML='\n <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>\n </svg>\n ',r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.05)",r.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),r.addEventListener("click",()=>{this.open()}),document.body.appendChild(r)}}get _scriptName(){return"chat"}_schedulePreload(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this._lazyLoad(),{timeout:5e3}):setTimeout(()=>this._lazyLoad(),3e3)}_lazyLoadAndThen(e){this._lazyLoadedChat?e():(this._pendingCallbacks.push(e),this._lazyLoad())}_lazyLoad(){var e,t;if(!(this._isLoading||this._lazyLoadedChat||this._loadError))if(null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=A.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Ht+" loadExternalDependency not available. Chat cannot start."),this._isLoading=!1,void(this._loadError="loadExternalDependency not available");i(this._instance,this._scriptName,e=>{if(this._isLoading=!1,e)return console.error(Ht+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=A.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Ht+" initChat not available after script load"),void(this._loadError="initChat not available");if(!this._lazyLoadedChat){var i=this.getMergedConfig();this._lazyLoadedChat=t(this._instance,i),this._messageCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onMessage(e)}),this._typingCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onTyping(e)}),this._connectionCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onConnectionChange(e)});var r=null===document||void 0===document?void 0:document.getElementById("vtilt-chat-bubble");r&&r.remove()}this._pendingCallbacks.forEach(e=>e()),this._pendingCallbacks=[],console.info(Ht+" loaded and ready")}}var Gt,Xt="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Gt||(Gt={}));var Kt=e=>{var{data:t,compression:i}=e;if(t){var r=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(t),n=new Blob([r]).size;if(i===Gt.GZipJS&&n>=1024)try{var s=Vt(function(e,t){if(Wt)return Wt.encode(e);for(var i=e.length,r=new ut(e.length+(e.length>>1)),n=0,s=function(e){r[n++]=e},o=0;o<i;++o){if(n+5>r.length){var a=new ut(n+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return Rt(r,0,n)}(r),{mtime:0}),o=new Blob([s],{type:Xt});if(o.size<.95*n)return{contentType:Xt,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:n}}},Zt=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Kt(e);if(r){var{contentType:n,body:s,estimatedSize:o}=r,a=e.compression===Gt.GZipJS&&n===Xt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,l=i({"Content-Type":n},e.headers||{}),d=new AbortController,u=e.timeout?setTimeout(()=>d.abort(),e.timeout):null;fetch(a,{method:e.method||"POST",headers:l,body:s,keepalive:o<52428.8,signal:d.signal}).then(function(){var i=t(function*(t){var i,r=yield t.text(),n={statusCode:t.status,text:r};if(200===t.status)try{n.json=JSON.parse(r)}catch(e){}null===(i=e.callback)||void 0===i||i.call(e,n)});return function(e){return i.apply(this,arguments)}}()).catch(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{u&&clearTimeout(u)})}}},{name:"XHR",available:"undefined"!=typeof XMLHttpRequest,method:e=>{var t=Kt(e);if(t){var{contentType:i,body:r}=t,n=e.compression===Gt.GZipJS&&i===Xt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,s=new XMLHttpRequest;s.open(e.method||"POST",n,!0),e.headers&&Object.entries(e.headers).forEach(e=>{var[t,i]=e;s.setRequestHeader(t,i)}),s.setRequestHeader("Content-Type",i),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{var t;if(4===s.readyState){var i={statusCode:s.status,text:s.responseText};if(200===s.status)try{i.json=JSON.parse(s.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,i)}},s.onerror=()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},s.send(r)}}},{name:"sendBeacon",available:"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=Kt(e);if(t){var{contentType:i,body:r}=t;try{var n="string"==typeof r?new Blob([r],{type:i}):r,s=e.compression===Gt.GZipJS&&i===Xt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,n)}catch(e){}}}}],Yt=e=>{var t,i=e.transport||"fetch",r=Zt.find(e=>e.name===i&&e.available)||Zt.find(e=>e.available);if(!r)return console.error("vTilt: No available transport method"),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0}));r.method(e)};class ei{constructor(e,t){var i,r,n,s;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(i=(null==t?void 0:t.flush_interval_ms)||3e3,r=250,n=5e3,s=3e3,"number"!=typeof i||isNaN(i)?s:Math.min(Math.max(i,r),n)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var r=e[t];this._sendRequest(i({},r,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var i in e){var r=e[i];r.events.forEach(e=>{var i=new Date(e.timestamp).getTime();e.$offset=Math.abs(i-t)}),this._sendRequest(r)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var i=t.batchKey||t.url;e[i]||(e[i]={url:t.url,events:[],batchKey:t.batchKey}),e[i].events.push(t.event)}),this._queue=[],e}}class ti{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,T&&void 0!==k&&"onLine"in k&&(this._areWeOnline=k.onLine,S(T,"online",()=>{this._areWeOnline=!0,this._flush()}),S(T,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)console.warn("VTilt: Request failed after 10 retries, giving up");else{var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),n=(Math.random()-.5)*(r-i);return Math.ceil(r+n)}(t),r=Date.now()+i;this._queue.push({retryAt:r,request:e,retriesPerformedSoFar:t+1});var n="VTilt: Enqueued failed request for retry in "+Math.round(i/1e3)+"s";this._areWeOnline||(n+=" (Browser is offline)"),console.warn(n),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var i=this;return t(function*(){try{var t=yield i._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&i.enqueue(e,0)}catch(t){i.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,i=Date.now(),r=[],n=[];this._queue.forEach(e=>{e.retryAt<i?n.push(e):r.push(e)}),this._queue=r,n.forEach(function(){var i=t(function*(t){var{request:i,retriesPerformedSoFar:r}=t;try{var n=yield e._sendRequest(i);200!==n.statusCode&&(n.statusCode<400||n.statusCode>=500)&&e.enqueue(i,r)}catch(t){e.enqueue(i,r)}});return function(e){return i.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){console.error("VTilt: Failed to send beacon on unload",e)}}),this._queue=[]}}var ii="vt_rate_limit";class ri{constructor(e){var t,i;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(i=e.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,i,r,n;void 0===e&&(e=!1);var s=Date.now(),o=null!==(i=null===(t=this.persistence)||void 0===t?void 0:t.get(ii))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:s},a=(s-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=s,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var l=o.tokens<1;return l||e||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||e||null===(r=this.captureWarning)||void 0===r||r.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(n=this.persistence)||void 0===n||n.set(ii,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class ni{constructor(e){void 0===e&&(e={}),this.version=r,this.__loaded=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this.__request_queue=[],this._has_warned_about_config=!1,this._set_once_properties_sent=!1,this._remoteConfig=null,this.configManager=new m(e);var t=this.configManager.getConfig();this.sessionManager=new D(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ye(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.webVitalsManager=new nt(t,this),this.rateLimiter=new ri({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._capture_internal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new ti({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new ei(e=>this._send_batched_request(e),{flush_interval_ms:3e3})}init(e,t,i){var r;if(i&&i!==oi){var n=null!==(r=si[i])&&void 0!==r?r:new ni;return n._init(e,t,i),si[i]=n,si[oi][i]=n,n}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: You have already initialized vTilt! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:r})),this.__loaded=!0,this._loadRemoteConfig();var n=this.configManager.getConfig();return this.userManager.set_initial_person_info(n.mask_personal_data_properties,n.custom_personal_data_properties),this.historyAutocapture=new ot(this),this.historyAutocapture.startIfEnabled(),this._initSessionRecording(),this._initChat(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==n.capture_pageview&&this._capture_initial_pageview(),this}_start_queue_if_opted_in(){this.requestQueue.enable()}_setup_unload_handler(){if(T){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};S(T,"beforeunload",e),S(T,"pagehide",e)}}_loadRemoteConfig(){var e,t=this.configManager.getConfig();if(t.projectId){if(null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._applyRemoteConfig(this._remoteConfig),void this._fetchRemoteConfig();try{var i=T.__VTILT_BOOTSTRAP__;if(null==i?void 0:i.remoteConfig)return this._remoteConfig=i.remoteConfig,this._applyRemoteConfig(this._remoteConfig),void this._fetchRemoteConfig()}catch(e){}try{var r=localStorage.getItem(u+"_"+t.projectId);r&&(this._remoteConfig=JSON.parse(r),this._applyRemoteConfig(this._remoteConfig))}catch(e){}this._fetchRemoteConfig()}}_fetchRemoteConfig(){var e=this.configManager.getConfig();if(e.projectId&&e.api_host){var t=e.api_host+"/api/projects/"+e.projectId+"/decide",i=new AbortController,r=setTimeout(()=>i.abort(),3e3);(R||fetch)(t,{method:"GET",signal:i.signal,headers:{Accept:"application/json"}}).then(e=>e.json()).then(t=>{clearTimeout(r),this._remoteConfig=t;try{localStorage.setItem(u+"_"+e.projectId,JSON.stringify(t))}catch(e){}this._applyRemoteConfig(t)}).catch(()=>{clearTimeout(r)})}}_applyRemoteConfig(e){var t,i,r=this.configManager.getConfig(),n={},s=!1,o=!1;if(e.sessionRecording&&void 0===r.session_recording&&(n.session_recording={enabled:e.sessionRecording.enabled,sampleRate:e.sessionRecording.sampleRate,minimumDurationMs:e.sessionRecording.minimumDurationMs,maskAllInputs:e.sessionRecording.maskAllInputs,captureConsole:e.sessionRecording.captureConsole,captureCanvas:e.sessionRecording.captureCanvas},e.sessionRecording.enabled&&(s=!0)),(null===(t=e.chat)||void 0===t?void 0:t.enabled)&&void 0===r.chat&&(n.chat={enabled:e.chat.enabled,position:e.chat.widgetPosition,color:e.chat.widgetColor},o=!0),e.analytics&&(void 0!==e.analytics.capturePageview&&void 0===r.capture_pageview&&(n.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===r.capture_pageleave&&(n.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===r.capture_performance&&(n.capture_performance=e.analytics.capturePerformance),void 0!==e.analytics.autocapture&&void 0===r.autocapture&&(n.autocapture=e.analytics.autocapture)),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.respectDnt)&&void 0===r.respect_dnt&&(n.respect_dnt=e.privacy.respectDnt),Object.keys(n).length>0&&this.updateConfig(n),s&&this.__loaded&&this.startSessionRecording(),o&&this.__loaded)if(this.chat){var a=this._buildChatConfig(this.configManager.getConfig());this.chat.updateConfig(a),this.chat.startIfEnabled()}else this._initChat()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:oi;return t!==oi&&(t=oi+"."+t),t}getCurrentDomain(){if(!E)return"";var e=E.protocol,t=E.hostname,i=E.port;return e+"//"+t+(i?":"+i:"")}_is_configured(){var e=this.configManager.getConfig();return!(!e.projectId||!e.token)||(this._has_warned_about_config||(console.warn("VTilt: projectId and token are required for tracking. Events will be skipped until init() or updateConfig() is called with these fields."),this._has_warned_about_config=!0),!1)}buildUrl(){var e=this.configManager.getConfig(),{proxyUrl:t,proxy:i,api_host:r,token:n}=e;return t||(i?i+"/api/tracking?token="+n:r?r.replace(/\/+$/gm,"")+"/api/tracking?token="+n:"/api/tracking?token="+n)}sendRequest(e,t,i){if(this._is_configured()){if(i&&void 0!==T)if(T.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_send_batched_request(e){var{transport:t}=e;"sendBeacon"!==t?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:i,events:r}=e,n=1===r.length?r[0]:{events:r},s=this.configManager.getConfig().disable_compression?Gt.None:Gt.GZipJS;Yt({url:i,data:n,method:"POST",transport:"XHR",compression:s,callback:e=>{t({statusCode:e.statusCode})}})})}_send_beacon_request(e){var{url:t,events:i}=e,r=1===i.length?i[0]:{events:i},n=this.configManager.getConfig().disable_compression?Gt.None:Gt.GZipJS;Yt({url:t,data:r,method:"POST",transport:"sendBeacon",compression:n})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}capture(e,t,r){if(this.sessionManager.setSessionId(),k&&k.userAgent&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(k.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this.rateLimiter.shouldAllowEvent())){var n=this.buildUrl(),s=Ze(),o=this.userManager.getUserProperties(),a=this.userManager.get_initial_props(),l=this.sessionManager.getSessionId(),d=this.sessionManager.getWindowId(),u=this.userManager.getAnonymousId(),h={};!this._set_once_properties_sent&&Object.keys(a).length>0&&Object.assign(h,a),t.$set_once&&Object.assign(h,t.$set_once);var c=i({},s,o,{$session_id:l,$window_id:d},u?{$anon_distinct_id:u}:{},Object.keys(h).length>0?{$set_once:h}:{},t.$set?{$set:t.$set}:{},t);!this._set_once_properties_sent&&Object.keys(a).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&M&&(c.title=M.title);var g,v,_=this.configManager.getConfig();if(!1!==_.stringifyPayload){if(g=Object.assign({},c,_.globalAttributes),!b(g=JSON.stringify(g)))return}else if(g=Object.assign({},c,_.globalAttributes),!b(JSON.stringify(g)))return;v="$identify"===e?this.userManager.getAnonymousId():this.userManager.getDistinctId()||this.userManager.getAnonymousId();var f={timestamp:(new Date).toISOString(),event:e,project_id:_.projectId||"",payload:g,distinct_id:v,anonymous_id:u};this.sendRequest(n,f,!0)}}_capture_internal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}identify(e,t,i){if("number"==typeof e&&(e=String(e),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.userManager.isDistinctIdStringLikePublic(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var r=this.userManager.getDistinctId(),n=this.userManager.getAnonymousId(),s=this.userManager.getDeviceId(),o="anonymous"===this.userManager.getUserState();if(!s){var a=r||n;this.userManager.ensureDeviceId(a)}e!==r&&o?(this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n,$set:t||{},$set_once:i||{}}),this.userManager.setDistinctId(e)):t||i?(o&&this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$set",{$set:t||{},$set_once:i||{}})):e!==r&&(this.userManager.setUserState("identified"),this.userManager.setDistinctId(e))}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){this.userManager.setUserProperties(e,t)&&this.capture("$set",{$set:e||{},$set_once:t||{}})}resetUser(e){this.sessionManager.resetSessionId(),this.userManager.reset(e)}getUserIdentity(){return this.userManager.getUserIdentity()}getDeviceId(){return this.userManager.getDeviceId()}getUserState(){return this.userManager.getUserState()}createAlias(e,t){var i=this.userManager.createAlias(e,t);i?this.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this.userManager.getDistinctId()||this.userManager.getAnonymousId())&&this.identify(e)}_capture_initial_pageview(){M&&("visible"===M.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{if(M&&E){this.capture("$pageview",{navigation_type:"initial_load"})}},300),this._visibility_state_listener&&(M.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>{this._capture_initial_pageview()},S(M,"visibilitychange",this._visibility_state_listener)))}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this.userManager.getDistinctId()||this.userManager.getAnonymousId()}getAnonymousId(){return this.userManager.getAnonymousId()}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new D(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ye(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.webVitalsManager=new nt(t,this),this.sessionRecording&&t.session_recording&&this.sessionRecording.updateConfig(this._buildSessionRecordingConfig(t))}_initSessionRecording(){if(!this.sessionRecording){var e=this.configManager.getConfig();if(!e.disable_session_recording){var t=this._buildSessionRecordingConfig(e);this.sessionRecording=new lt(this,t),t.enabled&&this.sessionRecording.startIfEnabledOrStop("recording_initialized")}}}_buildSessionRecordingConfig(e){var t,i,r,n=e.session_recording||{};return{enabled:null!==(t=n.enabled)&&void 0!==t&&t,sampleRate:n.sampleRate,minimumDurationMs:n.minimumDurationMs,sessionIdleThresholdMs:n.sessionIdleThresholdMs,fullSnapshotIntervalMs:n.fullSnapshotIntervalMs,captureConsole:null!==(i=n.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(r=n.captureNetwork)&&void 0!==r&&r,captureCanvas:n.captureCanvas,blockClass:n.blockClass,blockSelector:n.blockSelector,ignoreClass:n.ignoreClass,maskTextClass:n.maskTextClass,maskTextSelector:n.maskTextSelector,maskAllInputs:n.maskAllInputs,maskInputOptions:n.maskInputOptions,masking:n.masking,recordHeaders:n.recordHeaders,recordBody:n.recordBody,compressEvents:n.compressEvents,__mutationThrottlerRefillRate:n.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:n.__mutationThrottlerBucketSize}}startSessionRecording(){var e=this.configManager.getConfig(),t=this._buildSessionRecordingConfig(e);t.enabled=!0,this.sessionRecording?this.sessionRecording.updateConfig(t):this.sessionRecording=new lt(this,t),this.sessionRecording.startIfEnabledOrStop("recording_initialized")}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stopRecording()}isRecordingActive(){var e;return"active"===(null===(e=this.sessionRecording)||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this.sessionRecording)||void 0===e?void 0:e.sessionId)||null}_initChat(){if(!this.chat){var e=this.configManager.getConfig();if(!e.disable_chat){var t=this._buildChatConfig(e);this.chat=new Qt(this,t),this.chat.startIfEnabled()}}}_buildChatConfig(e){var t,i=e.chat||{};return{enabled:i.enabled,autoConfig:null===(t=i.autoConfig)||void 0===t||t,position:i.position,greeting:i.greeting,color:i.color,aiMode:i.aiMode,aiGreeting:i.aiGreeting,preload:i.preload,offlineMessage:i.offlineMessage,collectEmailOffline:i.collectEmailOffline}}_execute_array(e){Array.isArray(e)&&e.forEach(e=>{if(e&&Array.isArray(e)&&e.length>0){var t=e[0],i=e.slice(1);if("function"==typeof this[t])try{this[t](...i)}catch(e){console.error("vTilt: Error executing queued call "+t+":",e)}}})}_dom_loaded(){this.__request_queue.forEach(e=>{this._send_retriable_request(e)}),this.__request_queue=[],this._start_queue_if_opted_in()}}var si={},oi="vt",ai=!(void 0!==x||void 0!==R)&&-1===(null==P?void 0:P.indexOf("MSIE"))&&-1===(null==P?void 0:P.indexOf("Mozilla"));null!=T&&(T.__VTILT_ENQUEUE_REQUESTS=ai);var li,di=(li=si[oi]=new ni,function(){function e(){e.done||(e.done=!0,ai=!1,null!=T&&(T.__VTILT_ENQUEUE_REQUESTS=!1),w(si,function(e){e._dom_loaded()}))}M&&"function"==typeof M.addEventListener?"complete"===M.readyState?e():S(M,"DOMContentLoaded",e,{capture:!1}):T&&console.error("Browser doesn't support `document.addEventListener` so vTilt couldn't be initialized")}(),li);export{et as ALL_WEB_VITALS_METRICS,tt as DEFAULT_WEB_VITALS_METRICS,ni as VTilt,di as default,di as vt};
|
|
1
|
+
function e(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,n)}function t(t){return function(){var i=this,r=arguments;return new Promise(function(n,s){var o=t.apply(i,r);function a(t){e(o,n,s,a,l,"next",t)}function l(t){e(o,n,s,a,l,"throw",t)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}var r="1.10.0",n="__vt_session",s="__vt_window_id",o="__vt_primary_window",a="__vt_user_state",l="__vt_device_id",d="__vt_anonymous_id",u="__vt_remote_config",h="__vt_distinct_id",c="__vt_user_properties",_="localStorage",v="localStorage+cookie",g="sessionStorage",f="memory",p="$initial_person_info";class m{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!document.currentScript)return i({token:e.token||""},e);var t=document.currentScript,r=i({token:""},e);r.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,r.script_host=t.getAttribute("data-script-host")||e.script_host,r.proxy=t.getAttribute("data-proxy")||e.proxy,r.proxyUrl=t.getAttribute("data-proxy-url")||e.proxyUrl,r.token=t.getAttribute("data-token")||e.token||"",r.projectId=t.getAttribute("data-project-id")||e.projectId||"",r.domain=t.getAttribute("data-domain")||e.domain,r.storage=t.getAttribute("data-storage")||e.storage,r.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var n="true"===t.getAttribute("data-capture-performance");if(r.capture_performance=!!n||e.capture_performance,r.proxy&&r.proxyUrl)throw console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them."),new Error("Both data-proxy and data-proxy-url are specified. Please use only one of them.");for(var s of(r.globalAttributes=i({},e.globalAttributes),Array.from(t.attributes)))s.name.startsWith("data-vt-")&&(r.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return r}getConfig(){return i({},this.config)}updateConfig(e){this.config=i({},this.config,e)}}function y(e,t){try{return e()}catch(e){return t}}class b{constructor(){this._events=new Map,this._onceEvents=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>{var i;null===(i=this._events.get(e))||void 0===i||i.delete(t)}}once(e,t){return this._onceEvents.has(e)||this._onceEvents.set(e,new Set),this._onceEvents.get(e).add(t),()=>{var i;null===(i=this._onceEvents.get(e))||void 0===i||i.delete(t)}}emit(e,t){var i,r;null===(i=this._events.get(e))||void 0===i||i.forEach(i=>{try{i(t)}catch(t){console.error('[vTilt] Error in event listener for "'+e+'":',t)}});var n=this._onceEvents.get(e);n&&(n.forEach(i=>{try{i(t)}catch(t){console.error('[vTilt] Error in once listener for "'+e+'":',t)}}),this._onceEvents.delete(e)),null===(r=this._events.get("*"))||void 0===r||r.forEach(i=>{try{i({event:e,payload:t})}catch(e){console.error("[vTilt] Error in wildcard listener:",e)}})}off(e){e?(this._events.delete(e),this._onceEvents.delete(e)):(this._events.clear(),this._onceEvents.clear())}listenerCount(e){var t,i,r,n;return(null!==(i=null===(t=this._events.get(e))||void 0===t?void 0:t.size)&&void 0!==i?i:0)+(null!==(n=null===(r=this._onceEvents.get(e))||void 0===r?void 0:r.size)&&void 0!==n?n:0)}hasListeners(e){return this.listenerCount(e)>0}}var S="sdk:initialized",w="sdk:config_updated",C="sdk:remote_config_loaded",I="feature:started",E="feature:stopped",M="event:captured",L="recording:started",k="recording:stopped";function T(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function x(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function P(e,t,i){if(e)if(Array.isArray(e))e.forEach((e,r)=>{t.call(i,e,r)});else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(i,e[r],r)}function R(e,t,i,r){var{capture:n=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:n,passive:s})}function A(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function U(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var n of i)for(var s of n)e.push(s);return e}var O="undefined"!=typeof window?window:void 0,$="undefined"!=typeof globalThis?globalThis:O,z=null==$?void 0:$.navigator,q=null==$?void 0:$.document,D=null==$?void 0:$.location,F=null==$?void 0:$.fetch,N=(null==$?void 0:$.XMLHttpRequest)&&"withCredentials"in new $.XMLHttpRequest?$.XMLHttpRequest:void 0;null==$||$.AbortController;var B=null==z?void 0:z.userAgent,j=null!=O?O:{},V=[d,l,h,a],W=31536e3,H=["herokuapp.com","vercel.app","netlify.app"];function J(e){var t;if(!e||"undefined"==typeof document)return"";var i=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!i)return"";var r=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return r?"."+r[0]:""}class Q{constructor(e){var t,i,r;this.memoryStorage=new Map,this._localStorageSupported=null,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var i=t.split(".").slice(-2).join(".");return!H.includes(i)}(),this.sameSite=null!==(i=e.sameSite)&&void 0!==i?i:"Lax",this.secure=null!==(r=e.secure)&&void 0!==r?r:"undefined"!=typeof location&&"https:"===location.protocol}isLocalStorageSupported(){if(null!==this._localStorageSupported)return this._localStorageSupported;if(void 0===O||!O.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";O.localStorage.setItem(e,"1");var t="1"===O.localStorage.getItem(e);return O.localStorage.removeItem(e),this._localStorageSupported=t,t||console.warn("[vTilt] localStorage unavailable, using cookies"),t}catch(e){return this._localStorageSupported=!1,console.warn("[vTilt] localStorage unavailable, using cookies"),!1}}isCriticalProperty(e){return V.includes(e)}get(e){var t;try{switch(this.method){case f:return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;case v:return this.getLocalStoragePlusCookie(e);case _:return this.getLocalStorage(e);case g:return this.readFromSessionStorage(e);default:return this.getCookie(e)}}catch(t){return console.warn('[vTilt] Storage get error for "'+e+'":',t),null}}set(e,t,i){try{switch(this.method){case f:this.memoryStorage.set(e,t);break;case v:this.setLocalStoragePlusCookie(e,t,i);break;case _:this.setLocalStorage(e,t);break;case g:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=i?i:W)}}catch(t){console.warn('[vTilt] Storage set error for "'+e+'":',t)}}remove(e){try{switch(this.method){case f:this.memoryStorage.delete(e);break;case v:this.removeLocalStoragePlusCookie(e);break;case _:this.removeLocalStorage(e);break;case g:this.removeFromSessionStorage(e);break;default:this.removeCookie(e)}}catch(t){console.warn('[vTilt] Storage remove error for "'+e+'":',t)}}getLocalStoragePlusCookie(e){if(this.isCriticalProperty(e)){var t=this.getCookie(e),i=this.getLocalStorage(e);if(null!==t){if(i!==t&&this.isLocalStorageSupported())try{null==O||O.localStorage.setItem(e,t)}catch(e){}return t}return i}return this.getLocalStorage(e)}setLocalStoragePlusCookie(e,t,i){this.setLocalStorage(e,t),this.isCriticalProperty(e)&&this.setCookie(e,t,null!=i?i:W)}removeLocalStoragePlusCookie(e){this.removeLocalStorage(e),this.isCriticalProperty(e)&&this.removeCookie(e)}getLocalStorage(e){var t;if(!this.isLocalStorageSupported())return null;try{return null!==(t=null==O?void 0:O.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==O||O.localStorage.setItem(e,t)}catch(e){console.warn("[vTilt] localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==O||O.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==O?void 0:O.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==O||O.sessionStorage.setItem(e,t)}catch(e){console.warn("[vTilt] sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==O||O.sessionStorage.removeItem(e)}catch(e){}}getCookie(e){if("undefined"==typeof document)return null;var t=e+"=";for(var i of document.cookie.split(";")){var r=i.trim();if(r.startsWith(t))try{return decodeURIComponent(r.slice(t.length))}catch(e){return r.slice(t.length)}}return null}setCookie(e,t,i){if("undefined"!=typeof document){var r=J(this.cross_subdomain),n=e+"="+encodeURIComponent(t)+"; Max-Age="+i+"; path=/; SameSite="+this.sameSite;this.secure&&(n+="; Secure"),r&&(n+="; domain="+r),document.cookie=n}}removeCookie(e){if("undefined"!=typeof document){var t=J(this.cross_subdomain);document.cookie=e+"=; Max-Age=0; path=/"+(t?"; domain="+t:""),document.cookie=e+"=; Max-Age=0; path=/"}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var i=JSON.parse(t);return i.expiry&&Date.now()>i.expiry?(this.remove(e),null):i.value}catch(e){return null}}setWithExpiry(e,t,r){var n=i({value:t},r?{expiry:Date.now()+r}:{});this.set(e,JSON.stringify(n))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,i){this.set(e,JSON.stringify(t),i)}canUseSessionStorage(){if(void 0===O||!(null==O?void 0:O.sessionStorage))return!1;try{var e="__vt_ss_test__";return O.sessionStorage.setItem(e,"1"),O.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==O?void 0:O.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class G{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=T(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||T();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(T())}_getSessionIdRaw(){return this.storage.get(n)}_storeSessionId(e){this.storage.set(n,e,1800)}_clearSessionId(){this.storage.remove(n)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(s);if(t)return this._windowId=t,t}var i=T();return this._setWindowId(i),i}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(s,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(o),i=e.getItem(s);i&&!t?this._windowId=i:(i&&e.removeItem(s),this._setWindowId(T())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=T()}_listenToUnload(){var e=this.storage.getSessionStorage();O&&e&&R(O,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"})}}function K(e){if(!q)return null;var t=q.createElement("a");return t.href=e,t}function X(e,t){for(var i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<i.length;r++){var n=i[r].split("=");if(n[0]===t){if(n.length<2)return"";var s=n[1];try{s=decodeURIComponent(s)}catch(e){}return s.replace(/\+/g," ")}}return""}function Z(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],d=(a||"").split("&"),u=[],h=0;h<d.length;h++){var c=d[h].split("="),_=c[0],v=c.slice(1).join("=");-1!==t.indexOf(_)?u.push(_+"="+i):_&&u.push(_+(v?"="+v:""))}var g=u.join("&");return l+(g?"?"+g:"")+(s?"#"+s:"")}function Y(e){return"function"==typeof e}var ee="Mobile",te="iOS",ie="Android",re="Tablet",ne=ie+" "+re,se="iPad",oe="Apple",ae=oe+" Watch",le="Safari",de="BlackBerry",ue="Samsung",he=ue+"Browser",ce=ue+" Internet",_e="Chrome",ve=_e+" OS",ge=_e+" "+te,fe="Internet Explorer",pe=fe+" "+ee,me="Opera",ye=me+" Mini",be="Edge",Se="Microsoft "+be,we="Firefox",Ce=we+" "+te,Ie="Nintendo",Ee="PlayStation",Me="Xbox",Le=ie+" "+ee,ke=ee+" "+le,Te="Windows",xe=Te+" Phone",Pe="Nokia",Re="Ouya",Ae="Generic",Ue=Ae+" "+ee.toLowerCase(),Oe=Ae+" "+re.toLowerCase(),$e="Konqueror",ze="(\\d+(\\.\\d+)?)",qe=new RegExp("Version/"+ze),De=new RegExp(Me,"i"),Fe=new RegExp(Ee+" \\w+","i"),Ne=new RegExp(Ie+" \\w+","i"),Be=new RegExp(de+"|PlayBook|BB10","i"),je={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function Ve(e,t){return e.toLowerCase().includes(t.toLowerCase())}var We=(e,t)=>t&&Ve(t,oe)||function(e){return Ve(e,le)&&!Ve(e,_e)&&!Ve(e,ie)}(e),He=function(e,t){return t=t||"",Ve(e," OPR/")&&Ve(e,"Mini")?ye:Ve(e," OPR/")?me:Be.test(e)?de:Ve(e,"IE"+ee)||Ve(e,"WPDesktop")?pe:Ve(e,he)?ce:Ve(e,be)||Ve(e,"Edg/")?Se:Ve(e,"FBIOS")?"Facebook "+ee:Ve(e,"UCWEB")||Ve(e,"UCBrowser")?"UC Browser":Ve(e,"CriOS")?ge:Ve(e,"CrMo")||Ve(e,_e)?_e:Ve(e,ie)&&Ve(e,le)?Le:Ve(e,"FxiOS")?Ce:Ve(e.toLowerCase(),$e.toLowerCase())?$e:We(e,t)?Ve(e,ee)?ke:le:Ve(e,we)?we:Ve(e,"MSIE")||Ve(e,"Trident/")?fe:Ve(e,"Gecko")?we:""},Je={[pe]:[new RegExp("rv:"+ze)],[Se]:[new RegExp(be+"?\\/"+ze)],[_e]:[new RegExp("("+_e+"|CrMo)\\/"+ze)],[ge]:[new RegExp("CriOS\\/"+ze)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ze)],[le]:[qe],[ke]:[qe],[me]:[new RegExp("(Opera|OPR)\\/"+ze)],[we]:[new RegExp(we+"\\/"+ze)],[Ce]:[new RegExp("FxiOS\\/"+ze)],[$e]:[new RegExp("Konqueror[:/]?"+ze,"i")],[de]:[new RegExp(de+" "+ze),qe],[Le]:[new RegExp("android\\s"+ze,"i")],[ce]:[new RegExp(he+"\\/"+ze)],[fe]:[new RegExp("(rv:|MSIE )"+ze)],Mozilla:[new RegExp("rv:"+ze)]},Qe=function(e,t){var i=He(e,t),r=Je[i];if(void 0===r)return null;for(var n=0;n<r.length;n++){var s=r[n],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},Ge=[[new RegExp(Me+"; "+Me+" (.*?)[);]","i"),e=>[Me,e&&e[1]||""]],[new RegExp(Ie,"i"),[Ie,""]],[new RegExp(Ee,"i"),[Ee,""]],[Be,[de,""]],[new RegExp(Te,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[xe,""];if(new RegExp(ee).test(t)&&!/IEMobile\b/.test(t))return[Te+" "+ee,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=je[r]||"";return/arm/i.test(t)&&(n="RT"),[Te,n]}return[Te,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[te,t.join(".")]}return[te,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ie+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ie+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ie,t.join(".")]}return[ie,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ve,""]],[/Linux|debian/i,["Linux",""]]],Ke=function(e){return Ne.test(e)?Ie:Fe.test(e)?Ee:De.test(e)?Me:new RegExp(Re,"i").test(e)?Re:new RegExp("("+xe+"|WPDesktop)","i").test(e)?xe:/iPad/.test(e)?se:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ae:Be.test(e)?de:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Pe,"i").test(e)?Pe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ee).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ie:ne:ie:new RegExp("(pda|"+ee+")","i").test(e)?Ue:new RegExp(re,"i").test(e)&&!new RegExp(re+" pc","i").test(e)?Oe:""},Xe="https?://(.*)",Ze=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ye=U(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ze),et="<masked>";function tt(e){var t=function(e){return e?0===e.search(Xe+"google.([^/?]*)")?"google":0===e.search(Xe+"bing.com")?"bing":0===e.search(Xe+"yahoo.com")?"yahoo":0===e.search(Xe+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var n=q?X(q.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function it(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function rt(){return(null==q?void 0:q.referrer)||"$direct"}function nt(){var e;return(null==q?void 0:q.referrer)&&(null===(e=K(q.referrer))||void 0===e?void 0:e.host)||"$direct"}function st(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=K(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=K(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Ye.concat([]),i={};return P(t,function(t){var r=X(e,t);i[t]=r||null}),i}(r);A(n,o)}i&&A(n,tt(i));return n}function ot(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function at(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function lt(e,t){if(!B)return{};var i,n,s,[o,a]=function(e){for(var t=0;t<Ge.length;t++){var[i,r]=Ge[t],n=i.exec(e),s=n&&(Y(r)?r(n,e):r);if(s)return s}return["",""]}(B);return A(function(e){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=e[i];null!=r&&""!==r&&(t[i]=r)}return t}({$os:o,$os_version:a,$browser:He(B,navigator.vendor),$device:Ke(B),$device_type:(n=B,s=Ke(n),s===se||s===ne||"Kobo"===s||"Kindle Fire"===s||s===Oe?re:s===Ie||s===Me||s===Ee||s===Re?"Console":s===ae?"Wearable":s?ee:"Desktop"),$timezone:ot(),$timezone_offset:at()}),{$current_url:Z(null==D?void 0:D.href,[],et),$host:null==D?void 0:D.host,$pathname:null==D?void 0:D.pathname,$raw_user_agent:B.length>1e3?B.substring(0,997)+"...":B,$browser_version:Qe(B,navigator.vendor),$browser_language:it(),$browser_language_prefix:(i=it(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==O?void 0:O.screen.height,$screen_width:null==O?void 0:O.screen.width,$viewport_height:null==O?void 0:O.innerHeight,$viewport_width:null==O?void 0:O.innerWidth,$lib:"web",$lib_version:r,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}class dt{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){return this.userIdentity.anonymous_id||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(d,this.userIdentity.anonymous_id,W)),this.userIdentity.anonymous_id}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}identify(e,t,r){if("number"==typeof e&&(e=e.toString(),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.isDistinctIdStringLike(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this.userIdentity.distinct_id;if(this.userIdentity.distinct_id=e,!this.userIdentity.device_id){var s=n||this.userIdentity.anonymous_id;this.userIdentity.device_id=s,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:s})}e!==n&&(this.userIdentity.distinct_id=e);var o="anonymous"===this.userIdentity.user_state;e!==n&&o?(this.userIdentity.user_state="identified",t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):t||r?("anonymous"===this.userIdentity.user_state&&(this.userIdentity.user_state="identified"),t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):e!==n&&(this.userIdentity.user_state="identified",this.saveUserIdentity())}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){if(!e&&!t)return!1;var r=this.userIdentity.distinct_id||this.userIdentity.anonymous_id,n=this.getPersonPropertiesHash(r,e,t);return this._cachedPersonProperties===n?(console.info("VTilt: A duplicate setUserProperties call was made with the same properties. It has been ignored."),!1):(e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity(),this._cachedPersonProperties=n,!0)}reset(e){var t=this.generateAnonymousId(),r=this.userIdentity.device_id,n=e?this.generateDeviceId():r;this.userIdentity={distinct_id:null,anonymous_id:t,device_id:n,properties:{},user_state:"anonymous"},this._cachedPersonProperties=null,this.saveUserIdentity(),this.userIdentity.properties=i({},this.userIdentity.properties,{$last_vtilt_reset:(new Date).toISOString()}),this.saveUserIdentity()}setDistinctId(e){this.userIdentity.distinct_id=e,this.saveUserIdentity()}setUserState(e){this.userIdentity.user_state=e,this.saveUserIdentity()}updateUserProperties(e,t){e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity()}ensureDeviceId(e){this.userIdentity.device_id||(this.userIdentity.device_id=e,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:e}),this.saveUserIdentity())}createAlias(e,t){return this.isValidDistinctId(e)?(void 0===t&&(t=this.getDistinctId()||this.getAnonymousId()),this.isValidDistinctId(t)?e===t?(console.warn("alias matches current distinct_id - should use identify instead"),null):{distinct_id:e,original:t}:(console.warn("Invalid original distinct ID"),null)):(console.warn("Invalid alias provided"),null)}isDistinctIdStringLikePublic(e){return this.isDistinctIdStringLike(e)}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[p]){var i=function(e,t){var i=e?U([],Ze,t||[]):[],r=null==D?void 0:D.href.substring(0,1e3);return{r:rt().substring(0,1e3),u:r?Z(r,i,et):void 0}}(e,t);this.register_once({[p]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[p];return i?(e=st(i),t={},P(e,function(e,i){var r;t["$initial_"+(r=String(i),r.startsWith("$")?r.substring(1):r)]=e}),t):{}}update_referrer_info(){var e={$referrer:rt(),$referring_domain:nt()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(d),t=this.storage.get(l),i=this.storage.get(h),r=this.storage.get(a),n=this.getStoredUserProperties(),s=e||this.generateAnonymousId(),o=t||this.generateDeviceId(),u=i||null,c=r||"anonymous",_=s||this.generateAnonymousId();return e||this.storage.set(d,_,W),t||this.storage.set(l,o,W),r||this.storage.set(a,c,W),{distinct_id:u,anonymous_id:_,device_id:o,properties:n,user_state:c}}saveUserIdentity(){this.storage.set(d,this.userIdentity.anonymous_id,W),this.storage.set(l,this.userIdentity.device_id,W),this.storage.set(a,this.userIdentity.user_state,W),this.userIdentity.distinct_id?this.storage.set(h,this.userIdentity.distinct_id,W):this.storage.remove(h),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(c)||{}}setStoredUserProperties(e){this.storage.setJSON(c,e,W)}register_once(e,t){var i=this.getStoredUserProperties(),r=!1;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(n in i||(i[n]=e[n],r=!0));if(t)for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(s in i||(i[s]=t[s],r=!0));r&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+T()}generateDeviceId(){return"device_"+T()}getPersonPropertiesHash(e,t,i){return JSON.stringify({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}isValidDistinctId(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return!["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none"].includes(t)&&0!==e.trim().length}isDistinctIdStringLike(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"].includes(t)}updateStorageMethod(e,t){this.storage=new Q({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var ut=["LCP","CLS","FCP","INP","TTFB"],ht=["LCP","CLS","FCP","INP"],ct=9e5,_t="[WebVitals]";class vt{static extractConfig(e){var t=e.capture_performance;return"boolean"==typeof t?{web_vitals:t}:"object"==typeof t&&null!==t?t:{web_vitals:!1}}constructor(e){this.name="WebVitals",this._isStarted=!1,this._instance=e,this._buffer=this._createEmptyBuffer(),this._config=vt.extractConfig(e.getConfig())}get isEnabled(){var e=null==D?void 0:D.protocol;return("http:"===e||"https:"===e)&&!1!==this._config.web_vitals}get isStarted(){return this._isStarted}startIfEnabled(){if(this.isEnabled&&!this._isStarted&&O){var e=this._getWebVitalsCallbacks();e?this._startCapturing(e):this._loadWebVitals()}}stop(){this._isStarted&&(this._flush(),this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),this._isStarted=!1)}onConfigUpdate(e){var t=vt.extractConfig(e),i=this.isEnabled;this._config=t,i||!this.isEnabled||this._isStarted?i&&!this.isEnabled&&this._isStarted&&this.stop():this.startIfEnabled()}get allowedMetrics(){return this._config.web_vitals_allowed_metrics||ht}get flushTimeoutMs(){return this._config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this._config.__web_vitals_max_value;return void 0===e?ct:0===e?0:e<6e4?ct:e}_createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}_getWebVitalsCallbacks(){var e;return null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}_loadWebVitals(){var e,t=null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this._instance,"web-vitals",e=>{if(e)console.error(_t+" Failed to load web-vitals:",e);else{var t=this._getWebVitalsCallbacks();t?this._startCapturing(t):console.error(_t+" web-vitals loaded but callbacks not registered")}}):console.warn(_t+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}_startCapturing(e){if(!this._isStarted){var t=this.allowedMetrics,i=this._addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(i),t.includes("CLS")&&e.onCLS&&e.onCLS(i,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(i),t.includes("INP")&&e.onINP&&e.onINP(i),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(i),this._isStarted=!0}}_getCurrentUrl(){var e;return null===(e=null==O?void 0:O.location)||void 0===e?void 0:e.href}_getCurrentPathname(){return null==D?void 0:D.pathname}_addToBuffer(e){try{if(!O||!q||!D)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(_t+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(_t+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this._getCurrentUrl(),r=this._getCurrentPathname();if(!t)return void console.warn(_t+" Could not determine current URL");this._buffer.url&&this._buffer.url!==t&&this._flush(),this._buffer.url||(this._buffer.url=t,this._buffer.pathname=r),this._buffer.firstMetricTimestamp||(this._buffer.firstMetricTimestamp=Date.now());var n=this._cleanAttribution(e.attribution),s=this._instance.getSessionId(),o=this._getWindowId(),a=i({},e,{attribution:n,timestamp:Date.now(),$current_url:t,$session_id:s,$window_id:o}),l=this._buffer.metrics.findIndex(t=>t.name===e.name);l>=0?this._buffer.metrics[l]=a:this._buffer.metrics.push(a),this._scheduleFlush(),this._buffer.metrics.length>=this.allowedMetrics.length&&this._flush()}catch(e){console.error(_t+" Error adding metric to buffer:",e)}}_cleanAttribution(e){if(e){var t=i({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}_getWindowId(){var e;try{return(null===(e=this._instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}_scheduleFlush(){this._flushTimer&&clearTimeout(this._flushTimer),this._flushTimer=setTimeout(()=>{this._flush()},this.flushTimeoutMs)}_flush(){if(this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),0!==this._buffer.metrics.length){try{var e={$pathname:this._buffer.pathname,$current_url:this._buffer.url};for(var t of this._buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this._instance.capture("$web_vitals",e)}catch(e){console.error(_t+" Error flushing metrics:",e)}this._buffer=this._createEmptyBuffer()}}}function gt(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return Y(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ft{constructor(e,t){var i;this.name="HistoryAutocapture",this._isStarted=!1,this._instance=e,this._config=t||ft.extractConfig(e.getConfig()),this._lastPathname=(null===(i=null==O?void 0:O.location)||void 0===i?void 0:i.pathname)||""}static extractConfig(e){return{enabled:!1!==e.capture_pageview}}get isEnabled(){return!1!==this._config.enabled&&!1!==this._instance.getConfig().capture_pageview}get isStarted(){return this._isStarted}startIfEnabled(){this.isEnabled&&!this._isStarted&&this._start()}stop(){this._isStarted&&(this._popstateListener&&(this._popstateListener(),this._popstateListener=void 0),this._isStarted=!1)}onConfigUpdate(e){this._config=ft.extractConfig(e),this.isEnabled&&!this._isStarted?this._start():!this.isEnabled&&this._isStarted&&this.stop()}_start(){O&&D&&(this._lastPathname=D.pathname||"",this._patchHistoryMethods(),this._setupPopstateListener(),this._isStarted=!0)}_patchHistoryMethods(){var e,t;if(null==O?void 0:O.history){var i=this;(null===(e=O.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||gt(O.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("pushState")}),(null===(t=O.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||gt(O.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._capturePageview("replaceState")})}}_setupPopstateListener(){if(!this._popstateListener&&O){var e=()=>{this._capturePageview("popstate")};R(O,"popstate",e),this._popstateListener=()=>{null==O||O.removeEventListener("popstate",e)}}}_capturePageview(e){this.isEnabled&&this._isStarted&&y(()=>{var t,i=null===(t=null==O?void 0:O.location)||void 0===t?void 0:t.pathname;if(i&&D&&q){if(i!==this._lastPathname){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}})}}var pt=["a","button","form","input","select","textarea","label"],mt=["click","change","submit"],yt=["hidden","password"],bt=["button","checkbox","submit","reset","radio"],St=["name","id","class","aria-label","role","type","data-testid"],wt=["_ngcontent","_nghost","_ngcontent-","_nghost-","style"],Ct="data-vt-capture-";function It(e,t){var i,r;if(!e||!e.tagName)return!1;var n=e.tagName.toLowerCase();if((null!==(i=null==t?void 0:t.element_allowlist)&&void 0!==i?i:[...pt]).includes(n))return!0;if(function(e){try{var t=null==O?void 0:O.getComputedStyle(e);return"pointer"===(null==t?void 0:t.cursor)}catch(e){return!1}}(e))return!0;if("true"===e.getAttribute("contenteditable"))return!0;if(null===(r=null==t?void 0:t.css_selector_allowlist)||void 0===r?void 0:r.length)for(var s of t.css_selector_allowlist)try{if(e.matches(s))return!0}catch(e){}return!1}function Et(e){if(!e)return!1;var t=e.tagName.toLowerCase();if(Rt(e,"vt-sensitive"))return!0;if("input"===t){var i=(e.getAttribute("type")||"text").toLowerCase();if(yt.includes(i))return!0;if(!bt.includes(i))return!0}if("select"===t||"textarea"===t)return!0;if("true"===e.getAttribute("contenteditable"))return!0;var r=e.getAttribute("name")||"",n=e.getAttribute("id")||"";return!(!Mt(r)&&!Mt(n))}function Mt(e){if(!e)return!1;return/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(e)}function Lt(e){return!e||"string"!=typeof e||!function(e){var t=e.replace(/[\s-]/g,"");if(!/^\d{13,19}$/.test(t))return!1;return[/^4\d{12}(\d{3})?$/,/^5[1-5]\d{14}$/,/^3[47]\d{13}$/,/^6(?:011|5\d{2})\d{12}$/].some(e=>e.test(t))}(e)&&!function(e){return/^\d{3}-?\d{2}-?\d{4}$/.test(e)}(e)}function kt(e){if(!e)return"";for(var t="",i=e.childNodes,r=0;r<i.length;r++){var n=i[r];n.nodeType===Node.TEXT_NODE&&(t+=n.textContent||"")}return Tt(t)}function Tt(e){if(!e||"string"!=typeof e)return"";var t=e.replace(/\s+/g," ").trim();return t.length>255&&(t=t.substring(0,255)+"..."),Lt(t)?t:""}function xt(e,t){if(!e||!e.tagName)return null;var i=e.tagName.toLowerCase(),r=Et(e),n={tag_name:i};if(!r){var s=function(e){if(!e)return"";var t=kt(e);return e.querySelectorAll(":scope > span").forEach(e=>{t+=" "+kt(e)}),Tt(t)}(e);s&&(n.$el_text=s)}var o=Pt(e);o.length>0&&(n.classes=o);var a=function(e,t,i){var r={},n=(null==i?void 0:i.element_attribute_ignorelist)||[];try{var s=e.attributes;if(!s)return r;for(var o=0;o<s.length;o++){var a=s[o],l=a.name.toLowerCase(),d=a.value;At(l,n)||(t&&!Ut(l)||d&&Lt(d)&&(r["attr__"+l]=d))}}catch(e){}return r}(e,r,t);Object.assign(n,a);var l=function(e){var t=e.parentElement;if(!t)return{};for(var i=t.children,r=e.tagName,n=0,s=0,o=0;o<i.length;o++){var a=i[o];if(n++,a.tagName===r&&s++,a===e)return{nth_child:n,nth_of_type:s}}return{}}(e);return l.nth_child&&(n.nth_child=l.nth_child),l.nth_of_type&&(n.nth_of_type=l.nth_of_type),n}function Pt(e){if(!e)return[];try{var t=e.className;return"string"!=typeof t?t&&"string"==typeof t.baseVal?t.baseVal.split(/\s+/).filter(Boolean):[]:t.split(/\s+/).filter(Boolean)}catch(e){return[]}}function Rt(e,t){var i,r;if(!e)return!1;try{return null!==(r=null===(i=e.classList)||void 0===i?void 0:i.contains(t))&&void 0!==r&&r}catch(i){return Pt(e).includes(t)}}function At(e,t){if(t.includes(e))return!0;for(var i of wt)if(e===i||e.startsWith(i))return!0;return!1}function Ut(e){return St.includes(e)}function Ot(e){return e.replace(/"/g,'\\"').replace(/;/g,"\\;")}function $t(e,t,i){var r;return!!(null!==(r=null==i?void 0:i.dom_event_allowlist)&&void 0!==r?r:mt).includes(e)&&(!function(e){if(!e)return!0;if(Rt(e,"vt-include"))return!1;for(var t=e;t;){if(Rt(t,"vt-no-capture"))return!0;t=t.parentElement}return!1}(t)&&!!function(e){var t,i,r;if(!(null===(t=null==O?void 0:O.location)||void 0===t?void 0:t.href))return!1;var n=O.location.href;if(null===(i=null==e?void 0:e.url_ignorelist)||void 0===i?void 0:i.length)for(var s of e.url_ignorelist)if(zt(n,s))return!1;if(null===(r=null==e?void 0:e.url_allowlist)||void 0===r?void 0:r.length){for(var o of e.url_allowlist)if(zt(n,o))return!0;return!1}return!0}(i))}function zt(e,t){return t instanceof RegExp?t.test(e):e===t||e.includes(t)}class qt{constructor(e,t){this.name="Autocapture",this._isStarted=!1,this._eventHandlers=new Map,this._instance=e,this._config=t||qt.extractConfig(e.getConfig())}static extractConfig(e){var t;return"boolean"==typeof e.autocapture?{enabled:e.autocapture}:"object"==typeof e.autocapture&&null!==e.autocapture?{enabled:null===(t=e.autocapture.enabled)||void 0===t||t,url_allowlist:e.autocapture.url_allowlist,url_ignorelist:e.autocapture.url_ignorelist,dom_event_allowlist:e.autocapture.dom_event_allowlist,element_allowlist:e.autocapture.element_allowlist,css_selector_allowlist:e.autocapture.css_selector_allowlist,element_attribute_ignorelist:e.autocapture.element_attribute_ignorelist,capture_copied_text:e.autocapture.capture_copied_text}:{enabled:!1}}get isEnabled(){return!1!==this._config.enabled&&!1!==this._instance.getConfig().autocapture}get isStarted(){return this._isStarted}startIfEnabled(){this.isEnabled&&!this._isStarted&&this._start()}stop(){this._isStarted&&(this._removeEventHandlers(),this._isStarted=!1)}onConfigUpdate(e){this._config=qt.extractConfig(e),this.isEnabled&&!this._isStarted?this._start():!this.isEnabled&&this._isStarted&&this.stop()}updateConfig(e){this._config=i({},this._config,e)}_start(){this._isStarted||q&&q.addEventListener&&(this._addEventHandlers(),this._isStarted=!0)}_addEventHandlers(){var e,t=null!==(e=this._config.dom_event_allowlist)&&void 0!==e?e:mt;if(t.includes("submit")){var i=this._createEventHandler("submit");R(q,"submit",i,{capture:!0,passive:!0}),this._eventHandlers.set("submit",i)}if(t.includes("change")){var r=this._createEventHandler("change");R(q,"change",r,{capture:!0,passive:!0}),this._eventHandlers.set("change",r)}if(t.includes("click")){var n=this._createEventHandler("click");R(q,"click",n,{capture:!0,passive:!0}),this._eventHandlers.set("click",n)}}_removeEventHandlers(){var e=q;e&&(this._eventHandlers.forEach((t,i)=>{e.removeEventListener(i,t,{capture:!0})}),this._eventHandlers.clear())}_createEventHandler(e){return t=>{try{this._captureEvent(t,e)}catch(e){"undefined"!=typeof console&&console.error&&console.error("[vTilt] Autocapture error:",e)}}}_captureEvent(e,t){var i=function(e){if(e.composedPath&&"function"==typeof e.composedPath){var t=e.composedPath();if(t.length>0){var i=t[0];if(i instanceof Element)return i;if(i instanceof Node&&i.parentElement)return i.parentElement}}var r=e.target;return r instanceof Element?r:r instanceof Node&&r.parentElement?r.parentElement:null}(e);if(i){var r="click"===t?function(e,t){if(!e)return null;if(It(e,t))return e;for(var i=e.parentElement,r=0;i&&r<10;){if(It(i,t))return i;i=i.parentElement,r++}return null}(i,this._config):i;if(r&&$t(t,r,this._config)){var n=this._buildEventProperties(e,r,t);n&&this._instance.capture("$autocapture",n)}}}_buildEventProperties(e,t,r){var n=function(e,t){var i,r=[];if(!e)return r;for(var n=e,s=0;n&&s<10;){var o=null===(i=n.tagName)||void 0===i?void 0:i.toLowerCase();if("body"===o||"html"===o)break;var a=xt(n,t);a&&r.push(a),n=n.parentElement,s++}return r}(t,this._config);if(0===n.length)return null;var s,o=function(e){var t={};if(!e)return t;for(var i=e,r=0;i&&r<10;){try{var n=i.attributes;if(n)for(var s=0;s<n.length;s++){var o=n[s];if(o.name.startsWith(Ct)){var a=o.name.substring(16);!(a in t)&&o.value&&(t[a]=o.value)}}}catch(e){}i=i.parentElement,r++}return t}(t),a=i({$event_type:r,$elements_chain:(s=n,s.length?s.map(e=>{var t,i=e.tag_name;(null===(t=e.classes)||void 0===t?void 0:t.length)&&(i+="."+e.classes.join("."));var r=[];for(var[n,s]of Object.entries(e))if(n.startsWith("attr__")&&s){var o=n.replace("attr__","");r.push(o+'="'+Ot(String(s))+'"')}return e.nth_child&&r.push('nth-child="'+e.nth_child+'"'),e.nth_of_type&&r.push('nth-of-type="'+e.nth_of_type+'"'),r.length&&(i+=":"+r.join("")),i}).join(";"):""),$elements:n},o);return this._addElementSpecificProps(a,t,r),this._addEventSpecificProps(a,e,r),a}_addElementSpecificProps(e,t,i){var r=t.tagName.toLowerCase();if(e.$tag_name=r,"a"===r){var n=t.getAttribute("href");n&&(e.$href=n)}if(!Et(t)){var s=kt(t);s&&(e.$el_text=s)}if("change"===i&&("input"===r||"select"===r||"textarea"===r)){var o=t.getAttribute("type");o&&(e.$input_type=o)}}_addEventSpecificProps(e,t,i){if("click"===i&&t instanceof MouseEvent&&(e.$click_x=t.clientX,e.$click_y=t.clientY),"submit"===i&&t.target instanceof HTMLFormElement){var r=t.target.action;r&&(e.$form_action=r);var n=t.target.method;n&&(e.$form_method=n.toUpperCase())}}}var Dt="[SessionRecording]";class Ft{constructor(e,t){this._instance=e,this.name="SessionRecording",this._isStarted=!1,this._config=t||Ft.extractConfig(e.getConfig())}static extractConfig(e){var t,i,r,n=e.session_recording||{};return{enabled:null!==(t=n.enabled)&&void 0!==t&&t,sampleRate:n.sampleRate,minimumDurationMs:n.minimumDurationMs,sessionIdleThresholdMs:n.sessionIdleThresholdMs,fullSnapshotIntervalMs:n.fullSnapshotIntervalMs,captureConsole:null!==(i=n.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(r=n.captureNetwork)&&void 0!==r&&r,captureCanvas:n.captureCanvas,blockClass:n.blockClass,blockSelector:n.blockSelector,ignoreClass:n.ignoreClass,maskTextClass:n.maskTextClass,maskTextSelector:n.maskTextSelector,maskAllInputs:n.maskAllInputs,maskInputOptions:n.maskInputOptions,masking:n.masking,recordHeaders:n.recordHeaders,recordBody:n.recordBody,compressEvents:n.compressEvents,__mutationThrottlerRefillRate:n.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:n.__mutationThrottlerBucketSize}}get isEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!O&&i&&r}get isStarted(){var e;return this._isStarted&&!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.isStarted)}startIfEnabled(){this.startIfEnabledOrStop("recording_initialized")}startIfEnabledOrStop(e){var t;if(!this.isEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this.isEnabled&&i?(this._lazyLoadAndStart(e),this._isStarted=!0,console.info(Dt+" starting")):this.stop()}}stop(){y(()=>{var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.stop(),this._isStarted=!1})}onConfigUpdate(e){var t;this._config=Ft.extractConfig(e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config),this.startIfEnabledOrStop("config_updated")}onRemoteConfig(e){var t,r,n,s,o,a,l;if(e.sessionRecording){var d=e.sessionRecording;this._config=i({},this._config,{enabled:null!==(t=this._config.enabled)&&void 0!==t?t:d.enabled,sampleRate:null!==(r=this._config.sampleRate)&&void 0!==r?r:d.sampleRate,minimumDurationMs:null!==(n=this._config.minimumDurationMs)&&void 0!==n?n:d.minimumDurationMs,fullSnapshotIntervalMs:null!==(s=this._config.fullSnapshotIntervalMs)&&void 0!==s?s:d.fullSnapshotIntervalMs,maskAllInputs:null!==(o=this._config.maskAllInputs)&&void 0!==o?o:d.maskAllInputs,captureConsole:null!==(a=this._config.captureConsole)&&void 0!==a?a:d.captureConsole,captureCanvas:null!==(l=this._config.captureCanvas)&&void 0!==l?l:d.captureCanvas}),this.startIfEnabledOrStop("remote_config")}}get started(){return this.isStarted}get status(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.sessionId)||""}stopRecording(){this.stop()}log(e,t){var i;void 0===t&&(t="log"),(null===(i=this._lazyLoadedRecording)||void 0===i?void 0:i.log)?this._lazyLoadedRecording.log(e,t):console.warn(Dt+" log called before recorder was ready")}updateConfig(e){var t;this._config=i({},this._config,e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config)}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,n;if(this.isEnabled)if((null===(i=null===(t=null==j?void 0:j.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=j.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(n=j.__VTiltExtensions__)||void 0===n?void 0:n.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(Dt+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(Dt+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=j.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(Dt+" initSessionRecording not available after script load")}}var Nt=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(Nt||{}),Bt=Uint8Array,jt=Uint16Array,Vt=Int32Array,Wt=new Bt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ht=new Bt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jt=new Bt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qt=function(e,t){for(var i=new jt(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new Vt(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return{b:i,r:n}},Gt=Qt(Wt,2),Kt=Gt.b,Xt=Gt.r;Kt[28]=258,Xt[258]=28;for(var Zt=Qt(Ht,0).r,Yt=new jt(32768),ei=0;ei<32768;++ei){var ti=(43690&ei)>>1|(21845&ei)<<1;ti=(61680&(ti=(52428&ti)>>2|(13107&ti)<<2))>>4|(3855&ti)<<4,Yt[ei]=((65280&ti)>>8|(255&ti)<<8)>>1}var ii=function(e,t,i){for(var r=e.length,n=0,s=new jt(t);n<r;++n)e[n]&&++s[e[n]-1];var o,a=new jt(t);for(n=1;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new jt(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var d=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,c=h|(1<<u)-1;h<=c;++h)o[Yt[h]>>l]=d}else for(o=new jt(r),n=0;n<r;++n)e[n]&&(o[n]=Yt[a[e[n]-1]++]>>15-e[n]);return o},ri=new Bt(288);for(ei=0;ei<144;++ei)ri[ei]=8;for(ei=144;ei<256;++ei)ri[ei]=9;for(ei=256;ei<280;++ei)ri[ei]=7;for(ei=280;ei<288;++ei)ri[ei]=8;var ni=new Bt(32);for(ei=0;ei<32;++ei)ni[ei]=5;var si=ii(ri,9,0),oi=ii(ni,5,0),ai=function(e){return(e+7)/8|0},li=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new Bt(e.subarray(t,i))},di=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},ui=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},hi=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return{t:mi,l:0};if(1==n){var o=new Bt(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],d=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f<i[h].f?d++:h++],l=i[d!=u&&i[d].f<i[h].f?d++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var c=s[0].s;for(r=1;r<n;++r)s[r].s>c&&(c=s[r].s);var _=new jt(c+1),v=ci(i[u-1],_,0);if(v>t){r=0;var g=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(_[m]>t))break;g+=p-(1<<v-_[m]),_[m]=t}for(g>>=f;g>0;){var y=s[r].s;_[y]<t?g-=1<<t-_[y]++-1:++r}for(;r>=0&&g;--r){var b=s[r].s;_[b]==t&&(--_[b],++g)}v=t}return{t:new Bt(_),l:v}},ci=function(e,t,i){return-1==e.s?Math.max(ci(e.l,t,i+1),ci(e.r,t,i+1)):t[e.s]=i},_i=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new jt(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return{c:i.subarray(0,r),n:t}},vi=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},gi=function(e,t,i){var r=i.length,n=ai(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s<r;++s)e[n+s+4]=i[s];return 8*(n+4+r)},fi=function(e,t,i,r,n,s,o,a,l,d,u){di(t,u++,i),++n[256];for(var h=hi(n,15),c=h.t,_=h.l,v=hi(s,15),g=v.t,f=v.l,p=_i(c),m=p.c,y=p.n,b=_i(g),S=b.c,w=b.n,C=new jt(19),I=0;I<m.length;++I)++C[31&m[I]];for(I=0;I<S.length;++I)++C[31&S[I]];for(var E=hi(C,7),M=E.t,L=E.l,k=19;k>4&&!M[Jt[k-1]];--k);var T,x,P,R,A=d+5<<3,U=vi(n,ri)+vi(s,ni)+o,O=vi(n,c)+vi(s,g)+o+14+3*k+vi(C,M)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&A<=U&&A<=O)return gi(t,u,e.subarray(l,l+d));if(di(t,u,1+(O<U)),u+=2,O<U){T=ii(c,_,0),x=c,P=ii(g,f,0),R=g;var $=ii(M,L,0);di(t,u,y-257),di(t,u+5,w-1),di(t,u+10,k-4),u+=14;for(I=0;I<k;++I)di(t,u+3*I,M[Jt[I]]);u+=3*k;for(var z=[m,S],q=0;q<2;++q){var D=z[q];for(I=0;I<D.length;++I){var F=31&D[I];di(t,u,$[F]),u+=M[F],F>15&&(di(t,u,D[I]>>5&127),u+=D[I]>>12)}}}else T=si,x=ri,P=oi,R=ni;for(I=0;I<a;++I){var N=r[I];if(N>255){ui(t,u,T[(F=N>>18&31)+257]),u+=x[F+257],F>7&&(di(t,u,N>>23&31),u+=Wt[F]);var B=31&N;ui(t,u,P[B]),u+=R[B],B>3&&(ui(t,u,N>>5&8191),u+=Ht[B])}else ui(t,u,T[N]),u+=x[N]}return ui(t,u,T[256]),u+x[256]},pi=new Vt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mi=new Bt(0),yi=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&-306674912)^i>>>1;e[t]=i}return e}(),bi=function(e,t,i,r,n){if(!n&&(n={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new Bt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,n.w=s.length}return function(e,t,i,r,n,s){var o=s.z||e.length,a=new Bt(r+o+5*(1+Math.ceil(o/7e3))+n),l=a.subarray(r,a.length-n),d=s.l,u=7&(s.r||0);if(t){u&&(l[0]=s.r>>3);for(var h=pi[t-1],c=h>>13,_=8191&h,v=(1<<i)-1,g=s.p||new jt(32768),f=s.h||new jt(v+1),p=Math.ceil(i/3),m=2*p,y=function(t){return(e[t]^e[t+1]<<p^e[t+2]<<m)&v},b=new Vt(25e3),S=new jt(288),w=new jt(32),C=0,I=0,E=s.i||0,M=0,L=s.w||0,k=0;E+2<o;++E){var T=y(E),x=32767&E,P=f[T];if(g[x]=P,f[T]=x,L<=E){var R=o-E;if((C>7e3||M>24576)&&(R>423||!d)){u=fi(e,l,0,b,S,w,I,M,k,E-k,u),M=C=I=0,k=E;for(var A=0;A<286;++A)S[A]=0;for(A=0;A<30;++A)w[A]=0}var U=2,O=0,$=_,z=x-P&32767;if(R>2&&T==y(E-z))for(var q=Math.min(c,R)-1,D=Math.min(32767,E),F=Math.min(258,R);z<=D&&--$&&x!=P;){if(e[E+U]==e[E+U-z]){for(var N=0;N<F&&e[E+N]==e[E+N-z];++N);if(N>U){if(U=N,O=z,N>q)break;var B=Math.min(z,N-2),j=0;for(A=0;A<B;++A){var V=E-z+A&32767,W=V-g[V]&32767;W>j&&(j=W,P=V)}}}z+=(x=P)-(P=g[x])&32767}if(O){b[M++]=268435456|Xt[U]<<18|Zt[O];var H=31&Xt[U],J=31&Zt[O];I+=Wt[H]+Ht[J],++S[257+H],++w[J],L=E+U,++C}else b[M++]=e[E],++S[e[E]]}}for(E=Math.max(E,L);E<o;++E)b[M++]=e[E],++S[e[E]];u=fi(e,l,d,b,S,w,I,M,k,E-k,u),d||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=f,s.p=g,s.i=E,s.w=L)}else{for(E=s.w||0;E<o+d;E+=65535){var Q=E+65535;Q>=o&&(l[u/8|0]=d,Q=o),u=gi(l,u+1,e.subarray(E,Q))}s.i=o}return li(a,0,r+ai(u)+n)}(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,i,r,n)},Si=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function wi(e,t){t||(t={});var i=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=yi[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var n,s=bi(e,t,10+((n=t).filename?n.filename.length+1:0),8),o=s.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Si(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(s,t),Si(s,o-8,i.d()),Si(s,o-4,r),s}var Ci="undefined"!=typeof TextEncoder&&new TextEncoder,Ii="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ii.decode(mi,{stream:!0})}catch(e){}Nt.MouseMove,Nt.MouseInteraction,Nt.Scroll,Nt.ViewportResize,Nt.Input,Nt.TouchMove,Nt.MediaInteraction,Nt.Drag;var Ei="[Chat]";class Mi{constructor(e,t){this._instance=e,this.name="Chat",this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._isStarted=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t||Mi.extractConfig(e.getConfig())}static extractConfig(e){var t,i=e.chat||{};return{enabled:i.enabled,autoConfig:null===(t=i.autoConfig)||void 0===t||t,position:i.position,greeting:i.greeting,color:i.color,aiMode:i.aiMode,aiGreeting:i.aiGreeting,preload:i.preload,offlineMessage:i.offlineMessage,collectEmailOffline:i.collectEmailOffline}}get isEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!this._instance.getConfig().disable_chat&&!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}get isStarted(){return this._isStarted}startIfEnabled(){this._startAsync().catch(e=>{console.error(Ei+" Error starting:",e)})}stop(){this.destroy(),this._isStarted=!1}onConfigUpdate(e){var t,i;this._config=Mi.extractConfig(e),this._lazyLoadedChat&&(null===(i=(t=this._lazyLoadedChat).updateConfig)||void 0===i||i.call(t,this.getMergedConfig()))}onRemoteConfig(e){var t,r,n,s,o,a,l,d,u;e.chat&&(this._serverConfig=i({},this._serverConfig,{enabled:null!==(n=null!==(t=e.chat.enabled)&&void 0!==t?t:null===(r=this._serverConfig)||void 0===r?void 0:r.enabled)&&void 0!==n&&n,position:null!==(a=null!==(s=e.chat.widgetPosition)&&void 0!==s?s:null===(o=this._serverConfig)||void 0===o?void 0:o.position)&&void 0!==a?a:"bottom-right",color:null!==(u=null!==(l=e.chat.widgetColor)&&void 0!==l?l:null===(d=this._serverConfig)||void 0===d?void 0:d.color)&&void 0!==u?u:"#6366f1"}),this.isEnabled&&!this._isStarted&&this.startIfEnabled())}_startAsync(){var e=this;return t(function*(){var t,i,r,n;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Ei+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e.isEnabled?(e._isStarted=!0,null!==(r=null!==(t=e._config.preload)&&void 0!==t?t:null===(i=e._serverConfig)||void 0===i?void 0:i.enabled)&&void 0!==r&&r&&e._schedulePreload(),(null===(n=e._serverConfig)||void 0===n?void 0:n.enabled)&&e._showBubble(),console.info(Ei+" ready (lazy-load on demand)")):console.info(Ei+" not enabled (check dashboard settings)")):console.info(Ei+" disabled by code config")})()}get isOpen(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isOpen)&&void 0!==t&&t}get isConnected(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isLoading(){var e,t;return this._isLoading||null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isLoading)&&void 0!==t&&t}get unreadCount(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.unreadCount)&&void 0!==t?t:0}get channel(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channel)&&void 0!==t?t:null}get channels(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channels)&&void 0!==t?t:[]}get currentView(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.currentView)&&void 0!==t?t:"list"}open(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.open()})}close(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.close()}toggle(){this._lazyLoadedChat?this._lazyLoadedChat.toggle():this.open()}show(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.show()})}hide(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.hide()}getChannels(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.getChannels()})}selectChannel(e){this._lazyLoadAndThen(()=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.selectChannel(e)})}createChannel(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.createChannel()})}goToChannelList(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.goToChannelList()}sendMessage(e){this._lazyLoadedChat?this._lazyLoadedChat.sendMessage(e):(this._pendingMessages.push(e),this._lazyLoadAndThen(()=>{this._pendingMessages.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.sendMessage(e)}),this._pendingMessages=[]}))}markAsRead(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.markAsRead()}onMessage(e){return this._messageCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onMessage(e):()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onTyping(e):()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onConnectionChange(e):()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,r,n,s,o,a,l,d,u,h,c,_,v,g,f,p,m=this._serverConfig,y=this._config;return{enabled:null!==(t=null!==(e=y.enabled)&&void 0!==e?e:null==m?void 0:m.enabled)&&void 0!==t&&t,autoConfig:null===(i=y.autoConfig)||void 0===i||i,position:null!==(n=null!==(r=y.position)&&void 0!==r?r:null==m?void 0:m.position)&&void 0!==n?n:"bottom-right",greeting:null!==(s=y.greeting)&&void 0!==s?s:null==m?void 0:m.greeting,color:null!==(a=null!==(o=y.color)&&void 0!==o?o:null==m?void 0:m.color)&&void 0!==a?a:"#6366f1",aiMode:null===(d=null!==(l=y.aiMode)&&void 0!==l?l:null==m?void 0:m.ai_enabled)||void 0===d||d,aiGreeting:null!==(u=y.aiGreeting)&&void 0!==u?u:null==m?void 0:m.ai_greeting,preload:null!==(h=y.preload)&&void 0!==h&&h,theme:null!==(c=y.theme)&&void 0!==c?c:{primaryColor:null!==(v=null!==(_=y.color)&&void 0!==_?_:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(g=y.offlineMessage)&&void 0!==g?g:null==m?void 0:m.offline_message,collectEmailOffline:null===(p=null!==(f=y.collectEmailOffline)&&void 0!==f?f:null==m?void 0:m.collect_email_offline)||void 0===p||p}}destroy(){y(()=>{var e,t;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[];var i=null===(t=null==O?void 0:O.document)||void 0===t?void 0:t.getElementById("vtilt-chat-bubble");i&&i.remove()})}_fetchServerSettings(){var e=this;return t(function*(){if(!e._configFetched){var t=e._instance.getConfig(),i=t.token,r=t.api_host;if(!i||!r)return console.warn(Ei+" Cannot fetch settings: missing token or api_host"),void(e._configFetched=!0);try{var n=r+"/api/chat/settings?token="+encodeURIComponent(i),s=yield fetch(n);if(!s.ok)return console.warn(Ei+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Ei+" Loaded settings from dashboard")}catch(t){console.warn(Ei+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==O?void 0:O.document)&&!document.getElementById("vtilt-chat-bubble")){var e=this.getMergedConfig(),t=e.position||"bottom-right",i=e.color||"#6366f1",r=document.createElement("div");r.id="vtilt-chat-bubble",r.setAttribute("style",("\n position: fixed;\n bottom: 20px;\n "+("bottom-right"===t?"right: 20px;":"left: 20px;")+"\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: "+i+";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n z-index: 999999;\n ").trim()),r.innerHTML='\n <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>\n </svg>\n ',r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.05)",r.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),r.addEventListener("click",()=>{this.open()}),document.body.appendChild(r)}}get _scriptName(){return"chat"}_schedulePreload(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this._lazyLoad(),{timeout:5e3}):setTimeout(()=>this._lazyLoad(),3e3)}_lazyLoadAndThen(e){this._lazyLoadedChat?e():(this._pendingCallbacks.push(e),this._lazyLoad())}_lazyLoad(){var e,t;if(!(this._isLoading||this._lazyLoadedChat||this._loadError))if(null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=j.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Ei+" loadExternalDependency not available. Chat cannot start."),this._isLoading=!1,void(this._loadError="loadExternalDependency not available");i(this._instance,this._scriptName,e=>{if(this._isLoading=!1,e)return console.error(Ei+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=j.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Ei+" initChat not available after script load"),void(this._loadError="initChat not available");if(!this._lazyLoadedChat){var i=this.getMergedConfig();this._lazyLoadedChat=t(this._instance,i),this._messageCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onMessage(e)}),this._typingCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onTyping(e)}),this._connectionCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onConnectionChange(e)});var r=null===document||void 0===document?void 0:document.getElementById("vtilt-chat-bubble");r&&r.remove()}this._pendingCallbacks.forEach(e=>e()),this._pendingCallbacks=[],console.info(Ei+" loaded and ready")}}var Li,ki="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Li||(Li={}));var Ti=e=>{var{data:t,compression:i}=e;if(t){var r=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(t),n=new Blob([r]).size;if(i===Li.GZipJS&&n>=1024)try{var s=wi(function(e,t){if(Ci)return Ci.encode(e);for(var i=e.length,r=new Bt(e.length+(e.length>>1)),n=0,s=function(e){r[n++]=e},o=0;o<i;++o){if(n+5>r.length){var a=new Bt(n+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return li(r,0,n)}(r),{mtime:0}),o=new Blob([s],{type:ki});if(o.size<.95*n)return{contentType:ki,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:n}}},xi=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Ti(e);if(r){var{contentType:n,body:s,estimatedSize:o}=r,a=e.compression===Li.GZipJS&&n===ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,l=i({"Content-Type":n},e.headers||{}),d=new AbortController,u=e.timeout?setTimeout(()=>d.abort(),e.timeout):null;fetch(a,{method:e.method||"POST",headers:l,body:s,keepalive:o<52428.8,signal:d.signal}).then(function(){var i=t(function*(t){var i,r=yield t.text(),n={statusCode:t.status,text:r};if(200===t.status)try{n.json=JSON.parse(r)}catch(e){}null===(i=e.callback)||void 0===i||i.call(e,n)});return function(e){return i.apply(this,arguments)}}()).catch(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{u&&clearTimeout(u)})}}},{name:"XHR",available:"undefined"!=typeof XMLHttpRequest,method:e=>{var t=Ti(e);if(t){var{contentType:i,body:r}=t,n=e.compression===Li.GZipJS&&i===ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,s=new XMLHttpRequest;s.open(e.method||"POST",n,!0),e.headers&&Object.entries(e.headers).forEach(e=>{var[t,i]=e;s.setRequestHeader(t,i)}),s.setRequestHeader("Content-Type",i),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{var t;if(4===s.readyState){var i={statusCode:s.status,text:s.responseText};if(200===s.status)try{i.json=JSON.parse(s.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,i)}},s.onerror=()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},s.send(r)}}},{name:"sendBeacon",available:"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=Ti(e);if(t){var{contentType:i,body:r}=t;try{var n="string"==typeof r?new Blob([r],{type:i}):r,s=e.compression===Li.GZipJS&&i===ki?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,n)}catch(e){}}}}],Pi=e=>{var t,i=e.transport||"fetch",r=xi.find(e=>e.name===i&&e.available)||xi.find(e=>e.available);if(!r)return console.error("vTilt: No available transport method"),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0}));r.method(e)};class Ri{constructor(e,t){var i,r,n,s;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(i=(null==t?void 0:t.flush_interval_ms)||3e3,r=250,n=5e3,s=3e3,"number"!=typeof i||isNaN(i)?s:Math.min(Math.max(i,r),n)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var r=e[t];this._sendRequest(i({},r,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var i in e){var r=e[i];r.events.forEach(e=>{var i=new Date(e.timestamp).getTime();e.$offset=Math.abs(i-t)}),this._sendRequest(r)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var i=t.batchKey||t.url;e[i]||(e[i]={url:t.url,events:[],batchKey:t.batchKey}),e[i].events.push(t.event)}),this._queue=[],e}}class Ai{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,O&&void 0!==z&&"onLine"in z&&(this._areWeOnline=z.onLine,R(O,"online",()=>{this._areWeOnline=!0,this._flush()}),R(O,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)console.warn("VTilt: Request failed after 10 retries, giving up");else{var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),n=(Math.random()-.5)*(r-i);return Math.ceil(r+n)}(t),r=Date.now()+i;this._queue.push({retryAt:r,request:e,retriesPerformedSoFar:t+1});var n="VTilt: Enqueued failed request for retry in "+Math.round(i/1e3)+"s";this._areWeOnline||(n+=" (Browser is offline)"),console.warn(n),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var i=this;return t(function*(){try{var t=yield i._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&i.enqueue(e,0)}catch(t){i.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,i=Date.now(),r=[],n=[];this._queue.forEach(e=>{e.retryAt<i?n.push(e):r.push(e)}),this._queue=r,n.forEach(function(){var i=t(function*(t){var{request:i,retriesPerformedSoFar:r}=t;try{var n=yield e._sendRequest(i);200!==n.statusCode&&(n.statusCode<400||n.statusCode>=500)&&e.enqueue(i,r)}catch(t){e.enqueue(i,r)}});return function(e){return i.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){console.error("VTilt: Failed to send beacon on unload",e)}}),this._queue=[]}}var Ui="vt_rate_limit";class Oi{constructor(e){var t,i;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(i=e.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,i,r,n;void 0===e&&(e=!1);var s=Date.now(),o=null!==(i=null===(t=this.persistence)||void 0===t?void 0:t.get(Ui))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:s},a=(s-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=s,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var l=o.tokens<1;return l||e||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||e||null===(r=this.captureWarning)||void 0===r||r.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(n=this.persistence)||void 0===n||n.set(Ui,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class $i{constructor(e){this._remoteConfig=null,this._host=e}get config(){return this._remoteConfig}onApply(e){this._onApply=e}onLoad(e){this._onLoad=e}load(){var e,t=this._host.getConfig();if(t.projectId){if(null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._apply(this._remoteConfig),void this._fetch();var i=y(()=>O.__VTILT_BOOTSTRAP__);if(null==i?void 0:i.remoteConfig)return this._remoteConfig=i.remoteConfig,this._apply(this._remoteConfig),void this._fetch();y(()=>{var e=localStorage.getItem(u+"_"+t.projectId);e&&(this._remoteConfig=JSON.parse(e),this._apply(this._remoteConfig))}),this._fetch()}}_fetch(){var e=this._host.getConfig();if(e.projectId&&e.api_host){var t=e.api_host+"/api/projects/"+e.projectId+"/decide",i=new AbortController,r=setTimeout(()=>i.abort(),3e3);(F||fetch)(t,{method:"GET",signal:i.signal,headers:{Accept:"application/json"}}).then(e=>e.json()).then(t=>{var i;clearTimeout(r),this._remoteConfig=t,y(()=>{localStorage.setItem(u+"_"+e.projectId,JSON.stringify(t))}),this._apply(t),null===(i=this._onLoad)||void 0===i||i.call(this,t)}).catch(()=>{clearTimeout(r)})}}_apply(e){var t,i,r,n,s,o,a,l,d,u=this._host.getConfig(),h={},c=!1,_=!1,v=!1;e.sessionRecording&&void 0===u.session_recording&&(h.session_recording={enabled:e.sessionRecording.enabled,sampleRate:e.sessionRecording.sampleRate,minimumDurationMs:e.sessionRecording.minimumDurationMs,fullSnapshotIntervalMs:e.sessionRecording.fullSnapshotIntervalMs,maskAllInputs:e.sessionRecording.maskAllInputs,captureConsole:e.sessionRecording.captureConsole,captureCanvas:e.sessionRecording.captureCanvas},e.sessionRecording.enabled&&(c=!0)),(null===(t=e.chat)||void 0===t?void 0:t.enabled)&&void 0===u.chat&&(h.chat={enabled:e.chat.enabled,position:e.chat.widgetPosition,color:e.chat.widgetColor},_=!0),e.analytics&&(void 0!==e.analytics.capturePageview&&void 0===u.capture_pageview&&(h.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===u.capture_pageleave&&(h.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===u.capture_performance&&(h.capture_performance=e.analytics.capturePerformance),void 0!==e.analytics.autocapture&&void 0===u.autocapture&&(h.autocapture=e.analytics.autocapture,e.analytics.autocapture&&(v=!0))),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.respectDnt)&&void 0===u.respect_dnt&&(h.respect_dnt=e.privacy.respectDnt),Object.keys(h).length>0&&this._host.updateConfig(h),null===(r=this._onApply)||void 0===r||r.call(this,e),this._host.__loaded&&(c&&(null===(s=(n=this._host).startSessionRecording)||void 0===s||s.call(n)),_&&(null===(a=(o=this._host)._initChat)||void 0===a||a.call(o)),v&&(null===(d=(l=this._host).startAutocapture)||void 0===d||d.call(l)))}}class zi{constructor(e){this._set_once_properties_sent=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this._vt_person_uuid=null,this._host=e}setVtPersonUuid(e){this._vt_person_uuid=e}capture(e,t,r){var n;if(this._host.sessionManager.setSessionId(),(null==z?void 0:z.userAgent)&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(z.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this._host.rateLimiter.shouldAllowEvent())){var s,o=this._host.buildUrl(),a=this._host.getConfig(),l=this._buildEventPayload(e,t);if(!1!==a.stringifyPayload){if(!x(s=JSON.stringify(i({},l,a.globalAttributes))))return}else if(s=i({},l,a.globalAttributes),!x(JSON.stringify(s)))return;var d="$identify"===e?this._host.userManager.getAnonymousId():null!==(n=this._host.userManager.getDistinctId())&&void 0!==n?n:this._host.userManager.getAnonymousId(),u={timestamp:(new Date).toISOString(),event:e,project_id:a.projectId||"",payload:s,distinct_id:d,anonymous_id:this._host.userManager.getAnonymousId()};this._host.sendRequest(o,u,!0)}}captureInternal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}captureInitialPageview(){q&&("visible"===q.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{q&&D&&this.capture("$pageview",{navigation_type:"initial_load"})},300),this._visibility_state_listener&&(q.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>this.captureInitialPageview(),R(q,"visibilitychange",this._visibility_state_listener)))}_buildEventPayload(e,t){var r=lt(),n=this._host.userManager.getUserProperties(),s=this._host.userManager.get_initial_props(),o=this._host.sessionManager.getSessionId(),a=this._host.sessionManager.getWindowId(),l=this._host.userManager.getAnonymousId(),d={};!this._set_once_properties_sent&&Object.keys(s).length>0&&Object.assign(d,s),t.$set_once&&Object.assign(d,t.$set_once);var u=i({},r,n,{$session_id:o,$window_id:a},l?{$anon_distinct_id:l}:{},this._vt_person_uuid?{$vt:this._vt_person_uuid}:{},Object.keys(d).length>0?{$set_once:d}:{},t.$set?{$set:t.$set}:{},t);return!this._set_once_properties_sent&&Object.keys(s).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&q&&(u.title=q.title),u}}class qi{constructor(e){this._host=e}identify(e,t,i){var r;if("number"==typeof e&&(e=String(e),console.warn("identify: first argument should be a string, not a number")),e)if(this._host.userManager.isDistinctIdStringLikePublic(e))console.error('identify: "'+e+'" appears to be a hardcoded string');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this._host.userManager.getDistinctId(),s=this._host.userManager.getAnonymousId(),o=this._host.userManager.getDeviceId(),a="anonymous"===this._host.userManager.getUserState();o||this._host.userManager.ensureDeviceId(n||s),e!==n&&a?(this._host.userManager.setUserState("identified"),this._host.userManager.updateUserProperties(t,i),this._host.capture("$identify",{distinct_id:e,$anon_distinct_id:s,$set:t||{},$set_once:i||{}}),this._host.userManager.setDistinctId(e),null===(r=this._host._emitter)||void 0===r||r.emit("user:identified",{distinctId:e})):t||i?(a&&this._host.userManager.setUserState("identified"),this._host.userManager.updateUserProperties(t,i),this._host.capture("$set",{$set:t||{},$set_once:i||{}})):e!==n&&(this._host.userManager.setUserState("identified"),this._host.userManager.setDistinctId(e))}else console.error("identify: cannot use sentinel value as distinct_id");else console.error("identify: unique user id is required")}setUserProperties(e,t){var i;this._host.userManager.setUserProperties(e,t)&&(this._host.capture("$set",{$set:e||{},$set_once:t||{}}),null===(i=this._host._emitter)||void 0===i||i.emit("user:properties_set",{properties:e}))}resetUser(e){var t;this._host.sessionManager.resetSessionId(),this._host.userManager.reset(e),null===(t=this._host._emitter)||void 0===t||t.emit("user:reset")}createAlias(e,t){var i=this._host.userManager.createAlias(e,t);i?this._host.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this._host.userManager.getDistinctId()||this._host.userManager.getAnonymousId())&&this.identify(e)}getUserIdentity(){return this._host.userManager.getUserIdentity()}getDeviceId(){return this._host.userManager.getDeviceId()}getUserState(){return this._host.userManager.getUserState()}getDistinctId(){var e;return null!==(e=this._host.userManager.getDistinctId())&&void 0!==e?e:this._host.userManager.getAnonymousId()}getAnonymousId(){return this._host.userManager.getAnonymousId()}}class Di{constructor(e){this._features=new Map,this._host=e}onFeatureStarted(e){this._onFeatureStarted=e}onFeatureStopped(e){this._onFeatureStopped=e}register(e){this._features.set(e.name,e)}get(e){var t;return null===(t=this._features.get(e))||void 0===t?void 0:t.instance}initAll(){this._features.forEach(e=>{this._initFeature(e)})}init(e){var t=this._features.get(e);if(t)return this._initFeature(t),t.instance}start(e){var t,i=this._features.get(e);if(i&&(i.instance||this._initFeature(i),i.instance)){if(i.instance.onConfigUpdate){var r=this._host.getConfig();i.instance.onConfigUpdate(r)}i.instance.startIfEnabled(),null===(t=this._onFeatureStarted)||void 0===t||t.call(this,e)}}stop(e){var t,i=this._features.get(e);(null==i?void 0:i.instance)&&(i.instance.stop(),null===(t=this._onFeatureStopped)||void 0===t||t.call(this,e))}isActive(e){var t,i,r;return null!==(r=null===(i=null===(t=this._features.get(e))||void 0===t?void 0:t.instance)||void 0===i?void 0:i.isStarted)&&void 0!==r&&r}notifyConfigUpdate(e){this._features.forEach(t=>{var i;(null===(i=t.instance)||void 0===i?void 0:i.onConfigUpdate)&&y(()=>t.instance.onConfigUpdate(e))})}notifyRemoteConfig(e){this._features.forEach(t=>{var i;(null===(i=t.instance)||void 0===i?void 0:i.onRemoteConfig)&&y(()=>t.instance.onRemoteConfig(e))})}getAll(){var e=[];return this._features.forEach(t=>{t.instance&&e.push(t.instance)}),e}_initFeature(e){if(!e.instance){var t=this._host.getConfig();e.disableKey&&t[e.disableKey]||e.enableKey&&!1===t[e.enableKey]||y(()=>{var t;e.instance=new e.FeatureClass(this._host),e.instance.startIfEnabled(),e.instance.isStarted&&(null===(t=this._onFeatureStarted)||void 0===t||t.call(this,e.name))})}}}var Fi="vt";class Ni{constructor(e){void 0===e&&(e={}),this.version=r,this.__loaded=!1,this.__request_queue=[],this._has_warned_about_config=!1,this._emitter=new b,this.configManager=new m(e);var t=this.configManager.getConfig();this.sessionManager=new G(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new dt(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.rateLimiter=new Oi({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._captureManager.captureInternal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new Ai({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new Ri(e=>this._send_batched_request(e),{flush_interval_ms:3e3}),this._captureManager=new zi(this),this._identityManager=new qi(this),this._remoteConfigManager=new $i(this),this._featureManager=new Di(this),this._remoteConfigManager.onApply(e=>{this._featureManager.notifyRemoteConfig(e)}),this._remoteConfigManager.onLoad(e=>{this._emitter.emit(C,{config:e})}),this._featureManager.onFeatureStarted(e=>{this._emitter.emit(I,{feature:e})}),this._featureManager.onFeatureStopped(e=>{this._emitter.emit(E,{feature:e})})}init(e,t,i){var r;if(i&&i!==Fi){var n=null!==(r=Bi[i])&&void 0!==r?r:new Ni;return n._init(e,t,i),Bi[i]=n,Bi[Fi][i]=n,n}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: Already initialized! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:r})),this.__loaded=!0,this._read_vt_param_from_url(),this._remoteConfigManager.load();var n=this.configManager.getConfig();return this.userManager.set_initial_person_info(n.mask_personal_data_properties,n.custom_personal_data_properties),this._initFeatures(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==n.capture_pageview&&this._captureManager.captureInitialPageview(),this._emitter.emit(S,{config:n}),this}_initFeatures(){this._initHistoryAutocapture(),this._initAutocapture(),this._initWebVitals(),this._initSessionRecording(),this._initChat()}_initHistoryAutocapture(){this.historyAutocapture||(this.historyAutocapture=new ft(this),this.historyAutocapture.startIfEnabled())}_initAutocapture(){this.autocapture||!1!==this.configManager.getConfig().autocapture&&(this.autocapture=new qt(this),this.autocapture.startIfEnabled())}_initWebVitals(){this.webVitals||(this.webVitals=new vt(this),this.webVitals.startIfEnabled())}_initSessionRecording(){this.sessionRecording||(this.configManager.getConfig().disable_session_recording||(this.sessionRecording=new Ft(this),this.sessionRecording.isEnabled&&(this.sessionRecording.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(L))))}_initChat(){this.chat||(this.configManager.getConfig().disable_chat||(this.chat=new Mi(this),this.chat.startIfEnabled()))}startAutocapture(){this.autocapture||(this.autocapture=new qt(this)),this.autocapture.updateConfig({enabled:!0}),this.autocapture.startIfEnabled()}stopAutocapture(){var e;null===(e=this.autocapture)||void 0===e||e.stop()}isAutocaptureActive(){var e,t;return null!==(t=null===(e=this.autocapture)||void 0===e?void 0:e.isStarted)&&void 0!==t&&t}startSessionRecording(){this.sessionRecording||(this.sessionRecording=new Ft(this)),this.sessionRecording.updateConfig({enabled:!0}),this.sessionRecording.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(L)}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stop(),this._emitter.emit(k)}isRecordingActive(){var e;return"active"===(null===(e=this.sessionRecording)||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this.sessionRecording)||void 0===e?void 0:e.sessionId)||null}capture(e,t,i){this._captureManager.capture(e,t,i),this._emitter.emit(M,{event:e,payload:t})}trackEvent(e,t){void 0===t&&(t={}),this._captureManager.trackEvent(e,t)}identify(e,t,i){this._identityManager.identify(e,t,i)}setUserProperties(e,t){this._identityManager.setUserProperties(e,t)}resetUser(e){this._identityManager.resetUser(e)}createAlias(e,t){this._identityManager.createAlias(e,t)}getUserIdentity(){return this._identityManager.getUserIdentity()}getDeviceId(){return this._identityManager.getDeviceId()}getUserState(){return this._identityManager.getUserState()}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this._identityManager.getDistinctId()}getAnonymousId(){return this._identityManager.getAnonymousId()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:Fi;return t!==Fi&&(t="vt."+t),t}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new G(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new dt(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this._notifyFeaturesOfConfigUpdate(t),this._emitter.emit(w,{config:t})}_notifyFeaturesOfConfigUpdate(e){[this.historyAutocapture,this.autocapture,this.webVitals,this.sessionRecording,this.chat].forEach(t=>{(null==t?void 0:t.onConfigUpdate)&&y(()=>t.onConfigUpdate(e))})}buildUrl(){var e=this.configManager.getConfig(),{proxyUrl:t,proxy:i,api_host:r,token:n}=e;return t||(i?i+"/api/tracking?token="+n:r?r.replace(/\/+$/gm,"")+"/api/tracking?token="+n:"/api/tracking?token="+n)}sendRequest(e,t,i){if(this._is_configured()){if(i&&void 0!==O)if(O.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_is_configured(){var e=this.configManager.getConfig();return!(!e.projectId||!e.token)||(this._has_warned_about_config||(console.warn("VTilt: projectId and token are required for tracking"),this._has_warned_about_config=!0),!1)}_send_batched_request(e){"sendBeacon"!==e.transport?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:i,events:r}=e,n=1===r.length?r[0]:{events:r},s=this.configManager.getConfig().disable_compression?Li.None:Li.GZipJS;Pi({url:i,data:n,method:"POST",transport:"XHR",compression:s,callback:e=>t({statusCode:e.statusCode})})})}_send_beacon_request(e){var{url:t,events:i}=e,r=1===i.length?i[0]:{events:i},n=this.configManager.getConfig().disable_compression?Li.None:Li.GZipJS;Pi({url:t,data:r,method:"POST",transport:"sendBeacon",compression:n})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}_setup_unload_handler(){if(O){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};R(O,"beforeunload",e),R(O,"pagehide",e)}}_start_queue_if_opted_in(){this.requestQueue.enable()}_read_vt_param_from_url(){y(()=>{var e,t;if(void 0!==D&&D.search){var i=new URL(D.href),r=i.searchParams.get("vt");if(null==r?void 0:r.trim()){this._captureManager.setVtPersonUuid(r.trim()),i.searchParams.delete("vt");var n=i.pathname+(i.search||"")+i.hash;null===(t=null===(e=null==O?void 0:O.history)||void 0===e?void 0:e.replaceState)||void 0===t||t.call(e,{},"",n)}}})}_execute_array(e){Array.isArray(e)&&e.forEach(e=>{if(e&&Array.isArray(e)&&e.length>0){var t=e[0],i=e.slice(1);"function"==typeof this[t]&&y(()=>this[t](...i))}})}_dom_loaded(){this.__request_queue.forEach(e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}}var Bi={},ji=!(void 0!==N||void 0!==F)&&-1===(null==B?void 0:B.indexOf("MSIE"))&&-1===(null==B?void 0:B.indexOf("Mozilla"));null!=O&&(O.__VTILT_ENQUEUE_REQUESTS=ji);var Vi,Wi=(Vi=Bi[Fi]=new Ni,function(){function e(){e.done||(e.done=!0,ji=!1,null!=O&&(O.__VTILT_ENQUEUE_REQUESTS=!1),P(Bi,e=>e._dom_loaded()))}q&&"function"==typeof q.addEventListener?"complete"===q.readyState?e():R(q,"DOMContentLoaded",e,{capture:!1}):O&&console.error("Browser doesn't support document.addEventListener")}(),Vi);export{ut as ALL_WEB_VITALS_METRICS,ht as DEFAULT_WEB_VITALS_METRICS,Ni as VTilt,Wi as default,Wi as vt};
|
|
2
2
|
//# sourceMappingURL=module.no-external.js.map
|