{"version":3,"file":"Markdown_table_cms.CDDCvLln.mjs","names":["React.useCallback"],"sources":["https:/framerusercontent.com/modules/OUq9x5j8Ze0f5NF8as9v/vyQugADwxExvjjKlCttV/Markdown_table_cms.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:\"#f0f0f0\"});export function TableOverride(Component){return props=>{const[store]=useStore();const extractAndFormatTable=React.useCallback(()=>{const contentDivs=document.querySelectorAll('[data-framer-name=\"Content\"][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=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                        `;// 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{while(cells.length<3){cells.push(\"\");}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                                background-color: ${cssVars[`--cb-colors-surface1-${colorScheme}`]};\n                                border-right: 1px solid ${borderColor};\n                                border-bottom: 1px solid ${borderColor};\n                            }\n                            table th {\n                                font-weight: bold;\n                                color: ${cssVars[`--cb-syntax-color-plain-${colorScheme}`]};\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=\"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 and set opacity to 1\nconst style=document.createElement(\"style\");style.textContent=`\n                [data-framer-name=\"Content\"][data-framer-component-type=\"RichTextContainer\"] {\n                    white-space: normal !important;\n                    opacity: 1 !important;\n                }\n                [data-framer-name=\"Content\"][data-framer-component-type=\"RichTextContainer\"] > div {\n                    white-space: normal !important;\n                    opacity: 1 !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=./Markdown_table_cms.map"],"mappings":"8RAA+L,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,GAAO,GAAU,CAAO,EAAsBA,MAAsB,CAAmB,SAAS,iBAAiB,+EAA+E,CAAa,QAAQ,GAAY,CAAkB,EAAW,iBAAiB,kCAAkC,CAAY,QAAQ,GAAW,CAAC,GAAG,aAAqB,YAAY,CAClnB,IAAM,EAAY,EAAU,cAAc,aAAa,CAAC,GAAG,CAAC,EAAY,OACxE,IAAM,EAAU,EAAY,aAAa,QAAQ,EAAE,GAAS,EAAQ,EAAE,CAAC,EAAU,MAAM,IAAI,CAAC,QAAQ,GAAM,CAAC,GAAK,CAAC,EAAI,GAAO,EAAK,MAAM,IAAI,CAAC,IAAI,GAAG,EAAE,MAAM,CAAC,CAAI,EAAI,WAAW,KA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