{"version":3,"file":"TableOfContent.Cb7B5eNe.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/q6TPcm1rVRPb4ymPsf0M/tT5y56245iRxWudZC25A/TableOfContent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 400\n */export default function Table_of_Content(props){const[headers,setHeaders]=useState([]);const[activeId,setActiveId]=useState(\"\");const[firstHeadingLevel,setFirstHeadingLevel]=useState(null);useEffect(()=>{const sectionElement=document.getElementById(props.section_id)||document.body;const headingElements=Array.from(sectionElement.querySelectorAll(\"h1, h2, h3, h4, h5, h6\"));if(headingElements.length>0&&firstHeadingLevel===null){// Determine the level of the first heading in the content\nsetFirstHeadingLevel(parseInt(headingElements[0].tagName[1],10));}const headers=headingElements.map((element,index)=>{if(!element.id){element.id=`header-${index}`;}return{id:element.id,text:element.innerText,level:parseInt(element.tagName[1],10)};});setHeaders(headers);},[props.section_id,firstHeadingLevel]);useEffect(()=>{const onScroll=()=>{let currentSectionId=\"\";headers.forEach(header=>{const element=document.getElementById(header.id);const scrollPosition=element.getBoundingClientRect().top+window.scrollY;if(scrollPosition<window.scrollY+5){currentSectionId=header.id;}});setActiveId(currentSectionId);};window.addEventListener(\"scroll\",onScroll);return()=>window.removeEventListener(\"scroll\",onScroll);},[headers]);const getStyle=header=>{// Adjust indentation based on the first heading level present\nconst indentation=firstHeadingLevel?header.level-firstHeadingLevel:0;return{display:\"block\",...props[`h${header.level}Font`],color:header.id===activeId?props.activeColor:props.fontColor,textDecoration:\"none\",marginBottom:`${props.spacing}px`,marginLeft:`${indentation*props.indentation}px`};};return /*#__PURE__*/_jsx(\"div\",{children:headers.map(header=>/*#__PURE__*/_jsx(\"a\",{href:`#${header.id}`,style:getStyle(header),onMouseOver:e=>e.currentTarget.style.color=props.onHoverColor,onMouseOut:e=>e.currentTarget.style.color=header.id===activeId?props.activeColor:props.fontColor,onClick:e=>{var _document_getElementById;e.preventDefault();setActiveId(header.id);(_document_getElementById=document.getElementById(header.id))===null||_document_getElementById===void 0?void 0:_document_getElementById.scrollIntoView({behavior:\"smooth\"});},children:header.text},header.id))});}Table_of_Content.defaultProps={section_id:\"\",fontColor:\"#000000\",activeColor:\"#FF0000\",onHoverColor:\"#00FF00\",spacing:8,indentation:10};addPropertyControls(Table_of_Content,{section_id:{type:ControlType.String,title:\"Section ID\"},fontColor:{type:ControlType.Color,title:\"Font Color\"},activeColor:{type:ControlType.Color,title:\"Active Color\"},onHoverColor:{type:ControlType.Color,title:\"On Hover Color\"},spacing:{type:ControlType.Number,title:\"Spacing\"},indentation:{type:ControlType.Number,title:\"Indentation\"},// Separate extended font controls for each heading size\nh1Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H1 Font\"},h2Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H2 Font\"},h3Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H3 Font\"},h4Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H4 Font\"},h5Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H5 Font\"},h6Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H6 Font\",description:\"[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Table_of_Content\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"400\",\"framerDisableUnlink\":\"*\"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