{"version":3,"file":"MarkdownRenderer.BbSegMs3.mjs","names":["useMemo","lines"],"sources":["https:/framerusercontent.com/modules/kBb63WBlDalBlRYERtFj/Bkt7M486RKb2ACBhon09/MarkdownRenderer.js"],"sourcesContent":["// Markdown renderer component with configurable base font size and accent color\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function MarkdownRenderer(props){const{content=\"# Markdown Renderer\",baseFontSize=16,accentColor=\"#0099FF\",textColor=\"#000\",secondaryColor=\"#000\",font,headingFontWeight=600,strongFontWeight=600}=props;const parsedContent=useMemo(()=>{const html=parseMarkdown(content);return html;},[content]);const containerStyles={...props.style,color:textColor,lineHeight:\"1.6\",...font,fontSize:`${baseFontSize}px`,width:\"100%\",minHeight:\"100%\",boxSizing:\"border-box\"};const dynamicStyles=`\n        <style for=\"markdown-renderer\">\n            .markdown-renderer > style[for=markdown-renderer] + * {\n                margin-top: 0;\n            }\n            .markdown-renderer h1 {\n                font-size: 1.5em;\n                line-height: 135%;\n                margin: 1em 0;\n                font-weight: ${headingFontWeight};\n            }\n            .markdown-renderer h2 {\n                font-size: 1.35em;\n                line-height: 135%;\n                margin: 1em 0;\n                font-weight: ${headingFontWeight};\n            }\n            .markdown-renderer h3 {\n                font-size: 1.2em;\n                line-height: 135%;\n                margin: 1em 0;\n                font-weight: ${headingFontWeight};\n            }\n            .markdown-renderer h4 {\n                font-size: 1em;\n                line-height: 135%;\n                margin: 1em 0;\n                font-weight: ${headingFontWeight};\n            }\n            .markdown-renderer h5 {\n                font-size: 1em;\n                line-height: 135%;\n                margin: 1em 0;\n                font-weight: ${headingFontWeight};\n            }\n            .markdown-renderer h6 {\n                font-size: 0.875em;\n                line-height: 135%;\n                margin: 1em 0;\n                font-weight: ${headingFontWeight};\n            }\n            .markdown-renderer p {\n                margin: 1em 0;\n                color: ${secondaryColor};\n            }\n            .markdown-renderer a {\n                color: ${accentColor};\n                text-decoration: none;\n            }\n            .markdown-renderer a:hover {\n                color: ${accentColor};\n                opacity: 0.8;\n            }\n            .markdown-renderer a strong {\n                color: inherit;\n            }\n            .markdown-renderer strong {\n                font-weight: ${strongFontWeight};\n            }\n            .markdown-renderer em {\n                font-style: italic;\n            }\n            .markdown-renderer pre {\n                background: #f5f5f5;\n                padding: 1em;\n                border-radius: 4px;\n                margin: 1em 0;\n                overflow-x: auto;\n                border-left: 4px solid ${accentColor};\n            }\n            .markdown-renderer code {\n                font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n                font-size: 0.875em;\n            }\n            .markdown-renderer pre code {\n                background: none;\n                padding: 0;\n                border-radius: 0;\n            }\n            .markdown-renderer code:not(pre code) {\n                background: #f5f5f5;\n                padding: 2px 4px;\n                border-radius: 3px;\n            }\n            .markdown-renderer blockquote {\n                border-left: 4px solid ${accentColor};\n                margin: 1em 0;\n                padding: 1em;\n                font-style: italic;\n                background: #f9f9f9;\n            }\n            .markdown-renderer ul, .markdown-renderer ol {\n                margin: 1em 0;\n                padding-left: 1.5em;\n            }\n            .markdown-renderer ol {\n                list-style-type: decimal;\n                counter-reset: item;\n            }\n            .markdown-renderer ol li {\n                display: list-item;\n            }\n            .markdown-renderer li {\n                margin: 0.25em 0;\n            }\n        </style>\n    `;return /*#__PURE__*/_jsx(\"div\",{style:containerStyles,className:\"markdown-renderer\",dangerouslySetInnerHTML:{__html:dynamicStyles+parsedContent}});}function parseMarkdown(markdown){if(!markdown)return\"\";let html=markdown;// Code blocks (must be processed before inline code)\nhtml=html.replace(/```([\\s\\S]*?)```/g,\"<pre><code>$1</code></pre>\");// Inline code (after code blocks, but avoid code inside pre tags)\nhtml=html.replace(/`([^`\\n]+)`/g,\"<code>$1</code>\");// Bold (process before italic to avoid conflicts)\nhtml=html.replace(/\\*\\*([^*\\n]+)\\*\\*/g,\"<strong>$1</strong>\");html=html.replace(/__([^_\\n]+)__/g,\"<strong>$1</strong>\");// Italic\nhtml=html.replace(/\\*([^*\\n]+)\\*/g,\"<em>$1</em>\");html=html.replace(/_([^_\\n]+)_/g,\"<em>$1</em>\");// Links - process BEFORE headers so links in headers work correctly\n// More specific pattern: only match if parentheses contain something that looks like a URL\nhtml=html.replace(/\\[([^\\]\\n]+)\\]\\(((?:https?:\\/\\/|www\\.|\\/)[^\\s)\\n]+)\\)/g,'<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>');// Auto-detect plain URLs (after Markdown links to avoid double-processing)\n// Match URLs starting with http://, https://, or www.\nhtml=html.replace(RegExp('(?<!href=\"|\">)(https?:\\\\/\\\\/[^\\\\s<]+|www\\\\.[^\\\\s<]+)',\"g\"),match=>{const href=match.startsWith(\"www.\")?`https://${match}`:match;return`<a href=\"${href}\" target=\"_blank\" rel=\"noopener noreferrer\">${match}</a>`;});// Headers (process from most specific to least specific) - improved patterns\nhtml=html.replace(/^######\\s+(.+?)$/gm,\"<h6>$1</h6>\");html=html.replace(/^#####\\s+(.+?)$/gm,\"<h5>$1</h5>\");html=html.replace(/^####\\s+(.+?)$/gm,\"<h4>$1</h4>\");html=html.replace(/^###\\s+(.+?)$/gm,\"<h3>$1</h3>\");html=html.replace(/^##\\s+(.+?)$/gm,\"<h2>$1</h2>\");html=html.replace(/^#\\s+(.+?)$/gm,\"<h1>$1</h1>\");// Blockquotes\nhtml=html.replace(/^>\\s+(.+)$/gm,\"<blockquote>$1</blockquote>\");// Process lists with proper nesting support\nconst lines=html.split(\"\\n\");const result=[];let i=0;while(i<lines.length){const line=lines[i];const trimmed=line.trim();// Check if this line starts a list\nif(trimmed.match(/^[-*+] /)||trimmed.match(/^\\d+\\. /)){const{html:listHtml,nextIndex}=parseList(lines,i);result.push(listHtml);i=nextIndex;}else{result.push(line);i++;}}html=result.join(\"\\n\");// Handle paragraphs - split by double newlines and wrap non-block elements\nconst blocks=html.split(/\\n\\s*\\n/);const processedBlocks=blocks.map(block=>{const trimmed=block.trim();if(!trimmed)return\"\";// Check if this is a block-level element (don't wrap in <p>)\nconst isBlockElement=/^<(h[1-6]|ul|ol|li|blockquote|pre|div|style|table|tr|td|th|thead|tbody)[\\s>]/i.test(trimmed);if(isBlockElement){return trimmed;}// Don't wrap if it contains list elements\nif(trimmed.includes(\"<li>\")||trimmed.includes(\"<ul>\")||trimmed.includes(\"<ol>\")){return trimmed;}// Split into lines and check each line\nconst lines=trimmed.split(\"\\n\").filter(line=>line.trim());if(lines.length===0)return\"\";// Process each line individually\nconst processedLines=[];for(const line of lines){const lineTrimmed=line.trim();// Check if this specific line is a block element\nif(/^<(h[1-6]|ul|ol|li|blockquote|pre|div|style)[\\s>]/i.test(lineTrimmed)){processedLines.push(lineTrimmed);}else{// This is regular text, wrap in paragraph\nprocessedLines.push(`<p>${lineTrimmed}</p>`);}}return processedLines.join(\"\\n\");});return processedBlocks.filter(block=>block).join(\"\\n\\n\");}function parseList(lines,startIndex){let currentIndex=startIndex;const result=[];let currentListType=null;let currentIndent=-1;while(currentIndex<lines.length){const line=lines[currentIndex];const trimmed=line.trim();// Calculate indentation\nconst indentMatch=line.match(/^(\\s*)/);const indent=indentMatch?indentMatch[1].length:0;// Check for list items\nconst unorderedMatch=trimmed.match(/^[-*+] (.+)$/);const orderedMatch=trimmed.match(/^\\d+\\. (.+)$/);if(!unorderedMatch&&!orderedMatch){break;}const isUnordered=!!unorderedMatch;const listType=isUnordered?\"ul\":\"ol\";const content=isUnordered?unorderedMatch[1]:orderedMatch[1];// Start new list if this is the first item or different type\nif(currentListType===null){result.push(`<${listType}>`);currentListType=listType;currentIndent=indent;}else if(currentListType!==listType){// Close previous list and start new one\nresult.push(`</${currentListType}>`);result.push(`<${listType}>`);currentListType=listType;currentIndent=indent;}// Add list item\nresult.push(`<li>${content}</li>`);currentIndex++;}// Close the list\nif(currentListType){result.push(`</${currentListType}>`);}return{html:result.join(\"\\n\"),nextIndex:currentIndex};}addPropertyControls(MarkdownRenderer,{content:{type:ControlType.String,title:\"Markdown Content\",defaultValue:\"# Hello World\",displayTextArea:true},baseFontSize:{type:ControlType.Number,title:\"Base Size\",defaultValue:16,min:10,max:24,step:1,unit:\"px\"},textColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000\"},secondaryColor:{type:ControlType.Color,title:\"Secondary\",defaultValue:\"#000\"},accentColor:{type:ControlType.Color,title:\"Accent\",defaultValue:\"#0099FF\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"16px\",variant:\"Regular\",letterSpacing:\"-0.02em\",lineHeight:\"1.6em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},headingFontWeight:{type:ControlType.Number,title:\"Heading Weight\",defaultValue:600,min:100,max:900,step:100},strongFontWeight:{type:ControlType.Number,title:\"Strong Weight\",defaultValue:600,min:100,max:900,step:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MarkdownRenderer\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MarkdownRenderer.map"],"mappings":"sKAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,UAAQ,sBAAsB,eAAa,GAAG,cAAY,UAAU,YAAU,OAAO,iBAAe,OAAO,OAAK,oBAAkB,IAAI,mBAAiB,KAAK,EAAY,EAAcA,MAAwB,EAAc,EAAQ,CAAe,CAAC,EAAQ,CAAC,CA0GhT,OAAoB,EAAK,MAAM,CAAC,MA1GuS,CAAC,GAAG,EAAM,MAAM,MAAM,EAAU,WAAW,MAAM,GAAG,EAAK,SAAS,GAAG,EAAa,IAAI,MAAM,OAAO,UAAU,OAAO,UAAU,aAAa,CA0G5Z,UAAU,oBAAoB,wBAAwB,CAAC,OA1G0X;;;;;;;;;+BAS9c,EAAkB;;;;;;+BAMlB,EAAkB;;;;;;+BAMlB,EAAkB;;;;;;+BAMl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