var e;e=()=>(()=>{function e(t){var n,i=Sn[t];return void 0!==i?i.exports:(n=Sn[t]={exports:{}},bn[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,vn.AO)(`Failed to set cookie: ${e}`)}catch(e){(0,vn.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,vn.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===zn)try{s=JSON.parse(r)}catch(e){(0,vn.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(qn.exact.includes(e))return!0;for(const t of qn.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,vn.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===zn&&"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,vn.AO)(`Error converting value for key: ${e}`,t),[e,""]}}))}function o(e){return r(e)}function a(){try{if("undefined"==typeof window)return;if(Xn)return Gn;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 Xn=!0,Gn=void 0,Gn;const a=o.split(".");if(a.length<2)return Xn=!0,Gn=void 0,Gn;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,vn.cY)("Selected cookie domain",e),Xn=!0,Gn=e,Gn}catch(e){}}catch(e){}var e;return Xn=!0,Gn=void 0,Gn}function s(){try{return navigator.userAgent||""}catch(e){return""}}function c(e=s()){const t=e.match(/Version\/(\d+).*Safari/);return!!t&&parseInt(t[1],10)>=17}function l(e=s()){const t=e.match(/SamsungBrowser\/(\d+)/);return!!t&&parseInt(t[1],10)>=26}function d(e=s()){return c(e)||l(e)}async function u(){try{if(d())return"canvas-antifingerprint";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([m(),...e?[]:[f()]])).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 m(){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 f(){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 h(e,t){return!Number.isFinite(e)||t<=0?0:Math.round(e/t)*t}function p(e){return Number.isFinite(e)?Math.max(.5,.5*Math.round(e/.5)):1}function g(){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 v(){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 y(){return d()}function w(){try{const e=navigator.userAgent||"",t=/Edg\//.test(e),n=/OPR\//.test(e),i=/Firefox\//.test(e),r=/SamsungBrowser\//.test(e),o=/Safari\//.test(e)&&/Version\//.test(e)&&!/Chrome\//.test(e)&&!t&&!n,a=/Chrome\//.test(e)&&!t&&!n&&!r,s=function(){try{const e=navigator;return!(!(null==e?void 0:e.brave)||"function"!=typeof e.brave.isBrave)||Boolean(null==e?void 0:e.brave)}catch(e){return!1}}();return{engine:v(),isSafari:o,isBrave:s,isSamsungInternet:r,isFirefox:i,isChromium:a,isEdge:t,isOpera:n}}catch(e){return{engine:"unknown",isSafari:!1,isBrave:!1,isSamsungInternet:!1,isFirefox:!1,isChromium:!1,isEdge:!1,isOpera:!1}}}function b(){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 S(){if(y())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 T(e){return!e.includes("error")&&!e.includes("unsupported")&&"canvas-antifingerprint"!==e}function _(e){return!e.includes("error")&&"audio-unsupported"!==e&&"audio-antifingerprint"!==e}async function I(e,t,n){const i=await e();if(!n||!t(i))return{value:i,stable:null};const r=await e();return t(r)?{value:i,stable:i===r}:{value:i,stable:!1}}function k(){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""}}function A(){var e;try{return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platform)||""}catch(e){return""}}function E(){var e;try{return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.architecture)||""}catch(e){return""}}function O(e){return e.map(e=>"string"==typeof e?e:String(e)).join("|||")}async function L(){return await async function(){var e,t,n,i,r,o;if(Jn)return Jn.raw;try{const r=(new Date).toISOString(),o=w(),a=k(),s=A(),d=E(),m=h(screen.width,64),f=h(screen.height,64),v=p(window.devicePixelRatio),L=b(),M=(new Date).getTimezoneOffset(),Y=Array.isArray(navigator.languages)?navigator.languages.slice().sort().join(","):navigator.language||"",N=[`screen:${m}x${f}`,`depth:${screen.colorDepth}`,`dpr:${v}`,`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:${s}`,`arch:${d||"unknown"}`,`engine:${o.engine}`,`brands:${a}`,`lang:${Y}`,`tz:${L}`,`gamut:${g()}`],x=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"}}();await async function(){try{const e=null===document||void 0===document?void 0:document.fonts;if(!e||!e.ready||"function"!=typeof e.ready.then)return;await Promise.race([e.ready,new Promise(e=>setTimeout(e,300))])}catch(e){}}();const R=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"}}(),D=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"}}(),W=y(),H=o.isBrave,F={canvasStable:null,audioStable:null};let j="canvas-antifingerprint",U="audio-antifingerprint";if(!W){const e=await I(u,T,H);j=e.value,F.canvasStable=e.stable;const t=await I(S,_,H);U=t.value,F.audioStable=t.stable}const z={canvas:T(j)&&!1!==F.canvasStable,webgl:"no-webgl"!==x&&"webgl-error"!==x,fonts:"fonts-unsupported"!==R&&"font-detection-error"!==R&&"none"!==R,audio:_(U)&&!1!==F.audioStable,math:"math-unsupported"!==D,media:"media-error"!==$&&"no-media"!==$},V=[x,R,z.canvas?j:"canvas-unstable",z.audio?U:"audio-unstable",D,$],q=O(N),B=O(V),[K,G]=await Promise.all([C(q),C(B)]),X=P(K.slice(0,40)).slice(0,12),J=P(G.slice(0,40)).slice(0,12),Q=function(e){const t=[e.canvas,e.webgl,e.fonts,e.audio,e.math].filter(Boolean).length;return 5===t?"high":t>=3?"medium":"low"}(z),Z=`fp_${X}${"high"===Q?"h":"medium"===Q?"m":"l"}${J}`,ee=function(e){const t=[];return c()&&t.push("safari17_noise"),l()&&t.push("samsung_antifp"),!1===e.canvasStable&&t.push("canvas_inconsistent"),!1===e.audioStable&&t.push("audio_inconsistent"),{detected:t.length>0,reasons:t}}(F),te={screen:{width:m,height:f,colorDepth:screen.colorDepth||0,dpr:v},hardware:{cores:navigator.hardwareConcurrency||"unknown",memory:null!==(n=navigator.deviceMemory)&&void 0!==n?n:"unknown",touchPoints:null!==(i=navigator.maxTouchPoints)&&void 0!==i?i:0,touchEvent:"ontouchstart"in window},platform:{platform:navigator.platform||"unknown",uaPlatform:s,arch:d||"unknown",brands:a,engine:o.engine},timezone:{id:L,offset:M},colorGamut:g(),mediaCapabilities:$,webgl:x,fonts:R,math:D,canvas:j,audio:U};return Jn={raw:Z,stable:X,entropy:J,confidence:Q,signals:z,stability:F,browser:o,antiFingerprinting:ee,rawSignals:te,collectedAt:r},Z}catch(e){(0,vn.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),a=`fp_${n}l${i}`,s=w(),c=(new Date).toISOString(),l={canvasStable:null,audioStable:null},d={screen:{width:h(screen.width,64),height:h(screen.height,64),colorDepth:screen.colorDepth||0,dpr:p(window.devicePixelRatio)},hardware:{cores:navigator.hardwareConcurrency||"unknown",memory:null!==(r=navigator.deviceMemory)&&void 0!==r?r:"unknown",touchPoints:null!==(o=navigator.maxTouchPoints)&&void 0!==o?o:0,touchEvent:"ontouchstart"in window},platform:{platform:navigator.platform||"unknown",uaPlatform:A(),arch:E()||"unknown",brands:k(),engine:s.engine},timezone:{id:b(),offset:(new Date).getTimezoneOffset()},colorGamut:g(),mediaCapabilities:"media-error",webgl:"webgl-error",fonts:"font-detection-error",math:"math-unsupported",canvas:"canvas-error",audio:"audio-error"};return Jn={raw:a,stable:n,entropy:i,confidence:"low",signals:{canvas:!1,webgl:!1,fonts:!1,audio:!1,math:!1,media:!1},stability:l,browser:s,antiFingerprinting:{detected:!1,reasons:[]},rawSignals:d,collectedAt:c},a}}(),Jn}async function C(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,vn.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 P(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 M(e){return e?encodeURIComponent(e).replace(/'/g,"%27").replace(/"/g,"%22"):""}function Y(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 N(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 x(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 R(e,t){let n=null;return function(...i){n&&clearTimeout(n),n=setTimeout(()=>{n=null,e(...i)},t)}}function D(){return(new Date).toISOString()}function $(){return Date.now()}function W(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 H(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 F(e){const t=e.trim();if(!t)return"";if(/^https?:\/\//i.test(t))return t;try{if("undefined"!=typeof window&&window.location){const e=window.location.origin||"";if(e)return t.startsWith("/")?`${e}${t}`:`${e}/${t}`}}catch(e){}return t}function j(e){var t,n;const i=null===(t=null==e?void 0:e.page)||void 0===t?void 0:t.url;if(i&&i.trim())return i;try{if("undefined"!=typeof window&&window.location){const e=window.location.href||"";if(e.trim())return e;const t=F(window.location.pathname||"");if(t)return t}}catch(e){}const r=null===(n=null==e?void 0:e.page)||void 0===n?void 0:n.pathname;return r&&r.trim()?F(r):""}function U(e){var t,n;const i=(null===(t=null==e?void 0:e.page)||void 0===t?void 0:t.url)||"",r=(null===(n=null==e?void 0:e.page)||void 0===n?void 0:n.pathname)||"";return!i.trim()&&!r.trim()}function z(e){var t,n;return null!==(n=null!==(t=null==e?void 0:e[ei.session])&&void 0!==t?t:null==e?void 0:e.session)&&void 0!==n?n:{}}function V(e){var t,n;const i=z(e);return null!==(n=null!==(t=null==i?void 0:i[ei.pageView])&&void 0!==t?t:null==i?void 0:i.pageView)&&void 0!==n?n:{}}function q(e){try{const t=function(e){var t,n;try{const i=V(e),r=null!==(n=null!==(t=null==i?void 0:i[ei.url])&&void 0!==t?t:null==i?void 0:i.url)&&void 0!==n?n:"";return"string"==typeof r?r:String(r||"")}catch(e){return""}}(e);if(!B(t))return;const n=function(){try{if("undefined"!=typeof window&&window.location){if(window.location.href&&window.location.href.trim())return window.location.href;const e=window.location.pathname||"",t=window.location.origin||"";if(t&&e)return e.startsWith("/")?`${t}${e}`:`${t}/${e}`;if(e)return e}}catch(e){}return"about:blank"}();if(B(n))return;const i=z(e),r=V(e);r[ei.url]=n,r.url=n,e[ei.session]&&!e[ei.session][ei.pageView]&&(e[ei.session][ei.pageView]=r),e.session&&!e.session.pageView&&(e.session.pageView=r),i[ei.pageView]=r,i.pageView=r}catch(e){}}function B(e){const t=(e||"").trim().toLowerCase();return!t||"unknown - state"===t||"undefined"===t||"null"===t}function K(e){const t=[];return B(function(e){var t,n,i;try{const r=z(e),o=null!==(i=null!==(n=null!==(t=null==r?void 0:r[ei.sessionId])&&void 0!==t?t:null==r?void 0:r.sessionId)&&void 0!==n?n:null==r?void 0:r.id)&&void 0!==i?i:"";return"string"==typeof o?o:String(o||"")}catch(e){return""}}(e))&&t.push("sessionId"),B(function(e){var t,n,i;try{const r=V(e),o=null!==(i=null!==(n=null!==(t=null==r?void 0:r[ei.pageViewId])&&void 0!==t?t:null==r?void 0:r.pageViewId)&&void 0!==n?n:null==r?void 0:r.id)&&void 0!==i?i:"";return"string"==typeof o?o:String(o||"")}catch(e){return""}}(e))&&t.push("pageViewId"),t}function G(e){null==ri&&(ri=setTimeout(()=>{ri=null,J()},Math.max(100,e)))}function X(e,t){const n=ei.session,i=ei.pageView,r=ei.events,o=ei.sessionId,a=ei.pageViewId,s=ei.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 f=[s.id];let h=c[n][i][r].length;for(a++;a<e.length&&h<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),f.push(o.id),c.queuedAt.push(o.queuedAt),h=c[n][i][r].length,a++}l.push({merged:c,sourceIds:f})}}),l}async function J(e={}){var t;if(si)return(0,vn.cY)("Already sending, scheduling pending flush"),void(ci=!0);si=!0,ci=!1;try{do{ci=!1;const n=Boolean(e.force);if(!ni.isAllowed())return void(0,vn.cY)("Circuit breaker preventing send");const i=oe();if(!i.length)break;const r=Date.now();if(!(n||i.length>=ai||r-oi>=1e4)){const e=Math.max(100,1e4-(r-oi));(0,vn.cY)("Delaying send: thresholds not met",{remaining:e,queued:i.length}),G(e);break}n&&ri&&(clearTimeout(ri),ri=null);const o=X(i,ai);for(const{merged:e,sourceIds:n}of o){q(e);const i=K(e);if(i.length>0){(0,vn.AO)("Dropping queued batch with missing required context",{eventType:null!==(t=null==e?void 0:e[ei.eventType])&&void 0!==t?t:null==e?void 0:e.eventType,sourceBatchCount:n.length,missingFields:i});for(const e of n)ae(e)}else{if(!await se(e)){ni.recordFailure();break}for(const e of n)ae(e);ni.recordSuccess(),oi=Date.now()}}}while(ci)}catch(e){(0,vn.AO)("Error in sendQueuedBatches",e),ni.recordFailure()}finally{si=!1}}async function Q(){try{(0,vn.cY)("sendInitialData called");const e=await ti(null,"initial");q(e);const t=K(e);if(t.length>0)return(0,vn.AO)("Refusing to send initial batch with missing required context",{missingFields:t}),!1;try{let t;try{t=JSON.stringify(e)}catch(e){throw(0,vn.AO)("JSON serialization failed for initial data",e),e}const n=await fetch(CST_LAMBDA_ENDPOINT,{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,vn.cY)("sendInitialData sent successfully"),!0}catch(t){return(0,vn.AO)("Error in immediate initial data send",t),await se(e,!1)?((0,vn.cY)("sendInitialData retry succeeded"),!0):((0,vn.cY)("sendInitialData saving to storage after failed attempts"),re(e),li(),!1)}}catch(e){return(0,vn.AO)("Error sending initial data",e),!1}}async function Z(e){var t;try{q(e);const n=K(e);return n.length>0?((0,vn.AO)("Refusing to queue batch with missing required context",{eventType:null!==(t=null==e?void 0:e[ei.eventType])&&void 0!==t?t:null==e?void 0:e.eventType,missingFields:n}),!1):(re(e),li(),!0)}catch(e){return(0,vn.AO)("Error queueing data",e),!1}}async function ee(e){return Z(await ti(e))}function te(e,t={}){const n=re(e);return n&&t.triggerSend&&li(),n}function ne(e){e&&ae(e)}function ie(e){if(null==e?void 0:e.force)return J({force:!0});li()}function re(e){try{const t=oe(),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,vn.AO)("JSON serialization failed for batch storage",e)}return(0,vn.cY)(`Saved batch to storage. Total batches: ${t.length}`),n.id}catch(e){return(0,vn.AO)("Error saving batch to storage",e),null}}function oe(){try{const e=localStorage.getItem(Vn);return e?JSON.parse(e):[]}catch(e){return(0,vn.AO)("Error loading pending batches",e),[]}}function ae(e){try{const t=oe().filter(t=>t.id!==e);try{localStorage.setItem(Vn,JSON.stringify(t))}catch(e){(0,vn.AO)("JSON serialization failed for batch removal",e)}}catch(e){(0,vn.AO)("Error removing batch from storage",e)}}async function se(e,t=!1){var n;try{q(e);const i=K(e);if(i.length>0)return(0,vn.AO)("Dropping outbound batch with missing required context",{eventType:null!==(n=null==e?void 0:e[ei.eventType])&&void 0!==n?n:null==e?void 0:e.eventType,missingFields:i}),!1;(0,vn.cY)("sendDataWithRetry called",e.eventType);const r=Object.assign({},e);let o;delete r.id,delete r.queuedAt;try{o=JSON.stringify(r)}catch(e){throw(0,vn.AO)("JSON serialization failed",e),e}const a=("hidden"===document.visibilityState||t)&&"function"==typeof navigator.sendBeacon;let s=!1;if(a){(0,vn.cY)("sendDataWithRetry using beacon");try{const e=new Blob([o],{type:"application/json"});s=navigator.sendBeacon(CST_LAMBDA_ENDPOINT,e),s&&(0,vn.cY)("sendDataWithRetry beacon accepted for delivery")}catch(e){(0,vn.AO)("Beacon threw error, falling back to fetch",e)}}(0,vn.cY)("sendDataWithRetry trying primary endpoint:",CST_LAMBDA_ENDPOINT);try{const t=await fetch(CST_LAMBDA_ENDPOINT,{method:"POST",headers:{"Content-Type":"text/plain"},body:o,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,vn.cY)("Could not read success response body, but request succeeded")}return"heartbeat"!==e.eventType&&(ii=Date.now()),(0,vn.cY)("sendDataWithRetry primary endpoint success"),!0}catch(t){(0,vn.AO)("Primary endpoint failed, trying fallback:",t);const n=(()=>{const e=Tn;return(0,vn.cY)("Using fallback endpoint:",e),e})();(0,vn.cY)("sendDataWithRetry trying fallback endpoint:",n);try{const t=await fetch(n,{method:"POST",headers:{"Content-Type":"text/plain"},body:o,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,vn.cY)("Could not read fallback success response body, but request succeeded")}return"heartbeat"!==e.eventType&&(ii=Date.now()),(0,vn.cY)("sendDataWithRetry fallback endpoint success"),!0}catch(e){return(0,vn.AO)("Both primary and fallback endpoints failed:",e),s&&(0,vn.cY)("sendDataWithRetry falling back to queued beacon-only delivery"),!1}}}catch(e){return(0,vn.AO)("Error sending data",e),!1}}function ce(e){try{const t=localStorage.getItem(ui);if(!t)return;const n=JSON.parse(t).filter(t=>t.id!==e);0===n.length?localStorage.removeItem(ui):localStorage.setItem(ui,JSON.stringify(n)),(0,vn.cY)(`Removed batch ${e} from storage. Remaining: ${n.length}`)}catch(e){(0,vn.AO)("Error removing batch from storage",e)}}async function le(){if(mi)(0,vn.cY)("Already retrying events, skipping");else try{mi=!0;const e=localStorage.getItem(ui);if(!e)return;const t=JSON.parse(e);if(0===t.length)return;(0,vn.cY)(`Retrying ${t.length} stored batches`);for(const e of t){try{await se(e)?ce(e.id):(0,vn.cY)(`Failed to send batch ${e.id}, keeping in storage`)}catch(t){(0,vn.AO)(`Error processing batch ${e.id}`,t)}await new Promise(e=>setTimeout(e,di))}}catch(e){(0,vn.AO)("Error in retryFailedEvents",e)}finally{mi=!1}}function de(e){if(!hi)return hi={x:e.clientX,y:e.clientY},void gi();Math.hypot(e.clientX-hi.x,e.clientY-hi.y)>100&&(hi={x:e.clientX,y:e.clientY},gi())}function ue(){me(),document.addEventListener("mousemove",de,{passive:!0}),["touchmove","scroll","keypress","click"].forEach(e=>{document.addEventListener(e,gi,{passive:!0})}),gi(),(0,vn.cY)("Activity tracking initialized")}function me(){fi&&(clearTimeout(fi),fi=null),document.removeEventListener("mousemove",de),["touchmove","scroll","keypress","click"].forEach(e=>{document.removeEventListener(e,gi)})}function fe(e=Date.now()){var t,n,i;try{const r=localStorage.getItem($n)||localStorage.getItem(Wn);if(!r)return null;const o=JSON.parse(r);if(!o||"object"!=typeof o)return he(),null;const a=o.createdAt||o.timestamp,s=a?W(a):NaN;if(!Number.isFinite(s))return he(),null;if(e-s>7776e6)return he(),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"}:(he(),null)}catch(e){return(0,vn.AO)("Error loading acquisition context",e),null}}function he(){try{localStorage.removeItem($n),localStorage.removeItem(Wn)}catch(e){(0,vn.AO)("Error clearing acquisition context",e)}}function pe(){return crypto.randomUUID().replace(/-/g,"")}function ge(e){return"string"!=typeof e?null:e.trim()||null}function ve(e){const n=ge(e);if(n){try{localStorage.setItem(Ti,n)}catch(e){}try{const e=a();t(Ti,n,576e3,{domain:e,path:"/",sameSite:"Lax"})}catch(e){}}}function ye(e){if(e){try{const n=a();t(On,e,Cn,{domain:n,path:"/",sameSite:"Lax"})}catch(e){}try{"undefined"!=typeof localStorage&&localStorage.setItem(On,e)}catch(e){}}}async function we(e){var t;const n=await L(),i=n.raw;return ye(i),e&&ve(e),stateManager.setFingerprintConfidence(null!==(t=n.confidence)&&void 0!==t?t:null),(0,vn.cY)("Generated new visitor ID:",i,{confidence:n.confidence}),i}function be(){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=M(r);return n(e),e}}catch(e){}let i="UNKNOWN";try{const e=document.getElementsByTagName("script");(0,vn.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=[kn,"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,vn.cY)("Checking script for clientId",{src:n,rawClientId:e,matchesKnownScriptName:r,matchesKnownDomain:o}),(r||o)&&e){i=M(e),(0,vn.cY)("Found clientId:",i);break}}}catch(e){(0,vn.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=M(e.content),(0,vn.cY)("Found clientId via meta tag:",i))}catch(e){}return(0,vn.cY)("Final clientId:",i),i&&"UNKNOWN"!==i&&n(i),i}function Se(){let e=n(Ln)||localStorage.getItem(Ln)||"";if(e){try{const n=a();t(Ln,e,Cn,{domain:n,path:"/",sameSite:"Lax"}),localStorage.setItem(Ln,e)}catch(e){(0,vn.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(Ln)||localStorage.getItem(Ln)||"",!e)&&(l=s(),l&&c(l));){const e=Date.now()+25;for(;Date.now()<e;);}if(e){try{const n=a();t(Ln,e,Cn,{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_${pe()}`,(0,vn.cY)("Generated new userId",e);try{const n=a();t(Ln,e,Cn,{domain:n,path:"/",sameSite:"Lax"})}catch(e){(0,vn.AO)("Error persisting userId cookie:",e)}try{localStorage.setItem(Ln,e)}catch(e){(0,vn.AO)("Error persisting userId to localStorage:",e)}try{d&&localStorage.removeItem(i)}catch(e){}return e}function Te(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 _e(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 Ie(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 ke(e){Ie(Ai,e),Ie(Ei,e),Ie(Li,e)}function Ae(e){const t=$(),n=Ai.get(e);return void 0!==n&&t-n<3e3}function Ee(e){const t=$();Ai.set(e,t),ke(t)}function Oe(e,t=3e3){const n=$(),i=Ai.get(e);return void 0!==i&&n-i<t}function Le(e){const t=$();return t-(Li.get(e)||0)<Oi||(Li.set(e,t),ke(t),!1)}function Ce(e){const t=_i.get(e);return!!t&&$()-t.timestamp<Ii.DEDUPLICATION_WINDOW}function Pe(e){try{return`form:${e.id||e.getAttribute("data-form-id")||Te(e)}`}catch(e){return"form:unknown"}}function Me(e){return`form:${e}`}function Ye(e,t,n=1e3){e.forEach((i,r)=>{t-i>n&&e.delete(r)})}function Ne(e){if(!e)return"";try{const t=new URL(e,location.href);return`${t.hostname}${t.pathname}`}catch(t){return String(e||"")}}function xe(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||Mi.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 Re(e){const t=Ne(e||"");return t?`action:${t}`:""}function De(e){try{return new URL(e,location.href).hostname}catch(e){return""}}function $e(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 We(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 He(e){const t=Ri.get(e);return t?$()-t.timestamp>5e3?(Ri.delete(e),null):t.data:null}function Fe(){const e=$();return Di>0&&e-Di<2e3}function je(e,t){if(Ce(e))return ki.duplicatesBlocked++,(0,vn.cY)("Duplicate submission blocked",e),"";const n=pe(),i={elementId:e.id||Te(e),timestamp:$(),submissionId:n,method:t};return _i.set(e,i),n}function Ue(e){return Bn.some(t=>"string"==typeof t?e.toLowerCase().includes(t.toLowerCase()):t.test(e))}function ze(e){var t,n;const i={};let r=0;if(e.elements.length>Ii.MAX_FORM_FIELDS)return(0,vn.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,Ii.MAX_FIELD_LENGTH))}),0===Object.keys(i).length){const t=He(e);if(t)return(0,vn.cY)("Using snapshot data for empty HubSpot form",e.id),t}return i}catch(e){(0,vn.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&&Ii.DISALLOWED_FIELD_TYPES.includes(n.type))continue;if(n.name&&"submit"!==n.type){if(r++,r>Ii.MAX_FORM_FIELDS){(0,vn.AO)("Too many form fields, truncating",e.id);break}const t=n.value.slice(0,Ii.MAX_FIELD_LENGTH);i[n.name]=Ue(n.name)?"[REDACTED]":t}}}if(0===Object.keys(i).length||!Object.values(i).some(e=>e.length>0)){const t=He(e);if(t&&Object.keys(t).length>0)return(0,vn.cY)("Using snapshot data for empty form",{formId:e.id,snapshotFields:Object.keys(t).length}),t}return i}async function Ve(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||"",Ne((null===(t=e.element)||void 0===t?void 0:t.action)||""),xe(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=$();return Ye(Ci,n,t),n-(Ci.get(e)||0)<t||(Ci.set(e,n),!1)}(n))return ki.duplicatesBlocked++,void(0,vn.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=Re(e);if(!n)return!1;const i=$();Ye(Pi,i,t),i-(Pi.get(n)||0)<t||Pi.set(n,i)}(o)}catch(e){}}catch(e){return void(0,vn.AO)("Error preparing form event",e)}let o,a=null;const s=`form_submit_${e.eventId}`;try{o=await ti(e),localStorage.setItem(s,JSON.stringify(o)),a=te(o,{triggerSend:!1})}catch(e){return(0,vn.AO)("Error building form batch",e),ki.formsMissed++,void ki.errors.push(`Batch error: ${e}`)}try{const i="submit"===t||"click"===t;let r=!1;try{r=await se(o,i)}catch(e){(0,vn.AO)("Error sending form data",e),ki.errors.push(`Send error: ${e}`),r=!1}if(r)return a&&ne(a),localStorage.removeItem(s),(Array.isArray(n.throttleKeys)?n.throttleKeys:n.throttleKeys?[n.throttleKeys]:[]).forEach(e=>Ee(e)),ki.formsSubmitted++,"submit"===t||"xhr"===t?ki.universalSuccess++:"provider"===t&&ki.providerSuccess++,void(0,vn.cY)("Form data sent successfully",e.eventId);(0,vn.cY)("Form send failed, scheduling queued retry",e.eventId),a?ie():te(o,{triggerSend:!0}),ki.formsMissed++,!ki.errors.some(e=>e.includes("Send error"))&&ki.errors.length<50&&ki.errors.push("Send error: queued for retry")}catch(e){(0,vn.AO)("Critical error in form submission recovery",e),ki.formsMissed++,ki.errors.length<50&&ki.errors.push(`Recovery error: ${e}`)}}async function qe(e,t={}){const n={eventId:pe(),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,vn.cY)("📡 Sending form signal (no field data)",{provider:e.provider,formId:e.formId,signalType:e.signalType,confidence:e.confidence}),await Ve(n,"provider",t),ki.providerTriggers[`signal:${e.provider}`]=(ki.providerTriggers[`signal:${e.provider}`]||0)+1}async function Be(e,t,n={}){try{if(n.throttleKeys&&(Array.isArray(n.throttleKeys)?n.throttleKeys:[n.throttleKeys]).forEach(e=>Ee(e)),(e.className||"").toLowerCase().includes("fusion-form")&&!We(e))return void(0,vn.cY)("Skipping Fusion form without user input",e.className);const i=await async function(e,t){try{const n=je(e,t);if(!n)return null;const i=ze(e);return{eventId:n,eventType:"formSubmit",time:(new Date).toISOString(),label:e.id||e.className||"unnamed-form",value:Y(e.action)||e.action||"",element:{tag:"form",id:e.id,class:e.className,action:Y(e.action)||e.action,method:e.method,formData:i,customSelector:Te(e),xpath:_e(e)}}}catch(e){return(0,vn.AO)("Error creating form event",e),ki.errors.push(`Error creating form event: ${e}`),null}}(e,t);i&&await Ve(i,t,n)}catch(e){(0,vn.AO)("Error handling form submission",e),ki.formsMissed++}}function Ke(e){const t=e.target;if(!t||"FORM"!==t.tagName)return;const n=We(t),i=function(e){const t=Ri.get(e);return!!t&&($()-t.timestamp>5e3?(Ri.delete(e),!1):t.hadUserInput)}(t);if(!n&&!i)return void(0,vn.cY)("Skipping form submit without likely user input (checked current and snapshot)",t.id||t.className);const r=Pe(t);if(Ae(r))return ki.duplicatesBlocked++,void(0,vn.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=$();Ei.set(r,e)}}catch(e){}(0,vn.cY)("Universal form submit detected",t.id||t.className),Be(t,"submit",{throttleKeys:r})}function Ge(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&&ki.buttonSubmissions++;const o=i.closest("form");if(o&&r){const e=We(o),t=function(e){const t=We(e),n=ze(e),i=Object.keys(n).length>0&&Object.values(n).some(e=>e.length>0);return!(!t&&!i||(Ri.set(e,{data:n,timestamp:$(),hadUserInput:t}),(0,vn.cY)("📸 Form data snapshot captured",{formId:e.id,fieldCount:Object.keys(n).length,hadUserInput:t}),0))}(o);if(!e&&!t)return;const n=Pe(o);return void setTimeout(()=>{try{Ce(o)||Oe(n)||((0,vn.cY)("Fallback form submission via button click (no native submit detected)",o.id||o.className),Be(o,"submit",{throttleKeys:n}))}catch(e){(0,vn.AO)("Fallback form submission error",e)}},400)}Fe()||r&&((0,vn.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())||Te(e)}`;if(Ae(i))return ki.duplicatesBlocked++,void(0,vn.cY)("Throttled button-only submission",i);Ee(i);const r=je(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&&!Ue(e.name)&&(s[e.name]=e.value.slice(0,Ii.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,Ii.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:Te(e),xpath:_e(e)}};await Ve(c,"provider",{throttleKeys:i})}catch(e){(0,vn.AO)("Error capturing button submission",e),ki.errors.push(`Button capture error: ${e}`)}}(i))}function Xe(e){if(Fe())return void(0,vn.cY)("Startup debounce active; skipping XHR form scan");const t=$();if(t-$i<1e3){if(!Wi){const n=1e3-(t-$i)+50;(0,vn.cY)(`XHR scan rate limited, queuing scan in ${n}ms`),Wi=setTimeout(()=>{Wi=null,Xe(e)},n)}return}$i=t;const n=document.querySelectorAll("form");let i=!1;n.forEach(t=>{if(t instanceof HTMLFormElement&&!Ce(t)){const n=ze(t),r=Object.keys(n).length>0&&Object.values(n).some(e=>e.length>0),o=We(t),a=null!==t.offsetParent||"none"!==window.getComputedStyle(t).display;if(r&&o&&a){(0,vn.cY)("Potential XHR form submission detected",t.id||t.className);const n=Pe(t);Oe(n)||function(e,t=1e3){const n=Re(e);return!!n&&$()-(Pi.get(n)||0)<t}(t.action)?(0,vn.cY)("Skipping XHR capture due to recent native/provider send",n):Be(t,e,{throttleKeys:n}),i=!0}}}),i||(0,vn.cY)("XHR detected but no valid form submissions found")}function Je(e,t=0){if(!e||t>3)return[];const n=[];if(Array.isArray(e)){for(const i of e)n.push(...Je(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(...Je(r,t+1))}return n}function Qe(e,t=0){if(!e||t>3)return!1;if(Array.isArray(e))return e.some(e=>Qe(e,t+1));if("object"==typeof e)for(const[n,i]of Object.entries(e)){const e=n.toLowerCase();if(ji.includes(e))return!0;if(Qe(i,t+1))return!0}return!1}function Ze(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=Je(r);if(o.some(e=>Fi.has(e)))return!1;if(o.some(e=>Hi.has(e)))return!0;if(Qe(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 et(){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}})()&&Ae(c))return ki.duplicatesBlocked++,void(0,vn.cY)("Throttled calendar event",{provider:r,signal:a});if(Le(c))return;const l=pe();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?Te(d):r,xpath:d?_e(d):"",captureSource:`calendar:${r}`}};(0,vn.cY)("Calendar/iframe scheduled event detected",{provider:r,origin:t.origin,signal:a}),Ve(u,"provider",{throttleKeys:c}).catch(e=>(0,vn.AO)("Error sending calendar event",e))}catch(e){(0,vn.AO)("Calendar listener error",e)}})}function tt(e){const t=[],n=e||window.location.href;return Object.entries(zi).forEach(([e,i])=>{!i.active&&i.trigger(n)&&(t.push(e),i.active=!0,(0,vn.cY)(`Form provider activated: ${i.name}`))}),t}function nt(){return Object.values(zi).filter(e=>e.active)}function it(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 rt(e){return["password","credit_card","cc_number","cvv","ssn","social_security"].some(t=>e.toLowerCase().includes(t))}function ot(){if(Vi.completed||Vi.inProgress)return;const e=$();if(Vi.lastAttemptAt&&e-Vi.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']")||nt().some(e=>"HubSpot"===e.name)))return;var t,n;Vi.inProgress=!0,Vi.lastAttemptAt=e;let i=0;const r=()=>{var e,t,n,o;if(i++,1!==i&&i%5!=0||(0,vn.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,vn.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,vn.cY)("✅ HubSpot form submit intercepted:",{formId:t.formId,formData:n}),window.postMessage({type:"hsFormCallback",fields:n,id:t.formId,action:"hubspot"},"*")}catch(e){(0,vn.AO)("Error in HubSpot form callback patch",e)}return n&&n(e)},e(t)},Vi.completed=!0,Vi.inProgress=!1,void(0,vn.cY)("✅ HubSpot forms.create successfully patched!")}i<50?setTimeout(r,100):(Vi.inProgress=!1,(0,vn.cY)("⚠️ HubSpot patching failed after maximum attempts"))};r()}function at(e,t,n,i){var r,o,a;try{if(!e)return void(0,vn.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,vn.cY)(`${i}: original is not a function, skipping wrap`);if(c[Bi])return void(0,vn.cY)(`${i}: already wrapped, skipping wrap`);if(/\[native code\]/.test(c.toString())||(0,vn.cY)(`${i}: existing non-native implementation detected, chaining wrap`,{originalName:c.name}),s&&!1===s.configurable)return void(0,vn.cY)(`${i}: descriptor not configurable, skipping wrap`);const l=n(c);l[Bi]=!0,l[Ki]=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,vn.cY)(`${i}: successfully wrapped ${t}`)}catch(e){(0,vn.AO)(`${i}: error wrapping ${t}`,e)}}function st(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 ct(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 lt(){var e;e={onProviderTrigger:e=>{tt(e)},onCalendarMatch:(e,t,n)=>{const i=function(e){for(const t of Ui)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(!Ze(e,0,i))return void(0,vn.cY)("Skipping calendar network event due to non-booking payload",{provider:e,signal:n});const r=`calendar:${e}:network:${n}`;if(Ae(r)||Le(r))return ki.duplicatesBlocked++,void(0,vn.cY)("Throttled calendar network event",{provider:e,signal:n});const o={eventId:pe(),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,vn.cY)("Calendar booking detected via network",{provider:e,url:t,signal:n}),await Ve(o,"provider",{throttleKeys:r})}catch(e){(0,vn.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=Ji.find(t=>t.test(e));n&&((0,vn.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=dt(e)||"hubspot-network",i=`form:${n}`;Oe(i)?(0,vn.cY)("Skipping network HubSpot signal - recent postMessage capture exists"):setTimeout(()=>{Oe(i)?(0,vn.cY)("Skipping network HubSpot signal - postMessage captured during delay"):qe({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(Gi.some(t=>t.test(e)))return(0,vn.cY)("Excluded analytics endpoint from form detection:",e),!1;const t=Xi.find(t=>t.test(e));return!!t&&((0,vn.cY)("Form submission endpoint detected:",{url:e,matchedPattern:t.toString()}),!0)}(e)&&((0,vn.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=dt(e)||"network-form",i=Pe({id:n});if(Ae(i)||Oe(i))return ki.duplicatesBlocked++,void(0,vn.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=De(e);if(n)for(const e of Array.from(t)){const t=e;if(t.action&&De(t.action)===n)return t}return null}(e);r?Be(r,"xhr",{throttleKeys:i}):((0,vn.cY)("📡 Network form capture (no DOM form found):",{url:e,formId:n,parsedFields:t.parsed?Object.keys(t.parsed):[]}),qe({provider:ut(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(()=>Xe("xhr"),100)))}},"undefined"!=typeof XMLHttpRequest&&(at(XMLHttpRequest.prototype,"send",e=>function(t){try{this.__cstRequestBodyText=st(t)}catch(e){(0,vn.cY)("Unable to capture XHR request body",e)}return e.call(this,t)},"XMLHttpRequest.send"),at(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"),at(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,vn.AO)("Error in onProviderTrigger callback",e)}if("POST"===n.toUpperCase()){const t=this;this.addEventListener("load",()=>{try{const i=ct(t.__cstRequestBodyText,t.__cstContentType);e.onCalendarMatch(s,n,i),e.onFormSubmissionMatch(s,n,i)}catch(e){(0,vn.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&&at(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=st(c);return{url:a,method:(s||"GET").toUpperCase(),bodyInfo:ct(l,o)}}(n,i);if(r)try{e.onProviderTrigger(r)}catch(e){(0,vn.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,vn.AO)("Error in fetch callbacks",e)}return s},"window.fetch")}function dt(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 ut(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 mt(){nt().forEach(e=>{var t;ki.providerTriggers[e.name]=(ki.providerTriggers[e.name]||0)+1,null===(t=e.events)||void 0===t||t.forEach(t=>{const n=`${e.name}:${t}`;if(Qi.has(n))return;if("HubSpot"===e.name&&"message"===t)return(0,vn.cY)("Skipping HubSpot message handler - using dedicated listener"),void Qi.add(n);const i=n=>{(0,vn.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,vn.cY)("Skipping non-HubSpot form with hs-cf-bound",{id:n.id,className:n.className});if(!We(n))return void(0,vn.cY)("Skipping provider capture without user input",{provider:e.name,selector:t,id:n.id});const r=`provider:${e.name}:${n.id||Te(n)}`;if(Ae(r))return ki.duplicatesBlocked++,void(0,vn.cY)("Throttled provider form submit",r);const o=Pe(n);if(Oe(o))return ki.duplicatesBlocked++,void(0,vn.cY)("Suppressed provider capture due to recent send",{provider:e.name,idPart:o});(0,vn.cY)(`Provider form found: ${e.name}`,n.id),Be(n,"provider",{throttleKeys:[r,o]})}})})}(e),50)};window.addEventListener(t,i),document.addEventListener(t,i,!0),Qi.add(n)})})}function ft(){var e,t;if(er)return;er=!0,(0,vn.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,vn.cY)("Enhanced form tracking already initialized, skipping");window[n]=!0,t=$(),Di=t,function(){try{const e=JSON.parse(localStorage.getItem("cst_learned_patterns")||"[]");e.forEach(e=>{Yi.add(e),Ni.set(e,.8)}),(0,vn.cY)(`Loaded ${e.length} learned patterns from storage`)}catch(e){(0,vn.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),xi.add(n))}catch(e){}const n=t,i=$e(n.className),r=$e(n.id||n.getAttribute("id"));(i.includes("hubspot")||i.includes("hs-form")||r.includes("hsform"))&&(xi.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")&&(xi.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"))&&(xi.add(t),e.add("hubspot-iframe")),t.includes("typeform")&&(xi.add(t),e.add("typeform-iframe"))}catch(e){}}),(0,vn.cY)("Discovered providers:",Array.from(e)),e}();(0,vn.cY)("Discovered form providers:",Array.from(i));try{tt()}catch(e){(0,vn.AO)("Error activating form providers via triggers",e)}mt(),document.addEventListener("gform_confirmation_loaded",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t[0];(0,vn.cY)("Gravity Forms confirmation loaded:",n);const i=document.querySelector(`#gform_${n}`);i&&!Ce(i)&&((0,vn.cY)("Gravity Forms submission detected via confirmation:",n),Be(i,"provider"))}),document.addEventListener("gform_post_render",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.formId;(0,vn.cY)("Gravity Forms post render:",n)}),"undefined"!=typeof HTMLFormElement&&at(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,vn.cY)("Gravity Forms iframe submission detected:",this.id),Be(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,vn.cY)("Gravity Forms button submission detected:",e),Be(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=it(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(qi.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=it(e.data);if(!i)return;(0,vn.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=qi.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=Me(o),s=$();if(Ae(a)||Oe(a))return ki.duplicatesBlocked++,void(0,vn.cY)("Throttled HubSpot callback",{formId:o});if(s-(Ei.get(a)||0)<Ii.DEDUPLICATION_WINDOW)return ki.duplicatesBlocked++,void(0,vn.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,vn.cY)("✅ HubSpot form callback processed with field data:",{formId:o,hasFields:!0,confidence:r.confidence}),async function(e,t,n){try{const i=pe(),r={};return Array.isArray(n)?n.forEach(({name:e,value:t})=>{const n="string"==typeof t?t:String(null!=t?t:"");e&&(r[e]=rt(e)?"[REDACTED]":n.slice(0,Ii.MAX_FIELD_LENGTH))}):Object.entries(n).forEach(([e,t])=>{t&&"string"==typeof t&&(r[e]=rt(e)?"[REDACTED]":t.slice(0,Ii.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,vn.AO)("Error creating HubSpot form event",e),ki.errors.push(`Error creating HubSpot form event: ${e}`),null}}(o,c,r.fields).then(e=>{e&&Ve(e,"provider",{throttleKeys:a})}).catch(e=>{(0,vn.AO)("Error processing HubSpot form callback",e)})):((0,vn.cY)("📡 HubSpot form submission detected (signal-only, no field data):",{formId:o,confidence:r.confidence,origin:e.origin}),qe({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,vn.AO)("Error sending HubSpot signal-only capture",e)}))}catch(e){(0,vn.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=it(e.data);if(!t)return;const n="string"==typeof t.type?t.type.toLowerCase():"",i="string"==typeof t.eventName?t.eventName.toLowerCase():"";if((qi.complete.some(e=>n.includes(e)||i.includes(e))||t.redirectUrl||t.thankYouMessage)&&!qi.submitted.some(e=>i.includes(e))){const e=t.formGuid||t.formId||"hubspot-unknown",r=Me(e);Oe(r)||((0,vn.cY)("📡 HubSpot completion signal detected via broad listener:",{formId:e,type:n,eventName:i,hasRedirect:!!t.redirectUrl}),qe({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,vn.AO)("Error in broad HubSpot listener",e)}))}}catch(e){}}))}())}(),et(),ot();try{lt()}catch(e){(0,vn.AO)("Failed installing form network interceptors",e)}document.addEventListener("submit",Ke,!0),document.addEventListener("click",Ge,!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,vn.cY)("New forms detected via MutationObserver"),setTimeout(()=>{document.querySelectorAll("form").forEach(e=>{e instanceof HTMLFormElement&&!Zi.has(e)&&((0,vn.cY)("Setting up tracking for late-rendered form:",e.id||e.className||"unnamed"),Zi.add(e))}),tt(),ot()},500))}).observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{const e=document.querySelectorAll("form");(0,vn.cY)(`Found ${e.length} forms on page load`),e.forEach(e=>{e instanceof HTMLFormElement&&!Zi.has(e)&&((0,vn.cY)("Setting up tracking for form:",e.id||e.className||"unnamed"),Zi.add(e))})},1e3),setInterval(()=>{mt(),ot()},2e3),(0,vn.cY)("Enhanced form tracking initialized")}function ht(){(0,vn.cY)("Rescanning all forms");const e=document.querySelectorAll("form");ki.formsFound=e.length,ot(),tt(),mt(),et(),(0,vn.cY)(`Rescan complete: ${e.length} forms found`)}function pt(){tr?(0,vn.cY)("Heartbeat already running"):"visible"===document.visibilityState?((0,vn.cY)("Starting heartbeat"),tr=setInterval(()=>{(async function(e=!1){var t;try{(0,vn.cY)("sendHeartbeat called");const n=stateManager.getState();if("UNKNOWN - STATE"===n.clientId||!(null===(t=n.session)||void 0===t?void 0:t.id))return void(0,vn.cY)("heartbeat - invalid state. not sending");if("visible"!==document.visibilityState)return void(0,vn.cY)("heartbeat - tab not visible");const i=ii;if(i>0&&Date.now()-i<nr)return void(0,vn.cY)("heartbeat - recent non-heartbeat event sent; skipping keepalive");const r=Object.assign({},ki),o={eventId:pe(),eventType:"heartbeat",time:(new Date).toISOString(),activeTime:n.session.activeTimeInSeconds,timeout:e,formMetrics:r};await ee(o)}catch(e){(0,vn.AO)("Error sending heartbeat",e),gt()}})().catch(e=>(0,vn.AO)("Error sending heartbeat",e))},nr)):(0,vn.cY)("Heartbeat not started - page hidden")}function gt(){tr&&(clearInterval(tr),tr=null,(0,vn.cY)("Heartbeat stopped"))}function vt(){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 yt(){(0,vn.cY)("Resetting scroll tracking"),lr&&(clearTimeout(lr),lr=null),or=Object.assign({},Kn),sr=0,dr=0,ur=!1,mr=!1,ar&&(window.removeEventListener("scroll",ar),ar=null),cr=!1}function wt(){const e=vt();e>dr&&(dr=e),(0,wn.AE)()}function bt(){lr&&clearTimeout(lr),lr=setTimeout(()=>{lr=null,function(){if(mr)(0,vn.cY)("Already processing scroll milestones, skipping");else if(!(dr<=sr)){mr=!0;try{sr=dr;let e=null;if(Object.keys(or).forEach(t=>{const n=parseInt(t,10);dr>=n&&!or[n]&&(or[n]=!0,(!e||n>e)&&(e=n))}),null!==e){const t={eventId:pe(),eventType:"scroll",time:(new Date).toISOString(),value:e};(0,vn.cY)(`Sending scroll event for milestone: ${e}%`),ee(t)}}finally{mr=!1}}}()},500)}function St(){if(cr&&ar)(0,vn.cY)("Scroll tracking already initialized, skipping");else try{(0,vn.cY)("Initializing scroll tracking"),yt(),ar=()=>{ur||(ur=!0,requestAnimationFrame(()=>{ur=!1,wt()})),bt()},window.addEventListener("scroll",ar,{passive:!0}),cr=!0,setTimeout(()=>{wt(),dr>0&&bt()},0),(0,vn.cY)("Scroll tracking initialized")}catch(e){(0,vn.AO)("Error tracking scroll",e),cr=!1}}function Tt(){const{clickTrackingMode:e,customClickSelector:t,alwaysIncludeClasses:n,includeDataAnlInStandard:i}=fr,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),_t(r+(e.length?", "+e.join(", "):""),t)}const s=a.concat('[tabindex]:not([tabindex="-1"])',o);return _t("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 _t(e,t){return t?e+", "+t:e}function It(){try{(0,vn.cY)("Reinitializing click tracking (manual trigger)"),Ot(),hr="",Et()}catch(e){(0,vn.AO)("Failed to reinitialize click tracking",e)}}function kt(e){const t=Object.assign({},fr);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 At(e,t){const n=Tt(),i=null==e?void 0:e.closest(n);if(!i)return;if(yr.has(i))return;const r=x(async()=>{var e,t,n,r,o;try{(0,vn.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=kt(i),m=c(i),f=(null===(e=i.innerText)||void 0===e?void 0:e.slice(0,1e3).trim())||"",h=i.getAttribute("aria-label")||"",p=i.getAttribute("title")||"",g=(null==m?void 0:m.alt)||"",v=(null==m?void 0:m.src)?Y(m.src)||m.src:"",y=f||h||p||g||v||null,w={eventId:pe(),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:vt(),selector:Te(i),href:Y(a)||a||null,src:v||null,value:null!=s?s:null,checked:i instanceof HTMLInputElement?i.checked:null,customSelector:Te(i),xpath:_e(i),captureMode:u.mode,captureSource:u.source}};(0,vn.cY)("Queueing click event:",w),await ee(w),(0,vn.cY)("Click event queued for batched send")}catch(e){(0,vn.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,wn.WI)();const i=e.currentTarget instanceof HTMLElement?e.currentTarget:this instanceof HTMLElement?this:null;if(!i)return;if((0,vn.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(Tt());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=kt(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")||"",f=(null==l?void 0:l.alt)||"",h=(null==l?void 0:l.src)?Y(l.src)||l.src:"",p=d||u||m||f||h||null,g={eventId:pe(),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:vt(),selector:Te(i),href:Y(e)||e||null,src:h||null,value:null,checked:null,customSelector:Te(i),xpath:_e(i),captureMode:r.mode,captureSource:r.source}},v=await ti(g);(0,vn.cY)("Navigation click batch",v);const y=te(v,{triggerSend:!1});try{await se(v,!0)?ne(y):((0,vn.cY)("Navigation click send failed, scheduling queued retry",v.eventType),y?ie():te(v,{triggerSend:!0}))}catch(e){(0,vn.AO)("Navigation click send threw error, scheduling queued retry",e),y?ie():te(v,{triggerSend:!0})}}else r()}catch(e){(0,vn.AO)("Error in click handler",e),i instanceof HTMLAnchorElement&&window.location.assign(i.href)}};i.addEventListener("click",o,{capture:!0,passive:!1}),yr.add(i),(0,vn.cY)("Click listener added to:",i.tagName,i.id||i.className),t instanceof MouseEvent&&o.call(i,t)}function Et(){try{if(pr)return void(0,vn.cY)("Click tracking already initialized");pr=!0,(0,vn.cY)("Initializing click tracking system"),function(){try{(function(e=document){if(!fr.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"===fr.clickTrackingMode&&(fr=Object.assign(Object.assign({},fr),{clickTrackingMode:"enhanced"}),1)&&(0,vn.cY)("Auto-enhanced click tracking mode → enhanced");const e=Tt();hr=e;const t=document.querySelectorAll(e);if((0,vn.cY)(`Initializing click listeners for ${t.length} elements`),t.forEach(e=>{At(e)}),gr)try{gr.disconnect()}catch(e){}gr=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(Tt())&&At(e),e.querySelectorAll(Tt()).forEach(e=>{At(e)}))})})}),gr.observe(document.body,{childList:!0,subtree:!0})}catch(e){(0,vn.AO)("Error initializing clickable elements",e)}}();const e=x(e=>{const t=Tt();if(e.target instanceof HTMLElement){const n=e.target.closest(t);n&&!yr.has(n)&&((0,vn.cY)("Adding click listener to dynamically detected element:",n.tagName),At(n,e))}},200,{maxRequestsPerSecond:2,leading:!0,trailing:!1});vr=e,document.addEventListener("click",vr),(0,vn.cY)("Click tracking system initialized")}catch(e){(0,vn.AO)("Error in initial click listener",e)}}function Ot(){try{gr&&(gr.disconnect(),gr=null),vr&&(document.removeEventListener("click",vr),vr=null)}catch(e){(0,vn.AO)("cleanupClickTracking error",e)}finally{pr=!1}}function Lt({element:e,eventType:t,platform:n,videoId:i,src:r,label:o,value:a,watchPercentage:s,furthestWatchPercentage:c,watchTime:l,furthestWatchTime:d}){try{ee({eventId:pe(),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:Te(e),xpath:_e(e),src:null!=r?r:e instanceof HTMLMediaElement?e.currentSrc:e.src||null}})}catch(e){(0,vn.AO)("Error emitting video event",e)}}function Ct(){document.querySelectorAll("video").forEach(e=>{(e=>{try{if(br.has(e))return;br.add(e);const t=Sr.get(e)||pe();Sr.set(e,t),(0,vn.cY)("Initializing HTML video tracking",{videoId:t,src:e.currentSrc||e.src,duration:e.duration}),wr.has(t)||wr.set(t,{lastPlayTime:e.currentTime,furthestWatchTime:0,watchTime:0,intervalsReported:new Set,lastRealTimestamp:void 0}),e.addEventListener("play",()=>{const n=wr.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,vn.cY)("HTML Video play event",{videoId:t,currentTime:e.currentTime,watchTime:n.watchTime,watchPercentage:r,furthestWatchTime:n.furthestWatchTime,furthestWatchPercentage:o}),Lt({element:e,eventType:"videoPlay",platform:"HTML5",videoId:Sr.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,vn.cY)(`HTML Video ${t}: ${a}% position reached. Actually watched: ${r}%`),Lt({element:e,eventType:"videoProgress",platform:"HTML5",videoId:Sr.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=wr.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,vn.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),Lt({element:e,eventType:"videoPause",platform:"HTML5",videoId:Sr.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=wr.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,vn.cY)("HTML Video ended event",{videoId:t,duration:e.duration,watchTime:n.watchTime,watchPercentage:i}),n.intervalId&&(clearInterval(n.intervalId),n.intervalId=void 0),Lt({element:e,eventType:"videoEnded",platform:"HTML5",videoId:Sr.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,vn.AO)("Error tracking HTML video",e)}})(e)})}function Pt(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 Mt(e){var t;try{if(await function(){var e;return(null===(e=window.Vimeo)||void 0===e?void 0:e.Player)?Promise.resolve():Tr||(Tr=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,vn.AO)("Failed to load Vimeo player API",e),Tr=null,e}),Tr)}(),!(null===(t=window.Vimeo)||void 0===t?void 0:t.Player))return void(0,vn.AO)("Vimeo Player constructor not available after script load");const n=kr.get(e)||`vimeo-${pe()}`;kr.set(e,n),Ir.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}=Pt(r);Lt({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}=Pt(r);Lt({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}=Pt(r,1);Lt({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}=Pt(e,i),a=10*Math.floor(o/10);a>0&&a<=100&&!e.intervalsReported.has(a)&&(e.intervalsReported.add(a),Lt({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,vn.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),_r.set(n,r),(0,vn.cY)("Vimeo tracking initialized",{src:e.src,videoKey:n})}catch(e){(0,vn.AO)("Error setting up Vimeo tracking",e)}}function Yt(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=>!Ir.has(e))}(e);t.forEach(e=>Mt(e))}function Nt(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 xt(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 Rt(e,t){t&&!Er.has(t)&&(Er.add(t),Lr.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}=Nt(e);Lt({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}=Nt(e);Lt({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}=Nt(e);Lt({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}=Nt(e),o=10*Math.floor(r/10);o>0&&o<=100&&!e.intervalsReported.has(o)&&(e.intervalsReported.add(o),Lt({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),Or.add(t),Lr.set(t,n),Ar.set(n,r),(0,vn.cY)("Wistia tracking initialized",{videoKey:n})}catch(e){(0,vn.AO)("Error binding Wistia video",e)}}(n,e,t)}catch(e){(0,vn.AO)("Error in Wistia onReady handler",e)}}}))}function Dt(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=>!Or.has(e))}(e);t.forEach(e=>{const t=xt(e);t?Rt(e,t):(0,vn.cY)("Unable to determine Wistia hashed id",{id:e.id,className:e.className})})}function $t(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 Wt(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}=$t(e),o=10*Math.floor(r/10);o>0&&o<=100&&!e.intervalsReported.has(o)&&(e.intervalsReported.add(o),Lt({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 Ht(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 Pr.forEach(n=>{t||n.contentWindow!==e||(t=n)}),t}(e.source)||(1===Pr.size?Array.from(Pr.values())[0]:null);if(!t)return;const n=Yr.get(t)||t.src;let i=Cr.get(n);i||(i={element:t,videoKey:n,duration:0,watchTime:0,furthestWatchTime:0,lastSeconds:0,intervalsReported:new Set},Cr.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}=$t(i);Lt({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&&Wt(i,s,c);const{watchPercentage:e,furthestWatchPercentage:t}=$t(i);Lt({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}=$t(i);Lt({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&&Wt(i,s,c)}}catch(e){(0,vn.AO)("Error handling Loom message",e)}}function Ft(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=>!Mr.has(e))}function jt(e){if(Mr.has(e))return;Nr||(Nr=!0,window.addEventListener("message",Ht));let t=Yr.get(e)||`loom-${pe()}`;Yr.set(e,t),Mr.add(e),Pr.add(e),Cr.has(t)||Cr.set(t,{element:e,videoKey:t,duration:0,watchTime:0,furthestWatchTime:0,lastSeconds:0,intervalsReported:new Set}),(0,vn.cY)("Loom tracking initialized",{src:e.src,videoKey:t})}function Ut(e=document){Ft(e).forEach(jt);try{xr&&(xr.disconnect(),xr=null),xr=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e instanceof HTMLElement&&Ft(e).forEach(jt)})})}),xr.observe(document.body,{childList:!0,subtree:!0})}catch(e){(0,vn.AO)("Error setting up Loom MutationObserver",e)}}function zt(e){e&&(async()=>{try{if(await new Promise((e,t)=>{let n=0;const i=()=>{if(window.YT&&window.YT.Player)return(0,vn.cY)("YouTube API loaded successfully"),void e();if(n>=zr){(0,vn.cY)("YouTube API not found after retries, attempting to reload"),window.onYouTubeIframeAPIReady=()=>{(0,vn.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,Vr)};i()}),(()=>{const e=document.querySelectorAll('iframe[src*="youtube.com/embed/"]');(0,vn.cY)("Found YouTube iframes:",e.length),e.forEach(e=>{const t=Br(e);t.id&&Vt(t,!0)})})(),qr)try{qr.disconnect()}catch(e){}qr=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&&Vt(t,!0)})})})}),qr.observe(document.body,{childList:!0,subtree:!0})}catch(e){(0,vn.AO)("Error initializing YouTube iframes:",e)}})()}function Vt(e,t){try{const n=e;if((0,vn.cY)("Initializing YouTube Iframe",{id:n.id,src:n.src,apiReady:!!window.YT&&!!window.YT.Player,youTubeApiCalled:t}),n.id||(n.id=`yt-${pe()}`,(0,vn.cY)("Generated new YouTube iframe ID",{id:n.id})),!t)return void(0,vn.cY)("YouTube API script not loaded yet, skipping initialization");if(!window.YT||!window.YT.Player){const e=Ur.get(n)||0;if(e>=10)return void(0,vn.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 Ur.set(n,e+1),(0,vn.cY)("YouTube API not ready, retrying in "+i+"ms",{retryCount:e+1,id:n.id}),void setTimeout(()=>Vt(n,t),i)}if(Ur.delete(n),jr.has(n.id))return void(0,vn.cY)("Player already initialized",{id:n.id});(0,vn.cY)("Creating YouTube player",{iframeId:n.id,src:n.src}),new window.YT.Player(n.id,{events:{onReady:e=>{(0,vn.cY)("YouTube player ready",{id:n.id,playerInfo:e.target.playerInfo}),jr.has(n.id)||jr.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,vn.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,vn.AO)("Missing player ID in YouTube event",e.target);const i=e.target;jr.has(n)||jr.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=jr.get(n);if(!r)return void(0,vn.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=jr.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,vn.cY)(`YouTube video ${t}: ${d}% position reached. Actually watched: ${l}%`),Lt({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=jr.get(t);i&&(i.intervalId=n)}catch(e){(0,vn.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,vn.cY)("youtube video update",{playerID:n,eventType:c,watchPercentage:d,watchTime:Math.floor(r.watchTime),furthestWatchTime:Math.floor(r.furthestWatchTime),furthestWatchPercentage:l,formattedWatchTime:qt(r.watchTime),currentTime:o,duration:a,lastPlayTime:r.lastPlayTime}),Lt({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,vn.AO)("Error in onPlayerStateChange",e)}}(t)},onError:e=>{(0,vn.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,vn.AO)("Error initializing YouTube iframe",{error:t,iframeId:e.id,src:e.src})}}function qt(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 Bt(e){if(Kr.has(e))return;const t=e instanceof HTMLSelectElement,n=t?"change":"blur",i=t?"select_change":"input_blur",r=async()=>{if((0,vn.cY)(`${n} event triggered`,e),!e.value.trim()||e instanceof HTMLInputElement&&("password"===e.type||"file"===e.type)||e.name&&(t=e.name,Bn.some(e=>"string"==typeof e?t.toLowerCase().includes(e.toLowerCase()):e.test(t))))return;var t;const r={eventId:pe(),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:Te(e),xpath:_e(e)}};(0,vn.cY)("Queueing input event:",r);try{await ee(r),(0,vn.cY)("input event queued for batched send")}catch(e){(0,vn.AO)("Error queueing input data",e)}};e.addEventListener(n,r),Kr.add(e);const o=Gr.get(e)||{};o[n]=r,Gr.set(e,o)}function Kt(e){e.querySelectorAll("input, textarea, select").forEach(e=>{Bt(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)&&Bt(e),e.querySelectorAll("input, textarea, select").forEach(e=>{Bt(e)}))})})});return t.observe(e,{childList:!0,subtree:!0}),t}function Gt(){Qr||(Qr=!0,(0,vn.cY)("Starting input and select tracking"),Xr=Kt(document),function(){let e=window.location.pathname;if(Jr)try{Jr.disconnect()}catch(e){}Jr=new MutationObserver(()=>{window.location.pathname!==e&&(e=window.location.pathname,(0,vn.cY)("SPA navigation detected, reinitializing input tracking"),Xr&&Xr.disconnect(),Xr=Kt(document))}),Jr.observe(document.body,{childList:!0,subtree:!0});const t=e=>{(0,vn.cY)("Navigation detected, reinitializing input tracking"),Xr&&Xr.disconnect(),Xr=Kt(document)};Zr=t,eo=t,to=t,window.addEventListener("popstate",Zr),window.addEventListener("pushState",eo),window.addEventListener("replaceState",to)}())}function Xt(e){return e.closest(io)||e.closest("[role='listbox']")}async function Jt(e){const t=Xt(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(io)||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():Te(t)}return Te(document.body)}(e,t),o={eventId:pe(),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:Te(e),customSelector:Te(e),xpath:_e(e)}};(0,vn.cY)("Custom dropdown option selected",{name:r,value:n,label:i,optionTag:e.tagName});const a=await ti(o);await se(a),(0,vn.cY)("Custom dropdown input event sent successfully")}function Qt(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,vn.cY)(`SPA tracking: history.${e} missing or not a function; skipping patch`);if(o[mo])return void(0,vn.cY)(`SPA tracking: history.${e} already wrapped by CST`);if(/\[native code\]/.test(o.toString())||(0,vn.cY)(`SPA tracking: history.${e} appears pre-wrapped; chaining listener`,{originalName:o.name}),r&&!1===r.configurable)return void(0,vn.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,vn.AO)(`SPA tracking: failed to dispatch ${e} event`,t)}return n};a[mo]=!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,vn.AO)(`SPA tracking: error patching history.${e}`,t)}}function Zt(e,t){try{if(fo.has(e))return;!function(e){var t;try{if(fo.has(e))return;if(e instanceof HTMLFormElement&&ho(),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&Bt(e),e.matches(Tt())&&At(e),e instanceof HTMLVideoElement&&At(e),e instanceof HTMLIFrameElement&&(null===(t=e.src)||void 0===t?void 0:t.includes("youtube.com/embed/"))){const t=Br(e);Wr()||Hr(),Vt(t,Wr())}!function(e){var t;e instanceof HTMLIFrameElement&&(null===(t=e.src)||void 0===t?void 0:t.includes("player.vimeo.com"))&&!Ir.has(e)&&Mt(e)}(e),function(e){const t=xt(e);t&&Rt(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")))&&jt(e)}(e),fo.add(e)}catch(e){(0,vn.AO)("Error processing element",e)}}(e),t.depth<so&&Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&!t.processedNodes.has(e)&&(t.processedNodes.add(e),Zt(e,Object.assign(Object.assign({},t),{depth:t.depth+1})))})}catch(e){(0,vn.AO)("Error handling dynamic element",e)}}async function en(){try{const e=lo,t=location.href;if(t===e)return void(0,vn.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 lo=t,window.__cst_spa_last_url=lo,void(0,vn.cY)("Hash-only navigation detected; skipping new page view");lo=t,window.__cst_spa_last_url=lo,(0,vn.cY)(`Route change detected: ${e} -> ${t}`,{previousUrl:e,currentUrl:t,documentReferrer:document.referrer,computedReferrer:e||document.referrer});const n=$(),i={id:`pv_${window.location.pathname}_${pe()}`,startTime:n,startTimestamp:D(),lastActivityTime:n,activeTimeInSeconds:0,url:t,pathname:location.pathname,title:document.title,referrer:e||document.referrer,isValid:!0};await stateManager.endCurrentPageViewAndStartNew(i);try{(0,vn.cY)("Sending initial data for SPA route change"),await Q()}catch(e){(0,vn.AO)("Error sending initial data during SPA route change",e)}setTimeout(async()=>{try{me(),Ot(),function(){try{Xr&&(Xr.disconnect(),Xr=null),Jr&&(Jr.disconnect(),Jr=null),Zr&&(window.removeEventListener("popstate",Zr),Zr=null),eo&&(window.removeEventListener("pushState",eo),eo=null),to&&(window.removeEventListener("replaceState",to),to=null)}catch(e){(0,vn.AO)("cleanupInputTracking error",e)}finally{Qr=!1}}(),function(){try{wr.forEach(e=>{e.intervalId&&(clearInterval(e.intervalId),e.intervalId=void 0)}),wr.clear()}catch(e){}}(),_r.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,vn.AO)("Error cleaning up Vimeo tracking",e)}}),_r.clear(),Ar.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,vn.AO)("Error cleaning up Wistia tracking",e)}}),Ar.clear(),Er.clear(),function(){window.removeEventListener("message",Ht),Nr=!1;try{xr&&(xr.disconnect(),xr=null)}catch(e){}Pr.clear(),Cr.clear()}();try{!function(){try{oo&&(document.removeEventListener("click",oo,!0),oo=null),ao&&(document.removeEventListener("keydown",ao,!0),ao=null)}catch(e){(0,vn.AO)("cleanupCustomDropdownTracking error",e)}finally{ro=!1}}()}catch(e){}yt(),St(),document.querySelectorAll("input, textarea").forEach(e=>{e.removeAttribute("cst-event-active")}),It(),ft(),ht(),Ct(),Yt(),Dt(),Ut(),pt(),document.querySelectorAll("input, textarea").forEach(e=>Bt(e)),Wr()&&zt(!0)}catch(e){(0,vn.AO)("Error reinitializing tracking after route change",e)}},100)}catch(e){(0,vn.AO)("Error handling route change",e)}}async function tn(e,t,n){const i=stateManager.getState().cookieConsent,r=function(e,t,n){if(!n)return`${e}|${t}`;try{return`${e}|${t}|${i=n,JSON.stringify(rn(i))}`}catch(n){return`${e}|${t}|[details-unserializable]`}var i}(e,t,n);if(i!==e||r!==bo){stateManager.setCookieConsent(e),bo=r,(0,vn.cY)(`Cookie consent set to ${e} from ${t}`);try{const i={eventId:pe(),eventType:"cookieConsent",time:(new Date).toISOString(),label:"Cookie consent "+(e?"granted":"denied"),value:Object.assign({consentGiven:e,consentSource:t},n?{details:n}:{})};await ee(i)}catch(e){(0,vn.AO)("Error sending cookie consent event",e)}}}function nn(e){yo.push(e)}function rn(e,t=new WeakSet){if(null===e||"object"!=typeof e)return e;if(t.has(e))return"[circular]";if(t.add(e),Array.isArray(e))return e.map(e=>rn(e,t));const n=e,i={},r=Object.keys(n).sort((e,t)=>e<t?-1:e>t?1:0);for(const e of r)i[e]=rn(n[e],t);return i}function on(){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,vn.AO)("Error parsing OneTrust consent",e),null}}function an(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);tn(!(!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),nn(()=>{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);tn(!(!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(()=>an(e-1),1e3);wo.push(t)}}function sn(){var e;if(!vo&&"undefined"!=typeof window){vo=!0;try{an(),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&&!l)return;const d=JSON.stringify(a,Object.keys(a).sort());if(d===n)return;n=d,i=!0,tn(c,t,{gcm:e,gcmState:a})}catch(e){(0,vn.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,vn.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,nn(()=>{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);nn(()=>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,vn.AO)("Error intercepting gtag consent",e)}return n.apply(this,e)};i.__cstPatched=!0,e.gtag=i};u();let m=40;const f=setInterval(()=>{try{"function"!=typeof e.gtag||e.gtag.__cstPatched||u()}catch(e){}--m<=0&&clearInterval(f)},250);nn(()=>clearInterval(f)),nn(()=>{var n;try{t&&(null===(n=e.gtag)||void 0===n?void 0:n.__cstPatched)&&(e.gtag=t)}catch(e){}})}catch(e){(0,vn.AO)("Error setting up Google Consent Mode listener",e)}}();const t=e=>{try{const t=function(e){var t,n,i,r;try{if(!e||"object"!=typeof e)return null;const o=e=>{if("boolean"==typeof e)return e;if("string"==typeof e){const t=e.trim().toLowerCase();if("true"===t||"1"===t||"yes"===t||"granted"===t)return!0;if("false"===t||"0"===t||"no"===t||"denied"===t)return!1}},a=o(null!==(n=null!==(t=e.analyticsAllowed)&&void 0!==t?t:e.analytics_allowed)&&void 0!==n?n:e.analytics),s=o(null!==(r=null!==(i=e.marketingAllowed)&&void 0!==i?i:e.marketing_allowed)&&void 0!==r?r:e.marketing);return!0===a||!0===s||(!1!==a||!1!==s)&&null}catch(e){return(0,vn.AO)("Error parsing Shopify consent payload",e),null}}(null==e?void 0:e.detail);null!==t&&tn(t,"shopify")}catch(e){(0,vn.AO)("Error handling Shopify consent event",e)}};try{document.addEventListener("visitorConsentCollected",t,{passive:!0}),nn(()=>{try{document.removeEventListener("visitorConsentCollected",t)}catch(e){}})}catch(e){(0,vn.AO)("Error registering Shopify consent listener",e)}try{const e=()=>async function(){var e;try{const t=window,n=null===(e=null==t?void 0:t.Shopify)||void 0===e?void 0:e.customerPrivacy;if(!n)return null;const i=async e=>{if("function"==typeof e)try{const t=e();return t&&"function"==typeof t.then?await t:t}catch(e){return}},r=await i(()=>{var e;return null===(e=n.analyticsProcessingAllowed)||void 0===e?void 0:e.call(n)}),o=await i(()=>{var e;return null===(e=n.marketingAllowed)||void 0===e?void 0:e.call(n)});if(!0===r||!0===o)return!0;if(!1===r&&!1===o)return!1}catch(e){(0,vn.AO)("Error reading Shopify customer privacy",e)}return null}().then(e=>(null!==e&&tn(e,"shopify"),e)).catch(()=>null);e().then(t=>{if(null!==t)return;const n=setTimeout(()=>{e()},1e3);wo.push(n)})}catch(e){(0,vn.AO)("Error probing Shopify consent",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,tn(n.consent,"hubspot",n.details)}catch(e){}};n();const i=setInterval(n,1e3);nn(()=>clearInterval(i))}catch(e){(0,vn.AO)("Error initializing HubSpot cookie monitor",e)}const n=setInterval(()=>{try{const e=window.hsConsentApi;if(e&&"function"==typeof e.onConsentChange){clearInterval(n);const t=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}};tn(t.hasConsent,"hubspot",t.details)}catch(e){(0,vn.AO)("Error handling HubSpot onConsentChange",e)}};try{e.onConsentChange(t),nn(()=>{var n;try{null===(n=e.offConsentChange)||void 0===n||n.call(e,t)}catch(e){}})}catch(e){(0,vn.AO)("Failed to register HubSpot onConsentChange",e)}}}catch(e){(0,vn.AO)("Error probing HubSpot consent API",e)}},1e3);nn(()=>clearInterval(n));const i=()=>tn(!0,"cookiebot"),r=()=>tn(!1,"cookiebot"),o=()=>{var e,t,n;const i=window.Cookiebot;tn(!!((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",i,{passive:!0}),window.addEventListener("CookiebotOnDecline",r,{passive:!0}),window.addEventListener("CookiebotOnLoad",o,{passive:!0}),nn(()=>{window.removeEventListener("CookiebotOnAccept",i),window.removeEventListener("CookiebotOnDecline",r),window.removeEventListener("CookiebotOnLoad",o)}),(null===(e=window.Cookiebot)||void 0===e?void 0:e.consent)&&o();const a=()=>{const e=setTimeout(()=>{const e=on();e&&tn(e.hasConsent,"oneTrust",e.details)},100);wo.push(e)};window.addEventListener("OneTrustConsentChanged",a,{passive:!0}),nn(()=>{window.removeEventListener("OneTrustConsentChanged",a)});const s=on();s&&tn(s.hasConsent,"oneTrust",s.details);const c=()=>tn(!0,"generic"),l=()=>tn(!1,"generic");window.addEventListener("consentGiven",c,{passive:!0}),window.addEventListener("consentDenied",l,{passive:!0}),nn(()=>{window.removeEventListener("consentGiven",c),window.removeEventListener("consentDenied",l)}),(0,vn.cY)("Cookie consent tracking initialized")}catch(e){(0,vn.AO)("Error initializing cookie consent tracking",e)}}}function cn(){Io||(Io=!0,Promise.resolve().then(async()=>{Io=!1;const e=_o.shift();if(e){try{await async function(e){const t=`${En}${So}`,n=JSON.stringify(e);(0,vn.cY)("Posting pixel context bridge payload",{endpoint:t,shop:e.shop}),await H(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,vn.AO)("Failed to push pixel context bridge payload",e)}_o.length>0&&cn()}}))}function ln(e){return!e||"UNKNOWN - STATE"===e||!e.trim()}function dn(e){var t,n;const i=null===(t=null==e?void 0:e.session)||void 0===t?void 0:t.id,r=null===(n=null==e?void 0:e.page)||void 0===n?void 0:n.id,o=null==e?void 0:e.clientId;return!ln(i)&&!ln(r)&&!ln(o)}async function un(e={}){var t,n;if(Eo)return!1;const{force:i=!1}=e,r=Date.now();if(!i&&0!==Oo&&r-Oo<Lo)return console.log("[CST] Skipping cart attribute update (cooldown active)"),!1;try{Eo=!0,await stateManager.ensureInitialized();let e=stateManager.getState();if(!dn(e)&&(await stateManager.refreshStateManually(),await stateManager.ensureInitialized(),e=stateManager.getState(),!dn(e)))return(0,vn.cY)("Skipping cart attribute update: missing required identifiers after refresh.",{sessionId:null===(t=null==e?void 0:e.session)||void 0===t?void 0:t.id,pageViewId:null===(n=null==e?void 0:e.page)||void 0===n?void 0:n.id,clientId:null==e?void 0:e.clientId}),function(e,t){var n,i,r,o,a,s,c,l;const d=Date.now();if(!(d-Ao<6e4)){Ao=d;try{null===(r=null===(i=null===(n=null==t?void 0:t.session)||void 0===n?void 0:n.id)||void 0===i?void 0:i.slice)||void 0===r||r.call(i,0,12),null===(s=null===(a=null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.id)||void 0===a?void 0:a.slice)||void 0===s||s.call(a,0,12),null===(l=null===(c=null==t?void 0:t.clientId)||void 0===c?void 0:c.slice)||void 0===l||l.call(c,0,12)}catch(e){}}}(0,e),function(){if(ko)return;ko={attempts:0,ticks:0};const e=stateManager.addTickListener(async()=>{if(ko){if(ko.ticks+=1,!(ko.ticks<1)){if(ko.ticks=0,!dn(stateManager.getState()))return ko.attempts+=1,void(ko.attempts>=3&&(e(),ko=null));e(),ko=null;try{await un({force:!0})}catch(e){}}}else e()});ko.dispose=e;try{console.log("[CST] Scheduled cart attribute retry",{reason:"missing-identifiers"})}catch(e){}}(),!1;const i=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,vn.cY)("Failed to read Shopify cart localStorage",e)}return null}();i&&e.parsedMarketingTrackers&&(e.parsedMarketingTrackers.shopify_cart_token=i);const r={_cst_sessionId:e.session.id,_cst_clientId:e.clientId,_cst_pageViewId:e.page.id,_cst_userId:e.userId,_cst_visitorId:e.visitorId};let o,a,s=!1,c="",l=0;try{const e=await H(fetch("/cart.js",{credentials:"same-origin"}),2e3).catch(()=>null);if(e&&e.ok){const t=await e.json().catch(()=>null);t&&"object"==typeof t&&(s=!0,"string"==typeof t.note&&(c=t.note),Array.isArray(t.items)&&(l=t.items.length),t.attributes&&"object"==typeof t.attributes&&(a=t.attributes),"string"==typeof t.token&&(o=t.token))}}catch(e){}if(o||(o=i||void 0,o&&(0,vn.cY)("Using cart token from Shopify localStorage",{existingToken:o})),o&&e.parsedMarketingTrackers&&(e.parsedMarketingTrackers.shopify_cart_token=o),s&&(0===l||!o))return(0,vn.cY)("Skipping cart attribute update: cart is empty or lacks a token.",{itemsCount:l,hasToken:!!o}),!1;let d=!1;a&&(d=a._cst_sessionId===r._cst_sessionId&&a._cst_clientId===r._cst_clientId&&a._cst_pageViewId===r._cst_pageViewId&&a._cst_userId===r._cst_userId&&a._cst_visitorId===r._cst_visitorId);const u="string"==typeof c&&Co.test(c),m=()=>{if(o)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=To.get(i))&&void 0!==t?t:0)<6e4||(To.set(i,r),_o.length>=25&&_o.shift(),_o.push(Object.assign(Object.assign({},e),{cartToken:n,timestamp:(new Date).toISOString()})),cn())}({cartToken:o,clientId:r._cst_clientId,sessionId:r._cst_sessionId,pageViewId:r._cst_pageViewId,userId:r._cst_userId,visitorId:r._cst_visitorId,shop:e})}catch(e){(0,vn.AO)("Failed to enqueue pixel context sync",e)}};if(d&&!u)return console.log("[CST] Cart attributes already current; skipping write"),m(),!0;console.log("[CST] Updating cart attributes (enrichment)",{attributes:r,removingLegacyNoteMarker:u});const f={attributes:r};u&&(f.note=c?c.replace(Po,"").trim():"");const h=await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json","X-CST-Attrs":"1"},body:JSON.stringify(f),credentials:"same-origin",keepalive:!0});if(h.ok){await h.json().catch(()=>null),console.log("[CST] Cart attributes updated successfully",{status:h.status,attributeCount:Object.keys(r).length}),m();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&&Co.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=D();await async function(e,t=!1){try{const n=await ti(e);return await se(n,t)}catch(e){return(0,vn.AO)("Error in buildAndSendDataImmediate",e),!1}}({eventId:"crt_"+pe(),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,vn.AO)("Failed to emit cartIdsSync event",e)}}}catch(e){(0,vn.AO)("Post-update cart verification failed",e)}return!0}return(0,vn.AO)("Cart attributes update failed",{status:h.status,statusText:h.statusText}),!1}catch(e){return(0,vn.AO)("Failed to update cart attributes",e),!1}finally{Oo=Date.now(),Eo=!1}}function mn(e){return!e||"UNKNOWN - STATE"===e||!e.trim()}function fn(e){var t,n;const i=null===(t=null==e?void 0:e.session)||void 0===t?void 0:t.id,r=null===(n=null==e?void 0:e.page)||void 0===n?void 0:n.id,o=null==e?void 0:e.clientId;return!mn(i)&&!mn(r)&&!mn(o)}async function hn(){var e,t;try{(0,vn.cY)("Performing initial Shopify cart enrichment check"),await stateManager.ensureInitialized();let n=stateManager.getState();if(!fn(n)&&(await stateManager.refreshStateManually(),await stateManager.ensureInitialized(),n=stateManager.getState(),!fn(n)))return(0,vn.cY)("Skipping cart enrichment: missing required identifiers after refresh.",{sessionId:null===(e=null==n?void 0:n.session)||void 0===e?void 0:e.id,pageViewId:null===(t=null==n?void 0:n.page)||void 0===t?void 0:t.id,clientId:null==n?void 0:n.clientId}),function(e,t){var n,i,r,o,a,s,c,l;const d=Date.now();if(!(d-Yo<6e4)){Yo=d;try{null===(r=null===(i=null===(n=null==t?void 0:t.session)||void 0===n?void 0:n.id)||void 0===i?void 0:i.slice)||void 0===r||r.call(i,0,12),null===(s=null===(a=null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.id)||void 0===a?void 0:a.slice)||void 0===s||s.call(a,0,12),null===(l=null===(c=null==t?void 0:t.clientId)||void 0===c?void 0:c.slice)||void 0===l||l.call(c,0,12)}catch(e){}}}(0,n),void function(){if(Mo)return;Mo={attempts:0,ticks:0};const e=stateManager.addTickListener(async()=>{if(Mo){if(Mo.ticks+=1,!(Mo.ticks<1)){if(Mo.ticks=0,!fn(stateManager.getState()))return Mo.attempts+=1,void(Mo.attempts>=3&&(e(),Mo=null));e(),Mo=null;try{await hn()}catch(e){}}}else e()});Mo.dispose=e;try{console.log("[CST] Scheduled cart enrichment retry",{reason:"missing-identifiers"})}catch(e){}}();const i={_cst_sessionId:n.session.id,_cst_clientId:n.clientId,_cst_pageViewId:n.page.id,_cst_userId:n.userId,_cst_visitorId:n.visitorId};let r=null;try{const e=await H(fetch("/cart.js",{method:"GET",credentials:"same-origin",headers:{Accept:"application/json"}}),2e3).catch(()=>null);(null==e?void 0:e.ok)&&(r=await e.json().catch(()=>null))}catch(e){return void(0,vn.cY)("Initial cart read failed, skipping enrichment.",e)}if(!r)return void(0,vn.cY)("No cart snapshot available on init, skipping enrichment.");if(!r.token)return void(0,vn.cY)("Cart token missing on init, skipping enrichment write.");if(0===(Array.isArray(r.items)?r.items.length:0))return void(0,vn.cY)("Cart empty on init, skipping enrichment write.");const o=r.attributes||{};if(o._cst_sessionId===i._cst_sessionId&&o._cst_clientId===i._cst_clientId)return void(0,vn.cY)("Cart already enriched on init, skipping write.");await un({force:!0}),(0,vn.cY)("Initial Shopify cart enrichment complete.")}catch(e){(0,vn.AO)("Initial cart enrichment failed",e)}}async function pn(){var n,i;if(No)(0,vn.cY)("KLRR_CST_FX] Already initialized, skipping");else try{(0,vn.cY)("KLRR_CST_FX] Starting initialization"),(0,vn.cY)("KLRR_CST_FX] calling stateManager.initialize()"),await stateManager.initialize(),(0,vn.cY)("KLRR_CST_FX] state initialized; session:",stateManager.getSessionId(),"page:",stateManager.getState().page.id);let r=null;try{(0,vn.cY)("KLRR_CST_FX] running bot detection"),r=await async function(){try{const e=await go.detect(),n=e.isBot;return(0,vn.cY)("BotDetector result",e),t("cst_bot",String(n)),e}catch(e){return(0,vn.cY)("detectBot error",e),{isBot:!1,confidence:0,signals:[]}}}(),stateManager.setBotDetection(r);const{checkCanvasUaMismatch:n}=await Promise.resolve().then(e.bind(e,53));n()}catch(e){(0,vn.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,vn.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,vn.cY)("Bot detected but kept for tracking",{category:(null==r?void 0:r.botType)||"UNKNOWN",confidence:e})}(0,vn.cY)("Installing early form network interceptors"),function(){try{lt()}catch(e){(0,vn.AO)("Failed installing early network interceptors",e)}}(),(0,vn.cY)("Initializing cookie consent tracking"),sn(),(0,vn.cY)("Initializing visibility handling"),ir=()=>{(async function(){try{const e="visible"===document.visibilityState;(0,vn.cY)("Visibility changed to: "+(e?"visible":"hidden")),e?((await stateManager.isSessionValid()).isValid?((0,vn.cY)("Session valid, resuming tracking"),stateManager.resumeTracking(),pt()):((0,vn.cY)("Session invalid, creating new session"),await stateManager.handleSessionTimeout()),stateManager.updateActivity()):((0,vn.cY)("Tab hidden, pausing tracking"),stateManager.pauseTracking(),gt(),await le())}catch(e){(0,vn.AO)("Error handling visibility change",e)}})().catch(e=>(0,vn.AO)("Visibility handler error",e))},document.addEventListener("visibilitychange",ir,{passive:!0}),(0,vn.cY)("Initializing SPA tracking"),function(){try{co&&(co.disconnect(),co=null),lo=location.href,window.__cst_spa_last_url=lo,co=new MutationObserver(po);const e=R(async()=>{location.href!==lo&&((0,vn.cY)(`Route change detected: ${lo} -> ${location.href}`),await en())},100);return uo=e,window.addEventListener("popstate",e),window.addEventListener("pushState",e),window.addEventListener("replaceState",e),Qt("pushState"),Qt("replaceState"),co.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),(0,vn.cY)("SPA tracking initialized",{initialLastUrl:lo}),co}catch(e){throw(0,vn.AO)("Error setting up SPA tracking",e),e}}(),(0,vn.cY)("Initializing scroll tracking"),St(),(0,vn.cY)("Initializing click tracking"),Et(),(0,vn.cY)("Initializing enhanced form tracking"),ft(),(0,vn.cY)("Initializing input tracking"),Gt(),(0,vn.cY)("Initializing custom dropdown tracking"),ro||(ro=!0,oo=async e=>{try{if(!(e.target instanceof HTMLElement))return;const t=e.target.closest(no);if(!t)return;if(!Xt(t))return;await Jt(t)}catch(e){(0,vn.AO)("Error handling custom dropdown selection",e)}},document.addEventListener("click",oo,{capture:!0,passive:!0}),ao=async e=>{try{const t=e.key;if("Enter"!==t&&" "!==t)return;if(!(e.target instanceof HTMLElement))return;const n=e.target.closest(no);if(!n)return;if(!Xt(n))return;await Jt(n)}catch(e){(0,vn.AO)("Error handling keyboard dropdown selection",e)}},document.addEventListener("keydown",ao,{capture:!0}),(0,vn.cY)("Initialized custom dropdown tracking")),(0,vn.cY)("Initializing video tracking (HTML5, Vimeo, Wistia, Loom)"),Ct(),Yt(),Dt(),Ut(),(0,vn.cY)("Loading YouTube API and watcher"),Hr(),$r||($r=setInterval(()=>{document.querySelectorAll('iframe[src*="youtube.com/embed/"]').length>0&&(Dr||(Rr||Hr(),Fr()))},2e3)),(0,vn.cY)("Initializing activity tracking"),ue(),(0,vn.cY)("KLRR_CST_FX] Initialization complete");const a=()=>{try{(0,vn.cY)("Ensuring click tracking after DOM ready"),It()}catch(e){(0,vn.AO)("Error reinitializing click tracking",e)}try{window.__cstEnhancedFormTrackingInit&&((0,vn.cY)("Rescanning forms after DOM ready"),ht())}catch(e){(0,vn.AO)("Error rescanning forms",e)}try{(0,vn.cY)("Ensuring input tracking after DOM ready"),Gt()}catch(e){(0,vn.AO)("Error ensuring input tracking",e)}},s=()=>{(0,vn.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,vn.cY)("KLRR_CST_FX] DOMContentLoaded"),s()},{once:!0}):((0,vn.cY)("KLRR_CST_FX] DOM already ready -> ensuring interactions immediately"),s()),document.addEventListener("readystatechange",()=>{(0,vn.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,vn.cY)("DOM root changed, reapplying interaction hooks"),c())}).observe(e,{childList:!0})}}catch(e){(0,vn.AO)("Error setting up DOM replacement monitor",e)}if(window.addEventListener("online",()=>{(0,vn.cY)("Network online, retrying failed events"),(0,vn.cY)("KLRR_CST_FX] online -> retryFailedEvents()"),le()},{passive:!0}),window.addEventListener("load",()=>{(0,vn.cY)("Page load complete, retrying failed events"),(0,vn.cY)("KLRR_CST_FX] window load -> retryFailedEvents()"),le()},{passive:!0}),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&((0,vn.cY)("Document hidden, flushing queued batches"),ie({force:!0}))},{passive:!0}),window.addEventListener("pagehide",()=>{(0,vn.cY)("Pagehide event, flushing queued batches"),ie({force:!0})},{passive:!0}),vi.cleanupOldStorage(),await le(),"undefined"!=typeof window&&(null===(i=window.Shopify)||void 0===i?void 0:i.shop)){(0,vn.cY)("Shopify storefront detected, enabling cart attribute handling."),await hn(),"undefined"!=typeof document&&document.addEventListener("mousedown",e=>{const t=e.target;t.closest&&t.closest('[name="checkout"], [name="add"], .shopify-payment-button, [href*="/checkout"]')&&un({force:!0}).catch(()=>{})},{capture:!0,passive:!0}),document.addEventListener("cart:updated",()=>{(0,vn.cY)("Cart change event detected, resetting enrichment latch and queueing update.");try{e=!1}catch(e){}un({force:!1})},{passive:!0});let e=!1,t=0;const n=24,i=stateManager.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 un({force:!1})&&(e=!0,(0,vn.cY)("Cart enrichment confirmed; polling dormant"))}catch(e){(0,vn.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,vn.cY)("CST initialization complete - all handlers initialized");const l=stateManager.getState();(0,vn.cY)("Final initialization state:",{sessionValid:l.session.isValid,isTracking:l.session.isValid,sessionId:l.session.id,pageId:l.page.id}),No=!0}catch(e){throw(0,vn.AO)("CST initialization error:",e),console.error("KLRR_CST_FX] Initialization error",e),No=!1,e}}function initialize(e={}){if((0,vn.cY)("KLRR_CST_FX] initialize() called; isInitialized:",No),!No){try{t=e,fr=Object.assign(Object.assign({},fr),t)}catch(e){(0,vn.AO)("Failed applying runtime config",e)}return(0,vn.cY)("KLRR_CST_FX] invoking cst() now"),pn()}var t;return Promise.resolve()}var gn,vn,yn,wn,bn={53(e,t,n){function i(){const e=performance.now();d.push(e),d.length>20&&d.shift()}function r(){const e=performance.now(),t=window.scrollY||document.documentElement.scrollTop;if(m>0){const n=e-m;if(n>16){const e=Math.abs(t-f);u.push(e/n),u.length>30&&u.shift()}}m=e,f=t}function o(){if(null!==h)return h;try{const e=navigator.userAgent.toLowerCase(),t=document.createElement("canvas"),n=t.getContext("webgl")||t.getContext("experimental-webgl");if(!n)return h={detected:!1},h;const i=n.getExtension("WEBGL_debug_renderer_info"),r=i&&n.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",o=r.toLowerCase();return o.includes("google swiftshader")?(h={detected:!0,reason:"google_swiftshader_renderer"},(0,l.cY)("Canvas/UA mismatch: Google SwiftShader renderer"),h):o.includes("swiftshader")&&!e.includes("headless")?(h={detected:!0,reason:"swiftshader_without_headless_ua"},(0,l.cY)("Canvas/UA mismatch: SwiftShader detected without headless UA"),h):o.includes("angle")&&e.includes("linux")&&(o.includes("direct3d")||o.includes("d3d"))?(h={detected:!0,reason:"angle_d3d_on_linux"},(0,l.cY)("Canvas/UA mismatch: Direct3D ANGLE on Linux"),h):r&&"unknown"!==r&&(o.includes("llvmpipe")||o.includes("mesa")&&o.includes("software"))&&!e.includes("linux")?(h={detected:!0,reason:"software_renderer_non_linux_ua"},(0,l.cY)("Canvas/UA mismatch: Software renderer with non-Linux UA"),h):(h={detected:!1},h)}catch(e){return(0,l.cY)("Error checking Canvas/UA mismatch",e),h={detected:!1},h}}function a(e){if(e.length<3)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(d.length>=3){const t=[];for(let e=1;e<d.length;e++)t.push(d[e]-d[e-1]);const n=a(t);null!==n&&(e.clickTiming={intervalVariance:Math.round(100*n)/100,sampleCount:d.length})}if(u.length>=3){const t=a(u);null!==t&&(e.scrollVelocity={velocityVariance:Math.round(1e4*t)/1e4,hasAcceleration:s(u),sampleCount:u.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);let d=[],u=[],m=0,f=0,h=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.01.20260206"}')}},Sn={};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(gn={},{default:()=>Ro}),vn=e(154),e(330);const Tn="https://dd0gkif4bl.execute-api.us-east-2.amazonaws.com/Prod",_n="production".toLowerCase(),In="development"===_n||"staging"===_n;["development","staging","production","test"].includes(_n);const CST_LAMBDA_ENDPOINT=In?"https://dev-api.klrr.org/send":"https://api.klrr.org/send",kn=In?"cstm-dev.js":"cstm.js",An=In?"https://dev-api.klrr.org/shop":"https://api.klrr.org/shop",En=In?"https://dev-api.klrr.org/pixel-context":"https://api.klrr.org/pixel-context";In&&(0,vn.cY)("CST Configuration:",{environment:_n,apiEndpoint:CST_LAMBDA_ENDPOINT,buildTime:(new Date).toISOString()});const On="cst_fp",Ln="cst_tiid",Cn=576e3,Pn="cst_sid",Mn="cst_sid_time",Yn="cst_active_time",Nn="cst_session_entry_url",xn="cst_session_entry_referrer",Rn="cst_pvid",Dn="cst_pvid_ts",$n="cst_aq_context",Wn="cst_acquisition_context",Hn=240,Fn=144e5,jn=18e5,Un="cst_cfp",zn="cst_loc",Vn="cst_pending_batches",qn={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_"]},Bn=[/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],Kn={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 Gn,Xn=!1,Jn=null;const Qn="cst_loc_cache";!function(e){e[e.CLOSED=0]="CLOSED",e[e.OPEN=1]="OPEN",e[e.HALF_OPEN=2]="HALF_OPEN"}(yn||(yn={})),new WeakSet,wn=e(53);const Zn=(e,t)=>t,ei={botHint:Zn(0,"bH"),suspectedBot:Zn(0,"sB"),confidence:Zn(0,"cf"),category:Zn(0,"ct"),signals:Zn(0,"sg"),detectorVersion:Zn(0,"dV"),behavioral:Zn(0,"bv"),scrollVelocity:Zn(0,"sV"),velocityVariance:Zn(0,"vV"),hasAcceleration:Zn(0,"hA"),sampleCount:Zn(0,"sC"),canvasUaMismatch:Zn(0,"cU"),detected:Zn(0,"dt"),fingerprint:Zn(0,"fp"),fingerprintConfidence:Zn(0,"fC"),cfp:Zn(0,"cf_"),visitorId:Zn(0,"vI"),hint_internal_restart:Zn(0,"hIR"),hint_payment_gateway_return:Zn(0,"hPG"),inherited_context:Zn(0,"iC"),clientId:Zn(0,"cI"),userId:Zn(0,"uI"),sessionId:Zn(0,"sI"),pageViewId:Zn(0,"pI"),timestamp:Zn(0,"ts"),start:Zn(0,"st"),activeTime:Zn(0,"aT"),lastActivityTime:Zn(0,"lA"),timeSinceLastActive:Zn(0,"tS"),eventType:Zn(0,"eT"),eventId:Zn(0,"eI"),events:Zn(0,"ev"),session:Zn(0,"ss"),entryUrl:Zn(0,"eU"),entryReferrer:Zn(0,"eR"),navigationType:Zn(0,"nT"),visibilityState:Zn(0,"vS"),historyLength:Zn(0,"hL"),consentGranted:Zn(0,"cG"),pageView:Zn(0,"pV"),referrer:Zn(0,"rf"),url:Zn(0,"ur"),pathname:Zn(0,"pn"),title:Zn(0,"tt"),location:Zn(0,"lo"),city:Zn(0,"cy"),region:Zn(0,"rg"),country:Zn(0,"co"),ip:Zn(0,"ip"),cookies:Zn(0,"ck"),marketingTrackers:Zn(0,"mT"),isBot:Zn(0,"iB"),timeout:Zn(0,"to"),time:Zn(0,"tm"),cookieEnabled:Zn(0,"cE"),doNotTrack:Zn(0,"dN"),language:Zn(0,"lg"),timezoneOffset:Zn(0,"tO"),userAgent:Zn(0,"uA")},ti=async(e,t)=>{var n;try{await stateManager.ensureInitialized();let i=stateManager.getState();const r=!i.session.id||"UNKNOWN - STATE"===i.session.id,o=!i.page.id||"UNKNOWN - STATE"===i.page.id;let a=j(i);const s=U(i);if(r||o||s){await stateManager.refreshStateManually(),await stateManager.ensureInitialized();const e=stateManager.getState(),t=!e.session.id||"UNKNOWN - STATE"===e.session.id,n=!e.page.id||"UNKNOWN - STATE"===e.page.id,r=j(e),o=U(e);if(t||n)throw new Error("State not initialized - missing session/page identifiers");i=e,a=r,o&&(0,vn.cY)("buildUserBatch - Page URL unavailable after refresh; proceeding with empty url")}stateManager.isSessionValid().isValid||(0,vn.cY)("buildUserBatch - Session is invalid, batch may be outdated");const c=D(),l={sessionId:i.session.id,pageViewId:i.page.id,timestamp:c,activeTime:i.session.activeTimeInSeconds,pageActiveTime:i.page.activeTimeInSeconds},d=[];t?d.push({[ei.eventId]:pe(),[ei.eventType]:t,[ei.time]:D(),[ei.activeTime]:i.page.activeTimeInSeconds,[ei.timeout]:!1}):e&&d.push(e);const u=stateManager.getBotDetection(),m=(0,wn.vj)(),f=u?{[ei.suspectedBot]:u.isBot,[ei.category]:u.botType,[ei.confidence]:u.confidence,[ei.signals]:u.signals,[ei.detectorVersion]:"bot-detector-v1",[ei.behavioral]:Object.keys(m).length>0?m:void 0}:Object.keys(m).length>0?{[ei.suspectedBot]:!1,[ei.detectorVersion]:"bot-detector-v1",[ei.behavioral]:m}:void 0,h=i.session.hint_internal_restart,p=i.session.hint_payment_gateway_return,g=i.session.inherited_context,v=stateManager.getFingerprintConfidence();return{[ei.clientId]:i.clientId,[ei.userId]:i.userId,[ei.visitorId]:i.visitorId,[ei.fingerprint]:i.fingerprint,[ei.timestamp]:l.timestamp,[ei.eventType]:t||(null==e?void 0:e.eventType)||"heartbeat",[ei.isBot]:null!==(n=null==u?void 0:u.isBot)&&void 0!==n&&n,[ei.botHint]:f,[ei.fingerprintConfidence]:v,[ei.session]:{[ei.sessionId]:l.sessionId,[ei.start]:i.session.startTimestamp,[ei.entryUrl]:i.session.entryUrl||a,[ei.entryReferrer]:i.session.entryReferrer||void 0,[ei.cookies]:i.parsedCookies,[ei.marketingTrackers]:i.parsedMarketingTrackers,[ei.activeTime]:l.activeTime,[ei.lastActivityTime]:i.session.lastActivityTime,[ei.location]:i.location,[ei.consentGranted]:null===i.cookieConsent?void 0:i.cookieConsent,[ei.navigationType]:i.session.navigationType,[ei.visibilityState]:i.session.visibilityState,[ei.timeSinceLastActive]:i.session.timeSinceLastActive,[ei.historyLength]:i.session.historyLength,[ei.hint_internal_restart]:h,[ei.hint_payment_gateway_return]:p,[ei.inherited_context]:g,[ei.pageView]:{[ei.pageViewId]:l.pageViewId,[ei.activeTime]:l.pageActiveTime,[ei.referrer]:i.page.referrer,[ei.lastActivityTime]:i.page.lastActivityTime,[ei.url]:a,[ei.pathname]:i.page.pathname,[ei.title]:i.page.title,[ei.start]:i.page.startTimestamp,[ei.events]:d}}}}catch(e){throw(0,vn.AO)("Error in buildUserBatch",e),e}},ni=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 ii=0,ri=null,oi=0;const ai=Math.max(1,15);let si=!1,ci=!1;const li=R(()=>{J()},200),di=1e3,ui=Vn;let mi=!1,fi=null,hi=null;const pi=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,vn.cY)("Activity detected, updating state"),await stateManager.updateActivity()},5e3),gi=()=>{fi&&clearTimeout(fi),fi=setTimeout(()=>{(0,vn.cY)("Inactivity timeout reached, triggering session end"),stateManager.handleSessionTimeout()},jn),pi()},vi=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,vn.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=$();Object.keys(localStorage).forEach(t=>{if(t!==$n&&t!==Wn){if(t.startsWith("cst_")||t.startsWith("pageview_")){const n=localStorage.getItem(t);n&&!isNaN(Number(n))&&e-Number(n)>2592e6&&localStorage.removeItem(t)}}else fe(e)})}},yi=["shopify.com","paypal.com","stripe.com","squareup.com","afterpay.com","klarna.com","affirm.com","adyen.com"],wi={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 bi{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:wi,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,vn.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=vi.getItem("local","cst_last_activity_time");if(!e)return null;const t=W(e);return Number.isFinite(t)?t:null}catch(e){return null}}captureSessionStartSignals(e,t=$()){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=`${Yn}_${this.state.session.id}`,t=this.state.session.activeTimeInSeconds.toString(),n=this.state.session.lastActivityTime.toString();vi.setItem("session",e,t),vi.setItem("local",e,t),vi.setItem("local","cst_last_activity_time",n),(0,vn.cY)(`Active time retry successful: ${t}s`)}catch(e){(0,vn.AO)("Active time retry failed",e)}}handleFormSubmit(e){this.formSubmitTimeout&&clearTimeout(this.formSubmitTimeout),this.formSubmitTimeout=setTimeout(()=>{(0,vn.cY)("Form submitted, refreshing state for new cookies"),this.refreshState().catch(e=>(0,vn.AO)("Error refreshing state after form submit",e)),this.formSubmitTimeout=null},500)}isStoredSessionValid(e){const t=$();return!(t-e.startTime>Fn||t-e.lastActivityTime>jn)}async initializeSession(){var e,t;(0,vn.cY)("Initializing session");const n=this.loadStoredSession();if(console.log(`DEBUG: initializeSession storedSession=${n?n.id:"null"}\n`),n){if(this.isStoredSessionValid(n)){(0,vn.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=`${Yn}_${this.state.session.id}`,r=vi.getItem("session",i),o=vi.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,vn.cY)("Session invalid, creating new session"),await this.handleSessionEnd("manual")}(0,vn.cY)("No existing session, creating new session"),await this.createNewSession()}loadStoredSession(){try{const e=n(Pn)||vi.getItem("local",Pn),t=n(Mn)||vi.getItem("local",Mn),i=vi.getItem("local","cst_last_activity_time"),r=n(Nn)||vi.getItem("local",Nn)||"",o=n(xn)||vi.getItem("local",xn)||"",a=this.captureEntryPoint(),s=`${Yn}_${e}`,c=vi.getItem("session",s),l=vi.getItem("local",s);if(!e||!t)return(0,vn.cY)("No stored session found"),null;if(!i)return(0,vn.cY)("No stored last activity time; stored session invalid"),null;const d=this.getStoredActiveSeconds(c,l);let u,m;try{u=W(t)}catch(e){return(0,vn.cY)("Invalid stored session start time format",t),null}try{m=W(i)}catch(e){return(0,vn.cY)("Invalid stored last activity time",i),null}if(!Number.isFinite(m)||m<=0)return(0,vn.cY)("Parsed last activity time invalid",m),null;const f=new Date(u).toISOString();return(0,vn.cY)("Found stored session",{sessionId:e,startTimeRaw:t,activeTimeInSeconds:d}),{id:e,startTime:u,startTimestamp:f,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,vn.AO)("Error loading stored session",e),null}}isSessionValid(){if(!this.state.session.isValid)return(0,vn.cY)("Session invalid: already marked as invalid"),{isValid:!1};const e=$(),t=e-this.state.session.startTime,n=e-this.state.session.lastActivityTime;return(0,vn.cY)(`Session age: ${t/1e3}s, Inactivity time: ${n/1e3}s`),t>Fn?((0,vn.cY)("Session invalid: Max duration exceeded"),this.handleSessionEnd("maxDuration"),{isValid:!1,reason:"maxDuration"}):n>jn?((0,vn.cY)("Session invalid: Inactivity timeout"),this.handleSessionEnd("timeout"),{isValid:!1,reason:"timeout"}):{isValid:!0}}async createNewSession(){if((0,vn.cY)("createnewssession called"),this.isHandlingSessionOperation)(0,vn.cY)("Session operation in progress, skipping new session creation");else{this.isHandlingSessionOperation=!0;try{(0,vn.cY)("creating new session");const e=this.captureEntryPoint(),t=this.getLastActivityFromStorage();await this.handleSessionEnd("manual"),this.clearSessionStorage();const n=$(),i=D(),r=this.captureSessionStartSignals(t,n),o=fe(n),a=this.safeHostname(e.url),s=this.safeHostname(e.referrer),c=a?N(a):"",l=s?N(s):"",d=!(!e.referrer||!e.referrer.trim()),u=this.hasAttributionParams(e.url),m=!!l&&!!c&&l===c,f=!!l&&yi.some(e=>l===e);let h,p=!1,g=!1,v=!1,y=!1;f&&o?(h=o,p=!0):m&&o?(h=o,g=!0):u||d&&!m?v=!0:y=!0;const w=Object.assign({id:`s_${pe()}`,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!=h?h: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($n,JSON.stringify(n))}catch(e){(0,vn.AO)("Error saving acquisition context",e)}}({sessionId:w.id,entryUrl:e.url,entryReferrer:d?e.referrer:null,createdAt:i,version:"v1"}),(0,vn.cY)("Persisted acquisition context for new arrival",{sessionId:w.id,hasReferrer:d,hasAttributionParams:u})):y&&he(),(0,vn.cY)("Creating new session",w.id),this.state.session=w,this.isTracking=!0,this.state.session.isValid=!0,this.persistSession(w),this.startUnifiedTimer(),ue(),gt(),pt(),await this.initializePageView(),this.publishContext(),!this.isInitializing){this.initialDataSent=!1,this.initialDataSent=!0,(0,vn.cY)("Sending initial data for new session",w.id);try{await Q()||(this.initialDataSent=!1)}catch(e){(0,vn.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,vn.AO)("Invalid session data, cannot persist");const n=a();t(Pn,e.id,Hn,{domain:n,path:"/",sameSite:"Lax"}),t(Mn,e.startTimestamp,Hn,{domain:n,path:"/",sameSite:"Lax"}),vi.setItem("local",Pn,e.id),vi.setItem("local",Mn,e.startTimestamp);const i=this.sanitizeCookieData(e.entryUrl);t(Nn,i,Hn,{domain:n,path:"/",sameSite:"Lax"});const r=this.sanitizeCookieData(e.entryReferrer);r?t(xn,r,Hn,{domain:n,path:"/",sameSite:"Lax"}):t(xn,"",-1,{domain:n,path:"/",sameSite:"Lax"}),vi.setItem("local",Nn,i),r?vi.setItem("local",xn,r):vi.removeItem("local",xn)}catch(e){(0,vn.AO)("Error persisting session",e)}}async handleSessionEnd(e){try{(0,vn.cY)(`Ending session due to: ${e}`),this.state.session.isValid=!1,this.isTracking=!1,this.clearAllIntervals(),gt(),this.saveActiveTime(),await le(),this.clearSessionStorage(),vi.cleanupOldStorage(),this.publishContext()}catch(e){(0,vn.AO)("Error ending session",e)}}static getInstance(){return bi.instance||(bi.instance=new bi),bi.instance}getState(){return $()-this.state.lastCookieUpdate>3e5&&this.refreshState().catch(e=>(0,vn.AO)("Error in getState refresh",e)),this.state}setCookieConsent(e){this.state.cookieConsent=e}async refreshState(){var e;try{const{allCookies:s,marketingTrackers:c}=i(document.cookie),l={},d={};for(const[e,t]of Object.entries(r(s)))l[e]=this.sanitizeCookieData(t);for(const[e,t]of Object.entries(o(c)))d[e]=this.sanitizeCookieData(t);const m=await async function(){var e;const t=function(){try{return ge(n(Si)||n(Ti)||localStorage.getItem(Ti)||null)}catch(e){return null}}();try{let i=n(On)||null;if(!i)try{"undefined"!=typeof localStorage&&(i=localStorage.getItem(On))}catch(e){i=null}const r=ge(i);if(r){if((0,vn.cY)("Using stored visitor ID from cookies:",r),t&&ve(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 we(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?(ye(r),stateManager.setFingerprintConfidence(n),r):await we(t)}return await we(t)}catch(e){return(0,vn.AO)("Error in getVisitorId:",e),stateManager.setFingerprintConfidence(null),"UNKNOWN"}}()||"",f=await async function(){const e=n(Un);if(e)return e;const i=await u(),r=a();return t(Un,i,576e3,{domain:r,path:"/",sameSite:"Lax"}),i}()||"",h=await async function(){try{const e=function(){var e,t;const i=Date.now();try{const t=localStorage.getItem(Qn);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(Qn)}}catch(e){(0,vn.cY)("Unable to read location from localStorage",e)}const r=n(zn);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(CST_LAMBDA_ENDPOINT);return e.pathname="/geo",e.toString()}catch(e){return CST_LAMBDA_ENDPOINT.replace(/\/[^/]*$/,"/geo")}}();(0,vn.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,vn.cY)("Geo data from Cloudflare:",null==i?void 0:i.country)}finally{clearTimeout(n)}}catch(e){(0,vn.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,vn.cY)("Geo data from fallback:",null==i?void 0:i.country_name))}finally{clearTimeout(t)}}catch(e){return(0,vn.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(Qn,JSON.stringify({data:e,cachedAt:i}))}catch(e){(0,vn.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(zn,JSON.stringify(r),60)}(o),o}catch(e){return(0,vn.AO)("Error fetching location:",e),null}}()||wi,p=await L().catch(()=>null);this.state=Object.assign(Object.assign({},this.state),{parsedCookies:l,parsedMarketingTrackers:d,lastCookieUpdate:$(),clientId:be()||"",visitorId:m,userId:Se()||"",fingerprint:{userAgent:navigator.userAgent||"",language:navigator.language||"",timezoneOffset:(new Date).getTimezoneOffset(),doNotTrack:null!==(e=navigator.doNotTrack)&&void 0!==e?e:"",cfp:f,cookieEnabled:navigator.cookieEnabled,fpCurrent:null==p?void 0:p.raw,fpStable:null==p?void 0:p.stable,fpEntropy:null==p?void 0:p.entropy,fpConfidence:null==p?void 0:p.confidence,fpSignals:null==p?void 0:p.signals,fpStability:null==p?void 0:p.stability,fpAntiFingerprinting:null==p?void 0:p.antiFingerprinting,fpBrowser:null==p?void 0:p.browser,fpRaw:null==p?void 0:p.rawSignals,fpCollectedAt:null==p?void 0:p.collectedAt},location:h}),(0,vn.cY)("State refreshed",this.state),this.publishContext()}catch(e){(0,vn.AO)("Error refreshing state",e)}}getSessionId(){return this.state.session.id}getActiveTime(){return this.state.session.activeTimeInSeconds}async updateActivity(){try{(0,vn.cY)("updateActivity called");const e=$();if(!e||e<0)return void(0,vn.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,vn.cY)(`Updated session last activity time to ${new Date(e).toISOString()}`),this.unifiedTimer||this.startUnifiedTimer()}catch(e){(0,vn.AO)("Error updating activity",e)}}async initialize(){var e,t;if(this.initialized)(0,vn.cY)("StateManager already initialized");else{if(this.isInitializing){(0,vn.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,vn.cY)("StateManager initialization completed while waiting")}(0,vn.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,vn.cY)("State validation successful during initialization")):(n--,(0,vn.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,vn.AO)("Failed to initialize state with valid data after retries"),await this.initializeSession(),this.state.session.isValid&&pt(),this.startUnifiedTimer(),this.initialized=!0,(0,vn.cY)("StateManager initialization completed successfully"),this.publishContext(),!this.initialDataSent){this.initialDataSent=!0,(0,vn.cY)("Sending initial data after initialization");try{await Q()||(this.initialDataSent=!1)}catch(e){(0,vn.AO)("Error sending initial data after initialization",e),this.initialDataSent=!1}}ie()}catch(e){throw this.initialized=!1,(0,vn.AO)("Error initializing StateManager",e),e}finally{this.isInitializing=!1}}}stopTracking(){(0,vn.cY)("Stopping all tracking"),this.isTracking=!1,this.clearAllIntervals(),this.saveActiveTime()}pauseTracking(){(0,vn.cY)("Pausing tracking"),this.isTracking=!1,this.clearAllIntervals(),this.saveActiveTime()}async resumeTracking(){(0,vn.cY)("Resuming tracking"),this.isSessionValid().isValid?(this.isTracking=!0,this.startUnifiedTimer()):await this.createNewSession()}saveActiveTime(){try{if(!this.state.session.id)return;const e=`${Yn}_${this.state.session.id}`,t=this.state.session.activeTimeInSeconds.toString(),n=this.state.session.lastActivityTime.toString();vi.setItem("session",e,t),vi.setItem("local",e,t),vi.setItem("local","cst_last_activity_time",n),(0,vn.cY)(`Active time saved: ${t}s`)}catch(e){(0,vn.AO)("Error saving active time",e),e instanceof Error&&"QuotaExceededError"===e.name&&(vi.cleanupOldStorage(),this.retrySaveActiveTime())}}clearSessionStorage(){if(!this.state.session.isValid){const e=new Date(0).toUTCString(),t=a();document.cookie=`${Pn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${Mn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${Nn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${xn}=; expires=${e}; path=/; SameSite=Lax; Secure`,t&&(document.cookie=`${Pn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${Mn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${Nn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${xn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`);const n=`${Yn}_${this.state.session.id}`;vi.removeItem("session",n),vi.removeItem("local",n),vi.removeItem("local",Pn),vi.removeItem("local",Mn)}}async endCurrentPageViewAndStartNew(e){(0,vn.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,vn.cY)("Session became invalid during page transition, creating new session"),void await this.createNewSession();await this.initializePageView(e),(0,vn.cY)("Page view transition complete",{session:this.state.session,newPage:this.state.page})}async endCurrentPageView(){try{(0,vn.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,vn.AO)("Error ending page view",e)}}async initializePageView(e){if((0,vn.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,vn.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=$(),n=D();this.state.page=Object.assign({id:`pv_${pe()}`,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,vn.cY)("Page view initialized, initial data sending will be handled separately")}persistPageViewState(){try{const e=a();t(Rn,this.state.page.id,Hn,{domain:e,path:"/",sameSite:"Lax"}),t(Dn,encodeURIComponent(this.state.page.startTimestamp),Hn,{domain:e,path:"/",sameSite:"Lax"}),vi.setItem("local",Rn,this.state.page.id),vi.setItem("local",Dn,this.state.page.startTimestamp),this.savePageViewTime()}catch(e){(0,vn.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}`;vi.setItem("session",e,this.state.page.activeTimeInSeconds.toString()),vi.setItem("session",t,this.state.page.lastActivityTime.toString()),(0,vn.cY)(`Page view time saved: ${this.state.page.activeTimeInSeconds}s`)}catch(e){(0,vn.AO)("Error saving page view time",e)}}async sendPageViewEvent(){const e=await ti(null,"initial");await Z(e)}clearPageViewStorage(){const e=new Date(0).toUTCString(),t=a();document.cookie=`${Rn}=; expires=${e}; path=/; SameSite=Lax; Secure`,document.cookie=`${Dn}=; expires=${e}; path=/; SameSite=Lax; Secure`,t&&(document.cookie=`${Rn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`,document.cookie=`${Dn}=; expires=${e}; path=/; domain=${t}; SameSite=Lax; Secure`),vi.removeItem("local",Rn),vi.removeItem("local",Dn),vi.removeItem("session",`pageview_time_${this.state.page.id}`),vi.removeItem("session",`pageview_last_active_${this.state.page.id}`)}cleanup(){try{(0,vn.cY)("Starting StateManager cleanup"),this.clearAllIntervals(),this.tickListeners.clear(),me(),rr(),"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(),gt(),this.isTracking=!1,this.initialized=!1,this.isHandlingSessionOperation=!1,this.initialDataSent=!1,this.state.botDetection=null,le().catch(e=>(0,vn.AO)("Error clearing queued events during cleanup",e)),(0,vn.cY)("StateManager cleanup completed")}catch(e){(0,vn.AO)("Error during StateManager cleanup",e)}}async handleSessionTimeout(){if(this.isHandlingSessionOperation)(0,vn.cY)("Session operation already in progress, skipping timeout handler");else{this.isHandlingSessionOperation=!0;try{(0,vn.cY)("Session timeout triggered"),this.saveActiveTime(),gt(),this.stopTracking(),this.state.session.isValid=!1}finally{this.isHandlingSessionOperation=!1}}}async refreshStateManually(){(0,vn.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=$();if(this.lastSaveTimestamp=this.lastSaveTimestamp||e,this.state.session.id&&0===this.state.session.activeTimeInSeconds){const e=`${Yn}_${this.state.session.id}`;try{const t=vi.getItem("session",e);t&&!isNaN(Number(t))&&(this.state.session.activeTimeInSeconds=Number(t))}catch(e){(0,vn.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,vn.cY)(`Session invalid during timer tick: ${t}`),void(t||await this.handleSessionEnd("manual"));if("visible"!==document.visibilityState)return;if($()-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=$();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,vn.AO)("Unified tick listener error",e)}}catch(e){}if(5e3*this.unifiedTicks>=288e5)return(0,vn.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,vn.AO)("Unified timer marketing refresh error",e)}this.unifiedTicks%180==0&&this.refreshState().catch(e=>(0,vn.AO)("Unified timer state refresh error",e)),this.unifiedTicks%4320==0&&vi.cleanupOldStorage(),r-this.lastSaveTimestamp>=3e4&&(this.saveActiveTime(),this.savePageViewTime(),this.lastSaveTimestamp=r,this.stateChanged=!1)}catch(e){(0,vn.AO)("Unified timer error",e),this.clearAllIntervals(),this.startUnifiedTimer()}},5e3)}}const stateManager=bi.getInstance(),Si="_shopify_y",Ti="_cst_shopifyVisitorId",_i=new WeakMap,Ii={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},ki={formsFound:0,formsSubmitted:0,buttonSubmissions:0,formsMissed:0,universalSuccess:0,providerSuccess:0,providerTriggers:{},errors:[],duplicatesBlocked:0};"undefined"!=typeof window&&(window.__cstFormMetrics=ki);const Ai=new Map,Ei=new Map,Oi=Ii.DEDUPLICATION_WINDOW,Li=new Map,Ci=new Map,Pi=new Map,Mi=new Set(["email","phone","firstname","first_name","lastname","last_name","name","company","subject","message"]),Yi=new Set,Ni=new Map,xi=new Set,Ri=new WeakMap;let Di=0,$i=0,Wi=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"]),ji=["contact","customer","email","phone","first_name","firstname","last_name","lastname"],Ui=[{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"}],zi={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}},Vi={inProgress:!1,completed:!1,lastAttemptAt:0},qi=(new Map,{submitted:["onformsubmitted","submitted","onformsubmit","submission"],ready:["onformready","ready","formready"],complete:["formsubmissioncomplete","complete","success"]}),Bi="__cstWrapped",Ki="__cstOriginal",Gi=[new RegExp(CST_LAMBDA_ENDPOINT.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],Xi=[/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],Ji=[/hubspot/i,/hsforms/i,/hs-/i,/\.hs\./i,/meeting/i,/calendar/i,/schedule/i,/book/i],Qi=new Set,Zi=new WeakSet;let er=!1,tr=null;const nr=3e4;let ir=null;const rr=()=>{ir&&(document.removeEventListener("visibilitychange",ir),ir=null)};let or=Object.assign({},Kn),ar=null,sr=0,cr=!1,lr=null,dr=0,ur=!1,mr=!1,fr=Object.assign({},{clickTrackingMode:"standard",autoEnhanceClicks:!0,alwaysIncludeClasses:!1,includeDataAnlInStandard:!1}),hr="",pr=!1,gr=null,vr=null,yr=new WeakSet;const wr=new Map,br=new WeakSet,Sr=new WeakMap;let Tr=null;const _r=new Map,Ir=new WeakSet,kr=new WeakMap,Ar=new Map,Er=new Set,Or=new WeakSet,Lr=new WeakMap,Cr=new Map,Pr=new Set,Mr=new WeakSet,Yr=new WeakMap;let Nr=!1,xr=null,Rr=!1,Dr=!1,$r=null;const Wr=()=>Dr,Hr=()=>{if(Rr)return;const e=document.createElement("script");e.src="https://www.youtube.com/iframe_api",e.async=!0,e.onload=()=>{(0,vn.cY)("YouTube API script loaded")},e.onerror=()=>{(0,vn.AO)("Failed to load YouTube API script"),Rr=!1,Dr=!1,setTimeout(Hr,1e3)};const t=document.getElementsByTagName("script")[0];(null==t?void 0:t.parentNode)&&(t.parentNode.insertBefore(e,t),(0,vn.cY)("YouTube API script loading"),Rr=!0)},Fr=()=>!(!window.YT||!window.YT.Player||(Dr=!0,(0,vn.cY)("YouTube API loaded successfully"),zt(!0),$r&&(clearInterval($r),$r=null),0));window.onYouTubeIframeAPIReady=()=>{Fr()};const jr=new Map,Ur=new WeakMap,zr=20,Vr=100;let qr=null;const Br=e=>{try{const t=e;t.id=t.id||`yt-${pe()}`;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,vn.cY)("youtube iframe configured:",{id:t.id,src:t.src})),t}catch(t){return(0,vn.AO)("Error adding ID and enablejsapi to YouTube iframe",t),e}},Kr=new WeakSet,Gr=new WeakMap;let Xr=null,Jr=null,Qr=!1,Zr=null,eo=null,to=null;const no=["[role='option']","li[role='option']","[aria-selected]","[data-value]",".multiselect__option",".select2-results__option",".MuiAutocomplete-option",".rc-select-item-option"].join(", "),io=["[role='combobox']","[role='listbox']","[aria-haspopup='listbox']",".multiselect",".select2",".MuiAutocomplete-root",".rc-select"].join(", ");let ro=!1,oo=null,ao=null;const so=10;let co=null,lo=location.href,uo=null;const mo="__cstSpaHistoryWrapped";let fo=new WeakSet;const ho=R(()=>{try{ht()}catch(e){(0,vn.AO)("Error in debounced enhanced form rescan",e)}},100),po=R(e=>{try{const t={depth:0,processedNodes:new Set,startTime:performance.now()};if(location.href!==lo)return(0,vn.cY)("Mutation observer detected route change",{lastUrl:lo,currentUrl:location.href}),void en();!function(e,t){if(performance.now()-t.startTime>100)(0,vn.cY)("Mutation processing time limit exceeded");else if(t.depth>=so)(0,vn.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,vn.cY)("Maximum nodes per mutation reached"):e instanceof HTMLElement&&Zt(e,t))})}(e,t)}catch(e){(0,vn.AO)("Error in mutation observer callback",e)}},100);class go{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,vn.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,vn.cY)("Permissions check error",e)}return e}static getConnectionSignalHints(){const e=[];try{const t=stateManager.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,vn.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"}}go.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],go.AUTOMATION_PROPERTIES=new Set(["webdriver","_phantom","__nightmare","__selenium_evaluate","__webdriver_script_fn","__fxdriver_evaluate","__driver_evaluate","callPhantom","ChromeDriver"]),go.MIN_SIGNALS_FOR_BOT=2,go.MAX_CONFIDENCE=1,go.SIGNAL_WEIGHT=.33;let vo=!1;const yo=[],wo=[];let bo=null;const So="/sync",To=new Map,_o=[];let Io=!1,ko=null,Ao=0,Eo=!1,Oo=0;const Lo=2e3,Co=/\[cst:[^\]]+\]/i,Po=/\[cst:[^\]]+\]/gi;let Mo=null,Yo=0,No=!1;const xo="2.0.01.20260206";window.CST_VERSION=xo,console.log("CST version:",xo);try{if("undefined"!=typeof window){const e=window;e.__KLEERR_PIXEL_ENDPOINT||(e.__KLEERR_PIXEL_ENDPOINT=An)}}catch(e){(0,vn.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,vn.cY)("KLRR_CST_FX] Global set: window.KLRR_CSTM_FX")),e.KLRR_CST_FX||(e.KLRR_CST_FX=e.KLRR_CSTM_FX,(0,vn.cY)("KLRR_CST_FX] Back-compat: window.KLRR_CST_FX → window.KLRR_CSTM_FX")),e.CST?(0,vn.cY)("KLRR_CST_FX] window.CST already defined; keeping existing alias"):(e.CST=e.KLRR_CSTM_FX,(0,vn.cY)("KLRR_CST_FX] Back-compat: window.CST → window.KLRR_CSTM_FX")),(0,vn.cY)("CST attempting auto-initialization"),initialize().catch(e=>{console.error("CST initialization failed:",e)})}const Ro=CSTExport;return gn.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();