{"version":3,"file":"TableOfContents.DoMF2PC5.mjs","names":["useState","useCallback","startTransition"],"sources":["https:/framerusercontent.com/modules/2ZFjdoZDKaNnLWihLxtZ/qRWa8pvbbpNPXdASDfoH/TableOfContents.js"],"sourcesContent":["// Table of Contents component that sits next to blog/help articles for easy page navigation\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Table of Contents\n *\n * @framerIntrinsicWidth 280\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TableOfContents(props){const{title,headingLevels,contentSelector,backgroundColor,textColor,activeColor,hoverColor,borderColor,titleFont,itemFont,showBorder,stickyPosition,topOffset,indentSize}=props;const[items,setItems]=useState([]);const[activeId,setActiveId]=useState(\"\");const[hoverId,setHoverId]=useState(\"\");// Parse heading levels (e.g., \"h2,h3\" or \"2,3\")\nconst getHeadingSelector=useCallback(()=>{const levels=headingLevels.split(\",\").map(l=>l.trim().toLowerCase()).map(l=>l.startsWith(\"h\")?l:`h${l}`).join(\",\");return levels||\"h2,h3\";},[headingLevels]);// Extract headings from the page\nuseEffect(()=>{if(typeof document===\"undefined\")return;const selector=getHeadingSelector();const container=contentSelector?document.querySelector(contentSelector):document;if(!container){console.warn(`Container not found: ${contentSelector}`);return;}// First, get H1 from the container if it exists\nconst h1=container.querySelector(\"h1\");const tocItems=[];if(h1){if(!h1.id){h1.id=h1.textContent?.toLowerCase().replace(/\\s+/g,\"-\")||\"\";}tocItems.push({id:h1.id,text:h1.textContent||\"\",level:1});}// Then get the other headings based on selector\nconst headings=container.querySelectorAll(selector);headings.forEach(heading=>{if(!heading.id){heading.id=heading.textContent?.toLowerCase().replace(/\\s+/g,\"-\")||\"\";}const level=parseInt(heading.tagName.substring(1));tocItems.push({id:heading.id,text:heading.textContent||\"\",level:level});});startTransition(()=>setItems(tocItems));},[getHeadingSelector,contentSelector]);// Track active section on scroll\nuseEffect(()=>{if(typeof window===\"undefined\"||items.length===0)return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){startTransition(()=>setActiveId(entry.target.id));}});},{rootMargin:\"-20% 0px -35% 0px\"});items.forEach(item=>{const element=document.getElementById(item.id);if(element)observer.observe(element);});return()=>observer.disconnect();},[items]);const handleClick=id=>{const element=document.getElementById(id);if(element){const elementPosition=element.getBoundingClientRect().top;const offsetPosition=elementPosition+window.pageYOffset-100;window.scrollTo({top:offsetPosition,behavior:\"smooth\"});}};const minLevel=items.length>0?Math.min(...items.map(item=>item.level)):2;const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";return /*#__PURE__*/_jsxs(\"nav\",{style:{...props.style,position:stickyPosition?\"sticky\":\"relative\",top:stickyPosition?`${topOffset}px`:undefined,backgroundColor,borderRadius:8,padding:20,border:showBorder?`1px solid ${borderColor}`:\"none\",overflow:\"auto\",...isFixedWidth?{}:{minWidth:\"max-content\"},...isFixedHeight?{}:{height:\"fit-content\"}},\"aria-label\":\"Table of contents\",children:[/*#__PURE__*/_jsx(\"h2\",{style:{margin:0,marginBottom:16,color:textColor,...titleFont},children:title}),/*#__PURE__*/_jsx(\"ul\",{style:{listStyle:\"none\",margin:0,padding:0},children:items.map(item=>{const isActive=activeId===item.id;const isHovered=hoverId===item.id;const indent=(item.level-minLevel)*indentSize;return /*#__PURE__*/_jsx(\"li\",{style:{marginBottom:8},children:/*#__PURE__*/_jsx(\"a\",{href:`#${item.id}`,onClick:e=>{e.preventDefault();handleClick(item.id);},onMouseEnter:()=>startTransition(()=>setHoverId(item.id)),onMouseLeave:()=>startTransition(()=>setHoverId(\"\")),style:{display:\"block\",paddingLeft:isHovered?indent+8:indent,paddingTop:6,paddingBottom:6,paddingRight:isHovered?8:0,color:isActive?activeColor:textColor,textDecoration:\"none\",borderRadius:4,backgroundColor:isHovered?hoverColor:\"transparent\",transition:\"all 0.2s ease\",cursor:\"pointer\",...itemFont},children:item.text})},item.id);})}),items.length===0&&/*#__PURE__*/_jsx(\"p\",{style:{color:textColor,opacity:.5,margin:0,...itemFont},children:\"No headings found on page\"})]});}addPropertyControls(TableOfContents,{title:{type:ControlType.String,title:\"Title\",defaultValue:\"On this page\"},headingLevels:{type:ControlType.String,title:\"Heading Levels\",defaultValue:\"h2,h3\",placeholder:\"h2,h3 or 2,3\"},contentSelector:{type:ControlType.String,title:\"Content Selector\",defaultValue:\"\",placeholder:\".cms-content or #article\",description:\"CSS selector for article container\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F5F5F5\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},activeColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#0099FF\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#EEEEEE\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#CCCCCC\"},showBorder:{type:ControlType.Boolean,title:\"Show Border\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},stickyPosition:{type:ControlType.Boolean,title:\"Sticky\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},topOffset:{type:ControlType.Number,title:\"Top Offset\",defaultValue:20,min:0,max:200,step:10,unit:\"px\",hidden:({stickyPosition})=>!stickyPosition},indentSize:{type:ControlType.Number,title:\"Indent Size\",defaultValue:16,min:0,max:40,step:4,unit:\"px\"},titleFont:{type:ControlType.Font,title:\"Title Font\",defaultValue:{fontSize:\"15px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},itemFont:{type:ControlType.Font,title:\"Item Font\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"280\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContents.map"],"mappings":"qNASG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,gBAAc,kBAAgB,kBAAgB,YAAU,cAAY,aAAW,cAAY,YAAU,WAAS,aAAW,iBAAe,YAAU,cAAY,EAAW,CAAC,EAAM,GAAUA,EAAS,CAAC,CAAC,EAAO,CAAC,EAAS,GAAaA,EAAS,EAAE,EAAO,CAAC,EAAQ,GAAYA,EAAS,EAAE,EAC7U,EAAmBC,MAA8B,EAAc,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,WAAW,GAAG,EAAE,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,GAAiB,GAAG,QAAU,CAAC,CAAa,CAAC,EACrM,MAAc,CAAC,GAAG,OAAO,SAAW,IAAY,OAAO,IAAM,EAAS,EAAmB,EAAQ,EAAU,EAAgB,SAAS,cAAc,CAAe,EAAE,SAAS,GAAG,CAAC,EAAU,CAAC,QAAQ,KAAK,wBAAwB,GAAiB,EAAE,MAAO,CAC1P,IAAM,EAAG,EAAU,cAAc,IAAI,EAAQ,EAAS,CAAC,EAAK,IAAI,AAAW,EAAG,KAAG,EAAG,aAAa,YAAY,CAAC,CAAC,QAAQ,OAAO,GAAG,GAAG,GAAI,EAAS,KAAK,CAAC,GAAG,EAAG,GAAG,KAAK,EAAG,aAAa,GAAG,MAAM,CAAC,CAAC,GAC5I,EAA3B,iBAAiB,CAAiB,CAAC,CAAC,QAAQ,GAAS,CAAC,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