{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/PF1dXvUypVpfq84CrORY/UWGmykIPpDvi5bEigsL2/TableOFContent.js"],
  "sourcesContent": ["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState}from\"react\";const HEADING_TO_DISPLAY=[\"h2\",\"h4\"];const SCROLL_MARGIN_TOP=110;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(\"\");const[isClickActive,setIsClickActive]=useState(false);const scrollToId=id=>{const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\"});setActiveSection(id);setIsClickActive(true);setTimeout(()=>{setIsClickActive(false);},500);}};useEffect(()=>{const handleScroll=()=>{if(isClickActive)return;const sections=store.headings.map(heading=>document.getElementById(heading.id));const scrollPosition=window.scrollY-60;for(let i=sections.length-1;i>=0;i--){if(sections[i]&&sections[i].offsetTop<=scrollPosition){setActiveSection(store.headings[i].id);break;}}};window.addEventListener(\"scroll\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[store.headings,isClickActive]);return /*#__PURE__*/_jsx(_Fragment,{children:store.headings.length>0&&window?store.headings.sort((a,b)=>a.originalIndex-b.originalIndex).filter(({type})=>HEADING_TO_DISPLAY.includes(type)).map(({id,heading,type},index)=>/*#__PURE__*/_jsx(Component,{...props,variant:activeSection===id?`${type}-active`:type,title:heading,onClick:()=>scrollToId(id)})):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);useEffect(()=>{setStore({headings:formatTableOfContent(newProps.children?.props?.children||[])});},[newProps]);useEffect(()=>{const formatHeadings=()=>{const newChildren=[];const children=Array.isArray(props.children?.props?.children)?props.children.props.children:[props.children?.props?.children].filter(Boolean);children.forEach((item,index)=>{if(item&&[\"h2\",\"h4\"].includes(item.type)){const{formattedId}=formatHeading(item.props.children,index);const newItem={...item,props:{...item.props,id:formattedId}};newChildren.push(newItem);}else{newChildren.push(item);}});return{...props,children:{...props.children,props:{...props.children.props,children:newChildren}}};};setNewProps(formatHeadings());},[props]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`.framer-text {\n                    scroll-margin-top: ${SCROLL_MARGIN_TOP}px;\n                }`}),/*#__PURE__*/_jsx(Component,{...newProps})]});};}const formatTableOfContent=children=>{const result=[];(Array.isArray(children)?children:[children]).filter(Boolean).filter(({type})=>[\"h2\",\"h4\"].includes(type)).forEach((item,index)=>{const{formattedId,formattedHeading}=formatHeading(item.props.children,index);result.push({id:formattedId,heading:formattedHeading,type:item.type,originalIndex:index});});return result;};const formatHeading=(children,index)=>{let formattedHeading=\"\";let formattedId=\"\";if(typeof children===\"string\"){formattedHeading=children.trim();}else if(Array.isArray(children)){formattedHeading=children.map(item=>{if(typeof item===\"string\")return item.trim();if(item.type===\"br\")return\"\";return item.props.children?.trim()||\"\";}).join(\" \");}else if(children?.props?.children){formattedHeading=children.props.children.trim();}else{formattedHeading=`heading-${index}`;}formattedId=formattedHeading.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\");return{formattedId,formattedHeading};};\nexport const __FramerMetadata__ = {\"exports\":{\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTableOfContent\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOFContent.map"],
  "mappings": "uJAA0L,IAAMA,EAAmB,CAAC,KAAK,IAAI,EAAQC,EAAkB,IAAUC,EAASC,EAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAS,SAASC,EAAmBC,EAAU,CAAC,OAAOC,GAAO,CAAC,GAAK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,CAAC,CAAC,CAAC,CAAC,CAAE,CAAE,CAAC,IAAME,EAAqBO,GAAU,CAAC,IAAMC,EAAO,CAAC,EAAE,OAAC,MAAM,QAAQD,CAAQ,EAAEA,EAAS,CAACA,CAAQ,GAAG,OAAO,OAAO,EAAE,OAAO,CAAC,CAAC,KAAAb,CAAI,IAAI,CAAC,KAAK,IAAI,EAAE,SAASA,CAAI,CAAC,EAAE,QAAQ,CAACQ,EAAKP,IAAQ,CAAC,GAAK,CAAC,YAAAQ,EAAY,iBAAAM,CAAgB,EAAEL,EAAcF,EAAK,MAAM,SAASP,CAAK,EAAEa,EAAO,KAAK,CAAC,GAAGL,EAAY,QAAQM,EAAiB,KAAKP,EAAK,KAAK,cAAcP,CAAK,CAAC,CAAE,CAAC,EAASa,CAAO,EAAQJ,EAAc,CAACG,EAASZ,IAAQ,CAAC,IAAIc,EAAiB,GAAON,EAAY,GAAG,OAAG,OAAOI,GAAW,SAAUE,EAAiBF,EAAS,KAAK,EAAW,MAAM,QAAQA,CAAQ,EAAGE,EAAiBF,EAAS,IAAIL,GAAU,OAAOA,GAAO,SAAgBA,EAAK,KAAK,EAAKA,EAAK,OAAO,KAAW,GAAUA,EAAK,MAAM,UAAU,KAAK,GAAG,EAAI,EAAE,KAAK,GAAG,EAAWK,GAAU,OAAO,SAAUE,EAAiBF,EAAS,MAAM,SAAS,KAAK,EAAQE,EAAiB,WAAWd,CAAK,GAAIQ,EAAYM,EAAiB,YAAY,EAAE,QAAQ,cAAc,GAAG,EAAE,QAAQ,WAAW,EAAE,EAAQ,CAAC,YAAAN,EAAY,iBAAAM,CAAgB,CAAE",
  "names": ["HEADING_TO_DISPLAY", "SCROLL_MARGIN_TOP", "useStore", "createStore", "withTableOfContent", "Component", "props", "store", "activeSection", "setActiveSection", "ye", "isClickActive", "setIsClickActive", "scrollToId", "id", "element", "ue", "handleScroll", "sections", "heading", "scrollPosition", "window", "p", "l", "a", "b", "type", "index", "withContent", "setStore", "newProps", "setNewProps", "formatTableOfContent", "newChildren", "item", "formattedId", "formatHeading", "newItem", "u", "children", "result", "formattedHeading"]
}
