{"version":3,"file":"BlendText.B5vDihA_.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/usKeneJkjhvolZ131Dbn/Y6dQjt1wXSKVKvK8mnfE/BlendText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";/**\n * Blend-mode text.\n *\n * mix-blend-mode only composites against the nearest stacking context, so text\n * nested inside sections with z-index / overflow / filters can never blend with\n * a video sitting behind them. This mirrors the custom cursor: it paints a copy\n * of the text into a body-level fixed layer set to difference, and makes the\n * original transparent so layout, wrapping and accessibility are untouched.\n */export function withBlendText(Component){return props=>{const ref=useRef(null);useEffect(()=>{const root=ref.current;if(!root)return;const src=root.querySelector(\"h1, h2, h3, p\")??root.querySelector(\"a\")??root.firstElementChild;if(!src)return;const layer=document.createElement(\"div\");Object.assign(layer.style,{position:\"fixed\",inset:\"0\",pointerEvents:\"none\",zIndex:\"40\",mixBlendMode:\"difference\"});const ghost=document.createElement(\"div\");Object.assign(ghost.style,{position:\"absolute\",margin:\"0\",whiteSpace:\"pre-wrap\",willChange:\"transform\"});layer.appendChild(ghost);document.body.appendChild(layer);const COPY=[\"fontFamily\",\"fontSize\",\"fontWeight\",\"fontStyle\",\"lineHeight\",\"letterSpacing\",\"textTransform\",\"textAlign\",\"fontVariationSettings\",\"wordSpacing\"];/**\n             * Optical alignment. A box edge is not an ink edge: at 64px Geist's\n             * \"B\" sits ~6px inside its box while the 13px wordmark's \"N\" sits\n             * ~1px inside, so two elements both padded to 40px do not line up.\n             * Canvas text metrics give the real left sidebearing of the first\n             * glyph, which we subtract so ink — not the box — hits the margin.\n             */let inkCache={key:\"\",value:0};const inkOffset=el=>{try{const cs=getComputedStyle(el);const ctx=document.createElement(\"canvas\").getContext(\"2d\");if(!ctx)return 0;ctx.font=`${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;let ch=(el.innerText||\"\").trim().charAt(0);if(!ch)return 0;if(cs.textTransform===\"uppercase\")ch=ch.toUpperCase();// sync() runs every scroll frame; only measure when the font or glyph changes\nconst key=ctx.font+ch;if(key===inkCache.key)return inkCache.value;const m=ctx.measureText(ch);if(typeof m.actualBoundingBoxLeft!==\"number\")return 0;const size=parseFloat(cs.fontSize)||0;// positive = ink starts inside the box; clamp so an odd font can't fling it\ninkCache={key,value:Math.max(0,Math.min(size*.12,-m.actualBoundingBoxLeft))};return inkCache.value;}catch{return 0;}};const sync=()=>{const r=src.getBoundingClientRect();const cs=getComputedStyle(src);for(const p of COPY)ghost.style.setProperty(p.replace(/[A-Z]/g,m=>\"-\"+m.toLowerCase()),cs.getPropertyValue(p.replace(/[A-Z]/g,m=>\"-\"+m.toLowerCase())));ghost.style.color=\"#ffffff\";ghost.style.width=r.width+\"px\";ghost.style.transform=`translate3d(${r.left-inkOffset(src)}px, ${r.top}px, 0)`;if(ghost.textContent!==src.innerText)ghost.textContent=src.innerText;// hide the original without disturbing layout or screen readers.\n// link style presets set colour with higher specificity, so force it\n// on the node and any anchors inside it.\nsrc.style.setProperty(\"color\",\"transparent\",\"important\");src.querySelectorAll(\"a, span\").forEach(el=>el.style.setProperty(\"color\",\"transparent\",\"important\"));};let raf=0,ticking=false;const onScroll=()=>{if(!ticking){ticking=true;raf=requestAnimationFrame(()=>{ticking=false;sync();});}};sync();const ro=new ResizeObserver(onScroll);ro.observe(src);window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);const t=setTimeout(sync,400)// after webfonts settle\n;return()=>{clearTimeout(t);cancelAnimationFrame(raf);ro.disconnect();window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);src.style.removeProperty(\"color\");src.querySelectorAll(\"a, span\").forEach(el=>el.style.removeProperty(\"color\"));layer.remove();};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withBlendText\":{\"type\":\"reactHoc\",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