{"version":3,"file":"TableOfContent.Cipp5Y5S.mjs","names":["useState","useState","_Fragment","useRef","__esmMin","window","_e","de","init_ssg_sandbox_shims","c","init_jsx_runtime","H","init_npm_react_18_3_1","p","l","ce","useObserveData","init_framer_CaDWdxiz","Data","createStore","dataStore","state1","setDataStore","newState","storeState","storeSetters","setStoreState","setter","useStore","state","setState","init_createStore","init_store_js__1_0","mergedHeadings","seen","all","registry","group","heading","inPageOrder","headings","el","top","a","b","toArray","children","withTableOfContent","store","activeSection","setActiveSection","HEADING_TO_DISPLAY","type","scrollToId","element","id","handleScroll","midpoint","ordered","matched","Component","props","withContent","setStore","newProps","setNewProps","layerKey","updatedHeadings","formatTableOfContent","original","isArray","newChildren","childrenContent","item","formatHeading","index","formattedId","SCROLL_MARGIN_TOP","result","formattedHeading","layerCount","init_TableOfContent"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/gnNkoAmm27jNSr2cTkAa/fS52RuAx09foblXqF6oc/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","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","/**\n * Table of Contents Overrides v1.1.0\n * Made with ❤️ by ekayy.com\n * v1.1: supports several withContent layers on one page (headings are merged in page order)\n */import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useRef,useState}from\"react\";const HEADING_TO_DISPLAY=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const SCROLL_MARGIN_TOP=80;const useStore=createStore({headings:[]});// Headings of every withContent layer, keyed by layer, in mount order\nconst registry=new Map;let layerCount=0;function mergedHeadings(){const seen=new Set;const all=[];Array.from(registry.values()).forEach((group,groupIndex)=>{group.forEach(heading=>{if(seen.has(heading.id))return;seen.add(heading.id);all.push({...heading,groupIndex});});});return all;}// Sort by position on the page once the ids are in the DOM, otherwise keep mount order\nfunction inPageOrder(headings){if(typeof document===\"undefined\")return headings;return headings.map((heading,index)=>{const el=document.getElementById(heading.id);const top=el?el.getBoundingClientRect().top+window.scrollY:Number.MAX_SAFE_INTEGER;return{...heading,index,top};}).sort((a,b)=>a.top-b.top||a.index-b.index);}function toArray(children){if(Array.isArray(children))return children;return children?[children]:[];}export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(\"\");const headings=inPageOrder(store.headings.filter(({type})=>HEADING_TO_DISPLAY.includes(type)));const scrollToId=id=>{const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\"});}};useEffect(()=>{const handleScroll=()=>{const midpoint=window.innerHeight/2;const ordered=inPageOrder(store.headings);let matched=false;for(const heading of ordered){const el=document.getElementById(heading.id);if(!el)continue;const rect=el.getBoundingClientRect();if(rect.top<=midpoint){setActiveSection(heading.id);matched=true;}else{break;}}if(!matched&&ordered.length>0){setActiveSection(ordered[0].id);}};handleScroll()// ✅ ensure correct on load\n;window.addEventListener(\"scroll\",handleScroll);window.addEventListener(\"resize\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);window.removeEventListener(\"resize\",handleScroll);};},[store.headings]);return /*#__PURE__*/_jsx(_Fragment,{children:headings.length>0&&typeof window!==\"undefined\"?headings.map(({id,heading,type})=>/*#__PURE__*/_createElement(Component,{...props,variant:activeSection===id?`${type}-active`:type,title:heading,onClick:()=>scrollToId(id),key:id})):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);const layerKey=useRef(null);if(layerKey.current===null)layerKey.current=layerCount++;useEffect(()=>{const updatedHeadings=formatTableOfContent(toArray(newProps?.children?.props?.children));registry.set(layerKey.current,updatedHeadings);setStore({headings:mergedHeadings()});},[newProps]);useEffect(()=>{return()=>{registry.delete(layerKey.current);setStore({headings:mergedHeadings()});};},[]);useEffect(()=>{const formatHeadings=()=>{const original=props?.children?.props?.children;if(!original)return props;const isArray=Array.isArray(original);const children=toArray(original);const newChildren=[];children.forEach((item,index)=>{const childrenContent=item?.props?.children;if(HEADING_TO_DISPLAY.includes(item?.type)){const{formattedId}=formatHeading(childrenContent,index);newChildren.push({...item,props:{...item.props,id:formattedId}});}else{newChildren.push(item);}});return{...props,children:{...props.children,props:{...props.children.props,children:isArray?newChildren:newChildren[0]}}};};setNewProps(formatHeadings());},[props]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`.framer-text { scroll-margin-top: ${SCROLL_MARGIN_TOP}px; }`}),/*#__PURE__*/_jsx(Component,{...newProps})]});};}function formatTableOfContent(children){const result=[];if(!Array.isArray(children))return result;children.filter(item=>HEADING_TO_DISPLAY.includes(item?.type)).forEach((item,index)=>{const children=item.props.children;const{formattedId,formattedHeading}=formatHeading(children,index);// Skip empty headings so the TOC has no blank entries\nif(!formattedHeading.trim()||!formattedId)return;result.push({id:formattedId,heading:formattedHeading,type:item.type,originalIndex:index});});return result;}function formatHeading(children,index){let formattedHeading=\"\";let formattedId=\"\";if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{if(typeof item===\"string\")return item.trim();if(item?.type===\"br\")return\"\";return typeof item?.props?.children===\"string\"?item.props.children.trim():\"\";}).join(\" \");}else if(typeof children===\"object\"){if(typeof children?.props?.children===\"string\"){formattedHeading=children.props.children;}}else{formattedHeading=`heading-${index}`;}formattedId=formattedHeading.trim().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":"A,6NAA8E,SAAgBmB,EAAY,EAAO,CACjH,IAAMC,EAAUF,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGG,CAAM,CAAC,CAAC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