{"version":3,"file":"TableOfContent.BfMpl43E.mjs","names":["useState","useEffect","useEffect","_jsx","_Fragment","useState","_jsxs","__esmMin","init_npm_react_18_3_1","window","_e","init_jsx_runtime","l","c","p","ce","init_ssg_sandbox_shims","init_framer_ChujFWHC","useObserveData","Data","createStore","state1","dataStore","setDataStore","newState","storeState","storeSetters","setStoreState","setter","useStore","state","setState","init_createStore","init_store_js__1_0","HEADINGS","formatHeading","formatTableOfContent","formatHeadings","init_Utils","children","index","formattedHeading","formattedId","item","result","type","props","newChildren","newItem","withTableOfContent","Component","store","setStore","pathname","headings","a","b","aEl","bEl","HEADING_TO_DISPLAY","id","heading","isActive","withContent","newProps","setNewProps","formatted","prev","existing","filtered","f","h","headingElements","observer","entries","visible","entry","SCROLL_MARGIN_TOP","el","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/1XxWQwY0hfK0NPkccp4R/KJkJpnADqLZBYSaIILnx/Utils.js","https:/framerusercontent.com/modules/vvnzAzT8Dp0XMvVtrvXV/udqI2vzICSsmEhVadx4E/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","export const HEADINGS=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const formatHeading=(children,index)=>{let formattedHeading=\"\";let formattedId=\"\";if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{var _item_props;if(typeof item===\"string\")return item.trim();if(typeof((_item_props=item.props)===null||_item_props===void 0?void 0:_item_props.children)===\"string\")return item.props.children.trim();}).join(\" \");}else if(typeof children===\"object\"){if(typeof children.props.children===\"string\"){formattedHeading=children.props.children;}else{formattedHeading=children.type;}}else{formattedHeading=index.toString();}formattedId=formattedHeading.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\").trim();return{formattedId,formattedHeading};};export const formatTableOfContent=children=>{const result=[];children.length>0&&children.filter(({type})=>HEADINGS.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;};export const formatHeadings=props=>{const newChildren=[];props.children.props.children.forEach((item,index)=>{const children=item.props.children;if(HEADINGS.includes(item.type)){const{formattedId}=formatHeading(children,index);// Create a new object for the modified item\nconst newItem={...item,props:{...item.props,id:formattedId}};newChildren.push(newItem);}else{newChildren.push(item);}});// Return a new props object with the modified children\nreturn{...props,children:{...props.children,props:{...props.children.props,children:newChildren}}};};\nexport const __FramerMetadata__ = {\"exports\":{\"formatTableOfContent\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"HEADINGS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatHeadings\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utils.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\";import{formatHeadings,formatTableOfContent}from\"https://framer.com/m/Utils-WIyM.js\";const HEADING_TO_DISPLAY=[\"h2\"];const SCROLL_MARGIN_TOP=160;const useStore=createStore({headings:[],activeId:null});export function withTableOfContent(Component){return props=>{const[store,setStore]=useStore();const pathname=window.location.pathname;const headings=store.allHeadings?.[pathname]||[];useEffect(()=>{setStore({allHeadings:{[pathname]:store.allHeadings?.[pathname]||[]}});},[pathname]);return /*#__PURE__*/_jsx(_Fragment,{children:headings.length>0&&window?headings.sort((a,b)=>{const aEl=document.getElementById(a.id);const bEl=document.getElementById(b.id);if(!aEl||!bEl)return 0;return aEl.getBoundingClientRect().top-bEl.getBoundingClientRect().top;}).filter(({type})=>HEADING_TO_DISPLAY.includes(type)).map(({id,heading,type})=>{const isActive=id===store.activeId;return /*#__PURE__*/_jsx(Component,{...props,variant:isActive?`${type}-active`:type,title:heading,link:`${window.location.pathname}#${id}`});}):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);// Format headings with IDs\nuseEffect(()=>{setNewProps(formatHeadings(props));},[props]);// Extract headings for TOC\nuseEffect(()=>{const formatted=formatTableOfContent(newProps.children?.props?.children);if(!formatted||formatted.length===0)return;const pathname=window.location.pathname;setStore(prev=>{const existing=prev.allHeadings?.[pathname]||[];const filtered=formatted.filter(f=>!existing.some(h=>h.id===f.id));if(filtered.length===0)return{};return{allHeadings:{...prev.allHeadings,[pathname]:[...existing,...filtered]}};});},[newProps]);// Track which heading is in view\nuseEffect(()=>{const headingElements=Array.from(document.querySelectorAll(\"h2\"));const observer=new IntersectionObserver(entries=>{const visible=entries.filter(entry=>entry.isIntersecting).sort((a,b)=>b.intersectionRatio-a.intersectionRatio);if(visible.length>0){setStore({activeId:visible[0].target.id});}},{rootMargin:`-${SCROLL_MARGIN_TOP}px 0px 0px 0px`,threshold:.1});headingElements.forEach(el=>observer.observe(el));return()=>observer.disconnect();},[]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                    html {\n                        scroll-behavior: smooth;\n                    }\n                    .framer-text {\n                        scroll-margin-top: ${SCROLL_MARGIN_TOP}px;\n                    }\n                `}),/*#__PURE__*/_jsx(Component,{...newProps})]});};}\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,8MAA8E,SAAgBoB,EAAYC,EAAO,CACjH,IAAMC,EAAUH,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGE,CAAM,CAAC,CAAC,CAAC,EACjDE,EAAaC,GAAU,CAC1B,OAAOA,GAAW,aAAYA,EAASA,EAASF,EAAU,KA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