{"version":3,"file":"WithTableOverride.BqsFkcvi.mjs","names":["useStore","useState","React.useCallback"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/7mvfRZgYnbTmjXwrKw9p/DGmGvVEuXEhlVjRh5M2t/WithTableOverride.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","import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({background:\"#f0f0f0\"});// Function to convert Markdown table to HTML table\nconst markdownToHtmlTable=markdown=>{const lines=markdown.trim().split(\"\\n\");if(lines.length<3){return\"<p>Invalid Markdown table</p>\";}// Extract headers from the first line\nconst headers=lines[0].split(\"|\").map(header=>header.trim()).filter(header=>header);// Extract rows starting from the second line (ignore the separator line)\nconst rows=lines.slice(2).map(line=>line.split(\"|\").map(cell=>cell.trim()).filter(cell=>cell!==\"\"));// Create the HTML table string\nlet html=\"<thead><tr>\";headers.forEach(header=>{html+=`<th>${header}</th>`;});html+=\"</tr></thead><tbody>\";rows.forEach(row=>{html+=\"<tr>\";row.forEach(cell=>{html+=`<td>${cell}</td>`;});html+=\"</tr>\";});html+=\"</tbody>\";return html;};export function withTableOverride(Component){return props=>{const[store]=useStore();const extractAndFormatTable=React.useCallback(()=>{const contentDivs=document.querySelectorAll('[data-framer-component-type=\"RichTextContainer\"]');contentDivs.forEach(contentDiv=>{const codeBlocks=contentDiv.querySelectorAll(\".framer-text.framer-text-module\");codeBlocks.forEach(codeBlock=>{if(codeBlock instanceof HTMLElement){// Get the framer-cb div to access CSS variables\nconst framerCbDiv=codeBlock.querySelector(\".framer-cb\");if(!framerCbDiv)return;// Extract CSS variables from the style attribute\nconst styleAttr=framerCbDiv.getAttribute(\"style\")||\"\";const cssVars={};styleAttr.split(\";\").forEach(pair=>{const[key,value]=pair.split(\":\").map(s=>s.trim());if(key.startsWith(\"--\")){cssVars[key]=value;}});// Determine if we're in light or dark mode\nconst colorScheme=cssVars[\"--cb-color-scheme-dark\"]===\"light\"?\"light\":\"dark\";// Find the div with the border (sp-layout)\nconst borderDiv=codeBlock.querySelector(\".sp-layout\");if(!borderDiv)return;// Extract the border properties and padding from the style attribute\nconst borderStyle=window.getComputedStyle(borderDiv);const borderWidth=borderStyle.borderWidth;const borderColor=borderStyle.borderColor;const borderRadius=\"10px\";// Create an outer container for the border\nconst outerContainer=document.createElement(\"div\");outerContainer.style.cssText=`\n                            border: ${borderWidth} solid ${borderColor};\n                            border-radius: ${borderRadius};\n                            overflow: hidden;\n                            width: 100%;\n                            height: 100%;\n                        `;// Create an inner container for the scrollable content\nconst innerContainer=document.createElement(\"div\");innerContainer.style.cssText=`\n                            overflow: auto;\n                            width: 100%;\n                            height: 100%;\n                        `;// Create the table\nconst table=document.createElement(\"table\");table.style.cssText=`\n                            border-collapse: separate;\n                            border-spacing: 0;\n                            width: 100%;\n                        `;// Convert extracted content to HTML table\nconst collection=codeBlock.getElementsByClassName(\"cm-line\");const codeContent=Array.from(collection).map(el=>el.textContent).join(\"\\n\");if(codeContent.length>0){table.innerHTML=`\n                            <table style=\"width: 100%; border-collapse: separate; border-spacing: 0;\">\n                                ${markdownToHtmlTable(codeContent)}\n                            </table>\n                        `;// Add styles\nconst style=document.createElement(\"style\");style.textContent=`\n                            table {\n                                table-layout: fixed;\n                            }\n                            table th, table td {\n                                padding: 14px;\n                                vertical-align: baseline;\n                                text-align: left;\n                                font-family: \"Open Sans\", \"Open Sans Placeholder\", sans-serif;\n                                background-color: ${cssVars[`--cb-colors-surface1-${colorScheme}`]};\n                                @media only screen and (max-width: 700px) {\n                                    font-size: 9px;\n                                    padding: 10px;\n                                }\n                                font-size: 16px;\n                                border-right: 1px solid ${borderColor};\n                                border-bottom: 1px solid ${borderColor};\n                            }\n                            table th {\n                                font-family: \"Open Sans\", \"Open Sans Placeholder\", sans-serif;\n                                @media only screen and (max-width: 700px) {\n                                     font-size: 10px;\n                                }\n                                font-size: 18px;\n                                font-weight: bold;\n                                color: ${cssVars[`--cb-syntax-color-plain-${colorScheme}`]};\n                                position: sticky;\n                                top: 0;\n                                z-index: 1;\n                            }\n                            table tr:last-child td {\n                                border-bottom: none;\n                            }\n                            table th:last-child,\n                            table td:last-child {\n                                border-right: none;\n                            }\n                        `;outerContainer.appendChild(style);// Assemble the structure\ninnerContainer.appendChild(table);outerContainer.appendChild(innerContainer);// Replace the content of the code block with the new structure\ncodeBlock.innerHTML=\"\";codeBlock.appendChild(outerContainer);}}});});},[store.background]);React.useEffect(()=>{// Add a MutationObserver to handle dynamic content changes\nconst observer=new MutationObserver(extractAndFormatTable);const contentDivs=document.querySelectorAll('[data-framer-name=\"Content\"][data-framer-component-type=\"RichTextContainer\"]');contentDivs.forEach(contentDiv=>{observer.observe(contentDiv,{childList:true,subtree:true});});// Remove white-space: pre-wrap from the Content div\nconst style=document.createElement(\"style\");style.textContent=`\n                [data-framer-name=\"Content\"][data-framer-component-type=\"RichTextContainer\"] {\n                    white-space: normal !important;\n                }\n                [data-framer-name=\"Content\"][data-framer-component-type=\"RichTextContainer\"] > div {\n                    white-space: normal !important;\n                }\n            `;document.head.appendChild(style);return()=>{observer.disconnect();document.head.removeChild(style);};},[extractAndFormatTable]);React.useEffect(()=>{setTimeout(extractAndFormatTable,50);const interval=setInterval(extractAndFormatTable,100);return()=>{clearInterval(interval);};},[]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withTableOverride\":{\"type\":\"reactHoc\",\"name\":\"withTableOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithTableOverride.map"],"mappings":"kMAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OA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