{"version":3,"file":"MarkdownTable.DNjHPO2y.mjs","names":["React.useCallback"],"sources":["https:/framerusercontent.com/modules/4V4IN33efgPjQLJmwIax/JneZmAtTTkzOYePMdf3K/MarkdownTable.js"],"sourcesContent":["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:\"#ff00ff\"});const cellBackground=\"#FFF\";const headerBackground=\"rgba(0,0,0,0.05)\";const textColor=\"#14141f\";const borderColor=\"rgba(0,0,0,0.2)\";export function TableOverride(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){// Ensure codeBlock has content before proceeding\nif(!codeBlock.textContent||codeBlock.textContent.trim()===\"\"){return;// Skip if no content is present\n}// 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 borderRadius=borderStyle.borderRadius;const padding=borderStyle.getPropertyValue(\"--cb-padding\")||\"27px\"// Default to 27px if not set\n;// 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                            min-width: 600px;\n                        `;// Convert extracted content to HTML table\nconst codeContent=codeBlock.textContent||\"\";const tableLines=codeContent.split(/\\r?\\n/).filter(line=>line.trim()!==\"\");const tableHtml=tableLines.map((row,index)=>{const cells=row.split(\"|\").map(cell=>cell.trim()).filter(cell=>cell!==\"\");if(index===0){return`<tr>${cells.map((cell,cellIndex)=>`<th${cellIndex===0?' class=\"first-column\"':\"\"}>${cell}</th>`).join(\"\")}</tr>`;}else if(index===1){return\"\"// Skip the separator row\n;}else{return`<tr>${cells.map((cell,cellIndex)=>`<td${cellIndex===0?' class=\"first-column\"':\"\"}>${cell.replace(/\\<br\\>/g,\"<br>\")}</td>`).join(\"\")}</tr>`;}}).filter(row=>row!==\"\").join(\"\");table.innerHTML=`\n                            <table style=\"width: 100%; border-collapse: separate; border-spacing: 0;\">\n                                ${tableHtml}\n                            </table>\n                        `;// Add styles\nconst style=document.createElement(\"style\");style.textContent=`\n                            table th, table td {\n                                padding: ${padding};\n                                text-align: left;\n                                color: ${textColor};\n                                border-right: 1px solid ${borderColor};\n                                border-bottom: 1px solid ${borderColor};\n                                word-break: normal;\n                            }\n                            table td {\n                                background-color: ${cellBackground};\n                            }\n                            table th {\n                                font-weight: bold;\n                                background: ${headerBackground};\n                                position: sticky;\n                                top: 0;\n                                z-index: 1;\n                            }\n                            .first-column {\n                                // white-space: nowrap;\n                                // overflow: hidden;\n                                // text-overflow: ellipsis;\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(()=>{extractAndFormatTable();// Add a MutationObserver to handle dynamic content changes\nconst observer=new MutationObserver(extractAndFormatTable);const contentDivs=document.querySelectorAll('[data-framer-name=\"MarkdownTable\"] > [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=\"MarkdownTable\"] > [data-framer-component-type=\"RichTextContainer\"] {\n                    white-space: normal !important;\n                }\n                [data-framer-name=\"MarkdownTable\"] > [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]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"TableOverride\":{\"type\":\"reactHoc\",\"name\":\"TableOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MarkdownTable.map"],"mappings":"8RAAmU,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,GAAO,GAAU,CAAO,EAAsBA,MAAsB,CAAmB,SAAS,iBAAiB,mDAAmD,CAAa,QAAQ,GAAY,CAAkB,EAAW,iBAAiB,kCAAkC,CAAY,QAAQ,GAAW,CAAC,GAAG,aAAqB,YAAY,CAC1tB,GAAG,CAAC,EAAU,aAAa,EAAU,YAAY,MAAM,GAAG,GAAI,OAE9D,IAAM,EAAY,EAAU,cAAc,aAAa,CAAC,GAAG,CAAC,EAAY,OACxE,IAAM,EAAU,EAAY,aAAa,QAAQ,EAAE,GAAS,EAAQ,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