{"version":3,"file":"FunnelTracking.BoFfpknf.mjs","names":[],"sources":["https:/framerusercontent.com/modules/U4nbGG9MtrI8z9rPmRAR/IWTLBNYGYg9NL3OEohyB/FunnelTracking.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{RenderTarget,useTracking}from\"framer\";/**\n * Funnel tracking for landing pages.\n * Sends Framer Analytics custom events (visible via the analytics API):\n *   <prefix>-scroll-25 / -50 / -75 / -100   how far the visitor scrolled\n *   <prefix>-time-30                         stayed at least 30 seconds\n *   <prefix>-calendar-seen                   the #book-call section entered the viewport\n *   <prefix>-calendar-open                   Calendly widget loaded and viewed\n *   <prefix>-calendar-slot                   a date and time was selected\n *   <prefix>-calendar-booked                 the booking was completed\n * prefix is derived from the pathname: /chatgpt-ads -> cgpt, /sv/chatgpt-ads -> cgpt-sv, /wine-spirits -> ws.\n * Each event fires once per page load.\n */function prefixFor(pathname){const p=pathname.replace(/\\/+$/,\"\")||\"/\";if(p===\"/\")return\"home\";if(p===\"/sv/chatgpt-ads\")return\"cgpt-sv\";if(p===\"/chatgpt-ads\")return\"cgpt\";if(p===\"/wine-spirits\"||p===\"/wine-and-spirits\")return\"ws\";// CMS detail pages are grouped by their section so events are not split per item:\n// /case/livetec -> case, /ai-work/caia -> ai-work, /blog/xyz -> blog, /sv/foo -> sv-foo\nconst parts=p.replace(/^\\//,\"\").split(\"/\");const base=parts[0]===\"sv\"&&parts.length>1?\"sv-\"+parts[1]:parts[0];const slug=base.replace(/[^a-z0-9]+/gi,\"-\").replace(/^-+|-+$/g,\"\").toLowerCase();return slug.length>0?slug:\"home\";}function fromCalendly(origin){return origin===\"https://calendly.com\"||/^https:\\/\\/[a-z0-9-]+\\.calendly\\.com$/.test(origin);}export function withFunnelTracking(Component){return props=>{const track=useTracking();useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas)return;if(typeof window===\"undefined\")return;const prefix=prefixFor(window.location.pathname);const fired=new Set;const fire=id=>{const full=prefix+\"-\"+id;if(fired.has(full))return;fired.add(full);try{track(full);}catch(e){}};const onScroll=()=>{const doc=document.documentElement;const max=doc.scrollHeight-window.innerHeight;if(max<=0)return;const pct=window.scrollY/max*100;if(pct>=25)fire(\"scroll-25\");if(pct>=50)fire(\"scroll-50\");if(pct>=75)fire(\"scroll-75\");if(pct>=95)fire(\"scroll-100\");};const onMessage=e=>{if(!e.data||typeof e.data!==\"object\")return;if(!fromCalendly(e.origin))return;const ev=e.data.event;if(ev===\"calendly.event_type_viewed\"||ev===\"calendly.profile_page_viewed\"){fire(\"calendar-open\");fire(\"calendar-loaded\");}else if(ev===\"calendly.date_and_time_selected\")fire(\"calendar-slot\");else if(ev===\"calendly.event_scheduled\")fire(\"calendar-booked\");};const timer=window.setTimeout(()=>fire(\"time-30\"),3e4);let observer=null;const target=document.getElementById(\"book-call\");if(target&&\"IntersectionObserver\"in window){observer=new IntersectionObserver(entries=>{if(entries.some(en=>en.isIntersecting)){fire(\"calendar-seen\");observer?.disconnect();}},{threshold:.25});observer.observe(target);}const onBlur=()=>{const el=document.activeElement;if(el&&el.tagName===\"IFRAME\"&&(el.src||\"\").includes(\"calendly.com\"))fire(\"calendar-engaged\");};window.addEventListener(\"blur\",onBlur);window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"message\",onMessage);onScroll();return()=>{window.clearTimeout(timer);window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"message\",onMessage);observer?.disconnect();};},[track]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withFunnelTracking\":{\"type\":\"reactHoc\",\"name\":\"withFunnelTracking\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FunnelTracking.map"],"mappings":"yLAWG,SAAS,EAAU,EAAS,CAAC,IAAM,EAAE,EAAS,QAAQ,OAAO,EAAE,GAAG,IAAI,GAAG,IAAI,IAAI,MAAM,OAA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