{"version":3,"file":"Table_of_Contents_Blog.CvYfrQLF.mjs","names":["_Fragment","useState","children"],"sources":["https:/framerusercontent.com/modules/YdssnNKDeArgaiNs4wFI/Csk3X3zusmvkCgg2I5Fj/Table_of_Contents_Blog.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=[\"h1\",\"h2\"];const SCROLL_MARGIN_TOP=186;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();const handleLinkClick=(event,id)=>{event.preventDefault();const targetElement=document.getElementById(id);if(targetElement){targetElement.scrollIntoView({behavior:\"smooth\"});}};return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                    .toc-link {\n                        text-decoration: none;\n                        color: inherit;\n                    }\n                `}),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(\"a\",{href:`${window.location.pathname}#${id}`,onClick:event=>handleLinkClick(event,id),className:\"toc-link\",children:/*#__PURE__*/_jsx(Component,{...props,variant:type,title:heading})},index)):/*#__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.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{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.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=>{if(typeof item===\"string\")return item.trim();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-z]+/g,\"-\").replace(/^-+|-+$/g,\"\").trim();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=./Table_of_Contents_Blog.map"],"mappings":"wMAAqS,SAAgB,EAAmB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,GAAO,GAAU,CAAO,GAAiB,EAAM,IAAK,CAAC,EAAM,gBAAgB,CAAC,IAAM,EAAc,SAAS,eAAe,EAAG,CAAI,GAAe,EAAc,eAAe,CAAC,SAAS,SAAS,CAAC,EAAI,OAAoB,EAAMA,EAAU,CAAC,SAAS,CAAc,EAAK,QAAQ,CAAC,SAAS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