@remyxjs/react 1.0.0-beta → 1.0.4-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/{AttachmentModal-D-uxbXvb.cjs → AttachmentModal-BDFFiZJt.cjs} +2 -2
  2. package/dist/{AttachmentModal-D-uxbXvb.cjs.map → AttachmentModal-BDFFiZJt.cjs.map} +1 -1
  3. package/dist/{AttachmentModal--6T-vYJt.js → AttachmentModal-Di5V6QX-.js} +2 -2
  4. package/dist/{AttachmentModal--6T-vYJt.js.map → AttachmentModal-Di5V6QX-.js.map} +1 -1
  5. package/dist/{ContextMenu-B4K3Zbfp.cjs → ContextMenu-BafbP2Uh.cjs} +2 -2
  6. package/dist/{ContextMenu-B4K3Zbfp.cjs.map → ContextMenu-BafbP2Uh.cjs.map} +1 -1
  7. package/dist/{ContextMenu-D8wNSMc3.js → ContextMenu-DsA0YsY7.js} +2 -2
  8. package/dist/{ContextMenu-D8wNSMc3.js.map → ContextMenu-DsA0YsY7.js.map} +1 -1
  9. package/dist/{EmbedModal-Bh2Tcow9.cjs → EmbedModal-C73lODIT.cjs} +2 -2
  10. package/dist/{EmbedModal-Bh2Tcow9.cjs.map → EmbedModal-C73lODIT.cjs.map} +1 -1
  11. package/dist/{EmbedModal-cxE4maD2.js → EmbedModal-alpHQiAP.js} +2 -2
  12. package/dist/{EmbedModal-cxE4maD2.js.map → EmbedModal-alpHQiAP.js.map} +1 -1
  13. package/dist/{ExportModal-Cf1uE4r_.js → ExportModal-BN8LUaSR.js} +2 -2
  14. package/dist/{ExportModal-Cf1uE4r_.js.map → ExportModal-BN8LUaSR.js.map} +1 -1
  15. package/dist/{ExportModal-DwQVsrZE.cjs → ExportModal-Cu-cCwa6.cjs} +2 -2
  16. package/dist/{ExportModal-DwQVsrZE.cjs.map → ExportModal-Cu-cCwa6.cjs.map} +1 -1
  17. package/dist/{FindReplaceModal-Dgt_MrWb.js → FindReplaceModal-BqNcotUr.js} +2 -2
  18. package/dist/{FindReplaceModal-Dgt_MrWb.js.map → FindReplaceModal-BqNcotUr.js.map} +1 -1
  19. package/dist/{FindReplaceModal-DYL_2z8U.cjs → FindReplaceModal-DgysYT04.cjs} +2 -2
  20. package/dist/{FindReplaceModal-DYL_2z8U.cjs.map → FindReplaceModal-DgysYT04.cjs.map} +1 -1
  21. package/dist/{ImageModal-D39ywxqI.cjs → ImageModal-BzgYXY9y.cjs} +2 -2
  22. package/dist/{ImageModal-D39ywxqI.cjs.map → ImageModal-BzgYXY9y.cjs.map} +1 -1
  23. package/dist/{ImageModal-DqScpPrc.js → ImageModal-bCzSSTmd.js} +2 -2
  24. package/dist/{ImageModal-DqScpPrc.js.map → ImageModal-bCzSSTmd.js.map} +1 -1
  25. package/dist/{ImportDocumentModal-BKqMxO3z.js → ImportDocumentModal-BypTEn2i.js} +4 -4
  26. package/dist/{ImportDocumentModal-BKqMxO3z.js.map → ImportDocumentModal-BypTEn2i.js.map} +1 -1
  27. package/dist/{ImportDocumentModal-Bev9hp_J.cjs → ImportDocumentModal-gCFept9p.cjs} +2 -2
  28. package/dist/{ImportDocumentModal-Bev9hp_J.cjs.map → ImportDocumentModal-gCFept9p.cjs.map} +1 -1
  29. package/dist/{LinkModal-k9IeDtAb.js → LinkModal-CmkK4m-k.js} +3 -3
  30. package/dist/{LinkModal-k9IeDtAb.js.map → LinkModal-CmkK4m-k.js.map} +1 -1
  31. package/dist/{LinkModal-B-igSa-g.cjs → LinkModal-DPxg7YCE.cjs} +2 -2
  32. package/dist/{LinkModal-B-igSa-g.cjs.map → LinkModal-DPxg7YCE.cjs.map} +1 -1
  33. package/dist/{MenuBar-DWxJNHmb.js → MenuBar-DOv7JPwR.js} +2 -2
  34. package/dist/{MenuBar-DWxJNHmb.js.map → MenuBar-DOv7JPwR.js.map} +1 -1
  35. package/dist/{MenuBar-B-ZAX9rH.cjs → MenuBar-Lw_5Jp8u.cjs} +2 -2
  36. package/dist/{MenuBar-B-ZAX9rH.cjs.map → MenuBar-Lw_5Jp8u.cjs.map} +1 -1
  37. package/dist/{ModalOverlay-BDsGgv3_.cjs → ModalOverlay-Dh5quv7X.cjs} +2 -2
  38. package/dist/{ModalOverlay-BDsGgv3_.cjs.map → ModalOverlay-Dh5quv7X.cjs.map} +1 -1
  39. package/dist/{ModalOverlay-CLvRNHmp.js → ModalOverlay-Dt0JiW3M.js} +2 -2
  40. package/dist/{ModalOverlay-CLvRNHmp.js.map → ModalOverlay-Dt0JiW3M.js.map} +1 -1
  41. package/dist/{SourceModal-BNI_i4iW.cjs → SourceModal-CHKC5xcv.cjs} +2 -2
  42. package/dist/{SourceModal-BNI_i4iW.cjs.map → SourceModal-CHKC5xcv.cjs.map} +1 -1
  43. package/dist/{SourceModal-MdTGK3Uf.js → SourceModal-ChhNVz7y.js} +2 -2
  44. package/dist/{SourceModal-MdTGK3Uf.js.map → SourceModal-ChhNVz7y.js.map} +1 -1
  45. package/dist/{TablePickerModal-DYODWEA1.js → TablePickerModal-BnZHyMsk.js} +2 -2
  46. package/dist/{TablePickerModal-DYODWEA1.js.map → TablePickerModal-BnZHyMsk.js.map} +1 -1
  47. package/dist/{TablePickerModal-Do1QyoyM.cjs → TablePickerModal-Dr0wUx_h.cjs} +2 -2
  48. package/dist/{TablePickerModal-Do1QyoyM.cjs.map → TablePickerModal-Dr0wUx_h.cjs.map} +1 -1
  49. package/dist/index-Bg_uAWlM.js +3 -0
  50. package/dist/index-Bg_uAWlM.js.map +1 -0
  51. package/dist/index-DL-qBZZU.js +357 -0
  52. package/dist/index-DL-qBZZU.js.map +1 -0
  53. package/dist/index-OfJxpaev.cjs +2 -0
  54. package/dist/index-OfJxpaev.cjs.map +1 -0
  55. package/dist/index-qh1Yzh-l.cjs +2 -0
  56. package/dist/index-qh1Yzh-l.cjs.map +1 -0
  57. package/dist/remyx-react.cjs +1 -1
  58. package/dist/remyx-react.css +1 -1
  59. package/dist/remyx-react.js +1 -1
  60. package/package.json +3 -3
  61. package/dist/index-C720tbJA.js +0 -359
  62. package/dist/index-C720tbJA.js.map +0 -1
  63. package/dist/index-Dc63uIP0.cjs +0 -2
  64. package/dist/index-Dc63uIP0.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SourceModal-MdTGK3Uf.js","sources":["../src/components/Modals/CodeEditor/highlightHTML.js","../src/components/Modals/CodeEditor/highlightMarkdown.js","../src/components/Modals/CodeEditor/CodeEditor.jsx","../src/components/Modals/SourceModal.jsx"],"sourcesContent":["/**\n * Lightweight HTML tokenizer for syntax highlighting.\n * Returns an array of { text, className } tokens.\n */\nexport function highlightHTML(code) {\n const tokens = []\n let i = 0\n const len = code.length\n\n while (i < len) {\n // Comment: <!-- ... -->\n if (code[i] === '<' && code.startsWith('!--', i + 1)) {\n const end = code.indexOf('-->', i + 4)\n const commentEnd = end === -1 ? len : end + 3\n tokens.push({ text: code.slice(i, commentEnd), className: 'rmx-syn-comment' })\n i = commentEnd\n continue\n }\n\n // Doctype: <!DOCTYPE ...>\n if (code[i] === '<' && code.startsWith('!', i + 1) && /^<![a-zA-Z]/.test(code.slice(i, i + 3))) {\n const end = code.indexOf('>', i)\n const doctypeEnd = end === -1 ? len : end + 1\n tokens.push({ text: code.slice(i, doctypeEnd), className: 'rmx-syn-doctype' })\n i = doctypeEnd\n continue\n }\n\n // Tag: < ... >\n if (code[i] === '<' && (code[i + 1] === '/' || /[a-zA-Z]/.test(code[i + 1] || ''))) {\n i = parseTag(code, i, tokens)\n continue\n }\n\n // Entity: &...;\n if (code[i] === '&') {\n const semi = code.indexOf(';', i + 1)\n if (semi !== -1 && semi - i < 12 && /^&[#a-zA-Z0-9]+;$/.test(code.slice(i, semi + 1))) {\n tokens.push({ text: code.slice(i, semi + 1), className: 'rmx-syn-entity' })\n i = semi + 1\n continue\n }\n }\n\n // Plain text until next < or &\n let textEnd = i + 1\n while (textEnd < len && code[textEnd] !== '<' && code[textEnd] !== '&') {\n textEnd++\n }\n tokens.push({ text: code.slice(i, textEnd), className: null })\n i = textEnd\n }\n\n return tokens\n}\n\n/**\n * Parse an HTML tag starting at position i, pushing tokens.\n * Returns the new position after the tag.\n */\nfunction parseTag(code, i, tokens) {\n const len = code.length\n\n // Opening: < or </\n if (code[i + 1] === '/') {\n tokens.push({ text: '</', className: 'rmx-syn-tag' })\n i += 2\n } else {\n tokens.push({ text: '<', className: 'rmx-syn-tag' })\n i += 1\n }\n\n // Tag name\n let nameStart = i\n while (i < len && /[a-zA-Z0-9:-]/.test(code[i])) i++\n if (i > nameStart) {\n tokens.push({ text: code.slice(nameStart, i), className: 'rmx-syn-tag' })\n }\n\n // Attributes and closing\n while (i < len) {\n // Skip whitespace\n if (/\\s/.test(code[i])) {\n let wsStart = i\n while (i < len && /\\s/.test(code[i])) i++\n tokens.push({ text: code.slice(wsStart, i), className: null })\n continue\n }\n\n // Self-close or close: />, >\n if (code[i] === '/' && code[i + 1] === '>') {\n tokens.push({ text: '/>', className: 'rmx-syn-tag' })\n return i + 2\n }\n if (code[i] === '>') {\n tokens.push({ text: '>', className: 'rmx-syn-tag' })\n return i + 1\n }\n\n // Attribute name\n let attrStart = i\n while (i < len && /[^\\s=/>]/.test(code[i])) i++\n if (i > attrStart) {\n tokens.push({ text: code.slice(attrStart, i), className: 'rmx-syn-attr-name' })\n }\n\n // Skip whitespace around =\n while (i < len && /\\s/.test(code[i])) {\n tokens.push({ text: code[i], className: null })\n i++\n }\n\n // = sign\n if (i < len && code[i] === '=') {\n tokens.push({ text: '=', className: null })\n i++\n\n // Skip whitespace after =\n while (i < len && /\\s/.test(code[i])) {\n tokens.push({ text: code[i], className: null })\n i++\n }\n\n // Attribute value\n if (i < len && (code[i] === '\"' || code[i] === \"'\")) {\n const quote = code[i]\n const valEnd = code.indexOf(quote, i + 1)\n const end = valEnd === -1 ? len : valEnd + 1\n tokens.push({ text: code.slice(i, end), className: 'rmx-syn-attr-value' })\n i = end\n } else {\n // Unquoted value\n let valStart = i\n while (i < len && /[^\\s>]/.test(code[i])) i++\n if (i > valStart) {\n tokens.push({ text: code.slice(valStart, i), className: 'rmx-syn-attr-value' })\n }\n }\n }\n }\n\n return i\n}\n","/**\n * Lightweight Markdown tokenizer for syntax highlighting.\n * Operates line-by-line since Markdown is line-oriented.\n * Returns an array of { text, className } tokens.\n */\nexport function highlightMarkdown(code) {\n const lines = code.split('\\n')\n const tokens = []\n let inCodeBlock = false\n\n for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {\n const line = lines[lineIdx]\n\n // Add newline between lines (not before the first)\n if (lineIdx > 0) {\n tokens.push({ text: '\\n', className: null })\n }\n\n // Code fence toggle: ```\n if (/^```/.test(line.trimStart())) {\n tokens.push({ text: line, className: 'rmx-syn-code-fence' })\n inCodeBlock = !inCodeBlock\n continue\n }\n\n // Inside code block — all code\n if (inCodeBlock) {\n tokens.push({ text: line, className: 'rmx-syn-code' })\n continue\n }\n\n // Heading: # ... ######\n if (/^#{1,6}\\s/.test(line)) {\n tokens.push({ text: line, className: 'rmx-syn-heading' })\n continue\n }\n\n // Horizontal rule: ---, ***, ___\n if (/^(\\s*)([-*_])\\2{2,}\\s*$/.test(line)) {\n tokens.push({ text: line, className: 'rmx-syn-hr' })\n continue\n }\n\n // Blockquote: > text\n if (/^>\\s?/.test(line)) {\n const markerMatch = line.match(/^(>\\s?)/)\n tokens.push({ text: markerMatch[0], className: 'rmx-syn-blockquote' })\n highlightInline(line.slice(markerMatch[0].length), tokens)\n continue\n }\n\n // Unordered list: - item, * item, + item\n const ulMatch = line.match(/^(\\s*[-*+]\\s+)/)\n if (ulMatch) {\n tokens.push({ text: ulMatch[0], className: 'rmx-syn-list-marker' })\n highlightInline(line.slice(ulMatch[0].length), tokens)\n continue\n }\n\n // Ordered list: 1. item, 2) item\n const olMatch = line.match(/^(\\s*\\d+[.)]\\s+)/)\n if (olMatch) {\n tokens.push({ text: olMatch[0], className: 'rmx-syn-list-marker' })\n highlightInline(line.slice(olMatch[0].length), tokens)\n continue\n }\n\n // Table separator: |---|---|\n if (/^\\|[\\s:|-]+\\|$/.test(line.trim())) {\n tokens.push({ text: line, className: 'rmx-syn-hr' })\n continue\n }\n\n // Regular line — process inline formatting\n highlightInline(line, tokens)\n }\n\n return tokens\n}\n\n/**\n * Tokenize inline Markdown formatting within a line.\n * Handles: bold, italic, inline code, links, images.\n */\nfunction highlightInline(text, tokens) {\n let i = 0\n const len = text.length\n let plainStart = 0\n\n while (i < len) {\n // Inline code: `code`\n if (text[i] === '`') {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n const end = text.indexOf('`', i + 1)\n if (end !== -1) {\n tokens.push({ text: text.slice(i, end + 1), className: 'rmx-syn-code' })\n i = end + 1\n plainStart = i\n continue\n }\n }\n\n // Image: ![alt](url)\n if (text[i] === '!' && text[i + 1] === '[') {\n const closeBracket = text.indexOf(']', i + 2)\n if (closeBracket !== -1 && text[closeBracket + 1] === '(') {\n const closeParen = text.indexOf(')', closeBracket + 2)\n if (closeParen !== -1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n tokens.push({ text: text.slice(i, closeParen + 1), className: 'rmx-syn-image' })\n i = closeParen + 1\n plainStart = i\n continue\n }\n }\n }\n\n // Link: [text](url)\n if (text[i] === '[') {\n const closeBracket = text.indexOf(']', i + 1)\n if (closeBracket !== -1 && text[closeBracket + 1] === '(') {\n const closeParen = text.indexOf(')', closeBracket + 2)\n if (closeParen !== -1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n // [text]\n tokens.push({ text: text.slice(i, closeBracket + 1), className: 'rmx-syn-link' })\n // (url)\n tokens.push({ text: text.slice(closeBracket + 1, closeParen + 1), className: 'rmx-syn-url' })\n i = closeParen + 1\n plainStart = i\n continue\n }\n }\n }\n\n // Bold: **text** or __text__\n if ((text[i] === '*' && text[i + 1] === '*') || (text[i] === '_' && text[i + 1] === '_')) {\n const marker = text.slice(i, i + 2)\n const end = text.indexOf(marker, i + 2)\n if (end !== -1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n tokens.push({ text: text.slice(i, end + 2), className: 'rmx-syn-bold' })\n i = end + 2\n plainStart = i\n continue\n }\n }\n\n // Italic: *text* or _text_ (single, not preceded/followed by same)\n if ((text[i] === '*' || text[i] === '_') && text[i + 1] !== text[i]) {\n const marker = text[i]\n const end = text.indexOf(marker, i + 1)\n if (end !== -1 && end > i + 1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n tokens.push({ text: text.slice(i, end + 1), className: 'rmx-syn-italic' })\n i = end + 1\n plainStart = i\n continue\n }\n }\n\n i++\n }\n\n // Remaining plain text\n if (plainStart < len) {\n tokens.push({ text: text.slice(plainStart), className: null })\n }\n}\n","import { useRef, useMemo, useCallback, useState, useEffect } from 'react'\nimport { highlightHTML } from './highlightHTML.js'\nimport { highlightMarkdown } from './highlightMarkdown.js'\nimport './CodeEditor.css'\n\nconst HIGHLIGHT_DEBOUNCE_MS = 150\n\nexport function CodeEditor({ value, onChange, language = 'html' }) {\n const textareaRef = useRef(null)\n const preRef = useRef(null)\n const gutterRef = useRef(null)\n const highlightTimerRef = useRef(null)\n\n // Debounced value for highlighting — delays expensive tokenization\n const [debouncedValue, setDebouncedValue] = useState(value || '')\n\n useEffect(() => {\n highlightTimerRef.current = setTimeout(() => {\n setDebouncedValue(value || '')\n }, HIGHLIGHT_DEBOUNCE_MS)\n return () => clearTimeout(highlightTimerRef.current)\n }, [value])\n\n // Tokenize the debounced source for highlighting\n const highlighted = useMemo(() => {\n const highlighter = language === 'markdown' ? highlightMarkdown : highlightHTML\n return highlighter(debouncedValue)\n }, [debouncedValue, language])\n\n // Count lines for the gutter\n const lineCount = useMemo(() => {\n return (value || '').split('\\n').length\n }, [value])\n\n // Sync scroll between textarea, pre, and gutter\n const handleScroll = useCallback(() => {\n const ta = textareaRef.current\n if (!ta) return\n if (preRef.current) {\n preRef.current.scrollTop = ta.scrollTop\n preRef.current.scrollLeft = ta.scrollLeft\n }\n if (gutterRef.current) {\n gutterRef.current.scrollTop = ta.scrollTop\n }\n }, [])\n\n // Tab key inserts 2 spaces\n const handleKeyDown = useCallback((e) => {\n if (e.key === 'Tab') {\n e.preventDefault()\n const ta = e.target\n const start = ta.selectionStart\n const end = ta.selectionEnd\n // Use setRangeText to insert text while preserving undo stack\n if (typeof ta.setRangeText === 'function') {\n ta.setRangeText(' ', start, end, 'end')\n ta.dispatchEvent(new Event('input', { bubbles: true }))\n } else {\n const newValue = value.substring(0, start) + ' ' + value.substring(end)\n onChange(newValue)\n requestAnimationFrame(() => {\n ta.selectionStart = ta.selectionEnd = start + 2\n })\n }\n }\n }, [value, onChange])\n\n return (\n <div className=\"rmx-code-editor\">\n {/* Line number gutter */}\n <div ref={gutterRef} className=\"rmx-code-gutter\" aria-hidden=\"true\">\n {Array.from({ length: lineCount }, (_, i) => (\n <div key={i} className=\"rmx-code-line-number\">{i + 1}</div>\n ))}\n </div>\n\n {/* Editor body: highlighted pre + transparent textarea */}\n <div className=\"rmx-code-body\">\n <pre ref={preRef} className=\"rmx-code-highlight\" aria-hidden=\"true\">\n <code>\n {highlighted.map((token, i) =>\n token.className\n ? <span key={i} className={token.className}>{token.text}</span>\n : token.text\n )}\n {'\\n'}\n </code>\n </pre>\n\n <textarea\n ref={textareaRef}\n className=\"rmx-code-input\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onScroll={handleScroll}\n onKeyDown={handleKeyDown}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n data-gramm=\"false\"\n />\n </div>\n </div>\n )\n}\n","import { useState, useEffect, useRef, useCallback } from 'react'\nimport PropTypes from 'prop-types'\nimport { ModalOverlay } from './ModalOverlay.jsx'\nimport { CodeEditor } from './CodeEditor/CodeEditor.jsx'\nimport { htmlToMarkdown, markdownToHtml, formatHTML } from '@remyxjs/core'\n\nexport function SourceModal({ open, onClose, engine }) {\n const [source, setSource] = useState('')\n const [initialSource, setInitialSource] = useState('')\n const isMarkdown = engine?.outputFormat === 'markdown'\n\n useEffect(() => {\n if (open && engine) {\n const html = engine.getHTML()\n const formatted = isMarkdown ? htmlToMarkdown(html) : formatHTML(html)\n setSource(formatted)\n setInitialSource(formatted)\n }\n }, [open, engine, isMarkdown])\n\n const handleApply = () => {\n engine.history.snapshot()\n const rawHtml = isMarkdown ? markdownToHtml(source) : source\n // Re-sanitize user-edited HTML to prevent XSS injection via source mode\n const htmlToApply = engine.sanitizer.sanitize(rawHtml)\n // Notify if sanitizer modified the input (unsafe content was stripped)\n if (htmlToApply !== rawHtml) {\n engine.eventBus.emit('source:sanitized', {\n message: 'Some HTML elements or attributes were removed for security.',\n })\n }\n engine.setHTML(htmlToApply)\n engine.eventBus.emit('content:change')\n onClose()\n }\n\n // #33: Confirm before discarding unsaved changes\n const handleClose = useCallback(() => {\n if (source !== initialSource) {\n const confirmed = window.confirm('You have unsaved changes. Discard them?')\n if (!confirmed) return\n }\n onClose()\n }, [source, initialSource, onClose])\n\n return (\n <ModalOverlay title={isMarkdown ? 'Markdown Source' : 'Source Code'} open={open} onClose={handleClose} width={750}>\n <div className=\"rmx-modal-form\">\n <CodeEditor\n value={source}\n onChange={setSource}\n language={isMarkdown ? 'markdown' : 'html'}\n />\n <div className=\"rmx-modal-actions\">\n <button type=\"button\" className=\"rmx-btn\" onClick={handleClose}>Cancel</button>\n <button type=\"button\" className=\"rmx-btn rmx-btn-primary\" onClick={handleApply}>Apply</button>\n </div>\n </div>\n </ModalOverlay>\n )\n}\n\nSourceModal.propTypes = {\n open: PropTypes.bool.isRequired,\n onClose: PropTypes.func.isRequired,\n engine: PropTypes.object,\n}\n"],"names":["highlightHTML","code","tokens","i","len","length","startsWith","end","indexOf","commentEnd","push","text","slice","className","test","doctypeEnd","parseTag","semi","textEnd","nameStart","wsStart","attrStart","quote","valEnd","valStart","highlightMarkdown","lines","split","inCodeBlock","lineIdx","line","trimStart","markerMatch","match","highlightInline","ulMatch","olMatch","trim","plainStart","closeBracket","closeParen","marker","CodeEditor","value","onChange","language","textareaRef","useRef","preRef","gutterRef","highlightTimerRef","debouncedValue","setDebouncedValue","useState","useEffect","current","setTimeout","clearTimeout","highlighted","useMemo","lineCount","handleScroll","useCallback","ta","scrollTop","scrollLeft","handleKeyDown","e","key","preventDefault","target","start","selectionStart","selectionEnd","setRangeText","dispatchEvent","Event","bubbles","newValue","substring","requestAnimationFrame","jsxs","children","jsx","ref","Array","from","_","map","token","onScroll","onKeyDown","spellCheck","autoCapitalize","autoComplete","autoCorrect","SourceModal","open","onClose","engine","source","setSource","initialSource","setInitialSource","isMarkdown","outputFormat","html","getHTML","formatted","htmlToMarkdown","formatHTML","handleClose","window","confirm","ModalOverlay","title","width","type","onClick","history","snapshot","rawHtml","markdownToHtml","htmlToApply","sanitizer","sanitize","eventBus","emit","message","setHTML","propTypes","PropTypes","bool","isRequired","func","object"],"mappings":"sTAIO,SAASA,EAAcC,GAC5B,MAAMC,EAAS,GACf,IAAIC,EAAI,EACR,MAAMC,EAAMH,EAAKI,OAEjB,KAAOF,EAAIC,GAAK,CAEd,GAAgB,MAAZH,EAAKE,IAAcF,EAAKK,WAAW,MAAOH,EAAI,GAAI,CACpD,MAAMI,EAAMN,EAAKO,QAAQ,SAAOL,EAAI,GAC9BM,GAAqB,IAARF,EAAaH,EAAMG,EAAM,EAC5CL,EAAOQ,KAAK,CAAEC,KAAMV,EAAKW,MAAMT,EAAGM,GAAaI,UAAW,oBAC1DV,EAAIM,EACJ,QACF,CAGA,GAAgB,MAAZR,EAAKE,IAAcF,EAAKK,WAAW,IAAKH,EAAI,IAAM,cAAcW,KAAKb,EAAKW,MAAMT,EAAGA,EAAI,IAAK,CAC9F,MAAMI,EAAMN,EAAKO,QAAQ,IAAKL,GACxBY,GAAqB,IAARR,EAAaH,EAAMG,EAAM,EAC5CL,EAAOQ,KAAK,CAAEC,KAAMV,EAAKW,MAAMT,EAAGY,GAAaF,UAAW,oBAC1DV,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;AAE3B,SACGgB,EAAA,CAAaC,MAAOX,EAAa,kBAAoB,cAAeP,OAAYC,QAASa,EAAaK,MAAO,IAC5GlC,wBAAAD,EAAC,MAAA,CAAIpE,UAAU,iBACbqE,SAAA;eAAAC,EAACzC,EAAA,CACCC,MAAOyD,EACPxD,SAAUyD,EACVxD,SAAU2D,EAAa,WAAa;eAEtCvB,EAAC,MAAA,CAAIpE,UAAU,oBACbqE,SAAA;eAAAC,EAAC,UAAOkC,KAAK,SAASxG,UAAU,UAAUyG,QAASP,EAAa7B,SAAA;eAChEC,EAAC,UAAOkC,KAAK,SAASxG,UAAU,0BAA0ByG,QAnC9C,KAClBnB,EAAOoB,QAAQC,WACf,MAAMC,EAAUjB,EAAakB,EAAetB,GAAUA,EAEhDuB,EAAcxB,EAAOyB,UAAUC,SAASJ,GAE1CE,IAAgBF,GAClBtB,EAAO2B,SAASC,KAAK,mBAAoB,CACvCC,QAAS,gEAGb7B,EAAO8B,QAAQN,GACfxB,EAAO2B,SAASC,KAAK,kBACrB7B,GAAA,EAsBsFhB,SAAA,iBAK1F,CAEAc,EAAYkC,UAAY,CACtBjC,KAAMkC,EAAUC,KAAKC,WACrBnC,QAASiC,EAAUG,KAAKD,WACxBlC,OAAQgC,EAAUI"}
1
+ {"version":3,"file":"SourceModal-ChhNVz7y.js","sources":["../src/components/Modals/CodeEditor/highlightHTML.js","../src/components/Modals/CodeEditor/highlightMarkdown.js","../src/components/Modals/CodeEditor/CodeEditor.jsx","../src/components/Modals/SourceModal.jsx"],"sourcesContent":["/**\n * Lightweight HTML tokenizer for syntax highlighting.\n * Returns an array of { text, className } tokens.\n */\nexport function highlightHTML(code) {\n const tokens = []\n let i = 0\n const len = code.length\n\n while (i < len) {\n // Comment: <!-- ... -->\n if (code[i] === '<' && code.startsWith('!--', i + 1)) {\n const end = code.indexOf('-->', i + 4)\n const commentEnd = end === -1 ? len : end + 3\n tokens.push({ text: code.slice(i, commentEnd), className: 'rmx-syn-comment' })\n i = commentEnd\n continue\n }\n\n // Doctype: <!DOCTYPE ...>\n if (code[i] === '<' && code.startsWith('!', i + 1) && /^<![a-zA-Z]/.test(code.slice(i, i + 3))) {\n const end = code.indexOf('>', i)\n const doctypeEnd = end === -1 ? len : end + 1\n tokens.push({ text: code.slice(i, doctypeEnd), className: 'rmx-syn-doctype' })\n i = doctypeEnd\n continue\n }\n\n // Tag: < ... >\n if (code[i] === '<' && (code[i + 1] === '/' || /[a-zA-Z]/.test(code[i + 1] || ''))) {\n i = parseTag(code, i, tokens)\n continue\n }\n\n // Entity: &...;\n if (code[i] === '&') {\n const semi = code.indexOf(';', i + 1)\n if (semi !== -1 && semi - i < 12 && /^&[#a-zA-Z0-9]+;$/.test(code.slice(i, semi + 1))) {\n tokens.push({ text: code.slice(i, semi + 1), className: 'rmx-syn-entity' })\n i = semi + 1\n continue\n }\n }\n\n // Plain text until next < or &\n let textEnd = i + 1\n while (textEnd < len && code[textEnd] !== '<' && code[textEnd] !== '&') {\n textEnd++\n }\n tokens.push({ text: code.slice(i, textEnd), className: null })\n i = textEnd\n }\n\n return tokens\n}\n\n/**\n * Parse an HTML tag starting at position i, pushing tokens.\n * Returns the new position after the tag.\n */\nfunction parseTag(code, i, tokens) {\n const len = code.length\n\n // Opening: < or </\n if (code[i + 1] === '/') {\n tokens.push({ text: '</', className: 'rmx-syn-tag' })\n i += 2\n } else {\n tokens.push({ text: '<', className: 'rmx-syn-tag' })\n i += 1\n }\n\n // Tag name\n let nameStart = i\n while (i < len && /[a-zA-Z0-9:-]/.test(code[i])) i++\n if (i > nameStart) {\n tokens.push({ text: code.slice(nameStart, i), className: 'rmx-syn-tag' })\n }\n\n // Attributes and closing\n while (i < len) {\n // Skip whitespace\n if (/\\s/.test(code[i])) {\n let wsStart = i\n while (i < len && /\\s/.test(code[i])) i++\n tokens.push({ text: code.slice(wsStart, i), className: null })\n continue\n }\n\n // Self-close or close: />, >\n if (code[i] === '/' && code[i + 1] === '>') {\n tokens.push({ text: '/>', className: 'rmx-syn-tag' })\n return i + 2\n }\n if (code[i] === '>') {\n tokens.push({ text: '>', className: 'rmx-syn-tag' })\n return i + 1\n }\n\n // Attribute name\n let attrStart = i\n while (i < len && /[^\\s=/>]/.test(code[i])) i++\n if (i > attrStart) {\n tokens.push({ text: code.slice(attrStart, i), className: 'rmx-syn-attr-name' })\n }\n\n // Skip whitespace around =\n while (i < len && /\\s/.test(code[i])) {\n tokens.push({ text: code[i], className: null })\n i++\n }\n\n // = sign\n if (i < len && code[i] === '=') {\n tokens.push({ text: '=', className: null })\n i++\n\n // Skip whitespace after =\n while (i < len && /\\s/.test(code[i])) {\n tokens.push({ text: code[i], className: null })\n i++\n }\n\n // Attribute value\n if (i < len && (code[i] === '\"' || code[i] === \"'\")) {\n const quote = code[i]\n const valEnd = code.indexOf(quote, i + 1)\n const end = valEnd === -1 ? len : valEnd + 1\n tokens.push({ text: code.slice(i, end), className: 'rmx-syn-attr-value' })\n i = end\n } else {\n // Unquoted value\n let valStart = i\n while (i < len && /[^\\s>]/.test(code[i])) i++\n if (i > valStart) {\n tokens.push({ text: code.slice(valStart, i), className: 'rmx-syn-attr-value' })\n }\n }\n }\n }\n\n return i\n}\n","/**\n * Lightweight Markdown tokenizer for syntax highlighting.\n * Operates line-by-line since Markdown is line-oriented.\n * Returns an array of { text, className } tokens.\n */\nexport function highlightMarkdown(code) {\n const lines = code.split('\\n')\n const tokens = []\n let inCodeBlock = false\n\n for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {\n const line = lines[lineIdx]\n\n // Add newline between lines (not before the first)\n if (lineIdx > 0) {\n tokens.push({ text: '\\n', className: null })\n }\n\n // Code fence toggle: ```\n if (/^```/.test(line.trimStart())) {\n tokens.push({ text: line, className: 'rmx-syn-code-fence' })\n inCodeBlock = !inCodeBlock\n continue\n }\n\n // Inside code block — all code\n if (inCodeBlock) {\n tokens.push({ text: line, className: 'rmx-syn-code' })\n continue\n }\n\n // Heading: # ... ######\n if (/^#{1,6}\\s/.test(line)) {\n tokens.push({ text: line, className: 'rmx-syn-heading' })\n continue\n }\n\n // Horizontal rule: ---, ***, ___\n if (/^(\\s*)([-*_])\\2{2,}\\s*$/.test(line)) {\n tokens.push({ text: line, className: 'rmx-syn-hr' })\n continue\n }\n\n // Blockquote: > text\n if (/^>\\s?/.test(line)) {\n const markerMatch = line.match(/^(>\\s?)/)\n tokens.push({ text: markerMatch[0], className: 'rmx-syn-blockquote' })\n highlightInline(line.slice(markerMatch[0].length), tokens)\n continue\n }\n\n // Unordered list: - item, * item, + item\n const ulMatch = line.match(/^(\\s*[-*+]\\s+)/)\n if (ulMatch) {\n tokens.push({ text: ulMatch[0], className: 'rmx-syn-list-marker' })\n highlightInline(line.slice(ulMatch[0].length), tokens)\n continue\n }\n\n // Ordered list: 1. item, 2) item\n const olMatch = line.match(/^(\\s*\\d+[.)]\\s+)/)\n if (olMatch) {\n tokens.push({ text: olMatch[0], className: 'rmx-syn-list-marker' })\n highlightInline(line.slice(olMatch[0].length), tokens)\n continue\n }\n\n // Table separator: |---|---|\n if (/^\\|[\\s:|-]+\\|$/.test(line.trim())) {\n tokens.push({ text: line, className: 'rmx-syn-hr' })\n continue\n }\n\n // Regular line — process inline formatting\n highlightInline(line, tokens)\n }\n\n return tokens\n}\n\n/**\n * Tokenize inline Markdown formatting within a line.\n * Handles: bold, italic, inline code, links, images.\n */\nfunction highlightInline(text, tokens) {\n let i = 0\n const len = text.length\n let plainStart = 0\n\n while (i < len) {\n // Inline code: `code`\n if (text[i] === '`') {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n const end = text.indexOf('`', i + 1)\n if (end !== -1) {\n tokens.push({ text: text.slice(i, end + 1), className: 'rmx-syn-code' })\n i = end + 1\n plainStart = i\n continue\n }\n }\n\n // Image: ![alt](url)\n if (text[i] === '!' && text[i + 1] === '[') {\n const closeBracket = text.indexOf(']', i + 2)\n if (closeBracket !== -1 && text[closeBracket + 1] === '(') {\n const closeParen = text.indexOf(')', closeBracket + 2)\n if (closeParen !== -1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n tokens.push({ text: text.slice(i, closeParen + 1), className: 'rmx-syn-image' })\n i = closeParen + 1\n plainStart = i\n continue\n }\n }\n }\n\n // Link: [text](url)\n if (text[i] === '[') {\n const closeBracket = text.indexOf(']', i + 1)\n if (closeBracket !== -1 && text[closeBracket + 1] === '(') {\n const closeParen = text.indexOf(')', closeBracket + 2)\n if (closeParen !== -1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n // [text]\n tokens.push({ text: text.slice(i, closeBracket + 1), className: 'rmx-syn-link' })\n // (url)\n tokens.push({ text: text.slice(closeBracket + 1, closeParen + 1), className: 'rmx-syn-url' })\n i = closeParen + 1\n plainStart = i\n continue\n }\n }\n }\n\n // Bold: **text** or __text__\n if ((text[i] === '*' && text[i + 1] === '*') || (text[i] === '_' && text[i + 1] === '_')) {\n const marker = text.slice(i, i + 2)\n const end = text.indexOf(marker, i + 2)\n if (end !== -1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n tokens.push({ text: text.slice(i, end + 2), className: 'rmx-syn-bold' })\n i = end + 2\n plainStart = i\n continue\n }\n }\n\n // Italic: *text* or _text_ (single, not preceded/followed by same)\n if ((text[i] === '*' || text[i] === '_') && text[i + 1] !== text[i]) {\n const marker = text[i]\n const end = text.indexOf(marker, i + 1)\n if (end !== -1 && end > i + 1) {\n if (i > plainStart) {\n tokens.push({ text: text.slice(plainStart, i), className: null })\n }\n tokens.push({ text: text.slice(i, end + 1), className: 'rmx-syn-italic' })\n i = end + 1\n plainStart = i\n continue\n }\n }\n\n i++\n }\n\n // Remaining plain text\n if (plainStart < len) {\n tokens.push({ text: text.slice(plainStart), className: null })\n }\n}\n","import { useRef, useMemo, useCallback, useState, useEffect } from 'react'\nimport { highlightHTML } from './highlightHTML.js'\nimport { highlightMarkdown } from './highlightMarkdown.js'\nimport './CodeEditor.css'\n\nconst HIGHLIGHT_DEBOUNCE_MS = 150\n\nexport function CodeEditor({ value, onChange, language = 'html' }) {\n const textareaRef = useRef(null)\n const preRef = useRef(null)\n const gutterRef = useRef(null)\n const highlightTimerRef = useRef(null)\n\n // Debounced value for highlighting — delays expensive tokenization\n const [debouncedValue, setDebouncedValue] = useState(value || '')\n\n useEffect(() => {\n highlightTimerRef.current = setTimeout(() => {\n setDebouncedValue(value || '')\n }, HIGHLIGHT_DEBOUNCE_MS)\n return () => clearTimeout(highlightTimerRef.current)\n }, [value])\n\n // Tokenize the debounced source for highlighting\n const highlighted = useMemo(() => {\n const highlighter = language === 'markdown' ? highlightMarkdown : highlightHTML\n return highlighter(debouncedValue)\n }, [debouncedValue, language])\n\n // Count lines for the gutter\n const lineCount = useMemo(() => {\n return (value || '').split('\\n').length\n }, [value])\n\n // Sync scroll between textarea, pre, and gutter\n const handleScroll = useCallback(() => {\n const ta = textareaRef.current\n if (!ta) return\n if (preRef.current) {\n preRef.current.scrollTop = ta.scrollTop\n preRef.current.scrollLeft = ta.scrollLeft\n }\n if (gutterRef.current) {\n gutterRef.current.scrollTop = ta.scrollTop\n }\n }, [])\n\n // Tab key inserts 2 spaces\n const handleKeyDown = useCallback((e) => {\n if (e.key === 'Tab') {\n e.preventDefault()\n const ta = e.target\n const start = ta.selectionStart\n const end = ta.selectionEnd\n // Use setRangeText to insert text while preserving undo stack\n if (typeof ta.setRangeText === 'function') {\n ta.setRangeText(' ', start, end, 'end')\n ta.dispatchEvent(new Event('input', { bubbles: true }))\n } else {\n const newValue = value.substring(0, start) + ' ' + value.substring(end)\n onChange(newValue)\n requestAnimationFrame(() => {\n ta.selectionStart = ta.selectionEnd = start + 2\n })\n }\n }\n }, [value, onChange])\n\n return (\n <div className=\"rmx-code-editor\">\n {/* Line number gutter */}\n <div ref={gutterRef} className=\"rmx-code-gutter\" aria-hidden=\"true\">\n {Array.from({ length: lineCount }, (_, i) => (\n <div key={i} className=\"rmx-code-line-number\">{i + 1}</div>\n ))}\n </div>\n\n {/* Editor body: highlighted pre + transparent textarea */}\n <div className=\"rmx-code-body\">\n <pre ref={preRef} className=\"rmx-code-highlight\" aria-hidden=\"true\">\n <code>\n {highlighted.map((token, i) =>\n token.className\n ? <span key={i} className={token.className}>{token.text}</span>\n : token.text\n )}\n {'\\n'}\n </code>\n </pre>\n\n <textarea\n ref={textareaRef}\n className=\"rmx-code-input\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onScroll={handleScroll}\n onKeyDown={handleKeyDown}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n data-gramm=\"false\"\n />\n </div>\n </div>\n )\n}\n","import { useState, useEffect, useRef, useCallback } from 'react'\nimport PropTypes from 'prop-types'\nimport { ModalOverlay } from './ModalOverlay.jsx'\nimport { CodeEditor } from './CodeEditor/CodeEditor.jsx'\nimport { htmlToMarkdown, markdownToHtml, formatHTML } from '@remyxjs/core'\n\nexport function SourceModal({ open, onClose, engine }) {\n const [source, setSource] = useState('')\n const [initialSource, setInitialSource] = useState('')\n const isMarkdown = engine?.outputFormat === 'markdown'\n\n useEffect(() => {\n if (open && engine) {\n const html = engine.getHTML()\n const formatted = isMarkdown ? htmlToMarkdown(html) : formatHTML(html)\n setSource(formatted)\n setInitialSource(formatted)\n }\n }, [open, engine, isMarkdown])\n\n const handleApply = () => {\n engine.history.snapshot()\n const rawHtml = isMarkdown ? markdownToHtml(source) : source\n // Re-sanitize user-edited HTML to prevent XSS injection via source mode\n const htmlToApply = engine.sanitizer.sanitize(rawHtml)\n // Notify if sanitizer modified the input (unsafe content was stripped)\n if (htmlToApply !== rawHtml) {\n engine.eventBus.emit('source:sanitized', {\n message: 'Some HTML elements or attributes were removed for security.',\n })\n }\n engine.setHTML(htmlToApply)\n engine.eventBus.emit('content:change')\n onClose()\n }\n\n // #33: Confirm before discarding unsaved changes\n const handleClose = useCallback(() => {\n if (source !== initialSource) {\n const confirmed = window.confirm('You have unsaved changes. Discard them?')\n if (!confirmed) return\n }\n onClose()\n }, [source, initialSource, onClose])\n\n return (\n <ModalOverlay title={isMarkdown ? 'Markdown Source' : 'Source Code'} open={open} onClose={handleClose} width={750}>\n <div className=\"rmx-modal-form\">\n <CodeEditor\n value={source}\n onChange={setSource}\n language={isMarkdown ? 'markdown' : 'html'}\n />\n <div className=\"rmx-modal-actions\">\n <button type=\"button\" className=\"rmx-btn\" onClick={handleClose}>Cancel</button>\n <button type=\"button\" className=\"rmx-btn rmx-btn-primary\" onClick={handleApply}>Apply</button>\n </div>\n </div>\n </ModalOverlay>\n )\n}\n\nSourceModal.propTypes = {\n open: PropTypes.bool.isRequired,\n onClose: PropTypes.func.isRequired,\n engine: PropTypes.object,\n}\n"],"names":["highlightHTML","code","tokens","i","len","length","startsWith","end","indexOf","commentEnd","push","text","slice","className","test","doctypeEnd","parseTag","semi","textEnd","nameStart","wsStart","attrStart","quote","valEnd","valStart","highlightMarkdown","lines","split","inCodeBlock","lineIdx","line","trimStart","markerMatch","match","highlightInline","ulMatch","olMatch","trim","plainStart","closeBracket","closeParen","marker","CodeEditor","value","onChange","language","textareaRef","useRef","preRef","gutterRef","highlightTimerRef","debouncedValue","setDebouncedValue","useState","useEffect","current","setTimeout","clearTimeout","highlighted","useMemo","lineCount","handleScroll","useCallback","ta","scrollTop","scrollLeft","handleKeyDown","e","key","preventDefault","target","start","selectionStart","selectionEnd","setRangeText","dispatchEvent","Event","bubbles","newValue","substring","requestAnimationFrame","jsxs","children","jsx","ref","Array","from","_","map","token","onScroll","onKeyDown","spellCheck","autoCapitalize","autoComplete","autoCorrect","SourceModal","open","onClose","engine","source","setSource","initialSource","setInitialSource","isMarkdown","outputFormat","html","getHTML","formatted","htmlToMarkdown","formatHTML","handleClose","window","confirm","ModalOverlay","title","width","type","onClick","history","snapshot","rawHtml","markdownToHtml","htmlToApply","sanitizer","sanitize","eventBus","emit","message","setHTML","propTypes","PropTypes","bool","isRequired","func","object"],"mappings":"sTAIO,SAASA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8B,QAAQN,GACfxB,EAAO2B,SAASC,KAAK,kBACrB7B,GAAA,EAsBsFhB,SAAA,iBAK1F,CAEAc,EAAYkC,UAAY,CACtBjC,KAAMkC,EAAUC,KAAKC,WACrBnC,QAASiC,EAAUG,KAAKD,WACxBlC,OAAQgC,EAAUI"}
@@ -1,4 +1,4 @@
1
- import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as a,useCallback as t}from"react";import{P as l}from"./index-C720tbJA.js";import{M as o}from"./ModalOverlay-CLvRNHmp.js";function s({open:l,onClose:s,engine:n}){const[m,i]=a({row:0,col:0}),[c,d]=a(3),[p,x]=a(3),[u,b]=a(null),f=t((e=>{const r=e.target.closest("[data-row]");if(!r)return;const a=parseInt(r.dataset.row,10)+1,t=parseInt(r.dataset.col,10)+1;i({row:a,col:t}),d(a),x(t)}),[]),h=t((e=>{const r=e.target.closest("[data-row]");if(!r)return;const a=parseInt(r.dataset.row,10)+1,t=parseInt(r.dataset.col,10)+1;try{b(null),n.executeCommand("insertTable",{rows:a,cols:t}),s()}catch(l){b(l.message||"Failed to insert table")}}),[n,s]);/* @__PURE__ */
1
+ import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as a,useCallback as t}from"react";import{P as l}from"./index-DL-qBZZU.js";import{M as o}from"./ModalOverlay-Dt0JiW3M.js";function s({open:l,onClose:s,engine:n}){const[m,i]=a({row:0,col:0}),[c,d]=a(3),[p,x]=a(3),[u,b]=a(null),f=t((e=>{const r=e.target.closest("[data-row]");if(!r)return;const a=parseInt(r.dataset.row,10)+1,t=parseInt(r.dataset.col,10)+1;i({row:a,col:t}),d(a),x(t)}),[]),h=t((e=>{const r=e.target.closest("[data-row]");if(!r)return;const a=parseInt(r.dataset.row,10)+1,t=parseInt(r.dataset.col,10)+1;try{b(null),n.executeCommand("insertTable",{rows:a,cols:t}),s()}catch(l){b(l.message||"Failed to insert table")}}),[n,s]);/* @__PURE__ */
2
2
  return e(o,{title:"Insert Table",open:l,onClose:s,width:320,children:[
3
3
  /* @__PURE__ */e("div",{className:"rmx-table-picker",children:[
4
4
  /* @__PURE__ */r("div",{className:"rmx-table-grid",onMouseOver:f,onClick:h,"aria-hidden":"true",children:Array.from({length:10},((e,a)=>/* @__PURE__ */r("div",{className:"rmx-table-grid-row",children:Array.from({length:10},((e,t)=>/* @__PURE__ */r("div",{"data-row":a,"data-col":t,className:"rmx-table-grid-cell "+(a<m.row&&t<m.col?"rmx-active":"")},t)))},a)))}),
@@ -14,4 +14,4 @@ return e(o,{title:"Insert Table",open:l,onClose:s,width:320,children:[
14
14
  /* @__PURE__ */e("div",{className:"rmx-modal-actions",children:[
15
15
  /* @__PURE__ */r("button",{type:"button",className:"rmx-btn",onClick:s,children:"Cancel"}),
16
16
  /* @__PURE__ */r("button",{type:"button",className:"rmx-btn rmx-btn-primary",onClick:()=>{try{b(null),n.executeCommand("insertTable",{rows:c,cols:p}),s()}catch(e){b(e.message||"Failed to insert table")}},children:"Insert"})]})]})]})}s.propTypes={open:l.bool.isRequired,onClose:l.func.isRequired,engine:l.object};export{s as TablePickerModal};
17
- //# sourceMappingURL=TablePickerModal-DYODWEA1.js.map
17
+ //# sourceMappingURL=TablePickerModal-BnZHyMsk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TablePickerModal-DYODWEA1.js","sources":["../src/components/Modals/TablePickerModal.jsx"],"sourcesContent":["import { useState, useCallback } from 'react'\nimport PropTypes from 'prop-types'\nimport { ModalOverlay } from './ModalOverlay.jsx'\n\nconst MAX_SIZE = 10\n\nexport function TablePickerModal({ open, onClose, engine }) {\n const [hover, setHover] = useState({ row: 0, col: 0 })\n const [rows, setRows] = useState(3)\n const [cols, setCols] = useState(3)\n const [error, setError] = useState(null)\n\n const handleInsert = () => {\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows, cols })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }\n\n // Event delegation handlers for the grid container\n const handleGridMouseOver = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n setHover({ row: r, col: c })\n setRows(r)\n setCols(c)\n }, [])\n\n const handleGridClick = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows: r, cols: c })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }, [engine, onClose])\n\n return (\n <ModalOverlay title=\"Insert Table\" open={open} onClose={onClose} width={320}>\n <div className=\"rmx-table-picker\">\n <div className=\"rmx-table-grid\" onMouseOver={handleGridMouseOver} onClick={handleGridClick} aria-hidden=\"true\">\n {Array.from({ length: MAX_SIZE }, (_, r) => (\n <div key={r} className=\"rmx-table-grid-row\">\n {Array.from({ length: MAX_SIZE }, (_, c) => (\n <div\n key={c}\n data-row={r}\n data-col={c}\n className={`rmx-table-grid-cell ${r < hover.row && c < hover.col ? 'rmx-active' : ''}`}\n />\n ))}\n </div>\n ))}\n </div>\n <div className=\"rmx-table-picker-info\">{rows} x {cols}</div>\n </div>\n <div className=\"rmx-modal-form\" style={{ marginTop: 12 }}>\n <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-rows\">Rows</label>\n <input id=\"rmx-table-rows\" type=\"number\" className=\"rmx-form-input\" value={rows} min={1} max={20}\n onChange={(e) => setRows(parseInt(e.target.value) || 1)} />\n </div>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-cols\">Columns</label>\n <input id=\"rmx-table-cols\" type=\"number\" className=\"rmx-form-input\" value={cols} min={1} max={20}\n onChange={(e) => setCols(parseInt(e.target.value) || 1)} />\n </div>\n </div>\n {error && <div className=\"rmx-form-error\" style={{ color: '#d32f2f', fontSize: 13, marginBottom: 8 }}>{error}</div>}\n <div className=\"rmx-modal-actions\">\n <button type=\"button\" className=\"rmx-btn\" onClick={onClose}>Cancel</button>\n <button type=\"button\" className=\"rmx-btn rmx-btn-primary\" onClick={handleInsert}>Insert</button>\n </div>\n </div>\n </ModalOverlay>\n )\n}\n\nTablePickerModal.propTypes = {\n open: PropTypes.bool.isRequired,\n onClose: PropTypes.func.isRequired,\n engine: PropTypes.object,\n}\n"],"names":["TablePickerModal","open","onClose","engine","hover","setHover","useState","row","col","rows","setRows","cols","setCols","error","setError","handleGridMouseOver","useCallback","e","cell","target","closest","r","parseInt","dataset","c","handleGridClick","executeCommand","err","message","ModalOverlay","title","width","children","jsxs","className","jsx","onMouseOver","onClick","Array","from","length","_","style","marginTop","display","gap","alignItems","flex","htmlFor","id","type","value","min","max","onChange","color","fontSize","marginBottom","propTypes","PropTypes","bool","isRequired","func","object"],"mappings":"2LAMO,SAASA,GAAiBC,KAAEA,EAAAC,QAAMA,EAAAC,OAASA,IAChD,MAAOC,EAAOC,GAAYC,EAAS,CAAEC,IAAK,EAAGC,IAAK,KAC3CC,EAAMC,GAAWJ,EAAS,IAC1BK,EAAMC,GAAWN,EAAS,IAC1BO,EAAOC,GAAYR,EAAS,MAa7BS,EAAsBC,GAAaC,IACvC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,SAASJ,EAAKK,QAAQhB,IAAK,IAAM,EACrCiB,EAAIF,SAASJ,EAAKK,QAAQf,IAAK,IAAM,EAC3CH,EAAS,CAAEE,IAAKc,EAAGb,IAAKgB,IACxBd,EAAQW,GACRT,EAAQY,EAAC,GACR,IAEGC,EAAkBT,GAAaC,IACnC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,SAASJ,EAAKK,QAAQhB,IAAK,IAAM,EACrCiB,EAAIF,SAASJ,EAAKK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AU,iBAAiBQ,MAAO,CAAEK,KAAM,GAC7Cf,SAAA;eAAAG,EAAC,QAAA,CAAMD,UAAU,iBAAiBc,QAAQ,iBAAiBhB,SAAA;eAC3DG,EAAC,QAAA,CAAMc,GAAG,iBAAiBC,KAAK,SAAShB,UAAU,iBAAiBiB,MAAOxC,EAAMyC,IAAK,EAAGC,IAAK,GAC5FC,SAAWrC,GAAML,EAAQU,SAASL,EAAEE,OAAOgC,QAAU,WAG1DtC,kBAASsB,EAAC,MAAA,CAAID,UAAU,iBAAiBQ,MAAO,CAAEa,MAAO,UAAWC,SAAU,GAAIC,aAAc,GAAMzB,SAAAnB;eACvGoB,EAAC,MAAA,CAAIC,UAAU,oBACbF,SAAA;eAAAG,EAAC,UAAOe,KAAK,SAAShB,UAAU,UAAUG,QAASnC,EAAS8B,SAAA;eAC5DG,EAAC,UAAOe,KAAK,SAAShB,UAAU,0BAA0BG,QAtE7C,KACnB,IACEvB,EAAS,MACTX,EAAOuB,eAAe,cAAe,CAAEjB,OAAME,SAC7CT,GACF,OAASyB,GACPb,EAASa,EAAIC,SAAW,yBAC1B,GA+DuFI,SAAA,mBAK3F,CAEAhC,EAAiB0D,UAAY,CAC3BzD,KAAM0D,EAAUC,KAAKC,WACrB3D,QAASyD,EAAUG,KAAKD,WACxB1D,OAAQwD,EAAUI"}
1
+ {"version":3,"file":"TablePickerModal-BnZHyMsk.js","sources":["../src/components/Modals/TablePickerModal.jsx"],"sourcesContent":["import { useState, useCallback } from 'react'\nimport PropTypes from 'prop-types'\nimport { ModalOverlay } from './ModalOverlay.jsx'\n\nconst MAX_SIZE = 10\n\nexport function TablePickerModal({ open, onClose, engine }) {\n const [hover, setHover] = useState({ row: 0, col: 0 })\n const [rows, setRows] = useState(3)\n const [cols, setCols] = useState(3)\n const [error, setError] = useState(null)\n\n const handleInsert = () => {\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows, cols })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }\n\n // Event delegation handlers for the grid container\n const handleGridMouseOver = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n setHover({ row: r, col: c })\n setRows(r)\n setCols(c)\n }, [])\n\n const handleGridClick = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows: r, cols: c })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }, [engine, onClose])\n\n return (\n <ModalOverlay title=\"Insert Table\" open={open} onClose={onClose} width={320}>\n <div className=\"rmx-table-picker\">\n <div className=\"rmx-table-grid\" onMouseOver={handleGridMouseOver} onClick={handleGridClick} aria-hidden=\"true\">\n {Array.from({ length: MAX_SIZE }, (_, r) => (\n <div key={r} className=\"rmx-table-grid-row\">\n {Array.from({ length: MAX_SIZE }, (_, c) => (\n <div\n key={c}\n data-row={r}\n data-col={c}\n className={`rmx-table-grid-cell ${r < hover.row && c < hover.col ? 'rmx-active' : ''}`}\n />\n ))}\n </div>\n ))}\n </div>\n <div className=\"rmx-table-picker-info\">{rows} x {cols}</div>\n </div>\n <div className=\"rmx-modal-form\" style={{ marginTop: 12 }}>\n <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-rows\">Rows</label>\n <input id=\"rmx-table-rows\" type=\"number\" className=\"rmx-form-input\" value={rows} min={1} max={20}\n onChange={(e) => setRows(parseInt(e.target.value) || 1)} />\n </div>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-cols\">Columns</label>\n <input id=\"rmx-table-cols\" type=\"number\" className=\"rmx-form-input\" value={cols} min={1} max={20}\n onChange={(e) => setCols(parseInt(e.target.value) || 1)} />\n </div>\n </div>\n {error && <div className=\"rmx-form-error\" style={{ color: '#d32f2f', fontSize: 13, marginBottom: 8 }}>{error}</div>}\n <div className=\"rmx-modal-actions\">\n <button type=\"button\" className=\"rmx-btn\" onClick={onClose}>Cancel</button>\n <button type=\"button\" className=\"rmx-btn rmx-btn-primary\" onClick={handleInsert}>Insert</button>\n </div>\n </div>\n </ModalOverlay>\n )\n}\n\nTablePickerModal.propTypes = {\n open: PropTypes.bool.isRequired,\n onClose: PropTypes.func.isRequired,\n engine: PropTypes.object,\n}\n"],"names":["TablePickerModal","open","onClose","engine","hover","setHover","useState","row","col","rows","setRows","cols","setCols","error","setError","handleGridMouseOver","useCallback","e","cell","target","closest","r","parseInt","dataset","c","handleGridClick","executeCommand","err","message","ModalOverlay","title","width","children","jsxs","className","jsx","onMouseOver","onClick","Array","from","length","_","style","marginTop","display","gap","alignItems","flex","htmlFor","id","type","value","min","max","onChange","color","fontSize","marginBottom","propTypes","PropTypes","bool","isRequired","func","object"],"mappings":"2LAMO,SAASA,GAAiBC,KAAEA,EAAAC,QAAMA,EAAAC,OAASA,IAChD,MAAOC,EAAOC,GAAYC,EAAS,CAAEC,IAAK,EAAGC,IAAK,KAC3CC,EAAMC,GAAWJ,EAAS,IAC1BK,EAAMC,GAAWN,EAAS,IAC1BO,EAAOC,GAAYR,EAAS,MAa7BS,EAAsBC,GAAaC,IACvC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,SAASJ,EAAKK,QAAQhB,IAAK,IAAM,EACrCiB,EAAIF,SAASJ,EAAKK,QAAQf,IAAK,IAAM,EAC3CH,EAAS,CAAEE,IAAKc,EAAGb,IAAKgB,IACxBd,EAAQW,GACRT,EAAQY,EAAC,GACR,IAEGC,EAAkBT,GAAaC,IACnC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,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MP,EAAQY,SAASL,EAAEE,OAAOgC,QAAU;eAEzDlB,EAAC,OAAIC,UAAU,iBAAiBQ,MAAO,CAAEK,KAAM,GAC7Cf,SAAA;eAAAG,EAAC,QAAA,CAAMD,UAAU,iBAAiBc,QAAQ,iBAAiBhB,SAAA;eAC3DG,EAAC,QAAA,CAAMc,GAAG,iBAAiBC,KAAK,SAAShB,UAAU,iBAAiBiB,MAAOxC,EAAMyC,IAAK,EAAGC,IAAK,GAC5FC,SAAWrC,GAAML,EAAQU,SAASL,EAAEE,OAAOgC,QAAU,WAG1DtC,kBAASsB,EAAC,MAAA,CAAID,UAAU,iBAAiBQ,MAAO,CAAEa,MAAO,UAAWC,SAAU,GAAIC,aAAc,GAAMzB,SAAAnB;eACvGoB,EAAC,MAAA,CAAIC,UAAU,oBACbF,SAAA;eAAAG,EAAC,UAAOe,KAAK,SAAShB,UAAU,UAAUG,QAASnC,EAAS8B,SAAA;eAC5DG,EAAC,UAAOe,KAAK,SAAShB,UAAU,0BAA0BG,QAtE7C,KACnB,IACEvB,EAAS,MACTX,EAAOuB,eAAe,cAAe,CAAEjB,OAAME,SAC7CT,GACF,OAASyB,GACPb,EAASa,EAAIC,SAAW,yBAC1B,GA+DuFI,SAAA,mBAK3F,CAEAhC,EAAiB0D,UAAY,CAC3BzD,KAAM0D,EAAUC,KAAKC,WACrB3D,QAASyD,EAAUG,KAAKD,WACxB1D,OAAQwD,EAAUI"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),s=require("./index-Dc63uIP0.cjs"),a=require("./ModalOverlay-BDsGgv3_.cjs");function t({open:s,onClose:t,engine:l}){const[o,n]=r.useState({row:0,col:0}),[i,c]=r.useState(3),[m,d]=r.useState(3),[x,u]=r.useState(null),p=r.useCallback((e=>{const r=e.target.closest("[data-row]");if(!r)return;const s=parseInt(r.dataset.row,10)+1,a=parseInt(r.dataset.col,10)+1;n({row:s,col:a}),c(s),d(a)}),[]),b=r.useCallback((e=>{const r=e.target.closest("[data-row]");if(!r)return;const s=parseInt(r.dataset.row,10)+1,a=parseInt(r.dataset.col,10)+1;try{u(null),l.executeCommand("insertTable",{rows:s,cols:a}),t()}catch(o){u(o.message||"Failed to insert table")}}),[l,t]);return e.jsxs(a.ModalOverlay,{title:"Insert Table",open:s,onClose:t,width:320,children:[e.jsxs("div",{className:"rmx-table-picker",children:[e.jsx("div",{className:"rmx-table-grid",onMouseOver:p,onClick:b,"aria-hidden":"true",children:Array.from({length:10},((r,s)=>e.jsx("div",{className:"rmx-table-grid-row",children:Array.from({length:10},((r,a)=>e.jsx("div",{"data-row":s,"data-col":a,className:"rmx-table-grid-cell "+(s<o.row&&a<o.col?"rmx-active":"")},a)))},s)))}),e.jsxs("div",{className:"rmx-table-picker-info",children:[i," x ",m]})]}),e.jsxs("div",{className:"rmx-modal-form",style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("div",{className:"rmx-form-group",style:{flex:1},children:[e.jsx("label",{className:"rmx-form-label",htmlFor:"rmx-table-rows",children:"Rows"}),e.jsx("input",{id:"rmx-table-rows",type:"number",className:"rmx-form-input",value:i,min:1,max:20,onChange:e=>c(parseInt(e.target.value)||1)})]}),e.jsxs("div",{className:"rmx-form-group",style:{flex:1},children:[e.jsx("label",{className:"rmx-form-label",htmlFor:"rmx-table-cols",children:"Columns"}),e.jsx("input",{id:"rmx-table-cols",type:"number",className:"rmx-form-input",value:m,min:1,max:20,onChange:e=>d(parseInt(e.target.value)||1)})]})]}),x&&e.jsx("div",{className:"rmx-form-error",style:{color:"#d32f2f",fontSize:13,marginBottom:8},children:x}),e.jsxs("div",{className:"rmx-modal-actions",children:[e.jsx("button",{type:"button",className:"rmx-btn",onClick:t,children:"Cancel"}),e.jsx("button",{type:"button",className:"rmx-btn rmx-btn-primary",onClick:()=>{try{u(null),l.executeCommand("insertTable",{rows:i,cols:m}),t()}catch(e){u(e.message||"Failed to insert table")}},children:"Insert"})]})]})]})}t.propTypes={open:s.PropTypes.bool.isRequired,onClose:s.PropTypes.func.isRequired,engine:s.PropTypes.object},exports.TablePickerModal=t;
2
- //# sourceMappingURL=TablePickerModal-Do1QyoyM.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),s=require("./index-qh1Yzh-l.cjs"),a=require("./ModalOverlay-Dh5quv7X.cjs");function t({open:s,onClose:t,engine:l}){const[o,n]=r.useState({row:0,col:0}),[i,c]=r.useState(3),[m,d]=r.useState(3),[x,u]=r.useState(null),p=r.useCallback((e=>{const r=e.target.closest("[data-row]");if(!r)return;const s=parseInt(r.dataset.row,10)+1,a=parseInt(r.dataset.col,10)+1;n({row:s,col:a}),c(s),d(a)}),[]),b=r.useCallback((e=>{const r=e.target.closest("[data-row]");if(!r)return;const s=parseInt(r.dataset.row,10)+1,a=parseInt(r.dataset.col,10)+1;try{u(null),l.executeCommand("insertTable",{rows:s,cols:a}),t()}catch(o){u(o.message||"Failed to insert table")}}),[l,t]);return e.jsxs(a.ModalOverlay,{title:"Insert Table",open:s,onClose:t,width:320,children:[e.jsxs("div",{className:"rmx-table-picker",children:[e.jsx("div",{className:"rmx-table-grid",onMouseOver:p,onClick:b,"aria-hidden":"true",children:Array.from({length:10},((r,s)=>e.jsx("div",{className:"rmx-table-grid-row",children:Array.from({length:10},((r,a)=>e.jsx("div",{"data-row":s,"data-col":a,className:"rmx-table-grid-cell "+(s<o.row&&a<o.col?"rmx-active":"")},a)))},s)))}),e.jsxs("div",{className:"rmx-table-picker-info",children:[i," x ",m]})]}),e.jsxs("div",{className:"rmx-modal-form",style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("div",{className:"rmx-form-group",style:{flex:1},children:[e.jsx("label",{className:"rmx-form-label",htmlFor:"rmx-table-rows",children:"Rows"}),e.jsx("input",{id:"rmx-table-rows",type:"number",className:"rmx-form-input",value:i,min:1,max:20,onChange:e=>c(parseInt(e.target.value)||1)})]}),e.jsxs("div",{className:"rmx-form-group",style:{flex:1},children:[e.jsx("label",{className:"rmx-form-label",htmlFor:"rmx-table-cols",children:"Columns"}),e.jsx("input",{id:"rmx-table-cols",type:"number",className:"rmx-form-input",value:m,min:1,max:20,onChange:e=>d(parseInt(e.target.value)||1)})]})]}),x&&e.jsx("div",{className:"rmx-form-error",style:{color:"#d32f2f",fontSize:13,marginBottom:8},children:x}),e.jsxs("div",{className:"rmx-modal-actions",children:[e.jsx("button",{type:"button",className:"rmx-btn",onClick:t,children:"Cancel"}),e.jsx("button",{type:"button",className:"rmx-btn rmx-btn-primary",onClick:()=>{try{u(null),l.executeCommand("insertTable",{rows:i,cols:m}),t()}catch(e){u(e.message||"Failed to insert table")}},children:"Insert"})]})]})]})}t.propTypes={open:s.PropTypes.bool.isRequired,onClose:s.PropTypes.func.isRequired,engine:s.PropTypes.object},exports.TablePickerModal=t;
2
+ //# sourceMappingURL=TablePickerModal-Dr0wUx_h.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TablePickerModal-Do1QyoyM.cjs","sources":["../src/components/Modals/TablePickerModal.jsx"],"sourcesContent":["import { useState, useCallback } from 'react'\nimport PropTypes from 'prop-types'\nimport { ModalOverlay } from './ModalOverlay.jsx'\n\nconst MAX_SIZE = 10\n\nexport function TablePickerModal({ open, onClose, engine }) {\n const [hover, setHover] = useState({ row: 0, col: 0 })\n const [rows, setRows] = useState(3)\n const [cols, setCols] = useState(3)\n const [error, setError] = useState(null)\n\n const handleInsert = () => {\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows, cols })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }\n\n // Event delegation handlers for the grid container\n const handleGridMouseOver = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n setHover({ row: r, col: c })\n setRows(r)\n setCols(c)\n }, [])\n\n const handleGridClick = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows: r, cols: c })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }, [engine, onClose])\n\n return (\n <ModalOverlay title=\"Insert Table\" open={open} onClose={onClose} width={320}>\n <div className=\"rmx-table-picker\">\n <div className=\"rmx-table-grid\" onMouseOver={handleGridMouseOver} onClick={handleGridClick} aria-hidden=\"true\">\n {Array.from({ length: MAX_SIZE }, (_, r) => (\n <div key={r} className=\"rmx-table-grid-row\">\n {Array.from({ length: MAX_SIZE }, (_, c) => (\n <div\n key={c}\n data-row={r}\n data-col={c}\n className={`rmx-table-grid-cell ${r < hover.row && c < hover.col ? 'rmx-active' : ''}`}\n />\n ))}\n </div>\n ))}\n </div>\n <div className=\"rmx-table-picker-info\">{rows} x {cols}</div>\n </div>\n <div className=\"rmx-modal-form\" style={{ marginTop: 12 }}>\n <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-rows\">Rows</label>\n <input id=\"rmx-table-rows\" type=\"number\" className=\"rmx-form-input\" value={rows} min={1} max={20}\n onChange={(e) => setRows(parseInt(e.target.value) || 1)} />\n </div>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-cols\">Columns</label>\n <input id=\"rmx-table-cols\" type=\"number\" className=\"rmx-form-input\" value={cols} min={1} max={20}\n onChange={(e) => setCols(parseInt(e.target.value) || 1)} />\n </div>\n </div>\n {error && <div className=\"rmx-form-error\" style={{ color: '#d32f2f', fontSize: 13, marginBottom: 8 }}>{error}</div>}\n <div className=\"rmx-modal-actions\">\n <button type=\"button\" className=\"rmx-btn\" onClick={onClose}>Cancel</button>\n <button type=\"button\" className=\"rmx-btn rmx-btn-primary\" onClick={handleInsert}>Insert</button>\n </div>\n </div>\n </ModalOverlay>\n )\n}\n\nTablePickerModal.propTypes = {\n open: PropTypes.bool.isRequired,\n onClose: PropTypes.func.isRequired,\n engine: PropTypes.object,\n}\n"],"names":["TablePickerModal","open","onClose","engine","hover","setHover","useState","row","col","rows","setRows","cols","setCols","error","setError","handleGridMouseOver","useCallback","e","cell","target","closest","r","parseInt","dataset","c","handleGridClick","executeCommand","err","message","ModalOverlay","title","width","children","jsxs","className","jsx","onMouseOver","onClick","Array","from","length","_","style","marginTop","display","gap","alignItems","flex","htmlFor","id","type","value","min","max","onChange","color","fontSize","marginBottom","propTypes","PropTypes","bool","isRequired","func","object"],"mappings":"mNAMO,SAASA,GAAiBC,KAAEA,EAAAC,QAAMA,EAAAC,OAASA,IAChD,MAAOC,EAAOC,GAAYC,EAAAA,SAAS,CAAEC,IAAK,EAAGC,IAAK,KAC3CC,EAAMC,GAAWJ,EAAAA,SAAS,IAC1BK,EAAMC,GAAWN,EAAAA,SAAS,IAC1BO,EAAOC,GAAYR,EAAAA,SAAS,MAa7BS,EAAsBC,eAAaC,IACvC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,SAASJ,EAAKK,QAAQhB,IAAK,IAAM,EACrCiB,EAAIF,SAASJ,EAAKK,QAAQf,IAAK,IAAM,EAC3CH,EAAS,CAAEE,IAAKc,EAAGb,IAAKgB,IACxBd,EAAQW,GACRT,EAAQY,EAAC,GACR,IAEGC,EAAkBT,eAAaC,IACnC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,SAASJ,EAAKK,QAAQhB,IAAK,IAAM,EACrCiB,EAAIF,SAASJ,EAAKK,QAAQf,IAAK,IAAM,EAC3C,IACEM,EAAS,MACTX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O,CAAEK,KAAM,GAC7Cf,SAAA,CAAAG,MAAC,QAAA,CAAMD,UAAU,iBAAiBc,QAAQ,iBAAiBhB,SAAA,YAC3DG,EAAAA,IAAC,QAAA,CAAMc,GAAG,iBAAiBC,KAAK,SAAShB,UAAU,iBAAiBiB,MAAOxC,EAAMyC,IAAK,EAAGC,IAAK,GAC5FC,SAAWrC,GAAML,EAAQU,SAASL,EAAEE,OAAOgC,QAAU,WAG1DtC,GAASsB,EAAAA,IAAC,MAAA,CAAID,UAAU,iBAAiBQ,MAAO,CAAEa,MAAO,UAAWC,SAAU,GAAIC,aAAc,GAAMzB,SAAAnB,MACvGoB,KAAC,MAAA,CAAIC,UAAU,oBACbF,SAAA,CAAAG,EAAAA,IAAC,UAAOe,KAAK,SAAShB,UAAU,UAAUG,QAASnC,EAAS8B,SAAA,WAC5DG,EAAAA,IAAC,UAAOe,KAAK,SAAShB,UAAU,0BAA0BG,QAtE7C,KACnB,IACEvB,EAAS,MACTX,EAAOuB,eAAe,cAAe,CAAEjB,OAAME,SAC7CT,GACF,OAASyB,GACPb,EAASa,EAAIC,SAAW,yBAC1B,GA+DuFI,SAAA,mBAK3F,CAEAhC,EAAiB0D,UAAY,CAC3BzD,KAAM0D,EAAAA,UAAUC,KAAKC,WACrB3D,QAASyD,EAAAA,UAAUG,KAAKD,WACxB1D,OAAQwD,EAAAA,UAAUI"}
1
+ {"version":3,"file":"TablePickerModal-Dr0wUx_h.cjs","sources":["../src/components/Modals/TablePickerModal.jsx"],"sourcesContent":["import { useState, useCallback } from 'react'\nimport PropTypes from 'prop-types'\nimport { ModalOverlay } from './ModalOverlay.jsx'\n\nconst MAX_SIZE = 10\n\nexport function TablePickerModal({ open, onClose, engine }) {\n const [hover, setHover] = useState({ row: 0, col: 0 })\n const [rows, setRows] = useState(3)\n const [cols, setCols] = useState(3)\n const [error, setError] = useState(null)\n\n const handleInsert = () => {\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows, cols })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }\n\n // Event delegation handlers for the grid container\n const handleGridMouseOver = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n setHover({ row: r, col: c })\n setRows(r)\n setCols(c)\n }, [])\n\n const handleGridClick = useCallback((e) => {\n const cell = e.target.closest('[data-row]')\n if (!cell) return\n const r = parseInt(cell.dataset.row, 10) + 1\n const c = parseInt(cell.dataset.col, 10) + 1\n try {\n setError(null)\n engine.executeCommand('insertTable', { rows: r, cols: c })\n onClose()\n } catch (err) {\n setError(err.message || 'Failed to insert table')\n }\n }, [engine, onClose])\n\n return (\n <ModalOverlay title=\"Insert Table\" open={open} onClose={onClose} width={320}>\n <div className=\"rmx-table-picker\">\n <div className=\"rmx-table-grid\" onMouseOver={handleGridMouseOver} onClick={handleGridClick} aria-hidden=\"true\">\n {Array.from({ length: MAX_SIZE }, (_, r) => (\n <div key={r} className=\"rmx-table-grid-row\">\n {Array.from({ length: MAX_SIZE }, (_, c) => (\n <div\n key={c}\n data-row={r}\n data-col={c}\n className={`rmx-table-grid-cell ${r < hover.row && c < hover.col ? 'rmx-active' : ''}`}\n />\n ))}\n </div>\n ))}\n </div>\n <div className=\"rmx-table-picker-info\">{rows} x {cols}</div>\n </div>\n <div className=\"rmx-modal-form\" style={{ marginTop: 12 }}>\n <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-rows\">Rows</label>\n <input id=\"rmx-table-rows\" type=\"number\" className=\"rmx-form-input\" value={rows} min={1} max={20}\n onChange={(e) => setRows(parseInt(e.target.value) || 1)} />\n </div>\n <div className=\"rmx-form-group\" style={{ flex: 1 }}>\n <label className=\"rmx-form-label\" htmlFor=\"rmx-table-cols\">Columns</label>\n <input id=\"rmx-table-cols\" type=\"number\" className=\"rmx-form-input\" value={cols} min={1} max={20}\n onChange={(e) => setCols(parseInt(e.target.value) || 1)} />\n </div>\n </div>\n {error && <div className=\"rmx-form-error\" style={{ color: '#d32f2f', fontSize: 13, marginBottom: 8 }}>{error}</div>}\n <div className=\"rmx-modal-actions\">\n <button type=\"button\" className=\"rmx-btn\" onClick={onClose}>Cancel</button>\n <button type=\"button\" className=\"rmx-btn rmx-btn-primary\" onClick={handleInsert}>Insert</button>\n </div>\n </div>\n </ModalOverlay>\n )\n}\n\nTablePickerModal.propTypes = {\n open: PropTypes.bool.isRequired,\n onClose: PropTypes.func.isRequired,\n engine: PropTypes.object,\n}\n"],"names":["TablePickerModal","open","onClose","engine","hover","setHover","useState","row","col","rows","setRows","cols","setCols","error","setError","handleGridMouseOver","useCallback","e","cell","target","closest","r","parseInt","dataset","c","handleGridClick","executeCommand","err","message","ModalOverlay","title","width","children","jsxs","className","jsx","onMouseOver","onClick","Array","from","length","_","style","marginTop","display","gap","alignItems","flex","htmlFor","id","type","value","min","max","onChange","color","fontSize","marginBottom","propTypes","PropTypes","bool","isRequired","func","object"],"mappings":"mNAMO,SAASA,GAAiBC,KAAEA,EAAAC,QAAMA,EAAAC,OAASA,IAChD,MAAOC,EAAOC,GAAYC,EAAAA,SAAS,CAAEC,IAAK,EAAGC,IAAK,KAC3CC,EAAMC,GAAWJ,EAAAA,SAAS,IAC1BK,EAAMC,GAAWN,EAAAA,SAAS,IAC1BO,EAAOC,GAAYR,EAAAA,SAAS,MAa7BS,EAAsBC,eAAaC,IACvC,MAAMC,EAAOD,EAAEE,OAAOC,QAAQ,cAC9B,IAAKF,EAAM,OACX,MAAMG,EAAIC,SAASJ,EAAKK,QAAQhB,IAAK,IAAM,EACrCiB,EAAIF,SAASJ,EAAKK,QAAQf,IAAK,IAAM,EAC3CH,EAAS,CAAEE,IAAKc,EAAGb,IAAKgB,IACxBd,EAAQW,GACRT,EAAQY,EAAC,GACR,IAEGC,EAAkBT,eAAaC,IACnC,MAAMC,EAAO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BC,KAAK,SAAShB,UAAU,iBAAiBiB,MAAO1C,EAAM2C,IAAK,EAAGC,IAAK,GAC5FC,SAAWrC,GAAMP,EAAQY,SAASL,EAAEE,OAAOgC,QAAU,QAEzDlB,OAAC,OAAIC,UAAU,iBAAiBQ,MAAO,CAAEK,KAAM,GAC7Cf,SAAA,CAAAG,MAAC,QAAA,CAAMD,UAAU,iBAAiBc,QAAQ,iBAAiBhB,SAAA,YAC3DG,EAAAA,IAAC,QAAA,CAAMc,GAAG,iBAAiBC,KAAK,SAAShB,UAAU,iBAAiBiB,MAAOxC,EAAMyC,IAAK,EAAGC,IAAK,GAC5FC,SAAWrC,GAAML,EAAQU,SAASL,EAAEE,OAAOgC,QAAU,WAG1DtC,GAASsB,EAAAA,IAAC,MAAA,CAAID,UAAU,iBAAiBQ,MAAO,CAAEa,MAAO,UAAWC,SAAU,GAAIC,aAAc,GAAMzB,SAAAnB,MACvGoB,KAAC,MAAA,CAAIC,UAAU,oBACbF,SAAA,CAAAG,EAAAA,IAAC,UAAOe,KAAK,SAAShB,UAAU,UAAUG,QAASnC,EAAS8B,SAAA,WAC5DG,EAAAA,IAAC,UAAOe,KAAK,SAAShB,UAAU,0BAA0BG,QAtE7C,KACnB,IACEvB,EAAS,MACTX,EAAOuB,eAAe,cAAe,CAAEjB,OAAME,SAC7CT,GACF,OAASyB,GACPb,EAASa,EAAIC,SAAW,yBAC1B,GA+DuFI,SAAA,mBAK3F,CAEAhC,EAAiB0D,UAAY,CAC3BzD,KAAM0D,EAAAA,UAAUC,KAAKC,WACrB3D,QAASyD,EAAAA,UAAUG,KAAKD,WACxB1D,OAAQwD,EAAAA,UAAUI"}
@@ -0,0 +1,3 @@
1
+ import{createPlugin as e,escapeHTMLAttr as t,escapeHTML as n,evaluateTableFormulas as r}from"@remyxjs/core";function o(e){if(!(e=e.toLowerCase().replace(/[^a-z]/g,"")))return 0;if(e.length<=3)return 1;const t=(e=(e=e.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"")).replace(/^y/,"")).match(/[aeiouy]{1,2}/g);return t?t.length:1}function s(e){return e?e.split(new RegExp("(?<=[.!?])\\s+")).map((e=>e.trim())).filter((e=>e.length>0)):[]}function a(e){return e.trim().split(/\s+/).filter((e=>e.length>0))}function l(e){return 0===e.sentences||0===e.words?0:e.words/e.sentences*.39+e.syllables/e.words*11.8-15.59}function i(e){return 0===e.sentences||0===e.words?0:206.835-e.words/e.sentences*1.015-e.syllables/e.words*84.6}function c(e){return 0===e.sentences||0===e.words?0:.4*(e.words/e.sentences+e.complexWords/e.words*100)}function u(e){if(0===e.words)return 0;return.0588*(e.chars/e.words*100)-.296*(e.sentences/e.words*100)-15.8}function m(e){return e<=6?"basic":e<=12?"intermediate":"advanced"}function d(e,t={}){const{wordsPerMinute:n=200,targetWordCount:r=0,maxSentenceLength:d=30,maxParagraphLength:p=150}=t,g=a(e),h=s(e),f=function(e){return e.split(/\n\s*\n/).map((e=>e.trim())).filter((e=>e.length>0))}(e),y=e.replace(/\s/g,"").length;let b=0,x=0;for(const s of g){const e=o(s);b+=e,e>=3&&x++}const v={words:g.length,sentences:h.length,syllables:b,complexWords:x,chars:y},w=l(v),C=i(v),k=c(v),S=u(v),T=m(w),A=g.length/n,_=Math.round(60*A),E=h.map(((e,t)=>({index:t,text:e,wordCount:a(e).length}))).filter((e=>e.wordCount>d)),L=f.map(((e,t)=>({index:t,text:e.substring(0,100)+(e.length>100?"...":""),wordCount:a(e).length}))).filter((e=>e.wordCount>p)),N=r>0?{target:r,current:g.length,percentage:Math.round(g.length/r*100)}:null;return{wordCount:g.length,charCount:y,sentenceCount:h.length,paragraphCount:f.length,syllableCount:b,complexWordCount:x,readability:{fleschKincaid:Math.round(10*w)/10,fleschReadingEase:Math.round(10*C)/10,gunningFog:Math.round(10*k)/10,colemanLiau:Math.round(10*S)/10,vocabularyLevel:T},readingTime:{minutes:Math.ceil(A),seconds:_,wordsPerMinute:n},warnings:{longSentences:E,longParagraphs:L},goalProgress:N}}function p(e,t){if(!e||!t)return{count:0,density:0,positions:[]};const n=a(e),r=t.toLowerCase(),o=[];let s=0;return n.forEach(((e,t)=>{e.toLowerCase()===r&&(s++,o.push(t))})),{count:s,density:n.length>0?Math.round(s/n.length*1e4)/100:0,positions:o}}function g(e,t,n){const r=a(e),o=t.querySelectorAll("h1, h2, h3, h4, h5, h6"),s=t.querySelectorAll("h1").length,l=[];0===s&&l.push("Missing H1 heading"),s>1&&l.push("Multiple H1 headings — consider using only one"),r.length<300&&l.push("Content is short — aim for 300+ words for SEO"),0===o.length&&l.push("No headings — add headings to improve content structure");let i=null;return n&&(i=p(e,n),i.density<.5&&l.push(`Keyword "${n}" density is low (${i.density}%) — aim for 1-3%`),i.density>3&&l.push(`Keyword "${n}" density is high (${i.density}%) — may be over-optimized`)),{wordCount:r.length,headingCount:o.length,h1Count:s,keywordInfo:i,hints:l}}const h=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,AnalyticsPlugin:function(t={}){const{wordsPerMinute:n=200,targetWordCount:r=0,onAnalytics:s,maxSentenceLength:a=30,maxParagraphLength:i=150}=t;let m=null,h=null,f=null,y=null,b=null;function x(){if(!m)return;const e=m.getText();e===b&&y||(b=e,y=d(e,{wordsPerMinute:n,targetWordCount:r,maxSentenceLength:a,maxParagraphLength:i}),m.eventBus.emit("analytics:update",y),s?.(y))}return e({name:"analytics",requiresFullAccess:!0,version:"1.0.0",description:"Readability scores, reading time, vocabulary level, SEO hints",commands:[{name:"toggleAnalytics",execute:e=>(e._analyticsVisible=!e._analyticsVisible,e.eventBus.emit("analytics:toggle",{visible:e._analyticsVisible}),e._analyticsVisible),meta:{icon:"analytics",tooltip:"Toggle Analytics Panel"}},{name:"getAnalytics",execute:e=>d(e.getText(),{wordsPerMinute:n,targetWordCount:r,maxSentenceLength:a,maxParagraphLength:i}),meta:{tooltip:"Get Content Analytics"}},{name:"getSeoAnalysis",execute:(e,t)=>g(e.getText(),e.element,t),meta:{tooltip:"Get SEO Analysis"}},{name:"getKeywordDensity",execute:(e,t)=>p(e.getText(),t),meta:{tooltip:"Get Keyword Density"}}],init(e){m=e,m._analytics={analyzeContent:()=>d(m.getText(),{wordsPerMinute:n,targetWordCount:r,maxSentenceLength:a,maxParagraphLength:i}),seoAnalysis:e=>g(m.getText(),m.element,e),keywordDensity:e=>p(m.getText(),e),getStats:()=>y,countSyllables:o,fleschKincaid:l,gunningFog:c,colemanLiau:u},h=m.eventBus.on("content:change",(()=>{clearTimeout(f),f=setTimeout(x,300)})),x()},destroy(){clearTimeout(f),h?.(),m=null}})},analyzeContent:d,colemanLiau:u,countSyllables:o,fleschKincaid:l,fleschReadingEase:i,gunningFog:c,keywordDensity:p,seoAnalysis:g,splitSentences:s,vocabularyLevel:m},Symbol.toStringTag,{value:"Module"})),f={"Feature Card":'<div class="rmx-template-feature-card" style="border:1px solid #e2e8f0;border-radius:8px;padding:16px;margin:8px 0;">\n <img src="" alt="Feature image" style="width:100%;height:auto;border-radius:4px;margin-bottom:12px;" />\n <h3>Feature Title</h3>\n <p>Describe the feature here. Highlight key benefits and value propositions.</p>\n</div>',"Two-Column":'<div class="rmx-template-two-column" style="display:flex;gap:16px;margin:8px 0;">\n <div style="flex:1;padding:12px;border:1px solid #e2e8f0;border-radius:4px;">\n <p>Left column content</p>\n </div>\n <div style="flex:1;padding:12px;border:1px solid #e2e8f0;border-radius:4px;">\n <p>Right column content</p>\n </div>\n</div>',"Call to Action":'<div class="rmx-template-cta" style="text-align:center;padding:24px;margin:8px 0;background:#f8fafc;border-radius:8px;">\n <h2>Ready to Get Started?</h2>\n <p>Take the next step and join thousands of satisfied users today.</p>\n <p><span style="display:inline-block;padding:10px 24px;background:#6366f1;color:#fff;border-radius:6px;font-weight:600;">Get Started</span></p>\n</div>'};const y=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,BlockTemplatePlugin:function(){const t=/* @__PURE__ */new Map;return e({name:"blockTemplates",requiresFullAccess:!0,init(e){for(const[n,r]of Object.entries(f))t.set(n,r);e._blockTemplates={registerTemplate:function(e,n){e&&"string"==typeof n&&t.set(e,n)},insertTemplate:function(n){const r=t.get(n);if(!r)return;e.history.snapshot();const o=e.selection.getRange();if(!o)return;const s=document.createElement("div");s.innerHTML=e.sanitizer.sanitize(r);const a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);o.collapsed||o.deleteContents(),o.insertNode(a);const l=e.element;if(!l.lastElementChild||"P"!==l.lastElementChild.tagName){const e=document.createElement("p");e.innerHTML="<br>",l.appendChild(e)}e.eventBus.emit("content:change")},getTemplates:function(){return Array.from(t.entries()).map((([e,t])=>({name:e,html:t})))},removeTemplate:function(e){return t.delete(e)}}},destroy(){t.clear()}})}},Symbol.toStringTag,{value:"Module"})),b=/* @__PURE__ */new Map,x=[{type:"info",label:"Info",icon:"ℹ️",color:"#3b82f6"},{type:"warning",label:"Warning",icon:"⚠️",color:"#f59e0b"},{type:"error",label:"Error",icon:"❌",color:"#ef4444"},{type:"success",label:"Success",icon:"✅",color:"#22c55e"},{type:"tip",label:"Tip",icon:"💡",color:"#8b5cf6"},{type:"note",label:"Note",icon:"📝",color:"#6366f1"},{type:"question",label:"Question",icon:"❓",color:"#ec4899"}];for(const Ht of x)b.set(Ht.type,Ht);function v(e){e&&e.type&&b.set(e.type,e)}function w(e){return b.delete(e)}function C(){return Array.from(b.values())}function k(e){return b.get(e)}const S={NOTE:"note",TIP:"tip",IMPORTANT:"info",WARNING:"warning",CAUTION:"error"};function T(e){if(!e)return null;const t=e.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*\n?([\s\S]*)/);if(!t)return null;const n=t[1];return{type:S[n]||n.toLowerCase(),body:t[2].trim()}}function A(e,t="",n={}){const{collapsible:r=!1,collapsed:o=!1,title:s}=n,a=b.get(e)||{label:e,icon:"📌"},l=document.createElement("div");l.className=`rmx-callout rmx-callout-${e}`,l.setAttribute("data-callout",e),r&&(l.setAttribute("data-callout-collapsible",""),o&&l.setAttribute("data-callout-collapsed",""));const i=document.createElement("div");i.className="rmx-callout-header",i.contentEditable="false";const c=document.createElement("span");c.className="rmx-callout-icon",c.textContent=a.icon,i.appendChild(c);const u=document.createElement("span");if(u.className="rmx-callout-title",u.textContent=s||a.label,i.appendChild(u),r){const e=document.createElement("button");e.className="rmx-callout-toggle",e.type="button",e.setAttribute("aria-label",o?"Expand":"Collapse"),e.textContent=o?"▶":"▼",i.appendChild(e)}l.appendChild(i);const m=document.createElement("div");if(m.className="rmx-callout-body",t)m.innerHTML=t;else{const e=document.createElement("p");e.innerHTML="<br>",m.appendChild(e)}return r&&o&&(m.style.display="none"),l.appendChild(m),l}function _(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return null;let r=n.anchorNode;for(3===r.nodeType&&(r=r.parentNode);r&&r!==e.element;){if(r.classList?.contains(t))return r;r=r.parentNode}return null}const E=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,CalloutPlugin:function(){let t=null,n=null,r=null;function o(e){const t=e.target.closest?.(".rmx-callout-toggle");if(!t)return;const n=t.closest(".rmx-callout");if(!n)return;e.preventDefault(),e.stopPropagation();const r=n.querySelector(".rmx-callout-body");if(!r)return;n.hasAttribute("data-callout-collapsed")?(n.removeAttribute("data-callout-collapsed"),r.style.display="",t.textContent="▼",t.setAttribute("aria-label","Collapse")):(n.setAttribute("data-callout-collapsed",""),r.style.display="none",t.textContent="▶",t.setAttribute("aria-label","Expand"))}function s(){if(!t)return;const e=t.element.querySelectorAll("blockquote");for(const n of e){const e=T(n.textContent);if(e){t.history.snapshot();const r=A(e.type,`<p>${e.body||"<br>"}</p>`);n.parentNode.replaceChild(r,n),t.eventBus.emit("content:change")}}}return e({name:"callouts",requiresFullAccess:!0,version:"1.0.0",description:"Styled callout blocks with 7 built-in types, custom types, collapsible toggle, and GFM alert syntax",commands:[{name:"insertCallout",execute(e,t={}){const{type:n="info",content:r="",collapsible:o=!1,collapsed:s=!1,title:a}=t;e.history.snapshot();const l=A(n,r,{collapsible:o,collapsed:s,title:a}),i=window.getSelection();if(i&&i.rangeCount>0&&e.element.contains(i.anchorNode)){let t=i.getRangeAt(0).startContainer;for(;t&&t.parentNode!==e.element;)t=t.parentNode;t?t.parentNode.insertBefore(l,t.nextSibling):e.element.appendChild(l)}else e.element.appendChild(l);const c=l.querySelector(".rmx-callout-body p");if(c){const e=document.createRange();e.selectNodeContents(c),e.collapse(!0),i?.removeAllRanges(),i?.addRange(e)}return e.eventBus.emit("content:change"),l},meta:{icon:"callout",tooltip:"Insert Callout"}},{name:"removeCallout",execute(e){const t=e.selection.getClosestElement?.(".rmx-callout")||_(e,"rmx-callout");if(!t)return;e.history.snapshot();const n=t.querySelector(".rmx-callout-body"),r=t.parentNode;if(n)for(;n.firstChild;)r.insertBefore(n.firstChild,t);r.removeChild(t),r.normalize(),e.eventBus.emit("content:change")},meta:{icon:"remove",tooltip:"Remove Callout"}},{name:"changeCalloutType",execute(e,t){const n=_(e,"rmx-callout");if(!n||!t)return;const r=b.get(t);if(!r)return;e.history.snapshot();const o=n.getAttribute("data-callout");n.classList.remove(`rmx-callout-${o}`),n.classList.add(`rmx-callout-${t}`),n.setAttribute("data-callout",t);const s=n.querySelector(".rmx-callout-icon"),a=n.querySelector(".rmx-callout-title");s&&(s.textContent=r.icon),a&&(a.textContent=r.label),e.eventBus.emit("content:change")},meta:{icon:"swap",tooltip:"Change Callout Type"}},{name:"toggleCalloutCollapse",execute(e){const t=_(e,"rmx-callout");if(!t)return;const n=t.querySelector(".rmx-callout-body"),r=t.querySelector(".rmx-callout-toggle");if(n){if(t.hasAttribute("data-callout-collapsible")){t.hasAttribute("data-callout-collapsed")?(t.removeAttribute("data-callout-collapsed"),n.style.display="",r&&(r.textContent="▼",r.setAttribute("aria-label","Collapse"))):(t.setAttribute("data-callout-collapsed",""),n.style.display="none",r&&(r.textContent="▶",r.setAttribute("aria-label","Expand")))}else if(t.setAttribute("data-callout-collapsible",""),!r){const e=document.createElement("button");e.className="rmx-callout-toggle",e.type="button",e.textContent="▼",e.setAttribute("aria-label","Collapse"),t.querySelector(".rmx-callout-header")?.appendChild(e)}e.eventBus.emit("content:change")}},meta:{icon:"collapse",tooltip:"Toggle Callout Collapse"}}],contextMenuItems:[{label:"Insert Callout",command:"insertCallout"},{label:"Remove Callout",command:"removeCallout",when:e=>!!_(e,"rmx-callout")}],init(e){t=e,t._callouts={getCalloutTypes:C,getCalloutType:k,registerCalloutType:v,unregisterCalloutType:w,parseGFMAlert:T},t.element.addEventListener("click",o);let a=null;r=t.eventBus.on("content:change",(()=>{clearTimeout(a),a=setTimeout(s,300)})),s(),n=new MutationObserver((()=>{const e=t.element.querySelectorAll(".rmx-callout-body");for(const t of e)t.hasAttribute("contenteditable")})),n.observe(t.element,{childList:!0,subtree:!0})},destroy(){n?.disconnect(),n=null,r?.(),t?.element?.removeEventListener("click",o),t=null}})},getCalloutType:k,getCalloutTypes:C,parseGFMAlert:T,registerCalloutType:v,unregisterCalloutType:w},Symbol.toStringTag,{value:"Module"}));function L(e,t,n=0){const r=document.createRange(),o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s=0,a=!1;for(;o.nextNode();){const e=o.currentNode,l=e.textContent.length;if(!a&&s+l>=t&&(r.setStart(e,t-s),a=!0,0===n))return r.setEnd(e,t-s),r;if(a&&s+l>=t+n)return r.setEnd(e,t+n-s),r;s+=l}return a||(r.selectNodeContents(e),r.collapse(!1)),r}function N(e,t){const n=document.createRange();n.selectNodeContents(e),n.setEnd(t.startContainer,t.startOffset);return{offset:n.toString().length,length:t.toString().length}}class R{constructor(e){this.userId=e,this._clock={[e]:0},this._pendingOps=[],this._seenOps=/* @__PURE__ */new Set,this._maxSeenOps=1e4,this._suppressRemote=!1,this._lastTextContent=null}_trackOp(e){if(this._seenOps.add(e),this._seenOps.size>this._maxSeenOps){const e=this._seenOps.size-this._maxSeenOps,t=this._seenOps.values();for(let n=0;n<e;n++)this._seenOps.delete(t.next().value)}}_tickLocal(){return this._clock[this.userId]=(this._clock[this.userId]||0)+1,{...this._clock}}_merge(e){for(const[t,n]of Object.entries(e))this._clock[t]=Math.max(this._clock[t]||0,n)}captureOperations(e,t){if(this._suppressRemote)return[];const n=t.textContent,r=this._lastTextContent;if(null===r||n===r)return this._lastTextContent=n,[];const o=[],s=this._tickLocal(),a=`${this.userId}-${this._clock[this.userId]}`;if(n.length>r.length){const{position:e,content:t}=this._findInsert(r,n),l={id:a,type:"insert",userId:this.userId,clock:s,timestamp:Date.now(),position:e,content:t};o.push(l),this._trackOp(a)}else if(n.length<r.length){const{position:e,length:t}=this._findDelete(r,n),l={id:a,type:"delete",userId:this.userId,clock:s,timestamp:Date.now(),position:e,length:t};o.push(l),this._trackOp(a)}else{const{position:e,length:t,content:l}=this._findReplace(r,n);if(void 0!==l){const n={id:a,type:"replace",userId:this.userId,clock:s,timestamp:Date.now(),position:e,length:t,content:l};o.push(n),this._trackOp(a)}}return this._lastTextContent=n,o}_findInsert(e,t){let n=0;for(;n<e.length&&e[n]===t[n];)n++;const r=t.length-e.length;return{position:n,content:t.substring(n,n+r)}}_findDelete(e,t){let n=0;for(;n<t.length&&e[n]===t[n];)n++;return{position:n,length:e.length-t.length}}_findReplace(e,t){let n=0;for(;n<e.length&&e[n]===t[n];)n++;if(n>=e.length)return{};let r=e.length-1,o=t.length-1;for(;r>n&&e[r]===t[o];)r--,o--;return{position:n,length:r-n+1,content:t.substring(n,o+1)}}_transformPosition(e,t){if("insert"===t.type){if(t.position<=e)return e+t.content.length}else if("delete"===t.type){if(t.position+t.length<=e)return e-t.length;if(t.position<e)return t.position}else if("replace"===t.type){if(t.position+t.length<=e)return e+(t.content.length-t.length);if(t.position<e)return t.position+t.content.length}return e}applyRemoteOperations(e,t){const n=e.filter((e=>!this._seenOps.has(e.id)));if(0!==n.length){n.sort(((e,t)=>{const n=Object.values(e.clock).reduce(((e,t)=>e+t),0),r=Object.values(t.clock).reduce(((e,t)=>e+t),0);return n!==r?n-r:e.timestamp!==t.timestamp?e.timestamp-t.timestamp:e.userId.localeCompare(t.userId)})),this._suppressRemote=!0;for(const e of n)this._trackOp(e.id),this._applyOp(e,t);this._lastTextContent=t.textContent,this._suppressRemote=!1}}_applyOp(e,t){try{if("insert"===e.type){const n=L(t,e.position);n&&(n.collapse(!0),n.insertNode(document.createTextNode(e.content)),t.normalize())}else if("delete"===e.type){const n=L(t,e.position,e.length);n&&(n.deleteContents(),t.normalize())}else if("replace"===e.type){const n=L(t,e.position,e.length);n&&(n.deleteContents(),n.insertNode(document.createTextNode(e.content)),t.normalize())}}catch(n){}}queueOperation(e){this._pendingOps.push(e)}flushQueue(){const e=[...this._pendingOps];return this._pendingOps=[],e}hasPendingOps(){return this._pendingOps.length>0}initTextContent(e){this._lastTextContent=e.textContent}getState(){return{clock:{...this._clock},pendingOps:this._pendingOps.length,seenOps:this._seenOps.size}}destroy(){this._pendingOps=[],this._seenOps.clear(),this._lastTextContent=null}}class I{constructor(e,t,n){this.userId=e,this._localState={cursor:null,userName:t,userColor:n,status:"active",lastActive:Date.now()},this._remoteStates=/* @__PURE__ */new Map,this._broadcastInterval=null,this._idleTimer=null,this._cursorsContainer=null,this._renderRafId=null}updateLocalCursor(e,t){try{const t=window.getSelection();if(!t||0===t.rangeCount||!e.contains(t.anchorNode))return void(this._localState.cursor=null);const n=t.getRangeAt(0);this._localState.cursor=N(e,n),this._localState.lastActive=Date.now()}catch{this._localState.cursor=null}}setStatus(e){this._localState.status=e}resetIdleTimer(){this._localState.status="active",this._localState.lastActive=Date.now(),clearTimeout(this._idleTimer),this._idleTimer=setTimeout((()=>{this._localState.status="idle"}),3e4)}applyRemoteAwareness(e,t){e!==this.userId&&this._remoteStates.set(e,{...t})}removeUser(e){this._remoteStates.delete(e)}getCollaborators(){return Array.from(this._remoteStates.entries()).map((([e,t])=>({userId:e,userName:t.userName,userColor:t.userColor,cursor:t.cursor,status:t.status})))}renderRemoteCursors(e){this._renderRafId&&cancelAnimationFrame(this._renderRafId),this._renderRafId=requestAnimationFrame((()=>{this._doRender(e)}))}_doRender(e){this._cursorsContainer||(this._cursorsContainer=document.createElement("div"),this._cursorsContainer.className="rmx-collab-cursors-container",this._cursorsContainer.setAttribute("aria-hidden","true"),e.parentNode?.insertBefore(this._cursorsContainer,e.nextSibling)),this._cursorsContainer.innerHTML="";const t=e.getBoundingClientRect();let n=0;for(const[r,o]of this._remoteStates)if(o.cursor&&"offline"!==o.status){if(n>=20)break;n++;try{const n=L(e,o.cursor.offset,o.cursor.length);if(!n)continue;const r=n.getClientRects();if(0===r.length)continue;const s=r[0],a=document.createElement("div");a.className="rmx-collab-cursor",a.style.cssText=`\n left: ${s.left-t.left}px;\n top: ${s.top-t.top}px;\n height: ${s.height}px;\n background-color: ${o.userColor};\n `;const l=document.createElement("span");if(l.className="rmx-collab-cursor-label",l.textContent=o.userName,l.style.backgroundColor=o.userColor,a.appendChild(l),this._cursorsContainer.appendChild(a),o.cursor.length>0)for(const e of r){const n=document.createElement("div");n.className="rmx-collab-selection",n.style.cssText=`\n left: ${e.left-t.left}px;\n top: ${e.top-t.top}px;\n width: ${e.width}px;\n height: ${e.height}px;\n background-color: ${o.userColor};\n `,this._cursorsContainer.appendChild(n)}}catch{}}}clearRemoteCursors(e){this._cursorsContainer&&(this._cursorsContainer.innerHTML="")}getLocalState(){return{...this._localState}}startBroadcasting(e,t=1e3){this.stopBroadcasting(),this._broadcastInterval=setInterval((()=>{e(this.getLocalState())}),t)}stopBroadcasting(){this._broadcastInterval&&(clearInterval(this._broadcastInterval),this._broadcastInterval=null)}destroy(){this.stopBroadcasting(),clearTimeout(this._idleTimer),this._renderRafId&&cancelAnimationFrame(this._renderRafId),this._cursorsContainer&&(this._cursorsContainer.remove(),this._cursorsContainer=null),this._remoteStates.clear()}}class O{constructor(e,t={}){this._url=e,this._reconnect=!1!==t.reconnect,this._reconnectInterval=t.reconnectInterval||2e3,this._maxAttempts=t.maxReconnectAttempts||10,this._maxDelay=t.maxReconnectDelay||3e4,this._ws=null,this._messageHandler=null,this._connectHandler=null,this._disconnectHandler=null,this._reconnectTimer=null,this._reconnectAttempts=0,this._intentionalClose=!1}connect(){if(!this._ws||this._ws.readyState!==WebSocket.OPEN){this._intentionalClose=!1,this._reconnectAttempts=0;try{this._ws=new WebSocket(this._url)}catch(e){return void this._scheduleReconnect()}this._ws.onopen=()=>{this._reconnectAttempts=0,this._connectHandler?.()},this._ws.onmessage=t=>{try{const e=JSON.parse(t.data);this._messageHandler?.(e)}catch(e){}},this._ws.onclose=()=>{this._disconnectHandler?.(),!this._intentionalClose&&this._reconnect&&this._scheduleReconnect()},this._ws.onerror=()=>{}}}disconnect(){this._intentionalClose=!0,clearTimeout(this._reconnectTimer),this._reconnectTimer=null,this._ws&&(this._ws.onclose=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onopen=null,this._ws.readyState!==WebSocket.OPEN&&this._ws.readyState!==WebSocket.CONNECTING||this._ws.close(),this._ws=null)}send(e){this._ws&&this._ws.readyState===WebSocket.OPEN&&this._ws.send(JSON.stringify(e))}onMessage(e){this._messageHandler=e}onConnect(e){this._connectHandler=e}onDisconnect(e){this._disconnectHandler=e}isConnected(){return this._ws?.readyState===WebSocket.OPEN}_scheduleReconnect(){if(this._reconnectAttempts>=this._maxAttempts)return;const e=Math.min(this._reconnectInterval*Math.pow(2,this._reconnectAttempts),this._maxDelay);this._reconnectAttempts++,this._reconnectTimer=setTimeout((()=>{this.connect()}),e)}destroy(){this.disconnect(),this._messageHandler=null,this._connectHandler=null,this._disconnectHandler=null}}const B=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,AwarenessProtocol:I,CollaborationPlugin:function(t={}){const{signalingServer:n,transport:r,userId:o=`user-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,userName:s="Anonymous",userColor:a="#6366f1",roomId:l="default",autoConnect:i=!0,broadcastInterval:c=1e3,onUserJoin:u,onUserLeave:m,onSync:d,onConflict:p}=t;let g=null,h=null,f=null,y=null,b=null,x=[],v=!1;function w(e){if(g)switch(e.type){case"op":{if(e.userId===o)return;const t=window.getSelection();let n=null;if(t&&t.rangeCount>0&&g.element.contains(t.anchorNode))try{const e=t.getRangeAt(0);n={startOffset:e.startOffset,startContainer:e.startContainer}}catch{}if(g._isRemoteOperation=!0,f.applyRemoteOperations(e.operations,g.element),f._merge(e.clock),g._isRemoteOperation=!1,n)try{const e=document.createRange();e.setStart(n.startContainer,Math.min(n.startOffset,n.startContainer.length||0)),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}catch{}g.eventBus.emit("collab:sync",{userId:e.userId,opCount:e.operations.length}),g.eventBus.emit("content:change"),d?.({userId:e.userId,operations:e.operations});break}case"awareness":if(e.userId===o)return;y.applyRemoteAwareness(e.userId,e.state),y.renderRemoteCursors(g.element);break;case"join":if(e.userId===o)return;y.applyRemoteAwareness(e.userId,{userName:e.userName,userColor:e.userColor,status:"active",cursor:null,lastActive:Date.now()}),g.eventBus.emit("collab:userJoin",{userId:e.userId,userName:e.userName}),u?.({userId:e.userId,userName:e.userName});break;case"leave":if(e.userId===o)return;y.removeUser(e.userId),y.renderRemoteCursors(g.element),g.eventBus.emit("collab:userLeave",{userId:e.userId}),m?.({userId:e.userId});break;case"sync-request":if(e.userId===o)return;h?.send({type:"sync-response",roomId:l,userId:o,html:g.getHTML(),clock:f._clock});break;case"sync-response":if(e.userId===o)return;Object.entries(e.clock).some((([e,t])=>(f._clock[e]||0)<t))&&(g._isRemoteOperation=!0,g.setHTML(e.html),f._merge(e.clock),f.initTextContent(g.element),g._isRemoteOperation=!1,g.eventBus.emit("content:change"));break}}function C(){h&&!v&&(h.onMessage(w),h.onConnect((()=>{v=!0,h.send({type:"join",roomId:l,userId:o,userName:s,userColor:a}),h.send({type:"sync-request",roomId:l,userId:o,clock:f._clock});const e=f.flushQueue();e.length>0&&h.send({type:"op",roomId:l,userId:o,clock:f._clock,operations:e,timestamp:Date.now()}),y.setStatus("active"),y.startBroadcasting((e=>{h.send({type:"awareness",roomId:l,userId:o,state:e})}),c),g?.eventBus.emit("collab:connected")})),h.onDisconnect((()=>{v=!1,y.setStatus("offline"),y.stopBroadcasting(),g&&(y.clearRemoteCursors(g.element),g.eventBus.emit("collab:disconnected"))})),h.connect())}function k(){h&&(v&&h.send({type:"leave",roomId:l,userId:o}),y.stopBroadcasting(),g&&y.clearRemoteCursors(g.element),h.disconnect(),v=!1)}function S(){return h?h.isConnected()?"connected":"disconnected":"unconfigured"}function T(e){e.userName&&(y._localState.userName=e.userName),e.userColor&&(y._localState.userColor=e.userColor)}return e({name:"collaboration",version:"1.0.0",description:"Real-time collaborative editing with CRDT-inspired conflict resolution, live cursors, and configurable transport",requiresFullAccess:!0,commands:[{name:"startCollaboration",execute(){C()},meta:{icon:"collaboration",tooltip:"Start Collaboration"}},{name:"stopCollaboration",execute(){k()},meta:{icon:"collaboration",tooltip:"Stop Collaboration"}},{name:"getCollaborators",execute:()=>y?.getCollaborators()??[],meta:{tooltip:"Get Collaborators"}},{name:"setUserInfo",execute(e,t){T(t)},meta:{tooltip:"Set User Info"}}],init(e){g=e,f=new R(o),y=new I(o,s,a),r?h=r:n&&(h=new O(n)),f.initTextContent(g.element),g._collaboration={startCollaboration:C,stopCollaboration:k,getCollaborators:()=>y.getCollaborators(),isConnected:()=>h?.isConnected()??!1,getConnectionStatus:S,setUserInfo:T,getCrdtState:()=>f.getState(),userId:o,userName:s,userColor:a},b=new MutationObserver((e=>{if(f._suppressRemote||g._isRemoteOperation)return;const t=f.captureOperations(e,g.element);t.length>0&&(h?.isConnected()?h.send({type:"op",roomId:l,userId:o,clock:{...f._clock},operations:t,timestamp:Date.now()}):t.forEach((e=>f.queueOperation(e))))})),b.observe(g.element,{childList:!0,subtree:!0,characterData:!0,characterDataOldValue:!0});const t=g.eventBus.on("selection:change",(()=>{y.updateLocalCursor(g.element,g.selection),y.resetIdleTimer()}));x.push(t);const c=g.eventBus.on("content:change",(()=>{y.renderRemoteCursors(g.element)}));x.push(c),i&&h&&C()},destroy(){k(),b?.disconnect(),b=null;for(const e of x)e?.();x=[],f?.destroy(),y?.destroy(),h&&!r&&h.destroy?.(),g=null,h=null,f=null,y=null}})},CrdtEngine:R,WebSocketTransport:O,offsetToRange:L,rangeToOffset:N},Symbol.toStringTag,{value:"Module"}));let M=1;function D(){return`rmx-comment-${Date.now()}-${M++}`}function q(e){if(!e)return[];const t=e.match(/@([\w.-]+)/g);return t?t.map((e=>e.slice(1))):[]}const $=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,CommentsPlugin:function(t={}){const{onComment:n,onResolve:r,onDelete:o,onReply:s,mentionUsers:a=[],commentOnly:l=!1}=t,i=/* @__PURE__ */new Map;let c=null,u=null,m=null,d=null;function p(){return Array.from(i.values()).sort(((e,t)=>t.createdAt-e.createdAt))}function g(e){return i.get(e)}function h(){return p().filter((e=>!e.resolved))}function f(){return p().filter((e=>e.resolved))}function y({author:e="Anonymous",body:t=""}={}){if(!c)return null;const r=window.getSelection();if(!r||r.isCollapsed||0===r.rangeCount)return null;const o=r.getRangeAt(0);if(!c.element.contains(o.commonAncestorContainer))return null;const s=D(),a=Date.now(),l={id:s,author:e,body:t,mentions:q(t),resolved:!1,createdAt:a,updatedAt:a,replies:[]};c.history.snapshot();const u=document.createElement("mark");u.className="rmx-comment",u.setAttribute("data-comment-id",s),u.setAttribute("data-comment-resolved","false"),u.setAttribute("title",`${e}: ${t}`);try{o.surroundContents(u)}catch{const e=o.extractContents();u.appendChild(e),o.insertNode(u)}return r.removeAllRanges(),i.set(s,l),c.eventBus.emit("comment:created",{thread:l}),c.eventBus.emit("content:change"),n?.(l),l}function b(e,{author:t="Anonymous",body:n=""}={}){const r=i.get(e);if(!r)return null;const o={id:D(),author:t,body:n,mentions:q(n),createdAt:Date.now()};return r.replies.push(o),r.updatedAt=Date.now(),c?.eventBus.emit("comment:replied",{thread:r,reply:o}),s?.({thread:r,reply:o}),o}function x(e,t=!0){const n=i.get(e);if(!n)return;n.resolved=t,n.updatedAt=Date.now();const o=c?.element.querySelector(`[data-comment-id="${e}"]`);o&&(o.setAttribute("data-comment-resolved",String(t)),t?o.classList.add("rmx-comment-resolved"):o.classList.remove("rmx-comment-resolved")),c?.eventBus.emit("comment:resolved",{thread:n,resolved:t}),r?.({thread:n,resolved:t})}function v(e){const t=i.get(e);if(!t)return;const n=c?.element.querySelector(`[data-comment-id="${e}"]`);if(n){c.history.snapshot();const e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n),e.normalize(),c.eventBus.emit("content:change")}i.delete(e),c?.eventBus.emit("comment:deleted",{thread:t}),o?.(t)}function w(e,t){const n=i.get(e);if(!n)return;n.body=t,n.mentions=q(t),n.updatedAt=Date.now();const r=c?.element.querySelector(`[data-comment-id="${e}"]`);r&&r.setAttribute("title",`${n.author}: ${t}`),c?.eventBus.emit("comment:updated",{thread:n})}function C(e){const t=c?.element.querySelector(`[data-comment-id="${e}"]`);if(!t)return;t.scrollIntoView?.({behavior:"smooth",block:"center"});const n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),n.removeAllRanges(),n.addRange(r),c?.eventBus.emit("comment:navigated",{threadId:e})}function k(e){for(const t of e)i.set(t.id,{...t});c?.eventBus.emit("comment:imported",{count:e.length})}function S(){return p().map((e=>({...e,replies:[...e.replies]})))}function T(){if(c)for(const[e]of i){c.element.querySelector(`[data-comment-id="${e}"]`)||i.delete(e)}}function A(){return[...a]}return e({name:"comments",requiresFullAccess:!0,commands:[{name:"addComment",execute:(e,t)=>y(t),isEnabled(e){const t=window.getSelection();return t&&!t.isCollapsed&&e.element.contains(t.anchorNode)},meta:{icon:"comment",tooltip:"Add Comment"}},{name:"deleteComment",execute(e,t){v(t)},meta:{icon:"trash",tooltip:"Delete Comment"}},{name:"resolveComment",execute(e,t,n){x(t,n)},meta:{icon:"check",tooltip:"Resolve Comment"}},{name:"replyToComment",execute:(e,t,n)=>b(t,n),meta:{icon:"reply",tooltip:"Reply to Comment"}},{name:"editComment",execute(e,t,n){w(t,n)},meta:{icon:"edit",tooltip:"Edit Comment"}},{name:"navigateToComment",execute(e,t){C(t)},meta:{icon:"navigate",tooltip:"Go to Comment"}}],contextMenuItems:[{label:"Add Comment",command:"addComment",when:e=>{const t=window.getSelection();return t&&!t.isCollapsed}}],init(e){c=e,c._comments={addComment:y,deleteComment:v,resolveComment:x,replyToComment:b,editComment:w,navigateToComment:C,getAllThreads:p,getThread:g,getUnresolvedThreads:h,getResolvedThreads:f,importThreads:k,exportThreads:S,syncWithDOM:T,getMentionUsers:A},l&&(c.element.setAttribute("contenteditable","false"),c.element.classList.add("rmx-comment-only"));const t=c.element.querySelectorAll("[data-comment-id]");for(const n of t){const e=n.getAttribute("data-comment-id");i.has(e)||i.set(e,{id:e,author:"Imported",body:n.getAttribute("title")||"",mentions:[],resolved:"true"===n.getAttribute("data-comment-resolved"),createdAt:Date.now(),updatedAt:Date.now(),replies:[]})}u=c.eventBus.on("content:change",(()=>{clearTimeout(d),d=setTimeout(T,100)})),c.element.addEventListener("click",_),m=c.eventBus.on("destroy",E)},destroy(){E()}});function _(e){const t=e.target.closest?.("[data-comment-id]");if(t){const e=t.getAttribute("data-comment-id"),n=i.get(e);n&&c.eventBus.emit("comment:clicked",{thread:n,element:t})}}function E(){clearTimeout(d),d=null,u?.(),m?.(),c?.element?.removeEventListener("click",_),l&&c?.element&&(c.element.removeAttribute("contenteditable"),c.element.classList.remove("rmx-comment-only")),c=null}},parseMentions:q},Symbol.toStringTag,{value:"Module"})),P="rmx-drop-zone",j="rmx-drop-zone-active",H="rmx-drop-indicator",z="rmx-dragging";function F(e,t){const n=Array.from(e.children).filter((e=>!e.classList.contains(H)&&!e.classList.contains(P)));let r=null,o=1/0,s="after";for(const a of n){const e=a.getBoundingClientRect(),n=e.top+e.height/2,l=Math.abs(t-n);l<o&&(o=l,r=a,s=t<n?"before":"after")}return{element:r,position:s}}function W(e,t){let n=e;for(;n&&n!==t&&n.parentNode!==t;)n=n.parentNode;return n!==t?n:null}const U=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,DragDropPlugin:function(t={}){const{onDrop:n,onFileDrop:r,allowExternalDrop:o=!0,showDropZone:s=!0,enableReorder:a=!0}=t;let l=null,i=null,c=null,u=null;function m(e){if(!l||!a)return;const t=W(e.target,l.element);t&&(c=t,t.classList.add(z),u=t.cloneNode(!0),u.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0.6;pointer-events:none;max-width:400px;",document.body.appendChild(u),e.dataTransfer.setDragImage(u,20,20),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/x-remyx-block","true"),e.dataTransfer.setData("text/html",t.outerHTML))}function d(e){if(l&&(e.preventDefault(),e.dataTransfer.dropEffect="move",s&&l.element.classList.add(j),a&&i)){const{element:t,position:n}=F(l.element,e.clientY);if(t){const e=t.getBoundingClientRect(),r=l.element.getBoundingClientRect(),o="before"===n?e.top-r.top-2:e.bottom-r.top+1;i.style.top=`${o}px`,i.style.display="block"}}}function p(e){l&&(l.element.contains(e.relatedTarget)||(l.element.classList.remove(j),i&&(i.style.display="none")))}function g(e){if(!l)return;if(e.preventDefault(),l.element.classList.remove(j),i&&(i.style.display="none"),l.history.snapshot(),c&&l.element.contains(c)){const{element:t,position:r}=F(l.element,e.clientY);return t&&t!==c&&("before"===r?t.before(c):t.after(c),l.eventBus.emit("content:change"),l.eventBus.emit("dragdrop:reorder",{block:c})),f(),void n?.(e,{type:"reorder"})}if(e.dataTransfer.getData("text/x-remyx-block")){const t=e.dataTransfer.getData("text/html");if(t){const{element:r,position:o}=F(l.element,e.clientY),s=document.createElement("div");s.innerHTML=t;const a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);r?"before"===o?r.before(a):r.after(a):l.element.appendChild(a),l.eventBus.emit("content:change"),l.eventBus.emit("dragdrop:crossEditor",{}),n?.(e,{type:"crossEditor",html:t})}f()}else{if(o&&e.dataTransfer.files.length>0){const t=Array.from(e.dataTransfer.files);r?.(t),l.eventBus.emit("dragdrop:fileDrop",{files:t});for(const n of t)if(n.type.startsWith("image/")){const t=new FileReader;t.onload=()=>{const n=document.createElement("img");n.src=t.result,n.style.maxWidth="100%";const{element:r,position:o}=F(l.element,e.clientY);r?"before"===o?r.before(n):r.after(n):l.element.appendChild(n),l.eventBus.emit("content:change")},t.readAsDataURL(n)}return f(),void n?.(e,{type:"file",files:t})}if(o){const t=e.dataTransfer.getData("text/html"),r=e.dataTransfer.getData("text/plain"),o=t||(r?`<p>${r.replace(/\n/g,"</p><p>")}</p>`:"");if(o){const{element:t,position:r}=F(l.element,e.clientY),s=document.createElement("div");s.innerHTML=o;const a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);t?"before"===r?t.before(a):t.after(a):l.element.appendChild(a),l.eventBus.emit("content:change"),l.eventBus.emit("dragdrop:externalDrop",{html:o}),n?.(e,{type:"external",html:o})}}f()}}function h(){f()}function f(){c&&(c.classList.remove(z),c=null),u&&(u.remove(),u=null),l?.element?.classList.remove(j),i&&(i.style.display="none")}function y(e){if(!l||!a)return;const t=W(e.target,l.element);if(!t)return;const n=t.getBoundingClientRect();e.clientX-n.left<30&&(t.draggable=!0,t.addEventListener("dragend",(()=>{t.draggable=!1}),{once:!0}))}return e({name:"dragDrop",requiresFullAccess:!0,version:"1.0.0",description:"Drop zones, cross-editor drag, file drops, block reorder, ghost previews",commands:[{name:"moveBlockUp",execute(e){const t=e.selection?.getParentBlock?.();if(!t)return;let n=t;for(;n.parentNode!==e.element;)n=n.parentNode;const r=n.previousElementSibling;r&&(e.history.snapshot(),r.before(n),e.eventBus.emit("content:change"))},shortcut:"mod+shift+ArrowUp",meta:{icon:"arrow-up",tooltip:"Move Block Up"}},{name:"moveBlockDown",execute(e){const t=e.selection?.getParentBlock?.();if(!t)return;let n=t;for(;n.parentNode!==e.element;)n=n.parentNode;const r=n.nextElementSibling;r&&(e.history.snapshot(),r.after(n),e.eventBus.emit("content:change"))},shortcut:"mod+shift+ArrowDown",meta:{icon:"arrow-down",tooltip:"Move Block Down"}}],init(e){l=e,a&&(i=function(){const e=document.createElement("div");return e.className=H,e.style.cssText="position:absolute;left:0;right:0;height:3px;background:var(--rmx-primary,#6366f1);border-radius:2px;pointer-events:none;z-index:100;transition:top 0.1s ease;",e}(),i.style.display="none",l.element.style.position="relative",l.element.appendChild(i)),l.element.addEventListener("dragstart",m),l.element.addEventListener("dragover",d),l.element.addEventListener("dragleave",p),l.element.addEventListener("drop",g),l.element.addEventListener("dragend",h),l.element.addEventListener("mousedown",y),s&&l.element.classList.add(P),l._dragDrop={getDropTarget:e=>F(l.element,e)}},destroy(){l?.element?.removeEventListener("dragstart",m),l?.element?.removeEventListener("dragover",d),l?.element?.removeEventListener("dragleave",p),l?.element?.removeEventListener("drop",g),l?.element?.removeEventListener("dragend",h),l?.element?.removeEventListener("mousedown",y),i?.remove(),f(),l?.element?.classList.remove(P,j),l=null}})}},Symbol.toStringTag,{value:"Module"})),G={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},V=new Set(Object.values(G)),K="normal",J="insert",Z="visual";function X(){return{mode:K,pending:""}}const Y={"ctrl+a":"moveToLineStart","ctrl+e":"moveToLineEnd","ctrl+k":"killToLineEnd","ctrl+y":"yank","ctrl+w":"killWord","ctrl+f":"moveForward","ctrl+b":"moveBackward","ctrl+n":"moveDown","ctrl+p":"moveUp","ctrl+d":"deleteForward","ctrl+h":"deleteBackward","ctrl+space":"setMark"};function Q(e){const t=e.querySelectorAll("h1, h2, h3, h4, h5, h6");return Array.from(t).map((e=>({level:parseInt(e.tagName.charAt(1),10),text:e.textContent,element:e})))}function ee(e){const t=window.getSelection();if(!t||0===t.rangeCount)return 0;const n=t.toString();if(!n)return 0;const r=t.getRangeAt(t.rangeCount-1).endOffset,o=e.textContent,s=o.indexOf(n,-1===o.indexOf(n,r)?0:r+1);if(-1===s)return t.rangeCount;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let l=0;for(;a.nextNode();){const e=a.currentNode,r=e.textContent.length;if(l+r>s){const o=s-l,a=document.createRange();a.setStart(e,o),a.setEnd(e,Math.min(o+n.length,r)),t.addRange(a);break}l+=r}return t.rangeCount}const te=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,KeyboardPlugin:function(t={}){const{mode:n="default",keyBindings:r={},autoPair:o=!0,jumpToHeading:s=!0}=t;let a=null,l=null,i="";function c(e){if(!a)return;if("vim"===n&&l)return void function(e){if(l.mode===J)return"Escape"===e.key?(e.preventDefault(),l.mode=K,a.element.classList.remove("rmx-vim-insert"),a.element.classList.add("rmx-vim-normal"),void a.eventBus.emit("vim:modeChange",{mode:K})):void(o&&u(e));e.preventDefault();const t=window.getSelection();switch(e.key){case"i":l.mode=J,a.element.classList.remove("rmx-vim-normal"),a.element.classList.add("rmx-vim-insert"),a.eventBus.emit("vim:modeChange",{mode:J});break;case"a":if(l.mode=J,t&&t.rangeCount>0){t.getRangeAt(0).collapse(!1)}a.element.classList.remove("rmx-vim-normal"),a.element.classList.add("rmx-vim-insert"),a.eventBus.emit("vim:modeChange",{mode:J});break;case"v":l.mode=Z,a.element.classList.add("rmx-vim-visual"),a.eventBus.emit("vim:modeChange",{mode:Z});break;case"Escape":l.mode===Z&&(l.mode=K,a.element.classList.remove("rmx-vim-visual"),t?.collapseToStart(),a.eventBus.emit("vim:modeChange",{mode:K}));break;case"h":t?.modify("move","backward","character");break;case"l":t?.modify("move","forward","character");break;case"j":t?.modify("move","forward","line");break;case"k":t?.modify("move","backward","line");break;case"w":t?.modify("move","forward","word");break;case"b":t?.modify("move","backward","word");break;case"0":t?.modify("move","backward","lineboundary");break;case"$":t?.modify("move","forward","lineboundary");break;case"G":if(t&&a.element.lastChild){const e=document.createRange();e.selectNodeContents(a.element.lastChild),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}break;case"u":a.executeCommand("undo");break;case"x":a.history.snapshot(),document.execCommand("delete");break;case"d":if("d"===l.pending){l.pending="",a.history.snapshot();const e=a.selection?.getParentBlock?.();e&&e.remove(),a.eventBus.emit("content:change")}else l.pending="d";break;case"o":a.history.snapshot();{const e=a.selection?.getParentBlock?.()||a.element.lastChild,n=document.createElement("p");n.innerHTML="<br>",e?.after(n);const r=document.createRange();r.selectNodeContents(n),r.collapse(!0),t?.removeAllRanges(),t?.addRange(r)}l.mode=J,a.element.classList.remove("rmx-vim-normal"),a.element.classList.add("rmx-vim-insert"),a.eventBus.emit("vim:modeChange",{mode:J}),a.eventBus.emit("content:change");break;default:l.pending=""}}(e);"emacs"===n&&function(e){if(!e.ctrlKey)return;const t=`ctrl+${e.key}`,n=Y[t];if(!n)return;e.preventDefault();const r=window.getSelection(),o=r?.rangeCount>0?r.getRangeAt(0):null;switch(n){case"moveToLineStart":r?.modify("move","backward","lineboundary");break;case"moveToLineEnd":r?.modify("move","forward","lineboundary");break;case"moveForward":r?.modify("move","forward","character");break;case"moveBackward":r?.modify("move","backward","character");break;case"moveDown":r?.modify("move","forward","line");break;case"moveUp":r?.modify("move","backward","line");break;case"deleteForward":document.execCommand("forwardDelete");break;case"deleteBackward":document.execCommand("delete");break;case"killToLineEnd":o&&(a.history.snapshot(),r.modify("extend","forward","lineboundary"),i=r.toString(),o.deleteContents(),a.eventBus.emit("content:change"));break;case"yank":i&&o&&(a.history.snapshot(),o.insertNode(document.createTextNode(i)),o.collapse(!1),a.eventBus.emit("content:change"));break;case"killWord":o&&(a.history.snapshot(),r.modify("extend","backward","word"),i=r.toString(),o.deleteContents(),a.eventBus.emit("content:change"))}}(e);const t=function(e){const t=[];e.ctrlKey&&t.push("ctrl");e.metaKey&&t.push("cmd");e.altKey&&t.push("alt");e.shiftKey&&t.push("shift");1===e.key.length?t.push(e.key.toLowerCase()):t.push(e.key);return t.join("+")}(e);if(!r[t]){if(o&&"vim"!==n&&u(e),s){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"g"===e.key)return e.preventDefault(),void a.eventBus.emit("keyboard:jumpToHeading")}return!e.metaKey&&!e.ctrlKey||"d"!==e.key||e.shiftKey?void 0:(e.preventDefault(),void ee(a.element))}{e.preventDefault();const n=r[t];"function"==typeof n?n(a):"string"==typeof n&&a.executeCommand(n)}}function u(e){if(1!==e.key.length||e.metaKey||e.ctrlKey||e.altKey)return;const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0);if(G[e.key]){const r=G[e.key];if(!n.collapsed){e.preventDefault();const t=n.toString();return n.deleteContents(),void n.insertNode(document.createTextNode(e.key+t+r))}e.preventDefault();const o=document.createTextNode(e.key+r);return n.insertNode(o),n.setStart(o,1),n.setEnd(o,1),t.removeAllRanges(),t.addRange(n),void a.eventBus.emit("content:change")}if(V.has(e.key)&&n.collapsed){const r=n.startContainer;if(3===r.nodeType&&r.textContent.charAt(n.startOffset)===e.key)return e.preventDefault(),n.setStart(r,n.startOffset+1),n.collapse(!0),t.removeAllRanges(),void t.addRange(n)}}return e({name:"keyboard",requiresFullAccess:!0,version:"1.0.0",description:"Vim/Emacs modes, auto-pairing, multi-cursor, jump-to-heading",commands:[{name:"setKeyboardMode",execute(e,t){"vim"===t?(l=X(),e.element.classList.add("rmx-vim-normal"),e.eventBus.emit("vim:modeChange",{mode:K})):(l=null,e.element.classList.remove("rmx-vim-normal","rmx-vim-insert","rmx-vim-visual")),e.eventBus.emit("keyboard:modeChange",{mode:t})},meta:{tooltip:"Set Keyboard Mode"}},{name:"getVimMode",execute:()=>l?.mode||null,meta:{tooltip:"Get Vim Mode"}},{name:"jumpToHeading",execute(e,t){!function(e,t){const n=Q(e);if(t<0||t>=n.length)return;const r=n[t];r.element.scrollIntoView?.({behavior:"smooth",block:"center"});const o=window.getSelection(),s=document.createRange();s.selectNodeContents(r.element),s.collapse(!0),o.removeAllRanges(),o.addRange(s)}(e.element,t)},meta:{icon:"heading",tooltip:"Jump to Heading"}},{name:"getHeadings",execute:e=>Q(e.element),meta:{tooltip:"Get Headings"}},{name:"selectNextOccurrence",execute:e=>ee(e.element),shortcut:"mod+d",meta:{tooltip:"Select Next Occurrence"}}],init(e){a=e,"vim"===n&&(l=X(),a.element.classList.add("rmx-vim-normal")),a.element.addEventListener("keydown",c,!0),a._keyboard={getHeadings:()=>Q(a.element),getVimMode:()=>l?.mode||null,selectNextOccurrence:()=>ee(a.element)}},destroy(){a?.element?.removeEventListener("keydown",c,!0),a?.element?.classList.remove("rmx-vim-normal","rmx-vim-insert","rmx-vim-visual"),l=null,a=null}})},getHeadings:Q,selectNextOccurrence:ee},Symbol.toStringTag,{value:"Module"})),ne=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,re=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,oe=/(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/g;function se(e){const t=[];let n;for(ne.lastIndex=0;null!==(n=ne.exec(e));)t.push({type:"url",value:n[0],index:n.index});for(re.lastIndex=0;null!==(n=re.exec(e));){const e=n.index;t.some((t=>e>=t.index&&e<t.index+t.value.length))||t.push({type:"email",value:n[0],index:n.index})}for(oe.lastIndex=0;null!==(n=oe.exec(e));)t.push({type:"phone",value:n[0],index:n.index});return t.sort(((e,t)=>e.index-t.index))}function ae(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"anchor"}let le=null;function ie(){le&&(le.remove(),le=null)}function ce(e){return e?t(e):""}const ue=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,LinkPlugin:function(t={}){const{onLinkClick:n,onUnfurl:r,onSuggest:o,onBrokenLink:s,validateLink:a,scanInterval:l=6e4,autoLink:i=!0,showPreviews:c=!0}=t;let u=null,m=null,d=null,p=null;const g=/* @__PURE__ */new Map,h=/* @__PURE__ */new Set;function f(e){if(!i||!u)return;if(" "!==e.key&&"Enter"!==e.key)return;const t=window.getSelection();if(!t||0===t.rangeCount||!t.isCollapsed)return;const n=t.getRangeAt(0),r=n.startContainer;if(3!==r.nodeType)return;if(r.parentElement?.closest("a"))return;if(!u.element.contains(r))return;const o=se(r.textContent.substring(0,n.startOffset));if(0===o.length)return;const s=o[o.length-1],a=s.index+s.value.length;if(a!==n.startOffset)return;e.preventDefault(),u.history.snapshot();const l="email"===(c=s).type?`mailto:${c.value}`:"phone"===c.type?`tel:${c.value.replace(/[^\d+]/g,"")}`:c.value.startsWith("www.")?`https://${c.value}`:c.value;var c;const m=document.createRange();m.setStart(r,s.index),m.setEnd(r,a);const d=document.createElement("a");d.href=l,d.target="_blank",d.rel="noopener noreferrer",d.textContent=s.value,m.deleteContents(),m.insertNode(d);const p=document.createTextNode(" "===e.key?" ":"");if(d.after(p),"Enter"===e.key){const e=document.createElement("br");d.after(e);const n=document.createTextNode("");e.after(n);const r=document.createRange();r.setStart(n,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r)}else{const e=document.createRange();e.setStartAfter(p),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}r.parentNode?.normalize(),u.eventBus.emit("content:change")}function y(e){const t=e.target.closest?.("a[href]");t&&u?.element.contains(t)&&n&&n({href:t.href,text:t.textContent,target:t.target,timestamp:Date.now(),element:t})}function b(e){if(!c||!r)return;const t=e.target.closest?.("a[href]");t&&u?.element.contains(t)&&(clearTimeout(d),d=setTimeout((async()=>{const e=t.href;try{let n=g.get(e);n||(n=await r(e),n&&g.set(e,n)),n&&function(e,t,n){ie();const r=e.getBoundingClientRect(),o=n.getBoundingClientRect();le=document.createElement("div"),le.className="rmx-link-preview",le.innerHTML=`\n ${t.image?`<img class="rmx-link-preview-img" src="${t.image}" alt="" />`:""}\n <div class="rmx-link-preview-text">\n <div class="rmx-link-preview-title">${ce(t.title||e.href)}</div>\n ${t.description?`<div class="rmx-link-preview-desc">${ce(t.description)}</div>`:""}\n <div class="rmx-link-preview-url">${ce(e.href)}</div>\n </div>\n `,le.style.position="absolute",le.style.left=r.left-o.left+"px",le.style.top=r.bottom-o.top+4+"px",n.style.position="relative",n.appendChild(le)}(t,n,u.element)}catch{}}),400))}function x(e){const t=e.target.closest?.("a[href]");t&&(clearTimeout(d),ie())}async function v(){if(!u||!a)return;const e=u.element.querySelectorAll("a[href]"),t=/* @__PURE__ */new Set,n=[];for(const r of e){const e=r.href;t.has(e)||e.startsWith("mailto:")||e.startsWith("tel:")||e.startsWith("#")||(t.add(e),n.push({url:e,anchor:r}))}for(let r=0;r<n.length;r+=5){const e=n.slice(r,r+5);await Promise.all(e.map((async({url:e,anchor:t})=>{try{await a(e)?(h.delete(e),t.classList.remove("rmx-link-broken"),t.removeAttribute("data-link-broken")):(h.add(e),t.classList.add("rmx-link-broken"),t.setAttribute("data-link-broken","true"),s?.(e,t))}catch{h.add(e),t.classList.add("rmx-link-broken"),t.setAttribute("data-link-broken","true"),s?.(e,t)}})))}u.eventBus.emit("link:scanComplete",{total:t.size,broken:h.size})}function w(){if(!u||0===h.size)return;const e=u.element.querySelectorAll("a[href]");for(const t of e)h.has(t.href)&&(t.classList.add("rmx-link-broken"),t.setAttribute("data-link-broken","true"))}return e({name:"advancedLinks",requiresFullAccess:!0,version:"1.0.0",description:"Link previews, broken link detection, auto-linking, analytics, bookmarks",commands:[{name:"insertBookmark",execute(e,t={}){const{name:n,id:r}=t,o=r||ae(n||"bookmark");e.history.snapshot();const s=window.getSelection();if(!s||0===s.rangeCount)return;const a=s.getRangeAt(0),l=document.createElement("a");l.id=o,l.className="rmx-bookmark",l.setAttribute("data-bookmark",o),l.textContent=n?`📌 ${n}`:`📌 ${o}`,l.contentEditable="false",a.collapse(!0),a.insertNode(l);const i=document.createTextNode(" ");return l.after(i),e.eventBus.emit("content:change"),e.eventBus.emit("bookmark:created",{id:o,name:n}),l},meta:{icon:"bookmark",tooltip:"Insert Bookmark Anchor"}},{name:"linkToBookmark",execute(e,t){if(!t)return;const n=e.selection;if(!n.getSelectedText())return;e.history.snapshot();const r=n.wrapWith("a",{href:`#${t}`});r&&r.classList.add("rmx-internal-link"),e.eventBus.emit("content:change")},meta:{icon:"link",tooltip:"Link to Bookmark"}},{name:"getBookmarks",execute(e){const t=e.element.querySelectorAll("[data-bookmark]");return Array.from(t).map((e=>({id:e.getAttribute("data-bookmark"),name:e.textContent.replace(/^\u{1F4CC}\s*/u,""),element:e})))},meta:{tooltip:"List Bookmarks"}},{name:"removeBookmark",execute(e,t){const n=e.element.querySelector(`[data-bookmark="${t}"]`);n&&(e.history.snapshot(),n.remove(),e.eventBus.emit("content:change"),e.eventBus.emit("bookmark:deleted",{id:t}))},meta:{icon:"trash",tooltip:"Remove Bookmark"}},{name:"scanBrokenLinks",execute(){v()},meta:{icon:"scan",tooltip:"Scan for Broken Links"}},{name:"getBrokenLinks",execute:()=>Array.from(h),meta:{tooltip:"Get Broken Links"}}],contextMenuItems:[{label:"Insert Bookmark Here",command:"insertBookmark"}],init(e){u=e,u._links={detectLinks:se,slugify:ae,getBrokenLinks:()=>Array.from(h),getBookmarks:()=>{const e=u.element.querySelectorAll("[data-bookmark]");return Array.from(e).map((e=>({id:e.getAttribute("data-bookmark"),name:e.textContent.replace(/^\u{1F4CC}\s*/u,"")})))},scanForBrokenLinks:v,clearUnfurlCache:()=>g.clear()},i&&u.element.addEventListener("keydown",f),u.element.addEventListener("click",y),c&&r&&(u.element.addEventListener("mouseover",b),u.element.addEventListener("mouseout",x)),a&&l>0&&(m=setInterval(v,l),setTimeout(v,2e3)),p=u.eventBus.on("content:change",w)},destroy(){i&&u?.element?.removeEventListener("keydown",f),u?.element?.removeEventListener("click",y),u?.element?.removeEventListener("mouseover",b),u?.element?.removeEventListener("mouseout",x),ie(),clearTimeout(d),clearInterval(m),p?.(),g.clear(),h.clear(),u=null}})},detectLinks:se,slugify:ae},Symbol.toStringTag,{value:"Module"})),me=[{category:"Greek",symbols:[{label:"α",latex:"\\alpha"},{label:"β",latex:"\\beta"},{label:"γ",latex:"\\gamma"},{label:"δ",latex:"\\delta"},{label:"ε",latex:"\\epsilon"},{label:"θ",latex:"\\theta"},{label:"λ",latex:"\\lambda"},{label:"μ",latex:"\\mu"},{label:"π",latex:"\\pi"},{label:"σ",latex:"\\sigma"},{label:"φ",latex:"\\phi"},{label:"ω",latex:"\\omega"},{label:"Δ",latex:"\\Delta"},{label:"Σ",latex:"\\Sigma"},{label:"Ω",latex:"\\Omega"}]},{category:"Operators",symbols:[{label:"±",latex:"\\pm"},{label:"×",latex:"\\times"},{label:"÷",latex:"\\div"},{label:"≠",latex:"\\neq"},{label:"≤",latex:"\\leq"},{label:"≥",latex:"\\geq"},{label:"∞",latex:"\\infty"},{label:"≈",latex:"\\approx"},{label:"√",latex:"\\sqrt{}"},{label:"∑",latex:"\\sum"},{label:"∏",latex:"\\prod"},{label:"∫",latex:"\\int"}]},{category:"Arrows",symbols:[{label:"←",latex:"\\leftarrow"},{label:"→",latex:"\\rightarrow"},{label:"↔",latex:"\\leftrightarrow"},{label:"⇒",latex:"\\Rightarrow"},{label:"⇔",latex:"\\Leftrightarrow"},{label:"↑",latex:"\\uparrow"},{label:"↓",latex:"\\downarrow"}]},{category:"Common",symbols:[{label:"²",latex:"^{2}"},{label:"³",latex:"^{3}"},{label:"xⁿ",latex:"^{n}"},{label:"x₁",latex:"_{1}"},{label:"∀",latex:"\\forall"},{label:"∃",latex:"\\exists"},{label:"∈",latex:"\\in"},{label:"⊂",latex:"\\subset"},{label:"∪",latex:"\\cup"},{label:"∩",latex:"\\cap"},{label:"frac",latex:"\\frac{}{}"},{label:"∂",latex:"\\partial"}]}];function de(){return me}const pe=new RegExp("(?<!\\$)\\$(?!\\$)(.+?)(?<!\\$)\\$(?!\\$)","g"),ge=/\$\$([\s\S]+?)\$\$/g;function he(e){if(!e)return[];const t=[];let n;for(ge.lastIndex=0;null!==(n=ge.exec(e));)t.push({type:"block",src:n[1].trim(),index:n.index,length:n[0].length});for(pe.lastIndex=0;null!==(n=pe.exec(e));)t.some((e=>n.index>=e.index&&n.index<e.index+e.length))||t.push({type:"inline",src:n[1].trim(),index:n.index,length:n[0].length});return t.sort(((e,t)=>e.index-t.index))}function fe(e){return`<math xmlns="http://www.w3.org/1998/Math/MathML">${e.replace(/\\frac\{([^}]*)\}\{([^}]*)\}/g,"<mfrac><mrow>$1</mrow><mrow>$2</mrow></mfrac>").replace(/\\sqrt\{([^}]*)\}/g,"<msqrt><mrow>$1</mrow></msqrt>").replace(/\^{([^}]*)}/g,"<msup><mo></mo><mn>$1</mn></msup>").replace(/_{([^}]*)}/g,"<msub><mo></mo><mn>$1</mn></msub>").replace(/\\sum/g,"<mo>&sum;</mo>").replace(/\\prod/g,"<mo>&prod;</mo>").replace(/\\int/g,"<mo>&int;</mo>").replace(/\\infty/g,"<mo>&infin;</mo>").replace(/\\alpha/g,"<mi>&alpha;</mi>").replace(/\\beta/g,"<mi>&beta;</mi>").replace(/\\pi/g,"<mi>&pi;</mi>")}</math>`}function ye(e,t){return`<code class="rmx-math-latex">${n(e)}</code>`}const be=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,MathPlugin:function(t={}){const{renderMath:n=ye,autoRender:r=!0,numbering:o=!0}=t;let s=null,a=null,l=0;function i(e){const t=e.getAttribute("data-math-src");if(!t)return;const r=e.classList.contains("rmx-math-block"),s=n(t,r);if(e.innerHTML=s,r&&o){const t=e.getAttribute("data-equation-number");if(t){const n=document.createElement("span");n.className="rmx-equation-number",n.textContent=`(${t})`,e.appendChild(n)}}}function c(){if(!s)return;s.element.querySelectorAll("[data-math-src]").forEach(i)}return e({name:"math",requiresFullAccess:!0,version:"1.0.0",description:"LaTeX/KaTeX math rendering, symbol palette, equation numbering",commands:[{name:"insertMath",execute(e,t={}){const{latex:r="",displayMode:s=!1}=t;e.history.snapshot(),l++;const a=function(e,t,r){const s=t?"div":"span",a=document.createElement(s);if(a.className="rmx-math "+(t?"rmx-math-block":"rmx-math-inline"),a.setAttribute("data-math","latex"),a.setAttribute("data-math-src",e),a.contentEditable="false",t&&o&&r&&a.setAttribute("data-equation-number",String(r)),a.innerHTML=n(e,t),t&&o&&r){const e=document.createElement("span");e.className="rmx-equation-number",e.textContent=`(${r})`,a.appendChild(e)}return a}(r,s,s?l:null),i=window.getSelection();if(i&&i.rangeCount>0){const e=i.getRangeAt(0);e.deleteContents(),e.insertNode(a);const t=document.createTextNode(" ");a.after(t),e.setStartAfter(t),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}return e.eventBus.emit("content:change"),a},meta:{icon:"math",tooltip:"Insert Math Equation"}},{name:"editMath",execute(e,{element:t,latex:n}){t&&n&&(e.history.snapshot(),t.setAttribute("data-math-src",n),i(t),e.eventBus.emit("content:change"))},meta:{tooltip:"Edit Math Equation"}},{name:"insertSymbol",execute(e,t){if(!t)return;const n=window.getSelection();if(!n||0===n.rangeCount)return;const r=n.getRangeAt(0);r.deleteContents(),r.insertNode(document.createTextNode(t)),r.collapse(!1),e.eventBus.emit("content:change")},meta:{icon:"symbol",tooltip:"Insert Symbol"}},{name:"getSymbolPalette",execute:()=>de(),meta:{tooltip:"Get Symbol Palette"}},{name:"getMathElements",execute(e){const t=e.element.querySelectorAll("[data-math-src]");return Array.from(t).map(((e,t)=>({index:t,src:e.getAttribute("data-math-src"),displayMode:e.classList.contains("rmx-math-block"),equationNumber:e.getAttribute("data-equation-number"),element:e})))},meta:{tooltip:"Get Math Elements"}},{name:"copyMathAs",execute(e,{element:t,format:n="latex"}){if(!t)return null;const r=t.getAttribute("data-math-src");return r?"latex"===n?r:"mathml"===n?fe(r):r:null},meta:{tooltip:"Copy Math As Format"}}],contextMenuItems:[{label:"Insert Inline Math",command:"insertMath"}],init(e){s=e,s._math={getSymbolPalette:de,parseMathExpressions:he,latexToMathML:fe,renderAllMath:c,getEquationCount:()=>l},s.element.addEventListener("dblclick",(e=>{const t=e.target.closest("[data-math-src]");t&&s.eventBus.emit("math:edit",{element:t,src:t.getAttribute("data-math-src"),displayMode:t.classList.contains("rmx-math-block")})})),a=new MutationObserver((()=>c())),a.observe(s.element,{childList:!0,subtree:!0}),c()},destroy(){a?.disconnect(),s=null}})},getSymbolPalette:de,latexToMathML:fe,parseMathExpressions:he},Symbol.toStringTag,{value:"Module"})),xe=/\b(was|were|been|being|is|are|am|get|gets|got|gotten)\b/i,ve=/\b\w+(ed|en|wn|nt|ht|lt)\b/i;function we(e){const t=[],n=e.split(/(\s+)/);let r=0;for(let o=0;o<n.length;o++){const s=n[o];if(/^\s+$/.test(s))r+=s.length;else{if(xe.test(s)){let a=o+1;for(;a<n.length&&/^\s+$/.test(n[a]);)a++;if(a<n.length&&ve.test(n[a])){const l=r;let i=r+s.length;for(let e=o+1;e<=a;e++)i+=n[e].length;const c=e.slice(l,i);t.push({offset:l,length:i-l,message:`Passive voice detected: "${c}". Consider using active voice.`,suggestions:[],type:"grammar",rule:"passive-voice"})}}r+=s.length}}return t}const Ce=[{pattern:/\bin order to\b/gi,replacement:"to",message:'"in order to" can be simplified to "to"'},{pattern:/\bat this point in time\b/gi,replacement:"now",message:'"at this point in time" can be simplified to "now"'},{pattern:/\bdue to the fact that\b/gi,replacement:"because",message:'"due to the fact that" can be simplified to "because"'},{pattern:/\bin the event that\b/gi,replacement:"if",message:'"in the event that" can be simplified to "if"'},{pattern:/\bfor the purpose of\b/gi,replacement:"to",message:'"for the purpose of" can be simplified to "to"'},{pattern:/\bin the near future\b/gi,replacement:"soon",message:'"in the near future" can be simplified to "soon"'},{pattern:/\bat the present time\b/gi,replacement:"now",message:'"at the present time" can be simplified to "now"'},{pattern:/\bin spite of the fact that\b/gi,replacement:"although",message:'"in spite of the fact that" can be simplified to "although"'},{pattern:/\bwith regard to\b/gi,replacement:"about",message:'"with regard to" can be simplified to "about"'},{pattern:/\bin close proximity\b/gi,replacement:"near",message:'"in close proximity" can be simplified to "near"'},{pattern:/\ba large number of\b/gi,replacement:"many",message:'"a large number of" can be simplified to "many"'},{pattern:/\bhas the ability to\b/gi,replacement:"can",message:'"has the ability to" can be simplified to "can"'},{pattern:/\bis able to\b/gi,replacement:"can",message:'"is able to" can be simplified to "can"'},{pattern:/\bit is important to note that\b/gi,replacement:"(remove)",message:'"it is important to note that" is unnecessary filler'},{pattern:/\bneedless to say\b/gi,replacement:"(remove)",message:'"needless to say" is unnecessary — just say it'},{pattern:/\beach and every\b/gi,replacement:"each",message:'"each and every" can be simplified to "each" or "every"'},{pattern:/\bfirst and foremost\b/gi,replacement:"first",message:'"first and foremost" can be simplified to "first"'},{pattern:/\bbasically\b/gi,replacement:"(remove)",message:'"basically" is often unnecessary filler'},{pattern:/\bvery unique\b/gi,replacement:"unique",message:'"unique" is absolute — "very" is redundant'},{pattern:/\bcompletely eliminate\b/gi,replacement:"eliminate",message:'"eliminate" is absolute — "completely" is redundant'}];function ke(e){const t=[];for(const n of Ce){let r;const o=new RegExp(n.pattern.source,n.pattern.flags);for(;null!==(r=o.exec(e));)t.push({offset:r.index,length:r[0].length,message:n.message,suggestions:"(remove)"===n.replacement?[]:[n.replacement],type:"style",rule:"wordiness"})}return t}const Se=["at the end of the day","think outside the box","low-hanging fruit","move the needle","take it to the next level","game changer","paradigm shift","synergy","it goes without saying","avoid it like the plague","better late than never","the bottom line","by the same token","crystal clear","few and far between","hit the ground running","in a nutshell","level playing field","read between the lines","reinvent the wheel","tip of the iceberg","win-win situation","back to the drawing board","bite the bullet","cutting edge","pushing the envelope","raise the bar","on the same page","circle back","deep dive","best practice","leverage","ecosystem","robust","scalable solution"];function Te(e){const t=[],n=e.toLowerCase();for(const r of Se){let o=n.indexOf(r);for(;-1!==o;)t.push({offset:o,length:r.length,message:`Cliche detected: "${e.slice(o,o+r.length)}". Consider using more original phrasing.`,suggestions:[],type:"style",rule:"cliche"}),o=n.indexOf(r,o+r.length)}return t}function Ae(e){const t=[];let n;const r=/ +/g;for(;null!==(n=r.exec(e));)0!==n.index&&"\n"!==e[n.index-1]&&t.push({offset:n.index,length:n[0].length,message:"Multiple consecutive spaces detected.",suggestions:[" "],type:"grammar",rule:"double-space"});const o=/([.,!?;:])\1+/g;for(;null!==(n=o.exec(e));)"..."!==n[0]&&".."!==n[0]&&t.push({offset:n.index,length:n[0].length,message:`Repeated punctuation: "${n[0]}"`,suggestions:[n[1]],type:"grammar",rule:"repeated-punctuation"});const s=/[.!?,;:](?=[A-Za-z])/g;for(;null!==(n=s.exec(e));){const r=e.slice(Math.max(0,n.index-4),n.index+1);/\b[A-Z]\.$/.test(r)||/[a-z]\.[a-z]/.test(r)||/https?:/.test(r)||t.push({offset:n.index,length:2,message:"Missing space after punctuation.",suggestions:[e[n.index]+" "+e[n.index+1]],type:"grammar",rule:"missing-space"})}return t}const _e={formal:{passiveVoice:!0,wordiness:!0,cliches:!0,punctuation:!0},casual:{passiveVoice:!1,wordiness:!1,cliches:!0,punctuation:!0},technical:{passiveVoice:!0,wordiness:!1,cliches:!1,punctuation:!0},academic:{passiveVoice:!0,wordiness:!0,cliches:!1,punctuation:!0}};function Ee(e,t={}){if(!e)return[];const n=_e[t.stylePreset]||_e.formal,r=t.passiveVoice??n.passiveVoice,o=t.wordiness??n.wordiness,s=t.cliches??n.cliches,a=t.punctuation??n.punctuation,l=[];return r&&l.push(...we(e)),o&&l.push(...ke(e)),s&&l.push(...Te(e)),a&&l.push(...Ae(e)),l.sort(((e,t)=>e.offset-t.offset)),l}function Le(e){const t={total:e.length,grammar:0,style:0,byRule:{}};for(const n of e)"grammar"===n.type?t.grammar++:t.style++,t.byRule[n.rule]=(t.byRule[n.rule]||0)+1;return t}const Ne="rmx-spellcheck-dictionary",Re="rmx-spellcheck-ignored";function Ie(){try{const e=localStorage.getItem(Ne);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Oe(e){try{localStorage.setItem(Ne,JSON.stringify(e))}catch{}}const Be=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,STYLE_PRESETS:_e,SpellcheckPlugin:function(t={}){const{language:n="en-US",enabled:r=!0,grammarRules:o=!0,stylePreset:s="formal",customService:a=null,dictionary:l=[],persistent:i=!0,onError:c,onCorrection:u}=t;let m=null,d=r,p=s,g=n,h=null,f=[],y=null,b=null;const x=/* @__PURE__ */new Set([...l,...i?Ie():[]]),v=i?function(){try{const e=localStorage.getItem(Re);if(!e)/* @__PURE__ */return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t:[])}catch{/* @__PURE__ */
2
+ return new Set}}():/* @__PURE__ */new Set;function w(){if(!m)return;const e=m.element.querySelectorAll(".rmx-spelling-error, .rmx-grammar-error, .rmx-style-suggestion");for(const t of e){const e=t.parentNode;for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t),e.normalize()}}async function C(){if(!m||!d)return[];const e=m.getText();if(!e.trim())return f=[],m.eventBus.emit("spellcheck:update",{errors:[],stats:Le([])}),[];let t=[];if(o){const n=Ee(e,{stylePreset:p});t.push(...n)}if(a?.check)try{const n=await a.check(e);Array.isArray(n)&&t.push(...n)}catch(r){m.eventBus.emit("spellcheck:error",{error:r})}t=t.filter((t=>{const n=e.slice(t.offset,t.offset+t.length).toLowerCase();return!x.has(n)&&!v.has(n)})),t.sort(((e,t)=>e.offset-t.offset)),f=t,w(),function(e){if(!m||0===e.length)return;m.getText();const t=document.createTreeWalker(m.element,NodeFilter.SHOW_TEXT,null),n=[];let r,o=0;for(;r=t.nextNode();)n.push({node:r,start:o,end:o+r.textContent.length}),o+=r.textContent.length;const s=[...e].sort(((e,t)=>t.offset-e.offset));for(const a of s){const e=a.offset+a.length;let t=null,r=null,o=0,s=0;for(const l of n)if(!t&&l.end>a.offset&&(t=l,o=a.offset-l.start),l.end>=e){r=l,s=e-l.start;break}if(t&&r&&t.node===r.node)try{const e=document.createRange();e.setStart(t.node,o),e.setEnd(r.node,s);const n="spelling"===a.type?"rmx-spelling-error":"grammar"===a.type?"rmx-grammar-error":"rmx-style-suggestion",l=document.createElement("span");l.className=n,l.setAttribute("data-spellcheck-message",a.message),l.setAttribute("data-spellcheck-suggestions",JSON.stringify(a.suggestions||[])),l.setAttribute("data-spellcheck-type",a.type),l.setAttribute("title",a.message),e.surroundContents(l)}catch{}}}(t);const n=Le(t);return m.eventBus.emit("spellcheck:update",{errors:t,stats:n}),m.eventBus.emit("grammar:check",{errors:t,stats:n}),c?.(t),t}function k(){clearTimeout(h),h=setTimeout(C,500)}function S(e){if(!e)return;const t=e.toLowerCase();x.add(t),i&&Oe([...x]),m?.eventBus.emit("spellcheck:dictionary:add",{word:t}),k()}function T(e){x.delete(e.toLowerCase()),i&&Oe([...x]),k()}function A(){return[...x]}function _(e){if(!e)return;const t=e.toLowerCase();v.add(t),i&&function(e){try{localStorage.setItem(Re,JSON.stringify([...e]))}catch{}}(v),m?.eventBus.emit("spellcheck:ignored:add",{word:t}),k()}function E(){return[...v]}function L(e,t){if(!m||!e)return;const n=e.textContent;m.history.snapshot();const r=document.createTextNode(t);e.parentNode.replaceChild(r,e),r.parentNode.normalize(),m.eventBus.emit("content:change"),m.eventBus.emit("spellcheck:correction",{original:n,replacement:t}),u?.({original:n,replacement:t}),k()}function N(e){_e[e]&&(p=e,m?.eventBus.emit("spellcheck:style:change",{preset:e}),k())}function R(){return p}function I(e){g=e,m?.element&&m.element.setAttribute("lang",e),m?.eventBus.emit("spellcheck:language:change",{language:e}),k()}function O(){return g}function B(){return{...Le(f),enabled:d,stylePreset:p,language:g,dictionarySize:x.size,ignoredCount:v.size}}function M(e){const t=e.target.closest?.(".rmx-spelling-error, .rmx-grammar-error, .rmx-style-suggestion");if(!t)return;e.preventDefault();const n=t.getAttribute("data-spellcheck-message")||"",r=t.getAttribute("data-spellcheck-suggestions")||"[]",o=t.getAttribute("data-spellcheck-type")||"grammar";let s=[];try{s=JSON.parse(r)}catch{}const a=t.textContent,l=t.getBoundingClientRect();m.eventBus.emit("spellcheck:contextmenu",{word:a,message:n,suggestions:s,type:o,rect:l,mark:t,applyCorrection:e=>L(t,e),ignoreWord:()=>_(a),addToDictionary:()=>S(a)})}return e({name:"spellcheck",requiresFullAccess:!0,version:"1.0.0",description:"Spelling & grammar checking with inline underlines, writing-style presets, and custom service integration",commands:[{name:"toggleSpellcheck",execute:e=>(d=!d,d?(e.element.setAttribute("spellcheck","true"),k()):(e.element.setAttribute("spellcheck","false"),w(),f=[],e.eventBus.emit("spellcheck:update",{errors:[],stats:Le([])})),e.eventBus.emit("spellcheck:toggle",{enabled:d}),d),meta:{icon:"spellcheck",tooltip:"Toggle Spellcheck"}},{name:"checkGrammar",execute:async e=>C(),meta:{icon:"spellcheck",tooltip:"Check Grammar"}},{name:"addToDictionary",execute(e,t){S(t)},meta:{tooltip:"Add to Dictionary"}},{name:"ignoreWord",execute(e,t){_(t)},meta:{tooltip:"Ignore Word"}},{name:"setWritingStyle",execute:(e,t)=>(N(t),t),meta:{tooltip:"Set Writing Style"}},{name:"getSpellcheckStats",execute:e=>B(),meta:{tooltip:"Get Spellcheck Stats"}}],contextMenuItems:[{label:"Check Grammar",command:"checkGrammar",when:()=>d}],init(e){m=e,m._spellcheck={runCheck:C,clearMarks:w,addToDictionary:S,removeFromDictionary:T,getDictionary:A,ignoreWord:_,getIgnoredWords:E,applyCorrection:L,setWritingStyle:N,getWritingStyle:R,setLanguage:I,getLanguage:O,getErrors:()=>[...f],getStats:B,isEnabled:()=>d},m.element.setAttribute("spellcheck",d?"true":"false"),m.element.setAttribute("lang",g),y=m.eventBus.on("content:change",k),m.element.addEventListener("contextmenu",M),b=m.eventBus.on("destroy",D),d&&k()},destroy(){D()}});function D(){clearTimeout(h),w(),y?.(),b?.(),m?.element?.removeEventListener("contextmenu",M),m=null}},analyzeGrammar:Ee,detectCliches:Te,detectPassiveVoice:we,detectPunctuationIssues:Ae,detectWordiness:ke,summarizeIssues:Le},Symbol.toStringTag,{value:"Module"}));function Me(e,t){const n=[];let r=0,o="";const s=()=>{o&&(n.push({text:o,className:null}),o="")};for(;r<e.length;){let a=!1;for(const[o,l]of t){o.lastIndex=r;const t=o.exec(e);if(t&&t.index===r){s(),n.push({text:t[0],className:l}),r+=t[0].length,a=!0;break}}a||(o+=e[r],r++)}return s(),n}function De(e){return new RegExp(`\\b(?:${e.join("|")})\\b`,"g")}function qe(e){const t=new Set(e);return e=>t.has(e)}function $e(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>t.has(e.toLowerCase())}function Pe(e,t){const n=[],r=/\b[a-zA-Z_$]\w*\b/g;for(const o of e){if(null!==o.className){n.push(o);continue}let e,s=0;for(r.lastIndex=0;null!==(e=r.exec(o.text));){e.index>s&&n.push({text:o.text.slice(s,e.index),className:null});let a=null;for(const{match:n,className:r}of t)if(n(e[0])){a=r;break}n.push({text:e[0],className:a}),s=r.lastIndex}s<o.text.length&&n.push({text:o.text.slice(s),className:null})}return n}const je=[{match:qe(["any","boolean","never","number","string","unknown","void","type","keyof","readonly","infer"]),className:"rmx-syn-type"},{match:qe(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","from","function","if","implements","import","in","instanceof","interface","let","new","of","package","return","static","super","switch","this","throw","try","typeof","var","void","while","with","yield","async"]),className:"rmx-syn-keyword"},{match:qe(["Array","Boolean","console","Date","Error","JSON","Map","Math","Number","Object","Promise","Proxy","RegExp","Set","String","Symbol","WeakMap","WeakSet","parseInt","parseFloat","undefined","null","true","false","NaN","Infinity"]),className:"rmx-syn-builtin"}],He=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/\/(?:[^/\\*\n]|\\.){1,200}\/[gimsuy]{0,6}/g,"rmx-syn-regex"],[/`(?:[^`\\]|\\.|\$\{[^}]{0,200}\}){0,2000}`/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/@\w{1,50}/g,"rmx-syn-decorator"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/0[bB][01_]{1,64}/g,"rmx-syn-number"],[/\b[a-zA-Z_$]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_$]\\w{0,50}","g"),"rmx-syn-property"],[/=>|[+\-*/%=!<>&|^~?:]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function ze(e){return Pe(Me(e,He),je)}const Fe=[{match:qe(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]),className:"rmx-syn-keyword"},{match:qe(["abs","all","any","bin","bool","bytes","callable","chr","dict","dir","enumerate","eval","filter","float","format","frozenset","getattr","hasattr","hash","hex","id","input","int","isinstance","issubclass","iter","len","list","map","max","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"]),className:"rmx-syn-builtin"}],We=[[/#[^\n]{0,500}/g,"rmx-syn-comment"],[/"""[^]*?(?:"""|$)/g,"rmx-syn-string"],[/'''[^]*?(?:'''|$)/g,"rmx-syn-string"],[/f"(?:[^"\\]|\\.|\{[^}]{0,200}\}){0,1000}"/g,"rmx-syn-string"],[/f'(?:[^'\\]|\\.|\{[^}]{0,200}\}){0,1000}'/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/@\w{1,50}/g,"rmx-syn-decorator"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/0[bBoO][\d_]{1,64}/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/[+\-*/%=!<>&|^~@:]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function Ue(e){return Pe(Me(e,We),Fe)}const Ge=[[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[new RegExp(`@(?:${["charset","import","namespace","media","supports","keyframes","font-face","layer","container","property","scope"].join("|")})\\b`,"g"),"rmx-syn-keyword"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/#[\da-fA-F]{3,8}\b/g,"rmx-syn-number"],[/\b\d[\d.]{0,20}(?:%|px|rem|em|vh|vw|ch|ex|s|ms|deg|fr|vmin|vmax)?\b/g,"rmx-syn-number"],[/(?:^|\s|[{;])\s{0,10}[a-zA-Z-]{1,40}(?=\s{0,5}:)/gm,"rmx-syn-attr-name"],[/[.#][\w-]{1,60}/g,"rmx-syn-tag"],[/::?[\w-]{1,40}/g,"rmx-syn-entity"],[/\b(?:rgb|rgba|hsl|hsla|var|calc|min|max|clamp)(?=\()/g,"rmx-syn-builtin"],[/!important\b/g,"rmx-syn-keyword"],[/[{}();:,]/g,"rmx-syn-punctuation"]];const Ve=[{match:$e(["INT","INTEGER","BIGINT","SMALLINT","TINYINT","FLOAT","DOUBLE","DECIMAL","NUMERIC","CHAR","VARCHAR","TEXT","BLOB","BOOLEAN","DATE","TIMESTAMP","SERIAL"]),className:"rmx-syn-type"},{match:$e(["SELECT","FROM","WHERE","INSERT","INTO","UPDATE","DELETE","CREATE","DROP","ALTER","TABLE","INDEX","VIEW","JOIN","INNER","LEFT","RIGHT","OUTER","FULL","CROSS","ON","AS","AND","OR","NOT","IN","BETWEEN","LIKE","IS","NULL","ORDER","BY","GROUP","HAVING","LIMIT","OFFSET","UNION","ALL","DISTINCT","SET","VALUES","EXISTS","CASE","WHEN","THEN","ELSE","END","ASC","DESC","PRIMARY","KEY","FOREIGN","REFERENCES","CONSTRAINT","DEFAULT","WITH","RECURSIVE","RETURNING","BEGIN","COMMIT","ROLLBACK","TRANSACTION","GRANT","REVOKE","TRUNCATE"]),className:"rmx-syn-keyword"},{match:$e(["COUNT","SUM","AVG","MIN","MAX","COALESCE","IFNULL","NULLIF","CAST","CONVERT","SUBSTRING","TRIM","UPPER","LOWER","LENGTH","CONCAT","NOW","CURRENT_TIMESTAMP","TRUE","FALSE"]),className:"rmx-syn-builtin"}],Ke=[[/--[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/'(?:[^'\\]|\\.){0,1000}'/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/\b\d[\d.]{0,20}\b/g,"rmx-syn-number"],[/[+\-*/%=!<>]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];const Je=[[/"(?:[^"\\]|\\.){0,1000}"(?=\s{0,10}:)/g,"rmx-syn-attr-name"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/\b(?:true|false)\b/g,"rmx-syn-builtin"],[/\bnull\b/g,"rmx-syn-builtin"],[/-?\b\d[\d.]{0,20}(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/[{}[\]:,]/g,"rmx-syn-punctuation"]];const Ze=[[/#[^\n]{0,500}/g,"rmx-syn-comment"],[/"(?:[^"\\]|\\.|\$\{[^}]{0,200}\}|\$\w{1,50}){0,1000}"/g,"rmx-syn-string"],[/'[^']{0,2000}'/g,"rmx-syn-string"],[/\$\{[^}]{0,200}\}/g,"rmx-syn-entity"],[/\$[\w?!#@*]{1,50}/g,"rmx-syn-entity"],[De(["if","then","else","elif","fi","for","while","until","do","done","case","esac","in","function","select","return","exit","break","continue","local","export","declare","readonly","unset","shift","source","trap"]),"rmx-syn-keyword"],[De(["echo","printf","cd","pwd","ls","cp","mv","rm","mkdir","cat","grep","sed","awk","find","sort","uniq","wc","head","tail","chmod","chown","curl","wget","tar","git","docker","npm","yarn","pip","sudo","apt","brew","test","read","eval","exec","set"]),"rmx-syn-builtin"],[/\b\d[\d.]{0,20}\b/g,"rmx-syn-number"],[/[|&;<>]{1,3}/g,"rmx-syn-operator"],[/[{}()[\]]/g,"rmx-syn-punctuation"]];function Xe(e){return Me(e,Ze)}const Ye=[{match:qe(["bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","Self","Box","Vec","String","Option","Result","Rc","Arc","HashMap","HashSet","BTreeMap","BTreeSet","Cow"]),className:"rmx-syn-type"},{match:qe(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","static","struct","super","trait","type","unsafe","use","where","while","yield"]),className:"rmx-syn-keyword"},{match:qe(["Some","None","Ok","Err","true","false","println","eprintln","format","panic","assert","assert_eq","assert_ne","todo","unimplemented","unreachable","dbg","cfg","derive"]),className:"rmx-syn-builtin"}],Qe=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/r#*"[^]*?"#*/g,"rmx-syn-string"],[/'[a-zA-Z_]\w{0,30}/g,"rmx-syn-entity"],[/b?'(?:[^'\\]|\\.){1,4}'/g,"rmx-syn-string"],[/#!\[[\w:]{1,50}/g,"rmx-syn-decorator"],[/#\[[\w:]{1,50}/g,"rmx-syn-decorator"],[/\b\w{1,30}!/g,"rmx-syn-builtin"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?(?:_?(?:f32|f64|i8|i16|i32|i64|i128|u8|u16|u32|u64|u128|isize|usize))?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/0[bB][01_]{1,64}/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/[+\-*/%=!<>&|^]{1,3}|::|=>/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function et(e){return Pe(Me(e,Qe),Ye)}const tt=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/`[^`]{0,5000}`/g,"rmx-syn-string"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[De(["bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),"rmx-syn-type"],[De(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"]),"rmx-syn-keyword"],[De(["append","cap","close","complex","copy","delete","imag","len","make","new","panic","print","println","real","recover","true","false","nil","iota"]),"rmx-syn-builtin"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/:=|[+\-*/%=!<>&|^]{1,3}/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];function nt(e){return Me(e,tt)}const rt=[{match:qe(["String","Integer","Long","Double","Float","Boolean","Byte","Character","Short","Object","List","Map","Set","Collection","ArrayList","HashMap","HashSet","Optional","Stream"]),className:"rmx-syn-type"},{match:qe(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while","var","record","sealed","permits","yield"]),className:"rmx-syn-keyword"},{match:qe(["true","false","null","System","Math","Arrays","Collections"]),className:"rmx-syn-builtin"}],ot=[[/\/\/[^\n]{0,500}/g,"rmx-syn-comment"],[/\/\*[^]*?(?:\*\/|$)/g,"rmx-syn-comment"],[/"(?:[^"\\]|\\.){0,1000}"/g,"rmx-syn-string"],[/'(?:[^'\\]|\\.){1,4}'/g,"rmx-syn-string"],[/@\w{1,50}/g,"rmx-syn-decorator"],[/\b\d[\d_]{0,30}(?:\.\d[\d_]{0,30})?(?:[eE][+-]?\d{1,10})?[lLfFdD]?\b/g,"rmx-syn-number"],[/0[xX][\da-fA-F_]{1,20}[lL]?/g,"rmx-syn-number"],[/0[bB][01_]{1,64}[lL]?/g,"rmx-syn-number"],[/\b[a-zA-Z_]\w{0,50}(?=\s{0,5}\()/g,"rmx-syn-function"],[new RegExp("(?<=\\.)[a-zA-Z_]\\w{0,50}","g"),"rmx-syn-property"],[/[+\-*/%=!<>&|^~?:]{1,3}|->/g,"rmx-syn-operator"],[/[{}()[\];,.]/g,"rmx-syn-punctuation"]];const st=[[/<!--[^]*?(?:-->|$)/g,"rmx-syn-comment"],[/<!DOCTYPE[^>]{0,200}>/gi,"rmx-syn-entity"],[/<\/?[a-zA-Z][\w.-]{0,50}/g,"rmx-syn-tag"],[/\/?>/g,"rmx-syn-tag"],[/\b[a-zA-Z_:][\w:.-]{0,50}(?=\s{0,5}=)/g,"rmx-syn-attr-name"],[/=\s{0,5}"[^"]{0,1000}"/g,"rmx-syn-attr-value"],[/=\s{0,5}'[^']{0,1000}'/g,"rmx-syn-attr-value"],[/&\w{1,20};/g,"rmx-syn-entity"]];function at(e){return Me(e,st)}function lt(e){return[{text:e,className:null}]}const it={javascript:ze,js:ze,jsx:ze,typescript:ze,ts:ze,tsx:ze,python:Ue,py:Ue,css:function(e){return Me(e,Ge)},sql:function(e){return Pe(Me(e,Ke),Ve)},json:function(e){return Me(e,Je)},bash:Xe,sh:Xe,shell:Xe,zsh:Xe,rust:et,rs:et,go:nt,golang:nt,java:function(e){return Pe(Me(e,ot),rt)},html:at,htm:at,xml:at,svg:at,plaintext:lt,text:lt,txt:lt},ct=[{id:"javascript",label:"JavaScript"},{id:"typescript",label:"TypeScript"},{id:"python",label:"Python"},{id:"css",label:"CSS"},{id:"sql",label:"SQL"},{id:"json",label:"JSON"},{id:"bash",label:"Bash"},{id:"rust",label:"Rust"},{id:"go",label:"Go"},{id:"java",label:"Java"},{id:"html",label:"HTML"},{id:"plaintext",label:"Plain Text"}];function ut(e,t){const n=it[t?.toLowerCase()];if(!n||n===lt)return null;return n(e).map((({text:e,className:t})=>({type:t?t.replace("rmx-syn-",""):"plain",value:e})))}function mt(e){if(!e||"string"!=typeof e)return"plaintext";const t=e.trimStart(),n=t.slice(0,200);if(n.toLowerCase(),/^\s*[{\[]/.test(t))try{return JSON.parse(t),"json"}catch{}return/^\s*<!doctype\s+html/i.test(t)||/^\s*<(?:html|head|body|div|span|p|a|img|ul|ol|li|table|form|section|header|footer|nav|main|article)\b/i.test(t)?"html":/^\s*(?:SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|DROP|WITH|GRANT|EXPLAIN)\b/i.test(t)?"sql":/^#!.*python/i.test(t)||/^\s*(?:def |class \w+[:(]|from \w+ import|import (?:os|sys|re|json|math|typing|collections|pathlib|django|flask|numpy|pandas))\b/.test(t)?"python":/^\s*(?:fn |use std|pub fn|impl |#\[derive|mod \w+;|extern crate)/.test(t)?"rust":/^\s*(?:package \w+|func (?:main|\w+)\(|import \()/.test(t)?"go":/^\s*(?:(?:public|private|protected)\s+(?:class|interface|enum|abstract)|import java|@Override|package [a-z]+\.)/.test(t)?"java":/^#!\/(?:bin\/(?:ba)?sh|usr\/bin\/env (?:ba)?sh)/.test(t)||/^\s*(?:export |alias |source |if \[)/.test(t)?"bash":/^\s*(?:@(?:media|import|charset|keyframes|font-face)|[.#][\w-]+\s*\{|:root\s*\{|\*\s*\{|body\s*\{)/.test(t)?"css":/^\s*(?:import |export |const |let |var |function |class |async |'use strict')/.test(t)||/=>/.test(n)||/(?:React|require\(|module\.exports)/.test(n)?"javascript":"plaintext"}function dt(e){const t=e.selection.getSelection();if(!t||!t.anchorNode)return null;const n=t.anchorNode.nodeType===Node.TEXT_NODE?t.anchorNode.parentElement:t.anchorNode;return n?.closest?.("pre")??null}const pt=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,LANGUAGE_MAP:it,SUPPORTED_LANGUAGES:ct,SyntaxHighlightPlugin:function(){let t=null,r=null,o=null,s=null,a=null;function l(e,t){const r=e.closest("pre");if(!r)return;let o=e.getAttribute("data-language");o||(o=mt(e.textContent),o&&e.setAttribute("data-language",o));const s=ut(e.textContent,o);if(!s)return void r.classList.add("rmx-highlighted");let a="";for(const i of s)"plain"===i.type?a+=n(i.value):a+=`<span class="rmx-syn-${i.type}">${n(i.value)}</span>`;const l=t.selection.save();e.innerHTML=a,r.classList.add("rmx-highlighted"),l&&t.selection.restore(l)}function i(e){const t=e.hasAttribute("data-line-numbers");let n=e.querySelector(".rmx-line-numbers");if(!t)return n&&n.remove(),void e.classList.remove("rmx-has-line-numbers");const r=e.querySelector("code");if(!r)return;const o=(r.textContent.match(/\n/g)||[]).length+1;n||(n=document.createElement("span"),n.className="rmx-line-numbers",n.setAttribute("aria-hidden","true"),n.contentEditable="false",e.insertBefore(n,e.firstChild));let s="";for(let a=1;a<=o;a++)s+=`<span class="rmx-line-number">${a}</span>`;n.innerHTML=s,e.classList.add("rmx-has-line-numbers")}function c(e){if(e.querySelector(".rmx-code-copy-btn"))return;const t=document.createElement("button");t.className="rmx-code-copy-btn",t.type="button",t.setAttribute("aria-label","Copy code"),t.contentEditable="false",t.textContent="⧉",e.appendChild(t)}function u(e){const t=function(){if(!document.activeElement)return null;const e=window.getSelection();if(!e||!e.focusNode)return null;const t=e.focusNode.nodeType===Node.TEXT_NODE?e.focusNode.parentElement:e.focusNode;return t?.closest?.("pre")??null}(),r=e.element.querySelectorAll("pre");for(const n of r){if(c(n),i(n),n===t)continue;if(n.classList.contains("rmx-highlighted"))continue;const r=n.querySelector("code");r&&l(r,e)}!function(e){const t=e.element.querySelectorAll("code[data-language]:not(pre code)");for(const r of t){if(r.classList.contains("rmx-inline-highlighted"))continue;const e=r.getAttribute("data-language"),t=ut(r.textContent,e);if(!t)continue;let o="";for(const r of t)"plain"===r.type?o+=n(r.value):o+=`<span class="rmx-syn-${r.type}">${n(r.value)}</span>`;r.innerHTML=o,r.classList.add("rmx-inline-highlighted")}}(e)}return e({name:"syntaxHighlight",requiresFullAccess:!0,commands:[{name:"setCodeLanguage",execute(e,{language:t}={}){if(!t)return!1;const n=dt(e);if(!n)return!1;const r=n.querySelector("code");return!!r&&(r.setAttribute("data-language",t),n.classList.remove("rmx-highlighted"),l(r,e),e.eventBus.emit("codeblock:language-change",{language:t,element:r}),!0)}},{name:"getCodeLanguage",execute(e){const t=dt(e);if(!t)return null;const n=t.querySelector("code");return n&&n.getAttribute("data-language")||null}},{name:"toggleLineNumbers",execute(e,{element:t}={}){const n=t||dt(e);return!!n&&(n.hasAttribute("data-line-numbers")?n.removeAttribute("data-line-numbers"):n.setAttribute("data-line-numbers",""),i(n),!0)},meta:{icon:"lineNumbers",tooltip:"Toggle Line Numbers"}}],init(e){u(e),t=new MutationObserver((t=>{let n=!1;for(const e of t){if("childList"===e.type)for(const t of e.addedNodes)if(t.nodeType===Node.ELEMENT_NODE&&(t.matches?.("pre")||t.querySelector?.("pre"))){n=!0;break}if("characterData"===e.type){const t=e.target.parentElement?.closest?.("pre");t&&(t.classList.remove("rmx-highlighted"),n=!0)}if("attributes"===e.type){const t=e.target;if(t.matches?.("code")&&"data-language"===e.attributeName){const e=t.closest("pre");e&&(e.classList.remove("rmx-highlighted"),n=!0)}}if(n)break}n&&function(e){clearTimeout(r),r=setTimeout((()=>u(e)),150)}(e)})),t.observe(e.element,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-language"]}),a=async e=>{const t=e.target.closest(".rmx-code-copy-btn");if(!t)return;const n=t.closest("pre");if(!n)return;const r=n.querySelector("code");if(r){e.preventDefault(),e.stopPropagation();try{await navigator.clipboard.writeText(r.textContent),t.textContent="✓",t.classList.add("rmx-code-copy-success"),setTimeout((()=>{t.textContent="⧉",t.classList.remove("rmx-code-copy-success")}),1500)}catch{const e=document.createElement("textarea");e.value=r.textContent,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),t.textContent="✓",t.classList.add("rmx-code-copy-success"),setTimeout((()=>{t.textContent="⧉",t.classList.remove("rmx-code-copy-success")}),1500)}}},e.element.addEventListener("click",a,!0),o=t=>{const n=t.target?.closest?.("pre");if(n&&e.element.contains(n)){n.classList.remove("rmx-highlighted");const t=n.querySelector("code");t&&l(t,e),i(n)}},e.element.addEventListener("focusout",o,!0),s=e.eventBus.on("codeblock:language-change",(({language:t,element:n})=>{if(!n)return;const r=n.closest("pre");r&&e.element.contains(r)&&(r.classList.remove("rmx-highlighted"),l(n,e))}))},destroy(e){clearTimeout(r),r=null,t&&(t.disconnect(),t=null),o&&(e.element.removeEventListener("focusout",o,!0),o=null),a&&(e.element.removeEventListener("click",a,!0),a=null),s&&(s(),s=null)}})},detectLanguage:mt,registerLanguage:function(e,t,n,r=[]){if(!e||"string"!=typeof e)throw new Error("registerLanguage: id is required");if(!t||"string"!=typeof t)throw new Error("registerLanguage: label is required");if("function"!=typeof n)throw new Error("registerLanguage: tokenizer must be a function");it[e.toLowerCase()]=n;for(const o of r)it[o.toLowerCase()]=n;ct.find((t=>t.id===e))||ct.push({id:e,label:t})},runRules:Me,tokenize:ut,unregisterLanguage:function(e,t=[]){delete it[e.toLowerCase()];for(const r of t)delete it[r.toLowerCase()];const n=ct.findIndex((t=>t.id===e));-1!==n&&ct.splice(n,1)}},Symbol.toStringTag,{value:"Module"}));function gt(e,t){const n=[];let r=null,o=null;function s(){i();const t=e.querySelector("thead");if(!t)return;t.querySelectorAll("th").forEach(((e,t)=>{const s=document.createElement("span");s.className="rmx-filter-btn",s.textContent="▽",s.title="Filter column",s.setAttribute("data-col-index",String(t)),s.addEventListener("mousedown",(n=>{n.preventDefault(),n.stopPropagation(),function(e,t){if(r&&r.parentElement===e)return void l();l();const n=document.createElement("div");n.className="rmx-filter-dropdown",n.addEventListener("mousedown",(e=>e.stopPropagation()));const s=document.createElement("input");s.type="text",s.className="rmx-filter-input",s.placeholder="Filter...",s.value=e.getAttribute("data-filter-value")||"",s.addEventListener("input",(()=>{clearTimeout(o),o=setTimeout((()=>{a(t,s.value)}),200)}));const i=document.createElement("button");i.className="rmx-filter-clear-btn",i.textContent="Clear",i.type="button",i.addEventListener("click",(e=>{e.stopPropagation(),s.value="",a(t,""),l()})),n.appendChild(s),n.appendChild(i),e.appendChild(n),r=n,setTimeout((()=>s.focus()),0);const c=t=>{n.contains(t.target)||t.target===e.querySelector(".rmx-filter-btn")||(l(),document.removeEventListener("mousedown",c))};setTimeout((()=>document.addEventListener("mousedown",c)),0)}(e,t)})),e.style.position="relative",e.appendChild(s),n.push(s),e.getAttribute("data-filter-value")&&s.classList.add("rmx-filter-active")}))}function a(n,r){const o=e.querySelector("thead"),s=e.querySelector("tbody");if(!s)return;if(o){const e=o.querySelectorAll("th");if(e[n])if(r){e[n].setAttribute("data-filter-value",r);const t=e[n].querySelector(".rmx-filter-btn");t&&t.classList.add("rmx-filter-active")}else{e[n].removeAttribute("data-filter-value");const t=e[n].querySelector(".rmx-filter-btn");t&&t.classList.remove("rmx-filter-active")}}const a=[];o&&o.querySelectorAll("th").forEach(((e,t)=>{const n=e.getAttribute("data-filter-value");n&&a.push({columnIndex:t,value:n.toLowerCase()})}));s.querySelectorAll("tr").forEach((e=>{const t=e.querySelectorAll("td, th");a.some((e=>!(t[e.columnIndex]?.textContent||"").toLowerCase().includes(e.value)))?e.classList.add("rmx-row-hidden"):e.classList.remove("rmx-row-hidden")})),t?.eventBus&&t.eventBus.emit("table:filter-change",{table:e,filters:a})}function l(){r&&(r.remove(),r=null)}function i(){n.forEach((e=>e.remove())),n.length=0,l()}return s(),{update:s,destroy:()=>{clearTimeout(o),i()}}}const ht=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,TablePlugin:function(){let t=null,n=/* @__PURE__ */new Map,o=null,s=null,a=null,l=null,i=null;function c(e,t){if(n.has(e))return;const o={};o.resize=function(e,t){const n=[];let r=0,o=0,s=0,a=0,l=-1,i=null;function c(){const t=e.getBoundingClientRect(),r=e.querySelector("thead"),o=r?.querySelector("tr")||e.querySelector("tr");if(!o)return;const s=o.querySelectorAll("th, td");n.forEach((n=>{if(n.classList.contains("rmx-col-resize-handle")){const r=parseInt(n.getAttribute("data-col-index")),o=s[r];if(!o)return;const a=o.getBoundingClientRect();n.style.position="absolute",n.style.top="0",n.style.left=a.right-t.left-3+"px",n.style.width="6px",n.style.height=e.offsetHeight+"px"}else if(n.classList.contains("rmx-row-resize-handle")){const r=parseInt(n.getAttribute("data-row-index")),o=e.querySelectorAll("tbody tr")[r];if(!o)return;const s=o.getBoundingClientRect();n.style.position="absolute",n.style.left="0",n.style.top=s.bottom-t.top-3+"px",n.style.width=e.offsetWidth+"px",n.style.height="6px"}}))}function u(t){t.preventDefault(),t.stopPropagation(),l=parseInt(t.target.getAttribute("data-col-index"));const n=e.querySelector("thead"),o=n?.querySelector("tr")||e.querySelector("tr"),a=o?.querySelectorAll("th, td")[l];a&&(r=t.clientX,s=a.offsetWidth,t.target,e.classList.add("rmx-table-resizing"),document.addEventListener("mousemove",m),document.addEventListener("mouseup",d))}function m(t){if(l<0)return;const n=t.clientX-r,o=Math.max(40,s+n);e.querySelectorAll("tr").forEach((e=>{const t=e.cells[l];t&&t.colSpan<=1&&(t.style.width=o+"px")}))}function d(){document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d),e.classList.remove("rmx-table-resizing"),l=-1,t?.history&&t.history.snapshot(),c()}function p(t){t.preventDefault(),t.stopPropagation();const n=parseInt(t.target.getAttribute("data-row-index")),r=e.querySelectorAll("tbody tr");i=r[n],i&&(o=t.clientY,a=i.offsetHeight,e.classList.add("rmx-table-resizing"),document.addEventListener("mousemove",g),document.addEventListener("mouseup",h))}function g(e){if(!i)return;const t=e.clientY-o,n=Math.max(24,a+t);i.style.height=n+"px"}function h(){document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h),e.classList.remove("rmx-table-resizing"),i=null,t?.history&&t.history.snapshot(),c()}function f(){n.forEach((e=>e.remove())),n.length=0}return"static"===getComputedStyle(e).position&&(e.style.position="relative"),function(){f();const t=e.querySelector("thead"),r=t?.querySelector("tr")||e.querySelector("tr");if(!r)return;const o=r.querySelectorAll("th, td");o.forEach(((t,r)=>{if(r===o.length-1)return;const s=document.createElement("div");s.className="rmx-col-resize-handle",s.setAttribute("data-col-index",String(r)),s.addEventListener("mousedown",u),e.appendChild(s),n.push(s)}));const s=e.querySelectorAll("tbody tr");s.forEach(((t,r)=>{if(r===s.length-1)return;const o=document.createElement("div");o.className="rmx-row-resize-handle",o.setAttribute("data-row-index",String(r)),o.addEventListener("mousedown",p),e.appendChild(o),n.push(o)})),c()}(),{update:c,destroy:()=>{f(),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h)}}}(e,t),e.querySelector("thead")&&(o.filter=gt(e,t));const s=e.querySelector("thead");s&&s.querySelectorAll("th").forEach((e=>{e.classList.add("rmx-sortable")})),e.querySelectorAll("td, th").forEach((e=>{const t=e.textContent.trim();t.startsWith("=")&&!e.hasAttribute("data-formula")&&e.setAttribute("data-formula",t)})),r(e),n.set(e,o)}function u(e){const t=n.get(e);t&&(t.resize?.destroy(),t.filter?.destroy(),n.delete(e))}function m(e){e.element.querySelectorAll("table.rmx-table").forEach((t=>c(t,e)))}return e({name:"tableFeatures",requiresFullAccess:!0,init(e){m(e),t=new MutationObserver((t=>{let n=!1;for(const e of t){if("childList"===e.type){for(const t of e.addedNodes)if(t.nodeType===Node.ELEMENT_NODE&&(t.matches?.("table.rmx-table")||t.querySelector?.("table.rmx-table"))){n=!0;break}for(const t of e.removedNodes)t.nodeType===Node.ELEMENT_NODE&&t.matches?.("table.rmx-table")&&u(t)}if(n)break}n&&m(e)})),t.observe(e.element,{childList:!0,subtree:!0}),s=t=>{const n=t.target.closest("th");if(!n)return;const r=n.closest("thead");if(!r)return;const o=r.closest("table.rmx-table");if(!o||!e.element.contains(o))return;if(t.target.closest(".rmx-filter-btn")||t.target.closest(".rmx-filter-dropdown"))return;const s=Array.from(r.querySelectorAll("th")),a=s.indexOf(n);if(a<0)return;const l=n.getAttribute("data-sort-dir");let i;if(i=l?"asc"===l?"desc":null:"asc",t.shiftKey){const t=[];s.forEach(((e,n)=>{const r=e.getAttribute("data-sort-dir");r&&n!==a&&t.push({columnIndex:n,direction:r})})),i&&t.push({columnIndex:a,direction:i}),t.length>0?e.executeCommand("sortTable",{keys:t}):s.forEach((e=>{e.removeAttribute("data-sort-dir"),e.removeAttribute("data-sort-priority")}))}else i?e.executeCommand("sortTable",{columnIndex:a,direction:i}):s.forEach((e=>{e.removeAttribute("data-sort-dir"),e.removeAttribute("data-sort-priority")}))},e.element.addEventListener("click",s),a=t=>{const n=t.target.closest("td, th");if(!n||!e.element.contains(n))return;const r=n.getAttribute("data-formula");r&&(n.textContent="="+r)},l=t=>{const n=t.target.closest("td, th");if(!n||!e.element.contains(n))return;const o=n.textContent.trim();if(o.startsWith("=")&&o.length>1){const e=o.slice(1);n.setAttribute("data-formula",e);const t=n.closest("table.rmx-table");t&&r(t)}else n.hasAttribute("data-formula")&&!o.startsWith("=")&&n.removeAttribute("data-formula")},e.element.addEventListener("focusin",a,!0),e.element.addEventListener("focusout",l,!0),i=e.eventBus.on("content:change",(()=>{clearTimeout(o),o=setTimeout((()=>{e.element.querySelectorAll("table.rmx-table").forEach((e=>r(e)))}),200)}))},destroy(e){clearTimeout(o),o=null,i?.(),i=null,t&&(t.disconnect(),t=null),s&&(e.element.removeEventListener("click",s),s=null),a&&(e.element.removeEventListener("focusin",a,!0),a=null),l&&(e.element.removeEventListener("focusout",l,!0),l=null);for(const t of n.keys())u(t);n.clear()}})}},Symbol.toStringTag,{value:"Module"})),ft=/\{\{([^{}]+)\}\}/g,yt=/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g,bt=/\{\{#each\s+(\w+)\}\}([\s\S]*?)\{\{\/each\}\}/g;function xt(e,t){if(!e||!t)return e||"";let n=e;return n=n.replace(bt,((e,n,r)=>{const o=t[n];return Array.isArray(o)?o.map((e=>{let n=r;return n="object"==typeof e&&null!==e?xt(r,{...t,...e}):n.replace(/\{\{this\}\}/g,String(e)),n})).join(""):""})),n=n.replace(yt,((e,n,r)=>t[n]?xt(r,t):"")),n=n.replace(ft,((e,n)=>{const r=n.trim();return r in t?String(t[r]):`{{${r}}}`})),n}function vt(e){if(!e)return[];const t=/* @__PURE__ */new Set,n=e.matchAll(/\{\{(?:#(?:if|each)\s+)?(\w+)\}\}/g);for(const r of n)t.add(r[1]);return Array.from(t)}const wt=/* @__PURE__ */new Map,Ct=[{id:"email",name:"Email",category:"Communication",html:"<p>Dear {{recipient_name}},</p><p>{{body}}</p><p>Best regards,<br>{{sender_name}}<br>{{sender_title}}</p>",sampleData:{recipient_name:"John Doe",body:"Thank you for your interest in our product.",sender_name:"Jane Smith",sender_title:"Sales Manager"}},{id:"invoice",name:"Invoice",category:"Business",html:'<h2>Invoice #{{invoice_number}}</h2><p>Date: {{date}}</p><p>Bill to: <strong>{{client_name}}</strong></p><p>{{client_address}}</p><table class="rmx-table"><thead><tr><th>Item</th><th>Qty</th><th>Price</th></tr></thead><tbody><tr><td>{{item_1}}</td><td>{{qty_1}}</td><td>{{price_1}}</td></tr></tbody></table><p><strong>Total: {{total}}</strong></p>',sampleData:{invoice_number:"INV-001",date:"2026-03-19",client_name:"Acme Corp",client_address:"123 Main St",item_1:"Widget",qty_1:"10",price_1:"$29.99",total:"$299.90"}},{id:"letter",name:"Letter",category:"Communication",html:"<p>{{date}}</p><p>{{recipient_name}}<br>{{recipient_address}}</p><p>Dear {{recipient_name}},</p><p>{{body}}</p><p>Sincerely,<br>{{sender_name}}</p>",sampleData:{date:"March 19, 2026",recipient_name:"John Doe",recipient_address:"456 Oak Ave",body:"I am writing to inform you...",sender_name:"Jane Smith"}},{id:"report",name:"Report",category:"Business",html:"<h1>{{title}}</h1><p><em>Prepared by {{author}} | {{date}}</em></p><h2>Executive Summary</h2><p>{{summary}}</p><h2>Findings</h2><p>{{findings}}</p><h2>Recommendations</h2><p>{{recommendations}}</p>",sampleData:{title:"Q1 2026 Report",author:"Analytics Team",date:"March 2026",summary:"Key findings from Q1...",findings:"Revenue increased by 15%...",recommendations:"Continue investing in..."}},{id:"newsletter",name:"Newsletter",category:"Marketing",html:'<h1>{{newsletter_name}}</h1><p><em>{{edition}} | {{date}}</em></p><hr><h2>{{headline}}</h2><p>{{lead_story}}</p>{{#if has_coupon}}<div class="rmx-callout rmx-callout-success" data-callout="success"><div class="rmx-callout-header" contenteditable="false"><span class="rmx-callout-icon">✅</span><span class="rmx-callout-title">Special Offer</span></div><div class="rmx-callout-body"><p>Use code <strong>{{coupon_code}}</strong> for {{discount}} off!</p></div></div>{{/if}}<p>{{closing}}</p>',sampleData:{newsletter_name:"The Weekly Digest",edition:"Vol. 12",date:"March 19, 2026",headline:"Big News This Week",lead_story:"We are excited to announce...",has_coupon:!0,coupon_code:"SAVE20",discount:"20%",closing:"Thanks for reading!"}}];for(const Ht of Ct)wt.set(Ht.id,Ht);function kt(e){e?.id&&wt.set(e.id,e)}function St(e){return wt.delete(e)}function Tt(){return Array.from(wt.values())}function At(e){return wt.get(e)}function _t(e){return e.replace(ft,((e,t)=>{const n=t.trim();return n.startsWith("#")||n.startsWith("/")?e:`<span class="rmx-merge-tag" data-tag="${n}" contenteditable="false">{{${n}}}</span>`}))}function Et(e){return e.replace(/<span[^>]*class="rmx-merge-tag"[^>]*data-tag="([^"]*)"[^>]*>.*?<\/span>/g,((e,t)=>`{{${t}}}`))}const Lt=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,TemplatePlugin:function(t={}){let n=null,r=!1,o={};return e({name:"templates",requiresFullAccess:!0,version:"1.0.0",description:"Merge tags, conditional blocks, repeatable sections, live preview, template library",commands:[{name:"insertMergeTag",execute(e,t){if(!t)return;e.history.snapshot();const n=window.getSelection();if(!n||0===n.rangeCount)return;const r=n.getRangeAt(0),o=document.createElement("span");o.className="rmx-merge-tag",o.setAttribute("data-tag",t),o.contentEditable="false",o.textContent=`{{${t}}}`,r.deleteContents(),r.insertNode(o);const s=document.createTextNode(" ");o.after(s),r.setStartAfter(s),r.collapse(!0),n.removeAllRanges(),n.addRange(r),e.eventBus.emit("content:change")},meta:{icon:"tag",tooltip:"Insert Merge Tag"}},{name:"loadTemplate",execute(e,t){const n=wt.get(t);return n?(e.history.snapshot(),e.element.innerHTML=_t(n.html),o={...n.sampleData||{}},e.eventBus.emit("content:change"),e.eventBus.emit("template:loaded",{id:t,template:n}),n):null},meta:{icon:"template",tooltip:"Load Template"}},{name:"previewTemplate",execute(e,t){if(!t&&0===Object.keys(o).length)return;const n=t||o;o=n;const s=xt(Et(e.getHTML()),n);r=!0,e._templateBackup=e.element.innerHTML,e.element.innerHTML=s,e.element.contentEditable="false",e.element.classList.add("rmx-template-preview"),e.eventBus.emit("template:preview",{data:n})},meta:{icon:"preview",tooltip:"Preview Template"}},{name:"exitPreview",execute(e){r&&(r=!1,e._templateBackup&&(e.element.innerHTML=e._templateBackup,delete e._templateBackup),e.element.contentEditable="true",e.element.classList.remove("rmx-template-preview"),e.eventBus.emit("template:exitPreview"))},meta:{icon:"edit",tooltip:"Exit Preview"}},{name:"exportTemplate",execute(e){const t=Et(e.getHTML());return{html:t,tags:vt(t),sampleData:{...o}}},meta:{icon:"export",tooltip:"Export Template"}},{name:"getTemplateTags",execute:e=>vt(Et(e.getHTML())),meta:{tooltip:"Get Template Tags"}}],contextMenuItems:[{label:"Insert Merge Tag",command:"insertMergeTag"}],init(e){n=e,n._templates={renderTemplate:xt,extractTags:vt,getTemplateLibrary:Tt,getTemplate:At,registerTemplate:kt,unregisterTemplate:St,textToChips:_t,chipsToText:Et,setPreviewData:e=>{o={...e}},getPreviewData:()=>({...o}),isPreviewMode:()=>r}},destroy(){r&&n&&(n.element.contentEditable="true",n.element.classList.remove("rmx-template-preview")),n=null}})},extractTags:vt,getTemplate:At,getTemplateLibrary:Tt,registerTemplate:kt,renderTemplate:xt,unregisterTemplate:St},Symbol.toStringTag,{value:"Module"}));let Nt=0;function Rt(e,t={}){const{numbering:n=!0}=t,r=e.querySelectorAll("h1, h2, h3, h4, h5, h6"),o=[];for(const l of r){if(!l.id){const e=l.textContent.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"heading-"+ ++Nt;l.id=e}o.push({id:l.id,text:l.textContent,level:parseInt(l.tagName.charAt(1),10),element:l,children:[],number:""})}const s=[],a=[];for(const l of o){for(;a.length>0&&a[a.length-1].level>=l.level;)a.pop();0===a.length?s.push(l):a[a.length-1].item.children.push(l),a.push({item:l,level:l.level})}return n&&It(s,""),s}function It(e,t){e.forEach(((e,n)=>{e.number=t?`${t}.${n+1}`:String(n+1),It(e.children,e.number)}))}function Ot(e){const t=[];return function e(n){for(const r of n)t.push(r),e(r.children)}(e),t}function Bt(e,t={}){const{numbering:r=!0,linkPrefix:o="#"}=t;return`<nav class="rmx-toc" role="navigation" aria-label="Table of Contents"><ul>${function e(t){return 0===t.length?"":t.map((t=>{const s=r&&t.number?`<span class="rmx-toc-number">${t.number}</span> `:"",a=t.children.length>0?`<ul>${e(t.children)}</ul>`:"";return`<li><a href="${o}${t.id}" class="rmx-toc-link">${s}${n(t.text)}</a>${a}</li>`})).join("")}(e)}</ul></nav>`}function Mt(e){const t=[];for(let n=1;n<e.length;n++){const r=e[n-1].level,o=e[n].level;o>r+1&&t.push({message:`Heading level skipped: H${r} → H${o} (expected H${r+1})`,element:e[n].element})}return t}const Dt=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,TocPlugin:function(t={}){const{onOutlineChange:n,numbering:r=!0,collapsible:o=!0}=t;let s=null,a=null,l=[],i=null;function c(){s&&(l=Rt(s.element,{numbering:r}),s.eventBus.emit("toc:change",{outline:l}),n?.(l))}return e({name:"toc",requiresFullAccess:!0,version:"1.0.0",description:"Auto-generated table of contents, document outline, heading validation",commands:[{name:"getOutline",execute:e=>Rt(e.element,{numbering:r}),meta:{tooltip:"Get Document Outline"}},{name:"insertToc",execute(e){e.history.snapshot();const t=Bt(Rt(e.element,{numbering:r}),{numbering:r}),n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0),r=document.createElement("div");r.innerHTML=t;const o=document.createDocumentFragment();for(;r.firstChild;)o.appendChild(r.firstChild);e.deleteContents(),e.insertNode(o)}e.eventBus.emit("content:change")},meta:{icon:"toc",tooltip:"Insert Table of Contents"}},{name:"scrollToHeading",execute(e,t){const n=e.element.querySelector(`#${CSS.escape(t)}`);if(n){n.scrollIntoView?.({behavior:"smooth",block:"start"});const e=window.getSelection(),t=document.createRange();t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}},meta:{icon:"scroll",tooltip:"Scroll to Heading"}},{name:"validateHeadings",execute:e=>Mt(Ot(Rt(e.element,{numbering:!1}))),meta:{tooltip:"Validate Heading Hierarchy"}}],init(e){s=e,s._toc={buildOutline:()=>Rt(s.element,{numbering:r}),flattenOutline:Ot,renderTocHTML:Bt,validateHeadingHierarchy:Mt,getOutline:()=>l},a=s.eventBus.on("content:change",(()=>{clearTimeout(i),i=setTimeout(c,200)})),s.element.addEventListener("click",(e=>{const t=e.target.closest(".rmx-toc-link");if(t){e.preventDefault();const n=t.getAttribute("href")?.replace("#","");if(n){const e=s.element.querySelector(`#${CSS.escape(n)}`);e?.scrollIntoView?.({behavior:"smooth",block:"start"})}}})),c()},destroy(){clearTimeout(i),a?.(),s=null}})},buildOutline:Rt,flattenOutline:Ot,renderTocHTML:Bt,validateHeadingHierarchy:Mt},Symbol.toStringTag,{value:"Module"})),qt=/* @__PURE__ */Object.assign({"./analytics/index.js":h,"./block-templates/index.js":y,"./callout/index.js":E,"./collaboration/index.js":B,"./comments/index.js":$,"./drag-drop/index.js":U,"./keyboard/index.js":te,"./link/index.js":ue,"./math/index.js":be,"./spellcheck/index.js":Be,"./syntax-highlight/index.js":pt,"./table/index.js":ht,"./template/index.js":Lt,"./toc/index.js":Dt}),$t=/* @__PURE__ */new Map;for(const[Ht,zt]of Object.entries(qt)){const e=Ht.split("/");if(3===e.length&&"index.js"===e[2]){const t=e[1];$t.set(t,zt)}}function Pt(e,t={}){const n=$t.get(e);if(!n)return null;const r=Object.keys(n).find((e=>e.endsWith("Plugin")&&"function"==typeof n[e]));return r?n[r](t):null}function jt(e){return e&&"object"==typeof e?Object.entries(e).filter((([,e])=>!1!==e&&("object"!=typeof e||null===e||!1!==e.enabled))).map((([e,t])=>{const n="object"==typeof t&&null!==t?{...t}:{};return delete n.enabled,Pt(e,n)})).filter(Boolean):[]}export{Pt as loadPlugin,jt as resolvePluginsFromConfig};
3
+ //# sourceMappingURL=index-Bg_uAWlM.js.map