{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/q6TPcm1rVRPb4ymPsf0M/T8sfasfxfYIEBWpKyxWp/TableOfContent.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef}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);const ignoreNextScrollEvent=useRef(false);const scrollTimeoutRef=useRef(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){setFirstHeadingLevel(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=()=>{if(ignoreNextScrollEvent.current){ignoreNextScrollEvent.current=false;return;}let currentSectionId=\"\";headers.forEach(header=>{const element=document.getElementById(header.id);const scrollPosition=element.getBoundingClientRect().top+window.scrollY;if(scrollPosition<window.scrollY+props.yOffset+5){currentSectionId=header.id;}});setActiveId(currentSectionId);};window.addEventListener(\"scroll\",onScroll);return()=>window.removeEventListener(\"scroll\",onScroll);},[headers,props.yOffset]);const getStyle=header=>{const indentation=firstHeadingLevel?header.level-firstHeadingLevel:0;const headerFont=props[`h${header.level}Font`]||{};return{display:\"block\",...headerFont,color:header.id===activeId?props.activeColor:props.fontColor,fontWeight:header.id===activeId?props.activeFontWeight:headerFont.fontWeight||\"normal\",textDecoration:\"none\",marginBottom:`${props.spacing}px`,marginLeft:`${indentation*props.indentation}px`};};const handleClick=headerId=>{ignoreNextScrollEvent.current=true;const element=document.getElementById(headerId);if(element){const y=element.getBoundingClientRect().top+window.pageYOffset-props.yOffset;window.scrollTo({top:y,behavior:\"smooth\"});checkIfScrollFinished(headerId);}};const checkIfScrollFinished=headerId=>{if(scrollTimeoutRef.current){clearTimeout(scrollTimeoutRef.current);}const isScrolled=()=>{const element=document.getElementById(headerId);if(element){const rect=element.getBoundingClientRect();return Math.abs(rect.top-props.yOffset)<=1;}return false;};const checkScroll=()=>{if(isScrolled()){setActiveId(headerId);}else{scrollTimeoutRef.current=setTimeout(()=>{requestAnimationFrame(checkScroll);},10);}};checkScroll();};return /*#__PURE__*/_jsx(\"div\",{children:headers.filter(header=>props[`showH${header.level}`]!==false).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;e.currentTarget.style.fontWeight=header.id===activeId?props.activeFontWeight:getStyle(header).fontWeight;},onClick:e=>{e.preventDefault();handleClick(header.id);},children:header.text},header.id))});}Table_of_Content.defaultProps={section_id:\"\",fontColor:\"#000000\",activeColor:\"#FF0000\",onHoverColor:\"#00FF00\",spacing:8,indentation:10,yOffset:0,activeFontWeight:\"bold\"};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\"},yOffset:{type:ControlType.Number,title:\"Y Offset\",min:0,max:200,step:1},activeFontWeight:{type:ControlType.Enum,title:\"Active Font Weight\",options:[\"normal\",\"bold\",\"bolder\",\"lighter\",\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],defaultValue:\"bold\"},showH1:{type:ControlType.Boolean,title:\"Show H1\",defaultValue:true},showH2:{type:ControlType.Boolean,title:\"Show H2\",defaultValue:true},showH3:{type:ControlType.Boolean,title:\"Show H3\",defaultValue:true},showH4:{type:ControlType.Boolean,title:\"Show H4\",defaultValue:true},showH5:{type:ControlType.Boolean,title:\"Show H5\",defaultValue:true},showH6:{type:ControlType.Boolean,title:\"Show H6\",defaultValue:true},h1Font:{// @ts-expect-error \u2013 Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H1 Font\"},h2Font:{// @ts-expect-error \u2013 Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H2 Font\"},h3Font:{// @ts-expect-error \u2013 Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H3 Font\"},h4Font:{// @ts-expect-error \u2013 Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H4 Font\"},h5Font:{// @ts-expect-error \u2013 Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H5 Font\"},h6Font:{// @ts-expect-error \u2013 Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H6 Font\",description:\"Preview to see the component in effect \\nv1.5 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Table_of_Content\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContent.map"],
  "mappings": "uJAOkB,SAARA,EAAkCC,EAAM,CAAC,GAAK,CAACC,EAAQC,CAAU,EAAEC,EAAS,CAAC,CAAC,EAAO,CAACC,EAASC,CAAW,EAAEF,EAAS,EAAE,EAAO,CAACG,EA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,QAAQ,MAAM,UAAU,aAAa,EAAI,EAAE,OAAO,CAAC,KAAKA,EAAY,QAAQ,MAAM,UAAU,aAAa,EAAI,EAAE,OAAO,CACvrI,KAAKA,EAAY,KAAK,SAAS,WAAW,MAAM,SAAS,EAAE,OAAO,CAClE,KAAKA,EAAY,KAAK,SAAS,WAAW,MAAM,SAAS,EAAE,OAAO,CAClE,KAAKA,EAAY,KAAK,SAAS,WAAW,MAAM,SAAS,EAAE,OAAO,CAClE,KAAKA,EAAY,KAAK,SAAS,WAAW,MAAM,SAAS,EAAE,OAAO,CAClE,KAAKA,EAAY,KAAK,SAAS,WAAW,MAAM,SAAS,EAAE,OAAO,CAClE,KAAKA,EAAY,KAAK,SAAS,WAAW,MAAM,UAAU,YAAY;AAAA;AAAA,2CAA4F,CAAC,CAAC",
  "names": ["Table_of_Content", "props", "headers", "setHeaders", "ye", "activeId", "setActiveId", "firstHeadingLevel", "setFirstHeadingLevel", "ignoreNextScrollEvent", "pe", "scrollTimeoutRef", "ue", "sectionElement", "headingElements", "element", "index", "onScroll", "currentSectionId", "header", "window", "getStyle", "indentation", "headerFont", "handleClick", "headerId", "y", "checkIfScrollFinished", "isScrolled", "rect", "checkScroll", "p", "e", "addPropertyControls", "ControlType"]
}
