{"version":3,"file":"ColourLinkOverride.CT2AFXPF.mjs","names":[],"sources":["https:/framerusercontent.com/modules/iGmKEymSJCPPDFOH70IL/61swnMcovhLNhiVU9GLo/ColourLinkOverride.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function withColourClickHandler(Component){return props=>{useEffect(()=>{function handleDocClick(e){const el=e.target;if(!el?.closest)return;const target=el.closest(\"[aria-label]\");if(!target)return;const colour=target.getAttribute(\"aria-label\");if(!colour||![\"black\",\"ivory\",\"green\",\"blue\"].includes(colour))return;const clicked=el.closest(\"a[href]\");const anchor=clicked&&target.contains(clicked)?clicked:target.querySelector(\"a[href]\");if(!anchor)return;const raw=anchor.getAttribute(\"href\");if(!raw)return;e.preventDefault();e.stopPropagation();// 1. Resolve the raw href against a base with any trailing\n//    slash stripped — what the server's 308 would have done.\nconst base=window.location.origin+window.location.pathname.replace(/\\/+$/,\"\");const url=new URL(raw,base);// 2. Collapse any repeated adjacent path segment:\n//    \"/shop/shop/x\" -> \"/shop/x\". Never a valid path, so this\n//    is safe no matter what produced it.\nconst fixed=url.pathname.replace(/\\/([^/]+)\\/\\1(?=\\/|$)/g,\"/$1\");// Diagnostic — only when the URL carries ?debug=1\nif(fixed!==url.pathname&&window.location.search.includes(\"debug\")){window.alert(\"on:    \"+window.location.pathname+\"\\nraw:   \"+raw+\"\\nbad:   \"+url.pathname+\"\\nfixed: \"+fixed);}url.pathname=fixed;url.searchParams.set(\"colour\",colour);window.location.href=url.toString();}document.addEventListener(\"click\",handleDocClick,true);return()=>document.removeEventListener(\"click\",handleDocClick,true);},[]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withColourClickHandler\":{\"type\":\"reactHoc\",\"name\":\"withColourClickHandler\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ColourLinkOverride.map"],"mappings":"gIAAwE,SAAg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