{"version":3,"file":"Relative_path.BewiG5mA.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/0FXgiipSDisSoYxBAP40/4hnur1UsaljOjTQw94Bt/Relative_path.js"],"sourcesContent":["// Relative_path.tsx\n// ---------------------------------------------------------------------------\n// GoToLinkPath — make a Framer INLINE text link navigate to its real\n// destination, on a hybrid Framer + separate-React-app + Gatsby site.\n//\n// WHAT WE FOUND ON THE LIVE SITE (verified in the DOM + React fiber)\n//   The \"Browse All Games\" / \"Learn How to Use Factile…\" links are inline\n//   rich-text links: <a class=\"framer-text\" href=\"./\">. Framer does NOT put\n//   the real destination in the href — the href stays \"./\", which resolves to\n//   the HOMEPAGE, and Framer even marks it data-framer-page-link-current=\"true\".\n//   The real path (\"/search\", \"/blog/why-play-…\") lives only in a PARENT React\n//   fiber's props (props.href), because those targets aren't Framer pages so\n//   Framer can't bake them into a normal href.  THAT \"./\" href is the whole\n//   bug: every click just follows \"./\" to the homepage.\n//\n//   Also verified: an anchor-level click listener does NOT reliably win against\n//   Framer/React here, but a DOCUMENT-level capture listener fires first (before\n//   React's root delegation) and controls the navigation. So we intercept there.\n//\n// WHAT THIS DOES\n//   Per text layer it's applied to, it:\n//     1. Walks the React fiber up from each inline <a> to recover the REAL path\n//        Framer stored (props.href, ignoring the \"./\" placeholder). Nothing is\n//        hardcoded — each link resolves its own \"Link To\" value.\n//     2. Writes that path into the DOM href (so hover/copy-link/middle-click and\n//        crawlers see the right target) and tags the anchor as \"managed\".\n//   A single document-level capture click listener (installed once) then does a\n//   real full navigation for managed same-origin links — window.location.assign\n//   (or a new tab if the link's \"New Tab\" is on) — so the separate React app\n//   (/search, /signin) and Gatsby (/blog) pages load correctly instead of\n//   Framer trying to SPA-route them.  Modifier/middle clicks are left to the\n//   browser (correct href now), and genuinely external links are untouched.\n//\n// USE\n//   Apply to each inline text link's Text layer.\n//   File: Relative_path   Override: GoToLinkPath\n// ---------------------------------------------------------------------------\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";export function GoToLinkPath(Component){return /*#__PURE__*/forwardRef((props,forwardedRef)=>{const innerRef=useRef(null);const setRef=node=>{innerRef.current=node;if(typeof forwardedRef===\"function\")forwardedRef(node);else if(forwardedRef)forwardedRef.current=node;};useEffect(()=>{installGlobalHandler();const node=innerRef.current;if(!node)return;apply(node);const obs=new MutationObserver(()=>apply(node));obs.observe(node,{childList:true,subtree:true});const timers=[150,400,900].map(ms=>window.setTimeout(()=>apply(node),ms));return()=>{obs.disconnect();timers.forEach(t=>window.clearTimeout(t));};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRef});});}// --- fiber helpers ---------------------------------------------------------\nfunction fiberOf(el){const key=Object.keys(el).find(k=>k.indexOf(\"__reactFiber$\")===0||k.indexOf(\"__reactInternalInstance$\")===0);return key?el[key]:null;}// Recover the destination Framer stored for this anchor by walking the fiber\n// tree upward. Returns { href, newTab } or null if nothing real was found.\nfunction resolveLink(a){let f=fiberOf(a);let href=null;let newTab=null;let depth=0;while(f&&depth<30){const p=f.memoizedProps;if(p){if(href==null&&typeof p.href===\"string\"){const h=p.href.trim();if(h&&h!==\"./\"&&h!==\".\"&&h!==\"#\")href=h;}if(newTab==null){if(typeof p.openInNewTab===\"boolean\")newTab=p.openInNewTab;else if(p.target===\"_blank\")newTab=true;}}f=f.return;depth++;}if(!href)return null;return{href,newTab:newTab===true};}// --- per-layer: fix hrefs + tag managed links ------------------------------\nfunction apply(root){const anchors=[];if(root.tagName===\"A\")anchors.push(root);root.querySelectorAll(\"a\").forEach(a=>anchors.push(a));anchors.forEach(a=>{if(a.dataset.goLinkBound===\"1\")return;const resolved=resolveLink(a);if(!resolved)return;// couldn't recover a real path — leave it alone\nlet url;try{url=new URL(resolved.href,window.location.href);}catch{return;}a.dataset.goLinkBound=\"1\";if(url.origin!==window.location.origin){// External: just make the href correct; don't intercept.\na.setAttribute(\"href\",resolved.href);return;}// Same-origin: correct the href AND mark it for the global handler.\nconst dest=url.pathname+url.search+url.hash;a.setAttribute(\"href\",dest);a.dataset.goLinkTo=dest;if(resolved.newTab)a.dataset.goLinkNewtab=\"1\";});}// --- global, document-level capture click handler (installed once) ---------\nfunction installGlobalHandler(){if(window.__goLinkHandler)return;window.__goLinkHandler=true;document.addEventListener(\"click\",e=>{// Let the browser handle modifier / middle / right clicks normally\n// (the href is already correct, so new-tab/copy behave right).\nif(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const t=e.target;const a=t&&t.closest?t.closest(\"a\"):null;if(!a)return;const dest=a.dataset?a.dataset.goLinkTo:null;if(!dest)return;// not a link we manage\n// Document-capture fires before Framer's router; take over cleanly.\ne.preventDefault();e.stopImmediatePropagation();if(a.dataset.goLinkNewtab===\"1\")window.open(dest,\"_blank\",\"noopener\");else window.location.assign(dest);},true// capture\n);}\nexport const __FramerMetadata__ = {\"exports\":{\"GoToLinkPath\":{\"type\":\"reactHoc\",\"name\":\"GoToLinkPath\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Relative_path.map"],"mappings":"8IAqC0F,SAAgB,EAAa,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAe,CAAC,IAAM,EAASA,EAAO,IAAI,EAAQ,EAAO,GAAM,CAAC,EAAS,QAAQ,EAAQ,OAAO,GAAe,WAAW,EAAa,CAAI,EAAU,IAAa,EAAa,QAAQ,EAAK,EAAwV,OAAtV,MAAc,CAAC,EAAqB,EAAE,IAAM,EAAK,EAAS,QAAQ,GAAG,CAAC,EAAK,OAAO,EAAM,CAAI,EAAE,IAAM,EAAI,IAAI,qBAAqB,EAAM,CAAI,CAAC,EAAE,EAAI,QAAQ,EAAK,CAAC,UAAU,GAAK,QAAQ,EAAI,CAAC,EAAE,IAAM,EAAO,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,GAAI,EAAO,eAAe,EAAM,CAAI,EAAE,CAAE,CAAC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