{"version":3,"file":"SectionNav.BdHCeKQo.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/trEIgmQheUavnjsMnYbS/YZksgCnBRlarBs9MtSmP/SectionNav.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef,useState}from\"react\";/**\n * Builds a contents rail from the headings already rendered on the page, so it\n * works with CMS rich text where the headings aren't known at build time.\n * Highlights the section currently in view and smooth-scrolls on click.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function SectionNav(props){const{label,headingSelector,offset,font,fontSize,lineHeight,color,activeColor,labelColor,gap,style}=props;const ref=useRef(null);const[items,setItems]=useState([]);const[active,setActive]=useState(0);const onCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{if(onCanvas)return;const root=ref.current;if(!root)return;const collect=()=>{const found=Array.from(document.querySelectorAll(headingSelector)).filter(h=>{if(root.contains(h))return false// never index ourselves\n;if(h.closest(\"nav, footer, header\"))return false;return(h.textContent||\"\").trim().length>0;});found.forEach((h,i)=>{if(!h.id)h.id=`section-${i}-${(h.textContent||\"\").trim().toLowerCase().replace(/[^a-z0-9]+/g,\"-\").slice(0,40)}`;});setItems(found.map(h=>({id:h.id,text:(h.textContent||\"\").trim(),el:h})));};collect();// CMS rich text can hydrate after first paint\nconst mo=new MutationObserver(collect);mo.observe(document.body,{childList:true,subtree:true});const t=setTimeout(collect,600);return()=>{mo.disconnect();clearTimeout(t);};},[headingSelector,onCanvas]);useEffect(()=>{if(onCanvas||items.length===0)return;const onScroll=()=>{let idx=0;items.forEach((it,i)=>{const top=it.el.getBoundingClientRect().top;if(top<=offset+4)idx=i;});setActive(idx);};onScroll();window.addEventListener(\"scroll\",onScroll,{passive:true});return()=>window.removeEventListener(\"scroll\",onScroll);},[items,offset,onCanvas]);const go=(e,it)=>{e.preventDefault();const y=it.el.getBoundingClientRect().top+window.scrollY-offset;window.scrollTo({top:y,behavior:\"smooth\"});};const preview=onCanvas?[{id:\"a\",text:\"Section one\"},{id:\"b\",text:\"Section two\"},{id:\"c\",text:\"Section three\"}]:items;// a one-item contents list is noise, so stay out of the way\nif(!onCanvas&&preview.length<2)return /*#__PURE__*/_jsx(\"div\",{ref:ref});return /*#__PURE__*/_jsxs(\"nav\",{ref:ref,\"aria-label\":label||\"Contents\",style:{display:\"flex\",flexDirection:\"column\",gap,...style},children:[label?/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:font,fontSize:11,letterSpacing:\"1.54px\",textTransform:\"uppercase\",color:labelColor,lineHeight:\"1.2em\"},children:label}):null,preview.map((it,i)=>/*#__PURE__*/_jsx(\"a\",{href:`#${it.id}`,onClick:onCanvas?undefined:e=>go(e,it),\"aria-current\":i===active?\"true\":undefined,style:{fontFamily:font,fontSize,lineHeight,textDecoration:\"none\",color:i===active?activeColor:color,transition:\"color 240ms cubic-bezier(0.44,0,0.56,1)\"},children:it.text},it.id))]});}SectionNav.defaultProps={label:\"Contents\",headingSelector:\"h2\",offset:140,font:\"Inter, sans-serif\",fontSize:14,lineHeight:\"1.5em\",color:\"#9B968C\",activeColor:\"#14161A\",labelColor:\"#8A6A3B\",gap:14};addPropertyControls(SectionNav,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Contents\"},headingSelector:{type:ControlType.String,title:\"Headings\",defaultValue:\"h2\"},offset:{type:ControlType.Number,title:\"Offset\",defaultValue:140,min:0,max:400},font:{type:ControlType.String,title:\"Font\",defaultValue:\"Inter, sans-serif\"},fontSize:{type:ControlType.Number,title:\"Size\",defaultValue:14,min:9,max:32},lineHeight:{type:ControlType.String,title:\"Leading\",defaultValue:\"1.5em\"},color:{type:ControlType.Color,title:\"Idle\",defaultValue:\"#9B968C\"},activeColor:{type:ControlType.Color,title:\"Active\",defaultValue:\"#14161A\"},labelColor:{type:ControlType.Color,title:\"Label Colour\",defaultValue:\"#8A6A3B\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:14,min:0,max:48}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SectionNav\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SectionNav.map"],"mappings":"oNAOG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,QAAM,kBAAgB,SAAO,OAAK,WAAS,aAAW,QAAM,cAAY,aAAW,MAAI,SAAO,EAAY,EAAIA,EAAO,IAAI,EAAO,CAAC,EAAM,GAAUC,EAAS,CAAC,CAAC,EAAO,CAAC,EAAO,GAAWA,EAAS,CAAC,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAO,MAAc,CAAC,GAAG,EAAS,OAAO,IAAM,EAAK,EAAI,QAAQ,GAAG,CAAC,EAAK,OAAO,IAAM,MAAY,CAAC,IAAM,EAAM,MAAM,KAAK,SAAS,iBAAiB,CAAe,CAAC,CAAC,CAAC,OAAO,GAAO,EAAK,SAAS,CAAC,GACze,EAAE,QAAQ,qBAAqB,EAAS,IAAa,EAAE,aAAa,GAAA,CAAI,KAAK,CAAC,CAAC,OAAO,CAAG,EAAE,EAAM,SAAS,EAAE,IAAI,CAAC,AAAS,EAAE,KAAG,WAAW,EAAE,IAAI,EAAE,aAAa,GAAA,CAAI,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,GAAI,CAAC,EAAE,EAAS,EAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,EAAE,aAAa,GAAA,CAAI,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAE,EAAE,EAAQ,EAC3T,IAAM,EAAG,IAAI,iBAAiB,CAAO,EAAE,EAAG,QAAQ,SAAS,KAAK,CAAC,UAAU,GAAK,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