{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/framer/store.js@^1.0.0", "ssg:https://framerusercontent.com/modules/yP2rPB9Vjy6TvGe0LC9o/hLwahIsYqSs7yoC4Lezh/TableOfContent.js"],
  "sourcesContent": ["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map", "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\"];const SCROLL_MARGIN_TOP=180;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(\"\");const scrollToId=id=>{const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\"});// Trigger the scroll event manually after the smooth scroll\nsetTimeout(()=>{handleScroll()// Call the handleScroll function manually\n;},300)// Adjust the delay if necessary\n;}};const handleScroll=()=>{// Define a tolerance in pixels\nconst TOLERANCE=5;// Filter to only include headings we want to display (H2 in this case)\nconst sections=store.headings.filter(heading=>HEADING_TO_DISPLAY.includes(heading.type)).map(heading=>document.getElementById(heading.id));let found=false;for(let i=0;i<sections.length;i++){const rect=sections[i].getBoundingClientRect();const topIsWithinTolerance=Math.abs(rect.top-SCROLL_MARGIN_TOP)<=TOLERANCE;if(rect.top<=SCROLL_MARGIN_TOP||topIsWithinTolerance){setActiveSection(store.headings.filter(heading=>HEADING_TO_DISPLAY.includes(heading.type))[i].id);found=true;}else if(found){break;}}};useEffect(()=>{window.addEventListener(\"scroll\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[store.headings]);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=[];props.children.props.children.length>0&&props.children.props.children.forEach((item,index)=>{const children=item.props.children;if([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(item.type)){const{formattedId}=formatHeading(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=[];children.length>0&&children.filter(({type})=>[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(type)).map((item,index)=>{const children=item.props.children;const{formattedId,formattedHeading}=formatHeading(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;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{console.log(\"item\",item);if(typeof item===\"string\")return item.trim();if(item.type===\"br\")return\"\";return item.props.children.trim();}).join(\" \");}else if(typeof children===\"object\"){if(typeof children.props.children===\"string\"){formattedHeading=children.props.children;}}else{formattedHeading=index.toString();}formattedId=formattedHeading.trim().toLowerCase().replace(/[^a-z]+/g,\"-\").replace(/^-+|-+$/g,\"\");return{formattedId,formattedHeading};};\nexport const __FramerMetadata__ = {\"exports\":{\"withTableOfContent\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContent.map"],
  "mappings": "8JAAqF,SAASA,EAAYC,EAAO,CACjH,IAAMC,EAAUC,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGF,CAAM,CAAC,CAAC,CAAC,EACjDG,EAAaC,GAAU,CAC1B,OAAOA,GAAW,aAAYA,EAASA,EAASH,EAAU,KAAK,GAA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,EAAY,QAAQK,EAAiB,KAAKP,EAAK,KAAK,cAAcP,CAAK,CAAC,CAAE,CAAC,EAASa,CAAO,EAAQH,EAAc,CAACF,EAASR,IAAQ,CAAC,IAAIc,EAAiB,GAAOL,EAAY,GAAG,OAAG,OAAOD,GAAW,SAAUM,EAAiBN,EAAkB,MAAM,QAAQA,CAAQ,EAAGM,EAAiBN,EAAS,IAAID,IAAO,QAAQ,IAAI,OAAOA,CAAI,EAAK,OAAOA,GAAO,SAAgBA,EAAK,KAAK,EAAKA,EAAK,OAAO,KAAW,GAAUA,EAAK,MAAM,SAAS,KAAK,EAAG,EAAE,KAAK,GAAG,EAAW,OAAOC,GAAW,SAAa,OAAOA,EAAS,MAAM,UAAW,WAAUM,EAAiBN,EAAS,MAAM,UAAgBM,EAAiBd,EAAM,SAAS,EAAGS,EAAYK,EAAiB,KAAK,EAAE,YAAY,EAAE,QAAQ,WAAW,GAAG,EAAE,QAAQ,WAAW,EAAE,EAAQ,CAAC,YAAAL,EAAY,iBAAAK,CAAgB,CAAE",
  "names": ["createStore", "state1", "dataStore", "Data", "setDataStore", "newState", "storeState", "storeSetters", "setStoreState", "setter", "useStore", "state", "setState", "ye", "ue", "useObserveData", "HEADING_TO_DISPLAY", "SCROLL_MARGIN_TOP", "useStore", "createStore", "withTableOfContent", "Component", "props", "store", "activeSection", "setActiveSection", "ye", "scrollToId", "id", "element", "handleScroll", "sections", "heading", "found", "rect", "topIsWithinTolerance", "ue", "window", "p", "l", "a", "b", "type", "index", "withContent", "setStore", "newProps", "setNewProps", "formatTableOfContent", "newChildren", "item", "children", "formattedId", "formatHeading", "newItem", "u", "result", "formattedHeading"]
}
