{"version":3,"file":"SmartSticky.DksTHHOz.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/4IK698u16poZ91ZbzI0F/byAOzitkpuhC7vmqbnxb/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:0,top:TOP_OFFSET});useEffect(()=>{state.current.lastY=window.scrollY;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,IAAI,EAAQ,EAAMA,EAAO,CAAC,MAAM,EAAE,IAAI,CAAU,CAAC,EAIqF,OAJnF,MAAc,CAAC,EAAM,QAAQ,MAAM,EAAO,QAAQ,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,EAC7lB,EAAG,MAAM,IAAI,GAAG,EAAW,QAAS,CACpC,IAAM,EAAO,EAAG,EAAS,EAAkB,EAAO,EAAM,QAAQ,IAAI,AAEpE,EAFuE,EAAM,EACtE,KAAK,IAAI,EAAO,EAAO,CAAK,EAC5B,KAAK,IAAI,EAAW,EAAO,CAAK,EAAG,EAAM,QAAQ,IAAI,EAAO,EAAG,MAAM,IAAI,GAAG,EAAO,GAAI,CAAC,EAAM,QAAQ,MAAM,CAAQ,EAA0D,OAAxD,EAAO,iBAAiB,SAAS,EAAO,CAAC,QAAQ,EAAI,CAAC,MAAY,EAAO,oBAAoB,SAAS,CAAM,CAAE,EAAE,CAAC,CAAC,EAAsB,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,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAE,yBAftZ,IAAoC,EASnF,EAAW,IACb,EAAc"}