{"version":3,"file":"BottomPageLink_prod.CS0O5NE5.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/vlGYqAjDpnzcITcuj7JS/ZqJCSQLf5qSfOrcosV7O/BottomPageLink_prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,startTransition}from\"react\";// @ts-ignore\nimport{useRouter}from\"framer\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function BottomPageLink({url,newTab,delay}){// Get router navigation function and routes from Framer\nconst{navigate,routes}=useRouter()||{};const containerRef=useRef(null);const hasNavigatedRef=useRef(false);const timeoutRef=useRef(null);// Reset navigation state when URL changes\nuseEffect(()=>{hasNavigatedRef.current=false;if(timeoutRef.current){clearTimeout(timeoutRef.current);timeoutRef.current=null;}},[url]);// Set up scroll listener to detect when bottom of page is reached\nuseEffect(()=>{const handleScroll=()=>{// Don't navigate if we've already navigated\nif(hasNavigatedRef.current)return;// Check if we've reached the bottom of the page\nconst windowHeight=window.innerHeight;const scrollTop=window.scrollY||document.documentElement.scrollTop;const documentHeight=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight);// Check if bottom of body touches bottom of window\nconst isAtBottom=scrollTop+windowHeight>=documentHeight-1;if(isAtBottom&&url){// Clear any existing timeout\nif(timeoutRef.current){clearTimeout(timeoutRef.current);}// Set navigation after delay (convert seconds to milliseconds)\ntimeoutRef.current=setTimeout(()=>{if(hasNavigatedRef.current)return;hasNavigatedRef.current=true;// Open in new tab if specified\nif(newTab){window.open(url,\"_blank\",\"noopener,noreferrer\");}else if(navigate&&routes){// For internal navigation, find the route name from the path\n// Framer's navigate() requires a route name, not a URL path\nconst[path,hash]=url.split(\"#\");const routeEntry=Object.entries(routes).find(([,value])=>value?.path===path);if(routeEntry){// Wrap navigation in startTransition for non-blocking updates\nstartTransition(()=>{// Navigate using route name (routeEntry[0]) and optional hash\nnavigate(routeEntry[0],hash);});}}},delay*1e3);}};window.addEventListener(\"scroll\",handleScroll,{passive:true});// Also check on mount in case page is already at bottom\nhandleScroll();return()=>{window.removeEventListener(\"scroll\",handleScroll);if(timeoutRef.current){clearTimeout(timeoutRef.current);}};},[url,newTab,delay,navigate,routes]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{display:\"none\"}});}BottomPageLink.displayName=\"Bottom Page Link\";addPropertyControls(BottomPageLink,{url:{type:ControlType.Link,title:\"URL\"},newTab:{type:ControlType.Boolean,title:\"New Tab\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},delay:{type:ControlType.Number,title:\"Delay (s)\",defaultValue:1,min:0,max:5,step:.1,unit:\"s\",description:\"More components at [Framer University](https://frameruni.link/cc).\"}});BottomPageLink.displayName=\"Bottom Page Link\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BottomPageLink\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BottomPageLink_prod.map"],"mappings":"8MAKG,SAAwB,EAAe,CAAC,MAAI,SAAO,SAAO,CAC7D,GAAK,CAAC,WAAS,UAAQ,EAAU,GAAG,CAAC,EAAQ,EAAaA,EAAO,IAAI,EAAQ,EAAgBA,EAAO,EAAK,EAAQ,EAAWA,EAAO,IAAI,EAasC,OAZ7K,MAAc,CAAC,EAAgB,QAAQ,GAAM,AAAwD,EAAW,WAA5C,aAAa,EAAW,OAAO,EAAqB,KAAM,EAAE,CAAC,CAAG,CAAC,EACrI,MAAc,CAAC,IAAM,MAAiB,CACtC,GAAG,EAAgB,QAAQ,OAC3B,IAAM,EAAa,EAAO,YAAkB,EAAU,EAAO,SAAS,SAAS,gBAAgB,UAA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