{"version":3,"file":"TableOfContent.DX05fdNP.mjs","names":["useState","useEffect","_jsx","_jsxs","_Fragment","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","init_jsx_runtime","l","c","p","ce","_e","init_store_js__1_0","createStore","withContent","Component","props","store","setStore","useStore","newProps","setNewProps","formatTableOfContent","newChildren","item","index","children","formattedId","formatHeading","newItem","isPlatformComparisonTable","tableText","comparisonTableText","label","SCROLL_MARGIN_TOP","init_TableOfContent","node","result","type","formattedHeading"],"sources":["https:/framerusercontent.com/modules/a3VG9s3iUm0YoyEF2rgV/NYbuebzJczm3XWH1BK97/TableOfContent.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";// @ts-expect-error Framer resolves this hosted store module at runtime; URL-module typings are unavailable.\nimport{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState}from\"react\";const HEADING_TO_DISPLAY=[\"h1\",\"h2\"];const SCROLL_MARGIN_TOP=80;const comparisonTableText=node=>{if(typeof node===\"string\"||typeof node===\"number\")return String(node);if(Array.isArray(node))return node.map(comparisonTableText).join(\" \");return node?.props?comparisonTableText(node.props.children):\"\";};const isPlatformComparisonTable=node=>[\"Databricks Genie\",\"Snowflake Cortex Analyst / Agents\",\"Google\"].every(label=>comparisonTableText(node).includes(label));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\"});}};useEffect(()=>{const handleScroll=()=>{const sections=store.headings.map(heading=>document.getElementById(heading.id));const scrollPosition=window.scrollY-160;for(let i=sections.length-1;i>=0;i--){if(sections[i].offsetTop<=scrollPosition){setActiveSection(store.headings[i].id);break;}}};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);// Create a new object for the modified item\nconst newItem={...item,props:{...item.props,id:formattedId}};newChildren.push(newItem);}else if(isPlatformComparisonTable(item)){const tableText=comparisonTableText(item);const label=tableText.includes(\"Approche\")?\"Tableau comparatif\":tableText.includes(\"Aanpak\")?\"Vergelijkingstabel\":\"Comparison table\";newChildren.push(/*#__PURE__*/_jsx(\"div\",{role:\"region\",\"aria-label\":label,tabIndex:0,style:{width:\"100%\",maxWidth:\"100%\",minWidth:0,overflowX:\"auto\",WebkitOverflowScrolling:\"touch\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",minWidth:600},children:item})},item.key??`comparison-table-${index}`));}else{newChildren.push(item);}});// Return a new props object with the modified children\nreturn{...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\":{\"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,sMACopD,SAAgBgB,EAAYC,EAAU,CAAC,MAAOC,IAAO,CAAC,GAAK,CAACC,EAAMC,GAAUC,EAAS,EAAO,CAACC,EAASC,GAAavB,EAASkB,CAAK,EAEvoD,OAFyoDjB,MAAc,CAACmB,EAAS,CAAC,SAASI,EAAqBF,EAAS,SAAS,MAAM,QAAQ,CAAC,CAAC,CAAE,EAAE,CAACA,CAAQ,CAAC,EAAErB,MAAc,CAEzyDsB,OAFm0D,CAAC,IAAME,EAAY,CAAC,EAE57D,OAF87DP,EAAM,SAAS,MAAM,SAAS,OAAO,GAAGA,EAAM,SAAS,MAAM,SAAS,SAASQ,EAAKC,IAAQ,CAAC,IAAMC,EAASF,EAAK,MAAM,SAAS,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,SAASA,EAAK,IAAI,EAAE,CAAC,GAAK,CAACG,eAAaC,EA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