var e;e=()=>(()=>{function e(t){var n,i=qt[t];return void 0!==i?i.exports:(n=qt[t]={exports:{}},zt[t](n,n.exports,e),n.exports)}function t(e,t,i=576e3,r){var o;try{const a=new Date;a.setTime(a.getTime()+60*i*1e3);const s=[`${e}=${encodeURIComponent(t)}`,`expires=${a.toUTCString()}`,`path=${(null==r?void 0:r.path)||"/"}`,`SameSite=${(null==r?void 0:r.sameSite)||"Lax"}`];(null==r?void 0:r.domain)&&s.push(`domain=${r.domain}`);const c="undefined"!=typeof window&&"https:"===(null===(o=window.location)||void 0===o?void 0:o.protocol);(!0===(null==r?void 0:r.secure)||!1!==(null==r?void 0:r.secure)&&c)&&s.push("Secure");const l=s.join("; ");document.cookie=l,i<=0||""===String(t)||"__cst_domain_test__"===e||null===n(e)&&(0,jt.AO)(`Failed to set cookie: ${e}`)}catch(e){(0,jt.AO)("Error setting cookie:",e)}}function n(e){try{const t=e+"=",n=document.cookie.split(";");for(let e of n)if(e=e.trim(),e.startsWith(t))return decodeURIComponent(e.substring(t.length))}catch(t){(0,jt.AO)(`Error getting cookie: ${e}`,t)}return null}function i(e,t){const n={},i={};return e?(e.split(";").forEach(e=>{const r=e.indexOf("=");if(-1===r)return;const o=e.substring(0,r).trim(),a=e.substring(r+1).trim();if(o)try{const e=decodeURIComponent(o),r=decodeURIComponent(a);let s=r;if(e===gn)try{s=JSON.parse(r)}catch(e){(0,jt.AO)(`Error parsing location cookie JSON: ${r}`,e),s=r}n[e]?n[e].includes(s)||n[e].push(s):n[e]=[s],function(e,t){if(yn.exact.includes(e))return!0;for(const t of yn.prefix)if(e.startsWith(t))return!0;return!(!t||!t.includes(e))}(e,t)&&"string"==typeof s&&(i[e]?i[e].includes(s)||i[e].push(s):i[e]=[s])}catch(e){(0,jt.AO)(`Error decoding cookie: ${o}=${a}`,e)}}),{allCookies:n,marketingTrackers:i}):{allCookies:n,marketingTrackers:i}}function r(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{try{if(Array.isArray(t)&&1===t.length){const n=t[0];return e===gn&&"object"==typeof n&&null!==n?[e,JSON.stringify(n)]:[e,String(n)]}return[e,Array.isArray(t)?JSON.stringify(t):String(t)]}catch(t){return(0,jt.AO)(`Error converting value for key: ${e}`,t),[e,""]}}))}function o(e){return r(e)}function a(){try{if("undefined"==typeof window)return;if(Tn)return Sn;const i=window;if(i.CST_COOKIE_DOMAIN&&"string"==typeof i.CST_COOKIE_DOMAIN)return i.CST_COOKIE_DOMAIN.trim();const r=document.querySelector('meta[name="cst:cookieDomain"], meta[name="cst-cookie-domain"]');if(null==r?void 0:r.content)return r.content.trim();const o=window.location.hostname;if(!(e=o)||"localhost"===e||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(e)||e.includes(":"))return Tn=!0,Sn=void 0,Sn;const a=o.split(".");if(a.length<2)return Tn=!0,Sn=void 0,Sn;const s=[];for(let e=a.length-2;e>=0;e--){const t="."+a.slice(e).join(".");s.push(t)}const c="__cst_domain_test__";for(const e of s)try{t(c,"1",1,{domain:e,path:"/",sameSite:"Lax"});const i="1"===n(c);if(t(c,"",-1,{domain:e,path:"/",sameSite:"Lax"}),i)return(0,jt.cY)("Selected cookie domain",e),Tn=!0,Sn=e,Sn}catch(e){}}catch(e){}var e;return Tn=!0,Sn=void 0,Sn}async function s(){try{await new Promise(e=>requestAnimationFrame(e));const e=navigator.maxTouchPoints>0||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=(await Promise.all([c(),...e?[]:[l()]])).join("|||");return await async function(e){const t=(new TextEncoder).encode(e);try{const e=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,"0")).join("").slice(0,12)}catch(t){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;return Math.abs(n).toString(36).padStart(12,"0")}}(t)}catch(e){return"canvas-error"}}async function c(){try{const e=document.createElement("canvas"),t=e.getContext("2d");return t?(e.width=200,e.height=100,t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(100,1,50,15),t.fillStyle="#069",t.font="12pt Arial",t.fillText("Canvas test 🔒",2,15),t.fillStyle="rgba(102, 204, 0, 0.8)",t.font="16pt Arial",t.fillText("Font Test",4,40),t.fillStyle="#ff0000",t.font="11pt Times",t.fillText("©®™€",2,65),t.fillStyle="#0000ff",t.font="14pt Arial",t.fillText("😀🌍",2,85),e.toDataURL()):"text-canvas-unsupported"}catch(e){return"text-canvas-error"}}async function l(){try{const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return"geometry-canvas-unsupported";e.width=150,e.height=150;const n=t.createLinearGradient(0,0,150,150);return n.addColorStop(0,"#ff0000"),n.addColorStop(.5,"#00ff00"),n.addColorStop(1,"#0000ff"),t.fillStyle=n,t.fillRect(10,10,130,50),t.strokeStyle="#ff00ff",t.lineWidth=2,t.beginPath(),t.arc(75,100,30,0,2*Math.PI),t.stroke(),t.strokeStyle="#00ffff",t.lineWidth=1.5,t.beginPath(),t.moveTo(30,80),t.quadraticCurveTo(75,50,120,80),t.stroke(),t.globalAlpha=.6,t.fillStyle="#ffff00",t.fillRect(40,70,70,40),e.toDataURL()}catch(e){return"geometry-canvas-error"}}function d(e,t){return!Number.isFinite(e)||t<=0?0:Math.round(e/t)*t}function u(){try{if("function"!=typeof matchMedia)return"unknown";if(matchMedia("(color-gamut: rec2020)").matches)return"rec2020";if(matchMedia("(color-gamut: p3)").matches)return"p3";if(matchMedia("(color-gamut: srgb)").matches)return"srgb"}catch(e){}return"unknown"}function m(){const e=navigator.userAgent;return/Edg\//.test(e)?"edge":/OPR\//.test(e)?"opera":/Chrome\//.test(e)?"chromium":/Firefox\//.test(e)?"gecko":/Safari\//.test(e)&&/Version\//.test(e)?"webkit":"unknown"}function h(){try{const e=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat;if(e){const t=(new e).resolvedOptions().timeZone;if(t)return t}}catch(e){}return"UTC"+-(new Date).getTimezoneOffset()/60}async function f(){if(function(){try{const e=navigator.userAgent.match(/Version\/(\d+).*Safari/);if(e)return parseInt(e[1],10)>=17}catch(e){}return!1}()||function(){try{const e=navigator.userAgent.match(/SamsungBrowser\/(\d+)/);if(e)return parseInt(e[1],10)>=26}catch(e){}return!1}())return"audio-antifingerprint";try{const e=window.OfflineAudioContext||window.webkitOfflineAudioContext;if(!e)return"audio-unsupported";const t=new e(1,5e3,44100),n=t.createOscillator();n.type="triangle",n.frequency.value=1e4;const i=t.createDynamicsCompressor();i.threshold.value=-50,i.knee.value=40,i.ratio.value=12,i.attack.value=0,i.release.value=.25,n.connect(i),i.connect(t.destination),n.start(0);const r=(await Promise.race([new Promise((e,n)=>{t.oncomplete=t=>e(t.renderedBuffer),t.startRendering().catch(n)}),new Promise((e,t)=>setTimeout(()=>t(new Error("Audio timeout")),1e3))])).getChannelData(0).subarray(4500,5e3);let o=0;for(let e=0;e<r.length;e++)o=(o<<5)-o+Math.round(1e6*r[e])>>>0;return o.toString(36)}catch(e){return"audio-error"}}function p(e){return e.map(e=>"string"==typeof e?e:String(e)).join("|||")}async function g(e){try{const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")}catch(t){return(0,jt.AO)("Error generating SHA-256 hash:",t),function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t>>>=0;return t.toString(36).padStart(24,"0")}(e)}}function v(e){let t=BigInt("0x"+e),n="";for(;t>0;)n="0123456789abcdefghijklmnopqrstuvwxyz"[Number(t%BigInt(36))]+n,t/=BigInt(36);return n.padStart(24,"0")}function y(e){return e?encodeURIComponent(e).replace(/'/g,"%27").replace(/"/g,"%22"):""}function w(e){if(!e)return null;const t=e.trim();if(0===t.length)return null;try{const e="undefined"!=typeof document&&document.baseURI||"undefined"!=typeof location&&location.href||void 0,n=t.length>2048?t.slice(0,2048):t,i=e?new URL(n,e):new URL(n),r=i.protocol.toLowerCase();return"http:"!==r&&"https:"!==r&&"mailto:"!==r&&"tel:"!==r?null:(i.username="",i.password="",i.toString())}catch(e){return null}}function b(e){const t=e.split(".");if(t.length<=2)return e;const n=t.slice(-2).join(".");if(["co.uk","com.au","gov.bd","edu.sg"].includes(n)){if(3===t.length)return t.slice(-3).join(".");if(t.length>=4)return t.slice(-3).join(".")}return n}function S(e,t,n={}){const{maxRequestsPerSecond:i=10,leading:r=!0,trailing:o=!0}=n;let a=0,s=null,c=t;return function(...n){const l=Date.now(),d=l-a;c=d<1e3/i?Math.min(1.5*c,1e3):Math.max(t,.75*c),(r||0===a)&&d>=c?(s&&(clearTimeout(s),s=null),a=l,e.apply(this,n)):o&&!s&&(s=setTimeout(()=>{a=Date.now(),s=null,e.apply(this,n)},c))}}function T(e,t){let n=null;return function(...i){n&&clearTimeout(n),n=setTimeout(()=>{n=null,e(...i)},t)}}function _(){return(new Date).toISOString()}function I(){return Date.now()}function k(e){if("number"==typeof e)return e;if("string"==typeof e){const t=Number(e);if(!isNaN(t))return t;const n=Date.parse(e);if(!isNaN(n))return n}throw new Error(`Invalid time value: ${e}`)}function A(e,t){return new Promise((n,i)=>{const r=setTimeout(()=>{i(new Error(`Operation timed out after ${t} ms`))},t);e.then(e=>{clearTimeout(r),n(e)}).catch(e=>{clearTimeout(r),i(e)})})}function E(e){null==Cn&&(Cn=setTimeout(()=>{Cn=null,L()},Math.max(100,e)))}function O(e,t){const n=An.session,i=An.pageView,r=An.events,o=An.sessionId,a=An.pageViewId,s=An.clientId,c=new Map;for(const t of e){const e=t[n],r=null==e?void 0:e[i],l=`${t[s]||"unknown"}|${(null==e?void 0:e[o])||(null==e?void 0:e.id)||"unknown"}|${(null==r?void 0:r[a])||(null==r?void 0:r.id)||"unknown"}`,d=c.get(l);d?d.push(t):c.set(l,[t])}const l=[];return c.forEach(e=>{var o;e.sort((e,t)=>e.queuedAt-t.queuedAt);let a=0;for(;a<e.length;){const s=e[a],c=Object.assign(Object.assign({},s),{id:`${Date.now()}_${Math.random().toString(36).slice(2)}`,queuedAt:[s.queuedAt]}),d=s[n],u=null==d?void 0:d[i],m=Array.isArray(null==u?void 0:u[r])?[...u[r]]:[];(null===(o=c[n])||void 0===o?void 0:o[i])||(c[n]=c[n]||{},c[n][i]=c[n][i]||{[r]:[]}),c[n][i][r]=m;const h=[s.id];let f=c[n][i][r].length;for(a++;a<e.length&&f<t;){const o=e[a],s=o[n],l=null==s?void 0:s[i],d=Array.isArray(null==l?void 0:l[r])?l[r]:[];c[n][i][r]=[...c[n][i][r],...d].slice(0,t),h.push(o.id),c.queuedAt.push(o.queuedAt),f=c[n][i][r].length,a++}l.push({merged:c,sourceIds:h})}}),l}async function L(e={}){if(Pn)return(0,jt.cY)("Already sending, scheduling pending flush"),void(Nn=!0);Pn=!0,Nn=!1;try{do{Nn=!1;const t=Boolean(e.force);if(!On.isAllowed())return void(0,jt.cY)("Circuit breaker preventing send");const n=D();if(!n.length)break;const i=Date.now();if(!(t||n.length>=Yn||i-Mn>=1e4)){const e=Math.max(100,1e4-(i-Mn));(0,jt.cY)("Delaying send: thresholds not met",{remaining:e,queued:n.length}),E(e);break}t&&Cn&&(clearTimeout(Cn),Cn=null);const r=O(n,Yn);for(const{merged:e,sourceIds:t}of r){if(!await H(e)){On.recordFailure();break}for(const e of t)$(e);On.recordSuccess(),Mn=Date.now()}}while(Nn)}catch(e){(0,jt.AO)("Error in sendQueuedBatches",e),On.recordFailure()}finally{Pn=!1}}async function C(){try{(0,jt.cY)("sendInitialData called");const e=await En(null,"initial");try{let t;try{t=JSON.stringify(e)}catch(e){throw(0,jt.AO)("JSON serialization failed for initial data",e),e}const n=await fetch(Gt,{method:"POST",headers:{"Content-Type":"text/plain"},body:t,credentials:"omit",cache:"no-store",signal:AbortSignal.timeout(1e4)});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return(0,jt.cY)("sendInitialData sent successfully"),!0}catch(t){return(0,jt.AO)("Error in immediate initial data send",t),await H(e,!1)?((0,jt.cY)("sendInitialData retry succeeded"),!0):((0,jt.cY)("sendInitialData saving to storage after failed attempts"),R(e),xn(),!1)}}catch(e){return(0,jt.AO)("Error sending initial data",e),!1}}async function M(e){try{return R(e),xn(),!0}catch(e){return(0,jt.AO)("Error queueing data",e),!1}}async function Y(e){return M(await En(e))}function P(e,t={}){const n=R(e);return n&&t.triggerSend&&xn(),n}function N(e){e&&$(e)}function x(e){if(null==e?void 0:e.force)return L({force:!0});xn()}function R(e){try{const t=D(),n=Object.assign(Object.assign({},e),{id:`${Date.now()}_${Math.random().toString(36).substr(2,9)}`,queuedAt:Date.now()});t.push(n),t.length>10&&t.splice(0,t.length-10);try{localStorage.setItem(vn,JSON.stringify(t))}catch(e){(0,jt.AO)("JSON serialization failed for batch storage",e)}return(0,jt.cY)(`Saved batch to storage. Total batches: ${t.length}`),n.id}catch(e){return(0,jt.AO)("Error saving batch to storage",e),null}}function D(){try{const e=localStorage.getItem(vn);return e?JSON.parse(e):[]}catch(e){return(0,jt.AO)("Error loading pending batches",e),[]}}function $(e){try{const t=D().filter(t=>t.id!==e);try{localStorage.setItem(vn,JSON.stringify(t))}catch(e){(0,jt.AO)("JSON serialization failed for batch removal",e)}}catch(e){(0,jt.AO)("Error removing batch from storage",e)}}async function H(e,t=!1){try{(0,jt.cY)("sendDataWithRetry called",e.eventType);const n=Object.assign({},e);let i;delete n.id,delete n.queuedAt;try{i=JSON.stringify(n)}catch(e){throw(0,jt.AO)("JSON serialization failed",e),e}const r=("hidden"===document.visibilityState||t)&&"function"==typeof navigator.sendBeacon;let o=!1;if(r){(0,jt.cY)("sendDataWithRetry using beacon");try{const e=new Blob([i],{type:"application/json"});o=navigator.sendBeacon(Gt,e),o&&(0,jt.cY)("sendDataWithRetry beacon accepted for delivery")}catch(e){(0,jt.AO)("Beacon threw error, falling back to fetch",e)}}(0,jt.cY)("sendDataWithRetry trying primary endpoint:",Gt);try{const t=await fetch(Gt,{method:"POST",headers:{"Content-Type":"text/plain"},body:i,credentials:"omit",cache:"no-store",keepalive:!0,signal:AbortSignal.timeout(1e4)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);try{await t.text()}catch(e){(0,jt.cY)("Could not read success response body, but request succeeded")}return"heartbeat"!==e.eventType&&(Ln=Date.now()),(0,jt.cY)("sendDataWithRetry primary endpoint success"),!0}catch(t){(0,jt.AO)("Primary endpoint failed, trying fallback:",t);const n=(()=>{const e=Vt;return(0,jt.cY)("Using fallback endpoint:",e),e})();(0,jt.cY)("sendDataWithRetry trying fallback endpoint:",n);try{const t=await fetch(n,{method:"POST",headers:{"Content-Type":"text/plain"},body:i,credentials:"omit",cache:"no-store",keepalive:!0,signal:AbortSignal.timeout(1e4)});if(!t.ok)throw new Error(`Fallback HTTP error! status: ${t.status}`);try{await t.text()}catch(e){(0,jt.cY)("Could not read fallback success response body, but request succeeded")}return"heartbeat"!==e.eventType&&(Ln=Date.now()),(0,jt.cY)("sendDataWithRetry fallback endpoint success"),!0}catch(e){return(0,jt.AO)("Both primary and fallback endpoints failed:",e),o&&(0,jt.cY)("sendDataWithRetry falling back to queued beacon-only delivery"),!1}}}catch(e){return(0,jt.AO)("Error sending data",e),!1}}function W(e){try{const t=localStorage.getItem(Dn);if(!t)return;const n=JSON.parse(t).filter(t=>t.id!==e);0===n.length?localStorage.removeItem(Dn):localStorage.setItem(Dn,JSON.stringify(n)),(0,jt.cY)(`Removed batch ${e} from storage. Remaining: ${n.length}`)}catch(e){(0,jt.AO)("Error removing batch from storage",e)}}async function j(){if($n)(0,jt.cY)("Already retrying events, skipping");else try{$n=!0;const e=localStorage.getItem(Dn);if(!e)return;const t=JSON.parse(e);if(0===t.length)return;(0,jt.cY)(`Retrying ${t.length} stored batches`);for(const e of t){try{await H(e)?W(e.id):(0,jt.cY)(`Failed to send batch ${e.id}, keeping in storage`)}catch(t){(0,jt.AO)(`Error processing batch ${e.id}`,t)}await new Promise(e=>setTimeout(e,Rn))}}catch(e){(0,jt.AO)("Error in retryFailedEvents",e)}finally{$n=!1}}function F(e){if(!Wn)return Wn={x:e.clientX,y:e.clientY},void Fn();Math.hypot(e.clientX-Wn.x,e.clientY-Wn.y)>100&&(Wn={x:e.clientX,y:e.clientY},Fn())}function U(){z(),document.addEventListener("mousemove",F,{passive:!0}),["touchmove","scroll","keypress","click"].forEach(e=>{document.addEventListener(e,Fn,{passive:!0})}),Fn(),(0,jt.cY)("Activity tracking initialized")}function z(){Hn&&(clearTimeout(Hn),Hn=null),document.removeEventListener("mousemove",F),["touchmove","scroll","keypress","click"].forEach(e=>{document.removeEventListener(e,Fn)})}function q(e=Date.now()){var t,n,i;try{const r=localStorage.getItem(dn)||localStorage.getItem(un);if(!r)return null;const o=JSON.parse(r);if(!o||"object"!=typeof o)return V(),null;const a=o.createdAt||o.timestamp,s=a?k(a):NaN;if(!Number.isFinite(s))return V(),null;if(e-s>7776e6)return V(),null;const c=String(o.sessionId||""),l=o.entryUrl||o.originalEntryUrl||o.original_entry_url||"",d=null!==(i=null!==(n=null!==(t=o.entryReferrer)&&void 0!==t?t:o.originalReferrer)&&void 0!==n?n:o.original_referrer)&&void 0!==i?i:null,u="string"==typeof d?d:null;return c&&l?{sessionId:c,entryUrl:String(l),entryReferrer:u,createdAt:"string"==typeof o.createdAt?o.createdAt:new Date(s).toISOString(),version:"string"==typeof o.version?o.version:"v1"}:(V(),null)}catch(e){return(0,jt.AO)("Error loading acquisition context",e),null}}function V(){try{localStorage.removeItem(dn),localStorage.removeItem(un)}catch(e){(0,jt.AO)("Error clearing acquisition context",e)}}function B(){return crypto.randomUUID().replace(/-/g,"")}function K(e){return"string"!=typeof e?null:e.trim()||null}function G(e){const n=K(e);if(n){try{localStorage.setItem(Gn,n)}catch(e){}try{const e=a();t(Gn,n,576e3,{domain:e,path:"/",sameSite:"Lax"})}catch(e){}}}function X(e){if(e){try{const n=a();t(Zt,e,tn,{domain:n,path:"/",sameSite:"Lax"})}catch(e){}try{"undefined"!=typeof localStorage&&localStorage.setItem(Zt,e)}catch(e){}}}async function J(e){var t;const n=await async function(){return await async function(){var e,t,n;if(_n)return _n.raw;try{const i=function(){var e;try{const t=null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands;return Array.isArray(t)?t.map(e=>(null==e?void 0:e.brand)||"").filter(Boolean).sort().join(","):""}catch(e){return""}}(),r=function(){var e;try{return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platform)||""}catch(e){return""}}(),o=function(){var e;try{return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.architecture)||""}catch(e){return""}}(),a=d(screen.width,64),c=d(screen.height,64),l=(n=window.devicePixelRatio,Number.isFinite(n)?Math.max(.5,.5*Math.round(n/.5)):1),y=Array.isArray(navigator.languages)?navigator.languages.slice().sort().join(","):navigator.language||"",w=[`screen:${a}x${c}`,`depth:${screen.colorDepth}`,`dpr:${l}`,`hw:${navigator.hardwareConcurrency||"unknown"}`,`mem:${null!==(e=navigator.deviceMemory)&&void 0!==e?e:"unknown"}`,`touch:${null!==(t=navigator.maxTouchPoints)&&void 0!==t?t:0}`,`touchEvt:${"ontouchstart"in window}`,`platform:${navigator.platform||"unknown"}`,`uaPlatform:${r}`,`arch:${o||"unknown"}`,`engine:${m()}`,`brands:${i}`,`lang:${y}`,`tz:${h()}`,`gamut:${u()}`],b=function(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return"no-webgl";const n=t,i=n.getExtension("WEBGL_debug_renderer_info"),r=i?n.getParameter(i.UNMASKED_VENDOR_WEBGL):null,o=i?n.getParameter(i.UNMASKED_RENDERER_WEBGL):null;return[n.getParameter(n.RENDERER),n.getParameter(n.VENDOR),n.getParameter(n.VERSION),n.getParameter(n.SHADING_LANGUAGE_VERSION),r,o,n.getParameter(n.MAX_TEXTURE_SIZE),n.getParameter(n.MAX_RENDERBUFFER_SIZE),n.getParameter(n.MAX_VERTEX_ATTRIBS)].filter(Boolean).join("|||")}catch(e){return"webgl-error"}}(),S=function(){try{const e=["Arial","Verdana","Tahoma","Trebuchet MS","Times New Roman","Georgia","Courier New","Comic Sans MS","Impact","Calibri","Cambria","Consolas","Helvetica Neue","Helvetica","SF Pro Display","SF Pro Text","Menlo","Monaco","Apple Symbols","Lucida Grande","Palatino","Ubuntu","Liberation Sans","DejaVu Sans","Droid Sans","Roboto","Open Sans","Noto Sans","Source Sans Pro","Microsoft YaHei","SimSun","Hiragino Sans","Meiryo","Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji"],t=document.createElement("canvas"),n=t.getContext("2d");if(!n)return"canvas-unsupported";t.width=50,t.height=20;const i=["monospace","sans-serif","serif"],r="mmmmmmmmmmlli",o={};for(const e of i)n.font=`12px ${e}`,o[e]=n.measureText(r).width;const a=[];for(const t of e){let e=!1;for(const a of i)if(n.font=`12px '${t}', ${a}`,n.measureText(r).width!==o[a]){e=!0;break}e&&a.push(t)}return a.sort().join(",")||"none"}catch(e){return"font-detection-error"}}(),T=function(){try{const e=Math;return[e.acos(.12312423423423424),e.acosh(1e308),e.asin(.12312423423423424),e.asinh(1),e.atanh(.5),e.atan(2),e.sin(.5),e.sinh(1),e.cos(.5),e.cosh(1),e.tan(.5),e.tanh(1),e.exp(1),e.expm1(1),e.log1p(10),e.pow(e.PI,-100)].map(e=>e.toString().slice(0,15)).join(",")}catch(e){return"math-unsupported"}}(),_=function(){try{const e=document.createElement("video"),t=['video/mp4; codecs="avc1.42E01E"','video/mp4; codecs="avc1.4D401E"','video/mp4; codecs="avc1.64001E"','video/webm; codecs="vp8"','video/webm; codecs="vp9"','video/webm; codecs="av1"','audio/mp4; codecs="mp4a.40.2"','audio/webm; codecs="opus"'].filter(t=>""!==e.canPlayType(t));return t.length>0?t.join(","):"no-media"}catch(e){return"media-error"}}(),[I,k]=await Promise.all([s(),f()]),A={canvas:!I.includes("error")&&!I.includes("unsupported"),webgl:"no-webgl"!==b&&"webgl-error"!==b,fonts:"fonts-unsupported"!==S&&"font-detection-error"!==S&&"none"!==S,audio:!k.includes("error")&&"audio-unsupported"!==k&&"audio-antifingerprint"!==k,math:"math-unsupported"!==T},E=[b,S,I,k,T,_],O=p(w),L=p(E),[C,M]=await Promise.all([g(O),g(L)]),Y=v(C.slice(0,40)).slice(0,12),P=v(M.slice(0,40)).slice(0,12),N=function(e){const t=Object.values(e).filter(Boolean).length;return t===Object.keys(e).length?"high":t>=3?"medium":"low"}(A),x=`fp_${Y}${"high"===N?"h":"medium"===N?"m":"l"}${P}`;return _n={raw:x,stable:Y,entropy:P,confidence:N,signals:A},x}catch(e){(0,jt.AO)("Error generating browser fingerprint:",e);const t=function(){const e=[`${screen.width}x${screen.height}`,screen.colorDepth,navigator.hardwareConcurrency||"unknown",Math.round(window.devicePixelRatio),navigator.platform||"unknown"].join("|");let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t>>>=0;return t.toString(36).padStart(24,"0")}(),n=t.slice(0,12),i=t.slice(12),r=`fp_${n}l${i}`;return _n={raw:r,stable:n,entropy:i,confidence:"low",signals:{canvas:!1,webgl:!1,fonts:!1,audio:!1,math:!1}},r}}(),_n}(),i=n.raw;return X(i),e&&G(e),Bn.setFingerprintConfidence(null!==(t=n.confidence)&&void 0!==t?t:null),(0,jt.cY)("Generated new visitor ID:",i,{confidence:n.confidence}),i}function Q(){var e;const n=e=>{if(e){try{t("_cst_clientId",e,576e3,{domain:a(),path:"/",sameSite:"Lax"})}catch(e){}try{localStorage.setItem("_cst_clientId",e)}catch(e){}try{const t="undefined"!=typeof window?window:{};t.CST_CLIENT_ID||(t.CST_CLIENT_ID=e)}catch(e){}}};try{const e="undefined"!=typeof window?window:{};if(e.CST_CLIENT_ID&&"string"==typeof e.CST_CLIENT_ID&&e.CST_CLIENT_ID.trim()){const t=e.CST_CLIENT_ID.trim();return n(t),t}}catch(e){}try{const t="undefined"!=typeof document&&"string"==typeof document.cookie&&((null===(e=document.cookie.match(/(?:^|; )_cst_clientId=([^;]*)/))||void 0===e?void 0:e[1])?decodeURIComponent(document.cookie.match(/(?:^|; )_cst_clientId=([^;]*)/)[1]):void 0)||void 0,i="undefined"!=typeof localStorage&&(localStorage.getItem("_cst_clientId")||localStorage.getItem("cst_client_id")||void 0)||void 0,r=(t||i||"").trim();if(r){const e=y(r);return n(e),e}}catch(e){}let i="UNKNOWN";try{const e=document.getElementsByTagName("script");(0,jt.cY)("Searching for clientId in scripts:",e.length);for(const t of Array.from(e)){if(!t)continue;let e=null;try{if(t.src){const n=new URL(t.src,document.baseURI);e=n.searchParams.get("cid")||n.searchParams.get("clientId")||n.searchParams.get("client_id")}}catch(e){}e||(e=t.getAttribute("data-cid")||t.getAttribute("data-client-id")||null);const n=t.src||"",r=[Xt,"cst.js","cst-local.js"].some(e=>n.includes(e)),o=n.includes("https://ti-cs.s3.amazonaws.com/dev")||n.includes("https://ti-cs.s3.amazonaws.com")||n.includes("https://dev-cdn.klrr.org")||n.includes("https://cdn.klrr.org")||n.includes("klrr.org");if((0,jt.cY)("Checking script for clientId",{src:n,rawClientId:e,matchesKnownScriptName:r,matchesKnownDomain:o}),(r||o)&&e){i=y(e),(0,jt.cY)("Found clientId:",i);break}}}catch(e){(0,jt.AO)("Error during clientId discovery",e)}if("UNKNOWN"===i)try{const e=document.querySelector('meta[name="cst:clientId"], meta[name="cst-client-id"]');e&&e.content&&(i=y(e.content),(0,jt.cY)("Found clientId via meta tag:",i))}catch(e){}return(0,jt.cY)("Final clientId:",i),i&&"UNKNOWN"!==i&&n(i),i}function Z(){let e=n(en)||localStorage.getItem(en)||"";if(e){try{const n=a();t(en,e,tn,{domain:n,path:"/",sameSite:"Lax"}),localStorage.setItem(en,e)}catch(e){(0,jt.AO)("Error re-persisting existing userId:",e)}return e}const i="cst_uid_lock",r=Date.now(),o=`${r}:${Math.random().toString(36).slice(2)}`,s=()=>localStorage.getItem(i)||"",c=e=>{const t=Number(e.split(":")[0]||0);return t&&r-t<5e3};let l=s();if(l&&c(l)){const i=Date.now();for(;Date.now()-i<250&&(e=n(en)||localStorage.getItem(en)||"",!e)&&(l=s(),l&&c(l));){const e=Date.now()+25;for(;Date.now()<e;);}if(e){try{const n=a();t(en,e,tn,{domain:n,path:"/",sameSite:"Lax"})}catch(e){}return e}}try{const e=s();e&&c(e)||localStorage.setItem(i,o)}catch(e){}const d=s()===o;e=`u_${B()}`,(0,jt.cY)("Generated new userId",e);try{const n=a();t(en,e,tn,{domain:n,path:"/",sameSite:"Lax"})}catch(e){(0,jt.AO)("Error persisting userId cookie:",e)}try{localStorage.setItem(en,e)}catch(e){(0,jt.AO)("Error persisting userId to localStorage:",e)}try{d&&localStorage.removeItem(i)}catch(e){}return e}function ee(e){let t;t="target"in e&&"function"==typeof e.target.getIframe?e.target.getIframe():e;let n=t.tagName.toLowerCase();return t.id&&(n+=`#${t.id}`),t.className&&(n+=`.${t.className.split(/\s+/).join(".")}`),n}function te(e){let t;t="target"in e&&"function"==typeof e.target.getIframe?e.target.getIframe():e;const n=(e,t)=>e?n(e.previousElementSibling,t||e.nodeName)+(e.nodeName===t?1:0):1,i=e=>e&&1===e.nodeType?e.id&&document.getElementById(e.id)===e?[`id("${e.id}")`]:[...i(e.parentNode),`${e.nodeName.toLowerCase()}[${n(e.previousElementSibling,e.nodeName)}]`]:[];return i(t).join("/")}function ne(e,t,n=3e5){if(e.forEach((i,r)=>{t-i>n&&e.delete(r)}),e.size>500){const t=[];e.forEach((e,n)=>t.push([n,e])),t.sort((e,t)=>e[1]-t[1]);const n=e.size-500;for(let i=0;i<n;i++)e.delete(t[i][0])}}function ie(e){ne(Zn,e),ne(ei,e),ne(ni,e)}function re(e){const t=I(),n=Zn.get(e);return void 0!==n&&t-n<3e3}function oe(e){const t=I();Zn.set(e,t),ie(t)}function ae(e,t=3e3){const n=I(),i=Zn.get(e);return void 0!==i&&n-i<t}function se(e){const t=I();return t-(ni.get(e)||0)<ti||(ni.set(e,t),ie(t),!1)}function ce(e){const t=Xn.get(e);return!!t&&I()-t.timestamp<Jn.DEDUPLICATION_WINDOW}function le(e){try{return`form:${e.id||e.getAttribute("data-form-id")||ee(e)}`}catch(e){return"form:unknown"}}function de(e){return`form:${e}`}function ue(e,t,n=1e3){e.forEach((i,r)=>{t-i>n&&e.delete(r)})}function me(e){if(!e)return"";try{const t=new URL(e,location.href);return`${t.hostname}${t.pathname}`}catch(t){return String(e||"")}}function he(e){if(!e)return"";const t={};try{Object.keys(e).forEach(n=>{const i=n.toLowerCase();i.startsWith("hs_")||i.startsWith("utm")||"hs_context"===i||oi.has(i)&&(t[i]=e[n])})}catch(e){}return function(e){if(!e)return"";try{const t=Object.keys(e).sort().map(t=>`${t}:${String(e[t])}`);return t.join("|")}catch(t){try{return JSON.stringify(e)}catch(t){return String(e)}}}(t)}function fe(e){const t=me(e||"");return t?`action:${t}`:""}function pe(e){try{return new URL(e,location.href).hostname}catch(e){return""}}function ge(e){if(null==e)return"";if("string"==typeof e)return e.toLowerCase();try{const t=e;if("string"==typeof t.value)return t.value.toLowerCase();if("string"==typeof t.baseVal)return t.baseVal.toLowerCase()}catch(e){}return String(e||"").toLowerCase()}function ve(e){try{let t=!0;try{const n=window.getComputedStyle(e);t=null!==e.offsetParent||"none"!==n.display}catch(e){t=!0}if(!t)return!1;const n=Array.from(e.elements||[]);for(const e of n)if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)if(e instanceof HTMLInputElement){const t=(e.type||"").toLowerCase();if("hidden"===t)continue;if("password"===t)continue;if(("checkbox"===t||"radio"===t)&&e.checked)return!0;if("text"===t||"email"===t||"tel"===t||"url"===t||"search"===t||"number"===t){const t=(e.value||"").trim();if(t&&"0"!==t)return!0}}else if(e instanceof HTMLTextAreaElement){if((e.value||"").trim())return!0}else if(e instanceof HTMLSelectElement){const t=(e.value||"").trim();if(t&&"0"!==t&&"select"!==t.toLowerCase())return!0}}catch(e){}return!1}function ye(e){const t=li.get(e);return t?I()-t.timestamp>5e3?(li.delete(e),null):t.data:null}function we(){const e=I();return di>0&&e-di<2e3}function be(e,t){if(ce(e))return Qn.duplicatesBlocked++,(0,jt.cY)("Duplicate submission blocked",e),"";const n=B(),i={elementId:e.id||ee(e),timestamp:I(),submissionId:n,method:t};return Xn.set(e,i),n}function Se(e){return wn.some(t=>"string"==typeof t?e.toLowerCase().includes(t.toLowerCase()):t.test(e))}function Te(e){var t,n;const i={};let r=0;if(e.elements.length>Jn.MAX_FORM_FIELDS)return(0,jt.AO)("Form has too many fields, skipping",e.id),{};if(null===(t=e.action)||void 0===t?void 0:t.includes("facebook.com/tr/"))return{};if(e.classList.contains("hs-form")||(null===(n=e.id)||void 0===n?void 0:n.includes("hsForm_"))||e.closest("[data-reactroot]"))try{const t=new FormData(e);if(Array.from(t.entries()).forEach(([e,t])=>{"hs_context"!==e&&t&&"string"==typeof t&&(i[e]=t.slice(0,Jn.MAX_FIELD_LENGTH))}),0===Object.keys(i).length){const t=ye(e);if(t)return(0,jt.cY)("Using snapshot data for empty HubSpot form",e.id),t}return i}catch(e){(0,jt.AO)("Error processing HubSpot form data",e)}for(let t=0;t<e.elements.length;t++){const n=e.elements[t];if(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement){if(n instanceof HTMLInputElement&&Jn.DISALLOWED_FIELD_TYPES.includes(n.type))continue;if(n.name&&"submit"!==n.type){if(r++,r>Jn.MAX_FORM_FIELDS){(0,jt.AO)("Too many form fields, truncating",e.id);break}const t=n.value.slice(0,Jn.MAX_FIELD_LENGTH);i[n.name]=Se(n.name)?"[REDACTED]":t}}}if(0===Object.keys(i).length||!Object.values(i).some(e=>e.length>0)){const t=ye(e);if(t&&Object.keys(t).length>0)return(0,jt.cY)("Using snapshot data for empty form",{formId:e.id,snapshotFields:Object.keys(t).length}),t}return i}async function _e(e,t,n={}){var i,r;try{if(e.element&&null==e.element.captureSource){let n;n="submit"===t?"native":"xhr"===t?"network:xhr":"provider"===t?"provider":"click"===t?"button-only":t,e.element.captureSource=n}const n=function(e){var t,n;return[e.eventType||"",me((null===(t=e.element)||void 0===t?void 0:t.action)||""),he(null===(n=e.element)||void 0===n?void 0:n.formData)].join("#")}(e);if(function(e,t=1e3){if(function(){var e;try{return"undefined"!=typeof process&&"test"===(null===(e=process.env)||void 0===e?void 0:"production")}catch(e){return!1}}())return!1;const n=I();return ue(ii,n,t),n-(ii.get(e)||0)<t||(ii.set(e,n),!1)}(n))return Qn.duplicatesBlocked++,void(0,jt.cY)("Duplicate form event fingerprint blocked",{label:e.label,action:null===(i=e.element)||void 0===i?void 0:i.action,method:t});const o=(null===(r=e.element)||void 0===r?void 0:r.action)||"";if(o)try{!function(e,t=1e3){const n=fe(e);if(!n)return!1;const i=I();ue(ri,i,t),i-(ri.get(n)||0)<t||ri.set(n,i)}(o)}catch(e){}}catch(e){return void(0,jt.AO)("Error preparing form event",e)}let o,a=null;const s=`form_submit_${e.eventId}`;try{o=await En(e),localStorage.setItem(s,JSON.stringify(o)),a=P(o,{triggerSend:!1})}catch(e){return(0,jt.AO)("Error building form batch",e),Qn.formsMissed++,void Qn.errors.push(`Batch error: ${e}`)}try{const i="submit"===t||"click"===t;let r=!1;try{r=await H(o,i)}catch(e){(0,jt.AO)("Error sending form data",e),Qn.errors.push(`Send error: ${e}`),r=!1}if(r)return a&&N(a),localStorage.removeItem(s),(Array.isArray(n.throttleKeys)?n.throttleKeys:n.throttleKeys?[n.throttleKeys]:[]).forEach(e=>oe(e)),Qn.formsSubmitted++,"submit"===t||"xhr"===t?Qn.universalSuccess++:"provider"===t&&Qn.providerSuccess++,void(0,jt.cY)("Form data sent successfully",e.eventId);(0,jt.cY)("Form send failed, scheduling queued retry",e.eventId),a?x():P(o,{triggerSend:!0}),Qn.formsMissed++,!Qn.errors.some(e=>e.includes("Send error"))&&Qn.errors.length<50&&Qn.errors.push("Send error: queued for retry")}catch(e){(0,jt.AO)("Critical error in form submission recovery",e),Qn.formsMissed++,Qn.errors.length<50&&Qn.errors.push(`Recovery error: ${e}`)}}async function Ie(e,t={}){const n={eventId:B(),eventType:"formSubmit",time:(new Date).toISOString(),label:e.formId||`${e.provider}-form-signal`,value:e.action||e.provider,element:{tag:"form",id:e.formId||null,class:null,action:e.action||null,method:"post",formData:{},customSelector:e.formId?`#${e.formId}`:"",xpath:"",captureSource:"iframe-signal",signalMetadata:Object.assign({provider:e.provider,signalType:e.signalType,confidence:e.confidence,dataAvailable:!1},e.metadata||{})}};(0,jt.cY)("📡 Sending form signal (no field data)",{provider:e.provider,formId:e.formId,signalType:e.signalType,confidence:e.confidence}),await _e(n,"provider",t),Qn.providerTriggers[`signal:${e.provider}`]=(Qn.providerTriggers[`signal:${e.provider}`]||0)+1}async function ke(e,t,n={}){try{if(n.throttleKeys&&(Array.isArray(n.throttleKeys)?n.throttleKeys:[n.throttleKeys]).forEach(e=>oe(e)),(e.className||"").toLowerCase().includes("fusion-form")&&!ve(e))return void(0,jt.cY)("Skipping Fusion form without user input",e.className);const i=await async function(e,t){try{const n=be(e,t);if(!n)return null;const i=Te(e);return{eventId:n,eventType:"formSubmit",time:(new Date).toISOString(),label:e.id||e.className||"unnamed-form",value:w(e.action)||e.action||"",element:{tag:"form",id:e.id,class:e.className,action:w(e.action)||e.action,method:e.method,formData:i,customSelector:ee(e),xpath:te(e)}}}catch(e){return(0,jt.AO)("Error creating form event",e),Qn.errors.push(`Error creating form event: ${e}`),null}}(e,t);i&&await _e(i,t,n)}catch(e){(0,jt.AO)("Error handling form submission",e),Qn.formsMissed++}}function Ae(e){const t=e.target;if(!t||"FORM"!==t.tagName)return;const n=ve(t),i=function(e){const t=li.get(e);return!!t&&(I()-t.timestamp>5e3?(li.delete(e),!1):t.hadUserInput)}(t);if(!n&&!i)return void(0,jt.cY)("Skipping form submit without likely user input (checked current and snapshot)",t.id||t.className);const r=le(t);if(re(r))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled native form submit",r);try{if(t.classList.contains("hs-form")||t.id&&t.id.startsWith("hsForm_")||t.querySelector("input[name='hs_context']")){const e=I();ei.set(r,e)}}catch(e){}(0,jt.cY)("Universal form submit detected",t.id||t.className),ke(t,"submit",{throttleKeys:r})}function Ee(e){var t,n;const i=e.target.closest("button, input[type=submit], input[type=button]");if(!i)return;const r=i.matches("[type=submit]")||(null===(t=i.textContent)||void 0===t?void 0:t.toLowerCase().includes("submit"))||(null===(n=i.textContent)||void 0===n?void 0:n.toLowerCase().includes("send"))||i.classList.contains("submit")||"submit"===i.getAttribute("data-action");r&&Qn.buttonSubmissions++;const o=i.closest("form");if(o&&r){const e=ve(o),t=function(e){const t=ve(e),n=Te(e),i=Object.keys(n).length>0&&Object.values(n).some(e=>e.length>0);return!(!t&&!i||(li.set(e,{data:n,timestamp:I(),hadUserInput:t}),(0,jt.cY)("📸 Form data snapshot captured",{formId:e.id,fieldCount:Object.keys(n).length,hadUserInput:t}),0))}(o);if(!e&&!t)return;const n=le(o);return void setTimeout(()=>{try{ce(o)||ae(n)||((0,jt.cY)("Fallback form submission via button click (no native submit detected)",o.id||o.className),ke(o,"submit",{throttleKeys:n}))}catch(e){(0,jt.AO)("Fallback form submission error",e)}},400)}we()||r&&((0,jt.cY)("Button-only form submission detected",i),async function(e){var t,n;try{const i=`button:${e.id||(null===(t=e.textContent)||void 0===t?void 0:t.trim())||ee(e)}`;if(re(i))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled button-only submission",i);oe(i);const r=be(e,"click");if(!r)return;let o=e.closest("[data-form], .ghl-form-wrap, .form-builder--wrap, #_builder-form, .hl_form-builder--main, .c-form, .form, .contact-form, .newsletter")||document.getElementById("_builder-form")||e.closest(".ghl-form-wrap, .form-builder--wrap");if(!o){let t=e.parentElement,n=0;const i=5;for(;t&&n<i&&t!==document.body;){if(t.querySelectorAll("input:not([type=hidden]):not([type=submit]), textarea, select").length>=1){o=t;break}t=t.parentElement,n++}}o||(o=e.parentElement);const a=(null==o?void 0:o.querySelectorAll("input, textarea, select"))||[],s={};a.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name&&!Se(e.name)&&(s[e.name]=e.value.slice(0,Jn.MAX_FIELD_LENGTH).trim())});const c={eventId:r,eventType:"formSubmit",time:(new Date).toISOString(),label:(null===(n=e.textContent)||void 0===n?void 0:n.slice(0,Jn.MAX_FIELD_LENGTH).trim())||e.id||"unnamed-button",value:e.getAttribute("data-action")||"",element:{tag:e.tagName.toLowerCase(),id:e.id,class:e.className,formData:s,customSelector:ee(e),xpath:te(e)}};await _e(c,"provider",{throttleKeys:i})}catch(e){(0,jt.AO)("Error capturing button submission",e),Qn.errors.push(`Button capture error: ${e}`)}}(i))}function Oe(e){if(we())return void(0,jt.cY)("Startup debounce active; skipping XHR form scan");const t=I();if(t-ui<1e3){if(!mi){const n=1e3-(t-ui)+50;(0,jt.cY)(`XHR scan rate limited, queuing scan in ${n}ms`),mi=setTimeout(()=>{mi=null,Oe(e)},n)}return}ui=t;const n=document.querySelectorAll("form");let i=!1;n.forEach(t=>{if(t instanceof HTMLFormElement&&!ce(t)){const n=Te(t),r=Object.keys(n).length>0&&Object.values(n).some(e=>e.length>0),o=ve(t),a=null!==t.offsetParent||"none"!==window.getComputedStyle(t).display;if(r&&o&&a){(0,jt.cY)("Potential XHR form submission detected",t.id||t.className);const n=le(t);ae(n)||function(e,t=1e3){const n=fe(e);return!!n&&I()-(ri.get(n)||0)<t}(t.action)?(0,jt.cY)("Skipping XHR capture due to recent native/provider send",n):ke(t,e,{throttleKeys:n}),i=!0}}}),i||(0,jt.cY)("XHR detected but no valid form submissions found")}function Le(e,t=0){if(!e||t>3)return[];const n=[];if(Array.isArray(e)){for(const i of e)n.push(...Le(i,t+1));return n}if("object"==typeof e)for(const[i,r]of Object.entries(e)){const e=i.toLowerCase();"string"==typeof r&&["event","eventname","event_type","type","status","action","name"].includes(e)&&n.push(r.toLowerCase()),n.push(...Le(r,t+1))}return n}function Ce(e,t=0){if(!e||t>3)return!1;if(Array.isArray(e))return e.some(e=>Ce(e,t+1));if("object"==typeof e)for(const[n,i]of Object.entries(e)){const e=n.toLowerCase();if(pi.includes(e))return!0;if(Ce(i,t+1))return!0}return!1}function Me(e,t,n){var i;if("leadconnector"!==e)return!0;const r=function(e){if(!(null==e?void 0:e.text))return null;try{return JSON.parse(e.text)}catch(e){return null}}(n),o=Le(r);if(o.some(e=>fi.has(e)))return!1;if(o.some(e=>hi.has(e)))return!0;if(Ce(r))return!0;const a=(null===(i=null==n?void 0:n.text)||void 0===i?void 0:i.toLowerCase())||"";return!!a&&!/"event"\s*:\s*"calendar\.view"/i.test(a)&&(!!/email=|phone=|first_name=|last_name=|contact=/i.test(a)||/booking\.scheduled|appointment\.scheduled|meeting\.scheduled|\bbooked\b|\bconfirmed\b/i.test(a))}function Ye(){function e(e){try{return new URL(e).hostname}catch(e){return""}}const t="cst_calendar_listener";if(window[t])return;window[t]=!0;const n=["calendly.com","www.calendly.com","cal.com","app.cal.com","tidycal.com","app.tidycal.com","acuityscheduling.com","app.acuityscheduling.com","oncehub.com","scheduleonce.com","savvycal.com","meetings.hubspot.com","leadconnectorhq.com","backend.leadconnectorhq.com","meetings.leadconnectorhq.com","app.leadconnectorhq.com","gohighlevel.com","msgsndr.com"];window.addEventListener("message",t=>{try{const i=e(t.origin);if(!i)return;if(!n.some(e=>i.endsWith(e)))return;const r=function(e){const t=e.toLowerCase();return t.includes("calendly")?"calendly":t.endsWith("cal.com")?"cal.com":t.includes("tidycal")?"tidycal":t.includes("acuity")?"acuity":t.includes("oncehub")||t.includes("scheduleonce")?"oncehub":t.includes("savvycal")?"savvycal":t.includes("hubspot")?"hubspot-meetings":t.includes("leadconnectorhq")||t.includes("leadconnector")||t.includes("gohighlevel")||t.includes("msgsndr")?"leadconnector":null}(i);if(!r)return;const o=t.data;let a="";"string"==typeof o?a=o.toLowerCase():o&&"object"==typeof o&&(a=String(o.type||o.event||"").toLowerCase());let s=a.includes("scheduled")||a.includes("booking")||a.includes("meeting")||a.includes("booked")||a.includes("event_scheduled");if(!s&&o&&"object"==typeof o)try{const e=JSON.stringify(o).toLowerCase(),t=["event_scheduled","appointment","scheduled","booking","booked","meeting"].find(t=>e.includes(t));t&&(s=!0,a||(a=`payload:${t}`))}catch(e){}if(!s)return;const c=`calendar:${r}:${a}`;if(!(()=>{var e;try{return"undefined"!=typeof process&&"test"===(null===(e=process.env)||void 0===e?void 0:"production")}catch(e){return!1}})()&&re(c))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled calendar event",{provider:r,signal:a});if(se(c))return;const l=B();let d=null;try{const n=Array.from(document.querySelectorAll("iframe")),i=e(t.origin);d=n.find(e=>{try{const t=new URL(e.src).hostname;return t===i||t.endsWith(i)}catch(e){return!1}})||null}catch(e){}const u={eventId:l,eventType:"formSubmit",time:(new Date).toISOString(),label:`calendar-${r}`,value:`message:${a}`,element:{tag:"iframe",id:(null==d?void 0:d.id)||"",class:(null==d?void 0:d.className)||"",action:(null==d?void 0:d.src)||t.origin,method:"postMessage",formData:{},customSelector:d?ee(d):r,xpath:d?te(d):"",captureSource:`calendar:${r}`}};(0,jt.cY)("Calendar/iframe scheduled event detected",{provider:r,origin:t.origin,signal:a}),_e(u,"provider",{throttleKeys:c}).catch(e=>(0,jt.AO)("Error sending calendar event",e))}catch(e){(0,jt.AO)("Calendar listener error",e)}})}function Pe(e){const t=[],n=e||window.location.href;return Object.entries(vi).forEach(([e,i])=>{!i.active&&i.trigger(n)&&(t.push(e),i.active=!0,(0,jt.cY)(`Form provider activated: ${i.name}`))}),t}function Ne(){return Object.values(vi).filter(e=>e.active)}function xe(e){if(null==e)return null;if("string"==typeof e){const t=e.trim();if(!t)return null;const n=t.toLowerCase();if(n.includes("hsformcallback")||n.includes("hubspot"))return{type:"hsFormCallback"};try{return JSON.parse(t)}catch(e){return null}}return"object"==typeof e?e:null}function Re(e){return["password","credit_card","cc_number","cvv","ssn","social_security"].some(t=>e.toLowerCase().includes(t))}function De(){if(yi.completed||yi.inProgress)return;const e=I();if(yi.lastAttemptAt&&e-yi.lastAttemptAt<3e4)return;if("undefined"==typeof window||"undefined"==typeof document||!((null===(n=null===(t=window.hbspt)||void 0===t?void 0:t.forms)||void 0===n?void 0:n.create)||document.querySelector(".hs-form, form[data-hs-cf-bound], .hbspt-form, script[src*='hsforms'], script[src*='hubspot'], iframe[src*='hsforms']")||Ne().some(e=>"HubSpot"===e.name)))return;var t,n;yi.inProgress=!0,yi.lastAttemptAt=e;let i=0;const r=()=>{var e,t,n,o;if(i++,1!==i&&i%5!=0||(0,jt.cY)(`🔧 HubSpot patch attempt ${i}:`,{hasWindow:"undefined"!=typeof window,hasHbspt:!!window.hbspt,hasForms:!!(null===(e=window.hbspt)||void 0===e?void 0:e.forms),hasCreate:"function"==typeof(null===(n=null===(t=window.hbspt)||void 0===t?void 0:t.forms)||void 0===n?void 0:n.create),hbsptKeys:window.hbspt?Object.keys(window.hbspt):[]}),"undefined"!=typeof window&&(null===(o=window.hbspt)||void 0===o?void 0:o.forms)&&"function"==typeof window.hbspt.forms.create){const e=window.hbspt.forms.create;return window.hbspt.forms.create=t=>{(0,jt.cY)("🎯 HubSpot form created, patching callbacks:",t.formId);const n=t.onFormSubmit;return t.onFormSubmit=e=>{try{const n={};e.serializeArray().forEach(({name:e,value:t})=>{"hs_context"!==e&&(n[e]=t)}),(0,jt.cY)("✅ HubSpot form submit intercepted:",{formId:t.formId,formData:n}),window.postMessage({type:"hsFormCallback",fields:n,id:t.formId,action:"hubspot"},"*")}catch(e){(0,jt.AO)("Error in HubSpot form callback patch",e)}return n&&n(e)},e(t)},yi.completed=!0,yi.inProgress=!1,void(0,jt.cY)("✅ HubSpot forms.create successfully patched!")}i<50?setTimeout(r,100):(yi.inProgress=!1,(0,jt.cY)("⚠️ HubSpot patching failed after maximum attempts"))};r()}function $e(e,t,n,i){var r,o,a;try{if(!e)return void(0,jt.cY)(`${i}: target missing, skipping wrap`);const s=Object.getOwnPropertyDescriptor(e,t),c=null!==(r=null==s?void 0:s.value)&&void 0!==r?r:e[t];if("function"!=typeof c)return void(0,jt.cY)(`${i}: original is not a function, skipping wrap`);if(c[bi])return void(0,jt.cY)(`${i}: already wrapped, skipping wrap`);if(/\[native code\]/.test(c.toString())||(0,jt.cY)(`${i}: existing non-native implementation detected, chaining wrap`,{originalName:c.name}),s&&!1===s.configurable)return void(0,jt.cY)(`${i}: descriptor not configurable, skipping wrap`);const l=n(c);l[bi]=!0,l[Si]=c;try{const e=c.toString.bind(c);Object.defineProperty(l,"toString",{value:function(){return e()},configurable:!0,writable:!0})}catch(e){}s?Object.defineProperty(e,t,{configurable:!0,enumerable:null!==(o=s.enumerable)&&void 0!==o&&o,writable:null===(a=s.writable)||void 0===a||a,value:l}):e[t]=l,(0,jt.cY)(`${i}: successfully wrapped ${t}`)}catch(e){(0,jt.AO)(`${i}: error wrapping ${t}`,e)}}function He(e){if(!e)return null;if("string"==typeof e)return e;if("undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams)return e.toString();if("undefined"!=typeof FormData&&e instanceof FormData){const t=[];return e.forEach((e,n)=>{"string"==typeof e&&t.push(`${n}=${encodeURIComponent(e)}`)}),t.length?t.join("&"):null}if("object"==typeof e)try{return JSON.stringify(e)}catch(e){return null}return null}function We(e,t){if(!e)return null;const n=function(e,t){if(!e)return null;try{if((null==t?void 0:t.includes("application/json"))||e.trim().startsWith("{"))return JSON.parse(e);if((null==t?void 0:t.includes("application/x-www-form-urlencoded"))||e.includes("=")){const t=new URLSearchParams(e),n={};if(t.forEach((e,t)=>{"hs_context"!==t&&(n[t]=e)}),Object.keys(n).length>0)return n}return null}catch(e){return null}}(e,t);return{text:e,parsed:n||void 0,contentType:t}}function je(){var e;e={onProviderTrigger:e=>{Pe(e)},onCalendarMatch:(e,t,n)=>{const i=function(e){for(const t of gi)if(t.re.test(e))return{provider:t.provider,signal:t.signal};return null}(e);i&&setTimeout(()=>{!async function(e,t,n,i){try{if(!Me(e,0,i))return void(0,jt.cY)("Skipping calendar network event due to non-booking payload",{provider:e,signal:n});const r=`calendar:${e}:network:${n}`;if(re(r)||se(r))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled calendar network event",{provider:e,signal:n});const o={eventId:B(),eventType:"formSubmit",time:(new Date).toISOString(),label:`calendar-${e}`,value:`network:${n}`,element:{tag:"network",id:"",class:"calendar-network",action:t,method:"POST",formData:{},customSelector:e,xpath:"",captureSource:`calendar:${e}`}};(0,jt.cY)("Calendar booking detected via network",{provider:e,url:t,signal:n}),await _e(o,"provider",{throttleKeys:r})}catch(e){(0,jt.AO)("Error emitting calendar network event",e)}}(i.provider,e,i.signal,n)},50)},onFormSubmissionMatch:(e,t,n)=>{"POST"===t.toUpperCase()&&(function(e,t){const n=Ii.find(t=>t.test(e));n&&((0,jt.cY)("🔍 POTENTIAL HUBSPOT SUBMISSION DETECTED (lenient):",{url:e,matchedPattern:n.toString(),method:"POST",timestamp:(new Date).toISOString(),hasBody:!!(null==t?void 0:t.text),hasParsedData:!!(null==t?void 0:t.parsed)}),(e.includes("hsforms.com")||e.includes("hubspot.com/submissions"))&&function(e,t){const n=Fe(e)||"hubspot-network",i=`form:${n}`;ae(i)?(0,jt.cY)("Skipping network HubSpot signal - recent postMessage capture exists"):setTimeout(()=>{ae(i)?(0,jt.cY)("Skipping network HubSpot signal - postMessage captured during delay"):Ie({provider:"hubspot",formId:n,action:e,signalType:"networkIntercept",confidence:(null==t?void 0:t.parsed)?.7:.5,metadata:{source:"network-fallback",hasBody:String(!!(null==t?void 0:t.text)),hasParsedData:String(!!(null==t?void 0:t.parsed))}},{throttleKeys:i})},500)}(e,t))}(e,n),function(e){if(Ti.some(t=>t.test(e)))return(0,jt.cY)("Excluded analytics endpoint from form detection:",e),!1;const t=_i.find(t=>t.test(e));return!!t&&((0,jt.cY)("Form submission endpoint detected:",{url:e,matchedPattern:t.toString()}),!0)}(e)&&((0,jt.cY)("Likely form submission detected via network",e),(null==n?void 0:n.parsed)&&Object.keys(n.parsed).length>0?function(e,t){const n=Fe(e)||"network-form",i=le({id:n});if(re(i)||ae(i))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled network form capture",{url:e,formId:n});const r=function(e){const t=document.querySelectorAll("form");for(const n of Array.from(t)){const t=n;if(t.action&&e.includes(t.action))return t}const n=pe(e);if(n)for(const e of Array.from(t)){const t=e;if(t.action&&pe(t.action)===n)return t}return null}(e);r?ke(r,"xhr",{throttleKeys:i}):((0,jt.cY)("📡 Network form capture (no DOM form found):",{url:e,formId:n,parsedFields:t.parsed?Object.keys(t.parsed):[]}),Ie({provider:Ue(e)||"unknown",formId:n,action:e,signalType:"networkIntercept",confidence:t.parsed?.7:.5,metadata:{capturedFields:t.parsed?String(Object.keys(t.parsed).length):"0",contentType:t.contentType||"unknown"}},{throttleKeys:i}))}(e,n):setTimeout(()=>Oe("xhr"),100)))}},"undefined"!=typeof XMLHttpRequest&&($e(XMLHttpRequest.prototype,"send",e=>function(t){try{this.__cstRequestBodyText=He(t)}catch(e){(0,jt.cY)("Unable to capture XHR request body",e)}return e.call(this,t)},"XMLHttpRequest.send"),$e(XMLHttpRequest.prototype,"setRequestHeader",e=>function(t,n){try{"content-type"===t.toLowerCase()&&(this.__cstContentType=n)}catch(e){}return e.call(this,t,n)},"XMLHttpRequest.setRequestHeader"),$e(XMLHttpRequest.prototype,"open",t=>function(n,i,r=!0,o,a){const s="string"==typeof i?i:i.toString();try{e.onProviderTrigger(s)}catch(e){(0,jt.AO)("Error in onProviderTrigger callback",e)}if("POST"===n.toUpperCase()){const t=this;this.addEventListener("load",()=>{try{const i=We(t.__cstRequestBodyText,t.__cstContentType);e.onCalendarMatch(s,n,i),e.onFormSubmissionMatch(s,n,i)}catch(e){(0,jt.AO)("Error in XHR load callbacks",e)}})}return t.call(this,n,i,r,o,a)},"XMLHttpRequest.open")),"undefined"!=typeof window&&"function"==typeof window.fetch&&$e(window,"fetch",t=>async function(n,i){const{url:r,method:o,bodyInfo:a}=function(e,t){var n,i,r;let o,a="",s="GET",c=null!==(n=null==t?void 0:t.body)&&void 0!==n?n:null;if("string"==typeof e)a=e;else if(e instanceof URL)a=e.toString();else if("undefined"!=typeof Request&&e instanceof Request){if(a=e.url,s=e.method||s,null==c&&"function"==typeof e.clone)try{c="function"==typeof e.clone().text?void 0:null}catch(e){}try{o=(null===(r=null===(i=e.headers)||void 0===i?void 0:i.get)||void 0===r?void 0:r.call(i,"content-type"))||void 0}catch(e){}}else a=String(e);if((null==t?void 0:t.method)&&(s=t.method),!o&&(null==t?void 0:t.headers))try{if(t.headers instanceof Headers)o=t.headers.get("content-type")||void 0;else if(Array.isArray(t.headers)){const e=t.headers.find(([e])=>"content-type"===e.toLowerCase());o=null==e?void 0:e[1]}else"object"==typeof t.headers&&(o=t.headers["content-type"]||t.headers["Content-Type"])}catch(e){}const l=He(c);return{url:a,method:(s||"GET").toUpperCase(),bodyInfo:We(l,o)}}(n,i);if(r)try{e.onProviderTrigger(r)}catch(e){(0,jt.AO)("Error in onProviderTrigger callback (fetch)",e)}const s=await t.call(this,n,i);if("POST"===o&&r)try{e.onCalendarMatch(r,o,a),e.onFormSubmissionMatch(r,o,a)}catch(e){(0,jt.AO)("Error in fetch callbacks",e)}return s},"window.fetch")}function Fe(e){try{const t=new URL(e,location.href),n=e.match(/\/([a-f0-9-]{36})\//)||t.searchParams.get("formGuid")||t.searchParams.get("formId");return n?"string"==typeof n?n:n[1]:t.searchParams.get("form_id")||t.searchParams.get("formId")||t.searchParams.get("id")||null}catch(e){return null}}function Ue(e){const t=[[/hubspot|hsforms/i,"hubspot"],[/pardot/i,"pardot"],[/eloqua/i,"eloqua"],[/marketo/i,"marketo"],[/mailchimp/i,"mailchimp"],[/typeform/i,"typeform"],[/gravityforms|gf_/i,"gravity"],[/wpforms/i,"wpforms"],[/ninja/i,"ninjaforms"],[/formidable/i,"formidable"]];for(const[n,i]of t)if(n.test(e))return i;return null}function ze(){Ne().forEach(e=>{var t;Qn.providerTriggers[e.name]=(Qn.providerTriggers[e.name]||0)+1,null===(t=e.events)||void 0===t||t.forEach(t=>{const n=`${e.name}:${t}`;if(ki.has(n))return;if("HubSpot"===e.name&&"message"===t)return(0,jt.cY)("Skipping HubSpot message handler - using dedicated listener"),void ki.add(n);const i=n=>{(0,jt.cY)(`Provider event detected: ${t} for ${e.name}`),setTimeout(()=>function(e){e.selectors.forEach(t=>{document.querySelectorAll(t).forEach(n=>{var i;if(n instanceof HTMLFormElement){if("HubSpot"===e.name&&!n.classList.contains("hs-form")&&!(null===(i=n.id)||void 0===i?void 0:i.startsWith("hsForm_"))&&null===n.querySelector("input[name='hs_context']"))return void(0,jt.cY)("Skipping non-HubSpot form with hs-cf-bound",{id:n.id,className:n.className});if(!ve(n))return void(0,jt.cY)("Skipping provider capture without user input",{provider:e.name,selector:t,id:n.id});const r=`provider:${e.name}:${n.id||ee(n)}`;if(re(r))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled provider form submit",r);const o=le(n);if(ae(o))return Qn.duplicatesBlocked++,void(0,jt.cY)("Suppressed provider capture due to recent send",{provider:e.name,idPart:o});(0,jt.cY)(`Provider form found: ${e.name}`,n.id),ke(n,"provider",{throttleKeys:[r,o]})}})})}(e),50)};window.addEventListener(t,i),document.addEventListener(t,i,!0),ki.add(n)})})}function qe(){var e,t;if(Ei)return;Ei=!0,(0,jt.cY)("Initializing enhanced form tracking");const n="__cstEnhancedFormTrackingInit";if(("undefined"==typeof process||"test"!==(null===(e=process.env)||void 0===e?void 0:"production"))&&window[n])return void(0,jt.cY)("Enhanced form tracking already initialized, skipping");window[n]=!0,t=I(),di=t,function(){try{const e=JSON.parse(localStorage.getItem("cst_learned_patterns")||"[]");e.forEach(e=>{ai.add(e),si.set(e,.8)}),(0,jt.cY)(`Loaded ${e.length} learned patterns from storage`)}catch(e){(0,jt.AO)("Error loading learned patterns",e)}}();const i=function(){const e=new Set,t=document.querySelectorAll("form");Array.from(t).forEach(t=>{if(t.action)try{const n=new URL(t.action,location.href).hostname;n&&n!==location.hostname&&(e.add(n),ci.add(n))}catch(e){}const n=t,i=ge(n.className),r=ge(n.id||n.getAttribute("id"));(i.includes("hubspot")||i.includes("hs-form")||r.includes("hsform"))&&(ci.add("hsforms.com"),e.add("hubspot")),(i.includes("gravity")||i.includes("gform"))&&e.add("gravity-forms"),(i.includes("contact")||i.includes("mailchimp"))&&e.add("contact-form"),i.includes("typeform")&&(ci.add("typeform.com"),e.add("typeform"))});const n=document.querySelectorAll("iframe");return Array.from(n).forEach(t=>{const n=t.src;if(n)try{const t=new URL(n).hostname;(t.includes("hubspot")||t.includes("hsforms"))&&(ci.add(t),e.add("hubspot-iframe")),t.includes("typeform")&&(ci.add(t),e.add("typeform-iframe"))}catch(e){}}),(0,jt.cY)("Discovered providers:",Array.from(e)),e}();(0,jt.cY)("Discovered form providers:",Array.from(i));try{Pe()}catch(e){(0,jt.AO)("Error activating form providers via triggers",e)}ze(),document.addEventListener("gform_confirmation_loaded",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t[0];(0,jt.cY)("Gravity Forms confirmation loaded:",n);const i=document.querySelector(`#gform_${n}`);i&&!ce(i)&&((0,jt.cY)("Gravity Forms submission detected via confirmation:",n),ke(i,"provider"))}),document.addEventListener("gform_post_render",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.formId;(0,jt.cY)("Gravity Forms post render:",n)}),"undefined"!=typeof HTMLFormElement&&$e(HTMLFormElement.prototype,"submit",e=>function(...t){var n;return(null===(n=null==this?void 0:this.id)||void 0===n?void 0:n.startsWith("gform_"))&&!ce(this)&&((0,jt.cY)("Gravity Forms iframe submission detected:",this.id),ke(this,"provider")),e.apply(this,t)},"HTMLFormElement.submit"),document.addEventListener("click",e=>{var t;const n=e.target;if((null===(t=null==n?void 0:n.id)||void 0===t?void 0:t.startsWith("gform_submit_button_"))&&!ce(n)){const e=n.id.replace("gform_submit_button_",""),t=document.querySelector(`#gform_${e}`);t&&((0,jt.cY)("Gravity Forms button submission detected:",e),ke(t,"provider"))}}),function(){const e="__cstHubSpotListener";window[e]||(window[e]=!0,window.addEventListener("message",e=>{var t,n;try{if(!function(e){if(/hubspot|hsforms/i.test(e.origin||""))return!0;const t=xe(e.data);if(!t)return!1;const n="string"==typeof t.origin?t.origin:"";if(n&&/hubspot|hsforms/i.test(n))return!0;const i="string"==typeof t.type?t.type.toLowerCase():"";if("hsformcallback"===i)return!0;if(i.startsWith("hs.form.")||i.startsWith("hsform"))return!0;const r="string"==typeof t.eventName?t.eventName.toLowerCase():"";if(r.includes("hubspot")||r.includes("hsform"))return!0;if(wi.submitted.some(e=>r.includes(e))&&(t.formGuid||t.portalId||t.formId))return!0;const o="string"==typeof t.id?t.id.toLowerCase():"";return!!(o.startsWith("hsform")||o.includes("hubspot")||t.formGuid||t.portalId)}(e))return;const i=xe(e.data);if(!i)return;(0,jt.cY)("🔔 HubSpot PostMessage received:",{origin:e.origin,data:e.data,type:typeof e.data,hasType:null==i?void 0:i.type,isHubSpot:(null===(t=e.origin)||void 0===t?void 0:t.includes("hubspot"))||(null===(n=e.origin)||void 0===n?void 0:n.includes("hsforms"))});const r=function(e){if(!e)return null;const t="string"==typeof e.type?e.type.toLowerCase():"",n="string"==typeof e.eventName?e.eventName.toLowerCase():"",i=wi.submitted.some(e=>n.includes(e)),r=!!(e.fields||e.data||e.submissionData);if(!(i||"hsformcallback"===t&&i||"hsformcallback"===t&&r||"hs.form.submitted"===t||t.includes("submitted")||"onformsubmitted"===n||r&&(e.portalId||e.formGuid)))return null;const o=e.id||e.formId||e.formGuid||e.guid||("object"==typeof e.form?e.form.id:null)||"hubspot-form",a=e.fields||e.data||e.submissionData;let s=.5;return r&&a&&Object.keys(a).length>0&&(s+=.3),(e.formGuid||e.portalId)&&(s+=.1),"onformsubmitted"===n&&(s+=.1),{isSubmission:!0,formId:String(o),hasFields:r,fields:a,confidence:Math.min(s,1)}}(i);if(!r||!r.isSubmission)return;const o=r.formId||"hubspot-form",a=de(o),s=I();if(re(a)||ae(a))return Qn.duplicatesBlocked++,void(0,jt.cY)("Throttled HubSpot callback",{formId:o});if(s-(ei.get(a)||0)<Jn.DEDUPLICATION_WINDOW)return Qn.duplicatesBlocked++,void(0,jt.cY)("Duplicate HubSpot submission blocked (unified)",{formId:o});ei.set(a,s);let c=i.action||i.url||"hubspot";try{const e=document.querySelector(`form#${CSS.escape(o)}, form[id*='${o}'], form.hs-form`);e&&e.action&&(c=e.action)}catch(e){}r.hasFields&&r.fields?((0,jt.cY)("✅ HubSpot form callback processed with field data:",{formId:o,hasFields:!0,confidence:r.confidence}),async function(e,t,n){try{const i=B(),r={};return Array.isArray(n)?n.forEach(({name:e,value:t})=>{const n="string"==typeof t?t:String(null!=t?t:"");e&&(r[e]=Re(e)?"[REDACTED]":n.slice(0,Jn.MAX_FIELD_LENGTH))}):Object.entries(n).forEach(([e,t])=>{t&&"string"==typeof t&&(r[e]=Re(e)?"[REDACTED]":t.slice(0,Jn.MAX_FIELD_LENGTH))}),{eventId:i,eventType:"formSubmit",time:(new Date).toISOString(),label:e||"hubspot-form",value:t,element:{tag:"form",id:e,class:"hs-form",action:t,method:"post",formData:r,customSelector:`#hsForm_${e}`,xpath:"",captureSource:"provider:hubspot"}}}catch(e){return(0,jt.AO)("Error creating HubSpot form event",e),Qn.errors.push(`Error creating HubSpot form event: ${e}`),null}}(o,c,r.fields).then(e=>{e&&_e(e,"provider",{throttleKeys:a})}).catch(e=>{(0,jt.AO)("Error processing HubSpot form callback",e)})):((0,jt.cY)("📡 HubSpot form submission detected (signal-only, no field data):",{formId:o,confidence:r.confidence,origin:e.origin}),Ie({provider:"hubspot",formId:o,action:c,signalType:"postMessage",confidence:r.confidence,metadata:{origin:e.origin||"unknown",hasPortalId:String(!!i.portalId),hasFormGuid:String(!!i.formGuid)}},{throttleKeys:a}).catch(e=>{(0,jt.AO)("Error sending HubSpot signal-only capture",e)}))}catch(e){(0,jt.AO)("Error processing HubSpot postMessage",e)}}),function(){const e="__cstHubSpotBroadListener";window[e]||(window[e]=!0,window.addEventListener("message",e=>{try{if(!/hsforms\.net|hubspot\.com/i.test(e.origin||""))return;const t=xe(e.data);if(!t)return;const n="string"==typeof t.type?t.type.toLowerCase():"",i="string"==typeof t.eventName?t.eventName.toLowerCase():"";if((wi.complete.some(e=>n.includes(e)||i.includes(e))||t.redirectUrl||t.thankYouMessage)&&!wi.submitted.some(e=>i.includes(e))){const e=t.formGuid||t.formId||"hubspot-unknown",r=de(e);ae(r)||((0,jt.cY)("📡 HubSpot completion signal detected via broad listener:",{formId:e,type:n,eventName:i,hasRedirect:!!t.redirectUrl}),Ie({provider:"hubspot",formId:e,signalType:"postMessage",confidence:.6,metadata:{detectedVia:"broad-listener",hasRedirect:String(!!t.redirectUrl),hasThankYou:String(!!t.thankYouMessage)}},{throttleKeys:r}).catch(e=>{(0,jt.AO)("Error in broad HubSpot listener",e)}))}}catch(e){}}))}())}(),Ye(),De();try{je()}catch(e){(0,jt.AO)("Failed installing form network interceptors",e)}document.addEventListener("submit",Ae,!0),document.addEventListener("click",Ee,!0),new MutationObserver(e=>{let t=!1;e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&("FORM"===e.tagName||e.querySelector&&e.querySelector("form"))&&(t=!0)})}),t&&((0,jt.cY)("New forms detected via MutationObserver"),setTimeout(()=>{document.querySelectorAll("form").forEach(e=>{e instanceof HTMLFormElement&&!Ai.has(e)&&((0,jt.cY)("Setting up tracking for late-rendered form:",e.id||e.className||"unnamed"),Ai.add(e))}),Pe(),De()},500))}).observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{const e=document.querySelectorAll("form");(0,jt.cY)(`Found ${e.length} forms on page load`),e.forEach(e=>{e instanceof HTMLFormElement&&!Ai.has(e)&&((0,jt.cY)("Setting up tracking for form:",e.id||e.className||"unnamed"),Ai.add(e))})},1e3),setInterval(()=>{ze(),De()},2e3),(0,jt.cY)("Enhanced form tracking initialized")}function Ve(){(0,jt.cY)("Rescanning all forms");const e=document.querySelectorAll("form");Qn.formsFound=e.length,De(),Pe(),ze(),Ye(),(0,jt.cY)(`Rescan complete: ${e.length} forms found`)}function Be(){Oi?(0,jt.cY)("Heartbeat already running"):"visible"===document.visibilityState?((0,jt.cY)("Starting heartbeat"),Oi=setInterval(()=>{(async function(e=!1){var t;try{(0,jt.cY)("sendHeartbeat called");const n=Bn.getState();if("UNKNOWN - STATE"===n.clientId||!(null===(t=n.session)||void 0===t?void 0:t.id))return void(0,jt.cY)("heartbeat - invalid state. not sending");if("visible"!==document.visibilityState)return void(0,jt.cY)("heartbeat - tab not visible");const i=Ln;if(i>0&&Date.now()-i<Li)return void(0,jt.cY)("heartbeat - recent non-heartbeat event sent; skipping keepalive");const r=Object.assign({},Qn),o={eventId:B(),eventType:"heartbeat",time:(new Date).toISOString(),activeTime:n.session.activeTimeInSeconds,timeout:e,formMetrics:r};await Y(o)}catch(e){(0,jt.AO)("Error sending heartbeat",e),Ke()}})().catch(e=>(0,jt.AO)("Error sending heartbeat",e))},Li)):(0,jt.cY)("Heartbeat not started - page hidden")}function Ke(){Oi&&(clearInterval(Oi),Oi=null,(0,jt.cY)("Heartbeat stopped"))}function Ge(){const e=window.scrollY||document.documentElement.scrollTop||0,t=(document.documentElement.scrollHeight||0)-(window.innerHeight||0);return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function Xe(){(0,jt.cY)("Resetting scroll tracking"),Ri&&(clearTimeout(Ri),Ri=null),Yi=Object.assign({},bn),Ni=0,Di=0,$i=!1,Hi=!1,Pi&&(window.removeEventListener("scroll",Pi),Pi=null),xi=!1}function Je(){const e=Ge();e>Di&&(Di=e),(0,Ut.AE)()}function Qe(){Ri&&clearTimeout(Ri),Ri=setTimeout(()=>{Ri=null,function(){if(Hi)(0,jt.cY)("Already processing scroll milestones, skipping");else if(!(Di<=Ni)){Hi=!0;try{Ni=Di;let e=null;if(Object.keys(Yi).forEach(t=>{const n=parseInt(t,10);Di>=n&&!Yi[n]&&(Yi[n]=!0,(!e||n>e)&&(e=n))}),null!==e){const t={eventId:B(),eventType:"scroll",time:(new Date).toISOString(),value:e};(0,jt.cY)(`Sending scroll event for milestone: ${e}%`),Y(t)}}finally{Hi=!1}}}()},500)}function Ze(){if(xi&&Pi)(0,jt.cY)("Scroll tracking already initialized, skipping");else try{(0,jt.cY)("Initializing scroll tracking"),Xe(),Pi=()=>{$i||($i=!0,requestAnimationFrame(()=>{$i=!1,Je()})),Qe()},window.addEventListener("scroll",Pi,{passive:!0}),xi=!0,setTimeout(()=>{Je(),Di>0&&Qe()},0),(0,jt.cY)("Scroll tracking initialized")}catch(e){(0,jt.AO)("Error tracking scroll",e),xi=!1}}function et(){const{clickTrackingMode:e,customClickSelector:t,alwaysIncludeClasses:n,includeDataAnlInStandard:i}=Wi,r='button, a, input, select, textarea, [role="button"], [data-track-click]',o=['[class*="btn"]','[class*="button"]','[class*="cta"]'],a=["[data-anl-event]","[data-anl-event_action]"];if("standard"===e){const e=[];return n&&e.push(...o),i&&e.push(...a),tt(r+(e.length?", "+e.join(", "):""),t)}const s=a.concat('[tabindex]:not([tabindex="-1"])',o);return tt("enhanced"===e?r+", "+s.join(", "):r+", "+[].concat(s).concat(["[onclick]","div[role]","span[role]","[data-action]","[data-anl-element_order]","[data-anl-event_action_result]"]).join(", "),t)}function tt(e,t){return t?e+", "+t:e}function nt(){try{(0,jt.cY)("Reinitializing click tracking (manual trigger)"),at(),ji="",ot()}catch(e){(0,jt.AO)("Failed to reinitialize click tracking",e)}}function it(e){const t=Object.assign({},Wi);if(t.customClickSelector)try{if(e.matches(t.customClickSelector))return{mode:"forced",source:"custom"}}catch(e){}return"BUTTON"===e.tagName||"A"===e.tagName||["INPUT","SELECT","TEXTAREA"].includes(e.tagName)||"button"===e.getAttribute("role")||e.hasAttribute("data-track-click")?{mode:"semantic",source:"native"}:e.hasAttribute("data-anl-event")||e.hasAttribute("data-anl-event_action")?{mode:"heuristic",source:"data-anl"}:/btn|button|cta/i.test(e.className||"")?{mode:"heuristic",source:"class"}:e.hasAttribute("onclick")?{mode:"heuristic",source:"onclick"}:{mode:"heuristic",source:"other"}}function rt(e,t){const n=et(),i=null==e?void 0:e.closest(n);if(!i)return;if(qi.has(i))return;const r=S(async()=>{var e,t,n,r,o;try{(0,jt.cY)("Click event triggered for element:",i.tagName,i.id||i.className);let a="",s="";const c=e=>{if(e instanceof HTMLImageElement)return e;const t=e.querySelector("img");return t instanceof HTMLImageElement?t:null};i instanceof HTMLAnchorElement&&(a=i.href),(i instanceof HTMLInputElement||i instanceof HTMLSelectElement||i instanceof HTMLTextAreaElement)&&(s=i.value);const l=i.getBoundingClientRect(),d={top:l.top,left:l.left},u=it(i),m=c(i),h=(null===(e=i.innerText)||void 0===e?void 0:e.slice(0,1e3).trim())||"",f=i.getAttribute("aria-label")||"",p=i.getAttribute("title")||"",g=(null==m?void 0:m.alt)||"",v=(null==m?void 0:m.src)?w(m.src)||m.src:"",y=h||f||p||g||v||null,b={eventId:B(),eventType:"click",time:(new Date).toISOString(),label:i.tagName.toLowerCase(),value:s||i.tagName.toLowerCase(),element:{tag:i.tagName.toLowerCase(),text:y,id:null!==(t=i.id)&&void 0!==t?t:null,class:null!==(n=i.className)&&void 0!==n?n:null,ariaLabel:null!==(r=i.getAttribute("aria-label"))&&void 0!==r?r:null,role:null!==(o=i.getAttribute("role"))&&void 0!==o?o:null,viewportPosition:null!=d?d:null,scrollDepth:Ge(),selector:ee(i),href:w(a)||a||null,src:v||null,value:null!=s?s:null,checked:i instanceof HTMLInputElement?i.checked:null,customSelector:ee(i),xpath:te(i),captureMode:u.mode,captureSource:u.source}};(0,jt.cY)("Queueing click event:",b),await Y(b),(0,jt.cY)("Click event queued for batched send")}catch(e){(0,jt.AO)("Error in throttled click handler",e)}},500,{maxRequestsPerSecond:2,leading:!0,trailing:!1}),o=async function(e){var t,n,o,a,s,c;try{if(e.__cstClickHandled)return;(0,Ut.WI)();const i=e.currentTarget instanceof HTMLElement?e.currentTarget:this instanceof HTMLElement?this:null;if(!i)return;if((0,jt.cY)("Click event detected on:",i.tagName,i.id||i.className),!(e instanceof MouseEvent))return;try{const t=e.target;if(t&&t instanceof HTMLElement){const e=t.closest(et());if(e&&e!==i)return}}catch(e){}e.__cstClickHandled=!0;const l=i instanceof HTMLAnchorElement?i.getAttribute("target"):null,d=!l||""===l||"_self"===l,u=(()=>{if(!(i instanceof HTMLAnchorElement))return!1;if((i.getAttribute("href")||"").startsWith("#"))return!0;try{const e=new URL(i.href,document.baseURI);return e.origin===location.origin&&e.pathname===location.pathname&&e.search===location.search&&e.hash!==location.hash&&""!==e.hash}catch(e){return!1}})();if(i instanceof HTMLAnchorElement&&i.href&&!u&&d&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&i instanceof HTMLAnchorElement){const e=i.getAttribute("href")||i.href,r=it(i),l=(e=>{if(e instanceof HTMLImageElement)return e;const t=e.querySelector("img");return t instanceof HTMLImageElement?t:null})(i),d=(null===(t=i.innerText)||void 0===t?void 0:t.slice(0,1e3).trim())||"",u=i.getAttribute("aria-label")||"",m=i.getAttribute("title")||"",h=(null==l?void 0:l.alt)||"",f=(null==l?void 0:l.src)?w(l.src)||l.src:"",p=d||u||m||h||f||null,g={eventId:B(),eventType:"click",time:(new Date).toISOString(),label:i.tagName.toLowerCase(),value:i.tagName.toLowerCase(),element:{tag:i.tagName.toLowerCase(),text:p,id:null!==(n=i.id)&&void 0!==n?n:null,class:null!==(o=i.className)&&void 0!==o?o:null,ariaLabel:null!==(a=i.getAttribute("aria-label"))&&void 0!==a?a:null,role:null!==(s=i.getAttribute("role"))&&void 0!==s?s:null,viewportPosition:null!==(c=i.getBoundingClientRect())&&void 0!==c?c:null,scrollDepth:Ge(),selector:ee(i),href:w(e)||e||null,src:f||null,value:null,checked:null,customSelector:ee(i),xpath:te(i),captureMode:r.mode,captureSource:r.source}},v=await En(g);(0,jt.cY)("Navigation click batch",v);const y=P(v,{triggerSend:!1});try{await H(v,!0)?N(y):((0,jt.cY)("Navigation click send failed, scheduling queued retry",v.eventType),y?x():P(v,{triggerSend:!0}))}catch(e){(0,jt.AO)("Navigation click send threw error, scheduling queued retry",e),y?x():P(v,{triggerSend:!0})}}else r()}catch(e){(0,jt.AO)("Error in click handler",e),i instanceof HTMLAnchorElement&&window.location.assign(i.href)}};i.addEventListener("click",o,{capture:!0,passive:!1}),qi.add(i),(0,jt.cY)("Click listener added to:",i.tagName,i.id||i.className),t instanceof MouseEvent&&o.call(i,t)}function ot(){try{if(Fi)return void(0,jt.cY)("Click tracking already initialized");Fi=!0,(0,jt.cY)("Initializing click tracking system"),function(){try{(function(e=document){if(!Wi.autoEnhanceClicks)return!1;try{const t=e.querySelectorAll('button, a, [role="button"], [data-track-click]').length,n=e.querySelectorAll('[class*="btn"], [class*="button"], [class*="cta"], [data-anl-event], [data-anl-event_action]').length;return 0!==n&&(0===t||n/(t+1)>.5)}catch(e){return!1}})(document)&&"standard"===Wi.clickTrackingMode&&(Wi=Object.assign(Object.assign({},Wi),{clickTrackingMode:"enhanced"}),1)&&(0,jt.cY)("Auto-enhanced click tracking mode → enhanced");const e=et();ji=e;const t=document.querySelectorAll(e);if((0,jt.cY)(`Initializing click listeners for ${t.length} elements`),t.forEach(e=>{rt(e)}),Ui)try{Ui.disconnect()}catch(e){}Ui=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(et())&&rt(e),e.querySelectorAll(et()).forEach(e=>{rt(e)}))})})}),Ui.observe(document.body,{childList:!0,subtree:!0})}catch(e){(0,jt.AO)("Error initializing clickable elements",e)}}();const e=S(e=>{const t=et();if(e.target instanceof HTMLElement){const n=e.target.closest(t);n&&!qi.has(n)&&((0,jt.cY)("Adding click listener to dynamically detected element:",n.tagName),rt(n,e))}},200,{maxRequestsPerSecond:2,leading:!0,trailing:!1});zi=e,document.addEventListener("click",zi),(0,jt.cY)("Click tracking system initialized")}catch(e){(0,jt.AO)("Error in initial click listener",e)}}function at(){try{Ui&&(Ui.disconnect(),Ui=null),zi&&(document.removeEventListener("click",zi),zi=null)}catch(e){(0,jt.AO)("cleanupClickTracking error",e)}finally{Fi=!1}}function st({element:e,eventType:t,platform:n,videoId:i,src:r,label:o,value:a,watchPercentage:s,furthestWatchPercentage:c,watchTime:l,furthestWatchTime:d}){try{Y({eventId:B(),eventType:t,time:(new Date).toISOString(),label:o||i,value:null!=a?a:String(s),element:{tag:e.tagName.toLowerCase(),id:e.id,class:e.className,videoId:i,watchPercentage:s,furthestWatchPercentage:c,watchTime:l,furthestWatchTime:d,videoPlatform:n,customSelector:ee(e),xpath:te(e),src:null!=r?r:e instanceof HTMLMediaElement?e.currentSrc:e.src||null}})}catch(e){(0,jt.AO)("Error emitting video event",e)}}function ct(){document.querySelectorAll("video").forEach(e=>{(e=>{try{if(Bi.has(e))return;Bi.add(e);const t=Ki.get(e)||B();Ki.set(e,t),(0,jt.cY)("Initializing HTML video tracking",{videoId:t,src:e.currentSrc||e.src,duration:e.duration}),Vi.has(t)||Vi.set(t,{lastPlayTime:e.currentTime,furthestWatchTime:0,watchTime:0,intervalsReported:new Set,lastRealTimestamp:void 0}),e.addEventListener("play",()=>{const n=Vi.get(t);if(!n)return;const i=Date.now();n.lastPlayTime=e.currentTime,n.lastRealTimestamp=i;const r=Math.floor(n.watchTime/e.duration*100),o=Math.floor(n.furthestWatchTime/e.duration*100);(0,jt.cY)("HTML Video play event",{videoId:t,currentTime:e.currentTime,watchTime:n.watchTime,watchPercentage:r,furthestWatchTime:n.furthestWatchTime,furthestWatchPercentage:o}),st({element:e,eventType:"videoPlay",platform:"HTML5",videoId:Ki.get(e)||t,watchPercentage:r,furthestWatchPercentage:o,watchTime:Math.floor(n.watchTime),furthestWatchTime:Math.floor(n.furthestWatchTime),src:e.currentSrc||e.src}),n.intervalId&&clearInterval(n.intervalId),n.intervalId=setInterval(()=>{if(e.paused||e.ended)return void(n.intervalId&&(clearInterval(n.intervalId),n.intervalId=void 0));const i=Date.now();n.lastRealTimestamp&&(n.watchTime+=(i-n.lastRealTimestamp)/1e3),n.lastRealTimestamp=i,e.currentTime>n.furthestWatchTime&&(n.furthestWatchTime=e.currentTime);const r=Math.floor(n.watchTime/e.duration*100),o=Math.floor(n.furthestWatchTime/e.duration*100),a=10*Math.floor(o/10);a>0&&!n.intervalsReported.has(a)&&(n.intervalsReported.add(a),(0,jt.cY)(`HTML Video ${t}: ${a}% position reached. Actually watched: ${r}%`),st({element:e,eventType:"videoProgress",platform:"HTML5",videoId:Ki.get(e)||t,watchPercentage:r,furthestWatchPercentage:o,watchTime:Math.floor(n.watchTime),furthestWatchTime:Math.floor(n.furthestWatchTime),src:e.currentSrc||e.src}))},1e3)}),e.addEventListener("pause",()=>{const n=Vi.get(t);if(!n)return;if(n.lastRealTimestamp){const e=Date.now();n.watchTime+=(e-n.lastRealTimestamp)/1e3,n.lastRealTimestamp=void 0}e.currentTime>n.furthestWatchTime&&(n.furthestWatchTime=e.currentTime);const i=Math.floor(n.watchTime/e.duration*100),r=Math.floor(n.furthestWatchTime/e.duration*100);(0,jt.cY)("HTML Video pause event",{videoId:t,currentTime:e.currentTime,watchTime:n.watchTime,watchPercentage:i,furthestWatchTime:n.furthestWatchTime,furthestWatchPercentage:r}),n.intervalId&&(clearInterval(n.intervalId),n.intervalId=void 0),st({element:e,eventType:"videoPause",platform:"HTML5",videoId:Ki.get(e)||t,watchPercentage:i,furthestWatchPercentage:r,watchTime:Math.floor(n.watchTime),furthestWatchTime:Math.floor(n.furthestWatchTime),src:e.currentSrc||e.src})}),e.addEventListener("ended",()=>{const n=Vi.get(t);if(!n)return;if(n.lastRealTimestamp){const e=Date.now();n.watchTime+=(e-n.lastRealTimestamp)/1e3,n.lastRealTimestamp=void 0}n.furthestWatchTime=e.duration;const i=Math.floor(n.watchTime/e.duration*100);(0,jt.cY)("HTML Video ended event",{videoId:t,duration:e.duration,watchTime:n.watchTime,watchPercentage:i}),n.intervalId&&(clearInterval(n.intervalId),n.intervalId=void 0),st({element:e,eventType:"videoEnded",platform:"HTML5",videoId:Ki.get(e)||t,watchPercentage:i,furthestWatchPercentage:100,watchTime:Math.floor(n.watchTime),furthestWatchTime:Math.floor(e.duration),src:e.currentSrc||e.src})})}catch(e){(0,jt.AO)("Error tracking HTML video",e)}})(e)})}function lt(e,t=0){const n=e.duration||0;return{watchPercentage:n?Math.min(100,Math.floor(e.watchTime/n*100)):Math.min(100,Math.floor(100*t)),furthestWatchPercentage:n?Math.min(100,Math.floor(e.furthestWatchTime/n*100)):Math.min(100,Math.floor(100*t))}}async function dt(e){var t;try{if(await function(){var e;return(null===(e=window.Vimeo)||void 0===e?void 0:e.Player)?Promise.resolve():Gi||(Gi=new Promise((e,t)=>{const n=document.createElement("script");n.src="https://player.vimeo.com/api/player.js",n.async=!0,n.onload=()=>e(),n.onerror=e=>t(e),document.head.appendChild(n)}).catch(e=>{throw(0,jt.AO)("Failed to load Vimeo player API",e),Gi=null,e}),Gi)}(),!(null===(t=window.Vimeo)||void 0===t?void 0:t.Player))return void(0,jt.AO)("Vimeo Player constructor not available after script load");const n=Qi.get(e)||`vimeo-${B()}`;Qi.set(e,n),Ji.add(e);const i=new window.Vimeo.Player(e),r={player:i,element:e,videoKey:n,duration:0,watchTime:0,furthestWatchTime:0,lastSeconds:0,intervalsReported:new Set,handlers:{play:()=>{i.getCurrentTime().then(e=>{r.lastSeconds=e||0}).catch(()=>{}),i.getDuration().then(e=>{e&&(r.duration=e)}).catch(()=>{});const{watchPercentage:e,furthestWatchPercentage:t}=lt(r);st({element:r.element,eventType:"videoPlay",platform:"Vimeo",videoId:r.element.src,watchPercentage:e,furthestWatchPercentage:t,watchTime:Math.floor(r.watchTime),furthestWatchTime:Math.floor(r.furthestWatchTime),src:r.element.src})},pause:()=>{i.getCurrentTime().then(e=>{if("number"==typeof e){e>r.furthestWatchTime&&(r.furthestWatchTime=e);const t=e-r.lastSeconds;t>0&&(r.watchTime+=t),r.lastSeconds=e}}).catch(()=>{});const{watchPercentage:e,furthestWatchPercentage:t}=lt(r);st({element:r.element,eventType:"videoPause",platform:"Vimeo",videoId:r.element.src,watchPercentage:e,furthestWatchPercentage:t,watchTime:Math.floor(r.watchTime),furthestWatchTime:Math.floor(r.furthestWatchTime),src:r.element.src})},ended:()=>{r.duration>0&&(r.watchTime=r.duration,r.furthestWatchTime=r.duration);const{watchPercentage:e,furthestWatchPercentage:t}=lt(r,1);st({element:r.element,eventType:"videoEnded",platform:"Vimeo",videoId:r.element.src,watchPercentage:e,furthestWatchPercentage:t,watchTime:Math.floor(r.watchTime||r.duration),furthestWatchTime:Math.floor(r.furthestWatchTime||r.duration),src:r.element.src})},timeupdate:e=>function(e,t){try{const n="number"==typeof(null==t?void 0:t.seconds)?t.seconds:e.lastSeconds,i="number"==typeof(null==t?void 0:t.percent)?t.percent:0;if("number"==typeof(null==t?void 0:t.duration)&&t.duration>0&&(e.duration=t.duration),"number"==typeof n){if(e.lastSeconds>=0){const t=n-e.lastSeconds;t>0&&(e.watchTime+=t)}e.lastSeconds=n,n>e.furthestWatchTime&&(e.furthestWatchTime=n)}const{watchPercentage:r,furthestWatchPercentage:o}=lt(e,i),a=10*Math.floor(o/10);a>0&&a<=100&&!e.intervalsReported.has(a)&&(e.intervalsReported.add(a),st({element:e.element,eventType:"videoProgress",platform:"Vimeo",videoId:e.element.src,watchPercentage:r,furthestWatchPercentage:o,watchTime:Math.floor(e.watchTime),furthestWatchTime:Math.floor(e.furthestWatchTime),src:e.element.src}))}catch(e){(0,jt.AO)("Error handling Vimeo timeupdate",e)}}(r,e)}};i.getDuration().then(e=>{e&&(r.duration=e)}).catch(()=>{}),i.on("play",r.handlers.play),i.on("pause",r.handlers.pause),i.on("ended",r.handlers.ended),i.on("timeupdate",r.handlers.timeupdate),Xi.set(n,r),(0,jt.cY)("Vimeo tracking initialized",{src:e.src,videoKey:n})}catch(e){(0,jt.AO)("Error setting up Vimeo tracking",e)}}function ut(e=document){const t=function(e){const t=e instanceof HTMLElement?e:document;return Array.from(t.querySelectorAll('iframe[src*="player.vimeo.com"]')).filter(e=>!Ji.has(e))}(e);t.forEach(e=>dt(e))}function mt(e){const t=e.duration||0;return{watchPercentage:t?Math.min(100,Math.floor(e.watchTime/t*100)):0,furthestWatchPercentage:t?Math.min(100,Math.floor(e.furthestWatchTime/t*100)):0}}function ht(e){const t=e.dataset&&(e.dataset.wistiaId||e.dataset.hashedId||e.dataset.videoId)||null;if(t)return t;const n=e.className.match(/wistia_async_([a-zA-Z0-9]+)/);return n&&n[1]?n[1]:e.getAttribute("data-wistia-id")||e.getAttribute("data-hashed-id")||null}function ft(e,t){t&&!er.has(t)&&(er.add(t),nr.set(e,t),window._wq||(window._wq=[]),window._wq.push({id:t,onReady:n=>{try{!function(e,t,n){var i;try{const r={video:e,element:t,videoKey:n,duration:(null===(i=e.duration)||void 0===i?void 0:i.call(e))||0,watchTime:0,furthestWatchTime:0,lastSeconds:0,intervalsReported:new Set,handlers:{}};r.handlers=function(e){return{play:()=>{e.lastSeconds=e.video.time()||0,e.duration=e.video.duration()||e.duration;const{watchPercentage:t,furthestWatchPercentage:n}=mt(e);st({element:e.element,eventType:"videoPlay",platform:"Wistia",videoId:e.videoKey,label:e.element.getAttribute("title")||e.videoKey,src:e.element instanceof HTMLIFrameElement?e.element.src:null,watchPercentage:t,furthestWatchPercentage:n,watchTime:Math.floor(e.watchTime),furthestWatchTime:Math.floor(e.furthestWatchTime)})},pause:()=>{const{watchPercentage:t,furthestWatchPercentage:n}=mt(e);st({element:e.element,eventType:"videoPause",platform:"Wistia",videoId:e.videoKey,label:e.element.getAttribute("title")||e.videoKey,src:e.element instanceof HTMLIFrameElement?e.element.src:null,watchPercentage:t,furthestWatchPercentage:n,watchTime:Math.floor(e.watchTime),furthestWatchTime:Math.floor(e.furthestWatchTime)})},end:()=>{e.duration=e.video.duration()||e.duration,e.watchTime=e.duration,e.furthestWatchTime=e.duration;const{watchPercentage:t,furthestWatchPercentage:n}=mt(e);st({element:e.element,eventType:"videoEnded",platform:"Wistia",videoId:e.videoKey,label:e.element.getAttribute("title")||e.videoKey,src:e.element instanceof HTMLIFrameElement?e.element.src:null,watchPercentage:t,furthestWatchPercentage:n,watchTime:Math.floor(e.watchTime),furthestWatchTime:Math.floor(e.furthestWatchTime)})},timechange:t=>{if("number"!=typeof t)return;const n=t-e.lastSeconds;n>0&&(e.watchTime+=n),e.lastSeconds=t,e.duration=e.video.duration()||e.duration,t>e.furthestWatchTime&&(e.furthestWatchTime=t);const{watchPercentage:i,furthestWatchPercentage:r}=mt(e),o=10*Math.floor(r/10);o>0&&o<=100&&!e.intervalsReported.has(o)&&(e.intervalsReported.add(o),st({element:e.element,eventType:"videoProgress",platform:"Wistia",videoId:e.videoKey,label:e.element.getAttribute("title")||e.videoKey,src:e.element instanceof HTMLIFrameElement?e.element.src:null,watchPercentage:i,furthestWatchPercentage:r,watchTime:Math.floor(e.watchTime),furthestWatchTime:Math.floor(e.furthestWatchTime)}))}}}(r),e.bind("play",r.handlers.play),e.bind("pause",r.handlers.pause),e.bind("end",r.handlers.end),e.bind("timechange",r.handlers.timechange),tr.add(t),nr.set(t,n),Zi.set(n,r),(0,jt.cY)("Wistia tracking initialized",{videoKey:n})}catch(e){(0,jt.AO)("Error binding Wistia video",e)}}(n,e,t)}catch(e){(0,jt.AO)("Error in Wistia onReady handler",e)}}}))}function pt(e=document){const t=function(e){const t=e instanceof HTMLElement?e:document;return Array.from(t.querySelectorAll('.wistia_embed, [data-wistia-id], [data-hashed-id], iframe[src*="fast.wistia.net"], iframe[src*="wistia.com"]')).filter(e=>!tr.has(e))}(e);t.forEach(e=>{const t=ht(e);t?ft(e,t):(0,jt.cY)("Unable to determine Wistia hashed id",{id:e.id,className:e.className})})}function gt(e){const t=e.duration||0;return{watchPercentage:t?Math.min(100,Math.floor(e.watchTime/t*100)):0,furthestWatchPercentage:t?Math.min(100,Math.floor(e.furthestWatchTime/t*100)):0}}function vt(e,t,n){if("number"==typeof n&&n>0&&(e.duration=n),"number"==typeof t){const n=t-e.lastSeconds;n>0&&(e.watchTime+=n),e.lastSeconds=t,t>e.furthestWatchTime&&(e.furthestWatchTime=t)}const{watchPercentage:i,furthestWatchPercentage:r}=gt(e),o=10*Math.floor(r/10);o>0&&o<=100&&!e.intervalsReported.has(o)&&(e.intervalsReported.add(o),st({element:e.element,eventType:"videoProgress",platform:"Loom",videoId:e.element.src,src:e.element.src,watchPercentage:i,furthestWatchPercentage:r,watchTime:Math.floor(e.watchTime),furthestWatchTime:Math.floor(e.furthestWatchTime)}))}function yt(e){try{if(!e.data||"object"!=typeof e.data)return;if(!function(e){try{const t=new URL(e).hostname;return t.endsWith("loom.com")||t.endsWith("loom.com:443")}catch(e){return!1}}(e.origin))return;const t=function(e){if(!e)return null;let t=null;return rr.forEach(n=>{t||n.contentWindow!==e||(t=n)}),t}(e.source)||(1===rr.size?Array.from(rr.values())[0]:null);if(!t)return;const n=ar.get(t)||t.src;let i=ir.get(n);i||(i={element:t,videoKey:n,duration:0,watchTime:0,furthestWatchTime:0,lastSeconds:0,intervalsReported:new Set},ir.set(n,i));const r=function(e){if(!e)return null;const t=e.eventName||e.type||e.name||e.event||e.event_type||e.action;return t?{name:String(t).toUpperCase().startsWith("LOOM_")?String(t).toUpperCase():`LOOM_${String(t).toUpperCase()}`,data:e.data||e.payload||e.details||e.message||e}:null}(e.data);if(!r)return;const o=r.name;if(!o.startsWith("LOOM_"))return;const a=r.data||{},s="number"==typeof a.currentTime?a.currentTime:"number"==typeof a.time?a.time:void 0,c="number"==typeof a.duration?a.duration:void 0;switch(o){case"LOOM_PLAY":{"number"==typeof s&&(i.lastSeconds=s),"number"==typeof c&&(i.duration=c);const{watchPercentage:e,furthestWatchPercentage:t}=gt(i);st({element:i.element,eventType:"videoPlay",platform:"Loom",videoId:i.element.src,src:i.element.src,watchPercentage:e,furthestWatchPercentage:t,watchTime:Math.floor(i.watchTime),furthestWatchTime:Math.floor(i.furthestWatchTime)});break}case"LOOM_PAUSE":{"number"==typeof s&&vt(i,s,c);const{watchPercentage:e,furthestWatchPercentage:t}=gt(i);st({element:i.element,eventType:"videoPause",platform:"Loom",videoId:i.element.src,src:i.element.src,watchPercentage:e,furthestWatchPercentage:t,watchTime:Math.floor(i.watchTime),furthestWatchTime:Math.floor(i.furthestWatchTime)});break}case"LOOM_END":case"LOOM_ENDED":{"number"==typeof c&&(i.duration=c),i.watchTime=i.duration,i.furthestWatchTime=i.duration;const{watchPercentage:e,furthestWatchPercentage:t}=gt(i);st({element:i.element,eventType:"videoEnded",platform:"Loom",videoId:i.element.src,src:i.element.src,watchPercentage:e,furthestWatchPercentage:t,watchTime:Math.floor(i.watchTime),furthestWatchTime:Math.floor(i.furthestWatchTime)});break}case"LOOM_SEEK":case"LOOM_PROGRESS":case"LOOM_TIME":"number"==typeof s&&vt(i,s,c)}}catch(e){(0,jt.AO)("Error handling Loom message",e)}}function wt(e){const t=e instanceof HTMLElement?e:document;return Array.from(t.querySelectorAll('iframe[src*="loom.com/embed"], iframe[src*="loom.com/share"]')).filter(e=>!or.has(e))}function bt(e){if(or.has(e))return;sr||(sr=!0,window.addEventListener("message",yt));let t=ar.get(e)||`loom-${B()}`;ar.set(e,t),or.add(e),rr.add(e),ir.has(t)||ir.set(t,{element:e,videoKey:t,duration:0,watchTime:0,furthestWatchTime:0,lastSeconds:0,intervalsReported:new Set}),(0,jt.cY)("Loom tracking initialized",{src:e.src,videoKey:t})}function St(e=document){wt(e).forEach(bt);try{cr&&(cr.disconnect(),cr=null),cr=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&wt(e).forEach(bt)})})}),cr.observe(document.body,{childList:!0,subtree:!0})}catch(e){(0,jt.AO)("Error setting up Loom MutationObserver",e)}}function Tt(e){e&&(async()=>{try{if(await new Promise((e,t)=>{let n=0;const i=()=>{if(window.YT&&window.YT.Player)return(0,jt.cY)("YouTube API loaded successfully"),void e();if(n>=vr){(0,jt.cY)("YouTube API not found after retries, attempting to reload"),window.onYouTubeIframeAPIReady=()=>{(0,jt.cY)("YouTube API reloaded successfully"),e()};const t=document.querySelector('script[src*="youtube.com/iframe_api"]');return t&&t.remove(),void hr()}n++,setTimeout(i,yr)};i()}),(()=>{const e=document.querySelectorAll('iframe[src*="youtube.com/embed/"]');(0,jt.cY)("Found YouTube iframes:",e.length),e.forEach(e=>{const t=br(e);t.id&&_t(t,!0)})})(),wr)try{wr.disconnect()}catch(e){}wr=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&e.querySelectorAll('iframe[src*="youtube.com/embed/"]').forEach(e=>{const t=br(e);t.id&&_t(t,!0)})})})}),wr.observe(document.body,{childList:!0,subtree:!0})}catch(e){(0,jt.AO)("Error initializing YouTube iframes:",e)}})()}function _t(e,t){try{const n=e;if((0,jt.cY)("Initializing YouTube Iframe",{id:n.id,src:n.src,apiReady:!!window.YT&&!!window.YT.Player,youTubeApiCalled:t}),n.id||(n.id=`yt-${B()}`,(0,jt.cY)("Generated new YouTube iframe ID",{id:n.id})),!t)return void(0,jt.cY)("YouTube API script not loaded yet, skipping initialization");if(!window.YT||!window.YT.Player){const e=gr.get(n)||0;if(e>=10)return void(0,jt.AO)("Failed to initialize YouTube iframe after 10 retries",{id:n.id,src:n.src});const i=Math.min(100*Math.pow(2,e),3e3);return gr.set(n,e+1),(0,jt.cY)("YouTube API not ready, retrying in "+i+"ms",{retryCount:e+1,id:n.id}),void setTimeout(()=>_t(n,t),i)}if(gr.delete(n),pr.has(n.id))return void(0,jt.cY)("Player already initialized",{id:n.id});(0,jt.cY)("Creating YouTube player",{iframeId:n.id,src:n.src}),new window.YT.Player(n.id,{events:{onReady:e=>{(0,jt.cY)("YouTube player ready",{id:n.id,playerInfo:e.target.playerInfo}),pr.has(n.id)||pr.set(n.id,{lastPlayTime:0,furthestWatchTime:0,watchTime:0,intervalsReported:new Set,lastRealTimestamp:e.data===window.YT.PlayerState.PLAYING?Date.now():void 0})},onStateChange:e=>{const t=e;(0,jt.cY)("YouTube player state changed",{id:n.id,state:e.data,playerInfo:e.target.playerInfo}),function(e){var t;try{const n=null===(t=e.target.g)||void 0===t?void 0:t.id;if(!n)return void(0,jt.AO)("Missing player ID in YouTube event",e.target);const i=e.target;pr.has(n)||pr.set(n,{lastPlayTime:i.playerInfo.currentTime,furthestWatchTime:0,watchTime:0,intervalsReported:new Set,lastRealTimestamp:e.data===window.YT.PlayerState.PLAYING?Date.now():void 0});const r=pr.get(n);if(!r)return void(0,jt.AO)("Failed to get player state",{playerID:n});const o=i.playerInfo.currentTime,a=i.playerInfo.duration,s=Date.now();let c=null;if(e.data===window.YT.PlayerState.PLAYING&&(c="videoPlay",r.lastPlayTime=o,r.lastRealTimestamp=s,function(e,t){try{const n=setInterval(()=>{if(e.data!==window.YT.PlayerState.PLAYING)return void clearInterval(n);const i=pr.get(t);if(!i||!i.lastRealTimestamp)return void clearInterval(n);const r=e.target,o=r.playerInfo.currentTime,a=r.playerInfo.duration,s=Date.now();i.watchTime+=(s-i.lastRealTimestamp)/1e3,i.lastRealTimestamp=s,i.furthestWatchTime=Math.max(i.furthestWatchTime,o);const c=Math.floor(o/a*100),l=Math.floor(i.watchTime/a*100),d=10*Math.floor(c/10);!i.intervalsReported.has(d)&&d>0&&(i.intervalsReported.add(d),(0,jt.cY)(`YouTube video ${t}: ${d}% position reached. Actually watched: ${l}%`),st({element:document.getElementById(t),eventType:"videoProgress",platform:"YouTube",videoId:r.playerInfo.videoUrl,label:r.playerInfo.videoUrl,value:d.toString(),watchPercentage:l,furthestWatchPercentage:c,watchTime:Math.floor(i.watchTime),furthestWatchTime:Math.floor(i.furthestWatchTime),src:r.playerInfo.videoUrl}))},1e3),i=pr.get(t);i&&(i.intervalId=n)}catch(e){(0,jt.AO)("Error tracking youtube progress",e)}}(e,n)),(e.data===window.YT.PlayerState.PAUSED||e.data===window.YT.PlayerState.ENDED)&&(c=e.data===window.YT.PlayerState.PAUSED?"videoPause":"videoEnded",r.lastRealTimestamp&&(r.watchTime+=(s-r.lastRealTimestamp)/1e3,r.lastRealTimestamp=void 0),o>r.lastPlayTime&&(r.furthestWatchTime=Math.max(r.furthestWatchTime,o))),!c)return;const l=Math.floor(o/a*100),d=Math.floor(r.watchTime/a*100);(0,jt.cY)("youtube video update",{playerID:n,eventType:c,watchPercentage:d,watchTime:Math.floor(r.watchTime),furthestWatchTime:Math.floor(r.furthestWatchTime),furthestWatchPercentage:l,formattedWatchTime:It(r.watchTime),currentTime:o,duration:a,lastPlayTime:r.lastPlayTime}),st({element:document.getElementById(n),eventType:c,platform:"YouTube",videoId:i.playerInfo.videoUrl,label:i.playerInfo.videoUrl,value:d.toString(),watchPercentage:d,furthestWatchPercentage:l,watchTime:Math.floor(r.watchTime),furthestWatchTime:Math.floor(r.furthestWatchTime),src:i.playerInfo.videoUrl})}catch(e){(0,jt.AO)("Error in onPlayerStateChange",e)}}(t)},onError:e=>{(0,jt.AO)("YouTube player error",{id:n.id,errorCode:e.data,src:n.src})}},playerVars:{origin:window.location.origin,enablejsapi:1,modestbranding:1,rel:0,controls:1,host:window.location.origin}})}catch(t){(0,jt.AO)("Error initializing YouTube iframe",{error:t,iframeId:e.id,src:e.src})}}function It(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),i=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`:`${n}:${i.toString().padStart(2,"0")}`}function kt(e){if(Sr.has(e))return;const t=e instanceof HTMLSelectElement,n=t?"change":"blur",i=t?"select_change":"input_blur",r=async()=>{if((0,jt.cY)(`${n} event triggered`,e),!e.value.trim()||e instanceof HTMLInputElement&&("password"===e.type||"file"===e.type)||e.name&&(t=e.name,wn.some(e=>"string"==typeof e?t.toLowerCase().includes(e.toLowerCase()):e.test(t))))return;var t;const r={eventId:B(),eventType:"input",time:(new Date).toISOString(),label:i,value:e.value,element:{tag:e.tagName.toLowerCase(),id:e.id,class:e.className,type:e.type||null,name:e.name,value:e.value,customSelector:ee(e),xpath:te(e)}};(0,jt.cY)("Queueing input event:",r);try{await Y(r),(0,jt.cY)("input event queued for batched send")}catch(e){(0,jt.AO)("Error queueing input data",e)}};e.addEventListener(n,r),Sr.add(e);const o=Tr.get(e)||{};o[n]=r,Tr.set(e,o)}function At(e){e.querySelectorAll("input, textarea, select").forEach(e=>{kt(e)});const t=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&kt(e),e.querySelectorAll("input, textarea, select").forEach(e=>{kt(e)}))})})});return t.observe(e,{childList:!0,subtree:!0}),t}function Et(){kr||(kr=!0,(0,jt.cY)("Starting input and select tracking"),_r=At(document),function(){let e=window.location.pathname;if(Ir)try{Ir.disconnect()}catch(e){}Ir=new MutationObserver(()=>{window.location.pathname!==e&&(e=window.location.pathname,(0,jt.cY)("SPA navigation detected, reinitializing input tracking"),_r&&_r.disconnect(),_r=At(document))}),Ir.observe(document.body,{childList:!0,subtree:!0});const t=e=>{(0,jt.cY)("Navigation detected, reinitializing input tracking"),_r&&_r.disconnect(),_r=At(document)};Ar=t,Er=t,Or=t,window.addEventListener("popstate",Ar),window.addEventListener("pushState",Er),window.addEventListener("replaceState",Or)}())}function Ot(e){return e.closest(Cr)||e.closest("[role='listbox']")}async function Lt(e){const t=Ot(e),{value:n,label:i}=function(e){var t,n;const i=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"",r=e.getAttribute("data-value"),o=e.getAttribute("value"),a=(r||o||i).trim();return{value:a,label:i||a}}(e);if(!n&&!i)return;const r=function(e,t){const n=function(e){if(!e)return null;const t=e.id;if(t){const e=document.querySelector(`[aria-controls='${CSS.escape(t)}']`);if(e instanceof HTMLInputElement)return e;const n=null==e?void 0:e.querySelector("input[name]");if(n instanceof HTMLInputElement)return n}const n=e.closest(Cr)||e,i=null==n?void 0:n.querySelector("input[name], input[type='hidden'][name]");return i instanceof HTMLInputElement?i:null}(e.closest("[role='listbox']")||t);if(null==n?void 0:n.name)return n.name;if(t){const e=t.getAttribute("name")||t.getAttribute("data-name");return e&&e.trim()?e.trim():t.id&&t.id.trim()?t.id.trim():ee(t)}return ee(document.body)}(e,t),o={eventId:B(),eventType:"input",time:(new Date).toISOString(),label:"dropdown_select",value:n,element:{tag:e.tagName.toLowerCase(),id:(null==t?void 0:t.id)||e.id||null,class:(null==t?void 0:t.className)||e.className||null,role:(null==t?void 0:t.getAttribute("role"))||null,name:r,text:i,selector:ee(e),customSelector:ee(e),xpath:te(e)}};(0,jt.cY)("Custom dropdown option selected",{name:r,value:n,label:i,optionTag:e.tagName});const a=await En(o);await H(a),(0,jt.cY)("Custom dropdown input event sent successfully")}function Ct(e){var t,n,i;try{const r=Object.getOwnPropertyDescriptor(history,e),o=null!==(t=null==r?void 0:r.value)&&void 0!==t?t:history[e];if("function"!=typeof o)return void(0,jt.cY)(`SPA tracking: history.${e} missing or not a function; skipping patch`);if(o[$r])return void(0,jt.cY)(`SPA tracking: history.${e} already wrapped by CST`);if(/\[native code\]/.test(o.toString())||(0,jt.cY)(`SPA tracking: history.${e} appears pre-wrapped; chaining listener`,{originalName:o.name}),r&&!1===r.configurable)return void(0,jt.cY)(`SPA tracking: history.${e} not configurable; cannot patch`);const a=function(...t){const n=o.apply(this,t);try{window.dispatchEvent(new Event(e))}catch(t){(0,jt.AO)(`SPA tracking: failed to dispatch ${e} event`,t)}return n};a[$r]=!0,r?Object.defineProperty(history,e,{configurable:!0,enumerable:null!==(n=r.enumerable)&&void 0!==n&&n,writable:null===(i=r.writable)||void 0===i||i,value:a}):history[e]=a}catch(t){(0,jt.AO)(`SPA tracking: error patching history.${e}`,t)}}function Mt(e,t){try{if(Hr.has(e))return;!function(e){var t;try{if(Hr.has(e))return;if(e instanceof HTMLFormElement&&Wr(),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&kt(e),e.matches(et())&&rt(e),e instanceof HTMLVideoElement&&rt(e),e instanceof HTMLIFrameElement&&(null===(t=e.src)||void 0===t?void 0:t.includes("youtube.com/embed/"))){const t=br(e);mr()||hr(),_t(t,mr())}!function(e){var t;e instanceof HTMLIFrameElement&&(null===(t=e.src)||void 0===t?void 0:t.includes("player.vimeo.com"))&&!Ji.has(e)&&dt(e)}(e),function(e){const t=ht(e);t&&ft(e,t)}(e),function(e){var t,n;e instanceof HTMLIFrameElement&&((null===(t=e.src)||void 0===t?void 0:t.includes("loom.com/embed"))||(null===(n=e.src)||void 0===n?void 0:n.includes("loom.com/share")))&&bt(e)}(e),Hr.add(e)}catch(e){(0,jt.AO)("Error processing element",e)}}(e),t.depth<Nr&&Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&!t.processedNodes.has(e)&&(t.processedNodes.add(e),Mt(e,Object.assign(Object.assign({},t),{depth:t.depth+1})))})}catch(e){(0,jt.AO)("Error handling dynamic element",e)}}async function Yt(){try{const e=Rr,t=location.href;if(t===e)return void(0,jt.cY)("Route change ignored because URL has not changed");if(function(e,t){try{const n=new URL(e,document.baseURI),i=new URL(t,document.baseURI);return n.origin===i.origin&&n.pathname===i.pathname&&n.search===i.search&&n.hash!==i.hash}catch(n){const i=e=>e.split("#")[0];return i(e)===i(t)&&e!==t}}(e,t))return Rr=t,window.__cst_spa_last_url=Rr,void(0,jt.cY)("Hash-only navigation detected; skipping new page view");Rr=t,window.__cst_spa_last_url=Rr,(0,jt.cY)(`Route change detected: ${e} -> ${t}`,{previousUrl:e,currentUrl:t,documentReferrer:document.referrer,computedReferrer:e||document.referrer});const n=I(),i={id:`pv_${window.location.pathname}_${B()}`,startTime:n,startTimestamp:_(),lastActivityTime:n,activeTimeInSeconds:0,url:t,pathname:location.pathname,title:document.title,referrer:e||document.referrer,isValid:!0};await Bn.endCurrentPageViewAndStartNew(i);try{(0,jt.cY)("Sending initial data for SPA route change"),await C()}catch(e){(0,jt.AO)("Error sending initial data during SPA route change",e)}setTimeout(async()=>{try{z(),at(),function(){try{_r&&(_r.disconnect(),_r=null),Ir&&(Ir.disconnect(),Ir=null),Ar&&(window.removeEventListener("popstate",Ar),Ar=null),Er&&(window.removeEventListener("pushState",Er),Er=null),Or&&(window.removeEventListener("replaceState",Or),Or=null)}catch(e){(0,jt.AO)("cleanupInputTracking error",e)}finally{kr=!1}}(),function(){try{Vi.forEach(e=>{e.intervalId&&(clearInterval(e.intervalId),e.intervalId=void 0)}),Vi.clear()}catch(e){}}(),Xi.forEach(e=>{try{e.player.off("play",e.handlers.play),e.player.off("pause",e.handlers.pause),e.player.off("ended",e.handlers.ended),e.player.off("timeupdate",e.handlers.timeupdate)}catch(e){(0,jt.AO)("Error cleaning up Vimeo tracking",e)}}),Xi.clear(),Zi.forEach(e=>{try{e.video.unbind("play",e.handlers.play),e.video.unbind("pause",e.handlers.pause),e.video.unbind("end",e.handlers.end),e.video.unbind("timechange",e.handlers.timechange)}catch(e){(0,jt.AO)("Error cleaning up Wistia tracking",e)}}),Zi.clear(),er.clear(),function(){window.removeEventListener("message",yt),sr=!1;try{cr&&(cr.disconnect(),cr=null)}catch(e){}rr.clear(),ir.clear()}();try{!function(){try{Yr&&(document.removeEventListener("click",Yr,!0),Yr=null),Pr&&(document.removeEventListener("keydown",Pr,!0),Pr=null)}catch(e){(0,jt.AO)("cleanupCustomDropdownTracking error",e)}finally{Mr=!1}}()}catch(e){}Xe(),Ze(),document.querySelectorAll("input, textarea").forEach(e=>{e.removeAttribute("cst-event-active")}),nt(),qe(),Ve(),ct(),ut(),pt(),St(),Be(),document.querySelectorAll("input, textarea").forEach(e=>kt(e)),mr()&&Tt(!0)}catch(e){(0,jt.AO)("Error reinitializing tracking after route change",e)}},100)}catch(e){(0,jt.AO)("Error handling route change",e)}}async function Pt(e,t,n){const i=Bn.getState().cookieConsent,r=Pt._lastTag;if(i!==e||!r||r.consent!==e||r.source!==t){Bn.setCookieConsent(e),Pt._lastTag={consent:e,source:t},(0,jt.cY)(`Cookie consent set to ${e} from ${t}`);try{const i={eventId:B(),eventType:"cookieConsent",time:(new Date).toISOString(),label:"Cookie consent "+(e?"granted":"denied"),value:Object.assign({consentGiven:e,consentSource:t},n?{details:n}:{})};await Y(i)}catch(e){(0,jt.AO)("Error sending cookie consent event",e)}}}function Nt(e){zr.push(e)}function xt(){try{const e=document.cookie||"",t=e.match(/(?:^|; )OptanonConsent=([^;]+)/),n=e.match(/(?:^|; )OptanonActiveGroups=([^;]+)/);if(n){const e=decodeURIComponent(n[1]).split(",").filter(Boolean);return{hasConsent:!!e.some(e=>e&&"C0001"!==e),details:{oneTrust:{activeGroups:e}}}}if(!t)return null;const i=decodeURIComponent(t[1]),r=(Object.fromEntries(i.split("&").map(e=>{const t=e.indexOf("=");return-1===t?[e,""]:[e.slice(0,t),e.slice(t+1)]})).groups||"").split(",").map(e=>e.trim()).filter(Boolean);let o=!1;const a={};for(const e of r){const[t,n]=e.split(":"),i=Number(n);t&&(a[t]=i),t&&"C0001"!==t&&1===i&&(o=!0)}return{hasConsent:o,details:{oneTrust:{groups:a}}}}catch(e){return(0,jt.AO)("Error parsing OneTrust consent",e),null}}function Rt(e=5){const t=window.__tcfapi;if("function"==typeof t){const e=(e,t)=>{var n,i,r,o;if(t&&("useractioncomplete"===e.eventStatus||"tcloaded"===e.eventStatus)){const t=(null===(n=null==e?void 0:e.purpose)||void 0===n?void 0:n.consents)||{},a=(null===(i=null==e?void 0:e.vendor)||void 0===i?void 0:i.consents)||{},s=Object.entries(t).some(([e,t])=>"1"!==e&&!0===t),c=Object.values(a).some(e=>e);Pt(!(!s&&!c),"tcfapi",{tcf:{purposeConsents:null===(r=e.purpose)||void 0===r?void 0:r.consents,vendorConsents:null===(o=e.vendor)||void 0===o?void 0:o.consents}})}};return t("addEventListener",2,e),Nt(()=>{try{t("removeEventListener",2,e)}catch(e){}}),void t("getTCData",2,(e,t)=>{var n,i,r,o;if(!t)return;const a=(null===(n=null==e?void 0:e.purpose)||void 0===n?void 0:n.consents)||{},s=(null===(i=null==e?void 0:e.vendor)||void 0===i?void 0:i.consents)||{},c=Object.entries(a).some(([e,t])=>"1"!==e&&!0===t),l=Object.values(s).some(e=>e);Pt(!(!c&&!l),"tcfapi",{tcf:{purposeConsents:null===(r=e.purpose)||void 0===r?void 0:r.consents,vendorConsents:null===(o=e.vendor)||void 0===o?void 0:o.consents}})})}if(e>0){const t=setTimeout(()=>Rt(e-1),1e3);qr.push(t)}}function Dt(){var e;if(!Ur&&"undefined"!=typeof window){Ur=!0;try{Rt(),function(){try{const e=window;let t=null,n=null,i=!1,r=!1;const o=e=>{if(!e||"object"!=typeof e)return null;const t=e.consentParameters||e,n=["analytics_storage","ad_storage","ad_user_data","ad_personalization","personalization_storage","functionality_storage","security_storage"],i={};let r=!1;for(const e of n){const n=null==t?void 0:t[e];"string"==typeof n&&(i[e]=n,r=!0)}return r?i:null},a=(e,t)=>{try{const a=o(e);if(!a)return;const s=Object.values(a),c=s.some(e=>"granted"===e),l=s.length&&s.every(e=>"denied"===e);if(!c&&!l)return;if(!r)return;const d=JSON.stringify(a,Object.keys(a).sort());if(d===n)return;n=d,i=!0,Pt(c,t,{gcm:e,gcmState:a})}catch(e){(0,jt.AO)("Error emitting GCM consent",e)}},s=e=>{try{if(!e)return;const t="object"==typeof e&&!Array.isArray(e)&&"number"==typeof e.length&&"consent"===e[0];if((Array.isArray(e)||t)&&"consent"===e[0])return"update"===e[1]&&(r=!0),void a(e[2]||{},"gcm");if("object"==typeof e){const t=String(e.event||"");(t.includes("consent")||"gtm.init_consent"===t||"gtm.default_consent"===t||"gtm.default_consent_update"===t||"gtm.consentUpdate"===t)&&("gtm.consentUpdate"===t&&(r=!0),a(e,"gcm"))}}catch(e){(0,jt.AO)("Error processing GCM dataLayer item",e)}},c=e=>{if(!Array.isArray(e)||e.__cstPatched)return;try{e.forEach(s)}catch(e){}const t=e.push.bind(e),n=function(...e){const n=t(...e);try{e.forEach(s)}catch(e){}return n};n.__cstPatched=!0,e.push=n,e.__cstPatched=!0,Nt(()=>{try{Array.isArray(e)&&e.push===n&&(e.push=t)}catch(e){}})};let l=40;const d=setInterval(()=>{try{Array.isArray(e.dataLayer)&&c(e.dataLayer)}catch(e){}--l<=0&&clearInterval(d)},250);Nt(()=>clearInterval(d));try{Array.isArray(e.dataLayer)&&c(e.dataLayer)}catch(e){}const u=()=>{const n=e.gtag||function(){e.dataLayer=e.dataLayer||[],e.dataLayer.push(arguments)};if(n.__cstPatched)return;t||(t=n);const i=function(...e){try{"consent"!==e[0]||"update"!==e[1]&&"default"!==e[1]||("update"===e[1]&&(r=!0),a(e[2]||{},"gcm"))}catch(e){(0,jt.AO)("Error intercepting gtag consent",e)}return n.apply(this,e)};i.__cstPatched=!0,e.gtag=i};u();let m=40;const h=setInterval(()=>{try{"function"!=typeof e.gtag||e.gtag.__cstPatched||u()}catch(e){}--m<=0&&clearInterval(h)},250);Nt(()=>clearInterval(h)),Nt(()=>{var n;try{t&&(null===(n=e.gtag)||void 0===n?void 0:n.__cstPatched)&&(e.gtag=t)}catch(e){}})}catch(e){(0,jt.AO)("Error setting up Google Consent Mode listener",e)}}();try{let e=null;const t=()=>{const e=document.cookie,t=e.match(/__hs_cookie_cat_pref=([^;]+)/),n=e.match(/hs-privacy-settings=([^;]+)/);let i={},r=null;if(t)try{const e=decodeURIComponent(t[1]),n={};e.split(/[_,]/).map(e=>e.trim()).filter(Boolean).forEach(e=>{const t=e.indexOf(":");t>-1&&(n[e.slice(0,t)]=e.slice(t+1))}),r="true"===n[2]||"true"===n[3]||"true"===n[4],i.cookie_cat_pref=n}catch(e){}if(n)try{const e=JSON.parse(decodeURIComponent(n[1]));null===r&&(r=!!(e.consentAllowed||e.consentAnalytics||e.consentAdvertisement||e.consentFunctionality)),i.legacy=e}catch(e){}return null===r?null:{consent:r,details:{hubspot:i}}},n=()=>{try{const n=t();if(!n)return;const i=JSON.stringify(n);if(i===e)return;e=i,Pt(n.consent,"hubspot",n.details)}catch(e){}};n();const i=setInterval(n,1e3);Nt(()=>clearInterval(i))}catch(e){(0,jt.AO)("Error initializing HubSpot cookie monitor",e)}const t=setInterval(()=>{try{const e=window.hsConsentApi;if(e&&"function"==typeof e.onConsentChange){clearInterval(t);const n=e=>{try{const t={hasConsent:!!((null==e?void 0:e.consentAllowed)||(null==e?void 0:e.consentAnalytics)||(null==e?void 0:e.consentAdvertisement)||(null==e?void 0:e.consentFunctionality)),details:{hubspot:e}};Pt(t.hasConsent,"hubspot",t.details)}catch(e){(0,jt.AO)("Error handling HubSpot onConsentChange",e)}};try{e.onConsentChange(n),Nt(()=>{var t;try{null===(t=e.offConsentChange)||void 0===t||t.call(e,n)}catch(e){}})}catch(e){(0,jt.AO)("Failed to register HubSpot onConsentChange",e)}}}catch(e){(0,jt.AO)("Error probing HubSpot consent API",e)}},1e3);Nt(()=>clearInterval(t));const n=()=>Pt(!0,"cookiebot"),i=()=>Pt(!1,"cookiebot"),r=()=>{var e,t,n;const i=window.Cookiebot;Pt(!!((null===(e=null==i?void 0:i.consent)||void 0===e?void 0:e.marketing)||(null===(t=null==i?void 0:i.consent)||void 0===t?void 0:t.preferences)||(null===(n=null==i?void 0:i.consent)||void 0===n?void 0:n.statistics)),"cookiebot")};window.addEventListener("CookiebotOnAccept",n,{passive:!0}),window.addEventListener("CookiebotOnDecline",i,{passive:!0}),window.addEventListener("CookiebotOnLoad",r,{passive:!0}),Nt(()=>{window.removeEventListener("CookiebotOnAccept",n),window.removeEventListener("CookiebotOnDecline",i),window.removeEventListener("CookiebotOnLoad",r)}),(null===(e=window.Cookiebot)||void 0===e?void 0:e.consent)&&r();const o=()=>{const e=setTimeout(()=>{const e=xt();e&&Pt(e.hasConsent,"oneTrust",e.details)},100);qr.push(e)};window.addEventListener("OneTrustConsentChanged",o,{passive:!0}),Nt(()=>{window.removeEventListener("OneTrustConsentChanged",o)});const a=xt();a&&Pt(a.hasConsent,"oneTrust",a.details);const s=()=>Pt(!0,"generic"),c=()=>Pt(!1,"generic");window.addEventListener("consentGiven",s,{passive:!0}),window.addEventListener("consentDenied",c,{passive:!0}),Nt(()=>{window.removeEventListener("consentGiven",s),window.removeEventListener("consentDenied",c)}),(0,jt.cY)("Cookie consent tracking initialized")}catch(e){(0,jt.AO)("Error initializing cookie consent tracking",e)}}}function $t(){Gr||(Gr=!0,Promise.resolve().then(async()=>{Gr=!1;const e=Kr.shift();if(e){try{await async function(e){const t=`${Qt}${Vr}`,n=JSON.stringify(e);(0,jt.cY)("Posting pixel context bridge payload",{endpoint:t,shop:e.shop}),await A(fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-CST-Bridge":"1"},keepalive:!0,body:n,credentials:"omit"}),2e3).catch(e=>{throw e})}(e)}catch(e){(0,jt.AO)("Failed to push pixel context bridge payload",e)}Kr.length>0&&$t()}}))}async function Ht(e={}){if(Xr)return!1;const{force:t=!1}=e,n=Date.now();if(!t&&0!==Jr&&n-Jr<2e3)return console.log("[CST] Skipping cart attribute update (cooldown active)"),!1;try{Xr=!0;const e=Bn.getState(),t=function(){try{const e=localStorage.getItem("cart");if(e){const t=JSON.parse(e);if(null==t?void 0:t.token)return t.token}const t=localStorage.getItem("_shopify_cart_token");if(t)return t}catch(e){(0,jt.cY)("Failed to read Shopify cart localStorage",e)}return null}();t&&e.parsedMarketingTrackers&&(e.parsedMarketingTrackers.shopify_cart_token=t);const n={_cst_sessionId:e.session.id,_cst_clientId:e.clientId,_cst_pageViewId:e.page.id,_cst_userId:e.userId,_cst_visitorId:e.visitorId};let i,r,o=!1,a="",s=0;try{const e=await A(fetch("/cart.js",{credentials:"same-origin"}),2e3).catch(()=>null);if(e&&e.ok){const t=await e.json().catch(()=>null);t&&"object"==typeof t&&(o=!0,"string"==typeof t.note&&(a=t.note),Array.isArray(t.items)&&(s=t.items.length),t.attributes&&"object"==typeof t.attributes&&(r=t.attributes),"string"==typeof t.token&&(i=t.token))}}catch(e){}if(i||(i=t||void 0,i&&(0,jt.cY)("Using cart token from Shopify localStorage",{existingToken:i})),i&&e.parsedMarketingTrackers&&(e.parsedMarketingTrackers.shopify_cart_token=i),o&&(0===s||!i))return(0,jt.cY)("Skipping cart attribute update: cart is empty or lacks a token.",{itemsCount:s,hasToken:!!i}),!1;let c=!1;r&&(c=r._cst_sessionId===n._cst_sessionId&&r._cst_clientId===n._cst_clientId&&r._cst_pageViewId===n._cst_pageViewId&&r._cst_userId===n._cst_userId&&r._cst_visitorId===n._cst_visitorId);const l="string"==typeof a&&Qr.test(a),d=()=>{if(i)try{const e="undefined"!=typeof window&&window.location?window.location.hostname:void 0;!function(e){var t;if(!e||"string"!=typeof e.cartToken)return;const n=e.cartToken.trim();if(!n)return;const i=function(e,t){return`${"string"==typeof t&&t.trim().length>0?t.trim().toLowerCase():"unknown"}:${e}`}(n,e.shop),r=Date.now();r-(null!==(t=Br.get(i))&&void 0!==t?t:0)<6e4||(Br.set(i,r),Kr.length>=25&&Kr.shift(),Kr.push(Object.assign(Object.assign({},e),{cartToken:n,timestamp:(new Date).toISOString()})),$t())}({cartToken:i,clientId:n._cst_clientId,sessionId:n._cst_sessionId,pageViewId:n._cst_pageViewId,userId:n._cst_userId,visitorId:n._cst_visitorId,shop:e})}catch(e){(0,jt.AO)("Failed to enqueue pixel context sync",e)}};if(c&&!l)return console.log("[CST] Cart attributes already current; skipping write"),d(),!0;console.log("[CST] Updating cart attributes (enrichment)",{attributes:n,removingLegacyNoteMarker:l});const u={attributes:n};l&&(u.note=a?a.replace(Zr,"").trim():"");const m=await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json","X-CST-Attrs":"1"},body:JSON.stringify(u),credentials:"same-origin",keepalive:!0});if(m.ok){await m.json().catch(()=>null),console.log("[CST] Cart attributes updated successfully",{status:m.status,attributeCount:Object.keys(n).length}),d();try{const t=await fetch("/cart.js",{credentials:"same-origin"});if(t.ok){const n=await t.json().catch(()=>null),i=(null==n?void 0:n.note)||"",r=(null==n?void 0:n.attributes)||{},o=(null==n?void 0:n.token)||void 0,a="string"==typeof i&&Qr.test(i),s=Object.keys(r||{});if(console.log("[CST] Cart attributes synced",{token:o,hasCstTag:a,attrKeys:s,sessionId:e.session.id}),"string"==typeof o&&o)try{const t=_();await async function(e,t=!1){try{const n=await En(e);return await H(n,t)}catch(e){return(0,jt.AO)("Error in buildAndSendDataImmediate",e),!1}}({eventId:"crt_"+B(),eventType:"cartIdsSync",time:t,source:"shopify",cartToken:String(o),clientId:e.clientId,sessionId:e.session.id,visitorId:e.visitorId,pageViewId:e.page.id,noteHasTag:a,attributesPresent:s.length>0,timestamp:t},!0)}catch(e){(0,jt.AO)("Failed to emit cartIdsSync event",e)}}}catch(e){(0,jt.AO)("Post-update cart verification failed",e)}return!0}return(0,jt.AO)("Cart attributes update failed",{status:m.status,statusText:m.statusText}),!1}catch(e){return(0,jt.AO)("Failed to update cart attributes",e),!1}finally{Jr=Date.now(),Xr=!1}}function initialize(n={}){if((0,jt.cY)("KLRR_CST_FX] initialize() called; isInitialized:",eo),!eo){try{i=n,Wi=Object.assign(Object.assign({},Wi),i)}catch(e){(0,jt.AO)("Failed applying runtime config",e)}return(0,jt.cY)("KLRR_CST_FX] invoking cst() now"),async function(){var n,i;if(eo)(0,jt.cY)("KLRR_CST_FX] Already initialized, skipping");else try{(0,jt.cY)("KLRR_CST_FX] Starting initialization"),(0,jt.cY)("KLRR_CST_FX] calling stateManager.initialize()"),await Bn.initialize(),(0,jt.cY)("KLRR_CST_FX] state initialized; session:",Bn.getSessionId(),"page:",Bn.getState().page.id);let r=null;try{(0,jt.cY)("KLRR_CST_FX] running bot detection"),r=await async function(){try{const e=await Fr.detect(),n=e.isBot;return(0,jt.cY)("BotDetector result",e),t("cst_bot",String(n)),e}catch(e){return(0,jt.cY)("detectBot error",e),{isBot:!1,confidence:0,signals:[]}}}(),Bn.setBotDetection(r);const{checkCanvasUaMismatch:n}=await Promise.resolve().then(e.bind(e,53));n()}catch(e){(0,jt.AO)("Bot detection failed, proceeding with tracking:",e),r=null}let o=!!(null==r?void 0:r.isBot);if("undefined"!=typeof window&&"true"===window.localStorage.getItem("bypassBotDetection")&&((0,jt.cY)("Manual bot detection bypass enabled"),o=!1),o){const e=null!==(n=null==r?void 0:r.confidence)&&void 0!==n?n:0;(0,jt.cY)("Bot detected but kept for tracking",{category:(null==r?void 0:r.botType)||"UNKNOWN",confidence:e})}(0,jt.cY)("Installing early form network interceptors"),function(){try{je()}catch(e){(0,jt.AO)("Failed installing early network interceptors",e)}}(),(0,jt.cY)("Initializing cookie consent tracking"),Dt(),(0,jt.cY)("Initializing visibility handling"),Ci=()=>{(async function(){try{const e="visible"===document.visibilityState;(0,jt.cY)("Visibility changed to: "+(e?"visible":"hidden")),e?((await Bn.isSessionValid()).isValid?((0,jt.cY)("Session valid, resuming tracking"),Bn.resumeTracking(),Be()):((0,jt.cY)("Session invalid, creating new session"),await Bn.handleSessionTimeout()),Bn.updateActivity()):((0,jt.cY)("Tab hidden, pausing tracking"),Bn.pauseTracking(),Ke(),await j())}catch(e){(0,jt.AO)("Error handling visibility change",e)}})().catch(e=>(0,jt.AO)("Visibility handler error",e))},document.addEventListener("visibilitychange",Ci,{passive:!0}),(0,jt.cY)("Initializing SPA tracking"),function(){try{xr&&(xr.disconnect(),xr=null),Rr=location.href,window.__cst_spa_last_url=Rr,xr=new MutationObserver(jr);const e=T(async()=>{location.href!==Rr&&((0,jt.cY)(`Route change detected: ${Rr} -> ${location.href}`),await Yt())},100);return Dr=e,window.addEventListener("popstate",e),window.addEventListener("pushState",e),window.addEventListener("replaceState",e),Ct("pushState"),Ct("replaceState"),xr.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),(0,jt.cY)("SPA tracking initialized",{initialLastUrl:Rr}),xr}catch(e){throw(0,jt.AO)("Error setting up SPA tracking",e),e}}(),(0,jt.cY)("Initializing scroll tracking"),Ze(),(0,jt.cY)("Initializing click tracking"),ot(),(0,jt.cY)("Initializing enhanced form tracking"),qe(),(0,jt.cY)("Initializing input tracking"),Et(),(0,jt.cY)("Initializing custom dropdown tracking"),Mr||(Mr=!0,Yr=async e=>{try{if(!(e.target instanceof HTMLElement))return;const t=e.target.closest(Lr);if(!t)return;if(!Ot(t))return;await Lt(t)}catch(e){(0,jt.AO)("Error handling custom dropdown selection",e)}},document.addEventListener("click",Yr,{capture:!0,passive:!0}),Pr=async e=>{try{const t=e.key;if("Enter"!==t&&" "!==t)return;if(!(e.target instanceof HTMLElement))return;const n=e.target.closest(Lr);if(!n)return;if(!Ot(n))return;await Lt(n)}catch(e){(0,jt.AO)("Error handling keyboard dropdown selection",e)}},document.addEventListener("keydown",Pr,{capture:!0}),(0,jt.cY)("Initialized custom dropdown tracking")),(0,jt.cY)("Initializing video tracking (HTML5, Vimeo, Wistia, Loom)"),ct(),ut(),pt(),St(),(0,jt.cY)("Loading YouTube API and watcher"),hr(),ur||(ur=setInterval(()=>{document.querySelectorAll('iframe[src*="youtube.com/embed/"]').length>0&&(dr||(lr||hr(),fr()))},2e3)),(0,jt.cY)("Initializing activity tracking"),U(),(0,jt.cY)("KLRR_CST_FX] Initialization complete");const a=()=>{try{(0,jt.cY)("Ensuring click tracking after DOM ready"),nt()}catch(e){(0,jt.AO)("Error reinitializing click tracking",e)}try{window.__cstEnhancedFormTrackingInit&&((0,jt.cY)("Rescanning forms after DOM ready"),Ve())}catch(e){(0,jt.AO)("Error rescanning forms",e)}try{(0,jt.cY)("Ensuring input tracking after DOM ready"),Et()}catch(e){(0,jt.AO)("Error ensuring input tracking",e)}},s=()=>{(0,jt.cY)("KLRR_CST_FX] scheduleInteractionEnsure()"),a(),setTimeout(a,500),setTimeout(a,2e3)},c=(()=>{let e=!1;return()=>{e||(e=!0,setTimeout(()=>{e=!1,s()},50))}})();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{(0,jt.cY)("KLRR_CST_FX] DOMContentLoaded"),s()},{once:!0}):((0,jt.cY)("KLRR_CST_FX] DOM already ready -> ensuring interactions immediately"),s()),document.addEventListener("readystatechange",()=>{(0,jt.cY)("KLRR_CST_FX] readystatechange:",document.readyState),"complete"===document.readyState&&c()});try{if("undefined"!=typeof MutationObserver){const e=document.documentElement||document;new MutationObserver(e=>{let t=!1;for(const n of e)n.addedNodes.forEach(e=>{(e instanceof HTMLBodyElement||e instanceof HTMLHtmlElement)&&(t=!0)}),n.removedNodes.forEach(e=>{(e instanceof HTMLBodyElement||e instanceof HTMLHtmlElement)&&(t=!0)});t&&((0,jt.cY)("DOM root changed, reapplying interaction hooks"),c())}).observe(e,{childList:!0})}}catch(e){(0,jt.AO)("Error setting up DOM replacement monitor",e)}if(window.addEventListener("online",()=>{(0,jt.cY)("Network online, retrying failed events"),(0,jt.cY)("KLRR_CST_FX] online -> retryFailedEvents()"),j()},{passive:!0}),window.addEventListener("load",()=>{(0,jt.cY)("Page load complete, retrying failed events"),(0,jt.cY)("KLRR_CST_FX] window load -> retryFailedEvents()"),j()},{passive:!0}),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&((0,jt.cY)("Document hidden, flushing queued batches"),x({force:!0}))},{passive:!0}),window.addEventListener("pagehide",()=>{(0,jt.cY)("Pagehide event, flushing queued batches"),x({force:!0})},{passive:!0}),Un.cleanupOldStorage(),await j(),"undefined"!=typeof window&&(null===(i=window.Shopify)||void 0===i?void 0:i.shop)){(0,jt.cY)("Shopify storefront detected, enabling cart attribute handling."),await async function(){try{(0,jt.cY)("Performing initial Shopify cart enrichment check");const e=Bn.getState(),t={_cst_sessionId:e.session.id,_cst_clientId:e.clientId,_cst_pageViewId:e.page.id,_cst_userId:e.userId,_cst_visitorId:e.visitorId};let n=null;try{const e=await A(fetch("/cart.js",{method:"GET",credentials:"same-origin",headers:{Accept:"application/json"}}),2e3).catch(()=>null);(null==e?void 0:e.ok)&&(n=await e.json().catch(()=>null))}catch(e){return void(0,jt.cY)("Initial cart read failed, skipping enrichment.",e)}if(!n)return void(0,jt.cY)("No cart snapshot available on init, skipping enrichment.");if(!n.token)return void(0,jt.cY)("Cart token missing on init, skipping enrichment write.");if(0===(Array.isArray(n.items)?n.items.length:0))return void(0,jt.cY)("Cart empty on init, skipping enrichment write.");const i=n.attributes||{};if(i._cst_sessionId===t._cst_sessionId&&i._cst_clientId===t._cst_clientId)return void(0,jt.cY)("Cart already enriched on init, skipping write.");await Ht({force:!0}),(0,jt.cY)("Initial Shopify cart enrichment complete.")}catch(e){(0,jt.AO)("Initial cart enrichment failed",e)}}(),"undefined"!=typeof document&&document.addEventListener("mousedown",e=>{const t=e.target;t.closest&&t.closest('[name="checkout"], [name="add"], .shopify-payment-button, [href*="/checkout"]')&&Ht({force:!0}).catch(()=>{})},{capture:!0,passive:!0}),document.addEventListener("cart:updated",()=>{(0,jt.cY)("Cart change event detected, resetting enrichment latch and queueing update.");try{e=!1}catch(e){}Ht({force:!1})},{passive:!0});let e=!1,t=0;const n=24,i=Bn.addTickListener(async()=>{try{if(t+=1,t<n)return;if(t=0,e)return;if("visible"!==document.visibilityState)return;if("undefined"!=typeof navigator&&!1===navigator.onLine)return;await Ht({force:!1})&&(e=!0,(0,jt.cY)("Cart enrichment confirmed; polling dormant"))}catch(e){(0,jt.AO)("Unified polling tick failed",e)}});try{const e=()=>{try{i&&i()}catch(e){}};window.addEventListener("beforeunload",e,{once:!0}),window.addEventListener("pagehide",e,{once:!0})}catch(e){}}(0,jt.cY)("CST initialization complete - all handlers initialized");const l=Bn.getState();(0,jt.cY)("Final initialization state:",{sessionValid:l.session.isValid,isTracking:l.session.isValid,sessionId:l.session.id,pageId:l.page.id}),eo=!0}catch(e){throw(0,jt.AO)("CST initialization error:",e),console.error("KLRR_CST_FX] Initialization error",e),eo=!1,e}}()}var i;return Promise.resolve()}var Wt,jt,Ft,Ut,zt={53:(e,t,n)=>{function i(){const e=performance.now();h.push(e),h.length>d&&h.shift()}function r(){const e=performance.now(),t=window.scrollY||document.documentElement.scrollTop;if(p>0){const n=e-p;if(n>16){const e=Math.abs(t-g);f.push(e/n),f.length>u&&f.shift()}}p=e,g=t}function o(){if(null!==v)return v;try{const e=navigator.userAgent.toLowerCase(),t=document.createElement("canvas"),n=t.getContext("webgl")||t.getContext("experimental-webgl");if(!n)return v={detected:!1},v;const i=n.getExtension("WEBGL_debug_renderer_info"),r=i&&n.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",o=r.toLowerCase();return o.includes("google swiftshader")?(v={detected:!0,reason:"google_swiftshader_renderer"},(0,l.cY)("Canvas/UA mismatch: Google SwiftShader renderer"),v):o.includes("swiftshader")&&!e.includes("headless")?(v={detected:!0,reason:"swiftshader_without_headless_ua"},(0,l.cY)("Canvas/UA mismatch: SwiftShader detected without headless UA"),v):o.includes("angle")&&e.includes("linux")&&(o.includes("direct3d")||o.includes("d3d"))?(v={detected:!0,reason:"angle_d3d_on_linux"},(0,l.cY)("Canvas/UA mismatch: Direct3D ANGLE on Linux"),v):r&&"unknown"!==r&&(o.includes("llvmpipe")||o.includes("mesa")&&o.includes("software"))&&!e.includes("linux")?(v={detected:!0,reason:"software_renderer_non_linux_ua"},(0,l.cY)("Canvas/UA mismatch: Software renderer with non-Linux UA"),v):(v={detected:!1},v)}catch(e){return(0,l.cY)("Error checking Canvas/UA mismatch",e),v={detected:!1},v}}function a(e){if(e.length<m)return null;const t=e.length,n=e.reduce((e,t)=>e+t,0)/t;return e.map(e=>Math.pow(e-n,2)).reduce((e,t)=>e+t,0)/t}function s(e){if(e.length<5)return!0;let t=0;for(let n=2;n<e.length;n++){const i=e[n-1]-e[n-2],r=e[n]-e[n-1];(Math.sign(i)!==Math.sign(r)||Math.abs(r-i)>.1)&&t++}return t>.2*e.length}function c(){const e={};if(h.length>=m){const t=[];for(let e=1;e<h.length;e++)t.push(h[e]-h[e-1]);const n=a(t);null!==n&&(e.clickTiming={intervalVariance:Math.round(100*n)/100,sampleCount:h.length})}if(f.length>=m){const t=a(f);null!==t&&(e.scrollVelocity={velocityVariance:Math.round(1e4*t)/1e4,hasAcceleration:s(f),sampleCount:f.length})}const t=o();return t&&(e.canvasUaMismatch=t),e}n.d(t,{AE:()=>r,WI:()=>i,checkCanvasUaMismatch:()=>o,vj:()=>c});var l=n(154);const d=20,u=30,m=3;let h=[],f=[],p=0,g=0,v=null},154:(e,t,n)=>{n.d(t,{AO:()=>debugError,cY:()=>debugLog});const i=()=>{};"undefined"!=typeof localStorage&&localStorage.removeItem("debugMode");const debugLog=i,debugError=i},330:e=>{e.exports=JSON.parse('{"rE":"2.0.0.20260106"}')}},qt={};e.d=(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.d(Wt={},{default:()=>no}),jt=e(154),e(330);const Vt="https://dd0gkif4bl.execute-api.us-east-2.amazonaws.com/Prod",Bt="production".toLowerCase(),Kt="development"===Bt||"staging"===Bt;["development","staging","production","test"].includes(Bt);const Gt=Kt?"https://dev-api.klrr.org/send":"https://api.klrr.org/send",Xt=Kt?"cstm-dev.js":"cstm.js",Jt=Kt?"https://dev-api.klrr.org/shop":"https://api.klrr.org/shop",Qt=Kt?"https://dev-api.klrr.org/pixel-context":"https://api.klrr.org/pixel-context";Kt&&(0,jt.cY)("CST Configuration:",{environment:Bt,apiEndpoint:Gt,buildTime:(new Date).toISOString()});const Zt="cst_fp",en="cst_tiid",tn=576e3,nn="cst_sid",rn="cst_sid_time",on="cst_active_time",an="cst_session_entry_url",sn="cst_session_entry_referrer",cn="cst_pvid",ln="cst_pvid_ts",dn="cst_aq_context",un="cst_acquisition_context",mn=240,hn=144e5,fn=18e5,pn="cst_cfp",gn="cst_loc",vn="cst_pending_batches",yn={exact:["hubspotutk","pardot","visitor_id","pi_opt_in","_mkto_trk","_shopify_y","_shopify_s","_shopify_essential_","_orig_referrer","_shopify_sa_p","_shopify_sa_t","shopify_ga","_landing_page","cart","cart_ts","cart_currency","_tracking_consent","_shopify_analytics","_shopify_marketing","is_shopify_merchant","_fbp","_fbc","_ga","_gid","_gcl_aw","_gcl_au","_gcl_gs","FPID","FPLC","FPAU","FPGSID","_ttp","_tt_enable_cookie","ttwid","odin_tt","tta_attr_id_mirror","_pinterest_ct_rt","_pinterest_ct_ua","_pinterest_sess","_pinterest_cm","_pin_unauth","_derived_epik","_uetsid","_uetvid","_clck","_clsk","MUID","__kla_id","_kla_id","klaviyo","sc_at","li_fat_id","li_fat_id_s","bcookie","bscookie","lidc","personalization_id","guest_id","edgebucket","_rdt_uuid","reddit_session","__attentive_id","__attentive_cco","attntv_mstore_email","_ps_session","irclickid","awc","zanpid","rmStore","cto_bundle","ajs_anonymous_id","ajs_user_id","sparrow_id","_hjid","fs_uid","_fs_uid","distinct_id","_cio_id","_lo_uid","_dyjsession","_dy_soct","_dy_geo","_dy_df_geo","mprtcl-v4_","t_gid","t_pt_gid","obuid","s_ecid","AMCV_","s_cc","s_sq","OptanonConsent","eupubconsent-v2","zaraz-consent","transcy_tracking_token"],prefix:["_ga_","_gac_","ttcsid","__sc_","sc_","act_","_drip_","intercom-","mp_","_hjSessionUser_","ph_","amplitude_id_","pendo_","_hp2_","_attn","_dy_","mprtcl-","AMCV_","AMCVS_","kndctr_","_biz_","_cq_","__adroll","_db_"]},wn=[/pass(word)?/i,/^pw$/i,"secret","token","apikey","api_key","auth","authentication","bearer","jwt",/credit[_-]?card/i,/card[_-]?number/i,/^cc[_-]?/i,"cvv","cvc","ccv",/expir(y|ation)/i,/card[_-]?holder/i,"billing","payment",/account[_-]?number/i,"routing","swift","iban","ssn",/social[_-]?security/i,/tax[_-]?id/i,"sin","passport","drivers_license","driving_license","national_id","birth_date","birthdate","dob","health_id","insurance_id","medical_record","patient_id","private","secure","hidden","confidential",/sensitive/i,"_token","csrf","xsrf","nonce",/document[_-]?upload/i,/id[_-]?upload/i,/passport[_-]?upload/i],bn={5:!1,10:!1,15:!1,20:!1,25:!1,30:!1,35:!1,40:!1,45:!1,50:!1,55:!1,60:!1,65:!1,70:!1,75:!1,80:!1,85:!1,90:!1,95:!1,100:!1};let Sn,Tn=!1,_n=null;const In="cst_loc_cache";!function(e){e[e.CLOSED=0]="CLOSED",e[e.OPEN=1]="OPEN",e[e.HALF_OPEN=2]="HALF_OPEN"}(Ft||(Ft={})),new WeakSet,Ut=e(53);const kn=(e,t)=>t,An={botHint:kn(0,"bH"),suspectedBot:kn(0,"sB"),confidence:kn(0,"cf"),category:kn(0,"ct"),signals:kn(0,"sg"),detectorVersion:kn(0,"dV"),behavioral:kn(0,"bv"),scrollVelocity:kn(0,"sV"),velocityVariance:kn(0,"vV"),hasAcceleration:kn(0,"hA"),sampleCount:kn(0,"sC"),canvasUaMismatch:kn(0,"cU"),detected:kn(0,"dt"),fingerprint:kn(0,"fp"),fingerprintConfidence:kn(0,"fC"),cfp:kn(0,"cf_"),visitorId:kn(0,"vI"),hint_internal_restart:kn(0,"hIR"),hint_payment_gateway_return:kn(0,"hPG"),inherited_context:kn(0,"iC"),clientId:kn(0,"cI"),userId:kn(0,"uI"),sessionId:kn(0,"sI"),pageViewId:kn(0,"pI"),timestamp:kn(0,"ts"),start:kn(0,"st"),activeTime:kn(0,"aT"),lastActivityTime:kn(0,"lA"),timeSinceLastActive:kn(0,"tS"),eventType:kn(0,"eT"),eventId:kn(0,"eI"),events:kn(0,"ev"),session:kn(0,"ss"),entryUrl:kn(0,"eU"),entryReferrer:kn(0,"eR"),navigationType:kn(0,"nT"),visibilityState:kn(0,"vS"),historyLength:kn(0,"hL"),consentGranted:kn(0,"cG"),pageView:kn(0,"pV"),referrer:kn(0,"rf"),url:kn(0,"ur"),pathname:kn(0,"pn"),title:kn(0,"tt"),location:kn(0,"lo"),city:kn(0,"cy"),region:kn(0,"rg"),country:kn(0,"co"),ip:kn(0,"ip"),cookies:kn(0,"ck"),marketingTrackers:kn(0,"mT"),isBot:kn(0,"iB"),timeout:kn(0,"to"),time:kn(0,"tm"),cookieEnabled:kn(0,"cE"),doNotTrack:kn(0,"dN"),language:kn(0,"lg"),timezoneOffset:kn(0,"tO"),userAgent:kn(0,"uA")},En=async(e,t)=>{var n;try{await Bn.ensureInitialized();const i=Bn.getState();if("UNKNOWN - STATE"===i.session.id)throw new Error("State not initialized - cannot build batch");Bn.isSessionValid().isValid||(0,jt.cY)("buildUserBatch - Session is invalid, batch may be outdated");const r=_(),o={sessionId:i.session.id,pageViewId:i.page.id,timestamp:r,activeTime:i.session.activeTimeInSeconds,pageActiveTime:i.page.activeTimeInSeconds},a=[];t?a.push({[An.eventId]:B(),[An.eventType]:t,[An.time]:_(),[An.activeTime]:i.page.activeTimeInSeconds,[An.timeout]:!1}):e&&a.push(e);const s=Bn.getBotDetection(),c=(0,Ut.vj)(),l=s?{[An.suspectedBot]:s.isBot,[An.category]:s.botType,[An.confidence]:s.confidence,[An.signals]:s.signals,[An.detectorVersion]:"bot-detector-v1",[An.behavioral]:Object.keys(c).length>0?c:void 0}:Object.keys(c).length>0?{[An.suspectedBot]:!1,[An.detectorVersion]:"bot-detector-v1",[An.behavioral]:c}:void 0,d=i.session.hint_internal_restart,u=i.session.hint_payment_gateway_return,m=i.session.inherited_context,h=Bn.getFingerprintConfidence();return{[An.clientId]:i.clientId,[An.userId]:i.userId,[An.visitorId]:i.visitorId,[An.fingerprint]:i.fingerprint,[An.timestamp]:o.timestamp,[An.eventType]:t||(null==e?void 0:e.eventType)||"heartbeat",[An.isBot]:null!==(n=null==s?void 0:s.isBot)&&void 0!==n&&n,[An.botHint]:l,[An.fingerprintConfidence]:h,[An.session]:{[An.sessionId]:o.sessionId,[An.start]:i.session.startTimestamp,[An.entryUrl]:i.session.entryUrl||i.page.url,[An.entryReferrer]:i.session.entryReferrer||void 0,[An.cookies]:i.parsedCookies,[An.marketingTrackers]:i.parsedMarketingTrackers,[An.activeTime]:o.activeTime,[An.lastActivityTime]:i.session.lastActivityTime,[An.location]:i.location,[An.consentGranted]:null===i.cookieConsent?void 0:i.cookieConsent,[An.navigationType]:i.session.navigationType,[An.visibilityState]:i.session.visibilityState,[An.timeSinceLastActive]:i.session.timeSinceLastActive,[An.historyLength]:i.session.historyLength,[An.hint_internal_restart]:d,[An.hint_payment_gateway_return]:u,[An.inherited_context]:m,[An.pageView]:{[An.pageViewId]:o.pageViewId,[An.activeTime]:o.pageActiveTime,[An.referrer]:i.page.referrer,[An.lastActivityTime]:i.page.lastActivityTime,[An.url]:i.page.url,[An.pathname]:i.page.pathname,[An.title]:i.page.title,[An.start]:i.page.startTimestamp,[An.events]:a}}}}catch(e){throw(0,jt.AO)("Error in buildUserBatch",e),e}},On=new class{constructor(e){this.failures=0,this.lastFailureTime=0,this.isOpen=!1,this.config=e,setInterval(()=>{Date.now()-this.lastFailureTime>this.config.monitorInterval&&(this.failures=0)},this.config.monitorInterval)}isAllowed(){return!this.isOpen||Date.now()-this.lastFailureTime>this.config.resetTimeout&&(this.isOpen=!1,this.failures=0,!0)}recordSuccess(){this.failures=Math.max(0,this.failures-1)}recordFailure(){this.failures++,this.lastFailureTime=Date.now(),this.failures>=this.config.failureThreshold&&(this.isOpen=!0)}reset(){this.failures=0,this.lastFailureTime=0,this.isOpen=!1}}({failureThreshold:5,resetTimeout:3e4,monitorInterval:6e4});let Ln=0,Cn=null,Mn=0;const Yn=Math.max(1,15);let Pn=!1,Nn=!1;const xn=T(()=>{L()},200),Rn=1e3,Dn=vn;let $n=!1,Hn=null,Wn=null;const jn=function(e,t,n={}){let i=null,r=0;const{leading:o=!0,trailing:a=!0}=n;let s=!1;const c=function(...n){const c=Date.now();if(o&&!s)return s=!0,r=c,e.apply(this,n);r||!1!==o||(r=c);const l=t-(c-r);if(l<=0||l>t)return i&&(clearTimeout(i),i=null),r=c,e.apply(this,n);i||!1===a||(i=setTimeout(()=>function(t,n){r=!1===o?0:Date.now(),i=null,e.apply(t,n)}(this,n),l))};return c.cancel=function(){i&&(clearTimeout(i),i=null),r=0,s=!1},c}(async()=>{(0,jt.cY)("Activity detected, updating state"),await Bn.updateActivity()},5e3),Fn=()=>{Hn&&clearTimeout(Hn),Hn=setTimeout(()=>{(0,jt.cY)("Inactivity timeout reached, triggering session end"),Bn.handleSessionTimeout()},fn),jn()},Un=new class{setItem(e,t,n){const i="local"===e?localStorage:sessionStorage;try{return i.setItem(t,n),!0}catch(r){if(this.isQuotaError(r)){(0,jt.cY)(`Storage quota exceeded for ${e}Storage. Cleaning up.`),this.performEmergencyCleanup();try{return i.setItem(t,n),!0}catch(i){if("local"===e)try{return sessionStorage.setItem(t,n),!0}catch(e){return!1}}}return!1}}getItem(e,t){try{return("local"===e?localStorage:sessionStorage).getItem(t)}catch(e){return null}}removeItem(e,t){try{("local"===e?localStorage:sessionStorage).removeItem(t)}catch(e){}}isQuotaError(e){return e instanceof Error&&("QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name||"QuotaExceededError"===e.name)}performEmergencyCleanup(){this.cleanupOldStorage()}cleanupOldStorage(){const e=I();Object.keys(localStorage).forEach(t=>{if(t!==dn&&t!==un){if(t.startsWith("cst_")||t.startsWith("pageview_")){const n=localStorage.getItem(t);n&&!isNaN(Number(n))&&e-Number(n)>2592e6&&localStorage.removeItem(t)}}else q(e)})}},zn=["shopify.com","paypal.com","stripe.com","squareup.com","afterpay.com","klarna.com","affirm.com","adyen.com"],qn={ip:null,network:null,city:null,region:null,country:null,postal:null,latitude:null,longitude:null,in_eu:null,ipCompany:null,isp:null,asn:null,org:null,timezone:null};class Vn{addTickListener(e){return this.tickListeners.add(e),()=>{try{this.tickListeners.delete(e)}catch(e){}}}constructor(){this.initialized=!1,this.initialDataSent=!1,this.isInitializing=!1,this.state={parsedCookies:{},parsedMarketingTrackers:{},lastCookieUpdate:0,clientId:"",visitorId:"",userId:"",cookieConsent:null,fingerprintConfidence:null,fingerprint:{userAgent:"",language:"",timezoneOffset:0,doNotTrack:"",cfp:"",cookieEnabled:!1},location:qn,session:{id:"",startTime:0,startTimestamp:"",lastActivityTime:0,activeTimeInSeconds:0,entryUrl:"",entryReferrer:"",isValid:!1,hint_internal_restart:!1,hint_payment_gateway_return:!1,inherited_context:void 0,navigationType:void 0,visibilityState:void 0,timeSinceLastActive:void 0,historyLength:void 0},page:{id:"",startTime:0,startTimestamp:"",lastActivityTime:0,activeTimeInSeconds:0,url:"",pathname:"",title:"",referrer:"",isValid:!1},botDetection:null},this.tickListeners=new Set,this.isTracking=!1,this.unifiedTimer=null,this.lastSaveTimestamp=0,this.stateChanged=!1,this.unifiedTicks=0,this.lastUserActivityTs=0,this.isHandlingSessionOperation=!1,this.formSubmitTimeout=null,this.cleanupHandler=()=>this.cleanup(),this.formSubmitHandler=e=>this.handleFormSubmit(e),"undefined"!=typeof window&&(window.addEventListener("beforeunload",this.cleanupHandler),window.addEventListener("unload",this.cleanupHandler),document.addEventListener("submit",this.formSubmitHandler,!0)),"test"!=="production".toLowerCase()&&this.initialize().catch(e=>(0,jt.AO)("Error in constructor initialization",e))}publishContext(){try{const e={clientId:this.state.clientId||"",userId:this.state.userId||"",sessionId:this.state.session.id||"",pageViewId:this.state.page.id||"",timestamp:(new Date).toISOString()};globalThis.KLEERR_CST_CONTEXT=e}catch(e){}}setBotDetection(e){this.state.botDetection=e||null}getBotDetection(){return this.state.botDetection||null}setFingerprintConfidence(e){this.state.fingerprintConfidence=e}getFingerprintConfidence(){return this.state.fingerprintConfidence}clearAllIntervals(){this.unifiedTimer&&(clearInterval(this.unifiedTimer),this.unifiedTimer=null),this.formSubmitTimeout&&(clearTimeout(this.formSubmitTimeout),this.formSubmitTimeout=null)}sanitizeCookieData(e){return"string"!=typeof e?String(e||""):e.replace(/[\x00-\x1F\x7F]/g,"").substring(0,1e3)}getNavigationType(){var e;try{if("undefined"!=typeof performance&&"function"==typeof performance.getEntriesByType){const t=performance.getEntriesByType("navigation");if(t&&(null===(e=t[0])||void 0===e?void 0:e.type))return t[0].type}const t="undefined"!=typeof performance?performance.navigation:null;if(t&&"number"==typeof t.type)switch(t.type){case 1:return"reload";case 2:return"back_forward";default:return"navigate"}}catch(e){}}getInitialVisibilityState(){try{if("undefined"!=typeof document&&document.visibilityState)return document.visibilityState}catch(e){}}getHistoryLength(){try{if("undefined"!=typeof history&&"number"==typeof history.length)return history.length}catch(e){}}getLastActivityFromStorage(){try{const e=Un.getItem("local","cst_last_activity_time");if(!e)return null;const t=k(e);return Number.isFinite(t)?t:null}catch(e){return null}}captureSessionStartSignals(e,t=I()){const n=this.getNavigationType(),i=this.getInitialVisibilityState(),r=this.getHistoryLength(),o="number"==typeof e?e:this.getLastActivityFromStorage();let a;if("number"==typeof o&&Number.isFinite(o)){const e=t-o;e>=0&&(a=e)}return{navigationType:n,visibilityState:i,timeSinceLastActive:a,historyLength:r}}captureEntryPoint(){const e=e=>this.sanitizeCookieData(e||"");return{url:(()=>{try{if("undefined"!=typeof location&&location.href)return e(location.href)}catch(e){}return""})(),referrer:(()=>{try{const t=window.__cst_spa_last_url;if(t)return e(t);if("undefined"!=typeof document&&document.referrer)return e(document.referrer)}catch(e){}return""})()}}getStoredActiveSeconds(e,t){const n=e=>{if(!e)return 0;const t=Number(e);return Number.isFinite(t)&&t>=0?t:0};return Math.max(n(e),n(t))}safeHostname(e){if(!e)return"";try{return new URL(e).hostname||""}catch(t){const n=e.match(/^[a-zA-Z]+:\/\/([^/?#]+)/);return(null==n?void 0:n[1])||""}}hasAttributionParams(e){if(!e)return!1;try{return!!e.includes("utm_")||/(gclid|fbclid|ttclid|msclkid|kmi)=/i.test(e)}catch(e){return!1}}retrySaveActiveTime(){try{if(!this.state.session.id)return;const e=`${on}_${this.state.session.id}`,t=this.state.session.activeTimeInSeconds.toString(),n=this.state.session.lastActivityTime.toString();Un.setItem("session",e,t),Un.setItem("local",e,t),Un.setItem("local","cst_last_activity_time",n),(0,jt.cY)(`Active time retry successful: ${t}s`)}catch(e){(0,jt.AO)("Active time retry failed",e)}}handleFormSubmit(e){this.formSubmitTimeout&&clearTimeout(this.formSubmitTimeout),this.formSubmitTimeout=setTimeout(()=>{(0,jt.cY)("Form submitted, refreshing state for new cookies"),this.refreshState().catch(e=>(0,jt.AO)("Error refreshing state after form submit",e)),this.formSubmitTimeout=null},500)}isStoredSessionValid(e){const t=I();return!(t-e.startTime>hn||t-e.lastActivityTime>fn)}async initializeSession(){var e,t;(0,jt.cY)("Initializing session");const n=this.loadStoredSession();if(console.log(`DEBUG: initializeSession storedSession=${n?n.id:"null"}\n`),n){if(this.isStoredSessionValid(n)){(0,jt.cY)("Loaded existing session",n),this.state.session=Object.assign(Object.assign(Object.assign({},n),this.captureSessionStartSignals(n.lastActivityTime)),{hint_internal_restart:null!==(e=n.hint_internal_restart)&&void 0!==e&&e,hint_payment_gateway_return:null!==(t=n.hint_payment_gateway_return)&&void 0!==t&&t,inherited_context:n.inherited_context});const i=`${on}_${this.state.session.id}`,r=Un.getItem("session",i),o=Un.getItem("local",i);return this.state.session.activeTimeInSeconds=this.getStoredActiveSeconds(r,o),this.isTracking=!0,this.state.session.isValid=!0,this.startUnifiedTimer(),void await this.initializePageView()}(0,jt.cY)("Session invalid, creating new session"),await this.handleSessionEnd("manual")}(0,jt.cY)("No existing session, creating new session"),await this.createNewSession()}loadStoredSession(){try{const e=n(nn)||Un.getItem("local",nn),t=n(rn)||Un.getItem("local",rn),i=Un.getItem("local","cst_last_activity_time"),r=n(an)||Un.getItem("local",an)||"",o=n(sn)||Un.getItem("local",sn)||"",a=this.captureEntryPoint(),s=`${on}_${e}`,c=Un.getItem("session",s),l=Un.getItem("local",s);if(!e||!t)return(0,jt.cY)("No stored session found"),null;if(!i)return(0,jt.cY)("No stored last activity time; stored session invalid"),null;const d=this.getStoredActiveSeconds(c,l);let u,m;try{u=k(t)}catch(e){return(0,jt.cY)("Invalid stored session start time format",t),null}try{m=k(i)}catch(e){return(0,jt.cY)("Invalid stored last activity time",i),null}if(!Number.isFinite(m)||m<=0)return(0,jt.cY)("Parsed last activity time invalid",m),null;const h=new Date(u).toISOString();return(0,jt.cY)("Found stored session",{sessionId:e,startTimeRaw:t,activeTimeInSeconds:d}),{id:e,startTime:u,startTimestamp:h,lastActivityTime:m,activeTimeInSeconds:d,entryUrl:r?this.sanitizeCookieData(r):a.url,entryReferrer:o?this.sanitizeCookieData(o):a.referrer,isValid:!0,hint_internal_restart:!1,hint_payment_gateway_return:!1,inherited_context:void 0}}catch(e){return(0,jt.AO)("Error loading stored session",e),null}}isSessionValid(){if(!this.state.session.isValid)return(0,jt.cY)("Session invalid: already marked as invalid"),{isValid:!1};const e=I(),t=e-this.state.session.startTime,n=e-this.state.session.lastActivityTime;return(0,jt.cY)(`Session age: ${t/1e3}s, Inactivity time: ${n/1e3}s`),t>hn?((0,jt.cY)("Session invalid: Max duration exceeded"),this.handleSessionEnd("maxDuration"),{isValid:!1,reason:"maxDuration"}):n>fn?((0,jt.cY)("Session invalid: Inactivity timeout"),this.handleSessionEnd("timeout"),{isValid:!1,reason:"timeout"}):{isValid:!0}}async createNewSession(){if((0,jt.cY)("createnewssession called"),this.isHandlingSessionOperation)(0,jt.cY)("Session operation in progress, skipping new session creation");else{this.isHandlingSessionOperation=!0;try{(0,jt.cY)("creating new session");const e=this.captureEntryPoint(),t=this.getLastActivityFromStorage();await this.handleSessionEnd("manual"),this.clearSessionStorage();const n=I(),i=_(),r=this.captureSessionStartSignals(t,n),o=q(n),a=this.safeHostname(e.url),s=this.safeHostname(e.referrer),c=a?b(a):"",l=s?b(s):"",d=!(!e.referrer||!e.referrer.trim()),u=this.hasAttributionParams(e.url),m=!!l&&!!c&&l===c,h=!!l&&zn.some(e=>l===e);let f,p=!1,g=!1,v=!1,y=!1;h&&o?(f=o,p=!0):m&&o?(f=o,g=!0):u||d&&!m?v=!0:y=!0;const w=Object.assign({id:`s_${B()}`,startTime:n,startTimestamp:i,lastActivityTime:n,activeTimeInSeconds:0,entryUrl:e.url,entryReferrer:e.referrer,isValid:!0,hint_internal_restart:g,hint_payment_gateway_return:p,inherited_context:null!=f?f:void 0},r);if(v?(function(e){var t;try{const n={sessionId:e.sessionId,entryUrl:e.entryUrl,entryReferrer:null!==(t=e.entryReferrer)&&void 0!==t?t:null,version:e.version||"v1",createdAt:e.createdAt};localStorage.setItem(dn,JSON.stringify(n))}catch(e){(0,jt.AO)("Error saving acquisition context",e)}}({sessionId:w.id,entryUrl:e.url,entryReferrer:d?e.referrer:null,createdAt:i,version:"v1"}),(0,jt.cY)("Persisted acquisition context for new arrival",{sessionId:w.id,hasReferrer:d,hasAttributionParams:u})):y&&V(),(0,jt.cY)("Creating new session",w.id),this.state.session=w,this.isTracking=!0,this.state.session.isValid=!0,this.persistSession(w),this.startUnifiedTimer(),U(),Ke(),Be(),await this.initializePageView(),this.publishContext(),!this.isInitializing){this.initialDataSent=!1,this.initialDataSent=!0,(0,jt.cY)("Sending initial data for new session",w.id);try{await C()}catch(e){(0,jt.AO)("Error sending initial data for new session",e),this.initialDataSent=!1}}}finally{this.isHandlingSessionOperation=!1}}}persistSession(e){try{if(!e.id||e.startTime<=0)return void(0,jt.AO)("Invalid session data, cannot persist");const n=a();t(nn,e.id,mn,{domain:n,path:"/",sameSite:"Lax"}),t(rn,e.startTimestamp,mn,{domain:n,path:"/",sameSite:"Lax"}),Un.setItem("local",nn,e.id),Un.setItem("local",rn,e.startTimestamp);const i=this.sanitizeCookieData(e.entryUrl);t(an,i,mn,{domain:n,path:"/",sameSite:"Lax"});const r=this.sanitizeCookieData(e.entryReferrer);r?t(sn,r,mn,{domain:n,path:"/",sameSite:"Lax"}):t(sn,"",-1,{domain:n,path:"/",sameSite:"Lax"}),Un.setItem("local",an,i),r?Un.setItem("local",sn,r):Un.removeItem("local",sn)}catch(e){(0,jt.AO)("Error persisting session",e)}}async handleSessionEnd(e){try{(0,jt.cY)(`Ending session due to: ${e}`),this.state.session.isValid=!1,this.isTracking=!1,this.clearAllIntervals(),Ke(),this.saveActiveTime(),await j(),this.clearSessionStorage(),Un.cleanupOldStorage(),this.publishContext()}catch(e){(0,jt.AO)("Error ending session",e)}}static getInstance(){return Vn.instance||(Vn.instance=new Vn),Vn.instance}getState(){return I()-this.state.lastCookieUpdate>3e5&&this.refreshState().catch(e=>(0,jt.AO)("Error in getState refresh",e)),this.state}setCookieConsent(e){this.state.cookieConsent=e}async refreshState(){var e;try{const{allCookies:c,marketingTrackers:l}=i(document.cookie),d={},u={};for(const[e,t]of Object.entries(r(c)))d[e]=this.sanitizeCookieData(t);for(const[e,t]of Object.entries(o(l)))u[e]=this.sanitizeCookieData(t);const m=await async function(){var e;const t=function(){try{return K(n(Kn)||n(Gn)||localStorage.getItem(Gn)||null)}catch(e){return null}}();try{let i=n(Zt)||null;if(!i)try{"undefined"!=typeof localStorage&&(i=localStorage.getItem(Zt))}catch(e){i=null}const r=K(i);if(r){if((0,jt.cY)("Using stored visitor ID from cookies:",r),t&&G(t),function(e){if(!e||"string"!=typeof e)return!0;const t=e.trim();return!t||!t.startsWith("fp_")||28!==t.length}(r))return await J(t);const n=null!==(e=function(e){if(!e||"string"!=typeof e)return null;if(e.startsWith("fp_")&&28===e.length){const t=e.charAt(15);if("h"===t)return"high";if("m"===t)return"medium";if("l"===t)return"low"}return null}(r))&&void 0!==e?e:null;return n?(X(r),Bn.setFingerprintConfidence(n),r):await J(t)}return await J(t)}catch(e){return(0,jt.AO)("Error in getVisitorId:",e),Bn.setFingerprintConfidence(null),"UNKNOWN"}}()||"",h=await async function(){const e=n(pn);if(e)return e;const i=await s(),r=a();return t(pn,i,576e3,{domain:r,path:"/",sameSite:"Lax"}),i}()||"",f=await async function(){try{const e=function(){var e,t;const i=Date.now();try{const t=localStorage.getItem(In);if(t){const n=JSON.parse(t);if((null==n?void 0:n.data)&&"number"==typeof n.cachedAt&&i-n.cachedAt<36e5)return Object.assign(Object.assign({},n.data),{source:null!==(e=n.data.source)&&void 0!==e?e:"cache"});localStorage.removeItem(In)}}catch(e){(0,jt.cY)("Unable to read location from localStorage",e)}const r=n(gn);if(r)try{const e=JSON.parse(r);return Object.assign(Object.assign({},e),{source:null!==(t=e.source)&&void 0!==t?t:"cache"})}catch(e){}return null}();if(e)return e;let i=null,r=!1;try{const e=function(){try{const e=new URL(Gt);return e.pathname="/geo",e.toString()}catch(e){return Gt.replace(/\/[^/]*$/,"/geo")}}();(0,jt.cY)("Fetching geo from:",e);const t=new AbortController,n=setTimeout(()=>t.abort(),3e3);try{const n=await fetch(e,{method:"GET",signal:t.signal,credentials:"omit",cache:"no-store"});if(!n.ok)throw new Error(`Geo endpoint returned ${n.status}`);i=await n.json(),(0,jt.cY)("Geo data from Cloudflare:",null==i?void 0:i.country)}finally{clearTimeout(n)}}catch(e){(0,jt.cY)("Primary geo endpoint failed, trying fallback:",e);try{const e=new AbortController,t=setTimeout(()=>e.abort(),5e3);try{const t=await fetch("https://ipapi.co/json/",{signal:e.signal});t.ok&&(i=await t.json(),r=!0,(0,jt.cY)("Geo data from fallback:",null==i?void 0:i.country_name))}finally{clearTimeout(t)}}catch(e){return(0,jt.AO)("Fallback geo endpoint also failed:",e),null}}if(!i)return null;const o={ip:i.ip||null,network:i.network||null,city:i.city||null,region:i.region||null,country:r?i.country_name||null:i.country||null,postal:i.postal||i.postalCode||null,latitude:"number"==typeof i.latitude?i.latitude:null,longitude:"number"==typeof i.longitude?i.longitude:null,in_eu:"boolean"==typeof i.in_eu?i.in_eu:null,ipCompany:i.ip_company||null,isp:i.isp||null,asn:i.asn?String(i.asn):null,org:i.org||i.asOrganization||null,timezone:i.timezone||null,httpProtocol:i.httpProtocol||null,tlsVersion:i.tlsVersion||null,tlsCipher:i.tlsCipher||null,colo:i.colo||null,clientTcpRtt:"number"==typeof i.clientTcpRtt?i.clientTcpRtt:null,tlsClientExtensionsSha1:i.tlsClientExtensionsSha1||null,tlsClientHelloLength:"number"==typeof i.tlsClientHelloLength?i.tlsClientHelloLength:null,clientAcceptEncoding:i.clientAcceptEncoding||null,requestPriority:i.requestPriority||null,source:r?"ipapi":"cloudflare"};return function(e){var n;const i=Date.now();try{localStorage.setItem(In,JSON.stringify({data:e,cachedAt:i}))}catch(e){(0,jt.cY)("Unable to store location in localStorage",e)}const r={ip:e.ip,network:null,city:e.city,region:e.region,country:e.country,postal:e.postal,latitude:e.latitude,longitude:e.longitude,in_eu:e.in_eu,ipCompany:null,isp:null,asn:null,org:null,timezone:e.timezone,httpProtocol:null,tlsVersion:null,tlsCipher:null,colo:null,clientTcpRtt:null,tlsClientExtensionsSha1:null,tlsClientHelloLength:null,clientAcceptEncoding:null,requestPriority:null,source:null!==(n=e.source)&&void 0!==n?n:"cache"};t(gn,JSON.stringify(r),60)}(o),o}catch(e){return(0,jt.AO)("Error fetching location:",e),null}}()||qn;this.state=Object.assign(Object.assign({},this.state),{parsedCookies:d,parsedMarketingTrackers:u,lastCookieUpdate:I(),clientId:Q()||"",visitorId:m,userId:Z()||"",fingerprint:{userAgent:navigator.userAgent||"",language:navigator.language||"",timezoneOffset:(new Date).getTimezoneOffset(),doNotTrack:null!==(e=navigator.doNotTrack)&&void 0!==e?e:"",cfp:h,cookieEnabled:navigator.cookieEnabled},location:f}),(0,jt.cY)("State refreshed",this.state),this.publishContext()}catch(e){(0,jt.AO)("Error refreshing state",e)}}getSessionId(){return this.state.session.id}getActiveTime(){return this.state.session.activeTimeInSeconds}async updateActivity(){try{(0,jt.cY)("updateActivity called");const e=I();if(!e||e<0)return void(0,jt.AO)("Invalid timestamp in updateActivity");if(!this.state.session.isValid)return void await this.createNewSession();this.state.session.lastActivityTime=e,this.state.page.lastActivityTime=e,this.lastUserActivityTs=e,this.stateChanged=!0,(0,jt.cY)(`Updated session last activity time to ${new Date(e).toISOString()}`),this.unifiedTimer||this.startUnifiedTimer()}catch(e){(0,jt.AO)("Error updating activity",e)}}async initialize(){var e,t;if(this.initialized)(0,jt.cY)("StateManager already initialized");else{if(this.isInitializing){(0,jt.cY)("StateManager is already initializing, waiting...");let e=0;for(;this.isInitializing&&e<50;)await new Promise(e=>setTimeout(e,100)),e++;if(this.initialized)return void(0,jt.cY)("StateManager initialization completed while waiting")}(0,jt.cY)("Initializing StateManager"),this.isInitializing=!0;try{let n=3,i=!1;for(;n>0&&!i;){await this.refreshState();const r=this.getState();r.userId&&r.clientId&&(null===(e=r.fingerprint)||void 0===e?void 0:e.userAgent)?(i=!0,(0,jt.cY)("State validation successful during initialization")):(n--,(0,jt.cY)(`State validation failed, retries left: ${n}`,{hasUserId:!!r.userId,hasClientId:!!r.clientId,hasUserAgent:!!(null===(t=r.fingerprint)||void 0===t?void 0:t.userAgent)}),n>0&&await new Promise(e=>setTimeout(e,200)))}if(i||(0,jt.AO)("Failed to initialize state with valid data after retries"),await this.initializeSession(),this.state.session.isValid&&Be(),this.startUnifiedTimer(),this.initialized=!0,(0,jt.cY)("StateManager initialization completed successfully"),this.publishContext(),!this.initialDataSent){this.initialDataSent=!0,(0,jt.cY)("Sending initial data after initialization");try{await C()}catch(e){(0,jt.AO)("Error sending initial data after initialization",e),this.initialDataSent=!1}}x()}catch(e){throw this.initialized=!1,(0,jt.AO)("Error initializing StateManager",e),e}finally{this.isInitializing=!1}}}stopTracking(){(0,jt.cY)("Stopping all tracking"),this.isTracking=!1,this.clearAllIntervals(),this.saveActiveTime()}pauseTracking(){(0,jt.cY)("Pausing tracking"),this.isTracking=!1,this.clearAllIntervals(),this.saveActiveTime()}async resumeTracking(){(0,jt.cY)("Resuming tracking"),this.isSessionValid().isValid?(this.isTracking=!0,this.startUnifiedTimer()):await this.createNewSession()}saveActiveTime(){try{if(!this.state.session.id)return;const e=`${on}_${this.state.session.id}`,t=this.state.session.activeTimeInSeconds.toString(),n=this.state.session.lastActivityTime.toString();Un.setItem("session",e,t),Un.setItem("local",e,t),Un.setItem("local","cst_last_activity_time",n),(0,jt.cY)(`Active time saved: ${t}s`)}catch(e){(0,jt.AO)("Error saving active time",e),e instanceof Error&&"QuotaExceededError"===e.name&&(Un.cleanupOldStorage(),this.retrySaveActiveTime())}}clearSessionStorage(){if(!this.state.session.isValid){const e=new Date(0).toUTCString(),t=a();document.cookie=`${nn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${rn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${an}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${sn}=; expires=${e}; path=/; SameSite=Lax; Secure`,t&&(document.cookie=`${nn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${rn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${an}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${sn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`);const n=`${on}_${this.state.session.id}`;Un.removeItem("session",n),Un.removeItem("local",n),Un.removeItem("local",nn),Un.removeItem("local",rn)}}async endCurrentPageViewAndStartNew(e){(0,jt.cY)("Starting page view transition",{currentSession:this.state.session,currentPage:this.state.page});const t=Object.assign({},this.state.session);await this.endCurrentPageView(),this.state.session=t;const{isValid:n}=this.isSessionValid();if(!n)return(0,jt.cY)("Session became invalid during page transition, creating new session"),void await this.createNewSession();await this.initializePageView(e),(0,jt.cY)("Page view transition complete",{session:this.state.session,newPage:this.state.page})}async endCurrentPageView(){try{(0,jt.cY)("Ending current pageview",{currentSession:this.state.session,currentPage:this.state.page});const e=this.state.session.activeTimeInSeconds;this.stopPageTimeTracking(),this.clearPageViewStorage(),this.state.session.activeTimeInSeconds=e,this.saveActiveTime()}catch(e){(0,jt.AO)("Error ending page view",e)}}async initializePageView(e){if((0,jt.cY)("Initializing page view",{currentSession:this.state.session,pageState:e,initialDataSent:this.initialDataSent}),"UNKNOWN - STATE"!==this.state.page.id&&await this.endCurrentPageView(),!this.state.session.id){(0,jt.cY)("Session state lost during page initialization, attempting recovery");const e=this.loadStoredSession();if(!e||!this.isStoredSessionValid(e))return void await this.createNewSession();this.state.session=e}const t=I(),n=_();this.state.page=Object.assign({id:`pv_${B()}`,startTime:t,startTimestamp:n,lastActivityTime:t,activeTimeInSeconds:0,url:location.href,pathname:location.pathname,title:document.title,referrer:document.referrer,isValid:!0},e),this.persistPageViewState(),this.unifiedTimer||this.startUnifiedTimer(),this.publishContext(),(0,jt.cY)("Page view initialized, initial data sending will be handled separately")}persistPageViewState(){try{const e=a();t(cn,this.state.page.id,mn,{domain:e,path:"/",sameSite:"Lax"}),t(ln,encodeURIComponent(this.state.page.startTimestamp),mn,{domain:e,path:"/",sameSite:"Lax"}),Un.setItem("local",cn,this.state.page.id),Un.setItem("local",ln,this.state.page.startTimestamp),this.savePageViewTime()}catch(e){(0,jt.AO)("Error persisting page view state",e)}}stopPageTimeTracking(){this.savePageViewTime()}savePageViewTime(){try{if(!this.state.page.id)return;const e=`pageview_time_${this.state.page.id}`,t=`pageview_last_active_${this.state.page.id}`;Un.setItem("session",e,this.state.page.activeTimeInSeconds.toString()),Un.setItem("session",t,this.state.page.lastActivityTime.toString()),(0,jt.cY)(`Page view time saved: ${this.state.page.activeTimeInSeconds}s`)}catch(e){(0,jt.AO)("Error saving page view time",e)}}async sendPageViewEvent(){const e=await En(null,"initial");await M(e)}clearPageViewStorage(){const e=new Date(0).toUTCString(),t=a();document.cookie=`${cn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${ln}=; expires=${e}; path=/; SameSite=Lax; Secure`,t&&(document.cookie=`${cn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${ln}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`),Un.removeItem("local",cn),Un.removeItem("local",ln),Un.removeItem("session",`pageview_time_${this.state.page.id}`),Un.removeItem("session",`pageview_last_active_${this.state.page.id}`)}cleanup(){try{(0,jt.cY)("Starting StateManager cleanup"),this.clearAllIntervals(),this.tickListeners.clear(),z(),Mi(),"undefined"!=typeof window&&(window.removeEventListener("beforeunload",this.cleanupHandler),window.removeEventListener("unload",this.cleanupHandler),document.removeEventListener("submit",this.formSubmitHandler,!0)),this.clearPageViewStorage(),this.clearSessionStorage(),this.stopTracking(),Ke(),this.isTracking=!1,this.initialized=!1,this.isHandlingSessionOperation=!1,this.initialDataSent=!1,this.state.botDetection=null,j().catch(e=>(0,jt.AO)("Error clearing queued events during cleanup",e)),(0,jt.cY)("StateManager cleanup completed")}catch(e){(0,jt.AO)("Error during StateManager cleanup",e)}}async handleSessionTimeout(){if(this.isHandlingSessionOperation)(0,jt.cY)("Session operation already in progress, skipping timeout handler");else{this.isHandlingSessionOperation=!0;try{(0,jt.cY)("Session timeout triggered"),this.saveActiveTime(),Ke(),this.stopTracking(),this.state.session.isValid=!1}finally{this.isHandlingSessionOperation=!1}}}async refreshStateManually(){(0,jt.cY)("Manual state refresh requested"),await this.refreshState()}async ensureInitialized(){if(!this.initialized){if(this.isInitializing){let e=0;for(;this.isInitializing&&e<50;)await new Promise(e=>setTimeout(e,100)),e++}this.initialized||await this.initialize()}}startUnifiedTimer(){if(this.unifiedTimer)return;const e=I();if(this.lastSaveTimestamp=this.lastSaveTimestamp||e,this.state.session.id&&0===this.state.session.activeTimeInSeconds){const e=`${on}_${this.state.session.id}`;try{const t=Un.getItem("session",e);t&&!isNaN(Number(t))&&(this.state.session.activeTimeInSeconds=Number(t))}catch(e){(0,jt.AO)("Error loading saved active time",e)}}this.unifiedTimer=setInterval(async()=>{try{if(!this.isTracking)return;const{isValid:e,reason:t}=this.isSessionValid();if(!e)return(0,jt.cY)(`Session invalid during timer tick: ${t}`),void(t||await this.handleSessionEnd("manual"));if("visible"!==document.visibilityState)return;if(I()-this.lastUserActivityTs>6e4)return;const n=5;this.state.session.activeTimeInSeconds=Math.min(this.state.session.activeTimeInSeconds+n,86400),this.state.page.activeTimeInSeconds=Math.min(this.state.page.activeTimeInSeconds+n,86400);const r=I();this.state.session.lastActivityTime=r,this.state.page.lastActivityTime=r,this.stateChanged=!0,this.unifiedTicks++;try{for(const e of Array.from(this.tickListeners))try{e(this.unifiedTicks)}catch(e){(0,jt.AO)("Unified tick listener error",e)}}catch(e){}if(5e3*this.unifiedTicks>=288e5)return(0,jt.cY)("Max timer runtime reached; restarting unified timer"),this.unifiedTicks=0,this.clearAllIntervals(),void this.startUnifiedTimer();if(this.unifiedTicks%60==0)try{const{marketingTrackers:e}=i(document.cookie),t=o(e);for(const[e,n]of Object.entries(t))this.state.parsedMarketingTrackers[e]=this.sanitizeCookieData(n);this.state.lastCookieUpdate=r}catch(e){(0,jt.AO)("Unified timer marketing refresh error",e)}this.unifiedTicks%180==0&&this.refreshState().catch(e=>(0,jt.AO)("Unified timer state refresh error",e)),this.unifiedTicks%4320==0&&Un.cleanupOldStorage(),r-this.lastSaveTimestamp>=3e4&&(this.saveActiveTime(),this.savePageViewTime(),this.lastSaveTimestamp=r,this.stateChanged=!1)}catch(e){(0,jt.AO)("Unified timer error",e),this.clearAllIntervals(),this.startUnifiedTimer()}},5e3)}}const Bn=Vn.getInstance(),Kn="_shopify_y",Gn="_cst_shopifyVisitorId",Xn=new WeakMap,Jn={MAX_FIELD_LENGTH:1e3,MAX_FORM_FIELDS:50,DEDUPLICATION_WINDOW:3e3,DISALLOWED_FIELD_TYPES:["file","password","image","video"],CONFIDENCE_THRESHOLD:.7,MAX_LEARNED_PATTERNS:100},Qn={formsFound:0,formsSubmitted:0,buttonSubmissions:0,formsMissed:0,universalSuccess:0,providerSuccess:0,providerTriggers:{},errors:[],duplicatesBlocked:0};"undefined"!=typeof window&&(window.__cstFormMetrics=Qn);const Zn=new Map,ei=new Map,ti=Jn.DEDUPLICATION_WINDOW,ni=new Map,ii=new Map,ri=new Map,oi=new Set(["email","phone","firstname","first_name","lastname","last_name","name","company","subject","message"]),ai=new Set,si=new Map,ci=new Set,li=new WeakMap;let di=0,ui=0,mi=null;const hi=new Set(["booking.scheduled","appointment.scheduled","meeting.scheduled","appointment booked","appointment.confirmed","booking_confirmed","booking.succeeded"]),fi=new Set(["calendar.view","view","load","impression"]),pi=["contact","customer","email","phone","first_name","firstname","last_name","lastname"],gi=[{re:/https?:\/\/(?:[^\/]+\.)?backend\.leadconnectorhq\.com\/appengine\/appointment\b/i,provider:"leadconnector",signal:"appointment"},{re:/https?:\/\/(?:[^\/]+\.)?backend\.leadconnectorhq\.com\/calendars\/booking-analytics\/event\/submit\b/i,provider:"leadconnector",signal:"booking_analytics_submit"}],vi={hubspot:{name:"HubSpot",trigger:e=>e.includes("hsforms.com")||e.includes("forms.hubspot.com")||null!==document.querySelector(".hs-form, .hbspt-form, form[id^='hsForm_']"),selectors:[".hs-form","form[id^='hsForm_']",".hbspt-form"],events:["hsFormCallback","message"],submitPatterns:["/hsforms.com/submissions/","/forms.hubspot.com/"],active:!1},gravity:{name:"Gravity Forms",trigger:e=>e.includes("admin-ajax.php")||null!==document.querySelector(".gform_wrapper, #gform_1, [data-formid]"),selectors:[".gform_wrapper form","#gform_1, #gform_2, #gform_3, #gform_4, #gform_5, #gform_6, #gform_7, #gform_8, #gform_9","form[data-formid]",".gform_body"],events:["gform_confirmation_loaded","gform_post_render"],submitPatterns:["/wp-admin/admin-ajax.php"],active:!1},contactform7:{name:"Contact Form 7",trigger:e=>null!==document.querySelector(".wpcf7-form"),selectors:[".wpcf7-form","form.wpcf7-form"],events:["wpcf7submit","wpcf7mailsent"],submitPatterns:["/wp-json/contact-form-7/"],active:!1},typeform:{name:"Typeform",trigger:e=>e.includes("typeform.com")||null!==document.querySelector("[data-tf-widget]"),selectors:["[data-tf-widget]",".typeform-embed",'iframe[src*="typeform.com"]'],events:["tf-widget-loaded"],submitPatterns:["/forms/","typeform.com"],active:!1},mailchimp:{name:"Mailchimp",trigger:e=>e.includes("mailchimp.com")||null!==document.querySelector(".mc-embedded-subscribe-form"),selectors:[".mc-embedded-subscribe-form",'form[action*="mailchimp.com"]'],events:[],submitPatterns:["/subscribe/post"],active:!1},formstack:{name:"Formstack",trigger:e=>e.includes("formstack.com")||null!==document.querySelector(".fsForm"),selectors:[".fsForm",'form[action*="formstack.com"]'],events:[],submitPatterns:["/forms/"],active:!1},jotform:{name:"JotForm",trigger:e=>e.includes("jotform.com")||null!==document.querySelector(".jotform-form"),selectors:[".jotform-form",'form[action*="jotform.com"]'],events:[],submitPatterns:["/submit/"],active:!1},ninjaforms:{name:"Ninja Forms",trigger:e=>null!==document.querySelector(".ninja-forms-form"),selectors:[".ninja-forms-form",".nf-form-cont form"],events:["nfFormReady","nfFormSubmitResponse","nfFormSubmitted"],submitPatterns:["/wp-admin/admin-ajax.php"],active:!1},wpforms:{name:"WPForms",trigger:e=>null!==document.querySelector(".wpforms-form"),selectors:[".wpforms-form","form.wpforms-form"],events:["wpformsFormSubmitSuccess","wpformsAjaxSubmit","wpforms_submit_success"],submitPatterns:["/wp-admin/admin-ajax.php"],active:!1},elementor:{name:"Elementor Forms",trigger:e=>null!==document.querySelector(".elementor-form"),selectors:[".elementor-form","form.elementor-form"],events:["form_submit_success"],submitPatterns:["/wp-admin/admin-ajax.php"],active:!1},gohighlevel:{name:"Go High Level",trigger:e=>null!==document.querySelector(".ghl-form-wrap, .form-builder--wrap, #_builder-form, .hl_form-builder--main, .c-form"),selectors:[".ghl-form-wrap input, .ghl-form-wrap form",".form-builder--wrap input, .form-builder--wrap form","#_builder-form input, #_builder-form form",".hl_form-builder--main input, .hl_form-builder--main form",".c-form input, .c-form form"],events:[],submitPatterns:["leadconnector","gohighlevel","/funnels/","/forms/"],active:!1}},yi={inProgress:!1,completed:!1,lastAttemptAt:0},wi=(new Map,{submitted:["onformsubmitted","submitted","onformsubmit","submission"],ready:["onformready","ready","formready"],complete:["formsubmissioncomplete","complete","success"]}),bi="__cstWrapped",Si="__cstOriginal",Ti=[new RegExp(Gt.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"),/google-analytics\.com/i,/googletagmanager\.com/i,/facebook\.com\/tr/i,/hotjar\.com/i,/mixpanel\.com/i,/segment\.com/i,/amplitude\.com/i,/leadconnectorhq\.com\/calendars\/booking-analytics/i,/gohighlevel\.com\/calendars\/booking-analytics/i,/hscollectedforms\.net\/collected-forms/i],_i=[/https?:\/\/(?:[^\/]+\.)?hsforms\.com\/submissions\/v\d+\/public\/submit\//i,/https?:\/\/(?:[^\/]+\.)?forms\.hubspot\.com\/submissions\/v\d+\/public\/submit\//i,/https?:\/\/api\.hsforms\.com\/submissions\/v\d+\/integration\/submit\//i,/https?:\/\/forms\.hsforms\.com\/submissions\/v\d+\/public\/submit\/formsnext\//i,/https?:\/\/forms\.hsforms\.com\/submissions\/v\d+\/public\/submit\/legacy\//i,/https?:\/\/(?:[^\/]+\.)?hubspot\.com\/.*\/meetings?\//i,/https?:\/\/meetings\.hubspot\.com\//i,/https?:\/\/api\.hubapi\.com\/.*\/meetings?\//i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=gform_ajax_submit/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=gform_submit/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=gf_submit/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php(?:.*action=gform_ajax_submit|.*gform_ajax=)/i,/https?:\/\/(?:[^\/]+\.)?wp-json\/contact-form-7\/v1\/contact-forms\/\d+\/feedback/i,/https?:\/\/api\.typeform\.com\/forms\/[A-Za-z0-9_-]+\/responses/i,/https?:\/\/list-manage\.com\/subscribe\/post/i,/https?:\/\/(?:[^\/]+\.)?formstack\.com\/forms\//i,/https?:\/\/submit\.jotform\.com\/form\/\d+/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=ninja_forms_ajax_submit/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=wpforms_submit/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=elementor_pro_forms_ajax/i,/\/wp-admin\/admin-ajax\.php.*action=.*form.*submit/i,/\/api\/.*\/forms\/.*\/submit$/i,/\/forms\/.*\/submissions$/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=wpcf7_submit/i,/https?:\/\/(?:[^\/]+\.)?wp-admin\/admin-ajax\.php\?action=wpforms_submit/i,/https?:\/\/docs\.google\.com\/forms\/d\/[A-Za-z0-9_-]+\/formResponse/i,/https?:\/\/(?:[^\/]+\.)?wufoo\.com\/forms\/[A-Za-z0-9_-]+\/def\/field/i,/https?:\/\/(?:[^\/]+\.)?surveymonkey\.com\/r\/[A-Za-z0-9_-]+/i,/https?:\/\/forms\.office\.com\/Pages\/ResponsePage\.aspx/i,/https?:\/\/(?:[^\/]+\.)?constantcontact\.com\/signup\/signup\.do/i,/https?:\/\/(?:[^\/]+\.)?leadconnectorhq\.com\//i,/https?:\/\/(?:[^\/]+\.)?gohighlevel\.com\//i],Ii=[/hubspot/i,/hsforms/i,/hs-/i,/\.hs\./i,/meeting/i,/calendar/i,/schedule/i,/book/i],ki=new Set,Ai=new WeakSet;let Ei=!1,Oi=null;const Li=3e4;let Ci=null;const Mi=()=>{Ci&&(document.removeEventListener("visibilitychange",Ci),Ci=null)};let Yi=Object.assign({},bn),Pi=null,Ni=0,xi=!1,Ri=null,Di=0,$i=!1,Hi=!1,Wi=Object.assign({},{clickTrackingMode:"standard",autoEnhanceClicks:!0,alwaysIncludeClasses:!1,includeDataAnlInStandard:!1}),ji="",Fi=!1,Ui=null,zi=null,qi=new WeakSet;const Vi=new Map,Bi=new WeakSet,Ki=new WeakMap;let Gi=null;const Xi=new Map,Ji=new WeakSet,Qi=new WeakMap,Zi=new Map,er=new Set,tr=new WeakSet,nr=new WeakMap,ir=new Map,rr=new Set,or=new WeakSet,ar=new WeakMap;let sr=!1,cr=null,lr=!1,dr=!1,ur=null;const mr=()=>dr,hr=()=>{if(lr)return;const e=document.createElement("script");e.src="https://www.youtube.com/iframe_api",e.async=!0,e.onload=()=>{(0,jt.cY)("YouTube API script loaded")},e.onerror=()=>{(0,jt.AO)("Failed to load YouTube API script"),lr=!1,dr=!1,setTimeout(hr,1e3)};const t=document.getElementsByTagName("script")[0];(null==t?void 0:t.parentNode)&&(t.parentNode.insertBefore(e,t),(0,jt.cY)("YouTube API script loading"),lr=!0)},fr=()=>!(!window.YT||!window.YT.Player||(dr=!0,(0,jt.cY)("YouTube API loaded successfully"),Tt(!0),ur&&(clearInterval(ur),ur=null),0));window.onYouTubeIframeAPIReady=()=>{fr()};const pr=new Map,gr=new WeakMap,vr=20,yr=100;let wr=null;const br=e=>{try{const t=e;t.id=t.id||`yt-${B()}`;let n=new URL(t.src);const i=n.href,r=n.searchParams.get("enablejsapi"),o=n.searchParams.get("origin"),a=window.location.origin;return"1"===r&&o===a||(n.searchParams.set("enablejsapi","1"),n.searchParams.set("origin",a),n.searchParams.set("widget_referrer",window.location.href)),n.href!==i&&(t.src=n.toString(),(0,jt.cY)("youtube iframe configured:",{id:t.id,src:t.src})),t}catch(t){return(0,jt.AO)("Error adding ID and enablejsapi to YouTube iframe",t),e}},Sr=new WeakSet,Tr=new WeakMap;let _r=null,Ir=null,kr=!1,Ar=null,Er=null,Or=null;const Lr=["[role='option']","li[role='option']","[aria-selected]","[data-value]",".multiselect__option",".select2-results__option",".MuiAutocomplete-option",".rc-select-item-option"].join(", "),Cr=["[role='combobox']","[role='listbox']","[aria-haspopup='listbox']",".multiselect",".select2",".MuiAutocomplete-root",".rc-select"].join(", ");let Mr=!1,Yr=null,Pr=null;const Nr=10;let xr=null,Rr=location.href,Dr=null;const $r="__cstSpaHistoryWrapped";let Hr=new WeakSet;const Wr=T(()=>{try{Ve()}catch(e){(0,jt.AO)("Error in debounced enhanced form rescan",e)}},100),jr=T(e=>{try{const t={depth:0,processedNodes:new Set,startTime:performance.now()};if(location.href!==Rr)return(0,jt.cY)("Mutation observer detected route change",{lastUrl:Rr,currentUrl:location.href}),void Yt();!function(e,t){if(performance.now()-t.startTime>100)(0,jt.cY)("Mutation processing time limit exceeded");else if(t.depth>=Nr)(0,jt.cY)("Maximum mutation depth reached");else for(const n of e)"childList"===n.type&&Array.from(n.addedNodes).forEach(e=>{t.processedNodes.has(e)||(t.processedNodes.add(e),t.processedNodes.size>100?(0,jt.cY)("Maximum nodes per mutation reached"):e instanceof HTMLElement&&Mt(e,t))})}(e,t)}catch(e){(0,jt.AO)("Error in mutation observer callback",e)}},100);class Fr{static detectUserAgent(){const e=[],t=navigator.userAgent;return t?this.UA_PATTERNS.some(e=>e.test(t))&&e.push("suspicious_user_agent"):e.push("missing_user_agent"),e}static detectNavigatorProps(){const e=[];return navigator.languages&&navigator.platform||e.push("missing_navigator_info"),e}static detectAutomationGlobals(){const e=[],t=window;for(const n of Array.from(this.AUTOMATION_PROPERTIES))(n in t||n in document)&&e.push(`automation_global:${n}`);return e}static detectWebDriver(){return navigator.webdriver?["navigator_webdriver"]:[]}static detectBrowserFeatures(){const e=[];try{void 0!==window.localStorage&&void 0!==window.sessionStorage||e.push("no_storage");const t=document.createElement("canvas"),n=t.getContext("webgl")||t.getContext("experimental-webgl");if(n){const t=n.getExtension("WEBGL_debug_renderer_info"),i=t?n.getParameter(t.UNMASKED_RENDERER_WEBGL):"";/Headless|SwiftShader/i.test(i)&&e.push("headless_renderer")}0===(window.outerWidth||window.outerHeight)&&e.push("zero_window_size")}catch(t){(0,jt.cY)("Browser feature check error",t),e.push("feature_check_error")}return e}static async detectPermissions(){const e=[];if(navigator.permissions)try{const t=await navigator.permissions.query({name:"notifications"});"denied"===Notification.permission&&"prompt"===t.state&&e.push("notif_permission_mismatch")}catch(e){(0,jt.cY)("Permissions check error",e)}return e}static getConnectionSignalHints(){const e=[];try{const t=Bn.getState(),n=(null==t?void 0:t.location)||null;if(!n)return e;n.httpProtocol&&"HTTP/2"!==n.httpProtocol&&"h3"!==n.httpProtocol&&e.push(`conn:http_protocol:${n.httpProtocol}`),n.tlsVersion&&"TLSv1.3"!==n.tlsVersion&&e.push(`conn:tls_version:${n.tlsVersion}`),"HTTP/2"!==n.httpProtocol||n.requestPriority||e.push("conn:missing_h2_priority"),n.tlsClientExtensionsSha1&&e.push(`conn:tls_ext_sha1:${n.tlsClientExtensionsSha1}`),"number"==typeof n.tlsClientHelloLength&&e.push(`conn:tls_hello_len:${n.tlsClientHelloLength}`),n.asn&&e.push(`conn:asn:${n.asn}`),n.colo&&e.push(`conn:colo:${n.colo}`)}catch(e){(0,jt.cY)("Connection signal hint extraction error",e)}return e}static async detect(){const e=[...this.detectUserAgent(),...this.detectNavigatorProps(),...this.detectAutomationGlobals(),...this.detectWebDriver(),...this.detectBrowserFeatures(),...await this.detectPermissions()],t=this.getConnectionSignalHints(),n=Math.min(e.length*this.SIGNAL_WEIGHT,this.MAX_CONFIDENCE),i=e.length>=this.MIN_SIGNALS_FOR_BOT,r=i?this.getBotType(e):void 0;return{isBot:i,confidence:n,signals:[...e,...t],botType:r}}static getBotType(e){return e.some(e=>e.startsWith("automation_global")||"navigator_webdriver"===e)?"AUTOMATION":e.includes("suspicious_user_agent")?"CRAWLER":e.includes("headless_renderer")?"HEADLESS":"UNKNOWN"}}Fr.UA_PATTERNS=[/\b(bot|crawler|spider|crawl)\b/i,/HeadlessChrome/i,/PhantomJS/i,/Selenium/i,/puppeteer/i,/chrome\-lighthouse/i,/Googlebot/i,/Bingbot/i,/YandexBot/i,/Baiduspider/i,/FacebookExternalHit/i,/Twitterbot/i,/Applebot/i,/AhrefsBot/i],Fr.AUTOMATION_PROPERTIES=new Set(["webdriver","_phantom","__nightmare","__selenium_evaluate","__webdriver_script_fn","__fxdriver_evaluate","__driver_evaluate","callPhantom","ChromeDriver"]),Fr.MIN_SIGNALS_FOR_BOT=2,Fr.MAX_CONFIDENCE=1,Fr.SIGNAL_WEIGHT=.33;let Ur=!1;const zr=[],qr=[],Vr="/sync",Br=new Map,Kr=[];let Gr=!1,Xr=!1,Jr=0;const Qr=/\[cst:[^\]]+\]/i,Zr=/\[cst:[^\]]+\]/gi;let eo=!1;const to="2.0.0.20260106";window.CST_VERSION=to,console.log("CST version:",to);try{if("undefined"!=typeof window){const e=window;e.__KLEERR_PIXEL_ENDPOINT||(e.__KLEERR_PIXEL_ENDPOINT=Jt)}}catch(e){(0,jt.AO)("Failed to seed pixel endpoint",e)}const CSTExport={initialize};if("undefined"!=typeof window&&"test"!=="production".toLowerCase()){const e=window;e.KLRR_CSTM_FX||(e.KLRR_CSTM_FX=CSTExport,(0,jt.cY)("KLRR_CST_FX] Global set: window.KLRR_CSTM_FX")),e.KLRR_CST_FX||(e.KLRR_CST_FX=e.KLRR_CSTM_FX,(0,jt.cY)("KLRR_CST_FX] Back-compat: window.KLRR_CST_FX → window.KLRR_CSTM_FX")),e.CST?(0,jt.cY)("KLRR_CST_FX] window.CST already defined; keeping existing alias"):(e.CST=e.KLRR_CSTM_FX,(0,jt.cY)("KLRR_CST_FX] Back-compat: window.CST → window.KLRR_CSTM_FX")),(0,jt.cY)("CST attempting auto-initialization"),initialize().catch(e=>{console.error("CST initialization failed:",e)})}const no=CSTExport;return Wt.default})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CST=e():this.CST=e();