{"version":3,"file":"TableOfContents.Czw0PgYu.mjs","names":["useRef","useState","useCallback","useMemo","startTransition"],"sources":["https:/framerusercontent.com/modules/Ozim3xnRhmcRAFGIqQDP/hWCQFiO7xK2rh2kHYFTA/TableOfContents.js"],"sourcesContent":["// User request: Update TableOfContents so it lists only H2 headings in a flat list while keeping title/background controls, smooth-scroll behavior, anchor id generation, styling, and static-render safety unchanged.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";function slugify(value){return value.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/-+/g,\"-\").replace(/^-|-$/g,\"\");}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TableOfContents(props){const{title=\"Content of the article\",backgroundColor=\"rgba(255, 145, 0, 0.08)\",style}=props;const containerRef=useRef(null);const[tocItems,setTocItems]=useState([]);const[hoveredId,setHoveredId]=useState(null);const scanHeadings=useCallback(()=>{if(typeof document===\"undefined\")return;const root=document.querySelector(\"main\")??document;const headingElements=Array.from(root.querySelectorAll(\"h2\"));const container=containerRef.current;const filteredHeadings=headingElements.filter(el=>{if(!container)return true;return!container.contains(el);});const usedIds=new Set;filteredHeadings.forEach(heading=>{if(heading.id)usedIds.add(heading.id);});const ensureUniqueId=baseId=>{const normalizedBase=baseId||\"section\";if(!usedIds.has(normalizedBase)){usedIds.add(normalizedBase);return normalizedBase;}let index=2;let candidate=`${normalizedBase}-${index}`;while(usedIds.has(candidate)){index+=1;candidate=`${normalizedBase}-${index}`;}usedIds.add(candidate);return candidate;};const nextItems=[];filteredHeadings.forEach(heading=>{const text=heading.textContent?.trim()??\"\";if(!text)return;let id=heading.id?.trim()??\"\";if(!id){id=ensureUniqueId(slugify(text));heading.id=id;}else{id=ensureUniqueId(id);heading.id=id;}nextItems.push({id,text});});startTransition(()=>setTocItems(nextItems));},[]);useEffect(()=>{scanHeadings();let timeoutId=0;if(typeof window!==\"undefined\"){timeoutId=window.setTimeout(()=>{scanHeadings();},350);}return()=>{if(typeof window!==\"undefined\"&&timeoutId){window.clearTimeout(timeoutId);}};},[scanHeadings]);const onItemClick=useCallback((event,id)=>{event.preventDefault();if(typeof document===\"undefined\"||typeof window===\"undefined\")return;const target=document.getElementById(id);if(!target)return;const targetTop=target.getBoundingClientRect().top+window.scrollY-90;window.scrollTo({top:Math.max(0,targetTop),behavior:\"smooth\"});window.history.replaceState(null,\"\",`#${id}`);},[]);const hasItems=useMemo(()=>tocItems.length>0,[tocItems]);if(!hasItems)return null;return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"auto\",boxSizing:\"border-box\",backgroundColor,borderRadius:16,padding:24,color:\"#1A1A1A\",...style},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:18,fontWeight:700,lineHeight:1.2,marginBottom:14,letterSpacing:\"-0.01em\"},children:title}),/*#__PURE__*/_jsx(\"nav\",{\"aria-label\":\"Table of contents\",children:/*#__PURE__*/_jsx(\"ul\",{style:{display:\"flex\",flexDirection:\"column\",gap:8,listStyle:\"none\",padding:0,margin:0},children:tocItems.map(item=>{const isParentHovered=hoveredId===item.id;return /*#__PURE__*/_jsx(\"li\",{style:{display:\"flex\",flexDirection:\"column\",gap:6},children:/*#__PURE__*/_jsx(\"a\",{href:`#${item.id}`,onClick:event=>onItemClick(event,item.id),onMouseEnter:()=>startTransition(()=>setHoveredId(item.id)),onMouseLeave:()=>startTransition(()=>setHoveredId(null)),style:{color:isParentHovered?\"#FF7A00\":\"#2A2A2A\",textDecoration:\"none\",fontSize:15,fontWeight:500,lineHeight:1.45,cursor:\"pointer\",transition:\"color 0.2s ease\",width:\"max-content\",maxWidth:\"100%\"},children:item.text})},item.id);})})})]});}addPropertyControls(TableOfContents,{title:{type:ControlType.String,defaultValue:\"Content of the article\"},backgroundColor:{type:ControlType.Color,defaultValue:\"rgba(255, 145, 0, 0.08)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContents.map"],"mappings":"wNAC8L,SAAS,EAAQ,EAAM,CAAC,OAAO,EAAM,YAAY,CAAC,CAAC,QAAQ,cAAc,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC,QAAQ,SAAS,EAAE,CAAE,CAGjT,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,yBAAyB,kBAAgB,0BAA0B,SAAO,EAAY,EAAaA,EAAO,IAAI,EAAO,CAAC,EAAS,GAAaC,EAAS,CAAC,CAAC,EAAO,CAAC,EAAU,GAAcA,EAAS,IAAI,EAAQ,EAAaC,MAAgB,CAAC,GAAG,OAAO,SAAW,IAAY,OAAO,IAAM,EAAK,SAAS,cAAc,MAAM,GAAG,SAAe,EAAgB,MAAM,KAAK,EAAK,iBAAiB,IAAI,CAAC,EAAQ,EAAU,EAAa,QAAc,EAAiB,EAAgB,OAAO,GAAK,CAAI,GAA4B,CAAC,EAAU,SAAS,CAAE,CAAG,EAAQ,EAAQ,IAAI,IAAI,EAAiB,QAAQ,GAAS,CAAI,EAAQ,IAAG,EAAQ,IAAI,EAAQ,EAAE,CAAE,CAAC,EAAE,IAAM,EAAe,GAAQ,CAAC,IAAM,EAAe,GAAQ,UAAU,GAAG,CAAC,EAAQ,IAAI,CAAc,EAA+B,OAA5B,EAAQ,IAAI,CAAc,EAAS,EAAgB,IAAI,EAAM,EAAM,EAAU,GAAG,EAAe,GAAG,IAAQ,KAAM,EAAQ,IAAI,CAAS,GAAG,GAAO,EAAE,EAAU,GAAG,EAAe,GAAG,IAAgC,OAAvB,EAAQ,IAAI,CAAS,EAAS,CAAU,EA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