{"version":3,"file":"TableOfContents.BvmHLS7M.mjs","names":["useState","useMemo","startTransition"],"sources":["https:/framerusercontent.com/modules/5D3Lb6gJRQXH77FemNOV/8fiCdDHdcjtzvLvN6Zcp/TableOfContents.js"],"sourcesContent":["// Table of Contents component that finds headers in a section and displays them with configurable states\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TableOfContents(props){const{sectionId=\"\",inactiveColor=\"#CCCCCC\",hoverColor=\"#000000\",activeColor=\"#0099FF\",font,spacing=12,h2Padding=16,h3Padding=32,h4Padding=48,h5Padding=64,h6Padding=80}=props;const[headers,setHeaders]=useState([]);const[activeId,setActiveId]=useState(\"\");const[hoveredId,setHoveredId]=useState(\"\");const paddingMap=useMemo(()=>({1:0,2:h2Padding,3:h3Padding,4:h4Padding,5:h5Padding,6:h6Padding}),[h2Padding,h3Padding,h4Padding,h5Padding,h6Padding]);useEffect(()=>{if(typeof window===\"undefined\"||!sectionId)return;const findHeaders=()=>{let section=document.getElementById(sectionId);let searchRoot=section||document;// If section not found, search entire document\nconst headerElements=searchRoot.querySelectorAll(\"h1, h2, h3, h4, h5, h6\");const headerItems=[];headerElements.forEach((header,index)=>{const level=parseInt(header.tagName.substring(1));let id=header.id;if(!id){id=`toc-header-${index}`;header.id=id;}headerItems.push({id,text:header.textContent||\"\",level});});return headerItems;};const updateHeaders=()=>{const foundHeaders=findHeaders();startTransition(()=>setHeaders(foundHeaders));};// Initial delay to allow page to render\nconst initialTimeout=setTimeout(updateHeaders,100);// Set up observer\nconst observer=new MutationObserver(()=>{// Debounce updates\nclearTimeout(initialTimeout);setTimeout(updateHeaders,50);});// Observe the entire document body for changes\nobserver.observe(document.body,{childList:true,subtree:true,characterData:true});return()=>{clearTimeout(initialTimeout);observer.disconnect();};},[sectionId]);useEffect(()=>{if(typeof window===\"undefined\"||headers.length===0)return;// The offset from top where we consider a header to be \"active\"\nconst SCROLL_OFFSET=220;// Function to determine active header based on scroll position\nconst updateActiveHeader=()=>{let currentActiveId=\"\";// Get all header positions\nconst headerPositions=headers.map(header=>{const element=document.getElementById(header.id);if(!element)return{id:header.id,top:Infinity};const rect=element.getBoundingClientRect();const absoluteTop=rect.top+window.scrollY;return{id:header.id,top:absoluteTop};});const scrollTop=window.scrollY+SCROLL_OFFSET;// Find the header that is closest to (but above or at) the current scroll position\nfor(let i=headerPositions.length-1;i>=0;i--){const headerPos=headerPositions[i];if(headerPos.top<=scrollTop){currentActiveId=headerPos.id;break;}}// If no header is above scroll position, use the first one if we're near the top\nif(!currentActiveId&&headerPositions.length>0){const firstHeader=headerPositions[0];if(firstHeader.top!==Infinity){// If we're close to the first header, make it active\nconst distanceToFirst=firstHeader.top-scrollTop;if(distanceToFirst<100){currentActiveId=firstHeader.id;}}}// Fallback: if still no active header and we have headers, use the first one\nif(!currentActiveId&&headers.length>0){currentActiveId=headers[0].id;}startTransition(()=>setActiveId(currentActiveId));};// Throttle scroll handler for performance\nlet ticking=false;const handleScroll=()=>{if(!ticking){window.requestAnimationFrame(()=>{updateActiveHeader();ticking=false;});ticking=true;}};// Initial update\nupdateActiveHeader();// Listen to scroll events\nwindow.addEventListener(\"scroll\",handleScroll,{passive:true});// Also use IntersectionObserver as a backup for edge cases\nconst observerOptions={rootMargin:\"-100px 0px -70% 0px\",threshold:[0,1]};const observer=new IntersectionObserver(entries=>{// Trigger scroll handler on intersection changes\nhandleScroll();},observerOptions);// Observe all header elements\nheaders.forEach(header=>{const element=document.getElementById(header.id);if(element){observer.observe(element);}});return()=>{window.removeEventListener(\"scroll\",handleScroll);observer.disconnect();};},[headers]);const handleClick=id=>{if(typeof window===\"undefined\")return;const element=document.getElementById(id);if(element){const yOffset=-220// Position header 220px from top (matches SCROLL_OFFSET)\n;const y=element.getBoundingClientRect().top+window.pageYOffset+yOffset;window.scrollTo({top:y,behavior:\"smooth\"});}};if(headers.length===0){return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,padding:16,color:inactiveColor,...font},children:sectionId?`No headers found in section \"${sectionId}\"`:\"Please enter a Section ID\"});}return /*#__PURE__*/_jsx(\"nav\",{style:{...props.style,display:\"flex\",flexDirection:\"column\",gap:spacing},\"aria-label\":\"Table of Contents\",children:headers.map(header=>{const isActive=activeId===header.id;const isHovered=hoveredId===header.id;const color=isActive?activeColor:isHovered?hoverColor:inactiveColor;return /*#__PURE__*/_jsx(\"a\",{href:`#${header.id}`,onClick:e=>{e.preventDefault();handleClick(header.id);},onMouseEnter:()=>startTransition(()=>setHoveredId(header.id)),onMouseLeave:()=>startTransition(()=>setHoveredId(\"\")),style:{paddingLeft:paddingMap[header.level],color,textDecoration:\"none\",cursor:\"pointer\",transition:\"color 0.2s ease\",wordWrap:\"break-word\",...font},children:header.text},header.id);})});}addPropertyControls(TableOfContents,{sectionId:{type:ControlType.String,title:\"Section ID\",defaultValue:\"content\",placeholder:\"Enter section ID...\"},inactiveColor:{type:ControlType.Color,title:\"Inactive Color\",defaultValue:\"#CCCCCC\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#000000\"},activeColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#0099FF\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},spacing:{type:ControlType.Number,title:\"Spacing\",defaultValue:12,min:0,max:48,step:1,unit:\"px\"},h2Padding:{type:ControlType.Number,title:\"H2 Padding\",defaultValue:16,min:0,max:100,step:1,unit:\"px\"},h3Padding:{type:ControlType.Number,title:\"H3 Padding\",defaultValue:32,min:0,max:100,step:1,unit:\"px\"},h4Padding:{type:ControlType.Number,title:\"H4 Padding\",defaultValue:48,min:0,max:100,step:1,unit:\"px\"},h5Padding:{type:ControlType.Number,title:\"H5 Padding\",defaultValue:64,min:0,max:100,step:1,unit:\"px\"},h6Padding:{type:ControlType.Number,title:\"H6 Padding\",defaultValue:80,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContents.map"],"mappings":"8MAIG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,YAAU,GAAG,gBAAc,UAAU,aAAW,UAAU,cAAY,UAAU,OAAK,UAAQ,GAAG,YAAU,GAAG,YAAU,GAAG,YAAU,GAAG,YAAU,GAAG,YAAU,IAAI,EAAW,CAAC,EAAQ,GAAYA,EAAS,EAAE,CAAC,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAG,CAAO,EAAWC,OAAa,CAAC,EAAE,EAAE,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,CAAC,EAAU,EAAU,EAAU,EAAU,EAAU,CAAC,CAAC,MAAc,CAAC,GAAU,IAAS,QAAa,CAAC,EAAU,OAAO,IAAM,MAAgB,CACxkB,IAAM,GAD+kB,SAAS,eAAe,EAAU,EAAyB,UAChnB,iBAAiB,yBAAyB,CAAO,EAAY,EAAE,CAAuN,OAAtN,EAAe,SAAS,EAAO,IAAQ,CAAC,IAAM,EAAM,SAAS,EAAO,QAAQ,UAAU,EAAE,CAAC,CAAK,EAAG,EAAO,GAAO,IAAI,EAAG,cAAc,IAAQ,EAAO,GAAG,GAAI,EAAY,KAAK,CAAC,KAAG,KAAK,EAAO,aAAa,GAAG,QAAM,CAAC,EAAG,CAAQ,GAAoB,MAAkB,CAAC,IAAM,EAAa,GAAa,CAAC,MAAoB,EAAW,EAAa,CAA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