{"version":3,"file":"ReliableSectionScroll.CI8LdLYJ.mjs","names":["useCallback"],"sources":["https:/framerusercontent.com/modules/GDr1HyUvVIx0jXbiwp2D/psH6n8yLOupqHTqnkBhC/ReliableSectionScroll.js"],"sourcesContent":["// User request: Create a Framer code override export named ReliableSectionScroll for existing canvas hero CTA frames that preserves canvas styling/interactions, intercepts same-path hash links on click, updates hash without reload, retries scrolling until target exists after transitions, re-scrolls even when hash is unchanged, and leaves non-hash or different-path links untouched.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback}from\"react\";function normalizePathname(pathname){if(!pathname)return\"/\";if(pathname.length>1&&pathname.endsWith(\"/\"))return pathname.slice(0,-1);return pathname;}function decodeHashToId(hash){const value=hash.startsWith(\"#\")?hash.slice(1):hash;try{return decodeURIComponent(value);}catch{return value;}}function scrollToHashTargetWhenReady(hash){if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const maxWaitMs=1800;const retryDelayMs=120;const startTime=typeof performance!==\"undefined\"?performance.now():Date.now();const targetId=decodeHashToId(hash);if(!targetId)return;let stopped=false;let frameId=0;let timerId=0;const stop=()=>{stopped=true;if(frameId)window.cancelAnimationFrame(frameId);if(timerId)window.clearTimeout(timerId);};const attempt=()=>{if(stopped)return;const elapsed=(typeof performance!==\"undefined\"?performance.now():Date.now())-startTime;const target=document.getElementById(targetId);if(target){stop();target.scrollIntoView({behavior:\"smooth\",block:\"start\",inline:\"nearest\"});return;}if(elapsed>=maxWaitMs){stop();return;}timerId=window.setTimeout(()=>{frameId=window.requestAnimationFrame(attempt);},retryDelayMs);};attempt();}export function ReliableSectionScroll(Component){return /*#__PURE__*/forwardRef(function ReliableSectionScrollOverride(props,ref){const handleClick=useCallback(event=>{if(props.onClick)props.onClick(event);if(event?.defaultPrevented)return;if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const targetElement=event?.target instanceof Element?event.target:null;const currentTarget=event?.currentTarget instanceof Element?event.currentTarget:null;const anchor=(targetElement?.closest?.(\"a[href]\"))??(currentTarget?.closest?.(\"a[href]\"));if(!anchor)return;const href=anchor.getAttribute(\"href\")||anchor.href;if(!href)return;let destination;try{destination=new URL(href,window.location.href);}catch{return;}const hasHash=Boolean(destination.hash);const sameOrigin=destination.origin===window.location.origin;const samePath=normalizePathname(destination.pathname)===normalizePathname(window.location.pathname);if(!hasHash||!sameOrigin||!samePath)return;event.preventDefault();const nextUrl=`${window.location.pathname}${window.location.search}${destination.hash}`;if(typeof window.history!==\"undefined\"&&window.history.pushState){window.history.pushState(null,\"\",nextUrl);}else{window.location.hash=destination.hash;}scrollToHashTargetWhenReady(destination.hash);},[props.onClick]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClick});});}\nexport const __FramerMetadata__ = {\"exports\":{\"ReliableSectionScroll\":{\"type\":\"reactHoc\",\"name\":\"ReliableSectionScroll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReliableSectionScroll.map"],"mappings":"uIACqF,SAAS,EAAkB,EAAS,CAAiG,OAA5F,EAAsB,EAAS,OAAO,GAAG,EAAS,SAAS,GAAG,EAAS,EAAS,MAAM,EAAE,EAAE,EAAS,EAApF,GAA6F,CAAC,SAAS,EAAe,EAAK,CAAC,IAAM,EAAM,EAAK,WAAW,GAAG,EAAE,EAAK,MAAM,CAAC,EAAE,EAAK,GAAG,CAAC,OAAO,mBAAmB,CAAK,CAAE,MAAM,CAAC,OAAO,CAAM,CAAC,CAAC,SAAS,EAA4B,EAAK,CAAC,GAAU,IAAS,QAAa,OAAO,SAAW,IAAY,OAAO,IAAkD,EAAU,OAAO,YAAc,IAAY,YAAY,IAAI,EAAE,KAAK,IAAI,EAAQ,EAAS,EAAe,CAAI,EAAE,GAAG,CAAC,EAAS,OAAO,IAAI,EAAQ,GAAU,EAAQ,EAAM,EAAQ,EAAQ,MAAS,CAAC,EAAQ,GAAQ,GAAQ,EAAO,qBAAqB,CAAO,EAAK,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