{"version":3,"file":"StackDepth.7M5NJSOU.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/dSY4wGfmx0PGzLYYBSRC/OTyNunekOQCTUobNCktx/StackDepth.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";import{useMotionValue,useTransform}from\"framer-motion\";import{RenderTarget}from\"framer\";// Layer names the override looks for: cards named \"Fix Card\" in a \"Fix Cards\" container (case-study fixes)\n// or \"Stack Card\" in a \"Stack Cards\" container (/features app cards).\nconst CARD_SEL='[data-framer-name=\"Fix Card\"], [data-framer-name=\"Stack Card\"]';const LIST_SEL='[data-framer-name=\"Fix Cards\"], [data-framer-name=\"Stack Cards\"]';function isShown(el){return el.getClientRects().length>0;}// The element that actually sticks: the layer itself, or a wrapper Framer put around it.\nfunction stickyBox(el){let node=el;for(let i=0;node&&i<3;i++,node=node.parentElement){if(getComputedStyle(node).position===\"sticky\")return node;}return null;}/**\n * Depth for a stack of sticky cards. As later cards slide over this one, it scales\n * down from its top edge and dims slightly, so the stack reads as layered sheets.\n * Static (no transform) on the canvas, in exports and when the card is not sticky.\n */export function withStackDepth(Component){return /*#__PURE__*/forwardRef(function StackDepth(props,forwarded){const local=useRef(null);const depth=useMotionValue(0);const scale=useTransform(depth,d=>1-Math.min(.12,.045*d));const filter=useTransform(depth,d=>`brightness(${1-Math.min(.16,.06*d)})`);useEffect(()=>{if(RenderTarget.current()!==RenderTarget.preview)return;const el=local.current;if(!el)return;let raf=0;const measure=()=>{raf=0;if(!stickyBox(el)){depth.set(0);return;}const list=el.closest(LIST_SEL)||el.parentElement;if(!list)return;const cards=Array.from(list.querySelectorAll(CARD_SEL)).filter(isShown);const me=cards.indexOf(el);if(me<0){depth.set(0);return;}const vh=window.innerHeight;let d=0;for(const next of cards.slice(me+1)){const box=stickyBox(next)||next;const stick=parseFloat(getComputedStyle(box).top)||0;const top=box.getBoundingClientRect().top;// 0 while the next card is below the fold, 1 once it has reached its sticky spot\nd+=Math.min(1,Math.max(0,(vh-top)/Math.max(1,vh-stick)));}depth.set(d);};const onScroll=()=>{if(!raf)raf=requestAnimationFrame(measure);};measure();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);if(raf)cancelAnimationFrame(raf);};},[]);const setRef=node=>{local.current=node;if(typeof forwarded===\"function\")forwarded(node);else if(forwarded)forwarded.current=node;};return /*#__PURE__*/_jsx(Component,{...props,ref:setRef,style:{...props.style,scale,filter,transformOrigin:\"50% 0%\"}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withStackDepth\":{\"type\":\"reactHoc\",\"name\":\"withStackDepth\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StackDepth.map"],"mappings":"wPAEkK,SAAS,EAAQ,EAAG,CAAC,OAAO,EAAG,eAAe,CAAC,CAAC,OAAO,CAAE,CAC3N,SAAS,EAAU,EAAG,CAAC,IAAI,EAAK,EAAG,IAAI,IAAI,EAAE,EAAE,GAAM,EAAE,EAAE,IAAI,EAAK,EAAK,cAAe,GAAG,iBAAiB,CAAI,CAAC,CAAC,WAAW,SAAS,OAAO,EAAM,OAAO,IAAK,CAI1J,SAAgB,EAAe,EAAU,CAAC,OAAoB,EAAW,SAAoB,EAAM,EAAU,CAAC,IAAM,EAAMA,EAAO,IAAI,EAAQ,EAAM,EAAe,CAAC,EAAQ,EAAM,EAAa,EAAM,GAAG,EAAE,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,EAAQ,EAAO,EAAa,EAAM,GAAG,cAAc,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,EAAE,MAAc,CAAC,GAAG,EAAa,QAAQ,IAAI,EAAa,QAAQ,OAAO,IAAM,EAAG,EAAM,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAI,EAAI,EAAQ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