{"version":3,"file":"SmartSticky.CFQPFvLG.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/4IK698u16poZ91ZbzI0F/sGqEF8ULYwUf2OSRGGZf/SmartSticky.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";/**\n * SmartSticky override\n * Apply to the RightSidebar node on the /tools/:slug page.\n *\n * Behaviour:\n * - Sidebar shorter than viewport → sticks at top (normal sticky)\n * - Sidebar taller than viewport → scrolls down until its bottom hits\n *   the viewport bottom minus BOTTOM_OFFSET, then locks.\n *   Scrolls back up when you reverse.\n */const TOP_OFFSET=100// px from top — match your nav height\n;const BOTTOM_OFFSET=32// px gap from bottom of viewport\n;export function SmartSticky(Component){return function SmartStickyComponent(props){const markerRef=useRef(null);const state=useRef({lastY:window.scrollY,top:TOP_OFFSET});useEffect(()=>{const marker=markerRef.current;if(!marker)return;const el=marker.parentElement;if(!el)return;el.style.position=\"sticky\";el.style.top=`${TOP_OFFSET}px`;el.style.alignSelf=\"flex-start\";el.style.height=\"fit-content\";const update=()=>{const scrollY=window.scrollY;const vh=window.innerHeight;const elHeight=el.offsetHeight;const delta=scrollY-state.current.lastY;if(elHeight+TOP_OFFSET+BOTTOM_OFFSET<=vh){// Fits in viewport — always stick at top offset\nel.style.top=`${TOP_OFFSET}px`;}else{// Taller than viewport — track with bottom gap\nconst minTop=vh-elHeight-BOTTOM_OFFSET;let newTop=state.current.top;if(delta>0){// Scrolling down — shift top up until bottom hits viewport minus gap\nnewTop=Math.max(minTop,newTop-delta);}else{// Scrolling up — shift top down until it hits TOP_OFFSET\nnewTop=Math.min(TOP_OFFSET,newTop-delta);}state.current.top=newTop;el.style.top=`${newTop}px`;}state.current.lastY=scrollY;};window.addEventListener(\"scroll\",update,{passive:true});return()=>window.removeEventListener(\"scroll\",update);},[]);return /*#__PURE__*/_jsxs(Component,{...props,children:[props.children,/*#__PURE__*/_jsx(\"div\",{ref:markerRef,style:{position:\"absolute\",width:0,height:0,pointerEvents:\"none\",visibility:\"hidden\",overflow:\"hidden\"}})]});};}\nexport const __FramerMetadata__ = {\"exports\":{\"SmartSticky\":{\"type\":\"reactHoc\",\"name\":\"SmartSticky\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmartSticky.map"],"mappings":"8IAWC,SAAgB,EAAY,EAAU,CAAC,OAAO,SAA8B,EAAM,CAAC,IAAM,EAAUA,EAAO,KAAK,CAAO,EAAMA,EAAO,CAAC,MAAM,EAAO,QAAQ,IAAI,EAAW,CAAC,CAIuE,OAJtE,MAAc,CAAC,IAAM,EAAO,EAAU,QAAQ,GAAG,CAAC,EAAO,OAAO,IAAM,EAAG,EAAO,cAAc,GAAG,CAAC,EAAG,OAAO,EAAG,MAAM,SAAS,SAAS,EAAG,MAAM,IAAI,GAAG,EAAW,IAAI,EAAG,MAAM,UAAU,aAAa,EAAG,MAAM,OAAO,cAAc,IAAM,MAAW,CAAC,IAAM,EAAQ,EAAO,QAAc,EAAG,EAAO,YAAkB,EAAS,EAAG,aAAmB,EAAM,EAAQ,EAAM,QAAQ,MAAM,GAAG,EAAS,EAAW,GAAe,EACvkB,EAAG,MAAM,IAAI,GAAG,EAAW,QAAS,CACpC,IAAM,EAAO,EAAG,EAAS,EAAkB,EAAO,EAAM,QAAQ,IAAI,AAEpE,EAFuE,EAAM,EACtE,KAAK,IAAI,EAAO,EAAO,EAAM,CAC7B,KAAK,IAAI,EAAW,EAAO,EAAM,CAAE,EAAM,QAAQ,IAAI,EAAO,EAAG,MAAM,IAAI,GAAG,EAAO,IAAK,EAAM,QAAQ,MAAM,GAAkE,OAAxD,EAAO,iBAAiB,SAAS,EAAO,CAAC,QAAQ,GAAK,CAAC,KAAW,EAAO,oBAAoB,SAAS,EAAO,EAAG,EAAE,CAAC,CAAqB,EAAM,EAAU,CAAC,GAAG,EAAM,SAAS,CAAC,EAAM,SAAsB,EAAK,MAAM,CAAC,IAAI,EAAU,MAAM,CAAC,SAAS,WAAW,MAAM,EAAE,OAAO,EAAE,cAAc,OAAO,WAAW,SAAS,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,2BAflZ,IAAoC,CASpF,EAAW,IACb,EAAc"}