overtype 2.2.0 → 2.3.0

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/overtype.js", "../src/parser.js", "../src/shortcuts.js", "../src/themes.js", "../src/styles.js", "../node_modules/markdown-actions/src/core/formats.js", "../node_modules/markdown-actions/src/debug.js", "../node_modules/markdown-actions/src/core/insertion.js", "../node_modules/markdown-actions/src/core/selection.js", "../node_modules/markdown-actions/src/operations/block.js", "../node_modules/markdown-actions/src/operations/list.js", "../node_modules/markdown-actions/src/core/detection.js", "../node_modules/markdown-actions/src/index.js", "../src/toolbar.js", "../node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs", "../node_modules/@floating-ui/core/dist/floating-ui.core.mjs", "../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs", "../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs", "../src/link-tooltip.js", "../src/icons.js", "../src/toolbar-buttons.js"],
4
- "sourcesContent": ["/**\n * OverType - A lightweight markdown editor library with perfect WYSIWYG alignment\n * @version 1.0.0\n * @license MIT\n */\n\nimport { MarkdownParser } from './parser.js';\nimport { ShortcutsManager } from './shortcuts.js';\nimport { generateStyles } from './styles.js';\nimport { getTheme, mergeTheme, solar, themeToCSSVars, resolveAutoTheme } from './themes.js';\nimport { Toolbar } from './toolbar.js';\nimport { LinkTooltip } from './link-tooltip.js';\nimport { defaultToolbarButtons, toolbarButtons as builtinToolbarButtons } from './toolbar-buttons.js';\n\n/**\n * Build action map from toolbar button configurations\n * @param {Array} buttons - Array of button config objects\n * @returns {Object} Map of actionId -> action function\n */\nfunction buildActionsMap(buttons) {\n const map = {};\n (buttons || []).forEach((btn) => {\n if (!btn || btn.name === 'separator') return;\n const id = btn.actionId || btn.name;\n if (btn.action) {\n map[id] = btn.action;\n }\n });\n return map;\n}\n\n/**\n * Normalize toolbar buttons for comparison\n * @param {Array|null} buttons\n * @returns {Array|null}\n */\nfunction normalizeButtons(buttons) {\n const list = buttons || defaultToolbarButtons;\n if (!Array.isArray(list)) return null;\n return list.map((btn) => ({\n name: btn?.name || null,\n actionId: btn?.actionId || btn?.name || null,\n icon: btn?.icon || null,\n title: btn?.title || null\n }));\n}\n\n/**\n * Determine if toolbar button configuration changed\n * @param {Array|null} prevButtons\n * @param {Array|null} nextButtons\n * @returns {boolean}\n */\nfunction toolbarButtonsChanged(prevButtons, nextButtons) {\n const prev = normalizeButtons(prevButtons);\n const next = normalizeButtons(nextButtons);\n\n if (prev === null || next === null) return prev !== next;\n if (prev.length !== next.length) return true;\n\n for (let i = 0; i < prev.length; i++) {\n const a = prev[i];\n const b = next[i];\n if (a.name !== b.name ||\n a.actionId !== b.actionId ||\n a.icon !== b.icon ||\n a.title !== b.title) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * OverType Editor Class\n */\nclass OverType {\n // Static properties\n static instances = new WeakMap();\n static stylesInjected = false;\n static globalListenersInitialized = false;\n static instanceCount = 0;\n static _autoMediaQuery = null;\n static _autoMediaListener = null;\n static _autoInstances = new Set();\n static _globalAutoTheme = false;\n static _globalAutoCustomColors = null;\n\n /**\n * Constructor - Always returns an array of instances\n * @param {string|Element|NodeList|Array} target - Target element(s)\n * @param {Object} options - Configuration options\n * @returns {Array} Array of OverType instances\n */\n constructor(target, options = {}) {\n // Convert target to array of elements\n let elements;\n \n if (typeof target === 'string') {\n elements = document.querySelectorAll(target);\n if (elements.length === 0) {\n throw new Error(`No elements found for selector: ${target}`);\n }\n elements = Array.from(elements);\n } else if (target instanceof Element) {\n elements = [target];\n } else if (target instanceof NodeList) {\n elements = Array.from(target);\n } else if (Array.isArray(target)) {\n elements = target;\n } else {\n throw new Error('Invalid target: must be selector string, Element, NodeList, or Array');\n }\n\n // Initialize all elements and return array\n const instances = elements.map(element => {\n // Check for existing instance\n if (element.overTypeInstance) {\n // Re-init existing instance\n element.overTypeInstance.reinit(options);\n return element.overTypeInstance;\n }\n\n // Create new instance\n const instance = Object.create(OverType.prototype);\n instance._init(element, options);\n element.overTypeInstance = instance;\n OverType.instances.set(element, instance);\n return instance;\n });\n\n return instances;\n }\n\n /**\n * Internal initialization\n * @private\n */\n _init(element, options = {}) {\n this.element = element;\n \n // Store the original theme option before merging\n this.instanceTheme = options.theme || null;\n \n this.options = this._mergeOptions(options);\n this.instanceId = ++OverType.instanceCount;\n this.initialized = false;\n\n // Inject styles if needed\n OverType.injectStyles();\n\n // Initialize global listeners\n OverType.initGlobalListeners();\n\n // Check for existing OverType DOM structure\n const container = element.querySelector('.overtype-container');\n const wrapper = element.querySelector('.overtype-wrapper');\n if (container || wrapper) {\n this._recoverFromDOM(container, wrapper);\n } else {\n this._buildFromScratch();\n }\n\n if (this.instanceTheme === 'auto') {\n this.setTheme('auto');\n }\n\n // Setup shortcuts manager\n this.shortcuts = new ShortcutsManager(this);\n\n // Build action map from toolbar buttons (works whether or not toolbar UI is shown)\n this._rebuildActionsMap();\n\n // Setup link tooltip\n this.linkTooltip = new LinkTooltip(this);\n\n // Sync scroll positions on initial render\n // This ensures textarea matches preview scroll if page is reloaded while scrolled\n // Double requestAnimationFrame waits for browser to restore scroll position\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n this.textarea.scrollTop = this.preview.scrollTop;\n this.textarea.scrollLeft = this.preview.scrollLeft;\n });\n });\n\n // Mark as initialized\n this.initialized = true;\n\n // Call onChange if provided\n if (this.options.onChange) {\n this.options.onChange(this.getValue(), this);\n }\n }\n\n /**\n * Merge user options with defaults\n * @private\n */\n _mergeOptions(options) {\n const defaults = {\n // Typography\n fontSize: '14px',\n lineHeight: 1.6,\n /* System-first, guaranteed monospaced; avoids Android 'ui-monospace' pitfalls */\n fontFamily: '\"SF Mono\", SFMono-Regular, Menlo, Monaco, \"Cascadia Code\", Consolas, \"Roboto Mono\", \"Noto Sans Mono\", \"Droid Sans Mono\", \"Ubuntu Mono\", \"DejaVu Sans Mono\", \"Liberation Mono\", \"Courier New\", Courier, monospace',\n padding: '16px',\n \n // Mobile styles\n mobile: {\n fontSize: '16px', // Prevent zoom on iOS\n padding: '12px',\n lineHeight: 1.5\n },\n \n // Native textarea properties\n textareaProps: {},\n \n // Behavior\n autofocus: false,\n autoResize: false, // Auto-expand height with content\n minHeight: '100px', // Minimum height for autoResize mode\n maxHeight: null, // Maximum height for autoResize mode (null = unlimited)\n placeholder: 'Start typing...',\n value: '',\n \n // Callbacks\n onChange: null,\n onKeydown: null,\n \n // Features\n showActiveLineRaw: false,\n showStats: false,\n toolbar: false,\n toolbarButtons: null, // Defaults to defaultToolbarButtons if toolbar: true\n statsFormatter: null,\n smartLists: true, // Enable smart list continuation\n codeHighlighter: null, // Per-instance code highlighter\n spellcheck: false // Browser spellcheck (disabled by default)\n };\n \n // Remove theme and colors from options - these are now global\n const { theme, colors, ...cleanOptions } = options;\n \n return {\n ...defaults,\n ...cleanOptions\n };\n }\n\n /**\n * Recover from existing DOM structure\n * @private\n */\n _recoverFromDOM(container, wrapper) {\n // Handle old structure (wrapper only) or new structure (container + wrapper)\n if (container && container.classList.contains('overtype-container')) {\n this.container = container;\n this.wrapper = container.querySelector('.overtype-wrapper');\n } else if (wrapper) {\n // Old structure - just wrapper, no container\n this.wrapper = wrapper;\n // Wrap it in a container for consistency\n this.container = document.createElement('div');\n this.container.className = 'overtype-container';\n // Use instance theme if provided, otherwise use global theme\n const themeToUse = this.instanceTheme || OverType.currentTheme || solar;\n const themeName = typeof themeToUse === 'string' ? themeToUse : themeToUse.name;\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n \n // If using instance theme, apply CSS variables to container\n if (this.instanceTheme) {\n const themeObj = typeof this.instanceTheme === 'string' ? getTheme(this.instanceTheme) : this.instanceTheme;\n if (themeObj && themeObj.colors) {\n const cssVars = themeToCSSVars(themeObj.colors);\n this.container.style.cssText += cssVars;\n }\n }\n wrapper.parentNode.insertBefore(this.container, wrapper);\n this.container.appendChild(wrapper);\n }\n \n if (!this.wrapper) {\n // No valid structure found\n if (container) container.remove();\n if (wrapper) wrapper.remove();\n this._buildFromScratch();\n return;\n }\n \n this.textarea = this.wrapper.querySelector('.overtype-input');\n this.preview = this.wrapper.querySelector('.overtype-preview');\n\n if (!this.textarea || !this.preview) {\n // Partial DOM - clear and rebuild\n this.container.remove();\n this._buildFromScratch();\n return;\n }\n\n // Store reference on wrapper\n this.wrapper._instance = this;\n \n // Apply instance-specific styles via CSS custom properties\n if (this.options.fontSize) {\n this.wrapper.style.setProperty('--instance-font-size', this.options.fontSize);\n }\n if (this.options.lineHeight) {\n this.wrapper.style.setProperty('--instance-line-height', String(this.options.lineHeight));\n }\n if (this.options.padding) {\n this.wrapper.style.setProperty('--instance-padding', this.options.padding);\n }\n\n // Disable autofill, spellcheck, and extensions\n this._configureTextarea();\n\n // Apply any new options\n this._applyOptions();\n }\n\n /**\n * Build editor from scratch\n * @private\n */\n _buildFromScratch() {\n // Extract any existing content\n const content = this._extractContent();\n\n // Clear element\n this.element.innerHTML = '';\n\n // Create DOM structure\n this._createDOM();\n\n // Set initial content\n if (content || this.options.value) {\n this.setValue(content || this.options.value);\n }\n\n // Apply options\n this._applyOptions();\n }\n\n /**\n * Extract content from element\n * @private\n */\n _extractContent() {\n // Look for existing OverType textarea\n const textarea = this.element.querySelector('.overtype-input');\n if (textarea) return textarea.value;\n\n // Use element's text content as fallback\n return this.element.textContent || '';\n }\n\n /**\n * Create DOM structure\n * @private\n */\n _createDOM() {\n // Create container that will hold toolbar and editor\n this.container = document.createElement('div');\n this.container.className = 'overtype-container';\n \n // Set theme on container - use instance theme if provided\n const themeToUse = this.instanceTheme || OverType.currentTheme || solar;\n const themeName = typeof themeToUse === 'string' ? themeToUse : themeToUse.name;\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n \n // If using instance theme, apply CSS variables to container\n if (this.instanceTheme) {\n const themeObj = typeof this.instanceTheme === 'string' ? getTheme(this.instanceTheme) : this.instanceTheme;\n if (themeObj && themeObj.colors) {\n const cssVars = themeToCSSVars(themeObj.colors);\n this.container.style.cssText += cssVars;\n }\n }\n \n // Create wrapper for editor\n this.wrapper = document.createElement('div');\n this.wrapper.className = 'overtype-wrapper';\n \n \n // Apply instance-specific styles via CSS custom properties\n if (this.options.fontSize) {\n this.wrapper.style.setProperty('--instance-font-size', this.options.fontSize);\n }\n if (this.options.lineHeight) {\n this.wrapper.style.setProperty('--instance-line-height', String(this.options.lineHeight));\n }\n if (this.options.padding) {\n this.wrapper.style.setProperty('--instance-padding', this.options.padding);\n }\n \n this.wrapper._instance = this;\n\n // Create textarea\n this.textarea = document.createElement('textarea');\n this.textarea.className = 'overtype-input';\n this.textarea.placeholder = this.options.placeholder;\n this._configureTextarea();\n \n // Apply any native textarea properties\n if (this.options.textareaProps) {\n Object.entries(this.options.textareaProps).forEach(([key, value]) => {\n if (key === 'className' || key === 'class') {\n this.textarea.className += ' ' + value;\n } else if (key === 'style' && typeof value === 'object') {\n Object.assign(this.textarea.style, value);\n } else {\n this.textarea.setAttribute(key, value);\n }\n });\n }\n\n // Create preview div\n this.preview = document.createElement('div');\n this.preview.className = 'overtype-preview';\n this.preview.setAttribute('aria-hidden', 'true');\n\n // Create placeholder shim\n this.placeholderEl = document.createElement('div');\n this.placeholderEl.className = 'overtype-placeholder';\n this.placeholderEl.setAttribute('aria-hidden', 'true');\n this.placeholderEl.textContent = this.options.placeholder;\n\n // Assemble DOM\n this.wrapper.appendChild(this.textarea);\n this.wrapper.appendChild(this.preview);\n this.wrapper.appendChild(this.placeholderEl);\n \n // No need to prevent link clicks - pointer-events handles this\n \n // Add wrapper to container first\n this.container.appendChild(this.wrapper);\n \n // Add stats bar at the end (bottom) if enabled\n if (this.options.showStats) {\n this.statsBar = document.createElement('div');\n this.statsBar.className = 'overtype-stats';\n this.container.appendChild(this.statsBar);\n this._updateStats();\n }\n \n // Add container to element\n this.element.appendChild(this.container);\n \n // Setup auto-resize if enabled\n if (this.options.autoResize) {\n this._setupAutoResize();\n } else {\n // Ensure auto-resize class is removed if not using auto-resize\n this.container.classList.remove('overtype-auto-resize');\n }\n }\n\n /**\n * Configure textarea attributes\n * @private\n */\n _configureTextarea() {\n this.textarea.setAttribute('autocomplete', 'off');\n this.textarea.setAttribute('autocorrect', 'off');\n this.textarea.setAttribute('autocapitalize', 'off');\n this.textarea.setAttribute('spellcheck', String(this.options.spellcheck));\n this.textarea.setAttribute('data-gramm', 'false');\n this.textarea.setAttribute('data-gramm_editor', 'false');\n this.textarea.setAttribute('data-enable-grammarly', 'false');\n }\n\n /**\n * Create and setup toolbar\n * @private\n */\n _createToolbar() {\n let toolbarButtons = this.options.toolbarButtons || defaultToolbarButtons;\n\n if (this.options.fileUpload?.enabled && !toolbarButtons.some(b => b?.name === 'upload')) {\n const viewModeIdx = toolbarButtons.findIndex(b => b?.name === 'viewMode');\n if (viewModeIdx !== -1) {\n toolbarButtons = [...toolbarButtons];\n toolbarButtons.splice(viewModeIdx, 0, builtinToolbarButtons.separator, builtinToolbarButtons.upload);\n } else {\n toolbarButtons = [...toolbarButtons, builtinToolbarButtons.separator, builtinToolbarButtons.upload];\n }\n }\n\n this.toolbar = new Toolbar(this, { toolbarButtons });\n this.toolbar.create();\n\n\n // Store listener references for cleanup\n this._toolbarSelectionListener = () => {\n if (this.toolbar) {\n this.toolbar.updateButtonStates();\n }\n };\n this._toolbarInputListener = () => {\n if (this.toolbar) {\n this.toolbar.updateButtonStates();\n }\n };\n\n // Add listeners\n this.textarea.addEventListener('selectionchange', this._toolbarSelectionListener);\n this.textarea.addEventListener('input', this._toolbarInputListener);\n }\n\n /**\n * Cleanup toolbar event listeners\n * @private\n */\n _cleanupToolbarListeners() {\n if (this._toolbarSelectionListener) {\n this.textarea.removeEventListener('selectionchange', this._toolbarSelectionListener);\n this._toolbarSelectionListener = null;\n }\n if (this._toolbarInputListener) {\n this.textarea.removeEventListener('input', this._toolbarInputListener);\n this._toolbarInputListener = null;\n }\n }\n\n /**\n * Rebuild the action map from current toolbar button configuration\n * Called during init and reinit to keep shortcuts in sync with toolbar buttons\n * @private\n */\n _rebuildActionsMap() {\n // Always start with default actions (shortcuts always work regardless of toolbar config)\n this.actionsById = buildActionsMap(defaultToolbarButtons);\n\n // Overlay custom toolbar actions (can add/override, but never remove core actions)\n if (this.options.toolbarButtons) {\n Object.assign(this.actionsById, buildActionsMap(this.options.toolbarButtons));\n }\n\n // Register upload action when file upload is enabled\n if (this.options.fileUpload?.enabled) {\n Object.assign(this.actionsById, buildActionsMap([builtinToolbarButtons.upload]));\n }\n }\n\n /**\n * Apply options to the editor\n * @private\n */\n _applyOptions() {\n // Apply autofocus\n if (this.options.autofocus) {\n this.textarea.focus();\n }\n\n // Setup or remove auto-resize\n if (this.options.autoResize) {\n if (!this.container.classList.contains('overtype-auto-resize')) {\n this._setupAutoResize();\n } else {\n this._updateAutoHeight();\n }\n } else {\n // Ensure auto-resize class is removed\n this.container.classList.remove('overtype-auto-resize');\n }\n\n // Handle toolbar option changes\n if (this.options.toolbar && !this.toolbar) {\n // Create toolbar if enabled and doesn't exist\n this._createToolbar();\n } else if (!this.options.toolbar && this.toolbar) {\n // Destroy toolbar if disabled and exists\n this._cleanupToolbarListeners();\n this.toolbar.destroy();\n this.toolbar = null;\n }\n\n // Update placeholder text\n if (this.placeholderEl) {\n this.placeholderEl.textContent = this.options.placeholder;\n }\n\n // Setup or remove file upload\n if (this.options.fileUpload && !this.fileUploadInitialized) {\n this._initFileUpload();\n } else if (!this.options.fileUpload && this.fileUploadInitialized) {\n this._destroyFileUpload();\n }\n\n // Update preview with initial content\n this.updatePreview();\n }\n\n _initFileUpload() {\n const options = this.options.fileUpload;\n if (!options || !options.enabled) return;\n\n options.maxSize = options.maxSize || 10 * 1024 * 1024;\n options.mimeTypes = options.mimeTypes || [];\n options.batch = options.batch || false;\n if (!options.onInsertFile || typeof options.onInsertFile !== 'function') {\n console.warn('OverType: fileUpload.onInsertFile callback is required for file uploads.');\n return;\n }\n\n this._fileUploadCounter = 0;\n this._boundHandleFilePaste = this._handleFilePaste.bind(this);\n this._boundHandleFileDrop = this._handleFileDrop.bind(this);\n this._boundHandleDragOver = this._handleDragOver.bind(this);\n\n this.textarea.addEventListener('paste', this._boundHandleFilePaste);\n this.textarea.addEventListener('drop', this._boundHandleFileDrop);\n this.textarea.addEventListener('dragover', this._boundHandleDragOver);\n\n this.fileUploadInitialized = true;\n }\n\n _handleFilePaste(e) {\n if (!e?.clipboardData?.files?.length) return;\n e.preventDefault();\n this._handleDataTransfer(e.clipboardData);\n }\n\n _handleFileDrop(e) {\n if (!e?.dataTransfer?.files?.length) return;\n e.preventDefault();\n this._handleDataTransfer(e.dataTransfer);\n }\n\n _handleDataTransfer(dataTransfer) {\n const files = [];\n for (const file of dataTransfer.files) {\n if (file.size > this.options.fileUpload.maxSize) continue;\n if (this.options.fileUpload.mimeTypes.length > 0\n && !this.options.fileUpload.mimeTypes.includes(file.type)) continue;\n\n const id = ++this._fileUploadCounter;\n const prefix = file.type.startsWith('image/') ? '!' : '';\n const placeholder = `${prefix}[Uploading ${file.name} (#${id})...]()`;\n this.insertAtCursor(`${placeholder}\\n`);\n\n if (this.options.fileUpload.batch) {\n files.push({ file, placeholder });\n continue;\n }\n\n this.options.fileUpload.onInsertFile(file).then((text) => {\n this.textarea.value = this.textarea.value.replace(placeholder, text);\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }, (error) => {\n console.error('OverType: File upload failed', error);\n this.textarea.value = this.textarea.value.replace(placeholder, '[Upload failed]()');\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n });\n }\n\n if (this.options.fileUpload.batch && files.length > 0) {\n this.options.fileUpload.onInsertFile(files.map(f => f.file)).then((result) => {\n const texts = Array.isArray(result) ? result : [result];\n texts.forEach((text, index) => {\n this.textarea.value = this.textarea.value.replace(files[index].placeholder, text);\n });\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }, (error) => {\n console.error('OverType: File upload failed', error);\n files.forEach(({ placeholder }) => {\n this.textarea.value = this.textarea.value.replace(placeholder, '[Upload failed]()');\n });\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n });\n }\n }\n\n _handleDragOver(e) {\n e.preventDefault();\n }\n\n _destroyFileUpload() {\n this.textarea.removeEventListener('paste', this._boundHandleFilePaste);\n this.textarea.removeEventListener('drop', this._boundHandleFileDrop);\n this.textarea.removeEventListener('dragover', this._boundHandleDragOver);\n this._boundHandleFilePaste = null;\n this._boundHandleFileDrop = null;\n this._boundHandleDragOver = null;\n this.fileUploadInitialized = false;\n }\n\n insertAtCursor(text) {\n const start = this.textarea.selectionStart;\n const end = this.textarea.selectionEnd;\n\n let inserted = false;\n try {\n inserted = document.execCommand('insertText', false, text);\n } catch (_) {}\n\n if (!inserted) {\n const before = this.textarea.value.slice(0, start);\n const after = this.textarea.value.slice(end);\n this.textarea.value = before + text + after;\n this.textarea.setSelectionRange(start + text.length, start + text.length);\n }\n\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n\n /**\n * Update preview with parsed markdown\n */\n updatePreview() {\n const text = this.textarea.value;\n const cursorPos = this.textarea.selectionStart;\n const activeLine = this._getCurrentLine(text, cursorPos);\n\n // Detect if we're in preview mode\n const isPreviewMode = this.container.dataset.mode === 'preview';\n\n // Parse markdown\n const html = MarkdownParser.parse(text, activeLine, this.options.showActiveLineRaw, this.options.codeHighlighter, isPreviewMode);\n this.preview.innerHTML = html;\n\n // Show/hide placeholder shim\n if (this.placeholderEl) {\n this.placeholderEl.style.display = text ? 'none' : '';\n }\n \n // Apply code block backgrounds\n this._applyCodeBlockBackgrounds();\n \n // Links always have real hrefs now - no need to update them\n \n // Update stats if enabled\n if (this.options.showStats && this.statsBar) {\n this._updateStats();\n }\n \n // Trigger onChange callback\n if (this.options.onChange && this.initialized) {\n this.options.onChange(text, this);\n }\n }\n\n /**\n * Apply background styling to code blocks\n * @private\n */\n _applyCodeBlockBackgrounds() {\n // Find all code fence elements\n const codeFences = this.preview.querySelectorAll('.code-fence');\n \n // Process pairs of code fences\n for (let i = 0; i < codeFences.length - 1; i += 2) {\n const openFence = codeFences[i];\n const closeFence = codeFences[i + 1];\n \n // Get parent divs\n const openParent = openFence.parentElement;\n const closeParent = closeFence.parentElement;\n \n if (!openParent || !closeParent) continue;\n \n // Make fences display: block\n openFence.style.display = 'block';\n closeFence.style.display = 'block';\n \n // Apply class to parent divs\n openParent.classList.add('code-block-line');\n closeParent.classList.add('code-block-line');\n \n // With the new structure, there's a <pre> block between fences, not DIVs\n // We don't need to process anything between the fences anymore\n // The <pre><code> structure already handles the content correctly\n }\n }\n\n /**\n * Get current line number from cursor position\n * @private\n */\n _getCurrentLine(text, cursorPos) {\n const lines = text.substring(0, cursorPos).split('\\n');\n return lines.length - 1;\n }\n\n /**\n * Handle input events\n * @private\n */\n handleInput(event) {\n this.updatePreview();\n }\n\n /**\n * Handle keydown events\n * @private\n */\n handleKeydown(event) {\n // Handle Tab key to prevent focus loss and insert spaces\n if (event.key === 'Tab') {\n const start = this.textarea.selectionStart;\n const end = this.textarea.selectionEnd;\n const value = this.textarea.value;\n\n // If Shift+Tab without a selection, allow default behavior (navigate to previous element)\n if (event.shiftKey && start === end) {\n return;\n }\n\n event.preventDefault();\n\n // If there's a selection, indent/outdent based on shift key\n if (start !== end && event.shiftKey) {\n // Outdent: remove 2 spaces from start of each selected line\n const before = value.substring(0, start);\n const selection = value.substring(start, end);\n const after = value.substring(end);\n \n const lines = selection.split('\\n');\n const outdented = lines.map(line => line.replace(/^ /, '')).join('\\n');\n \n // Try to use execCommand first to preserve undo history\n if (document.execCommand) {\n // Select the text that needs to be replaced\n this.textarea.setSelectionRange(start, end);\n document.execCommand('insertText', false, outdented);\n } else {\n // Fallback to direct manipulation\n this.textarea.value = before + outdented + after;\n this.textarea.selectionStart = start;\n this.textarea.selectionEnd = start + outdented.length;\n }\n } else if (start !== end) {\n // Indent: add 2 spaces to start of each selected line\n const before = value.substring(0, start);\n const selection = value.substring(start, end);\n const after = value.substring(end);\n \n const lines = selection.split('\\n');\n const indented = lines.map(line => ' ' + line).join('\\n');\n \n // Try to use execCommand first to preserve undo history\n if (document.execCommand) {\n // Select the text that needs to be replaced\n this.textarea.setSelectionRange(start, end);\n document.execCommand('insertText', false, indented);\n } else {\n // Fallback to direct manipulation\n this.textarea.value = before + indented + after;\n this.textarea.selectionStart = start;\n this.textarea.selectionEnd = start + indented.length;\n }\n } else {\n // No selection: just insert 2 spaces\n // Use execCommand to preserve undo history\n if (document.execCommand) {\n document.execCommand('insertText', false, ' ');\n } else {\n // Fallback to direct manipulation\n this.textarea.value = value.substring(0, start) + ' ' + value.substring(end);\n this.textarea.selectionStart = this.textarea.selectionEnd = start + 2;\n }\n }\n \n // Trigger input event to update preview\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n return;\n }\n \n // Handle Enter key for smart list continuation\n if (event.key === 'Enter' && !event.shiftKey && !event.metaKey && !event.ctrlKey && this.options.smartLists) {\n if (this.handleSmartListContinuation()) {\n event.preventDefault();\n return;\n }\n }\n \n // Let shortcuts manager handle other keys\n const handled = this.shortcuts.handleKeydown(event);\n \n // Call user callback if provided\n if (!handled && this.options.onKeydown) {\n this.options.onKeydown(event, this);\n }\n }\n\n /**\n * Handle smart list continuation\n * @returns {boolean} Whether the event was handled\n */\n handleSmartListContinuation() {\n const textarea = this.textarea;\n const cursorPos = textarea.selectionStart;\n const context = MarkdownParser.getListContext(textarea.value, cursorPos);\n \n if (!context || !context.inList) return false;\n \n // Handle empty list item (exit list)\n if (context.content.trim() === '' && cursorPos >= context.markerEndPos) {\n this.deleteListMarker(context);\n return true;\n }\n \n // Handle text splitting if cursor is in middle of content\n if (cursorPos > context.markerEndPos && cursorPos < context.lineEnd) {\n this.splitListItem(context, cursorPos);\n } else {\n // Just add new item after current line\n this.insertNewListItem(context);\n }\n \n // Handle numbered list renumbering\n if (context.listType === 'numbered') {\n this.scheduleNumberedListUpdate();\n }\n \n return true;\n }\n \n /**\n * Delete list marker and exit list\n * @private\n */\n deleteListMarker(context) {\n // Select from line start to marker end\n this.textarea.setSelectionRange(context.lineStart, context.markerEndPos);\n document.execCommand('delete');\n \n // Trigger input event\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n \n /**\n * Insert new list item\n * @private\n */\n insertNewListItem(context) {\n const newItem = MarkdownParser.createNewListItem(context);\n document.execCommand('insertText', false, '\\n' + newItem);\n \n // Trigger input event\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n \n /**\n * Split list item at cursor position\n * @private\n */\n splitListItem(context, cursorPos) {\n // Get text after cursor\n const textAfterCursor = context.content.substring(cursorPos - context.markerEndPos);\n \n // Delete text after cursor\n this.textarea.setSelectionRange(cursorPos, context.lineEnd);\n document.execCommand('delete');\n \n // Insert new list item with remaining text\n const newItem = MarkdownParser.createNewListItem(context);\n document.execCommand('insertText', false, '\\n' + newItem + textAfterCursor);\n \n // Position cursor after new list marker\n const newCursorPos = this.textarea.selectionStart - textAfterCursor.length;\n this.textarea.setSelectionRange(newCursorPos, newCursorPos);\n \n // Trigger input event\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n \n /**\n * Schedule numbered list renumbering\n * @private\n */\n scheduleNumberedListUpdate() {\n // Clear any pending update\n if (this.numberUpdateTimeout) {\n clearTimeout(this.numberUpdateTimeout);\n }\n \n // Schedule update after current input cycle\n this.numberUpdateTimeout = setTimeout(() => {\n this.updateNumberedLists();\n }, 10);\n }\n \n /**\n * Update/renumber all numbered lists\n * @private\n */\n updateNumberedLists() {\n const value = this.textarea.value;\n const cursorPos = this.textarea.selectionStart;\n \n const newValue = MarkdownParser.renumberLists(value);\n \n if (newValue !== value) {\n // Calculate cursor offset\n let offset = 0;\n const oldLines = value.split('\\n');\n const newLines = newValue.split('\\n');\n let charCount = 0;\n \n for (let i = 0; i < oldLines.length && charCount < cursorPos; i++) {\n if (oldLines[i] !== newLines[i]) {\n const diff = newLines[i].length - oldLines[i].length;\n if (charCount + oldLines[i].length < cursorPos) {\n offset += diff;\n }\n }\n charCount += oldLines[i].length + 1; // +1 for newline\n }\n \n // Update textarea\n this.textarea.value = newValue;\n const newCursorPos = cursorPos + offset;\n this.textarea.setSelectionRange(newCursorPos, newCursorPos);\n \n // Trigger update\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n\n /**\n * Handle scroll events\n * @private\n */\n handleScroll(event) {\n // Sync preview scroll with textarea\n this.preview.scrollTop = this.textarea.scrollTop;\n this.preview.scrollLeft = this.textarea.scrollLeft;\n }\n\n /**\n * Get editor content\n * @returns {string} Current markdown content\n */\n getValue() {\n return this.textarea.value;\n }\n\n /**\n * Set editor content\n * @param {string} value - Markdown content to set\n */\n setValue(value) {\n this.textarea.value = value;\n this.updatePreview();\n\n // Update height if auto-resize is enabled\n if (this.options.autoResize) {\n this._updateAutoHeight();\n }\n }\n\n /**\n * Execute an action by ID\n * Central dispatcher used by toolbar clicks, keyboard shortcuts, and programmatic calls\n * @param {string} actionId - The action identifier (e.g., 'toggleBold', 'insertLink')\n * @param {Event|null} event - Optional event that triggered the action\n * @returns {Promise<boolean>} Whether the action was executed successfully\n */\n async performAction(actionId, event = null) {\n const textarea = this.textarea;\n if (!textarea) return false;\n\n const action = this.actionsById?.[actionId];\n if (!action) {\n console.warn(`OverType: Unknown action \"${actionId}\"`);\n return false;\n }\n\n textarea.focus();\n\n try {\n await action({\n editor: this,\n getValue: () => this.getValue(),\n setValue: (value) => this.setValue(value),\n event\n });\n // Note: actions are responsible for dispatching input event\n // This preserves behavior for direct consumers of toolbarButtons.*.action\n return true;\n } catch (error) {\n console.error(`OverType: Action \"${actionId}\" error:`, error);\n this.wrapper.dispatchEvent(new CustomEvent('button-error', {\n detail: { actionId, error }\n }));\n return false;\n }\n }\n\n /**\n * Get the rendered HTML of the current content\n * @param {Object} options - Rendering options\n * @param {boolean} options.cleanHTML - If true, removes syntax markers and OverType-specific classes\n * @returns {string} Rendered HTML\n */\n getRenderedHTML(options = {}) {\n const markdown = this.getValue();\n let html = MarkdownParser.parse(markdown, -1, false, this.options.codeHighlighter);\n\n if (options.cleanHTML) {\n // Remove all syntax marker spans for clean HTML export\n html = html.replace(/<span class=\"syntax-marker[^\"]*\">.*?<\\/span>/g, '');\n // Remove OverType-specific classes\n html = html.replace(/\\sclass=\"(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)\"/g, '');\n // Clean up empty class attributes\n html = html.replace(/\\sclass=\"\"/g, '');\n }\n \n return html;\n }\n\n /**\n * Get the current preview element's HTML\n * This includes all syntax markers and OverType styling\n * @returns {string} Current preview HTML (as displayed)\n */\n getPreviewHTML() {\n return this.preview.innerHTML;\n }\n \n /**\n * Get clean HTML without any OverType-specific markup\n * Useful for exporting to other formats or storage\n * @returns {string} Clean HTML suitable for export\n */\n getCleanHTML() {\n return this.getRenderedHTML({ cleanHTML: true });\n }\n\n /**\n * Focus the editor\n */\n focus() {\n this.textarea.focus();\n }\n\n /**\n * Blur the editor\n */\n blur() {\n this.textarea.blur();\n }\n\n /**\n * Check if editor is initialized\n * @returns {boolean}\n */\n isInitialized() {\n return this.initialized;\n }\n\n /**\n * Re-initialize with new options\n * @param {Object} options - New options to apply\n */\n reinit(options = {}) {\n const prevToolbarButtons = this.options?.toolbarButtons;\n this.options = this._mergeOptions({ ...this.options, ...options });\n const toolbarNeedsRebuild = this.toolbar &&\n this.options.toolbar &&\n toolbarButtonsChanged(prevToolbarButtons, this.options.toolbarButtons);\n\n // Rebuild action map in case toolbarButtons changed\n this._rebuildActionsMap();\n\n if (toolbarNeedsRebuild) {\n this._cleanupToolbarListeners();\n this.toolbar.destroy();\n this.toolbar = null;\n this._createToolbar();\n }\n\n if (this.fileUploadInitialized) {\n this._destroyFileUpload();\n }\n if (this.options.fileUpload) {\n this._initFileUpload();\n }\n\n this._applyOptions();\n this.updatePreview();\n }\n\n showToolbar() {\n if (this.toolbar) {\n this.toolbar.show();\n } else {\n this._createToolbar();\n }\n }\n\n hideToolbar() {\n if (this.toolbar) {\n this.toolbar.hide();\n }\n }\n\n /**\n * Set theme for this instance\n * @param {string|Object} theme - Theme name or custom theme object\n * @returns {this} Returns this for chaining\n */\n setTheme(theme) {\n OverType._autoInstances.delete(this);\n this.instanceTheme = theme;\n\n if (theme === 'auto') {\n OverType._autoInstances.add(this);\n OverType._startAutoListener();\n this._applyResolvedTheme(resolveAutoTheme('auto'));\n } else {\n const themeObj = typeof theme === 'string' ? getTheme(theme) : theme;\n const themeName = typeof themeObj === 'string' ? themeObj : themeObj.name;\n\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n\n if (themeObj && themeObj.colors) {\n const cssVars = themeToCSSVars(themeObj.colors);\n this.container.style.cssText += cssVars;\n }\n\n this.updatePreview();\n }\n\n OverType._stopAutoListener();\n return this;\n }\n\n _applyResolvedTheme(themeName) {\n const themeObj = getTheme(themeName);\n this.container.setAttribute('data-theme', themeName);\n\n if (themeObj && themeObj.colors) {\n this.container.style.cssText = themeToCSSVars(themeObj.colors);\n }\n\n this.updatePreview();\n }\n\n /**\n * Set instance-specific code highlighter\n * @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML\n */\n setCodeHighlighter(highlighter) {\n this.options.codeHighlighter = highlighter;\n this.updatePreview();\n }\n\n /**\n * Update stats bar\n * @private\n */\n _updateStats() {\n if (!this.statsBar) return;\n \n const value = this.textarea.value;\n const lines = value.split('\\n');\n const chars = value.length;\n const words = value.split(/\\s+/).filter(w => w.length > 0).length;\n \n // Calculate line and column\n const selectionStart = this.textarea.selectionStart;\n const beforeCursor = value.substring(0, selectionStart);\n const linesBeforeCursor = beforeCursor.split('\\n');\n const currentLine = linesBeforeCursor.length;\n const currentColumn = linesBeforeCursor[linesBeforeCursor.length - 1].length + 1;\n \n // Use custom formatter if provided\n if (this.options.statsFormatter) {\n this.statsBar.innerHTML = this.options.statsFormatter({\n chars,\n words,\n lines: lines.length,\n line: currentLine,\n column: currentColumn\n });\n } else {\n // Default format with live dot\n this.statsBar.innerHTML = `\n <div class=\"overtype-stat\">\n <span class=\"live-dot\"></span>\n <span>${chars} chars, ${words} words, ${lines.length} lines</span>\n </div>\n <div class=\"overtype-stat\">Line ${currentLine}, Col ${currentColumn}</div>\n `;\n }\n }\n \n /**\n * Setup auto-resize functionality\n * @private\n */\n _setupAutoResize() {\n // Add auto-resize class for styling\n this.container.classList.add('overtype-auto-resize');\n \n // Store previous height for comparison\n this.previousHeight = null;\n \n // Initial height update\n this._updateAutoHeight();\n \n // Listen for input events\n this.textarea.addEventListener('input', () => this._updateAutoHeight());\n \n // Listen for window resize\n window.addEventListener('resize', () => this._updateAutoHeight());\n }\n \n /**\n * Update height based on scrollHeight\n * @private\n */\n _updateAutoHeight() {\n if (!this.options.autoResize) return;\n \n const textarea = this.textarea;\n const preview = this.preview;\n const wrapper = this.wrapper;\n \n // Get computed styles\n const computed = window.getComputedStyle(textarea);\n const paddingTop = parseFloat(computed.paddingTop);\n const paddingBottom = parseFloat(computed.paddingBottom);\n \n // Store scroll positions\n const scrollTop = textarea.scrollTop;\n \n // Reset height to get accurate scrollHeight\n textarea.style.setProperty('height', 'auto', 'important');\n \n // Calculate new height based on scrollHeight\n let newHeight = textarea.scrollHeight;\n \n // Apply min height constraint\n if (this.options.minHeight) {\n const minHeight = parseInt(this.options.minHeight);\n newHeight = Math.max(newHeight, minHeight);\n }\n \n // Apply max height constraint\n let overflow = 'hidden';\n if (this.options.maxHeight) {\n const maxHeight = parseInt(this.options.maxHeight);\n if (newHeight > maxHeight) {\n newHeight = maxHeight;\n overflow = 'auto';\n }\n }\n \n // Apply the new height to all elements with !important to override base styles\n const heightPx = newHeight + 'px';\n textarea.style.setProperty('height', heightPx, 'important');\n textarea.style.setProperty('overflow-y', overflow, 'important');\n \n preview.style.setProperty('height', heightPx, 'important');\n preview.style.setProperty('overflow-y', overflow, 'important');\n \n wrapper.style.setProperty('height', heightPx, 'important');\n \n // Restore scroll position\n textarea.scrollTop = scrollTop;\n preview.scrollTop = scrollTop;\n \n // Track if height changed\n if (this.previousHeight !== newHeight) {\n this.previousHeight = newHeight;\n // Could dispatch a custom event here if needed\n }\n }\n \n /**\n * Show or hide stats bar\n * @param {boolean} show - Whether to show stats\n */\n showStats(show) {\n this.options.showStats = show;\n\n if (show && !this.statsBar) {\n // Create stats bar (add to container, not wrapper)\n this.statsBar = document.createElement('div');\n this.statsBar.className = 'overtype-stats';\n this.container.appendChild(this.statsBar);\n this._updateStats();\n } else if (show && this.statsBar) {\n // Already visible - refresh stats (useful after changing statsFormatter)\n this._updateStats();\n } else if (!show && this.statsBar) {\n // Remove stats bar\n this.statsBar.remove();\n this.statsBar = null;\n }\n }\n \n /**\n * Show normal edit mode (overlay with markdown preview)\n * @returns {this} Returns this for chaining\n */\n showNormalEditMode() {\n this.container.dataset.mode = 'normal';\n this.updatePreview(); // Re-render with normal mode (e.g., show syntax markers)\n\n // Always sync scroll from preview to textarea\n requestAnimationFrame(() => {\n this.textarea.scrollTop = this.preview.scrollTop;\n this.textarea.scrollLeft = this.preview.scrollLeft;\n });\n\n return this;\n }\n\n /**\n * Show plain textarea mode (no overlay)\n * @returns {this} Returns this for chaining\n */\n showPlainTextarea() {\n this.container.dataset.mode = 'plain';\n\n // Update toolbar button if exists\n if (this.toolbar) {\n const toggleBtn = this.container.querySelector('[data-action=\"toggle-plain\"]');\n if (toggleBtn) {\n toggleBtn.classList.remove('active');\n toggleBtn.title = 'Show markdown preview';\n }\n }\n\n return this;\n }\n\n /**\n * Show preview mode (read-only view)\n * @returns {this} Returns this for chaining\n */\n showPreviewMode() {\n this.container.dataset.mode = 'preview';\n this.updatePreview(); // Re-render with preview mode (e.g., checkboxes)\n return this;\n }\n\n /**\n * Destroy the editor instance\n */\n destroy() {\n OverType._autoInstances.delete(this);\n OverType._stopAutoListener();\n\n if (this.fileUploadInitialized) {\n this._destroyFileUpload();\n }\n\n // Remove instance reference\n this.element.overTypeInstance = null;\n OverType.instances.delete(this.element);\n\n // Cleanup shortcuts\n if (this.shortcuts) {\n this.shortcuts.destroy();\n }\n\n // Remove DOM if created by us\n if (this.wrapper) {\n const content = this.getValue();\n this.wrapper.remove();\n \n // Restore original content\n this.element.textContent = content;\n }\n\n this.initialized = false;\n }\n\n // ===== Static Methods =====\n\n /**\n * Initialize multiple editors (static convenience method)\n * @param {string|Element|NodeList|Array} target - Target element(s)\n * @param {Object} options - Configuration options\n * @returns {Array} Array of OverType instances\n */\n static init(target, options = {}) {\n return new OverType(target, options);\n }\n\n /**\n * Initialize editors with options from data-ot-* attributes\n * @param {string} selector - CSS selector for target elements\n * @param {Object} defaults - Default options (data attrs override these)\n * @returns {Array<OverType>} Array of OverType instances\n * @example\n * // HTML: <div class=\"editor\" data-ot-toolbar=\"true\" data-ot-theme=\"cave\"></div>\n * OverType.initFromData('.editor', { fontSize: '14px' });\n */\n static initFromData(selector, defaults = {}) {\n const elements = document.querySelectorAll(selector);\n return Array.from(elements).map(el => {\n const options = { ...defaults };\n\n // Parse data-ot-* attributes (kebab-case to camelCase)\n for (const attr of el.attributes) {\n if (attr.name.startsWith('data-ot-')) {\n const kebab = attr.name.slice(8); // Remove 'data-ot-'\n const key = kebab.replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n options[key] = OverType._parseDataValue(attr.value);\n }\n }\n\n return new OverType(el, options)[0];\n });\n }\n\n /**\n * Parse a data attribute value to the appropriate type\n * @private\n */\n static _parseDataValue(value) {\n if (value === 'true') return true;\n if (value === 'false') return false;\n if (value === 'null') return null;\n if (value !== '' && !isNaN(Number(value))) return Number(value);\n return value;\n }\n\n /**\n * Get instance from element\n * @param {Element} element - DOM element\n * @returns {OverType|null} OverType instance or null\n */\n static getInstance(element) {\n return element.overTypeInstance || OverType.instances.get(element) || null;\n }\n\n /**\n * Destroy all instances\n */\n static destroyAll() {\n const elements = document.querySelectorAll('[data-overtype-instance]');\n elements.forEach(element => {\n const instance = OverType.getInstance(element);\n if (instance) {\n instance.destroy();\n }\n });\n }\n\n /**\n * Inject styles into the document\n * @param {boolean} force - Force re-injection\n */\n static injectStyles(force = false) {\n if (OverType.stylesInjected && !force) return;\n\n // Remove any existing OverType styles\n const existing = document.querySelector('style.overtype-styles');\n if (existing) {\n existing.remove();\n }\n\n // Generate and inject new styles with current theme\n const theme = OverType.currentTheme || solar;\n const styles = generateStyles({ theme });\n const styleEl = document.createElement('style');\n styleEl.className = 'overtype-styles';\n styleEl.textContent = styles;\n document.head.appendChild(styleEl);\n\n OverType.stylesInjected = true;\n }\n \n /**\n * Set global theme for all OverType instances\n * @param {string|Object} theme - Theme name or custom theme object\n * @param {Object} customColors - Optional color overrides\n */\n static setTheme(theme, customColors = null) {\n OverType._globalAutoTheme = false;\n OverType._globalAutoCustomColors = null;\n\n if (theme === 'auto') {\n OverType._globalAutoTheme = true;\n OverType._globalAutoCustomColors = customColors;\n OverType._startAutoListener();\n OverType._applyGlobalTheme(resolveAutoTheme('auto'), customColors);\n return;\n }\n\n OverType._stopAutoListener();\n OverType._applyGlobalTheme(theme, customColors);\n }\n\n static _applyGlobalTheme(theme, customColors = null) {\n let themeObj = typeof theme === 'string' ? getTheme(theme) : theme;\n\n if (customColors) {\n themeObj = mergeTheme(themeObj, customColors);\n }\n\n OverType.currentTheme = themeObj;\n OverType.injectStyles(true);\n\n const themeName = typeof themeObj === 'string' ? themeObj : themeObj.name;\n\n document.querySelectorAll('.overtype-container').forEach(container => {\n if (themeName) {\n container.setAttribute('data-theme', themeName);\n }\n });\n\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n if (!wrapper.closest('.overtype-container')) {\n if (themeName) {\n wrapper.setAttribute('data-theme', themeName);\n }\n }\n\n const instance = wrapper._instance;\n if (instance) {\n instance.updatePreview();\n }\n });\n\n document.querySelectorAll('overtype-editor').forEach(webComponent => {\n if (themeName && typeof webComponent.setAttribute === 'function') {\n webComponent.setAttribute('theme', themeName);\n }\n if (typeof webComponent.refreshTheme === 'function') {\n webComponent.refreshTheme();\n }\n });\n }\n\n static _startAutoListener() {\n if (OverType._autoMediaQuery) return;\n if (!window.matchMedia) return;\n\n OverType._autoMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n OverType._autoMediaListener = (e) => {\n const resolved = e.matches ? 'cave' : 'solar';\n\n if (OverType._globalAutoTheme) {\n OverType._applyGlobalTheme(resolved, OverType._globalAutoCustomColors);\n }\n\n OverType._autoInstances.forEach(inst => inst._applyResolvedTheme(resolved));\n };\n\n OverType._autoMediaQuery.addEventListener('change', OverType._autoMediaListener);\n }\n\n static _stopAutoListener() {\n if (OverType._autoInstances.size > 0 || OverType._globalAutoTheme) return;\n if (!OverType._autoMediaQuery) return;\n\n OverType._autoMediaQuery.removeEventListener('change', OverType._autoMediaListener);\n OverType._autoMediaQuery = null;\n OverType._autoMediaListener = null;\n }\n\n /**\n * Set global code highlighter for all OverType instances\n * @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML\n */\n static setCodeHighlighter(highlighter) {\n MarkdownParser.setCodeHighlighter(highlighter);\n\n // Update all existing instances in light DOM\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n const instance = wrapper._instance;\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n });\n\n // Update web components (shadow DOM instances)\n document.querySelectorAll('overtype-editor').forEach(webComponent => {\n if (typeof webComponent.getEditor === 'function') {\n const instance = webComponent.getEditor();\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n }\n });\n }\n\n /**\n * Set custom syntax processor for extending markdown parsing\n * @param {Function|null} processor - Function that takes (html) and returns modified HTML\n * @example\n * OverType.setCustomSyntax((html) => {\n * // Highlight footnote references [^1]\n * return html.replace(/\\[\\^(\\w+)\\]/g, '<span class=\"footnote-ref\">$&</span>');\n * });\n */\n static setCustomSyntax(processor) {\n MarkdownParser.setCustomSyntax(processor);\n\n // Update all existing instances\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n const instance = wrapper._instance;\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n });\n\n document.querySelectorAll('overtype-editor').forEach(webComponent => {\n if (typeof webComponent.getEditor === 'function') {\n const instance = webComponent.getEditor();\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n }\n });\n }\n\n /**\n * Initialize global event listeners\n */\n static initGlobalListeners() {\n if (OverType.globalListenersInitialized) return;\n\n // Input event\n document.addEventListener('input', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleInput(e);\n }\n });\n\n // Keydown event\n document.addEventListener('keydown', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleKeydown(e);\n }\n });\n\n // Scroll event\n document.addEventListener('scroll', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleScroll(e);\n }\n }, true);\n\n // Selection change event\n document.addEventListener('selectionchange', (e) => {\n const activeElement = document.activeElement;\n if (activeElement && activeElement.classList.contains('overtype-input')) {\n const wrapper = activeElement.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) {\n // Update stats bar for cursor position\n if (instance.options.showStats && instance.statsBar) {\n instance._updateStats();\n }\n // Debounce updates\n clearTimeout(instance._selectionTimeout);\n instance._selectionTimeout = setTimeout(() => {\n instance.updatePreview();\n }, 50);\n }\n }\n });\n\n OverType.globalListenersInitialized = true;\n }\n}\n\n// Export classes for advanced usage\nOverType.MarkdownParser = MarkdownParser;\nOverType.ShortcutsManager = ShortcutsManager;\n\n// Export theme utilities\nOverType.themes = { solar, cave: getTheme('cave') };\nOverType.getTheme = getTheme;\n\n// Set default theme\nOverType.currentTheme = solar;\n\n// Export for module systems\nexport default OverType;\nexport { OverType };\n\n// Export toolbar buttons for custom toolbar configurations\nexport { toolbarButtons, defaultToolbarButtons } from './toolbar-buttons.js';\n", "/**\n * MarkdownParser - Parses markdown into HTML while preserving character alignment\n *\n * Key principles:\n * - Every character must occupy the exact same position as in the textarea\n * - No font-size changes, no padding/margin on inline elements\n * - Markdown tokens remain visible but styled\n */\nexport class MarkdownParser {\n // Track link index for anchor naming\n static linkIndex = 0;\n\n // Global code highlighter function\n static codeHighlighter = null;\n\n // Custom syntax processor function\n static customSyntax = null;\n\n /**\n * Reset link index (call before parsing a new document)\n */\n static resetLinkIndex() {\n this.linkIndex = 0;\n }\n\n /**\n * Set global code highlighter function\n * @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML\n */\n static setCodeHighlighter(highlighter) {\n this.codeHighlighter = highlighter;\n }\n\n /**\n * Set custom syntax processor function\n * @param {Function|null} processor - Function that takes (html) and returns modified HTML\n */\n static setCustomSyntax(processor) {\n this.customSyntax = processor;\n }\n\n /**\n * Apply custom syntax processor to parsed HTML\n * @param {string} html - Parsed HTML line\n * @returns {string} HTML with custom syntax applied\n */\n static applyCustomSyntax(html) {\n if (this.customSyntax) {\n return this.customSyntax(html);\n }\n return html;\n }\n\n /**\n * Escape HTML special characters\n * @param {string} text - Raw text to escape\n * @returns {string} Escaped HTML-safe text\n */\n static escapeHtml(text) {\n const map = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;'\n };\n return text.replace(/[&<>\"']/g, m => map[m]);\n }\n\n /**\n * Preserve leading spaces as non-breaking spaces\n * @param {string} html - HTML string\n * @param {string} originalLine - Original line with spaces\n * @returns {string} HTML with preserved indentation\n */\n static preserveIndentation(html, originalLine) {\n const leadingSpaces = originalLine.match(/^(\\s*)/)[1];\n const indentation = leadingSpaces.replace(/ /g, '&nbsp;');\n return html.replace(/^\\s*/, indentation);\n }\n\n /**\n * Parse headers (h1-h3 only)\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed HTML with header styling\n */\n static parseHeader(html) {\n return html.replace(/^(#{1,3})\\s(.+)$/, (match, hashes, content) => {\n const level = hashes.length;\n content = this.parseInlineElements(content);\n return `<h${level}><span class=\"syntax-marker\">${hashes} </span>${content}</h${level}>`;\n });\n }\n\n /**\n * Parse horizontal rules\n * @param {string} html - HTML line to parse\n * @returns {string|null} Parsed horizontal rule or null\n */\n static parseHorizontalRule(html) {\n if (html.match(/^(-{3,}|\\*{3,}|_{3,})$/)) {\n return `<div><span class=\"hr-marker\">${html}</span></div>`;\n }\n return null;\n }\n\n /**\n * Parse blockquotes\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed blockquote\n */\n static parseBlockquote(html) {\n return html.replace(/^&gt; (.+)$/, (match, content) => {\n return `<span class=\"blockquote\"><span class=\"syntax-marker\">&gt;</span> ${content}</span>`;\n });\n }\n\n /**\n * Parse bullet lists\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed bullet list item\n */\n static parseBulletList(html) {\n return html.replace(/^((?:&nbsp;)*)([-*+])\\s(.+)$/, (match, indent, marker, content) => {\n content = this.parseInlineElements(content);\n return `${indent}<li class=\"bullet-list\"><span class=\"syntax-marker\">${marker} </span>${content}</li>`;\n });\n }\n\n /**\n * Parse task lists (GitHub Flavored Markdown checkboxes)\n * @param {string} html - HTML line to parse\n * @param {boolean} isPreviewMode - Whether to render actual checkboxes (preview) or keep syntax visible (normal)\n * @returns {string} Parsed task list item\n */\n static parseTaskList(html, isPreviewMode = false) {\n return html.replace(/^((?:&nbsp;)*)-\\s+\\[([ xX])\\]\\s+(.+)$/, (match, indent, checked, content) => {\n content = this.parseInlineElements(content);\n if (isPreviewMode) {\n // Preview mode: render actual checkbox\n const isChecked = checked.toLowerCase() === 'x';\n return `${indent}<li class=\"task-list\"><input type=\"checkbox\" ${isChecked ? 'checked' : ''}> ${content}</li>`;\n } else {\n // Normal mode: keep syntax visible for alignment\n return `${indent}<li class=\"task-list\"><span class=\"syntax-marker\">- [${checked}] </span>${content}</li>`;\n }\n });\n }\n\n /**\n * Parse numbered lists\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed numbered list item\n */\n static parseNumberedList(html) {\n return html.replace(/^((?:&nbsp;)*)(\\d+\\.)\\s(.+)$/, (match, indent, marker, content) => {\n content = this.parseInlineElements(content);\n return `${indent}<li class=\"ordered-list\"><span class=\"syntax-marker\">${marker} </span>${content}</li>`;\n });\n }\n\n /**\n * Parse code blocks (markers only)\n * @param {string} html - HTML line to parse\n * @returns {string|null} Parsed code fence or null\n */\n static parseCodeBlock(html) {\n // The line must start with three backticks and have no backticks after subsequent text\n const codeFenceRegex = /^`{3}[^`]*$/;\n if (codeFenceRegex.test(html)) {\n return `<div><span class=\"code-fence\">${html}</span></div>`;\n }\n return null;\n }\n\n /**\n * Parse bold text\n * @param {string} html - HTML with potential bold markdown\n * @returns {string} HTML with bold styling\n */\n static parseBold(html) {\n html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong><span class=\"syntax-marker\">**</span>$1<span class=\"syntax-marker\">**</span></strong>');\n html = html.replace(/__(.+?)__/g, '<strong><span class=\"syntax-marker\">__</span>$1<span class=\"syntax-marker\">__</span></strong>');\n return html;\n }\n\n /**\n * Parse italic text\n * Note: Uses lookbehind assertions - requires modern browsers\n * @param {string} html - HTML with potential italic markdown\n * @returns {string} HTML with italic styling\n */\n static parseItalic(html) {\n // Single asterisk - must not be adjacent to other asterisks\n // Must not be inside a syntax-marker span (avoid matching bullet list markers like \">* \")\n html = html.replace(/(?<![\\*>])\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)/g, '<em><span class=\"syntax-marker\">*</span>$1<span class=\"syntax-marker\">*</span></em>');\n\n // Single underscore - must be at word boundaries to avoid matching inside words\n // This prevents matching underscores in the middle of words like \"bold_with_underscore\"\n html = html.replace(/(?<=^|\\s)_(?!_)(.+?)(?<!_)_(?!_)(?=\\s|$)/g, '<em><span class=\"syntax-marker\">_</span>$1<span class=\"syntax-marker\">_</span></em>');\n\n return html;\n }\n\n /**\n * Parse strikethrough text\n * Supports both single (~) and double (~~) tildes, but rejects 3+ tildes\n * @param {string} html - HTML with potential strikethrough markdown\n * @returns {string} HTML with strikethrough styling\n */\n static parseStrikethrough(html) {\n // Double tilde strikethrough: ~~text~~ (but not if part of 3+ tildes)\n html = html.replace(/(?<!~)~~(?!~)(.+?)(?<!~)~~(?!~)/g, '<del><span class=\"syntax-marker\">~~</span>$1<span class=\"syntax-marker\">~~</span></del>');\n // Single tilde strikethrough: ~text~ (but not if part of 2+ tildes on either side)\n html = html.replace(/(?<!~)~(?!~)(.+?)(?<!~)~(?!~)/g, '<del><span class=\"syntax-marker\">~</span>$1<span class=\"syntax-marker\">~</span></del>');\n return html;\n }\n\n /**\n * Parse inline code\n * @param {string} html - HTML with potential code markdown\n * @returns {string} HTML with code styling\n */\n static parseInlineCode(html) {\n // Must have equal number of backticks before and after inline code\n //\n // Regex explainer:\n // (?<!`): A negative lookbehind ensuring the opening backticks are not preceded by another backtick.\n // (`+): A capturing group that matches and remembers the opening sequence of one or more backticks. This is Group 1.\n // ((?:(?!\\1).)+?): A capturing group that greedily matches any character that is not the exact sequence of backticks captured in Group 1. This is Group 2.\n // (\\1): A backreference to Group 1, ensuring the closing sequence has the exact same number of backticks as the opening sequence. This is Group 3.\n // (?!`): A negative lookahead ensuring the closing backticks are not followed by another backtick.\n return html.replace(/(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)/g, '<code><span class=\"syntax-marker\">$1</span>$2<span class=\"syntax-marker\">$3</span></code>');\n }\n\n /**\n * Sanitize URL to prevent XSS attacks\n * @param {string} url - URL to sanitize\n * @returns {string} Safe URL or '#' if dangerous\n */\n static sanitizeUrl(url) {\n // Trim whitespace and convert to lowercase for protocol check\n const trimmed = url.trim();\n const lower = trimmed.toLowerCase();\n\n // Allow safe protocols\n const safeProtocols = [\n 'http://',\n 'https://',\n 'mailto:',\n 'ftp://',\n 'ftps://'\n ];\n\n // Check if URL starts with a safe protocol\n const hasSafeProtocol = safeProtocols.some(protocol => lower.startsWith(protocol));\n\n // Allow relative URLs (starting with / or # or no protocol)\n const isRelative = trimmed.startsWith('/') ||\n trimmed.startsWith('#') ||\n trimmed.startsWith('?') ||\n trimmed.startsWith('.') ||\n (!trimmed.includes(':') && !trimmed.includes('//'));\n\n // If safe protocol or relative URL, return as-is\n if (hasSafeProtocol || isRelative) {\n return url;\n }\n\n // Block dangerous protocols (javascript:, data:, vbscript:, etc.)\n return '#';\n }\n\n /**\n * Parse links\n * @param {string} html - HTML with potential link markdown\n * @returns {string} HTML with link styling\n */\n static parseLinks(html) {\n return html.replace(/\\[(.+?)\\]\\((.+?)\\)/g, (match, text, url) => {\n const anchorName = `--link-${this.linkIndex++}`;\n // Sanitize URL to prevent XSS attacks\n const safeUrl = this.sanitizeUrl(url);\n // Use real href - pointer-events handles click prevention in normal mode\n return `<a href=\"${safeUrl}\" style=\"anchor-name: ${anchorName}\"><span class=\"syntax-marker\">[</span>${text}<span class=\"syntax-marker url-part\">](${url})</span></a>`;\n });\n }\n\n /**\n * Identify and protect sanctuaries (code and links) before parsing\n * @param {string} text - Text with potential markdown\n * @returns {Object} Object with protected text and sanctuary map\n */\n static identifyAndProtectSanctuaries(text) {\n const sanctuaries = new Map();\n let sanctuaryCounter = 0;\n let protectedText = text;\n \n // Create a map to track protected regions (URLs should not be processed)\n const protectedRegions = [];\n \n // First, find all links and mark their URL regions as protected\n const linkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n let linkMatch;\n while ((linkMatch = linkRegex.exec(text)) !== null) {\n // Calculate the exact position of the URL part\n // linkMatch.index is the start of the match\n // We need to find where \"](\" starts, then add 2 to get URL start\n const bracketPos = linkMatch.index + linkMatch[0].indexOf('](');\n const urlStart = bracketPos + 2;\n const urlEnd = urlStart + linkMatch[2].length;\n protectedRegions.push({ start: urlStart, end: urlEnd });\n }\n \n // Now protect inline code, but skip if it's inside a protected region (URL)\n const codeRegex = /(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)/g;\n let codeMatch;\n const codeMatches = [];\n \n while ((codeMatch = codeRegex.exec(text)) !== null) {\n const codeStart = codeMatch.index;\n const codeEnd = codeMatch.index + codeMatch[0].length;\n \n // Check if this code is inside a protected URL region\n const inProtectedRegion = protectedRegions.some(region => \n codeStart >= region.start && codeEnd <= region.end\n );\n \n if (!inProtectedRegion) {\n codeMatches.push({\n match: codeMatch[0],\n index: codeMatch.index,\n openTicks: codeMatch[1],\n content: codeMatch[2],\n closeTicks: codeMatch[3]\n });\n }\n }\n \n // Replace code matches from end to start to preserve indices\n codeMatches.sort((a, b) => b.index - a.index);\n codeMatches.forEach(codeInfo => {\n const placeholder = `\\uE000${sanctuaryCounter++}\\uE001`;\n sanctuaries.set(placeholder, {\n type: 'code',\n original: codeInfo.match,\n openTicks: codeInfo.openTicks,\n content: codeInfo.content,\n closeTicks: codeInfo.closeTicks\n });\n protectedText = protectedText.substring(0, codeInfo.index) + \n placeholder + \n protectedText.substring(codeInfo.index + codeInfo.match.length);\n });\n \n // Then protect links - they can contain sanctuary placeholders for code but not raw code\n protectedText = protectedText.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, (match, linkText, url) => {\n const placeholder = `\\uE000${sanctuaryCounter++}\\uE001`;\n sanctuaries.set(placeholder, {\n type: 'link',\n original: match,\n linkText,\n url\n });\n return placeholder;\n });\n \n return { protectedText, sanctuaries };\n }\n \n /**\n * Restore and transform sanctuaries back to HTML\n * @param {string} html - HTML with sanctuary placeholders\n * @param {Map} sanctuaries - Map of sanctuaries to restore\n * @returns {string} HTML with sanctuaries restored and transformed\n */\n static restoreAndTransformSanctuaries(html, sanctuaries) {\n // Sort sanctuary placeholders by position to restore in order\n const placeholders = Array.from(sanctuaries.keys()).sort((a, b) => {\n const indexA = html.indexOf(a);\n const indexB = html.indexOf(b);\n return indexA - indexB;\n });\n \n placeholders.forEach(placeholder => {\n const sanctuary = sanctuaries.get(placeholder);\n let replacement;\n \n if (sanctuary.type === 'code') {\n // Transform code sanctuary to HTML\n replacement = `<code><span class=\"syntax-marker\">${sanctuary.openTicks}</span>${sanctuary.content}<span class=\"syntax-marker\">${sanctuary.closeTicks}</span></code>`;\n } else if (sanctuary.type === 'link') {\n // For links, we need to process the link text for markdown\n let processedLinkText = sanctuary.linkText;\n \n // First restore any sanctuary placeholders that were already in the link text\n // (e.g., inline code that was protected before the link)\n sanctuaries.forEach((innerSanctuary, innerPlaceholder) => {\n if (processedLinkText.includes(innerPlaceholder)) {\n if (innerSanctuary.type === 'code') {\n const codeHtml = `<code><span class=\"syntax-marker\">${innerSanctuary.openTicks}</span>${innerSanctuary.content}<span class=\"syntax-marker\">${innerSanctuary.closeTicks}</span></code>`;\n processedLinkText = processedLinkText.replace(innerPlaceholder, codeHtml);\n }\n }\n });\n \n // Now parse other markdown in the link text (bold, italic, etc)\n processedLinkText = this.parseStrikethrough(processedLinkText);\n processedLinkText = this.parseBold(processedLinkText);\n processedLinkText = this.parseItalic(processedLinkText);\n \n // Transform link sanctuary to HTML\n // URL should NOT be processed for markdown - use it as-is\n const anchorName = `--link-${this.linkIndex++}`;\n const safeUrl = this.sanitizeUrl(sanctuary.url);\n replacement = `<a href=\"${safeUrl}\" style=\"anchor-name: ${anchorName}\"><span class=\"syntax-marker\">[</span>${processedLinkText}<span class=\"syntax-marker url-part\">](${sanctuary.url})</span></a>`;\n }\n \n html = html.replace(placeholder, replacement);\n });\n \n return html;\n }\n \n /**\n * Parse all inline elements in correct order\n * @param {string} text - Text with potential inline markdown\n * @returns {string} HTML with all inline styling\n */\n static parseInlineElements(text) {\n // Step 1: Identify and protect sanctuaries (code and links)\n const { protectedText, sanctuaries } = this.identifyAndProtectSanctuaries(text);\n \n // Step 2: Parse other inline elements on protected text\n let html = protectedText;\n html = this.parseStrikethrough(html);\n html = this.parseBold(html);\n html = this.parseItalic(html);\n \n // Step 3: Restore and transform sanctuaries\n html = this.restoreAndTransformSanctuaries(html, sanctuaries);\n \n return html;\n }\n\n /**\n * Parse a single line of markdown\n * @param {string} line - Raw markdown line\n * @returns {string} Parsed HTML line\n */\n static parseLine(line, isPreviewMode = false) {\n let html = this.escapeHtml(line);\n\n // Preserve indentation\n html = this.preserveIndentation(html, line);\n\n // Check for block elements first\n const horizontalRule = this.parseHorizontalRule(html);\n if (horizontalRule) return horizontalRule;\n\n const codeBlock = this.parseCodeBlock(html);\n if (codeBlock) return codeBlock;\n\n // Parse block elements\n html = this.parseHeader(html);\n html = this.parseBlockquote(html);\n html = this.parseTaskList(html, isPreviewMode); // Check task lists before regular bullet lists\n html = this.parseBulletList(html);\n html = this.parseNumberedList(html);\n\n // Parse inline elements (skip for headers and list items \u2014 already parsed inside those functions)\n if (!html.includes('<li') && !html.includes('<h')) {\n html = this.parseInlineElements(html);\n }\n\n // Wrap in div to maintain line structure\n if (html.trim() === '') {\n // Intentionally use &nbsp; for empty lines to maintain vertical spacing\n // This causes a 0->1 character count difference but preserves visual alignment\n return '<div>&nbsp;</div>';\n }\n\n return `<div>${html}</div>`;\n }\n\n /**\n * Parse full markdown text\n * @param {string} text - Full markdown text\n * @param {number} activeLine - Currently active line index (optional)\n * @param {boolean} showActiveLineRaw - Show raw markdown on active line\n * @param {Function} instanceHighlighter - Instance-specific code highlighter (optional, overrides global if provided)\n * @returns {string} Parsed HTML\n */\n static parse(text, activeLine = -1, showActiveLineRaw = false, instanceHighlighter, isPreviewMode = false) {\n // Reset link counter for each parse\n this.resetLinkIndex();\n\n const lines = text.split('\\n');\n let inCodeBlock = false;\n\n const parsedLines = lines.map((line, index) => {\n // Show raw markdown on active line if requested\n if (showActiveLineRaw && index === activeLine) {\n const content = this.escapeHtml(line) || '&nbsp;';\n return `<div class=\"raw-line\">${content}</div>`;\n }\n\n // Check if this line is a code fence\n const codeFenceRegex = /^```[^`]*$/;\n if (codeFenceRegex.test(line)) {\n inCodeBlock = !inCodeBlock;\n // Parse fence markers normally to get styled output\n return this.applyCustomSyntax(this.parseLine(line, isPreviewMode));\n }\n\n // If we're inside a code block, don't parse as markdown\n if (inCodeBlock) {\n const escaped = this.escapeHtml(line);\n const indented = this.preserveIndentation(escaped, line);\n return `<div>${indented || '&nbsp;'}</div>`;\n }\n\n // Otherwise, parse the markdown normally\n return this.applyCustomSyntax(this.parseLine(line, isPreviewMode));\n });\n\n // Join without newlines to prevent extra spacing\n const html = parsedLines.join('');\n\n // Apply post-processing for list consolidation\n return this.postProcessHTML(html, instanceHighlighter);\n }\n\n /**\n * Post-process HTML to consolidate lists and code blocks\n * @param {string} html - HTML to post-process\n * @param {Function} instanceHighlighter - Instance-specific code highlighter (optional, overrides global if provided)\n * @returns {string} Post-processed HTML with consolidated lists and code blocks\n */\n static postProcessHTML(html, instanceHighlighter) {\n // Check if we're in a browser environment\n if (typeof document === 'undefined' || !document) {\n // In Node.js environment - do manual post-processing\n return this.postProcessHTMLManual(html, instanceHighlighter);\n }\n\n // Parse HTML string into DOM\n const container = document.createElement('div');\n container.innerHTML = html;\n\n let currentList = null;\n let listType = null;\n let currentCodeBlock = null;\n let inCodeBlock = false;\n\n // Process all direct children - need to be careful with live NodeList\n const children = Array.from(container.children);\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n\n // Skip if child was already processed/removed\n if (!child.parentNode) continue;\n\n // Check for code fence start/end\n const codeFence = child.querySelector('.code-fence');\n if (codeFence) {\n const fenceText = codeFence.textContent;\n if (fenceText.startsWith('```')) {\n if (!inCodeBlock) {\n // Start of code block - keep fence visible, then add pre/code\n inCodeBlock = true;\n\n // Create the code block that will follow the fence\n currentCodeBlock = document.createElement('pre');\n const codeElement = document.createElement('code');\n currentCodeBlock.appendChild(codeElement);\n currentCodeBlock.className = 'code-block';\n\n // Extract language if present\n const lang = fenceText.slice(3).trim();\n if (lang) {\n codeElement.className = `language-${lang}`;\n }\n\n // Insert code block after the fence div (don't remove the fence)\n container.insertBefore(currentCodeBlock, child.nextSibling);\n\n // Store reference to the code element for adding content\n currentCodeBlock._codeElement = codeElement;\n currentCodeBlock._language = lang;\n currentCodeBlock._codeContent = '';\n continue;\n } else {\n // End of code block - apply highlighting if needed\n // Use instance highlighter if provided, otherwise fall back to global highlighter\n const highlighter = instanceHighlighter || this.codeHighlighter;\n if (currentCodeBlock && highlighter && currentCodeBlock._codeContent) {\n try {\n const result = highlighter(\n currentCodeBlock._codeContent,\n currentCodeBlock._language || ''\n );\n\n // Check if result is a Promise (async highlighter)\n if (result && typeof result.then === 'function') {\n console.warn('Async highlighters are not supported in parse() because it returns an HTML string. The caller creates new DOM elements from that string, breaking references to the elements we would update. Use synchronous highlighters only.');\n // Keep the plain text fallback that was already set\n } else {\n // Synchronous highlighter\n // Verify highlighter returned non-empty string\n if (result && typeof result === 'string' && result.trim()) {\n currentCodeBlock._codeElement.innerHTML = result;\n }\n // else: keep the plain text fallback that was already set\n }\n } catch (error) {\n console.warn('Code highlighting failed:', error);\n // Keep the plain text content as fallback\n }\n }\n\n inCodeBlock = false;\n currentCodeBlock = null;\n continue;\n }\n }\n }\n\n // Check if we're in a code block - any div that's not a code fence\n if (inCodeBlock && currentCodeBlock && child.tagName === 'DIV' && !child.querySelector('.code-fence')) {\n const codeElement = currentCodeBlock._codeElement || currentCodeBlock.querySelector('code');\n // Add the line content to the code block content (for highlighting)\n if (currentCodeBlock._codeContent.length > 0) {\n currentCodeBlock._codeContent += '\\n';\n }\n // Get the actual text content, preserving spaces\n const lineText = child.textContent.replace(/\\u00A0/g, ' '); // \\u00A0 is nbsp\n currentCodeBlock._codeContent += lineText;\n\n // Also add to the code element (fallback if no highlighter)\n if (codeElement.textContent.length > 0) {\n codeElement.textContent += '\\n';\n }\n codeElement.textContent += lineText;\n child.remove();\n continue;\n }\n\n // Check if this div contains a list item\n let listItem = null;\n if (child.tagName === 'DIV') {\n // Look for li inside the div\n listItem = child.querySelector('li');\n }\n\n if (listItem) {\n const isBullet = listItem.classList.contains('bullet-list');\n const isOrdered = listItem.classList.contains('ordered-list');\n\n if (!isBullet && !isOrdered) {\n currentList = null;\n listType = null;\n continue;\n }\n\n const newType = isBullet ? 'ul' : 'ol';\n\n // Start new list or continue current\n if (!currentList || listType !== newType) {\n currentList = document.createElement(newType);\n container.insertBefore(currentList, child);\n listType = newType;\n }\n\n // Extract and preserve indentation from the div before moving the list item\n const indentationNodes = [];\n for (const node of child.childNodes) {\n if (node.nodeType === 3 && node.textContent.match(/^\\u00A0+$/)) {\n // This is a text node containing only non-breaking spaces (indentation)\n indentationNodes.push(node.cloneNode(true));\n } else if (node === listItem) {\n break; // Stop when we reach the list item\n }\n }\n\n // Add indentation to the list item\n indentationNodes.forEach(node => {\n listItem.insertBefore(node, listItem.firstChild);\n });\n\n // Move the list item to the current list\n currentList.appendChild(listItem);\n\n // Remove the now-empty div wrapper\n child.remove();\n } else {\n // Non-list element ends current list\n currentList = null;\n listType = null;\n }\n }\n\n return container.innerHTML;\n }\n\n /**\n * Manual post-processing for Node.js environments (without DOM)\n * @param {string} html - HTML to post-process\n * @param {Function} instanceHighlighter - Instance-specific code highlighter (optional, overrides global if provided)\n * @returns {string} Post-processed HTML\n */\n static postProcessHTMLManual(html, instanceHighlighter) {\n let processed = html;\n\n // Process unordered lists\n processed = processed.replace(/((?:<div>(?:&nbsp;)*<li class=\"bullet-list\">.*?<\\/li><\\/div>\\s*)+)/gs, (match) => {\n const divs = match.match(/<div>(?:&nbsp;)*<li class=\"bullet-list\">.*?<\\/li><\\/div>/gs) || [];\n if (divs.length > 0) {\n const items = divs.map(div => {\n // Extract indentation and list item\n const indentMatch = div.match(/<div>((?:&nbsp;)*)<li/);\n const listItemMatch = div.match(/<li class=\"bullet-list\">.*?<\\/li>/);\n\n if (indentMatch && listItemMatch) {\n const indentation = indentMatch[1];\n const listItem = listItemMatch[0];\n // Insert indentation at the start of the list item content\n return listItem.replace(/<li class=\"bullet-list\">/, `<li class=\"bullet-list\">${indentation}`);\n }\n return listItemMatch ? listItemMatch[0] : '';\n }).filter(Boolean);\n\n return '<ul>' + items.join('') + '</ul>';\n }\n return match;\n });\n\n // Process ordered lists\n processed = processed.replace(/((?:<div>(?:&nbsp;)*<li class=\"ordered-list\">.*?<\\/li><\\/div>\\s*)+)/gs, (match) => {\n const divs = match.match(/<div>(?:&nbsp;)*<li class=\"ordered-list\">.*?<\\/li><\\/div>/gs) || [];\n if (divs.length > 0) {\n const items = divs.map(div => {\n // Extract indentation and list item\n const indentMatch = div.match(/<div>((?:&nbsp;)*)<li/);\n const listItemMatch = div.match(/<li class=\"ordered-list\">.*?<\\/li>/);\n\n if (indentMatch && listItemMatch) {\n const indentation = indentMatch[1];\n const listItem = listItemMatch[0];\n // Insert indentation at the start of the list item content\n return listItem.replace(/<li class=\"ordered-list\">/, `<li class=\"ordered-list\">${indentation}`);\n }\n return listItemMatch ? listItemMatch[0] : '';\n }).filter(Boolean);\n\n return '<ol>' + items.join('') + '</ol>';\n }\n return match;\n });\n\n // Process code blocks - KEEP the fence markers for alignment AND use semantic pre/code\n const codeBlockRegex = /<div><span class=\"code-fence\">(```[^<]*)<\\/span><\\/div>(.*?)<div><span class=\"code-fence\">(```)<\\/span><\\/div>/gs;\n processed = processed.replace(codeBlockRegex, (match, openFence, content, closeFence) => {\n // Extract the content between fences\n const lines = content.match(/<div>(.*?)<\\/div>/gs) || [];\n const codeContent = lines.map(line => {\n // Extract text from each div - content is already escaped\n const text = line.replace(/<div>(.*?)<\\/div>/s, '$1')\n .replace(/&nbsp;/g, ' ');\n return text;\n }).join('\\n');\n\n // Extract language from the opening fence\n const lang = openFence.slice(3).trim();\n const langClass = lang ? ` class=\"language-${lang}\"` : '';\n\n // Apply code highlighting if available\n let highlightedContent = codeContent;\n // Use instance highlighter if provided, otherwise fall back to global highlighter\n const highlighter = instanceHighlighter || this.codeHighlighter;\n if (highlighter) {\n try {\n // CRITICAL: Decode HTML entities before passing to highlighter\n // In the DOM path, textContent automatically decodes entities.\n // In the manual path, we need to decode explicitly to avoid double-escaping.\n const decodedCode = codeContent\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&amp;/g, '&'); // Must be last to avoid double-decoding\n\n const result = highlighter(decodedCode, lang);\n\n // Check if result is a Promise (async highlighter)\n // Note: In Node.js context, we can't easily defer rendering, so we warn\n if (result && typeof result.then === 'function') {\n console.warn('Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering.');\n // Fall back to escaped content\n } else {\n // Synchronous highlighter - verify returned non-empty string\n if (result && typeof result === 'string' && result.trim()) {\n highlightedContent = result;\n }\n // else: keep the escaped codeContent as fallback\n }\n } catch (error) {\n console.warn('Code highlighting failed:', error);\n // Fall back to original content\n }\n }\n\n // Keep fence markers visible as separate divs, with pre/code block between them\n let result = `<div><span class=\"code-fence\">${openFence}</span></div>`;\n // Use highlighted content if available, otherwise use escaped content\n result += `<pre class=\"code-block\"><code${langClass}>${highlightedContent}</code></pre>`;\n result += `<div><span class=\"code-fence\">${closeFence}</span></div>`;\n\n return result;\n });\n\n return processed;\n }\n\n /**\n * List pattern definitions\n */\n static LIST_PATTERNS = {\n bullet: /^(\\s*)([-*+])\\s+(.*)$/,\n numbered: /^(\\s*)(\\d+)\\.\\s+(.*)$/,\n checkbox: /^(\\s*)-\\s+\\[([ x])\\]\\s+(.*)$/\n };\n\n /**\n * Get list context at cursor position\n * @param {string} text - Full text content\n * @param {number} cursorPosition - Current cursor position\n * @returns {Object} List context information\n */\n static getListContext(text, cursorPosition) {\n // Find the line containing the cursor\n const lines = text.split('\\n');\n let currentPos = 0;\n let lineIndex = 0;\n let lineStart = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const lineLength = lines[i].length;\n if (currentPos + lineLength >= cursorPosition) {\n lineIndex = i;\n lineStart = currentPos;\n break;\n }\n currentPos += lineLength + 1; // +1 for newline\n }\n\n const currentLine = lines[lineIndex];\n const lineEnd = lineStart + currentLine.length;\n\n // Check for checkbox first (most specific)\n const checkboxMatch = currentLine.match(this.LIST_PATTERNS.checkbox);\n if (checkboxMatch) {\n return {\n inList: true,\n listType: 'checkbox',\n indent: checkboxMatch[1],\n marker: '-',\n checked: checkboxMatch[2] === 'x',\n content: checkboxMatch[3],\n lineStart,\n lineEnd,\n markerEndPos: lineStart + checkboxMatch[1].length + checkboxMatch[2].length + 5 // indent + \"- [ ] \"\n };\n }\n\n // Check for bullet list\n const bulletMatch = currentLine.match(this.LIST_PATTERNS.bullet);\n if (bulletMatch) {\n return {\n inList: true,\n listType: 'bullet',\n indent: bulletMatch[1],\n marker: bulletMatch[2],\n content: bulletMatch[3],\n lineStart,\n lineEnd,\n markerEndPos: lineStart + bulletMatch[1].length + bulletMatch[2].length + 1 // indent + marker + space\n };\n }\n\n // Check for numbered list\n const numberedMatch = currentLine.match(this.LIST_PATTERNS.numbered);\n if (numberedMatch) {\n return {\n inList: true,\n listType: 'numbered',\n indent: numberedMatch[1],\n marker: parseInt(numberedMatch[2]),\n content: numberedMatch[3],\n lineStart,\n lineEnd,\n markerEndPos: lineStart + numberedMatch[1].length + numberedMatch[2].length + 2 // indent + number + \". \"\n };\n }\n\n // Not in a list\n return {\n inList: false,\n listType: null,\n indent: '',\n marker: null,\n content: currentLine,\n lineStart,\n lineEnd,\n markerEndPos: lineStart\n };\n }\n\n /**\n * Create a new list item based on context\n * @param {Object} context - List context from getListContext\n * @returns {string} New list item text\n */\n static createNewListItem(context) {\n switch (context.listType) {\n case 'bullet':\n return `${context.indent}${context.marker} `;\n case 'numbered':\n return `${context.indent}${context.marker + 1}. `;\n case 'checkbox':\n return `${context.indent}- [ ] `;\n default:\n return '';\n }\n }\n\n /**\n * Renumber all numbered lists in text\n * @param {string} text - Text containing numbered lists\n * @returns {string} Text with renumbered lists\n */\n static renumberLists(text) {\n const lines = text.split('\\n');\n const numbersByIndent = new Map();\n let inList = false;\n\n const result = lines.map(line => {\n const match = line.match(this.LIST_PATTERNS.numbered);\n\n if (match) {\n const indent = match[1];\n const indentLevel = indent.length;\n const content = match[3];\n\n // If we weren't in a list or indent changed, reset lower levels\n if (!inList) {\n numbersByIndent.clear();\n }\n\n // Get the next number for this indent level\n const currentNumber = (numbersByIndent.get(indentLevel) || 0) + 1;\n numbersByIndent.set(indentLevel, currentNumber);\n\n // Clear deeper indent levels\n for (const [level] of numbersByIndent) {\n if (level > indentLevel) {\n numbersByIndent.delete(level);\n }\n }\n\n inList = true;\n return `${indent}${currentNumber}. ${content}`;\n } else {\n // Not a numbered list item\n if (line.trim() === '' || !line.match(/^\\s/)) {\n // Empty line or non-indented line breaks the list\n inList = false;\n numbersByIndent.clear();\n }\n return line;\n }\n });\n\n return result.join('\\n');\n }\n}\n", "/**\n * Keyboard shortcuts handler for OverType editor\n * Delegates to editor.performAction for consistent behavior\n */\n\n/**\n * ShortcutsManager - Handles keyboard shortcuts for the editor\n */\nexport class ShortcutsManager {\n constructor(editor) {\n this.editor = editor;\n }\n\n /**\n * Handle keydown events - called by OverType\n * @param {KeyboardEvent} event - The keyboard event\n * @returns {boolean} Whether the event was handled\n */\n handleKeydown(event) {\n const isMac = navigator.platform.toLowerCase().includes('mac');\n const modKey = isMac ? event.metaKey : event.ctrlKey;\n\n if (!modKey) return false;\n\n let actionId = null;\n\n switch (event.key.toLowerCase()) {\n case 'b':\n if (!event.shiftKey) actionId = 'toggleBold';\n break;\n case 'i':\n if (!event.shiftKey) actionId = 'toggleItalic';\n break;\n case 'k':\n if (!event.shiftKey) actionId = 'insertLink';\n break;\n case '7':\n if (event.shiftKey) actionId = 'toggleNumberedList';\n break;\n case '8':\n if (event.shiftKey) actionId = 'toggleBulletList';\n break;\n }\n\n if (actionId) {\n event.preventDefault();\n this.editor.performAction(actionId, event);\n return true;\n }\n\n return false;\n }\n\n /**\n * Cleanup\n */\n destroy() {\n // Nothing to clean up since we don't add our own listener\n }\n}\n", "/**\n * Built-in themes for OverType editor\n * Each theme provides a complete color palette for the editor\n */\n\n/**\n * Solar theme - Light, warm and bright\n */\nexport const solar = {\n name: 'solar',\n colors: {\n bgPrimary: '#faf0ca', // Lemon Chiffon - main background\n bgSecondary: '#ffffff', // White - editor background\n text: '#0d3b66', // Yale Blue - main text\n textPrimary: '#0d3b66', // Yale Blue - primary text (same as text)\n textSecondary: '#5a7a9b', // Muted blue - secondary text\n h1: '#f95738', // Tomato - h1 headers\n h2: '#ee964b', // Sandy Brown - h2 headers\n h3: '#3d8a51', // Forest green - h3 headers\n strong: '#ee964b', // Sandy Brown - bold text\n em: '#f95738', // Tomato - italic text\n del: '#ee964b', // Sandy Brown - deleted text (same as strong)\n link: '#0d3b66', // Yale Blue - links\n code: '#0d3b66', // Yale Blue - inline code\n codeBg: 'rgba(244, 211, 94, 0.4)', // Naples Yellow with transparency\n blockquote: '#5a7a9b', // Muted blue - blockquotes\n hr: '#5a7a9b', // Muted blue - horizontal rules\n syntaxMarker: 'rgba(13, 59, 102, 0.52)', // Yale Blue with transparency\n syntax: '#999999', // Gray - syntax highlighting fallback\n cursor: '#f95738', // Tomato - cursor\n selection: 'rgba(244, 211, 94, 0.4)', // Naples Yellow with transparency\n listMarker: '#ee964b', // Sandy Brown - list markers\n rawLine: '#5a7a9b', // Muted blue - raw line indicators\n border: '#e0e0e0', // Light gray - borders\n hoverBg: '#f0f0f0', // Very light gray - hover backgrounds\n primary: '#0d3b66', // Yale Blue - primary accent\n // Toolbar colors\n toolbarBg: '#ffffff', // White - toolbar background\n toolbarIcon: '#0d3b66', // Yale Blue - icon color\n toolbarHover: '#f5f5f5', // Light gray - hover background\n toolbarActive: '#faf0ca', // Lemon Chiffon - active button background\n placeholder: '#999999', // Gray - placeholder text\n }\n};\n\n/**\n * Cave theme - Dark ocean depths\n */\nexport const cave = {\n name: 'cave',\n colors: {\n bgPrimary: '#141E26', // Deep ocean - main background\n bgSecondary: '#1D2D3E', // Darker charcoal - editor background\n text: '#c5dde8', // Light blue-gray - main text\n textPrimary: '#c5dde8', // Light blue-gray - primary text (same as text)\n textSecondary: '#9fcfec', // Brighter blue - secondary text\n h1: '#d4a5ff', // Rich lavender - h1 headers\n h2: '#f6ae2d', // Hunyadi Yellow - h2 headers\n h3: '#9fcfec', // Brighter blue - h3 headers\n strong: '#f6ae2d', // Hunyadi Yellow - bold text\n em: '#9fcfec', // Brighter blue - italic text\n del: '#f6ae2d', // Hunyadi Yellow - deleted text (same as strong)\n link: '#9fcfec', // Brighter blue - links\n code: '#c5dde8', // Light blue-gray - inline code\n codeBg: '#1a232b', // Very dark blue - code background\n blockquote: '#9fcfec', // Brighter blue - same as italic\n hr: '#c5dde8', // Light blue-gray - horizontal rules\n syntaxMarker: 'rgba(159, 207, 236, 0.73)', // Brighter blue semi-transparent\n syntax: '#7a8c98', // Muted gray-blue - syntax highlighting fallback\n cursor: '#f26419', // Orange Pantone - cursor\n selection: 'rgba(51, 101, 138, 0.4)', // Lapis Lazuli with transparency\n listMarker: '#f6ae2d', // Hunyadi Yellow - list markers\n rawLine: '#9fcfec', // Brighter blue - raw line indicators\n border: '#2a3f52', // Dark blue-gray - borders\n hoverBg: '#243546', // Slightly lighter charcoal - hover backgrounds\n primary: '#9fcfec', // Brighter blue - primary accent\n // Toolbar colors for dark theme\n toolbarBg: '#1D2D3E', // Darker charcoal - toolbar background\n toolbarIcon: '#c5dde8', // Light blue-gray - icon color\n toolbarHover: '#243546', // Slightly lighter charcoal - hover background\n toolbarActive: '#2a3f52', // Even lighter - active button background\n placeholder: '#6a7a88', // Muted blue-gray - placeholder text\n }\n};\n\n/**\n * Default themes registry\n */\nexport const themes = {\n solar,\n cave,\n auto: solar,\n // Aliases for backward compatibility\n light: solar,\n dark: cave\n};\n\n/**\n * Get theme by name or return custom theme object\n * @param {string|Object} theme - Theme name or custom theme object\n * @returns {Object} Theme configuration\n */\nexport function getTheme(theme) {\n if (typeof theme === 'string') {\n const themeObj = themes[theme] || themes.solar;\n // Preserve the requested theme name (important for 'light' and 'dark' aliases)\n return { ...themeObj, name: theme };\n }\n return theme;\n}\n\n/**\n * Resolve auto theme to actual theme based on system color scheme\n * @param {string} themeName - Theme name to resolve\n * @returns {string} Resolved theme name ('solar' or 'cave' if auto, otherwise unchanged)\n */\nexport function resolveAutoTheme(themeName) {\n if (themeName !== 'auto') return themeName;\n const mq = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');\n return mq?.matches ? 'cave' : 'solar';\n}\n\n/**\n * Apply theme colors to CSS variables\n * @param {Object} colors - Theme colors object\n * @returns {string} CSS custom properties string\n */\nexport function themeToCSSVars(colors) {\n const vars = [];\n for (const [key, value] of Object.entries(colors)) {\n // Convert camelCase to kebab-case\n const varName = key.replace(/([A-Z])/g, '-$1').toLowerCase();\n vars.push(`--${varName}: ${value};`);\n }\n return vars.join('\\n');\n}\n\n/**\n * Merge custom colors with base theme\n * @param {Object} baseTheme - Base theme object\n * @param {Object} customColors - Custom color overrides\n * @returns {Object} Merged theme object\n */\nexport function mergeTheme(baseTheme, customColors = {}) {\n return {\n ...baseTheme,\n colors: {\n ...baseTheme.colors,\n ...customColors\n }\n };\n}", "/**\n * CSS styles for OverType editor\n * Embedded in JavaScript to ensure single-file distribution\n */\n\nimport { themeToCSSVars } from './themes.js';\n\n/**\n * Generate the complete CSS for the editor\n * @param {Object} options - Configuration options\n * @returns {string} Complete CSS string\n */\nexport function generateStyles(options = {}) {\n const {\n fontSize = '14px',\n lineHeight = 1.6,\n /* System-first, guaranteed monospaced; avoids Android 'ui-monospace' pitfalls */\n fontFamily = '\"SF Mono\", SFMono-Regular, Menlo, Monaco, \"Cascadia Code\", Consolas, \"Roboto Mono\", \"Noto Sans Mono\", \"Droid Sans Mono\", \"Ubuntu Mono\", \"DejaVu Sans Mono\", \"Liberation Mono\", \"Courier New\", Courier, monospace',\n padding = '20px',\n theme = null,\n mobile = {}\n } = options;\n\n // Generate mobile overrides\n const mobileStyles = Object.keys(mobile).length > 0 ? `\n @media (max-width: 640px) {\n .overtype-wrapper .overtype-input,\n .overtype-wrapper .overtype-preview {\n ${Object.entries(mobile)\n .map(([prop, val]) => {\n const cssProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();\n return `${cssProp}: ${val} !important;`;\n })\n .join('\\n ')}\n }\n }\n ` : '';\n\n // Generate theme variables if provided\n const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors) : '';\n\n return `\n /* OverType Editor Styles */\n \n /* Middle-ground CSS Reset - Prevent parent styles from leaking in */\n .overtype-container * {\n /* Box model - these commonly leak */\n margin: 0 !important;\n padding: 0 !important;\n border: 0 !important;\n \n /* Layout - these can break our layout */\n /* Don't reset position - it breaks dropdowns */\n float: none !important;\n clear: none !important;\n \n /* Typography - only reset decorative aspects */\n text-decoration: none !important;\n text-transform: none !important;\n letter-spacing: normal !important;\n \n /* Visual effects that can interfere */\n box-shadow: none !important;\n text-shadow: none !important;\n \n /* Ensure box-sizing is consistent */\n box-sizing: border-box !important;\n \n /* Keep inheritance for these */\n /* font-family, color, line-height, font-size - inherit */\n }\n \n /* Container base styles after reset */\n .overtype-container {\n display: flex !important;\n flex-direction: column !important;\n width: 100% !important;\n height: 100% !important;\n position: relative !important; /* Override reset - needed for absolute children */\n overflow: visible !important; /* Allow dropdown to overflow container */\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif !important;\n text-align: left !important;\n ${themeVars ? `\n /* Theme Variables */\n ${themeVars}` : ''}\n }\n \n /* Force left alignment for all elements in the editor */\n .overtype-container .overtype-wrapper * {\n text-align: left !important;\n }\n \n /* Auto-resize mode styles */\n .overtype-container.overtype-auto-resize {\n height: auto !important;\n }\n\n .overtype-container.overtype-auto-resize .overtype-wrapper {\n flex: 0 0 auto !important; /* Don't grow/shrink, use explicit height */\n height: auto !important;\n min-height: 60px !important;\n overflow: visible !important;\n }\n \n .overtype-wrapper {\n position: relative !important; /* Override reset - needed for absolute children */\n width: 100% !important;\n flex: 1 1 0 !important; /* Grow to fill remaining space, with flex-basis: 0 */\n min-height: 60px !important; /* Minimum usable height */\n overflow: hidden !important;\n background: var(--bg-secondary, #ffffff) !important;\n z-index: 1; /* Below toolbar and dropdown */\n }\n\n /* Critical alignment styles - must be identical for both layers */\n .overtype-wrapper .overtype-input,\n .overtype-wrapper .overtype-preview {\n /* Positioning - must be identical */\n position: absolute !important; /* Override reset - required for overlay */\n top: 0 !important;\n left: 0 !important;\n width: 100% !important;\n height: 100% !important;\n \n /* Font properties - any difference breaks alignment */\n font-family: ${fontFamily} !important;\n font-variant-ligatures: none !important; /* keep metrics stable for code */\n font-size: var(--instance-font-size, ${fontSize}) !important;\n line-height: var(--instance-line-height, ${lineHeight}) !important;\n font-weight: normal !important;\n font-style: normal !important;\n font-variant: normal !important;\n font-stretch: normal !important;\n font-kerning: none !important;\n font-feature-settings: normal !important;\n \n /* Box model - must match exactly */\n padding: var(--instance-padding, ${padding}) !important;\n margin: 0 !important;\n border: none !important;\n outline: none !important;\n box-sizing: border-box !important;\n \n /* Text layout - critical for character positioning */\n white-space: pre-wrap !important;\n word-wrap: break-word !important;\n word-break: normal !important;\n overflow-wrap: break-word !important;\n tab-size: 2 !important;\n -moz-tab-size: 2 !important;\n text-align: left !important;\n text-indent: 0 !important;\n letter-spacing: normal !important;\n word-spacing: normal !important;\n \n /* Text rendering */\n text-transform: none !important;\n text-rendering: auto !important;\n -webkit-font-smoothing: auto !important;\n -webkit-text-size-adjust: 100% !important;\n \n /* Direction and writing */\n direction: ltr !important;\n writing-mode: horizontal-tb !important;\n unicode-bidi: normal !important;\n text-orientation: mixed !important;\n \n /* Visual effects that could shift perception */\n text-shadow: none !important;\n filter: none !important;\n transform: none !important;\n zoom: 1 !important;\n \n /* Vertical alignment */\n vertical-align: baseline !important;\n \n /* Size constraints */\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: none !important;\n max-height: none !important;\n \n /* Overflow */\n overflow-y: auto !important;\n overflow-x: auto !important;\n /* overscroll-behavior removed to allow scroll-through to parent */\n scrollbar-width: auto !important;\n scrollbar-gutter: auto !important;\n \n /* Animation/transition - disabled to prevent movement */\n animation: none !important;\n transition: none !important;\n }\n\n /* Input layer styles */\n .overtype-wrapper .overtype-input {\n /* Layer positioning */\n z-index: 1 !important;\n \n /* Text visibility */\n color: transparent !important;\n caret-color: var(--cursor, #f95738) !important;\n background-color: transparent !important;\n \n /* Textarea-specific */\n resize: none !important;\n appearance: none !important;\n -webkit-appearance: none !important;\n -moz-appearance: none !important;\n \n /* Prevent mobile zoom on focus */\n touch-action: manipulation !important;\n \n /* Disable autofill */\n autocomplete: off !important;\n autocorrect: off !important;\n autocapitalize: off !important;\n }\n\n .overtype-wrapper .overtype-input::selection {\n background-color: var(--selection, rgba(244, 211, 94, 0.4));\n }\n\n /* Placeholder shim - visible when textarea is empty */\n .overtype-wrapper .overtype-placeholder {\n position: absolute !important;\n top: 0 !important;\n left: 0 !important;\n width: 100% !important;\n z-index: 0 !important;\n pointer-events: none !important;\n user-select: none !important;\n font-family: ${fontFamily} !important;\n font-size: var(--instance-font-size, ${fontSize}) !important;\n line-height: var(--instance-line-height, ${lineHeight}) !important;\n padding: var(--instance-padding, ${padding}) !important;\n box-sizing: border-box !important;\n color: var(--placeholder, #999) !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n text-overflow: ellipsis !important;\n }\n\n /* Preview layer styles */\n .overtype-wrapper .overtype-preview {\n /* Layer positioning */\n z-index: 0 !important;\n pointer-events: none !important;\n color: var(--text, #0d3b66) !important;\n background-color: transparent !important;\n \n /* Prevent text selection */\n user-select: none !important;\n -webkit-user-select: none !important;\n -moz-user-select: none !important;\n -ms-user-select: none !important;\n }\n\n /* Defensive styles for preview child divs */\n .overtype-wrapper .overtype-preview div {\n /* Reset any inherited styles */\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n text-align: left !important;\n text-indent: 0 !important;\n display: block !important;\n position: static !important;\n transform: none !important;\n min-height: 0 !important;\n max-height: none !important;\n line-height: inherit !important;\n font-size: inherit !important;\n font-family: inherit !important;\n }\n\n /* Markdown element styling - NO SIZE CHANGES */\n .overtype-wrapper .overtype-preview .header {\n font-weight: bold !important;\n }\n\n /* Header colors */\n .overtype-wrapper .overtype-preview .h1 { \n color: var(--h1, #f95738) !important; \n }\n .overtype-wrapper .overtype-preview .h2 { \n color: var(--h2, #ee964b) !important; \n }\n .overtype-wrapper .overtype-preview .h3 { \n color: var(--h3, #3d8a51) !important; \n }\n\n /* Semantic headers - flatten in edit mode */\n .overtype-wrapper .overtype-preview h1,\n .overtype-wrapper .overtype-preview h2,\n .overtype-wrapper .overtype-preview h3 {\n font-size: inherit !important;\n font-weight: bold !important;\n margin: 0 !important;\n padding: 0 !important;\n display: inline !important;\n line-height: inherit !important;\n }\n\n /* Header colors for semantic headers */\n .overtype-wrapper .overtype-preview h1 { \n color: var(--h1, #f95738) !important; \n }\n .overtype-wrapper .overtype-preview h2 { \n color: var(--h2, #ee964b) !important; \n }\n .overtype-wrapper .overtype-preview h3 { \n color: var(--h3, #3d8a51) !important; \n }\n\n /* Lists - remove styling in edit mode */\n .overtype-wrapper .overtype-preview ul,\n .overtype-wrapper .overtype-preview ol {\n list-style: none !important;\n margin: 0 !important;\n padding: 0 !important;\n display: block !important; /* Lists need to be block for line breaks */\n }\n\n .overtype-wrapper .overtype-preview li {\n display: block !important; /* Each item on its own line */\n margin: 0 !important;\n padding: 0 !important;\n /* Don't set list-style here - let ul/ol control it */\n }\n\n /* Bold text */\n .overtype-wrapper .overtype-preview strong {\n color: var(--strong, #ee964b) !important;\n font-weight: bold !important;\n }\n\n /* Italic text */\n .overtype-wrapper .overtype-preview em {\n color: var(--em, #f95738) !important;\n text-decoration-color: var(--em, #f95738) !important;\n text-decoration-thickness: 1px !important;\n font-style: italic !important;\n }\n\n /* Strikethrough text */\n .overtype-wrapper .overtype-preview del {\n color: var(--del, #ee964b) !important;\n text-decoration: line-through !important;\n text-decoration-color: var(--del, #ee964b) !important;\n text-decoration-thickness: 1px !important;\n }\n\n /* Inline code */\n .overtype-wrapper .overtype-preview code {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n color: var(--code, #0d3b66) !important;\n padding: 0 !important;\n border-radius: 2px !important;\n font-family: inherit !important;\n font-size: inherit !important;\n line-height: inherit !important;\n font-weight: normal !important;\n }\n\n /* Code blocks - consolidated pre blocks */\n .overtype-wrapper .overtype-preview pre {\n padding: 0 !important;\n margin: 0 !important;\n border-radius: 4px !important;\n overflow-x: auto !important;\n }\n \n /* Code block styling in normal mode - yellow background */\n .overtype-wrapper .overtype-preview pre.code-block {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n white-space: break-spaces !important; /* Prevent horizontal scrollbar that breaks alignment */\n }\n\n /* Code inside pre blocks - remove background */\n .overtype-wrapper .overtype-preview pre code {\n background: transparent !important;\n color: var(--code, #0d3b66) !important;\n font-family: ${fontFamily} !important; /* Match textarea font exactly for alignment */\n }\n\n /* Blockquotes */\n .overtype-wrapper .overtype-preview .blockquote {\n color: var(--blockquote, #5a7a9b) !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n }\n\n /* Links */\n .overtype-wrapper .overtype-preview a {\n color: var(--link, #0d3b66) !important;\n text-decoration: underline !important;\n font-weight: normal !important;\n }\n\n .overtype-wrapper .overtype-preview a:hover {\n text-decoration: underline !important;\n color: var(--link, #0d3b66) !important;\n }\n\n /* Lists - no list styling */\n .overtype-wrapper .overtype-preview ul,\n .overtype-wrapper .overtype-preview ol {\n list-style: none !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n\n /* Horizontal rules */\n .overtype-wrapper .overtype-preview hr {\n border: none !important;\n color: var(--hr, #5a7a9b) !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n .overtype-wrapper .overtype-preview .hr-marker {\n color: var(--hr, #5a7a9b) !important;\n opacity: 0.6 !important;\n }\n\n /* Code fence markers - with background when not in code block */\n .overtype-wrapper .overtype-preview .code-fence {\n color: var(--code, #0d3b66) !important;\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n }\n \n /* Code block lines - background for entire code block */\n .overtype-wrapper .overtype-preview .code-block-line {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n }\n \n /* Remove background from code fence when inside code block line */\n .overtype-wrapper .overtype-preview .code-block-line .code-fence {\n background: transparent !important;\n }\n\n /* Raw markdown line */\n .overtype-wrapper .overtype-preview .raw-line {\n color: var(--raw-line, #5a7a9b) !important;\n font-style: normal !important;\n font-weight: normal !important;\n }\n\n /* Syntax markers */\n .overtype-wrapper .overtype-preview .syntax-marker {\n color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important;\n opacity: 0.7 !important;\n }\n\n /* List markers */\n .overtype-wrapper .overtype-preview .list-marker {\n color: var(--list-marker, #ee964b) !important;\n }\n\n /* Stats bar */\n \n /* Stats bar - positioned by flexbox */\n .overtype-stats {\n height: 40px !important;\n padding: 0 20px !important;\n background: #f8f9fa !important;\n border-top: 1px solid #e0e0e0 !important;\n display: flex !important;\n justify-content: space-between !important;\n align-items: center !important;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;\n font-size: 0.85rem !important;\n color: #666 !important;\n flex-shrink: 0 !important; /* Don't shrink */\n z-index: 10001 !important; /* Above link tooltip */\n position: relative !important; /* Enable z-index */\n }\n \n /* Dark theme stats bar */\n .overtype-container[data-theme=\"cave\"] .overtype-stats {\n background: var(--bg-secondary, #1D2D3E) !important;\n border-top: 1px solid rgba(197, 221, 232, 0.1) !important;\n color: var(--text, #c5dde8) !important;\n }\n \n .overtype-stats .overtype-stat {\n display: flex !important;\n align-items: center !important;\n gap: 5px !important;\n white-space: nowrap !important;\n }\n \n .overtype-stats .live-dot {\n width: 8px !important;\n height: 8px !important;\n background: #4caf50 !important;\n border-radius: 50% !important;\n animation: overtype-pulse 2s infinite !important;\n }\n \n @keyframes overtype-pulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.6; transform: scale(1.2); }\n }\n \n\n /* Toolbar Styles */\n .overtype-toolbar.overtype-toolbar-hidden {\n display: none !important;\n }\n\n .overtype-toolbar {\n display: flex !important;\n align-items: center !important;\n gap: 4px !important;\n padding: 8px !important; /* Override reset */\n background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */\n border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */\n overflow-x: auto !important; /* Allow horizontal scrolling */\n overflow-y: hidden !important; /* Hide vertical overflow */\n -webkit-overflow-scrolling: touch !important;\n flex-shrink: 0 !important;\n height: auto !important;\n position: relative !important; /* Override reset */\n z-index: 100 !important; /* Ensure toolbar is above wrapper */\n scrollbar-width: thin; /* Thin scrollbar on Firefox */\n }\n \n /* Thin scrollbar styling */\n .overtype-toolbar::-webkit-scrollbar {\n height: 4px;\n }\n \n .overtype-toolbar::-webkit-scrollbar-track {\n background: transparent;\n }\n \n .overtype-toolbar::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.2);\n border-radius: 2px;\n }\n\n .overtype-toolbar-button {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: var(--toolbar-icon, var(--text-secondary, #666));\n cursor: pointer;\n transition: all 0.2s ease;\n flex-shrink: 0;\n }\n\n .overtype-toolbar-button svg {\n width: 20px;\n height: 20px;\n fill: currentColor;\n }\n\n .overtype-toolbar-button:hover {\n background: var(--toolbar-hover, var(--bg-secondary, #e9ecef));\n color: var(--toolbar-icon, var(--text-primary, #333));\n }\n\n .overtype-toolbar-button:active {\n transform: scale(0.95);\n }\n\n .overtype-toolbar-button.active {\n background: var(--toolbar-active, var(--primary, #007bff));\n color: var(--toolbar-icon, var(--text-primary, #333));\n }\n\n .overtype-toolbar-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .overtype-toolbar-separator {\n width: 1px;\n height: 24px;\n background: var(--border, #e0e0e0);\n margin: 0 4px;\n flex-shrink: 0;\n }\n\n /* Adjust wrapper when toolbar is present */\n /* Mobile toolbar adjustments */\n @media (max-width: 640px) {\n .overtype-toolbar {\n padding: 6px;\n gap: 2px;\n }\n\n .overtype-toolbar-button {\n width: 36px;\n height: 36px;\n }\n\n .overtype-toolbar-separator {\n margin: 0 2px;\n }\n }\n \n /* Plain mode - hide preview and show textarea text */\n .overtype-container[data-mode=\"plain\"] .overtype-preview {\n display: none !important;\n }\n \n .overtype-container[data-mode=\"plain\"] .overtype-input {\n color: var(--text, #0d3b66) !important;\n /* Use system font stack for better plain text readability */\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \n \"Helvetica Neue\", Arial, sans-serif !important;\n }\n \n /* Ensure textarea remains transparent in overlay mode */\n .overtype-container:not([data-mode=\"plain\"]) .overtype-input {\n color: transparent !important;\n }\n\n /* Dropdown menu styles */\n .overtype-toolbar-button {\n position: relative !important; /* Override reset - needed for dropdown */\n }\n\n .overtype-toolbar-button.dropdown-active {\n background: var(--toolbar-active, var(--hover-bg, #f0f0f0));\n }\n\n .overtype-dropdown-menu {\n position: fixed !important; /* Fixed positioning relative to viewport */\n background: var(--bg-secondary, white) !important; /* Override reset */\n border: 1px solid var(--border, #e0e0e0) !important; /* Override reset */\n border-radius: 6px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* Override reset */\n z-index: 10000; /* Very high z-index to ensure visibility */\n min-width: 150px;\n padding: 4px 0 !important; /* Override reset */\n /* Position will be set via JavaScript based on button position */\n }\n\n .overtype-dropdown-item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: 8px 12px;\n border: none;\n background: none;\n text-align: left;\n cursor: pointer;\n font-size: 14px;\n color: var(--text, #333);\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n }\n\n .overtype-dropdown-item:hover {\n background: var(--hover-bg, #f0f0f0);\n }\n\n .overtype-dropdown-item.active {\n font-weight: 600;\n }\n\n .overtype-dropdown-check {\n width: 16px;\n margin-right: 8px;\n color: var(--h1, #007bff);\n }\n\n .overtype-dropdown-icon {\n width: 20px;\n margin-right: 8px;\n text-align: center;\n }\n\n /* Preview mode styles */\n .overtype-container[data-mode=\"preview\"] .overtype-input {\n display: none !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-preview {\n pointer-events: auto !important;\n user-select: text !important;\n cursor: text !important;\n }\n\n /* Hide syntax markers in preview mode */\n .overtype-container[data-mode=\"preview\"] .syntax-marker {\n display: none !important;\n }\n \n /* Hide URL part of links in preview mode - extra specificity */\n .overtype-container[data-mode=\"preview\"] .syntax-marker.url-part,\n .overtype-container[data-mode=\"preview\"] .url-part {\n display: none !important;\n }\n \n /* Hide all syntax markers inside links too */\n .overtype-container[data-mode=\"preview\"] a .syntax-marker {\n display: none !important;\n }\n\n /* Headers - restore proper sizing in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h1, \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h2, \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h3 {\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif !important;\n font-weight: 600 !important;\n margin: 0 !important;\n display: block !important;\n color: inherit !important; /* Use parent text color */\n line-height: 1 !important; /* Tight line height for headings */\n }\n \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h1 { \n font-size: 2em !important; \n }\n \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h2 { \n font-size: 1.5em !important; \n }\n \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h3 { \n font-size: 1.17em !important; \n }\n\n /* Lists - restore list styling in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview ul {\n display: block !important;\n list-style: disc !important;\n padding-left: 2em !important;\n margin: 1em 0 !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview ol {\n display: block !important;\n list-style: decimal !important;\n padding-left: 2em !important;\n margin: 1em 0 !important;\n }\n \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview li {\n display: list-item !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n /* Task list checkboxes - only in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview li.task-list {\n list-style: none !important;\n position: relative !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview li.task-list input[type=\"checkbox\"] {\n margin-right: 0.5em !important;\n cursor: default !important;\n vertical-align: middle !important;\n }\n\n /* Task list in normal mode - keep syntax visible */\n .overtype-container:not([data-mode=\"preview\"]) .overtype-wrapper .overtype-preview li.task-list {\n list-style: none !important;\n }\n\n .overtype-container:not([data-mode=\"preview\"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker {\n color: var(--syntax, #999999) !important;\n font-weight: normal !important;\n }\n\n /* Links - make clickable in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview a {\n pointer-events: auto !important;\n cursor: pointer !important;\n color: var(--link, #0066cc) !important;\n text-decoration: underline !important;\n }\n\n /* Code blocks - proper pre/code styling in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview pre.code-block {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n color: var(--code, #0d3b66) !important;\n padding: 1.2em !important;\n border-radius: 3px !important;\n overflow-x: auto !important;\n margin: 0 !important;\n display: block !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview pre.code-block code {\n background: transparent !important;\n color: inherit !important;\n padding: 0 !important;\n font-family: ${fontFamily} !important;\n font-size: 0.9em !important;\n line-height: 1.4 !important;\n }\n\n /* Hide old code block lines and fences in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .code-block-line {\n display: none !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .code-fence {\n display: none !important;\n }\n\n /* Blockquotes - enhanced styling in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .blockquote {\n display: block !important;\n border-left: 4px solid var(--blockquote, #ddd) !important;\n padding-left: 1em !important;\n margin: 1em 0 !important;\n font-style: italic !important;\n }\n\n /* Typography improvements in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview {\n font-family: Georgia, 'Times New Roman', serif !important;\n font-size: 16px !important;\n line-height: 1.8 !important;\n color: var(--text, #333) !important; /* Consistent text color */\n }\n\n /* Inline code in preview mode - keep monospace */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview code {\n font-family: ${fontFamily} !important;\n font-size: 0.9em !important;\n background: rgba(135, 131, 120, 0.15) !important;\n padding: 0.2em 0.4em !important;\n border-radius: 3px !important;\n }\n\n /* Strong and em elements in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview strong {\n font-weight: 700 !important;\n color: inherit !important; /* Use parent text color */\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview em {\n font-style: italic !important;\n color: inherit !important; /* Use parent text color */\n }\n\n /* HR in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .hr-marker {\n display: block !important;\n border-top: 2px solid var(--hr, #ddd) !important;\n text-indent: -9999px !important;\n height: 2px !important;\n }\n\n /* Link Tooltip */\n .overtype-link-tooltip {\n background: #333 !important;\n color: white !important;\n padding: 6px 10px !important;\n border-radius: 16px !important;\n font-size: 12px !important;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;\n display: flex !important;\n visibility: hidden !important;\n pointer-events: none !important;\n z-index: 10000 !important;\n cursor: pointer !important;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;\n max-width: 300px !important;\n white-space: nowrap !important;\n overflow: hidden !important;\n text-overflow: ellipsis !important;\n position: fixed;\n top: 0;\n left: 0;\n }\n\n .overtype-link-tooltip.visible {\n visibility: visible !important;\n pointer-events: auto !important;\n }\n\n ${mobileStyles}\n `;\n}", "/**\n * Format definitions for markdown syntax\n */\n\nexport const FORMATS = {\n bold: {\n prefix: '**',\n suffix: '**',\n trimFirst: true\n },\n italic: {\n prefix: '_',\n suffix: '_',\n trimFirst: true\n },\n code: {\n prefix: '`',\n suffix: '`',\n blockPrefix: '```',\n blockSuffix: '```'\n },\n link: {\n prefix: '[',\n suffix: '](url)',\n replaceNext: 'url',\n scanFor: 'https?://'\n },\n bulletList: {\n prefix: '- ',\n multiline: true,\n unorderedList: true\n },\n numberedList: {\n prefix: '1. ',\n multiline: true,\n orderedList: true\n },\n quote: {\n prefix: '> ',\n multiline: true,\n surroundWithNewlines: true\n },\n taskList: {\n prefix: '- [ ] ',\n multiline: true,\n surroundWithNewlines: true\n },\n header1: { prefix: '# ' },\n header2: { prefix: '## ' },\n header3: { prefix: '### ' },\n header4: { prefix: '#### ' },\n header5: { prefix: '##### ' },\n header6: { prefix: '###### ' }\n}\n\n/**\n * Default style configuration\n */\nexport function getDefaultStyle() {\n return {\n prefix: '',\n suffix: '',\n blockPrefix: '',\n blockSuffix: '',\n multiline: false,\n replaceNext: '',\n prefixSpace: false,\n scanFor: '',\n surroundWithNewlines: false,\n orderedList: false,\n unorderedList: false,\n trimFirst: false\n }\n}\n\n/**\n * Merge format with defaults\n */\nexport function mergeWithDefaults(format) {\n return { ...getDefaultStyle(), ...format }\n}", "/**\n * Debug utilities for markdown-actions\n * Add console logging to track what's happening\n */\n\n// Debug mode flag - disabled by default\nlet debugMode = false;\n\n/**\n * Enable or disable debug mode\n * @param {boolean} enabled - Whether to enable debug mode\n */\nexport function setDebugMode(enabled) {\n debugMode = enabled;\n}\n\n/**\n * Get current debug mode status\n * @returns {boolean} Whether debug mode is enabled\n */\nexport function getDebugMode() {\n return debugMode;\n}\n\nexport function debugLog(funcName, message, data) {\n // These will be completely removed by esbuild's drop: ['console'] in production\n if (!debugMode) return;\n \n console.group(`\uD83D\uDD0D ${funcName}`);\n console.log(message);\n if (data) {\n console.log('Data:', data);\n }\n console.groupEnd();\n}\n\nexport function debugSelection(textarea, label) {\n // These will be completely removed by esbuild's drop: ['console'] in production\n if (!debugMode) return;\n \n const selected = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n console.group(`\uD83D\uDCCD Selection: ${label}`);\n console.log('Position:', `${textarea.selectionStart}-${textarea.selectionEnd}`);\n console.log('Selected text:', JSON.stringify(selected));\n console.log('Length:', selected.length);\n \n // Show context around selection\n const before = textarea.value.slice(Math.max(0, textarea.selectionStart - 10), textarea.selectionStart);\n const after = textarea.value.slice(textarea.selectionEnd, Math.min(textarea.value.length, textarea.selectionEnd + 10));\n console.log('Context:', JSON.stringify(before) + '[SELECTION]' + JSON.stringify(after));\n console.groupEnd();\n}\n\nexport function debugResult(result) {\n // These will be completely removed by esbuild's drop: ['console'] in production\n if (!debugMode) return;\n \n console.group('\uD83D\uDCDD Result');\n console.log('Text to insert:', JSON.stringify(result.text));\n console.log('New selection:', `${result.selectionStart}-${result.selectionEnd}`);\n console.groupEnd();\n}", "/**\n * Text insertion system with undo/redo support\n * Extracted and adapted from GitHub's markdown-toolbar-element\n */\n\nimport { getDebugMode } from '../debug.js'\n\nlet canInsertText = null\n\n/**\n * Insert text at current position with undo/redo support\n * @param {HTMLTextAreaElement} textarea - Target textarea\n * @param {Object} options - Text and selection options\n * @param {string} options.text - Text to insert\n * @param {number} [options.selectionStart] - New selection start\n * @param {number} [options.selectionEnd] - New selection end\n */\nexport function insertText(textarea, { text, selectionStart, selectionEnd }) {\n const debugMode = getDebugMode();\n \n if (debugMode) {\n console.group('\uD83D\uDD27 insertText');\n console.log('Current selection:', `${textarea.selectionStart}-${textarea.selectionEnd}`);\n console.log('Text to insert:', JSON.stringify(text));\n console.log('New selection to set:', selectionStart, '-', selectionEnd);\n }\n \n // Make sure the textarea is focused\n textarea.focus();\n \n const originalSelectionStart = textarea.selectionStart\n const originalSelectionEnd = textarea.selectionEnd\n const before = textarea.value.slice(0, originalSelectionStart)\n const after = textarea.value.slice(originalSelectionEnd)\n \n if (debugMode) {\n console.log('Before text (last 20):', JSON.stringify(before.slice(-20)));\n console.log('After text (first 20):', JSON.stringify(after.slice(0, 20)));\n console.log('Selected text being replaced:', JSON.stringify(textarea.value.slice(originalSelectionStart, originalSelectionEnd)));\n }\n \n // Store the original value to check if execCommand actually changed it\n const originalValue = textarea.value\n\n // Try execCommand for both insertions and replacements to preserve undo history\n // execCommand('insertText') can handle replacing selected text\n const hasSelection = originalSelectionStart !== originalSelectionEnd\n \n if (canInsertText === null || canInsertText === true) {\n textarea.contentEditable = 'true'\n try {\n canInsertText = document.execCommand('insertText', false, text)\n if (debugMode) console.log('execCommand returned:', canInsertText, 'for text with', text.split('\\n').length, 'lines');\n } catch (error) {\n canInsertText = false\n if (debugMode) console.log('execCommand threw error:', error);\n }\n textarea.contentEditable = 'false'\n }\n\n if (debugMode) {\n console.log('canInsertText before:', canInsertText);\n console.log('execCommand result:', canInsertText);\n }\n \n // Check if execCommand actually worked by comparing the value\n if (canInsertText) {\n const expectedValue = before + text + after\n const actualValue = textarea.value\n \n if (debugMode) {\n console.log('Expected length:', expectedValue.length);\n console.log('Actual length:', actualValue.length);\n }\n \n if (actualValue !== expectedValue) {\n if (debugMode) {\n console.log('execCommand changed the value but not as expected');\n console.log('Expected:', JSON.stringify(expectedValue.slice(0, 100)));\n console.log('Actual:', JSON.stringify(actualValue.slice(0, 100)));\n }\n // Don't set canInsertText to false here - execCommand did work\n // We just need to not double-insert\n }\n }\n\n if (!canInsertText) {\n if (debugMode) console.log('Using manual insertion');\n // Only do manual insertion if execCommand didn't change the value\n if (textarea.value === originalValue) {\n if (debugMode) console.log('Value unchanged, doing manual replacement');\n try {\n document.execCommand('ms-beginUndoUnit')\n } catch (e) {\n // Do nothing.\n }\n textarea.value = before + text + after\n try {\n document.execCommand('ms-endUndoUnit')\n } catch (e) {\n // Do nothing.\n }\n textarea.dispatchEvent(new CustomEvent('input', { bubbles: true, cancelable: true }))\n } else {\n if (debugMode) console.log('Value was changed by execCommand, skipping manual insertion');\n }\n }\n\n if (debugMode) console.log('Setting selection range:', selectionStart, selectionEnd);\n if (selectionStart != null && selectionEnd != null) {\n textarea.setSelectionRange(selectionStart, selectionEnd)\n } else {\n textarea.setSelectionRange(originalSelectionStart, textarea.selectionEnd)\n }\n \n if (debugMode) {\n console.log('Final value length:', textarea.value.length);\n console.groupEnd();\n }\n}\n\n/**\n * Configure undo method\n * @param {'native' | 'manual' | 'auto'} method - Undo method to use\n */\nexport function setUndoMethod(method) {\n switch (method) {\n case 'native':\n canInsertText = true\n break\n case 'manual':\n canInsertText = false\n break\n case 'auto':\n canInsertText = null\n break\n }\n}", "/**\n * Core selection utilities extracted and adapted from GitHub's markdown-toolbar-element\n */\n\n/**\n * Check if string contains multiple lines\n */\nexport function isMultipleLines(string) {\n return string.trim().split('\\n').length > 1\n}\n\n/**\n * Find the start of the word at position i\n */\nexport function wordSelectionStart(text, i) {\n let index = i\n while (text[index] && text[index - 1] != null && !text[index - 1].match(/\\s/)) {\n index--\n }\n return index\n}\n\n/**\n * Find the end of the word at position i\n */\nexport function wordSelectionEnd(text, i, multiline) {\n let index = i\n const breakpoint = multiline ? /\\n/ : /\\s/\n while (text[index] && !text[index].match(breakpoint)) {\n index++\n }\n return index\n}\n\n/**\n * Expand selection to line boundaries\n */\nexport function expandSelectionToLine(textarea) {\n const lines = textarea.value.split('\\n')\n let counter = 0\n for (let index = 0; index < lines.length; index++) {\n const lineLength = lines[index].length + 1\n if (textarea.selectionStart >= counter && textarea.selectionStart < counter + lineLength) {\n textarea.selectionStart = counter\n }\n if (textarea.selectionEnd >= counter && textarea.selectionEnd < counter + lineLength) {\n // For the last line, don't go past the actual text length\n if (index === lines.length - 1) {\n textarea.selectionEnd = Math.min(counter + lines[index].length, textarea.value.length)\n } else {\n textarea.selectionEnd = counter + lineLength - 1\n }\n }\n counter += lineLength\n }\n}\n\n/**\n * Expand selected text with smart boundary detection\n */\nexport function expandSelectedText(textarea, prefixToUse, suffixToUse, multiline = false) {\n if (textarea.selectionStart === textarea.selectionEnd) {\n textarea.selectionStart = wordSelectionStart(textarea.value, textarea.selectionStart)\n textarea.selectionEnd = wordSelectionEnd(textarea.value, textarea.selectionEnd, multiline)\n } else {\n const expandedSelectionStart = textarea.selectionStart - prefixToUse.length\n const expandedSelectionEnd = textarea.selectionEnd + suffixToUse.length\n const beginsWithPrefix = textarea.value.slice(expandedSelectionStart, textarea.selectionStart) === prefixToUse\n const endsWithSuffix = textarea.value.slice(textarea.selectionEnd, expandedSelectionEnd) === suffixToUse\n if (beginsWithPrefix && endsWithSuffix) {\n textarea.selectionStart = expandedSelectionStart\n textarea.selectionEnd = expandedSelectionEnd\n }\n }\n return textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n}\n\n/**\n * Calculate newlines needed to surround selected text\n */\nexport function newlinesToSurroundSelectedText(textarea) {\n const beforeSelection = textarea.value.slice(0, textarea.selectionStart)\n const afterSelection = textarea.value.slice(textarea.selectionEnd)\n\n const breaksBefore = beforeSelection.match(/\\n*$/)\n const breaksAfter = afterSelection.match(/^\\n*/)\n const newlinesBeforeSelection = breaksBefore ? breaksBefore[0].length : 0\n const newlinesAfterSelection = breaksAfter ? breaksAfter[0].length : 0\n\n let newlinesToAppend = ''\n let newlinesToPrepend = ''\n\n if (beforeSelection.match(/\\S/) && newlinesBeforeSelection < 2) {\n newlinesToAppend = '\\n'.repeat(2 - newlinesBeforeSelection)\n }\n\n if (afterSelection.match(/\\S/) && newlinesAfterSelection < 2) {\n newlinesToPrepend = '\\n'.repeat(2 - newlinesAfterSelection)\n }\n\n return { newlinesToAppend, newlinesToPrepend }\n}\n\n/**\n * Utility to preserve selection during operations\n */\nexport function preserveSelection(textarea, callback) {\n const start = textarea.selectionStart\n const end = textarea.selectionEnd\n const scrollTop = textarea.scrollTop\n \n callback()\n \n textarea.selectionStart = start\n textarea.selectionEnd = end\n textarea.scrollTop = scrollTop\n}\n\n/**\n * Apply a line-based operation with cursor preservation\n * This function handles expanding to line boundaries and preserving cursor position\n * @param {HTMLTextAreaElement} textarea - The textarea element\n * @param {Function} operation - The operation to perform (receives textarea and returns result)\n * @param {Object} options - Options for the operation\n * @param {string} options.prefix - The prefix being added/removed (for cursor adjustment)\n * @param {Function} options.adjustSelection - Custom selection adjustment function\n * @returns {Object} The result from the operation with adjusted cursor position\n */\nexport function applyLineOperation(textarea, operation, options = {}) {\n // Save original cursor position AND selection before any expansion\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n const noInitialSelection = originalStart === originalEnd\n \n // Store the line start position to calculate offset later\n const value = textarea.value\n let lineStart = originalStart\n \n // Find start of the line containing the selection start\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n \n // Expand selection to line boundaries for the operation\n if (noInitialSelection) {\n // Expand to current line when no selection\n let lineEnd = originalStart\n \n // Find end of current line\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n } else {\n // For selections, expand to full lines\n expandSelectionToLine(textarea)\n }\n \n // Apply the operation\n const result = operation(textarea)\n \n // Restore original selection/cursor with prefix adjustment\n if (options.adjustSelection) {\n // Use custom selection adjustment logic\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const isRemoving = selectedText.startsWith(options.prefix)\n const adjusted = options.adjustSelection(isRemoving, originalStart, originalEnd, lineStart)\n result.selectionStart = adjusted.start\n result.selectionEnd = adjusted.end\n } else if (options.prefix) {\n // Use default prefix-based adjustment\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const isRemoving = selectedText.startsWith(options.prefix)\n \n if (noInitialSelection) {\n // No selection - just restore cursor position\n if (isRemoving) {\n // When removing prefix, adjust cursor position\n result.selectionStart = Math.max(originalStart - options.prefix.length, lineStart)\n result.selectionEnd = result.selectionStart\n } else {\n // When adding prefix, adjust cursor position\n result.selectionStart = originalStart + options.prefix.length\n result.selectionEnd = result.selectionStart\n }\n } else {\n // Had a selection - restore it with adjustment\n if (isRemoving) {\n // When removing prefix, shift selection back\n result.selectionStart = Math.max(originalStart - options.prefix.length, lineStart)\n result.selectionEnd = Math.max(originalEnd - options.prefix.length, lineStart)\n } else {\n // When adding prefix, shift selection forward\n result.selectionStart = originalStart + options.prefix.length\n result.selectionEnd = originalEnd + options.prefix.length\n }\n }\n }\n \n return result\n}", "/**\n * Block-level text formatting operations\n * Handles inline formats like bold, italic, code, and links\n */\n\nimport { expandSelectedText, newlinesToSurroundSelectedText, isMultipleLines } from '../core/selection.js'\nimport { insertText } from '../core/insertion.js'\n\n/**\n * Apply block-level styling to selected text\n */\nexport function blockStyle(textarea, style) {\n let newlinesToAppend\n let newlinesToPrepend\n\n const { prefix, suffix, blockPrefix, blockSuffix, replaceNext, prefixSpace, scanFor, surroundWithNewlines, trimFirst } = style\n const originalSelectionStart = textarea.selectionStart\n const originalSelectionEnd = textarea.selectionEnd\n\n let selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let prefixToUse = isMultipleLines(selectedText) && blockPrefix && blockPrefix.length > 0 ? `${blockPrefix}\\n` : prefix\n let suffixToUse = isMultipleLines(selectedText) && blockSuffix && blockSuffix.length > 0 ? `\\n${blockSuffix}` : suffix\n\n if (prefixSpace) {\n const beforeSelection = textarea.value[textarea.selectionStart - 1]\n if (textarea.selectionStart !== 0 && beforeSelection != null && !beforeSelection.match(/\\s/)) {\n prefixToUse = ` ${prefixToUse}`\n }\n }\n \n selectedText = expandSelectedText(textarea, prefixToUse, suffixToUse, style.multiline)\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n const hasReplaceNext = replaceNext && replaceNext.length > 0 && suffixToUse.indexOf(replaceNext) > -1 && selectedText.length > 0\n \n if (surroundWithNewlines) {\n const ref = newlinesToSurroundSelectedText(textarea)\n newlinesToAppend = ref.newlinesToAppend\n newlinesToPrepend = ref.newlinesToPrepend\n prefixToUse = newlinesToAppend + prefix\n suffixToUse += newlinesToPrepend\n }\n\n // Check if we should remove formatting (toggle off)\n if (selectedText.startsWith(prefixToUse) && selectedText.endsWith(suffixToUse)) {\n const replacementText = selectedText.slice(prefixToUse.length, selectedText.length - suffixToUse.length)\n if (originalSelectionStart === originalSelectionEnd) {\n let position = originalSelectionStart - prefixToUse.length\n position = Math.max(position, selectionStart)\n position = Math.min(position, selectionStart + replacementText.length)\n selectionStart = selectionEnd = position\n } else {\n selectionEnd = selectionStart + replacementText.length\n }\n return { text: replacementText, selectionStart, selectionEnd }\n } else if (!hasReplaceNext) {\n // Add formatting\n let replacementText = prefixToUse + selectedText + suffixToUse\n selectionStart = originalSelectionStart + prefixToUse.length\n selectionEnd = originalSelectionEnd + prefixToUse.length\n const whitespaceEdges = selectedText.match(/^\\s*|\\s*$/g)\n if (trimFirst && whitespaceEdges) {\n const leadingWhitespace = whitespaceEdges[0] || ''\n const trailingWhitespace = whitespaceEdges[1] || ''\n replacementText = leadingWhitespace + prefixToUse + selectedText.trim() + suffixToUse + trailingWhitespace\n selectionStart += leadingWhitespace.length\n selectionEnd -= trailingWhitespace.length\n }\n return { text: replacementText, selectionStart, selectionEnd }\n } else if (scanFor && scanFor.length > 0 && selectedText.match(scanFor)) {\n // Handle link/image with URL detection\n suffixToUse = suffixToUse.replace(replaceNext, selectedText)\n const replacementText = prefixToUse + suffixToUse\n selectionStart = selectionEnd = selectionStart + prefixToUse.length\n return { text: replacementText, selectionStart, selectionEnd }\n } else {\n // Handle link/image with placeholder\n const replacementText = prefixToUse + selectedText + suffixToUse\n selectionStart = selectionStart + prefixToUse.length + selectedText.length + suffixToUse.indexOf(replaceNext)\n selectionEnd = selectionStart + replaceNext.length\n return { text: replacementText, selectionStart, selectionEnd }\n }\n}\n\n/**\n * Apply style to selected text in textarea\n */\nexport function styleSelectedText(textarea, style) {\n const text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n \n let result\n if (style.orderedList || style.unorderedList) {\n // Will be handled by list operations\n return\n } else if (style.multiline && isMultipleLines(text)) {\n result = multilineStyle(textarea, style)\n } else {\n result = blockStyle(textarea, style)\n }\n\n insertText(textarea, result)\n}\n\n/**\n * Apply multiline styling (quotes, task lists, etc)\n * Note: This does NOT expand selection to line - that should be done by the caller if needed\n */\nexport function multilineStyle(textarea, style) {\n const { prefix, suffix, surroundWithNewlines } = style\n let text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n const lines = text.split('\\n')\n \n // Check if we need to undo (all lines have the format)\n const undoStyle = lines.every(line => line.startsWith(prefix) && (!suffix || line.endsWith(suffix)))\n\n if (undoStyle) {\n // Remove the formatting\n text = lines.map(line => {\n let result = line.slice(prefix.length)\n if (suffix) {\n result = result.slice(0, result.length - suffix.length)\n }\n return result\n }).join('\\n')\n selectionEnd = selectionStart + text.length\n } else {\n // Apply the formatting\n text = lines.map(line => prefix + line + (suffix || '')).join('\\n')\n if (surroundWithNewlines) {\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea)\n selectionStart += newlinesToAppend.length\n selectionEnd = selectionStart + text.length\n text = newlinesToAppend + text + newlinesToPrepend\n }\n }\n\n return { text, selectionStart, selectionEnd }\n}", "/**\n * List operations for bullet and numbered lists\n */\n\nimport { expandSelectionToLine, newlinesToSurroundSelectedText, applyLineOperation } from '../core/selection.js'\nimport { insertText } from '../core/insertion.js'\n\n/**\n * Undo ordered list formatting\n */\nfunction undoOrderedListStyle(text) {\n const lines = text.split('\\n')\n const orderedListRegex = /^\\d+\\.\\s+/\n const shouldUndoOrderedList = lines.every(line => orderedListRegex.test(line))\n let result = lines\n if (shouldUndoOrderedList) {\n result = lines.map(line => line.replace(orderedListRegex, ''))\n }\n\n return {\n text: result.join('\\n'),\n processed: shouldUndoOrderedList\n }\n}\n\n/**\n * Undo unordered list formatting\n */\nfunction undoUnorderedListStyle(text) {\n const lines = text.split('\\n')\n const unorderedListPrefix = '- '\n const shouldUndoUnorderedList = lines.every(line => line.startsWith(unorderedListPrefix))\n let result = lines\n if (shouldUndoUnorderedList) {\n result = lines.map(line => line.slice(unorderedListPrefix.length))\n }\n\n return {\n text: result.join('\\n'),\n processed: shouldUndoUnorderedList\n }\n}\n\n/**\n * Make prefix for list item\n */\nfunction makePrefix(index, unorderedList) {\n if (unorderedList) {\n return '- '\n } else {\n return `${index + 1}. `\n }\n}\n\n/**\n * Clear existing list style\n */\nfunction clearExistingListStyle(style, selectedText) {\n let undoResult\n let undoResultOppositeList\n let pristineText\n \n if (style.orderedList) {\n undoResult = undoOrderedListStyle(selectedText)\n undoResultOppositeList = undoUnorderedListStyle(undoResult.text)\n pristineText = undoResultOppositeList.text\n } else {\n undoResult = undoUnorderedListStyle(selectedText)\n undoResultOppositeList = undoOrderedListStyle(undoResult.text)\n pristineText = undoResultOppositeList.text\n }\n \n return [undoResult, undoResultOppositeList, pristineText]\n}\n\n/**\n * Apply list styling to selected text\n */\nexport function listStyle(textarea, style) {\n const noInitialSelection = textarea.selectionStart === textarea.selectionEnd\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n\n // Select whole line\n expandSelectionToLine(textarea)\n\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n\n // Clear any existing list formatting\n const [undoResult, undoResultOppositeList, pristineText] = clearExistingListStyle(style, selectedText)\n\n const prefixedLines = pristineText.split('\\n').map((value, index) => {\n return `${makePrefix(index, style.unorderedList)}${value}`\n })\n\n const totalPrefixLength = prefixedLines.reduce((previousValue, _currentValue, currentIndex) => {\n return previousValue + makePrefix(currentIndex, style.unorderedList).length\n }, 0)\n\n const totalPrefixLengthOppositeList = prefixedLines.reduce((previousValue, _currentValue, currentIndex) => {\n return previousValue + makePrefix(currentIndex, !style.unorderedList).length\n }, 0)\n\n // If we're undoing the same list type, just return the pristine text\n if (undoResult.processed) {\n if (noInitialSelection) {\n selectionStart = Math.max(selectionStart - makePrefix(0, style.unorderedList).length, 0)\n selectionEnd = selectionStart\n } else {\n selectionStart = textarea.selectionStart\n selectionEnd = textarea.selectionEnd - totalPrefixLength\n }\n return { text: pristineText, selectionStart, selectionEnd }\n }\n\n // Apply new list formatting\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea)\n const text = newlinesToAppend + prefixedLines.join('\\n') + newlinesToPrepend\n\n if (noInitialSelection) {\n selectionStart = Math.max(selectionStart + makePrefix(0, style.unorderedList).length + newlinesToAppend.length, 0)\n selectionEnd = selectionStart\n } else {\n if (undoResultOppositeList.processed) {\n // Converting from one list type to another\n selectionStart = Math.max(textarea.selectionStart + newlinesToAppend.length, 0)\n selectionEnd = textarea.selectionEnd + newlinesToAppend.length + totalPrefixLength - totalPrefixLengthOppositeList\n } else {\n // Adding list formatting to plain text\n selectionStart = Math.max(textarea.selectionStart + newlinesToAppend.length, 0)\n selectionEnd = textarea.selectionEnd + newlinesToAppend.length + totalPrefixLength\n }\n }\n\n return { text, selectionStart, selectionEnd }\n}\n\n/**\n * Apply list style to textarea\n */\nexport function applyListStyle(textarea, style) {\n // Use applyLineOperation for consistent selection preservation\n const result = applyLineOperation(\n textarea,\n (ta) => listStyle(ta, style),\n {\n // Custom selection adjustment for lists\n adjustSelection: (isRemoving, selStart, selEnd, lineStart) => {\n // Get the current line to check if we're removing\n const currentLine = textarea.value.slice(lineStart, textarea.selectionEnd)\n const orderedListRegex = /^\\d+\\.\\s+/\n const unorderedListRegex = /^- /\n \n // Check if we're removing a list\n const hasOrderedList = orderedListRegex.test(currentLine)\n const hasUnorderedList = unorderedListRegex.test(currentLine)\n const isRemovingCurrent = (style.orderedList && hasOrderedList) || (style.unorderedList && hasUnorderedList)\n \n if (selStart === selEnd) {\n // No selection - cursor position\n if (isRemovingCurrent) {\n // Removing list - adjust cursor back\n const prefixMatch = currentLine.match(style.orderedList ? orderedListRegex : unorderedListRegex)\n const prefixLength = prefixMatch ? prefixMatch[0].length : 0\n return {\n start: Math.max(selStart - prefixLength, lineStart),\n end: Math.max(selStart - prefixLength, lineStart)\n }\n } else if (hasOrderedList || hasUnorderedList) {\n // Converting from one list type to another\n const oldPrefixMatch = currentLine.match(hasOrderedList ? orderedListRegex : unorderedListRegex)\n const oldPrefixLength = oldPrefixMatch ? oldPrefixMatch[0].length : 0\n const newPrefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n const adjustment = newPrefixLength - oldPrefixLength\n return {\n start: selStart + adjustment,\n end: selStart + adjustment\n }\n } else {\n // Adding new list\n const prefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n return {\n start: selStart + prefixLength,\n end: selStart + prefixLength\n }\n }\n } else {\n // Has selection - preserve it\n if (isRemovingCurrent) {\n // Removing current list type\n const prefixMatch = currentLine.match(style.orderedList ? orderedListRegex : unorderedListRegex)\n const prefixLength = prefixMatch ? prefixMatch[0].length : 0\n return {\n start: Math.max(selStart - prefixLength, lineStart),\n end: Math.max(selEnd - prefixLength, lineStart)\n }\n } else if (hasOrderedList || hasUnorderedList) {\n // Converting from one list type to another\n const oldPrefixMatch = currentLine.match(hasOrderedList ? orderedListRegex : unorderedListRegex)\n const oldPrefixLength = oldPrefixMatch ? oldPrefixMatch[0].length : 0\n const newPrefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n const adjustment = newPrefixLength - oldPrefixLength\n return {\n start: selStart + adjustment,\n end: selEnd + adjustment\n }\n } else {\n // Adding new list\n const prefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n return {\n start: selStart + prefixLength,\n end: selEnd + prefixLength\n }\n }\n }\n }\n }\n )\n \n insertText(textarea, result)\n}", "/**\n * Format detection utilities\n */\n\nimport { FORMATS } from './formats.js'\n\n/**\n * Check if text has a specific format applied\n */\nfunction hasFormatApplied(text, format) {\n if (!format.prefix) return false\n \n if (format.suffix) {\n return text.startsWith(format.prefix) && text.endsWith(format.suffix)\n } else {\n return text.startsWith(format.prefix)\n }\n}\n\n/**\n * Get active formats at cursor position\n */\nexport function getActiveFormats(textarea) {\n if (!textarea) return []\n \n const formats = []\n const { selectionStart, selectionEnd, value } = textarea\n \n // Get current line for line-based formats\n const lines = value.split('\\n')\n let lineStart = 0\n let currentLine = ''\n \n for (const line of lines) {\n if (selectionStart >= lineStart && selectionStart <= lineStart + line.length) {\n currentLine = line\n break\n }\n lineStart += line.length + 1\n }\n \n // Check line-based formats\n if (currentLine.startsWith('- ')) {\n if (currentLine.startsWith('- [ ] ') || currentLine.startsWith('- [x] ')) {\n formats.push('task-list')\n } else {\n formats.push('bullet-list')\n }\n }\n \n if (/^\\d+\\.\\s/.test(currentLine)) {\n formats.push('numbered-list')\n }\n \n if (currentLine.startsWith('> ')) {\n formats.push('quote')\n }\n \n if (currentLine.startsWith('# ')) formats.push('header')\n if (currentLine.startsWith('## ')) formats.push('header-2')\n if (currentLine.startsWith('### ')) formats.push('header-3')\n \n // Check inline formats by looking around cursor\n const lookBehind = Math.max(0, selectionStart - 10)\n const lookAhead = Math.min(value.length, selectionEnd + 10)\n const surrounding = value.slice(lookBehind, lookAhead)\n \n // Check for bold\n if (surrounding.includes('**')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenBold = beforeCursor.lastIndexOf('**')\n const nextCloseBold = afterCursor.indexOf('**')\n if (lastOpenBold !== -1 && nextCloseBold !== -1) {\n formats.push('bold')\n }\n }\n \n // Check for italic\n if (surrounding.includes('_')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenItalic = beforeCursor.lastIndexOf('_')\n const nextCloseItalic = afterCursor.indexOf('_')\n if (lastOpenItalic !== -1 && nextCloseItalic !== -1) {\n formats.push('italic')\n }\n }\n \n // Check for code\n if (surrounding.includes('`')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n if (beforeCursor.includes('`') && afterCursor.includes('`')) {\n formats.push('code')\n }\n }\n \n // Check for link\n if (surrounding.includes('[') && surrounding.includes(']')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenBracket = beforeCursor.lastIndexOf('[')\n const nextCloseBracket = afterCursor.indexOf(']')\n if (lastOpenBracket !== -1 && nextCloseBracket !== -1) {\n const afterBracket = value.slice(selectionEnd + nextCloseBracket + 1, selectionEnd + nextCloseBracket + 10)\n if (afterBracket.startsWith('(')) {\n formats.push('link')\n }\n }\n }\n \n return formats\n}\n\n/**\n * Check if specific format is active at cursor\n */\nexport function hasFormat(textarea, format) {\n const activeFormats = getActiveFormats(textarea)\n return activeFormats.includes(format)\n}\n\n/**\n * Expand selection based on options\n */\nexport function expandSelection(textarea, options = {}) {\n if (!textarea) return\n \n const { toWord, toLine, toFormat } = options\n const { selectionStart, selectionEnd, value } = textarea\n \n if (toLine) {\n // Find line boundaries\n const lines = value.split('\\n')\n let lineStart = 0\n let lineEnd = 0\n let currentPos = 0\n \n for (const line of lines) {\n if (selectionStart >= currentPos && selectionStart <= currentPos + line.length) {\n lineStart = currentPos\n lineEnd = currentPos + line.length\n break\n }\n currentPos += line.length + 1\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n } else if (toWord && selectionStart === selectionEnd) {\n // Find word boundaries\n let start = selectionStart\n let end = selectionEnd\n \n // Move start back to word boundary\n while (start > 0 && !/\\s/.test(value[start - 1])) {\n start--\n }\n \n // Move end forward to word boundary\n while (end < value.length && !/\\s/.test(value[end])) {\n end++\n }\n \n textarea.selectionStart = start\n textarea.selectionEnd = end\n }\n}", "/**\n * markdown-actions - Lightweight markdown toolbar functionality\n * Based on GitHub's markdown-toolbar-element\n */\n\nimport { FORMATS, mergeWithDefaults } from './core/formats.js'\nimport { insertText, setUndoMethod } from './core/insertion.js'\nimport { preserveSelection, isMultipleLines, expandSelectionToLine, applyLineOperation } from './core/selection.js'\nimport { blockStyle, multilineStyle } from './operations/block.js'\nimport { applyListStyle } from './operations/list.js'\nimport { getActiveFormats as getActive, hasFormat as has, expandSelection as expand } from './core/detection.js'\nimport { debugLog, debugSelection, debugResult, setDebugMode, getDebugMode } from './debug.js'\n\n/**\n * Toggle bold formatting\n */\nexport function toggleBold(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n debugLog('toggleBold', 'Starting');\n debugSelection(textarea, 'Before');\n \n const style = mergeWithDefaults(FORMATS.bold)\n const result = blockStyle(textarea, style)\n \n debugResult(result);\n \n insertText(textarea, result)\n \n debugSelection(textarea, 'After');\n}\n\n/**\n * Toggle italic formatting\n */\nexport function toggleItalic(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.italic)\n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Toggle code formatting\n */\nexport function toggleCode(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n // blockStyle already handles both inline and block code correctly\n const style = mergeWithDefaults(FORMATS.code)\n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Insert or toggle link formatting\n */\nexport function insertLink(textarea, options = {}) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let style = mergeWithDefaults(FORMATS.link)\n \n // Check if selected text is a URL\n const isURL = selectedText && selectedText.match(/^https?:\\/\\//)\n \n if (isURL && !options.url) {\n // If selected text is a URL, use it as both link text and URL\n style.suffix = `](${selectedText})`\n style.replaceNext = ''\n // Don't change the selected text, it becomes the link text\n } else if (options.url) {\n // Override with custom URL if provided\n style.suffix = `](${options.url})`\n style.replaceNext = ''\n }\n \n // Override with custom text if provided\n if (options.text && !selectedText) {\n // Insert the text and select it\n const pos = textarea.selectionStart\n textarea.value = textarea.value.slice(0, pos) + options.text + textarea.value.slice(pos)\n textarea.selectionStart = pos\n textarea.selectionEnd = pos + options.text.length\n }\n \n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Toggle bullet list formatting\n */\nexport function toggleBulletList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.bulletList)\n applyListStyle(textarea, style)\n}\n\n/**\n * Toggle numbered list formatting\n */\nexport function toggleNumberedList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.numberedList)\n applyListStyle(textarea, style)\n}\n\n/**\n * Toggle quote formatting\n * Matches GitHub's implementation for quotes\n */\nexport function toggleQuote(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n debugLog('toggleQuote', 'Starting');\n debugSelection(textarea, 'Initial');\n \n const style = mergeWithDefaults(FORMATS.quote)\n \n // Use the reusable line operation helper\n const result = applyLineOperation(\n textarea,\n (ta) => multilineStyle(ta, style),\n { prefix: style.prefix }\n )\n \n debugResult(result);\n insertText(textarea, result)\n debugSelection(textarea, 'Final');\n}\n\n/**\n * Toggle task list formatting\n * Matches GitHub's implementation for task lists\n */\nexport function toggleTaskList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const style = mergeWithDefaults(FORMATS.taskList)\n \n // Use the reusable line operation helper\n const result = applyLineOperation(\n textarea,\n (ta) => multilineStyle(ta, style),\n { prefix: style.prefix }\n )\n \n insertText(textarea, result)\n}\n\n/**\n * Insert or toggle header with specific level\n */\nexport function insertHeader(textarea, level = 1, toggle = false) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n if (level < 1 || level > 6) level = 1\n \n debugLog('insertHeader', `============ START ============`);\n debugLog('insertHeader', `Level: ${level}, Toggle: ${toggle}`);\n debugLog('insertHeader', `Initial cursor: ${textarea.selectionStart}-${textarea.selectionEnd}`);\n \n const headerKey = `header${level === 1 ? '1' : level}`\n const style = mergeWithDefaults(FORMATS[headerKey] || FORMATS.header1)\n debugLog('insertHeader', `Style prefix: \"${style.prefix}\"`);\n \n // Save original positions and get line info BEFORE applyLineOperation\n const value = textarea.value\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n \n // Find the current line boundaries to check existing header\n let lineStart = originalStart\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n let lineEnd = originalEnd\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n // Get current line and check for existing header\n const currentLineContent = value.slice(lineStart, lineEnd)\n debugLog('insertHeader', `Current line (before): \"${currentLineContent}\"`);\n \n const existingHeaderMatch = currentLineContent.match(/^(#{1,6})\\s*/)\n const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0\n const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0\n \n debugLog('insertHeader', `Existing header check:`);\n debugLog('insertHeader', ` - Match: ${existingHeaderMatch ? `\"${existingHeaderMatch[0]}\"` : 'none'}`);\n debugLog('insertHeader', ` - Existing level: ${existingLevel}`);\n debugLog('insertHeader', ` - Existing prefix length: ${existingPrefixLength}`);\n debugLog('insertHeader', ` - Target level: ${level}`);\n \n // Determine if we're toggling off\n const shouldToggleOff = toggle && existingLevel === level\n debugLog('insertHeader', `Should toggle OFF: ${shouldToggleOff} (toggle=${toggle}, existingLevel=${existingLevel}, level=${level})`);\n \n // Use applyLineOperation for consistent behavior\n const result = applyLineOperation(\n textarea,\n (ta) => {\n const currentLine = ta.value.slice(ta.selectionStart, ta.selectionEnd)\n debugLog('insertHeader', `Line in operation: \"${currentLine}\"`);\n \n // Remove any existing header formatting\n const cleanedLine = currentLine.replace(/^#{1,6}\\s*/, '')\n debugLog('insertHeader', `Cleaned line: \"${cleanedLine}\"`);\n \n let newLine\n \n if (shouldToggleOff) {\n // Toggle off - just use the cleaned line\n debugLog('insertHeader', 'ACTION: Toggling OFF - removing header');\n newLine = cleanedLine\n } else if (existingLevel > 0) {\n // Replace existing header with new one\n debugLog('insertHeader', `ACTION: Replacing H${existingLevel} with H${level}`);\n newLine = style.prefix + cleanedLine\n } else {\n // Add new header\n debugLog('insertHeader', 'ACTION: Adding new header');\n newLine = style.prefix + cleanedLine\n }\n \n debugLog('insertHeader', `New line: \"${newLine}\"`);\n \n return {\n text: newLine,\n selectionStart: ta.selectionStart,\n selectionEnd: ta.selectionEnd\n }\n },\n {\n prefix: style.prefix,\n // Custom selection adjustment for headers\n adjustSelection: (isRemoving, selStart, selEnd, lineStartPos) => {\n debugLog('insertHeader', `Adjusting selection:`);\n debugLog('insertHeader', ` - isRemoving param: ${isRemoving}`);\n debugLog('insertHeader', ` - shouldToggleOff: ${shouldToggleOff}`);\n debugLog('insertHeader', ` - selStart: ${selStart}, selEnd: ${selEnd}`);\n debugLog('insertHeader', ` - lineStartPos: ${lineStartPos}`);\n \n if (shouldToggleOff) {\n // Removing the header entirely\n const adjustment = Math.max(selStart - existingPrefixLength, lineStartPos)\n debugLog('insertHeader', ` - Removing header, adjusting by -${existingPrefixLength}`);\n return {\n start: adjustment,\n end: selStart === selEnd ? adjustment : Math.max(selEnd - existingPrefixLength, lineStartPos)\n }\n } else if (existingPrefixLength > 0) {\n // Replacing existing header with new one\n const prefixDiff = style.prefix.length - existingPrefixLength\n debugLog('insertHeader', ` - Replacing header, adjusting by ${prefixDiff}`);\n return {\n start: selStart + prefixDiff,\n end: selEnd + prefixDiff\n }\n } else {\n // Adding new header\n debugLog('insertHeader', ` - Adding header, adjusting by +${style.prefix.length}`);\n return {\n start: selStart + style.prefix.length,\n end: selEnd + style.prefix.length\n }\n }\n }\n }\n )\n \n debugLog('insertHeader', `Final result: text=\"${result.text}\", cursor=${result.selectionStart}-${result.selectionEnd}`);\n debugLog('insertHeader', `============ END ============`);\n \n insertText(textarea, result)\n}\n\n/**\n * Toggle H1 header\n */\nexport function toggleH1(textarea) {\n insertHeader(textarea, 1, true)\n}\n\n/**\n * Toggle H2 header\n */\nexport function toggleH2(textarea) {\n insertHeader(textarea, 2, true)\n}\n\n/**\n * Toggle H3 header\n */\nexport function toggleH3(textarea) {\n insertHeader(textarea, 3, true)\n}\n\n/**\n * Get active formats at cursor position\n */\nexport function getActiveFormats(textarea) {\n return getActive(textarea)\n}\n\n/**\n * Check if format is active at cursor\n */\nexport function hasFormat(textarea, format) {\n return has(textarea, format)\n}\n\n/**\n * Expand selection based on options\n */\nexport function expandSelection(textarea, options = {}) {\n expand(textarea, options)\n}\n\n/**\n * Apply custom format\n */\nexport function applyCustomFormat(textarea, format) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const style = mergeWithDefaults(format)\n let result\n \n if (style.multiline) {\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n if (isMultipleLines(selectedText)) {\n result = multilineStyle(textarea, style)\n } else {\n result = blockStyle(textarea, style)\n }\n } else {\n result = blockStyle(textarea, style)\n }\n \n insertText(textarea, result)\n}\n\n/**\n * Preserve selection during callback\n */\nexport { preserveSelection }\n\n/**\n * Configure undo method\n */\nexport { setUndoMethod }\n\n/**\n * Debug mode control\n */\nexport { setDebugMode, getDebugMode }\n\n/**\n * Default export with all functions\n */\nexport default {\n toggleBold,\n toggleItalic,\n toggleCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n toggleTaskList,\n insertHeader,\n toggleH1,\n toggleH2,\n toggleH3,\n getActiveFormats,\n hasFormat,\n expandSelection,\n applyCustomFormat,\n preserveSelection,\n setUndoMethod,\n setDebugMode,\n getDebugMode\n}", "/**\n * Toolbar component for OverType editor\n * Provides markdown formatting buttons with support for custom buttons\n */\n\nimport * as markdownActions from 'markdown-actions';\n\nexport class Toolbar {\n constructor(editor, options = {}) {\n this.editor = editor;\n this.container = null;\n this.buttons = {};\n\n // Get toolbar buttons array\n this.toolbarButtons = options.toolbarButtons || [];\n }\n\n /**\n * Create and render toolbar\n */\n create() {\n this.container = document.createElement('div');\n this.container.className = 'overtype-toolbar';\n this.container.setAttribute('role', 'toolbar');\n this.container.setAttribute('aria-label', 'Formatting toolbar');\n\n // Create buttons from toolbarButtons array\n this.toolbarButtons.forEach(buttonConfig => {\n if (buttonConfig.name === 'separator') {\n const separator = this.createSeparator();\n this.container.appendChild(separator);\n } else {\n const button = this.createButton(buttonConfig);\n this.buttons[buttonConfig.name] = button;\n this.container.appendChild(button);\n }\n });\n\n // Insert toolbar before the wrapper (as sibling, not child)\n this.editor.container.insertBefore(this.container, this.editor.wrapper);\n }\n\n /**\n * Create a toolbar separator\n */\n createSeparator() {\n const separator = document.createElement('div');\n separator.className = 'overtype-toolbar-separator';\n separator.setAttribute('role', 'separator');\n return separator;\n }\n\n /**\n * Create a toolbar button\n */\n createButton(buttonConfig) {\n const button = document.createElement('button');\n button.className = 'overtype-toolbar-button';\n button.type = 'button';\n button.setAttribute('data-button', buttonConfig.name);\n button.title = buttonConfig.title || '';\n button.setAttribute('aria-label', buttonConfig.title || buttonConfig.name);\n button.innerHTML = this.sanitizeSVG(buttonConfig.icon || '');\n\n // Special handling for viewMode dropdown\n if (buttonConfig.name === 'viewMode') {\n button.classList.add('has-dropdown');\n button.dataset.dropdown = 'true';\n button.addEventListener('click', (e) => {\n e.preventDefault();\n this.toggleViewModeDropdown(button);\n });\n return button;\n }\n\n // Standard button click handler - delegate to performAction\n button._clickHandler = (e) => {\n e.preventDefault();\n const actionId = buttonConfig.actionId || buttonConfig.name;\n this.editor.performAction(actionId, e);\n };\n\n button.addEventListener('click', button._clickHandler);\n return button;\n }\n\n /**\n * Handle button action programmatically\n * Accepts either an actionId string or a buttonConfig object (backwards compatible)\n * @param {string|Object} actionIdOrConfig - Action identifier string or button config object\n * @returns {Promise<boolean>} Whether the action was executed\n */\n async handleAction(actionIdOrConfig) {\n // Old style: buttonConfig object with .action function - execute directly\n if (actionIdOrConfig && typeof actionIdOrConfig === 'object' && typeof actionIdOrConfig.action === 'function') {\n this.editor.textarea.focus();\n try {\n await actionIdOrConfig.action({\n editor: this.editor,\n getValue: () => this.editor.getValue(),\n setValue: (value) => this.editor.setValue(value),\n event: null\n });\n return true;\n } catch (error) {\n console.error(`Action \"${actionIdOrConfig.name}\" error:`, error);\n this.editor.wrapper.dispatchEvent(new CustomEvent('button-error', {\n detail: { buttonName: actionIdOrConfig.name, error }\n }));\n return false;\n }\n }\n\n // New style: string actionId - delegate to performAction\n if (typeof actionIdOrConfig === 'string') {\n return this.editor.performAction(actionIdOrConfig, null);\n }\n\n return false;\n }\n\n /**\n * Sanitize SVG to prevent XSS\n */\n sanitizeSVG(svg) {\n if (typeof svg !== 'string') return '';\n\n // Remove script tags and on* event handlers\n const cleaned = svg\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '')\n .replace(/\\son\\w+\\s*=\\s*[\"'][^\"']*[\"']/gi, '')\n .replace(/\\son\\w+\\s*=\\s*[^\\s>]*/gi, '');\n\n return cleaned;\n }\n\n /**\n * Toggle view mode dropdown (internal implementation)\n * Not exposed to users - viewMode button behavior is fixed\n */\n toggleViewModeDropdown(button) {\n // Close any existing dropdown\n const existingDropdown = document.querySelector('.overtype-dropdown-menu');\n if (existingDropdown) {\n existingDropdown.remove();\n button.classList.remove('dropdown-active');\n return;\n }\n\n button.classList.add('dropdown-active');\n\n const dropdown = this.createViewModeDropdown(button);\n\n // Position dropdown relative to button\n const rect = button.getBoundingClientRect();\n dropdown.style.position = 'absolute';\n dropdown.style.top = `${rect.bottom + 5}px`;\n dropdown.style.left = `${rect.left}px`;\n\n document.body.appendChild(dropdown);\n\n // Click outside to close\n this.handleDocumentClick = (e) => {\n if (!dropdown.contains(e.target) && !button.contains(e.target)) {\n dropdown.remove();\n button.classList.remove('dropdown-active');\n document.removeEventListener('click', this.handleDocumentClick);\n }\n };\n\n setTimeout(() => {\n document.addEventListener('click', this.handleDocumentClick);\n }, 0);\n }\n\n /**\n * Create view mode dropdown menu (internal implementation)\n */\n createViewModeDropdown(button) {\n const dropdown = document.createElement('div');\n dropdown.className = 'overtype-dropdown-menu';\n\n const items = [\n { id: 'normal', label: 'Normal Edit', icon: '\u2713' },\n { id: 'plain', label: 'Plain Textarea', icon: '\u2713' },\n { id: 'preview', label: 'Preview Mode', icon: '\u2713' }\n ];\n\n const currentMode = this.editor.container.dataset.mode || 'normal';\n\n items.forEach(item => {\n const menuItem = document.createElement('button');\n menuItem.className = 'overtype-dropdown-item';\n menuItem.type = 'button';\n menuItem.textContent = item.label;\n\n if (item.id === currentMode) {\n menuItem.classList.add('active');\n menuItem.setAttribute('aria-current', 'true');\n const checkmark = document.createElement('span');\n checkmark.className = 'overtype-dropdown-icon';\n checkmark.textContent = item.icon;\n menuItem.prepend(checkmark);\n }\n\n menuItem.addEventListener('click', (e) => {\n e.preventDefault();\n\n // Handle view mode changes\n switch(item.id) {\n case 'plain':\n this.editor.showPlainTextarea();\n break;\n case 'preview':\n this.editor.showPreviewMode();\n break;\n case 'normal':\n default:\n this.editor.showNormalEditMode();\n break;\n }\n\n dropdown.remove();\n button.classList.remove('dropdown-active');\n document.removeEventListener('click', this.handleDocumentClick);\n });\n\n dropdown.appendChild(menuItem);\n });\n\n return dropdown;\n }\n\n /**\n * Update active states of toolbar buttons\n */\n updateButtonStates() {\n try {\n const activeFormats = markdownActions.getActiveFormats?.(\n this.editor.textarea,\n this.editor.textarea.selectionStart\n ) || [];\n\n Object.entries(this.buttons).forEach(([name, button]) => {\n if (name === 'viewMode') return; // Skip dropdown button\n\n let isActive = false;\n\n switch(name) {\n case 'bold':\n isActive = activeFormats.includes('bold');\n break;\n case 'italic':\n isActive = activeFormats.includes('italic');\n break;\n case 'code':\n isActive = false; // Disabled: unreliable in code blocks\n break;\n case 'bulletList':\n isActive = activeFormats.includes('bullet-list');\n break;\n case 'orderedList':\n isActive = activeFormats.includes('numbered-list');\n break;\n case 'taskList':\n isActive = activeFormats.includes('task-list');\n break;\n case 'quote':\n isActive = activeFormats.includes('quote');\n break;\n case 'h1':\n isActive = activeFormats.includes('header');\n break;\n case 'h2':\n isActive = activeFormats.includes('header-2');\n break;\n case 'h3':\n isActive = activeFormats.includes('header-3');\n break;\n }\n\n button.classList.toggle('active', isActive);\n button.setAttribute('aria-pressed', isActive.toString());\n });\n } catch (error) {\n // Silently fail if markdown-actions not available\n }\n }\n\n show() {\n if (this.container) {\n this.container.classList.remove('overtype-toolbar-hidden');\n }\n }\n\n hide() {\n if (this.container) {\n this.container.classList.add('overtype-toolbar-hidden');\n }\n }\n\n /**\n * Destroy toolbar and cleanup\n */\n destroy() {\n if (this.container) {\n // Clean up event listeners\n if (this.handleDocumentClick) {\n document.removeEventListener('click', this.handleDocumentClick);\n }\n\n // Clean up button listeners\n Object.values(this.buttons).forEach(button => {\n if (button._clickHandler) {\n button.removeEventListener('click', button._clickHandler);\n delete button._clickHandler;\n }\n });\n\n // Remove container\n this.container.remove();\n this.container = null;\n this.buttons = {};\n }\n }\n}\n", "/**\n * Custom positioning reference element.\n * @see https://floating-ui.com/docs/virtual-elements\n */\n\nconst sides = ['top', 'right', 'bottom', 'left'];\nconst alignments = ['start', 'end'];\nconst placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + \"-\" + alignments[0], side + \"-\" + alignments[1]), []);\nconst min = Math.min;\nconst max = Math.max;\nconst round = Math.round;\nconst floor = Math.floor;\nconst createCoords = v => ({\n x: v,\n y: v\n});\nconst oppositeSideMap = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nconst oppositeAlignmentMap = {\n start: 'end',\n end: 'start'\n};\nfunction clamp(start, value, end) {\n return max(start, min(value, end));\n}\nfunction evaluate(value, param) {\n return typeof value === 'function' ? value(param) : value;\n}\nfunction getSide(placement) {\n return placement.split('-')[0];\n}\nfunction getAlignment(placement) {\n return placement.split('-')[1];\n}\nfunction getOppositeAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}\nfunction getAxisLength(axis) {\n return axis === 'y' ? 'height' : 'width';\n}\nconst yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);\nfunction getSideAxis(placement) {\n return yAxisSides.has(getSide(placement)) ? 'y' : 'x';\n}\nfunction getAlignmentAxis(placement) {\n return getOppositeAxis(getSideAxis(placement));\n}\nfunction getAlignmentSides(placement, rects, rtl) {\n if (rtl === void 0) {\n rtl = false;\n }\n const alignment = getAlignment(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const length = getAxisLength(alignmentAxis);\n let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';\n if (rects.reference[length] > rects.floating[length]) {\n mainAlignmentSide = getOppositePlacement(mainAlignmentSide);\n }\n return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];\n}\nfunction getExpandedPlacements(placement) {\n const oppositePlacement = getOppositePlacement(placement);\n return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];\n}\nfunction getOppositeAlignmentPlacement(placement) {\n return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);\n}\nconst lrPlacement = ['left', 'right'];\nconst rlPlacement = ['right', 'left'];\nconst tbPlacement = ['top', 'bottom'];\nconst btPlacement = ['bottom', 'top'];\nfunction getSideList(side, isStart, rtl) {\n switch (side) {\n case 'top':\n case 'bottom':\n if (rtl) return isStart ? rlPlacement : lrPlacement;\n return isStart ? lrPlacement : rlPlacement;\n case 'left':\n case 'right':\n return isStart ? tbPlacement : btPlacement;\n default:\n return [];\n }\n}\nfunction getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {\n const alignment = getAlignment(placement);\n let list = getSideList(getSide(placement), direction === 'start', rtl);\n if (alignment) {\n list = list.map(side => side + \"-\" + alignment);\n if (flipAlignment) {\n list = list.concat(list.map(getOppositeAlignmentPlacement));\n }\n }\n return list;\n}\nfunction getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);\n}\nfunction expandPaddingObject(padding) {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n ...padding\n };\n}\nfunction getPaddingObject(padding) {\n return typeof padding !== 'number' ? expandPaddingObject(padding) : {\n top: padding,\n right: padding,\n bottom: padding,\n left: padding\n };\n}\nfunction rectToClientRect(rect) {\n const {\n x,\n y,\n width,\n height\n } = rect;\n return {\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n x,\n y\n };\n}\n\nexport { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };\n", "import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';\nexport { rectToClientRect } from '@floating-ui/utils';\n\nfunction computeCoordsFromPlacement(_ref, placement, rtl) {\n let {\n reference,\n floating\n } = _ref;\n const sideAxis = getSideAxis(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const alignLength = getAxisLength(alignmentAxis);\n const side = getSide(placement);\n const isVertical = sideAxis === 'y';\n const commonX = reference.x + reference.width / 2 - floating.width / 2;\n const commonY = reference.y + reference.height / 2 - floating.height / 2;\n const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;\n let coords;\n switch (side) {\n case 'top':\n coords = {\n x: commonX,\n y: reference.y - floating.height\n };\n break;\n case 'bottom':\n coords = {\n x: commonX,\n y: reference.y + reference.height\n };\n break;\n case 'right':\n coords = {\n x: reference.x + reference.width,\n y: commonY\n };\n break;\n case 'left':\n coords = {\n x: reference.x - floating.width,\n y: commonY\n };\n break;\n default:\n coords = {\n x: reference.x,\n y: reference.y\n };\n }\n switch (getAlignment(placement)) {\n case 'start':\n coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);\n break;\n case 'end':\n coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);\n break;\n }\n return coords;\n}\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nasync function detectOverflow(state, options) {\n var _await$platform$isEle;\n if (options === void 0) {\n options = {};\n }\n const {\n x,\n y,\n platform,\n rects,\n elements,\n strategy\n } = state;\n const {\n boundary = 'clippingAncestors',\n rootBoundary = 'viewport',\n elementContext = 'floating',\n altBoundary = false,\n padding = 0\n } = evaluate(options, state);\n const paddingObject = getPaddingObject(padding);\n const altContext = elementContext === 'floating' ? 'reference' : 'floating';\n const element = elements[altBoundary ? altContext : elementContext];\n const clippingClientRect = rectToClientRect(await platform.getClippingRect({\n element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),\n boundary,\n rootBoundary,\n strategy\n }));\n const rect = elementContext === 'floating' ? {\n x,\n y,\n width: rects.floating.width,\n height: rects.floating.height\n } : rects.reference;\n const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));\n const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {\n x: 1,\n y: 1\n } : {\n x: 1,\n y: 1\n };\n const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n elements,\n rect,\n offsetParent,\n strategy\n }) : rect);\n return {\n top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,\n bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,\n left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,\n right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x\n };\n}\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n *\n * This export does not have any `platform` interface logic. You will need to\n * write one for the platform you are using Floating UI with.\n */\nconst computePosition = async (reference, floating, config) => {\n const {\n placement = 'bottom',\n strategy = 'absolute',\n middleware = [],\n platform\n } = config;\n const validMiddleware = middleware.filter(Boolean);\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));\n let rects = await platform.getElementRects({\n reference,\n floating,\n strategy\n });\n let {\n x,\n y\n } = computeCoordsFromPlacement(rects, placement, rtl);\n let statefulPlacement = placement;\n let middlewareData = {};\n let resetCount = 0;\n for (let i = 0; i < validMiddleware.length; i++) {\n var _platform$detectOverf;\n const {\n name,\n fn\n } = validMiddleware[i];\n const {\n x: nextX,\n y: nextY,\n data,\n reset\n } = await fn({\n x,\n y,\n initialPlacement: placement,\n placement: statefulPlacement,\n strategy,\n middlewareData,\n rects,\n platform: {\n ...platform,\n detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow\n },\n elements: {\n reference,\n floating\n }\n });\n x = nextX != null ? nextX : x;\n y = nextY != null ? nextY : y;\n middlewareData = {\n ...middlewareData,\n [name]: {\n ...middlewareData[name],\n ...data\n }\n };\n if (reset && resetCount <= 50) {\n resetCount++;\n if (typeof reset === 'object') {\n if (reset.placement) {\n statefulPlacement = reset.placement;\n }\n if (reset.rects) {\n rects = reset.rects === true ? await platform.getElementRects({\n reference,\n floating,\n strategy\n }) : reset.rects;\n }\n ({\n x,\n y\n } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));\n }\n i = -1;\n }\n }\n return {\n x,\n y,\n placement: statefulPlacement,\n strategy,\n middlewareData\n };\n};\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = options => ({\n name: 'arrow',\n options,\n async fn(state) {\n const {\n x,\n y,\n placement,\n rects,\n platform,\n elements,\n middlewareData\n } = state;\n // Since `element` is required, we don't Partial<> the type.\n const {\n element,\n padding = 0\n } = evaluate(options, state) || {};\n if (element == null) {\n return {};\n }\n const paddingObject = getPaddingObject(padding);\n const coords = {\n x,\n y\n };\n const axis = getAlignmentAxis(placement);\n const length = getAxisLength(axis);\n const arrowDimensions = await platform.getDimensions(element);\n const isYAxis = axis === 'y';\n const minProp = isYAxis ? 'top' : 'left';\n const maxProp = isYAxis ? 'bottom' : 'right';\n const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';\n const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];\n const startDiff = coords[axis] - rects.reference[axis];\n const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));\n let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;\n\n // DOM platform can return `window` as the `offsetParent`.\n if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {\n clientSize = elements.floating[clientProp] || rects.floating[length];\n }\n const centerToReference = endDiff / 2 - startDiff / 2;\n\n // If the padding is large enough that it causes the arrow to no longer be\n // centered, modify the padding so that it is centered.\n const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;\n const minPadding = min(paddingObject[minProp], largestPossiblePadding);\n const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);\n\n // Make sure the arrow doesn't overflow the floating element if the center\n // point is outside the floating element's bounds.\n const min$1 = minPadding;\n const max = clientSize - arrowDimensions[length] - maxPadding;\n const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;\n const offset = clamp(min$1, center, max);\n\n // If the reference is small enough that the arrow's padding causes it to\n // to point to nothing for an aligned placement, adjust the offset of the\n // floating element itself. To ensure `shift()` continues to take action,\n // a single reset is performed when this is true.\n const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;\n const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;\n return {\n [axis]: coords[axis] + alignmentOffset,\n data: {\n [axis]: offset,\n centerOffset: center - offset - alignmentOffset,\n ...(shouldAddOffset && {\n alignmentOffset\n })\n },\n reset: shouldAddOffset\n };\n }\n});\n\nfunction getPlacementList(alignment, autoAlignment, allowedPlacements) {\n const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);\n return allowedPlacementsSortedByAlignment.filter(placement => {\n if (alignment) {\n return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);\n }\n return true;\n });\n}\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'autoPlacement',\n options,\n async fn(state) {\n var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;\n const {\n rects,\n middlewareData,\n placement,\n platform,\n elements\n } = state;\n const {\n crossAxis = false,\n alignment,\n allowedPlacements = placements,\n autoAlignment = true,\n ...detectOverflowOptions\n } = evaluate(options, state);\n const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;\n const currentPlacement = placements$1[currentIndex];\n if (currentPlacement == null) {\n return {};\n }\n const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));\n\n // Make `computeCoords` start from the right place.\n if (placement !== currentPlacement) {\n return {\n reset: {\n placement: placements$1[0]\n }\n };\n }\n const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];\n const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {\n placement: currentPlacement,\n overflows: currentOverflows\n }];\n const nextPlacement = placements$1[currentIndex + 1];\n\n // There are more placements to check.\n if (nextPlacement) {\n return {\n data: {\n index: currentIndex + 1,\n overflows: allOverflows\n },\n reset: {\n placement: nextPlacement\n }\n };\n }\n const placementsSortedByMostSpace = allOverflows.map(d => {\n const alignment = getAlignment(d.placement);\n return [d.placement, alignment && crossAxis ?\n // Check along the mainAxis and main crossAxis side.\n d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :\n // Check only the mainAxis.\n d.overflows[0], d.overflows];\n }).sort((a, b) => a[1] - b[1]);\n const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,\n // Aligned placements should not check their opposite crossAxis\n // side.\n getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));\n const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];\n if (resetPlacement !== placement) {\n return {\n data: {\n index: currentIndex + 1,\n overflows: allOverflows\n },\n reset: {\n placement: resetPlacement\n }\n };\n }\n return {};\n }\n };\n};\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'flip',\n options,\n async fn(state) {\n var _middlewareData$arrow, _middlewareData$flip;\n const {\n placement,\n middlewareData,\n rects,\n initialPlacement,\n platform,\n elements\n } = state;\n const {\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = true,\n fallbackPlacements: specifiedFallbackPlacements,\n fallbackStrategy = 'bestFit',\n fallbackAxisSideDirection = 'none',\n flipAlignment = true,\n ...detectOverflowOptions\n } = evaluate(options, state);\n\n // If a reset by the arrow was caused due to an alignment offset being\n // added, we should skip any logic now since `flip()` has already done its\n // work.\n // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643\n if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n return {};\n }\n const side = getSide(placement);\n const initialSideAxis = getSideAxis(initialPlacement);\n const isBasePlacement = getSide(initialPlacement) === initialPlacement;\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));\n const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';\n if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {\n fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));\n }\n const placements = [initialPlacement, ...fallbackPlacements];\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const overflows = [];\n let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];\n if (checkMainAxis) {\n overflows.push(overflow[side]);\n }\n if (checkCrossAxis) {\n const sides = getAlignmentSides(placement, rects, rtl);\n overflows.push(overflow[sides[0]], overflow[sides[1]]);\n }\n overflowsData = [...overflowsData, {\n placement,\n overflows\n }];\n\n // One or more sides is overflowing.\n if (!overflows.every(side => side <= 0)) {\n var _middlewareData$flip2, _overflowsData$filter;\n const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;\n const nextPlacement = placements[nextIndex];\n if (nextPlacement) {\n const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;\n if (!ignoreCrossAxisOverflow ||\n // We leave the current main axis only if every placement on that axis\n // overflows the main axis.\n overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {\n // Try next placement and re-run the lifecycle.\n return {\n data: {\n index: nextIndex,\n overflows: overflowsData\n },\n reset: {\n placement: nextPlacement\n }\n };\n }\n }\n\n // First, find the candidates that fit on the mainAxis side of overflow,\n // then find the placement that fits the best on the main crossAxis side.\n let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;\n\n // Otherwise fallback.\n if (!resetPlacement) {\n switch (fallbackStrategy) {\n case 'bestFit':\n {\n var _overflowsData$filter2;\n const placement = (_overflowsData$filter2 = overflowsData.filter(d => {\n if (hasFallbackAxisSideDirection) {\n const currentSideAxis = getSideAxis(d.placement);\n return currentSideAxis === initialSideAxis ||\n // Create a bias to the `y` side axis due to horizontal\n // reading directions favoring greater width.\n currentSideAxis === 'y';\n }\n return true;\n }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];\n if (placement) {\n resetPlacement = placement;\n }\n break;\n }\n case 'initialPlacement':\n resetPlacement = initialPlacement;\n break;\n }\n }\n if (placement !== resetPlacement) {\n return {\n reset: {\n placement: resetPlacement\n }\n };\n }\n }\n return {};\n }\n };\n};\n\nfunction getSideOffsets(overflow, rect) {\n return {\n top: overflow.top - rect.height,\n right: overflow.right - rect.width,\n bottom: overflow.bottom - rect.height,\n left: overflow.left - rect.width\n };\n}\nfunction isAnySideFullyClipped(overflow) {\n return sides.some(side => overflow[side] >= 0);\n}\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'hide',\n options,\n async fn(state) {\n const {\n rects,\n platform\n } = state;\n const {\n strategy = 'referenceHidden',\n ...detectOverflowOptions\n } = evaluate(options, state);\n switch (strategy) {\n case 'referenceHidden':\n {\n const overflow = await platform.detectOverflow(state, {\n ...detectOverflowOptions,\n elementContext: 'reference'\n });\n const offsets = getSideOffsets(overflow, rects.reference);\n return {\n data: {\n referenceHiddenOffsets: offsets,\n referenceHidden: isAnySideFullyClipped(offsets)\n }\n };\n }\n case 'escaped':\n {\n const overflow = await platform.detectOverflow(state, {\n ...detectOverflowOptions,\n altBoundary: true\n });\n const offsets = getSideOffsets(overflow, rects.floating);\n return {\n data: {\n escapedOffsets: offsets,\n escaped: isAnySideFullyClipped(offsets)\n }\n };\n }\n default:\n {\n return {};\n }\n }\n }\n };\n};\n\nfunction getBoundingRect(rects) {\n const minX = min(...rects.map(rect => rect.left));\n const minY = min(...rects.map(rect => rect.top));\n const maxX = max(...rects.map(rect => rect.right));\n const maxY = max(...rects.map(rect => rect.bottom));\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY\n };\n}\nfunction getRectsByLine(rects) {\n const sortedRects = rects.slice().sort((a, b) => a.y - b.y);\n const groups = [];\n let prevRect = null;\n for (let i = 0; i < sortedRects.length; i++) {\n const rect = sortedRects[i];\n if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {\n groups.push([rect]);\n } else {\n groups[groups.length - 1].push(rect);\n }\n prevRect = rect;\n }\n return groups.map(rect => rectToClientRect(getBoundingRect(rect)));\n}\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'inline',\n options,\n async fn(state) {\n const {\n placement,\n elements,\n rects,\n platform,\n strategy\n } = state;\n // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a\n // ClientRect's bounds, despite the event listener being triggered. A\n // padding of 2 seems to handle this issue.\n const {\n padding = 2,\n x,\n y\n } = evaluate(options, state);\n const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);\n const clientRects = getRectsByLine(nativeClientRects);\n const fallback = rectToClientRect(getBoundingRect(nativeClientRects));\n const paddingObject = getPaddingObject(padding);\n function getBoundingClientRect() {\n // There are two rects and they are disjoined.\n if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {\n // Find the first rect in which the point is fully inside.\n return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;\n }\n\n // There are 2 or more connected rects.\n if (clientRects.length >= 2) {\n if (getSideAxis(placement) === 'y') {\n const firstRect = clientRects[0];\n const lastRect = clientRects[clientRects.length - 1];\n const isTop = getSide(placement) === 'top';\n const top = firstRect.top;\n const bottom = lastRect.bottom;\n const left = isTop ? firstRect.left : lastRect.left;\n const right = isTop ? firstRect.right : lastRect.right;\n const width = right - left;\n const height = bottom - top;\n return {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x: left,\n y: top\n };\n }\n const isLeftSide = getSide(placement) === 'left';\n const maxRight = max(...clientRects.map(rect => rect.right));\n const minLeft = min(...clientRects.map(rect => rect.left));\n const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);\n const top = measureRects[0].top;\n const bottom = measureRects[measureRects.length - 1].bottom;\n const left = minLeft;\n const right = maxRight;\n const width = right - left;\n const height = bottom - top;\n return {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x: left,\n y: top\n };\n }\n return fallback;\n }\n const resetRects = await platform.getElementRects({\n reference: {\n getBoundingClientRect\n },\n floating: elements.floating,\n strategy\n });\n if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {\n return {\n reset: {\n rects: resetRects\n }\n };\n }\n return {};\n }\n };\n};\n\nconst originSides = /*#__PURE__*/new Set(['left', 'top']);\n\n// For type backwards-compatibility, the `OffsetOptions` type was also\n// Derivable.\n\nasync function convertValueToCoords(state, options) {\n const {\n placement,\n platform,\n elements\n } = state;\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n const side = getSide(placement);\n const alignment = getAlignment(placement);\n const isVertical = getSideAxis(placement) === 'y';\n const mainAxisMulti = originSides.has(side) ? -1 : 1;\n const crossAxisMulti = rtl && isVertical ? -1 : 1;\n const rawValue = evaluate(options, state);\n\n // eslint-disable-next-line prefer-const\n let {\n mainAxis,\n crossAxis,\n alignmentAxis\n } = typeof rawValue === 'number' ? {\n mainAxis: rawValue,\n crossAxis: 0,\n alignmentAxis: null\n } : {\n mainAxis: rawValue.mainAxis || 0,\n crossAxis: rawValue.crossAxis || 0,\n alignmentAxis: rawValue.alignmentAxis\n };\n if (alignment && typeof alignmentAxis === 'number') {\n crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;\n }\n return isVertical ? {\n x: crossAxis * crossAxisMulti,\n y: mainAxis * mainAxisMulti\n } : {\n x: mainAxis * mainAxisMulti,\n y: crossAxis * crossAxisMulti\n };\n}\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = function (options) {\n if (options === void 0) {\n options = 0;\n }\n return {\n name: 'offset',\n options,\n async fn(state) {\n var _middlewareData$offse, _middlewareData$arrow;\n const {\n x,\n y,\n placement,\n middlewareData\n } = state;\n const diffCoords = await convertValueToCoords(state, options);\n\n // If the placement is the same and the arrow caused an alignment offset\n // then we don't need to change the positioning coordinates.\n if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n return {};\n }\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: {\n ...diffCoords,\n placement\n }\n };\n }\n };\n};\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'shift',\n options,\n async fn(state) {\n const {\n x,\n y,\n placement,\n platform\n } = state;\n const {\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = false,\n limiter = {\n fn: _ref => {\n let {\n x,\n y\n } = _ref;\n return {\n x,\n y\n };\n }\n },\n ...detectOverflowOptions\n } = evaluate(options, state);\n const coords = {\n x,\n y\n };\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const crossAxis = getSideAxis(getSide(placement));\n const mainAxis = getOppositeAxis(crossAxis);\n let mainAxisCoord = coords[mainAxis];\n let crossAxisCoord = coords[crossAxis];\n if (checkMainAxis) {\n const minSide = mainAxis === 'y' ? 'top' : 'left';\n const maxSide = mainAxis === 'y' ? 'bottom' : 'right';\n const min = mainAxisCoord + overflow[minSide];\n const max = mainAxisCoord - overflow[maxSide];\n mainAxisCoord = clamp(min, mainAxisCoord, max);\n }\n if (checkCrossAxis) {\n const minSide = crossAxis === 'y' ? 'top' : 'left';\n const maxSide = crossAxis === 'y' ? 'bottom' : 'right';\n const min = crossAxisCoord + overflow[minSide];\n const max = crossAxisCoord - overflow[maxSide];\n crossAxisCoord = clamp(min, crossAxisCoord, max);\n }\n const limitedCoords = limiter.fn({\n ...state,\n [mainAxis]: mainAxisCoord,\n [crossAxis]: crossAxisCoord\n });\n return {\n ...limitedCoords,\n data: {\n x: limitedCoords.x - x,\n y: limitedCoords.y - y,\n enabled: {\n [mainAxis]: checkMainAxis,\n [crossAxis]: checkCrossAxis\n }\n }\n };\n }\n };\n};\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n options,\n fn(state) {\n const {\n x,\n y,\n placement,\n rects,\n middlewareData\n } = state;\n const {\n offset = 0,\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = true\n } = evaluate(options, state);\n const coords = {\n x,\n y\n };\n const crossAxis = getSideAxis(placement);\n const mainAxis = getOppositeAxis(crossAxis);\n let mainAxisCoord = coords[mainAxis];\n let crossAxisCoord = coords[crossAxis];\n const rawOffset = evaluate(offset, state);\n const computedOffset = typeof rawOffset === 'number' ? {\n mainAxis: rawOffset,\n crossAxis: 0\n } : {\n mainAxis: 0,\n crossAxis: 0,\n ...rawOffset\n };\n if (checkMainAxis) {\n const len = mainAxis === 'y' ? 'height' : 'width';\n const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;\n const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;\n if (mainAxisCoord < limitMin) {\n mainAxisCoord = limitMin;\n } else if (mainAxisCoord > limitMax) {\n mainAxisCoord = limitMax;\n }\n }\n if (checkCrossAxis) {\n var _middlewareData$offse, _middlewareData$offse2;\n const len = mainAxis === 'y' ? 'width' : 'height';\n const isOriginSide = originSides.has(getSide(placement));\n const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);\n const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);\n if (crossAxisCoord < limitMin) {\n crossAxisCoord = limitMin;\n } else if (crossAxisCoord > limitMax) {\n crossAxisCoord = limitMax;\n }\n }\n return {\n [mainAxis]: mainAxisCoord,\n [crossAxis]: crossAxisCoord\n };\n }\n };\n};\n\n/**\n * Provides data that allows you to change the size of the floating element \u2014\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'size',\n options,\n async fn(state) {\n var _state$middlewareData, _state$middlewareData2;\n const {\n placement,\n rects,\n platform,\n elements\n } = state;\n const {\n apply = () => {},\n ...detectOverflowOptions\n } = evaluate(options, state);\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const side = getSide(placement);\n const alignment = getAlignment(placement);\n const isYAxis = getSideAxis(placement) === 'y';\n const {\n width,\n height\n } = rects.floating;\n let heightSide;\n let widthSide;\n if (side === 'top' || side === 'bottom') {\n heightSide = side;\n widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';\n } else {\n widthSide = side;\n heightSide = alignment === 'end' ? 'top' : 'bottom';\n }\n const maximumClippingHeight = height - overflow.top - overflow.bottom;\n const maximumClippingWidth = width - overflow.left - overflow.right;\n const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);\n const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);\n const noShift = !state.middlewareData.shift;\n let availableHeight = overflowAvailableHeight;\n let availableWidth = overflowAvailableWidth;\n if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {\n availableWidth = maximumClippingWidth;\n }\n if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {\n availableHeight = maximumClippingHeight;\n }\n if (noShift && !alignment) {\n const xMin = max(overflow.left, 0);\n const xMax = max(overflow.right, 0);\n const yMin = max(overflow.top, 0);\n const yMax = max(overflow.bottom, 0);\n if (isYAxis) {\n availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));\n } else {\n availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));\n }\n }\n await apply({\n ...state,\n availableWidth,\n availableHeight\n });\n const nextDimensions = await platform.getDimensions(elements.floating);\n if (width !== nextDimensions.width || height !== nextDimensions.height) {\n return {\n reset: {\n rects: true\n }\n };\n }\n return {};\n }\n };\n};\n\nexport { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size };\n", "function hasWindow() {\n return typeof window !== 'undefined';\n}\nfunction getNodeName(node) {\n if (isNode(node)) {\n return (node.nodeName || '').toLowerCase();\n }\n // Mocked nodes in testing environments may not be instances of Node. By\n // returning `#document` an infinite loop won't occur.\n // https://github.com/floating-ui/floating-ui/issues/2317\n return '#document';\n}\nfunction getWindow(node) {\n var _node$ownerDocument;\n return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;\n}\nfunction getDocumentElement(node) {\n var _ref;\n return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;\n}\nfunction isNode(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Node || value instanceof getWindow(value).Node;\n}\nfunction isElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Element || value instanceof getWindow(value).Element;\n}\nfunction isHTMLElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n}\nfunction isShadowRoot(value) {\n if (!hasWindow() || typeof ShadowRoot === 'undefined') {\n return false;\n }\n return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;\n}\nconst invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);\nfunction isOverflowElement(element) {\n const {\n overflow,\n overflowX,\n overflowY,\n display\n } = getComputedStyle(element);\n return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);\n}\nconst tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);\nfunction isTableElement(element) {\n return tableElements.has(getNodeName(element));\n}\nconst topLayerSelectors = [':popover-open', ':modal'];\nfunction isTopLayer(element) {\n return topLayerSelectors.some(selector => {\n try {\n return element.matches(selector);\n } catch (_e) {\n return false;\n }\n });\n}\nconst transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];\nconst willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];\nconst containValues = ['paint', 'layout', 'strict', 'content'];\nfunction isContainingBlock(elementOrCss) {\n const webkit = isWebKit();\n const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n // https://drafts.csswg.org/css-transforms-2/#individual-transforms\n return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));\n}\nfunction getContainingBlock(element) {\n let currentNode = getParentNode(element);\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else if (isTopLayer(currentNode)) {\n return null;\n }\n currentNode = getParentNode(currentNode);\n }\n return null;\n}\nfunction isWebKit() {\n if (typeof CSS === 'undefined' || !CSS.supports) return false;\n return CSS.supports('-webkit-backdrop-filter', 'none');\n}\nconst lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);\nfunction isLastTraversableNode(node) {\n return lastTraversableNodeNames.has(getNodeName(node));\n}\nfunction getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}\nfunction getNodeScroll(element) {\n if (isElement(element)) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n }\n return {\n scrollLeft: element.scrollX,\n scrollTop: element.scrollY\n };\n}\nfunction getParentNode(node) {\n if (getNodeName(node) === 'html') {\n return node;\n }\n const result =\n // Step into the shadow DOM of the parent of a slotted node.\n node.assignedSlot ||\n // DOM Element detected.\n node.parentNode ||\n // ShadowRoot detected.\n isShadowRoot(node) && node.host ||\n // Fallback.\n getDocumentElement(node);\n return isShadowRoot(result) ? result.host : result;\n}\nfunction getNearestOverflowAncestor(node) {\n const parentNode = getParentNode(node);\n if (isLastTraversableNode(parentNode)) {\n return node.ownerDocument ? node.ownerDocument.body : node.body;\n }\n if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {\n return parentNode;\n }\n return getNearestOverflowAncestor(parentNode);\n}\nfunction getOverflowAncestors(node, list, traverseIframes) {\n var _node$ownerDocument2;\n if (list === void 0) {\n list = [];\n }\n if (traverseIframes === void 0) {\n traverseIframes = true;\n }\n const scrollableAncestor = getNearestOverflowAncestor(node);\n const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);\n const win = getWindow(scrollableAncestor);\n if (isBody) {\n const frameElement = getFrameElement(win);\n return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);\n }\n return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));\n}\nfunction getFrameElement(win) {\n return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;\n}\n\nexport { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };\n", "import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@floating-ui/core';\nimport { round, createCoords, max, min, floor } from '@floating-ui/utils';\nimport { getComputedStyle as getComputedStyle$1, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom';\nexport { getOverflowAncestors } from '@floating-ui/utils/dom';\n\nfunction getCssDimensions(element) {\n const css = getComputedStyle$1(element);\n // In testing environments, the `width` and `height` properties are empty\n // strings for SVG elements, returning NaN. Fallback to `0` in this case.\n let width = parseFloat(css.width) || 0;\n let height = parseFloat(css.height) || 0;\n const hasOffset = isHTMLElement(element);\n const offsetWidth = hasOffset ? element.offsetWidth : width;\n const offsetHeight = hasOffset ? element.offsetHeight : height;\n const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;\n if (shouldFallback) {\n width = offsetWidth;\n height = offsetHeight;\n }\n return {\n width,\n height,\n $: shouldFallback\n };\n}\n\nfunction unwrapElement(element) {\n return !isElement(element) ? element.contextElement : element;\n}\n\nfunction getScale(element) {\n const domElement = unwrapElement(element);\n if (!isHTMLElement(domElement)) {\n return createCoords(1);\n }\n const rect = domElement.getBoundingClientRect();\n const {\n width,\n height,\n $\n } = getCssDimensions(domElement);\n let x = ($ ? round(rect.width) : rect.width) / width;\n let y = ($ ? round(rect.height) : rect.height) / height;\n\n // 0, NaN, or Infinity should always fallback to 1.\n\n if (!x || !Number.isFinite(x)) {\n x = 1;\n }\n if (!y || !Number.isFinite(y)) {\n y = 1;\n }\n return {\n x,\n y\n };\n}\n\nconst noOffsets = /*#__PURE__*/createCoords(0);\nfunction getVisualOffsets(element) {\n const win = getWindow(element);\n if (!isWebKit() || !win.visualViewport) {\n return noOffsets;\n }\n return {\n x: win.visualViewport.offsetLeft,\n y: win.visualViewport.offsetTop\n };\n}\nfunction shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {\n if (isFixed === void 0) {\n isFixed = false;\n }\n if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {\n return false;\n }\n return isFixed;\n}\n\nfunction getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {\n if (includeScale === void 0) {\n includeScale = false;\n }\n if (isFixedStrategy === void 0) {\n isFixedStrategy = false;\n }\n const clientRect = element.getBoundingClientRect();\n const domElement = unwrapElement(element);\n let scale = createCoords(1);\n if (includeScale) {\n if (offsetParent) {\n if (isElement(offsetParent)) {\n scale = getScale(offsetParent);\n }\n } else {\n scale = getScale(element);\n }\n }\n const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);\n let x = (clientRect.left + visualOffsets.x) / scale.x;\n let y = (clientRect.top + visualOffsets.y) / scale.y;\n let width = clientRect.width / scale.x;\n let height = clientRect.height / scale.y;\n if (domElement) {\n const win = getWindow(domElement);\n const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;\n let currentWin = win;\n let currentIFrame = getFrameElement(currentWin);\n while (currentIFrame && offsetParent && offsetWin !== currentWin) {\n const iframeScale = getScale(currentIFrame);\n const iframeRect = currentIFrame.getBoundingClientRect();\n const css = getComputedStyle$1(currentIFrame);\n const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;\n const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;\n x *= iframeScale.x;\n y *= iframeScale.y;\n width *= iframeScale.x;\n height *= iframeScale.y;\n x += left;\n y += top;\n currentWin = getWindow(currentIFrame);\n currentIFrame = getFrameElement(currentWin);\n }\n }\n return rectToClientRect({\n width,\n height,\n x,\n y\n });\n}\n\n// If <html> has a CSS width greater than the viewport, then this will be\n// incorrect for RTL.\nfunction getWindowScrollBarX(element, rect) {\n const leftScroll = getNodeScroll(element).scrollLeft;\n if (!rect) {\n return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;\n }\n return rect.left + leftScroll;\n}\n\nfunction getHTMLOffset(documentElement, scroll) {\n const htmlRect = documentElement.getBoundingClientRect();\n const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);\n const y = htmlRect.top + scroll.scrollTop;\n return {\n x,\n y\n };\n}\n\nfunction convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {\n let {\n elements,\n rect,\n offsetParent,\n strategy\n } = _ref;\n const isFixed = strategy === 'fixed';\n const documentElement = getDocumentElement(offsetParent);\n const topLayer = elements ? isTopLayer(elements.floating) : false;\n if (offsetParent === documentElement || topLayer && isFixed) {\n return rect;\n }\n let scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n let scale = createCoords(1);\n const offsets = createCoords(0);\n const isOffsetParentAnElement = isHTMLElement(offsetParent);\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n if (isHTMLElement(offsetParent)) {\n const offsetRect = getBoundingClientRect(offsetParent);\n scale = getScale(offsetParent);\n offsets.x = offsetRect.x + offsetParent.clientLeft;\n offsets.y = offsetRect.y + offsetParent.clientTop;\n }\n }\n const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);\n return {\n width: rect.width * scale.x,\n height: rect.height * scale.y,\n x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,\n y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y\n };\n}\n\nfunction getClientRects(element) {\n return Array.from(element.getClientRects());\n}\n\n// Gets the entire size of the scrollable document area, even extending outside\n// of the `<html>` and `<body>` rect bounds if horizontally scrollable.\nfunction getDocumentRect(element) {\n const html = getDocumentElement(element);\n const scroll = getNodeScroll(element);\n const body = element.ownerDocument.body;\n const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);\n const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);\n let x = -scroll.scrollLeft + getWindowScrollBarX(element);\n const y = -scroll.scrollTop;\n if (getComputedStyle$1(body).direction === 'rtl') {\n x += max(html.clientWidth, body.clientWidth) - width;\n }\n return {\n width,\n height,\n x,\n y\n };\n}\n\n// Safety check: ensure the scrollbar space is reasonable in case this\n// calculation is affected by unusual styles.\n// Most scrollbars leave 15-18px of space.\nconst SCROLLBAR_MAX = 25;\nfunction getViewportRect(element, strategy) {\n const win = getWindow(element);\n const html = getDocumentElement(element);\n const visualViewport = win.visualViewport;\n let width = html.clientWidth;\n let height = html.clientHeight;\n let x = 0;\n let y = 0;\n if (visualViewport) {\n width = visualViewport.width;\n height = visualViewport.height;\n const visualViewportBased = isWebKit();\n if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {\n x = visualViewport.offsetLeft;\n y = visualViewport.offsetTop;\n }\n }\n const windowScrollbarX = getWindowScrollBarX(html);\n // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the\n // visual width of the <html> but this is not considered in the size\n // of `html.clientWidth`.\n if (windowScrollbarX <= 0) {\n const doc = html.ownerDocument;\n const body = doc.body;\n const bodyStyles = getComputedStyle(body);\n const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;\n const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);\n if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {\n width -= clippingStableScrollbarWidth;\n }\n } else if (windowScrollbarX <= SCROLLBAR_MAX) {\n // If the <body> scrollbar is on the left, the width needs to be extended\n // by the scrollbar amount so there isn't extra space on the right.\n width += windowScrollbarX;\n }\n return {\n width,\n height,\n x,\n y\n };\n}\n\nconst absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);\n// Returns the inner client rect, subtracting scrollbars if present.\nfunction getInnerBoundingClientRect(element, strategy) {\n const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');\n const top = clientRect.top + element.clientTop;\n const left = clientRect.left + element.clientLeft;\n const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);\n const width = element.clientWidth * scale.x;\n const height = element.clientHeight * scale.y;\n const x = left * scale.x;\n const y = top * scale.y;\n return {\n width,\n height,\n x,\n y\n };\n}\nfunction getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {\n let rect;\n if (clippingAncestor === 'viewport') {\n rect = getViewportRect(element, strategy);\n } else if (clippingAncestor === 'document') {\n rect = getDocumentRect(getDocumentElement(element));\n } else if (isElement(clippingAncestor)) {\n rect = getInnerBoundingClientRect(clippingAncestor, strategy);\n } else {\n const visualOffsets = getVisualOffsets(element);\n rect = {\n x: clippingAncestor.x - visualOffsets.x,\n y: clippingAncestor.y - visualOffsets.y,\n width: clippingAncestor.width,\n height: clippingAncestor.height\n };\n }\n return rectToClientRect(rect);\n}\nfunction hasFixedPositionAncestor(element, stopNode) {\n const parentNode = getParentNode(element);\n if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {\n return false;\n }\n return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);\n}\n\n// A \"clipping ancestor\" is an `overflow` element with the characteristic of\n// clipping (or hiding) child elements. This returns all clipping ancestors\n// of the given element up the tree.\nfunction getClippingElementAncestors(element, cache) {\n const cachedResult = cache.get(element);\n if (cachedResult) {\n return cachedResult;\n }\n let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');\n let currentContainingBlockComputedStyle = null;\n const elementIsFixed = getComputedStyle$1(element).position === 'fixed';\n let currentNode = elementIsFixed ? getParentNode(element) : element;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {\n const computedStyle = getComputedStyle$1(currentNode);\n const currentNodeIsContaining = isContainingBlock(currentNode);\n if (!currentNodeIsContaining && computedStyle.position === 'fixed') {\n currentContainingBlockComputedStyle = null;\n }\n const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);\n if (shouldDropCurrentNode) {\n // Drop non-containing blocks.\n result = result.filter(ancestor => ancestor !== currentNode);\n } else {\n // Record last containing block for next iteration.\n currentContainingBlockComputedStyle = computedStyle;\n }\n currentNode = getParentNode(currentNode);\n }\n cache.set(element, result);\n return result;\n}\n\n// Gets the maximum area that the element is visible in due to any number of\n// clipping ancestors.\nfunction getClippingRect(_ref) {\n let {\n element,\n boundary,\n rootBoundary,\n strategy\n } = _ref;\n const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);\n const clippingAncestors = [...elementClippingAncestors, rootBoundary];\n const firstClippingAncestor = clippingAncestors[0];\n const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {\n const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);\n accRect.top = max(rect.top, accRect.top);\n accRect.right = min(rect.right, accRect.right);\n accRect.bottom = min(rect.bottom, accRect.bottom);\n accRect.left = max(rect.left, accRect.left);\n return accRect;\n }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));\n return {\n width: clippingRect.right - clippingRect.left,\n height: clippingRect.bottom - clippingRect.top,\n x: clippingRect.left,\n y: clippingRect.top\n };\n}\n\nfunction getDimensions(element) {\n const {\n width,\n height\n } = getCssDimensions(element);\n return {\n width,\n height\n };\n}\n\nfunction getRectRelativeToOffsetParent(element, offsetParent, strategy) {\n const isOffsetParentAnElement = isHTMLElement(offsetParent);\n const documentElement = getDocumentElement(offsetParent);\n const isFixed = strategy === 'fixed';\n const rect = getBoundingClientRect(element, true, isFixed, offsetParent);\n let scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n const offsets = createCoords(0);\n\n // If the <body> scrollbar appears on the left (e.g. RTL systems). Use\n // Firefox with layout.scrollbar.side = 3 in about:config to test this.\n function setLeftRTLScrollbarOffset() {\n offsets.x = getWindowScrollBarX(documentElement);\n }\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n if (isOffsetParentAnElement) {\n const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);\n offsets.x = offsetRect.x + offsetParent.clientLeft;\n offsets.y = offsetRect.y + offsetParent.clientTop;\n } else if (documentElement) {\n setLeftRTLScrollbarOffset();\n }\n }\n if (isFixed && !isOffsetParentAnElement && documentElement) {\n setLeftRTLScrollbarOffset();\n }\n const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);\n const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;\n const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;\n return {\n x,\n y,\n width: rect.width,\n height: rect.height\n };\n}\n\nfunction isStaticPositioned(element) {\n return getComputedStyle$1(element).position === 'static';\n}\n\nfunction getTrueOffsetParent(element, polyfill) {\n if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {\n return null;\n }\n if (polyfill) {\n return polyfill(element);\n }\n let rawOffsetParent = element.offsetParent;\n\n // Firefox returns the <html> element as the offsetParent if it's non-static,\n // while Chrome and Safari return the <body> element. The <body> element must\n // be used to perform the correct calculations even if the <html> element is\n // non-static.\n if (getDocumentElement(element) === rawOffsetParent) {\n rawOffsetParent = rawOffsetParent.ownerDocument.body;\n }\n return rawOffsetParent;\n}\n\n// Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\nfunction getOffsetParent(element, polyfill) {\n const win = getWindow(element);\n if (isTopLayer(element)) {\n return win;\n }\n if (!isHTMLElement(element)) {\n let svgOffsetParent = getParentNode(element);\n while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {\n if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {\n return svgOffsetParent;\n }\n svgOffsetParent = getParentNode(svgOffsetParent);\n }\n return win;\n }\n let offsetParent = getTrueOffsetParent(element, polyfill);\n while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {\n offsetParent = getTrueOffsetParent(offsetParent, polyfill);\n }\n if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {\n return win;\n }\n return offsetParent || getContainingBlock(element) || win;\n}\n\nconst getElementRects = async function (data) {\n const getOffsetParentFn = this.getOffsetParent || getOffsetParent;\n const getDimensionsFn = this.getDimensions;\n const floatingDimensions = await getDimensionsFn(data.floating);\n return {\n reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),\n floating: {\n x: 0,\n y: 0,\n width: floatingDimensions.width,\n height: floatingDimensions.height\n }\n };\n};\n\nfunction isRTL(element) {\n return getComputedStyle$1(element).direction === 'rtl';\n}\n\nconst platform = {\n convertOffsetParentRelativeRectToViewportRelativeRect,\n getDocumentElement,\n getClippingRect,\n getOffsetParent,\n getElementRects,\n getClientRects,\n getDimensions,\n getScale,\n isElement,\n isRTL\n};\n\nfunction rectsAreEqual(a, b) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\n// https://samthor.au/2021/observing-dom/\nfunction observeMove(element, onMove) {\n let io = null;\n let timeoutId;\n const root = getDocumentElement(element);\n function cleanup() {\n var _io;\n clearTimeout(timeoutId);\n (_io = io) == null || _io.disconnect();\n io = null;\n }\n function refresh(skip, threshold) {\n if (skip === void 0) {\n skip = false;\n }\n if (threshold === void 0) {\n threshold = 1;\n }\n cleanup();\n const elementRectForRootMargin = element.getBoundingClientRect();\n const {\n left,\n top,\n width,\n height\n } = elementRectForRootMargin;\n if (!skip) {\n onMove();\n }\n if (!width || !height) {\n return;\n }\n const insetTop = floor(top);\n const insetRight = floor(root.clientWidth - (left + width));\n const insetBottom = floor(root.clientHeight - (top + height));\n const insetLeft = floor(left);\n const rootMargin = -insetTop + \"px \" + -insetRight + \"px \" + -insetBottom + \"px \" + -insetLeft + \"px\";\n const options = {\n rootMargin,\n threshold: max(0, min(1, threshold)) || 1\n };\n let isFirstUpdate = true;\n function handleObserve(entries) {\n const ratio = entries[0].intersectionRatio;\n if (ratio !== threshold) {\n if (!isFirstUpdate) {\n return refresh();\n }\n if (!ratio) {\n // If the reference is clipped, the ratio is 0. Throttle the refresh\n // to prevent an infinite loop of updates.\n timeoutId = setTimeout(() => {\n refresh(false, 1e-7);\n }, 1000);\n } else {\n refresh(false, ratio);\n }\n }\n if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {\n // It's possible that even though the ratio is reported as 1, the\n // element is not actually fully within the IntersectionObserver's root\n // area anymore. This can happen under performance constraints. This may\n // be a bug in the browser's IntersectionObserver implementation. To\n // work around this, we compare the element's bounding rect now with\n // what it was at the time we created the IntersectionObserver. If they\n // are not equal then the element moved, so we refresh.\n refresh();\n }\n isFirstUpdate = false;\n }\n\n // Older browsers don't support a `document` as the root and will throw an\n // error.\n try {\n io = new IntersectionObserver(handleObserve, {\n ...options,\n // Handle <iframe>s\n root: root.ownerDocument\n });\n } catch (_e) {\n io = new IntersectionObserver(handleObserve, options);\n }\n io.observe(element);\n }\n refresh(true);\n return cleanup;\n}\n\n/**\n * Automatically updates the position of the floating element when necessary.\n * Should only be called when the floating element is mounted on the DOM or\n * visible on the screen.\n * @returns cleanup function that should be invoked when the floating element is\n * removed from the DOM or hidden from the screen.\n * @see https://floating-ui.com/docs/autoUpdate\n */\nfunction autoUpdate(reference, floating, update, options) {\n if (options === void 0) {\n options = {};\n }\n const {\n ancestorScroll = true,\n ancestorResize = true,\n elementResize = typeof ResizeObserver === 'function',\n layoutShift = typeof IntersectionObserver === 'function',\n animationFrame = false\n } = options;\n const referenceEl = unwrapElement(reference);\n const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];\n ancestors.forEach(ancestor => {\n ancestorScroll && ancestor.addEventListener('scroll', update, {\n passive: true\n });\n ancestorResize && ancestor.addEventListener('resize', update);\n });\n const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;\n let reobserveFrame = -1;\n let resizeObserver = null;\n if (elementResize) {\n resizeObserver = new ResizeObserver(_ref => {\n let [firstEntry] = _ref;\n if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {\n // Prevent update loops when using the `size` middleware.\n // https://github.com/floating-ui/floating-ui/issues/1740\n resizeObserver.unobserve(floating);\n cancelAnimationFrame(reobserveFrame);\n reobserveFrame = requestAnimationFrame(() => {\n var _resizeObserver;\n (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);\n });\n }\n update();\n });\n if (referenceEl && !animationFrame) {\n resizeObserver.observe(referenceEl);\n }\n resizeObserver.observe(floating);\n }\n let frameId;\n let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;\n if (animationFrame) {\n frameLoop();\n }\n function frameLoop() {\n const nextRefRect = getBoundingClientRect(reference);\n if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {\n update();\n }\n prevRefRect = nextRefRect;\n frameId = requestAnimationFrame(frameLoop);\n }\n update();\n return () => {\n var _resizeObserver2;\n ancestors.forEach(ancestor => {\n ancestorScroll && ancestor.removeEventListener('scroll', update);\n ancestorResize && ancestor.removeEventListener('resize', update);\n });\n cleanupIo == null || cleanupIo();\n (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();\n resizeObserver = null;\n if (animationFrame) {\n cancelAnimationFrame(frameId);\n }\n };\n}\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nconst detectOverflow = detectOverflow$1;\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = offset$1;\n\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = autoPlacement$1;\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = shift$1;\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = flip$1;\n\n/**\n * Provides data that allows you to change the size of the floating element \u2014\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = size$1;\n\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = hide$1;\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = arrow$1;\n\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = inline$1;\n\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = limitShift$1;\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n */\nconst computePosition = (reference, floating, options) => {\n // This caches the expensive `getClippingElementAncestors` function so that\n // multiple lifecycle resets re-use the same result. It only lives for a\n // single call. If other functions become expensive, we can add them as well.\n const cache = new Map();\n const mergedOptions = {\n platform,\n ...options\n };\n const platformWithCache = {\n ...mergedOptions.platform,\n _c: cache\n };\n return computePosition$1(reference, floating, {\n ...mergedOptions,\n platform: platformWithCache\n });\n};\n\nexport { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, platform, shift, size };\n", "/**\n * Link Tooltip - Shows a clickable tooltip when cursor is within a link\n * Uses Floating UI for positioning across all browsers\n */\n\nimport { computePosition, offset, shift, flip } from '@floating-ui/dom';\n\nexport class LinkTooltip {\n constructor(editor) {\n this.editor = editor;\n this.tooltip = null;\n this.currentLink = null;\n this.hideTimeout = null;\n this.visibilityChangeHandler = null;\n this.isTooltipHovered = false;\n\n this.init();\n }\n\n init() {\n // Create tooltip element\n this.createTooltip();\n\n // Listen for cursor position changes\n this.editor.textarea.addEventListener('selectionchange', () => this.checkCursorPosition());\n this.editor.textarea.addEventListener('keyup', e => {\n if (e.key.includes('Arrow') || e.key === 'Home' || e.key === 'End') {\n this.checkCursorPosition();\n }\n });\n\n // Hide tooltip when typing\n this.editor.textarea.addEventListener('input', () => this.hide());\n\n // Reposition tooltip when scrolling\n this.editor.textarea.addEventListener('scroll', () => {\n if (this.currentLink) {\n this.positionTooltip(this.currentLink);\n }\n });\n\n // Hide tooltip when textarea loses focus (unless hovering tooltip)\n this.editor.textarea.addEventListener('blur', () => {\n if (!this.isTooltipHovered) {\n this.hide();\n }\n });\n\n // Hide tooltip when page loses visibility (tab switch, minimize, etc.)\n this.visibilityChangeHandler = () => {\n if (document.hidden) {\n this.hide();\n }\n };\n document.addEventListener('visibilitychange', this.visibilityChangeHandler);\n\n // Track hover state to prevent hiding when clicking tooltip\n this.tooltip.addEventListener('mouseenter', () => {\n this.isTooltipHovered = true;\n this.cancelHide();\n });\n this.tooltip.addEventListener('mouseleave', () => {\n this.isTooltipHovered = false;\n this.scheduleHide();\n });\n }\n\n createTooltip() {\n this.tooltip = document.createElement('div');\n this.tooltip.className = 'overtype-link-tooltip';\n\n // Add link icon and text container\n this.tooltip.innerHTML = `\n <span style=\"display: flex; align-items: center; gap: 6px;\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"flex-shrink: 0;\">\n <path d=\"M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z\"></path>\n <path d=\"M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z\"></path>\n </svg>\n <span class=\"overtype-link-tooltip-url\"></span>\n </span>\n `;\n\n // Click handler to open link\n this.tooltip.addEventListener('click', e => {\n e.preventDefault();\n e.stopPropagation();\n if (this.currentLink) {\n window.open(this.currentLink.url, '_blank');\n this.hide();\n }\n });\n\n // Append tooltip to editor container\n this.editor.container.appendChild(this.tooltip);\n }\n\n checkCursorPosition() {\n const cursorPos = this.editor.textarea.selectionStart;\n const text = this.editor.textarea.value;\n\n // Find if cursor is within a markdown link\n const linkInfo = this.findLinkAtPosition(text, cursorPos);\n\n if (linkInfo) {\n if (!this.currentLink || this.currentLink.url !== linkInfo.url || this.currentLink.index !== linkInfo.index) {\n this.show(linkInfo);\n }\n } else {\n this.scheduleHide();\n }\n }\n\n findLinkAtPosition(text, position) {\n // Regex to find markdown links: [text](url)\n const linkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n let match;\n let linkIndex = 0;\n\n while ((match = linkRegex.exec(text)) !== null) {\n const start = match.index;\n const end = match.index + match[0].length;\n\n if (position >= start && position <= end) {\n return {\n text: match[1],\n url: match[2],\n index: linkIndex,\n start: start,\n end: end\n };\n }\n linkIndex++;\n }\n\n return null;\n }\n\n async show(linkInfo) {\n this.currentLink = linkInfo;\n this.cancelHide();\n\n // Update tooltip content\n const urlSpan = this.tooltip.querySelector('.overtype-link-tooltip-url');\n urlSpan.textContent = linkInfo.url;\n\n // Position first (tooltip is always rendered but invisible, so Floating UI can measure it)\n await this.positionTooltip(linkInfo);\n\n // Only reveal if we're still showing this link\n if (this.currentLink === linkInfo) {\n this.tooltip.classList.add('visible');\n }\n }\n\n async positionTooltip(linkInfo) {\n const anchorElement = this.findAnchorElement(linkInfo.index);\n\n if (!anchorElement) {\n return;\n }\n\n const rect = anchorElement.getBoundingClientRect();\n if (rect.width === 0 || rect.height === 0) {\n return;\n }\n\n try {\n const { x, y } = await computePosition(\n anchorElement,\n this.tooltip,\n {\n strategy: 'fixed',\n placement: 'bottom',\n middleware: [\n offset(8),\n shift({ padding: 8 }),\n flip()\n ]\n }\n );\n\n Object.assign(this.tooltip.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed'\n });\n } catch (error) {\n console.warn('Floating UI positioning failed:', error);\n }\n }\n\n findAnchorElement(linkIndex) {\n const preview = this.editor.preview;\n return preview.querySelector(`a[style*=\"--link-${linkIndex}\"]`);\n }\n\n hide() {\n this.tooltip.classList.remove('visible');\n this.currentLink = null;\n this.isTooltipHovered = false;\n }\n\n scheduleHide() {\n this.cancelHide();\n this.hideTimeout = setTimeout(() => this.hide(), 300);\n }\n\n cancelHide() {\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n }\n\n destroy() {\n this.cancelHide();\n\n if (this.visibilityChangeHandler) {\n document.removeEventListener('visibilitychange', this.visibilityChangeHandler);\n this.visibilityChangeHandler = null;\n }\n\n if (this.tooltip && this.tooltip.parentNode) {\n this.tooltip.parentNode.removeChild(this.tooltip);\n }\n this.tooltip = null;\n this.currentLink = null;\n this.isTooltipHovered = false;\n }\n}\n", "/**\n * SVG icons for OverType toolbar\n * Quill-style icons with inline styles\n */\n\nexport const boldIcon = `<svg viewBox=\"0 0 18 18\">\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z\"></path>\n</svg>`;\n\nexport const italicIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"13\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"5\" x2=\"11\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"10\" y1=\"14\" y2=\"4\"></line>\n</svg>`;\n\nexport const h1Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z\"></path>\n</svg>`;\n\nexport const h2Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z\"></path>\n</svg>`;\n\nexport const h3Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M16.65186,12.30664a2.6742,2.6742,0,0,1-2.915,2.68457,3.96592,3.96592,0,0,1-2.25537-.6709.56007.56007,0,0,1-.13232-.83594L11.64648,13c.209-.34082.48389-.36328.82471-.1543a2.32654,2.32654,0,0,0,1.12256.33008c.71484,0,1.12207-.35156,1.12207-.78125,0-.61523-.61621-.86816-1.46338-.86816H13.2085a.65159.65159,0,0,1-.68213-.41895l-.05518-.10937a.67114.67114,0,0,1,.14307-.78125l.71533-.86914a8.55289,8.55289,0,0,1,.68213-.7373V8.58887a3.93913,3.93913,0,0,1-.748.05469H11.9873a.54085.54085,0,0,1-.605-.60547V7.59863a.54085.54085,0,0,1,.605-.60547h3.75146a.53773.53773,0,0,1,.60547.59375v.17676a1.03723,1.03723,0,0,1-.27539.748L14.74854,10.0293A2.31132,2.31132,0,0,1,16.65186,12.30664ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z\"></path>\n</svg>`;\n\nexport const linkIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"11\" y1=\"7\" y2=\"11\"></line>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z\"></path>\n</svg>`;\n\nexport const codeIcon = `<svg viewBox=\"0 0 18 18\">\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" points=\"5 7 3 9 5 11\"></polyline>\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" points=\"13 7 15 9 13 11\"></polyline>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"10\" x2=\"8\" y1=\"5\" y2=\"13\"></line>\n</svg>`;\n\n\nexport const bulletListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"14\" y2=\"14\"></line>\n</svg>`;\n\nexport const orderedListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" x1=\"2.5\" x2=\"4.5\" y1=\"5.5\" y2=\"5.5\"></line>\n <path fill=\"currentColor\" d=\"M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" d=\"M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" d=\"M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109\"></path>\n</svg>`;\n\nexport const quoteIcon = `<svg viewBox=\"2 2 20 20\">\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14\"></path>\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14\"></path>\n</svg>`;\n\nexport const taskListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"14\" y2=\"14\"></line>\n <rect stroke=\"currentColor\" fill=\"none\" stroke-width=\"1.5\" x=\"2\" y=\"3\" width=\"3\" height=\"3\" rx=\"0.5\"></rect>\n <rect stroke=\"currentColor\" fill=\"none\" stroke-width=\"1.5\" x=\"2\" y=\"13\" width=\"3\" height=\"3\" rx=\"0.5\"></rect>\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" points=\"2.65 9.5 3.5 10.5 5 8.5\"></polyline>\n</svg>`;\n\nexport const uploadIcon = `<svg viewBox=\"0 0 18 18\">\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M2.25 12.375v1.688A1.688 1.688 0 0 0 3.938 15.75h10.124a1.688 1.688 0 0 0 1.688-1.688V12.375\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5.063 6.188L9 2.25l3.938 3.938\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M9 2.25v10.125\"></path>\n</svg>`;\n\nexport const eyeIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\" fill=\"none\"></path>\n <circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"none\"></circle>\n</svg>`;", "/**\n * Toolbar button definitions for OverType editor\n * Export built-in buttons that can be used in custom toolbar configurations\n */\n\nimport * as icons from './icons.js';\nimport * as markdownActions from 'markdown-actions';\n\n/**\n * Built-in toolbar button definitions\n * Each button has: name, actionId, icon, title, action\n * - name: DOM identifier for the button element\n * - actionId: Canonical action identifier used by performAction\n * Action signature: ({ editor, getValue, setValue, event }) => void\n */\nexport const toolbarButtons = {\n bold: {\n name: 'bold',\n actionId: 'toggleBold',\n icon: icons.boldIcon,\n title: 'Bold (Ctrl+B)',\n action: ({ editor }) => {\n markdownActions.toggleBold(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n italic: {\n name: 'italic',\n actionId: 'toggleItalic',\n icon: icons.italicIcon,\n title: 'Italic (Ctrl+I)',\n action: ({ editor }) => {\n markdownActions.toggleItalic(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n code: {\n name: 'code',\n actionId: 'toggleCode',\n icon: icons.codeIcon,\n title: 'Inline Code',\n action: ({ editor }) => {\n markdownActions.toggleCode(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n separator: {\n name: 'separator'\n // No icon, title, or action - special separator element\n },\n\n link: {\n name: 'link',\n actionId: 'insertLink',\n icon: icons.linkIcon,\n title: 'Insert Link',\n action: ({ editor }) => {\n markdownActions.insertLink(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n h1: {\n name: 'h1',\n actionId: 'toggleH1',\n icon: icons.h1Icon,\n title: 'Heading 1',\n action: ({ editor }) => {\n markdownActions.toggleH1(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n h2: {\n name: 'h2',\n actionId: 'toggleH2',\n icon: icons.h2Icon,\n title: 'Heading 2',\n action: ({ editor }) => {\n markdownActions.toggleH2(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n h3: {\n name: 'h3',\n actionId: 'toggleH3',\n icon: icons.h3Icon,\n title: 'Heading 3',\n action: ({ editor }) => {\n markdownActions.toggleH3(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n bulletList: {\n name: 'bulletList',\n actionId: 'toggleBulletList',\n icon: icons.bulletListIcon,\n title: 'Bullet List',\n action: ({ editor }) => {\n markdownActions.toggleBulletList(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n orderedList: {\n name: 'orderedList',\n actionId: 'toggleNumberedList',\n icon: icons.orderedListIcon,\n title: 'Numbered List',\n action: ({ editor }) => {\n markdownActions.toggleNumberedList(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n taskList: {\n name: 'taskList',\n actionId: 'toggleTaskList',\n icon: icons.taskListIcon,\n title: 'Task List',\n action: ({ editor }) => {\n if (markdownActions.toggleTaskList) {\n markdownActions.toggleTaskList(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n },\n\n quote: {\n name: 'quote',\n actionId: 'toggleQuote',\n icon: icons.quoteIcon,\n title: 'Quote',\n action: ({ editor }) => {\n markdownActions.toggleQuote(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n upload: {\n name: 'upload',\n actionId: 'uploadFile',\n icon: icons.uploadIcon,\n title: 'Upload File',\n action: ({ editor }) => {\n if (!editor.options.fileUpload?.enabled) return;\n const input = document.createElement('input');\n input.type = 'file';\n input.multiple = true;\n if (editor.options.fileUpload.mimeTypes?.length > 0) {\n input.accept = editor.options.fileUpload.mimeTypes.join(',');\n }\n input.onchange = () => {\n if (!input.files?.length) return;\n const dt = new DataTransfer();\n for (const f of input.files) dt.items.add(f);\n editor._handleDataTransfer(dt);\n };\n input.click();\n }\n },\n\n viewMode: {\n name: 'viewMode',\n icon: icons.eyeIcon,\n title: 'View mode'\n // Special: handled internally by Toolbar class as dropdown\n // No action property - dropdown behavior is internal\n }\n};\n\n/**\n * Default toolbar button layout with separators\n * This is used when toolbar: true but no toolbarButtons provided\n */\nexport const defaultToolbarButtons = [\n toolbarButtons.bold,\n toolbarButtons.italic,\n toolbarButtons.code,\n toolbarButtons.separator,\n toolbarButtons.link,\n toolbarButtons.separator,\n toolbarButtons.h1,\n toolbarButtons.h2,\n toolbarButtons.h3,\n toolbarButtons.separator,\n toolbarButtons.bulletList,\n toolbarButtons.orderedList,\n toolbarButtons.taskList,\n toolbarButtons.separator,\n toolbarButtons.quote,\n toolbarButtons.separator,\n toolbarButtons.viewMode\n];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAa1B,OAAO,iBAAiB;AACtB,SAAK,YAAY;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,mBAAmB,aAAa;AACrC,SAAK,kBAAkB;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,gBAAgB,WAAW;AAChC,SAAK,eAAe;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,kBAAkB,MAAM;AAC7B,QAAI,KAAK,cAAc;AACrB,aAAO,KAAK,aAAa,IAAI;AAAA,IAC/B;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,MAAM;AACtB,UAAM,MAAM;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AACA,WAAO,KAAK,QAAQ,YAAY,OAAK,IAAI,CAAC,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,oBAAoB,MAAM,cAAc;AAC7C,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AAW,mCAAS;AAC1B,YAAI;AAAU,mBAAS,aAAa,CAAC;AAAA,MACvC;AAAA,IACF,GAAG,IAAI;AAGP,aAAS,iBAAiB,mBAAmB,CAAC,MAAM;AAClD,YAAM,gBAAgB,SAAS;AAC/B,UAAI,iBAAiB,cAAc,UAAU,SAAS,gBAAgB,GAAG;AACvE,cAAM,UAAU,cAAc,QAAQ,mBAAmB;AACzD,cAAM,WAAW,mCAAS;AAC1B,YAAI,UAAU;AAEZ,cAAI,SAAS,QAAQ,aAAa,SAAS,UAAU;AACnD,qBAAS,aAAa;AAAA,UACxB;AAEA,uBAAa,SAAS,iBAAiB;AACvC,mBAAS,oBAAoB,WAAW,MAAM;AAC5C,qBAAS,cAAc;AAAA,UACzB,GAAG,EAAE;AAAA,QACP;AAAA,MACF;AAAA,IACF,CAAC;AAED,cAAS,6BAA6B;AAAA,EACxC;AACJ;AAAA;AAnqDI,cAFE,WAEK,aAAY,oBAAI,QAAQ;AAC/B,cAHE,WAGK,kBAAiB;AACxB,cAJE,WAIK,8BAA6B;AACpC,cALE,WAKK,iBAAgB;AACvB,cANE,WAMK,mBAAkB;AACzB,cAPE,WAOK,sBAAqB;AAC5B,cARE,WAQK,kBAAiB,oBAAI,IAAI;AAChC,cATE,WASK,oBAAmB;AAC1B,cAVE,WAUK,2BAA0B;AAVrC,IAAM,WAAN;AAwqDA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAG5B,SAAS,SAAS,EAAE,OAAO,MAAM,SAAS,MAAM,EAAE;AAClD,SAAS,WAAW;AAGpB,SAAS,eAAe;AAGxB,IAAO,mBAAQ;",
4
+ "sourcesContent": ["/**\n * OverType - A lightweight markdown editor library with perfect WYSIWYG alignment\n * @version 1.0.0\n * @license MIT\n */\n\nimport { MarkdownParser } from './parser.js';\nimport { ShortcutsManager } from './shortcuts.js';\nimport { generateStyles } from './styles.js';\nimport { getTheme, mergeTheme, solar, themeToCSSVars, resolveAutoTheme } from './themes.js';\nimport { Toolbar } from './toolbar.js';\nimport { LinkTooltip } from './link-tooltip.js';\nimport { defaultToolbarButtons, toolbarButtons as builtinToolbarButtons } from './toolbar-buttons.js';\n\n/**\n * Build action map from toolbar button configurations\n * @param {Array} buttons - Array of button config objects\n * @returns {Object} Map of actionId -> action function\n */\nfunction buildActionsMap(buttons) {\n const map = {};\n (buttons || []).forEach((btn) => {\n if (!btn || btn.name === 'separator') return;\n const id = btn.actionId || btn.name;\n if (btn.action) {\n map[id] = btn.action;\n }\n });\n return map;\n}\n\n/**\n * Normalize toolbar buttons for comparison\n * @param {Array|null} buttons\n * @returns {Array|null}\n */\nfunction normalizeButtons(buttons) {\n const list = buttons || defaultToolbarButtons;\n if (!Array.isArray(list)) return null;\n return list.map((btn) => ({\n name: btn?.name || null,\n actionId: btn?.actionId || btn?.name || null,\n icon: btn?.icon || null,\n title: btn?.title || null\n }));\n}\n\n/**\n * Determine if toolbar button configuration changed\n * @param {Array|null} prevButtons\n * @param {Array|null} nextButtons\n * @returns {boolean}\n */\nfunction toolbarButtonsChanged(prevButtons, nextButtons) {\n const prev = normalizeButtons(prevButtons);\n const next = normalizeButtons(nextButtons);\n\n if (prev === null || next === null) return prev !== next;\n if (prev.length !== next.length) return true;\n\n for (let i = 0; i < prev.length; i++) {\n const a = prev[i];\n const b = next[i];\n if (a.name !== b.name ||\n a.actionId !== b.actionId ||\n a.icon !== b.icon ||\n a.title !== b.title) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * OverType Editor Class\n */\nclass OverType {\n // Static properties\n static instances = new WeakMap();\n static stylesInjected = false;\n static globalListenersInitialized = false;\n static instanceCount = 0;\n static _autoMediaQuery = null;\n static _autoMediaListener = null;\n static _autoInstances = new Set();\n static _globalAutoTheme = false;\n static _globalAutoCustomColors = null;\n\n /**\n * Constructor - Always returns an array of instances\n * @param {string|Element|NodeList|Array} target - Target element(s)\n * @param {Object} options - Configuration options\n * @returns {Array} Array of OverType instances\n */\n constructor(target, options = {}) {\n // Convert target to array of elements\n let elements;\n \n if (typeof target === 'string') {\n elements = document.querySelectorAll(target);\n if (elements.length === 0) {\n throw new Error(`No elements found for selector: ${target}`);\n }\n elements = Array.from(elements);\n } else if (target instanceof Element) {\n elements = [target];\n } else if (target instanceof NodeList) {\n elements = Array.from(target);\n } else if (Array.isArray(target)) {\n elements = target;\n } else {\n throw new Error('Invalid target: must be selector string, Element, NodeList, or Array');\n }\n\n // Initialize all elements and return array\n const instances = elements.map(element => {\n // Check for existing instance\n if (element.overTypeInstance) {\n // Re-init existing instance\n element.overTypeInstance.reinit(options);\n return element.overTypeInstance;\n }\n\n // Create new instance\n const instance = Object.create(OverType.prototype);\n instance._init(element, options);\n element.overTypeInstance = instance;\n OverType.instances.set(element, instance);\n return instance;\n });\n\n return instances;\n }\n\n /**\n * Internal initialization\n * @private\n */\n _init(element, options = {}) {\n this.element = element;\n \n // Store the original theme option before merging\n this.instanceTheme = options.theme || null;\n \n this.options = this._mergeOptions(options);\n this.instanceId = ++OverType.instanceCount;\n this.initialized = false;\n\n // Inject styles if needed\n OverType.injectStyles();\n\n // Initialize global listeners\n OverType.initGlobalListeners();\n\n // Check for existing OverType DOM structure\n const container = element.querySelector('.overtype-container');\n const wrapper = element.querySelector('.overtype-wrapper');\n if (container || wrapper) {\n this._recoverFromDOM(container, wrapper);\n } else {\n this._buildFromScratch();\n }\n\n if (this.instanceTheme === 'auto') {\n this.setTheme('auto');\n }\n\n // Setup shortcuts manager\n this.shortcuts = new ShortcutsManager(this);\n\n // Build action map from toolbar buttons (works whether or not toolbar UI is shown)\n this._rebuildActionsMap();\n\n // Setup link tooltip\n this.linkTooltip = new LinkTooltip(this);\n\n // Sync scroll positions on initial render\n // This ensures textarea matches preview scroll if page is reloaded while scrolled\n // Double requestAnimationFrame waits for browser to restore scroll position\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n this.textarea.scrollTop = this.preview.scrollTop;\n this.textarea.scrollLeft = this.preview.scrollLeft;\n });\n });\n\n // Mark as initialized\n this.initialized = true;\n\n // Call onChange if provided\n if (this.options.onChange) {\n this.options.onChange(this.getValue(), this);\n }\n }\n\n /**\n * Merge user options with defaults\n * @private\n */\n _mergeOptions(options) {\n const defaults = {\n // Typography\n fontSize: '14px',\n lineHeight: 1.6,\n /* System-first, guaranteed monospaced; avoids Android 'ui-monospace' pitfalls */\n fontFamily: '\"SF Mono\", SFMono-Regular, Menlo, Monaco, \"Cascadia Code\", Consolas, \"Roboto Mono\", \"Noto Sans Mono\", \"Droid Sans Mono\", \"Ubuntu Mono\", \"DejaVu Sans Mono\", \"Liberation Mono\", \"Courier New\", Courier, monospace',\n padding: '16px',\n \n // Mobile styles\n mobile: {\n fontSize: '16px', // Prevent zoom on iOS\n padding: '12px',\n lineHeight: 1.5\n },\n \n // Native textarea properties\n textareaProps: {},\n \n // Behavior\n autofocus: false,\n autoResize: false, // Auto-expand height with content\n minHeight: '100px', // Minimum height for autoResize mode\n maxHeight: null, // Maximum height for autoResize mode (null = unlimited)\n placeholder: 'Start typing...',\n value: '',\n \n // Callbacks\n onChange: null,\n onKeydown: null,\n \n // Features\n showActiveLineRaw: false,\n showStats: false,\n toolbar: false,\n toolbarButtons: null, // Defaults to defaultToolbarButtons if toolbar: true\n statsFormatter: null,\n smartLists: true, // Enable smart list continuation\n codeHighlighter: null, // Per-instance code highlighter\n spellcheck: false // Browser spellcheck (disabled by default)\n };\n \n // Remove theme and colors from options - these are now global\n const { theme, colors, ...cleanOptions } = options;\n \n return {\n ...defaults,\n ...cleanOptions\n };\n }\n\n /**\n * Recover from existing DOM structure\n * @private\n */\n _recoverFromDOM(container, wrapper) {\n // Handle old structure (wrapper only) or new structure (container + wrapper)\n if (container && container.classList.contains('overtype-container')) {\n this.container = container;\n this.wrapper = container.querySelector('.overtype-wrapper');\n } else if (wrapper) {\n // Old structure - just wrapper, no container\n this.wrapper = wrapper;\n // Wrap it in a container for consistency\n this.container = document.createElement('div');\n this.container.className = 'overtype-container';\n // Use instance theme if provided, otherwise use global theme\n const themeToUse = this.instanceTheme || OverType.currentTheme || solar;\n const themeName = typeof themeToUse === 'string' ? themeToUse : themeToUse.name;\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n \n // If using instance theme, apply CSS variables to container\n if (this.instanceTheme) {\n const themeObj = typeof this.instanceTheme === 'string' ? getTheme(this.instanceTheme) : this.instanceTheme;\n if (themeObj && themeObj.colors) {\n const cssVars = themeToCSSVars(themeObj.colors);\n this.container.style.cssText += cssVars;\n }\n }\n wrapper.parentNode.insertBefore(this.container, wrapper);\n this.container.appendChild(wrapper);\n }\n \n if (!this.wrapper) {\n // No valid structure found\n if (container) container.remove();\n if (wrapper) wrapper.remove();\n this._buildFromScratch();\n return;\n }\n \n this.textarea = this.wrapper.querySelector('.overtype-input');\n this.preview = this.wrapper.querySelector('.overtype-preview');\n\n if (!this.textarea || !this.preview) {\n // Partial DOM - clear and rebuild\n this.container.remove();\n this._buildFromScratch();\n return;\n }\n\n // Store reference on wrapper\n this.wrapper._instance = this;\n \n // Apply instance-specific styles via CSS custom properties\n if (this.options.fontSize) {\n this.wrapper.style.setProperty('--instance-font-size', this.options.fontSize);\n }\n if (this.options.lineHeight) {\n this.wrapper.style.setProperty('--instance-line-height', String(this.options.lineHeight));\n }\n if (this.options.padding) {\n this.wrapper.style.setProperty('--instance-padding', this.options.padding);\n }\n\n // Disable autofill, spellcheck, and extensions\n this._configureTextarea();\n\n // Apply any new options\n this._applyOptions();\n }\n\n /**\n * Build editor from scratch\n * @private\n */\n _buildFromScratch() {\n // Extract any existing content\n const content = this._extractContent();\n\n // Clear element\n this.element.innerHTML = '';\n\n // Create DOM structure\n this._createDOM();\n\n // Set initial content\n if (content || this.options.value) {\n this.setValue(content || this.options.value);\n }\n\n // Apply options\n this._applyOptions();\n }\n\n /**\n * Extract content from element\n * @private\n */\n _extractContent() {\n // Look for existing OverType textarea\n const textarea = this.element.querySelector('.overtype-input');\n if (textarea) return textarea.value;\n\n // Use element's text content as fallback\n return this.element.textContent || '';\n }\n\n /**\n * Create DOM structure\n * @private\n */\n _createDOM() {\n // Create container that will hold toolbar and editor\n this.container = document.createElement('div');\n this.container.className = 'overtype-container';\n \n // Set theme on container - use instance theme if provided\n const themeToUse = this.instanceTheme || OverType.currentTheme || solar;\n const themeName = typeof themeToUse === 'string' ? themeToUse : themeToUse.name;\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n \n // If using instance theme, apply CSS variables to container\n if (this.instanceTheme) {\n const themeObj = typeof this.instanceTheme === 'string' ? getTheme(this.instanceTheme) : this.instanceTheme;\n if (themeObj && themeObj.colors) {\n const cssVars = themeToCSSVars(themeObj.colors);\n this.container.style.cssText += cssVars;\n }\n }\n \n // Create wrapper for editor\n this.wrapper = document.createElement('div');\n this.wrapper.className = 'overtype-wrapper';\n \n \n // Apply instance-specific styles via CSS custom properties\n if (this.options.fontSize) {\n this.wrapper.style.setProperty('--instance-font-size', this.options.fontSize);\n }\n if (this.options.lineHeight) {\n this.wrapper.style.setProperty('--instance-line-height', String(this.options.lineHeight));\n }\n if (this.options.padding) {\n this.wrapper.style.setProperty('--instance-padding', this.options.padding);\n }\n \n this.wrapper._instance = this;\n\n // Create textarea\n this.textarea = document.createElement('textarea');\n this.textarea.className = 'overtype-input';\n this.textarea.placeholder = this.options.placeholder;\n this._configureTextarea();\n \n // Apply any native textarea properties\n if (this.options.textareaProps) {\n Object.entries(this.options.textareaProps).forEach(([key, value]) => {\n if (key === 'className' || key === 'class') {\n this.textarea.className += ' ' + value;\n } else if (key === 'style' && typeof value === 'object') {\n Object.assign(this.textarea.style, value);\n } else {\n this.textarea.setAttribute(key, value);\n }\n });\n }\n\n // Create preview div\n this.preview = document.createElement('div');\n this.preview.className = 'overtype-preview';\n this.preview.setAttribute('aria-hidden', 'true');\n\n // Create placeholder shim\n this.placeholderEl = document.createElement('div');\n this.placeholderEl.className = 'overtype-placeholder';\n this.placeholderEl.setAttribute('aria-hidden', 'true');\n this.placeholderEl.textContent = this.options.placeholder;\n\n // Assemble DOM\n this.wrapper.appendChild(this.textarea);\n this.wrapper.appendChild(this.preview);\n this.wrapper.appendChild(this.placeholderEl);\n \n // No need to prevent link clicks - pointer-events handles this\n \n // Add wrapper to container first\n this.container.appendChild(this.wrapper);\n \n // Add stats bar at the end (bottom) if enabled\n if (this.options.showStats) {\n this.statsBar = document.createElement('div');\n this.statsBar.className = 'overtype-stats';\n this.container.appendChild(this.statsBar);\n this._updateStats();\n }\n \n // Add container to element\n this.element.appendChild(this.container);\n \n // Setup auto-resize if enabled\n if (this.options.autoResize) {\n this._setupAutoResize();\n } else {\n // Ensure auto-resize class is removed if not using auto-resize\n this.container.classList.remove('overtype-auto-resize');\n }\n }\n\n /**\n * Configure textarea attributes\n * @private\n */\n _configureTextarea() {\n this.textarea.setAttribute('autocomplete', 'off');\n this.textarea.setAttribute('autocorrect', 'off');\n this.textarea.setAttribute('autocapitalize', 'off');\n this.textarea.setAttribute('spellcheck', String(this.options.spellcheck));\n this.textarea.setAttribute('data-gramm', 'false');\n this.textarea.setAttribute('data-gramm_editor', 'false');\n this.textarea.setAttribute('data-enable-grammarly', 'false');\n }\n\n /**\n * Create and setup toolbar\n * @private\n */\n _createToolbar() {\n let toolbarButtons = this.options.toolbarButtons || defaultToolbarButtons;\n\n if (this.options.fileUpload?.enabled && !toolbarButtons.some(b => b?.name === 'upload')) {\n const viewModeIdx = toolbarButtons.findIndex(b => b?.name === 'viewMode');\n if (viewModeIdx !== -1) {\n toolbarButtons = [...toolbarButtons];\n toolbarButtons.splice(viewModeIdx, 0, builtinToolbarButtons.separator, builtinToolbarButtons.upload);\n } else {\n toolbarButtons = [...toolbarButtons, builtinToolbarButtons.separator, builtinToolbarButtons.upload];\n }\n }\n\n this.toolbar = new Toolbar(this, { toolbarButtons });\n this.toolbar.create();\n\n\n // Store listener references for cleanup\n this._toolbarSelectionListener = () => {\n if (this.toolbar) {\n this.toolbar.updateButtonStates();\n }\n };\n this._toolbarInputListener = () => {\n if (this.toolbar) {\n this.toolbar.updateButtonStates();\n }\n };\n\n // Add listeners\n this.textarea.addEventListener('selectionchange', this._toolbarSelectionListener);\n this.textarea.addEventListener('input', this._toolbarInputListener);\n }\n\n /**\n * Cleanup toolbar event listeners\n * @private\n */\n _cleanupToolbarListeners() {\n if (this._toolbarSelectionListener) {\n this.textarea.removeEventListener('selectionchange', this._toolbarSelectionListener);\n this._toolbarSelectionListener = null;\n }\n if (this._toolbarInputListener) {\n this.textarea.removeEventListener('input', this._toolbarInputListener);\n this._toolbarInputListener = null;\n }\n }\n\n /**\n * Rebuild the action map from current toolbar button configuration\n * Called during init and reinit to keep shortcuts in sync with toolbar buttons\n * @private\n */\n _rebuildActionsMap() {\n // Always start with default actions (shortcuts always work regardless of toolbar config)\n this.actionsById = buildActionsMap(defaultToolbarButtons);\n\n // Overlay custom toolbar actions (can add/override, but never remove core actions)\n if (this.options.toolbarButtons) {\n Object.assign(this.actionsById, buildActionsMap(this.options.toolbarButtons));\n }\n\n // Register upload action when file upload is enabled\n if (this.options.fileUpload?.enabled) {\n Object.assign(this.actionsById, buildActionsMap([builtinToolbarButtons.upload]));\n }\n }\n\n /**\n * Apply options to the editor\n * @private\n */\n _applyOptions() {\n // Apply autofocus\n if (this.options.autofocus) {\n this.textarea.focus();\n }\n\n // Setup or remove auto-resize\n if (this.options.autoResize) {\n if (!this.container.classList.contains('overtype-auto-resize')) {\n this._setupAutoResize();\n } else {\n this._updateAutoHeight();\n }\n } else {\n // Ensure auto-resize class is removed\n this.container.classList.remove('overtype-auto-resize');\n }\n\n // Handle toolbar option changes\n if (this.options.toolbar && !this.toolbar) {\n // Create toolbar if enabled and doesn't exist\n this._createToolbar();\n } else if (!this.options.toolbar && this.toolbar) {\n // Destroy toolbar if disabled and exists\n this._cleanupToolbarListeners();\n this.toolbar.destroy();\n this.toolbar = null;\n }\n\n // Update placeholder text\n if (this.placeholderEl) {\n this.placeholderEl.textContent = this.options.placeholder;\n }\n\n // Setup or remove file upload\n if (this.options.fileUpload && !this.fileUploadInitialized) {\n this._initFileUpload();\n } else if (!this.options.fileUpload && this.fileUploadInitialized) {\n this._destroyFileUpload();\n }\n\n // Update preview with initial content\n this.updatePreview();\n }\n\n _initFileUpload() {\n const options = this.options.fileUpload;\n if (!options || !options.enabled) return;\n\n options.maxSize = options.maxSize || 10 * 1024 * 1024;\n options.mimeTypes = options.mimeTypes || [];\n options.batch = options.batch || false;\n if (!options.onInsertFile || typeof options.onInsertFile !== 'function') {\n console.warn('OverType: fileUpload.onInsertFile callback is required for file uploads.');\n return;\n }\n\n this._fileUploadCounter = 0;\n this._boundHandleFilePaste = this._handleFilePaste.bind(this);\n this._boundHandleFileDrop = this._handleFileDrop.bind(this);\n this._boundHandleDragOver = this._handleDragOver.bind(this);\n\n this.textarea.addEventListener('paste', this._boundHandleFilePaste);\n this.textarea.addEventListener('drop', this._boundHandleFileDrop);\n this.textarea.addEventListener('dragover', this._boundHandleDragOver);\n\n this.fileUploadInitialized = true;\n }\n\n _handleFilePaste(e) {\n if (!e?.clipboardData?.files?.length) return;\n e.preventDefault();\n this._handleDataTransfer(e.clipboardData);\n }\n\n _handleFileDrop(e) {\n if (!e?.dataTransfer?.files?.length) return;\n e.preventDefault();\n this._handleDataTransfer(e.dataTransfer);\n }\n\n _handleDataTransfer(dataTransfer) {\n const files = [];\n for (const file of dataTransfer.files) {\n if (file.size > this.options.fileUpload.maxSize) continue;\n if (this.options.fileUpload.mimeTypes.length > 0\n && !this.options.fileUpload.mimeTypes.includes(file.type)) continue;\n\n const id = ++this._fileUploadCounter;\n const prefix = file.type.startsWith('image/') ? '!' : '';\n const placeholder = `${prefix}[Uploading ${file.name} (#${id})...]()`;\n this.insertAtCursor(`${placeholder}\\n`);\n\n if (this.options.fileUpload.batch) {\n files.push({ file, placeholder });\n continue;\n }\n\n this.options.fileUpload.onInsertFile(file).then((text) => {\n this.textarea.value = this.textarea.value.replace(placeholder, text);\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }, (error) => {\n console.error('OverType: File upload failed', error);\n this.textarea.value = this.textarea.value.replace(placeholder, '[Upload failed]()');\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n });\n }\n\n if (this.options.fileUpload.batch && files.length > 0) {\n this.options.fileUpload.onInsertFile(files.map(f => f.file)).then((result) => {\n const texts = Array.isArray(result) ? result : [result];\n texts.forEach((text, index) => {\n this.textarea.value = this.textarea.value.replace(files[index].placeholder, text);\n });\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }, (error) => {\n console.error('OverType: File upload failed', error);\n files.forEach(({ placeholder }) => {\n this.textarea.value = this.textarea.value.replace(placeholder, '[Upload failed]()');\n });\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n });\n }\n }\n\n _handleDragOver(e) {\n e.preventDefault();\n }\n\n _destroyFileUpload() {\n this.textarea.removeEventListener('paste', this._boundHandleFilePaste);\n this.textarea.removeEventListener('drop', this._boundHandleFileDrop);\n this.textarea.removeEventListener('dragover', this._boundHandleDragOver);\n this._boundHandleFilePaste = null;\n this._boundHandleFileDrop = null;\n this._boundHandleDragOver = null;\n this.fileUploadInitialized = false;\n }\n\n insertAtCursor(text) {\n const start = this.textarea.selectionStart;\n const end = this.textarea.selectionEnd;\n\n let inserted = false;\n try {\n inserted = document.execCommand('insertText', false, text);\n } catch (_) {}\n\n if (!inserted) {\n const before = this.textarea.value.slice(0, start);\n const after = this.textarea.value.slice(end);\n this.textarea.value = before + text + after;\n this.textarea.setSelectionRange(start + text.length, start + text.length);\n }\n\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n\n /**\n * Update preview with parsed markdown\n */\n updatePreview() {\n const text = this.textarea.value;\n const cursorPos = this.textarea.selectionStart;\n const activeLine = this._getCurrentLine(text, cursorPos);\n\n // Detect if we're in preview mode\n const isPreviewMode = this.container.dataset.mode === 'preview';\n\n // Parse markdown\n const html = MarkdownParser.parse(text, activeLine, this.options.showActiveLineRaw, this.options.codeHighlighter, isPreviewMode);\n this.preview.innerHTML = html;\n\n // Show/hide placeholder shim\n if (this.placeholderEl) {\n this.placeholderEl.style.display = text ? 'none' : '';\n }\n \n // Apply code block backgrounds\n this._applyCodeBlockBackgrounds();\n \n // Links always have real hrefs now - no need to update them\n \n // Update stats if enabled\n if (this.options.showStats && this.statsBar) {\n this._updateStats();\n }\n \n // Trigger onChange callback\n if (this.options.onChange && this.initialized) {\n this.options.onChange(text, this);\n }\n }\n\n /**\n * Apply background styling to code blocks\n * @private\n */\n _applyCodeBlockBackgrounds() {\n // Find all code fence elements\n const codeFences = this.preview.querySelectorAll('.code-fence');\n \n // Process pairs of code fences\n for (let i = 0; i < codeFences.length - 1; i += 2) {\n const openFence = codeFences[i];\n const closeFence = codeFences[i + 1];\n \n // Get parent divs\n const openParent = openFence.parentElement;\n const closeParent = closeFence.parentElement;\n \n if (!openParent || !closeParent) continue;\n \n // Make fences display: block\n openFence.style.display = 'block';\n closeFence.style.display = 'block';\n \n // Apply class to parent divs\n openParent.classList.add('code-block-line');\n closeParent.classList.add('code-block-line');\n \n // With the new structure, there's a <pre> block between fences, not DIVs\n // We don't need to process anything between the fences anymore\n // The <pre><code> structure already handles the content correctly\n }\n }\n\n /**\n * Get current line number from cursor position\n * @private\n */\n _getCurrentLine(text, cursorPos) {\n const lines = text.substring(0, cursorPos).split('\\n');\n return lines.length - 1;\n }\n\n /**\n * Handle input events\n * @private\n */\n handleInput(event) {\n this.updatePreview();\n }\n\n /**\n * Handle keydown events\n * @private\n */\n handleKeydown(event) {\n // Handle Tab key to prevent focus loss and insert spaces\n if (event.key === 'Tab') {\n const start = this.textarea.selectionStart;\n const end = this.textarea.selectionEnd;\n const value = this.textarea.value;\n\n // If Shift+Tab without a selection, allow default behavior (navigate to previous element)\n if (event.shiftKey && start === end) {\n return;\n }\n\n event.preventDefault();\n\n // If there's a selection, indent/outdent based on shift key\n if (start !== end && event.shiftKey) {\n // Outdent: remove 2 spaces from start of each selected line\n const before = value.substring(0, start);\n const selection = value.substring(start, end);\n const after = value.substring(end);\n \n const lines = selection.split('\\n');\n const outdented = lines.map(line => line.replace(/^ /, '')).join('\\n');\n \n // Try to use execCommand first to preserve undo history\n if (document.execCommand) {\n // Select the text that needs to be replaced\n this.textarea.setSelectionRange(start, end);\n document.execCommand('insertText', false, outdented);\n } else {\n // Fallback to direct manipulation\n this.textarea.value = before + outdented + after;\n this.textarea.selectionStart = start;\n this.textarea.selectionEnd = start + outdented.length;\n }\n } else if (start !== end) {\n // Indent: add 2 spaces to start of each selected line\n const before = value.substring(0, start);\n const selection = value.substring(start, end);\n const after = value.substring(end);\n \n const lines = selection.split('\\n');\n const indented = lines.map(line => ' ' + line).join('\\n');\n \n // Try to use execCommand first to preserve undo history\n if (document.execCommand) {\n // Select the text that needs to be replaced\n this.textarea.setSelectionRange(start, end);\n document.execCommand('insertText', false, indented);\n } else {\n // Fallback to direct manipulation\n this.textarea.value = before + indented + after;\n this.textarea.selectionStart = start;\n this.textarea.selectionEnd = start + indented.length;\n }\n } else {\n // No selection: just insert 2 spaces\n // Use execCommand to preserve undo history\n if (document.execCommand) {\n document.execCommand('insertText', false, ' ');\n } else {\n // Fallback to direct manipulation\n this.textarea.value = value.substring(0, start) + ' ' + value.substring(end);\n this.textarea.selectionStart = this.textarea.selectionEnd = start + 2;\n }\n }\n \n // Trigger input event to update preview\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n return;\n }\n \n // Handle Enter key for smart list continuation\n if (event.key === 'Enter' && !event.shiftKey && !event.metaKey && !event.ctrlKey && this.options.smartLists) {\n if (this.handleSmartListContinuation()) {\n event.preventDefault();\n return;\n }\n }\n \n // Let shortcuts manager handle other keys\n const handled = this.shortcuts.handleKeydown(event);\n \n // Call user callback if provided\n if (!handled && this.options.onKeydown) {\n this.options.onKeydown(event, this);\n }\n }\n\n /**\n * Handle smart list continuation\n * @returns {boolean} Whether the event was handled\n */\n handleSmartListContinuation() {\n const textarea = this.textarea;\n const cursorPos = textarea.selectionStart;\n const context = MarkdownParser.getListContext(textarea.value, cursorPos);\n \n if (!context || !context.inList) return false;\n \n // Handle empty list item (exit list)\n if (context.content.trim() === '' && cursorPos >= context.markerEndPos) {\n this.deleteListMarker(context);\n return true;\n }\n \n // Handle text splitting if cursor is in middle of content\n if (cursorPos > context.markerEndPos && cursorPos < context.lineEnd) {\n this.splitListItem(context, cursorPos);\n } else {\n // Just add new item after current line\n this.insertNewListItem(context);\n }\n \n // Handle numbered list renumbering\n if (context.listType === 'numbered') {\n this.scheduleNumberedListUpdate();\n }\n \n return true;\n }\n \n /**\n * Delete list marker and exit list\n * @private\n */\n deleteListMarker(context) {\n // Select from line start to marker end\n this.textarea.setSelectionRange(context.lineStart, context.markerEndPos);\n document.execCommand('delete');\n \n // Trigger input event\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n \n /**\n * Insert new list item\n * @private\n */\n insertNewListItem(context) {\n const newItem = MarkdownParser.createNewListItem(context);\n document.execCommand('insertText', false, '\\n' + newItem);\n \n // Trigger input event\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n \n /**\n * Split list item at cursor position\n * @private\n */\n splitListItem(context, cursorPos) {\n // Get text after cursor\n const textAfterCursor = context.content.substring(cursorPos - context.markerEndPos);\n \n // Delete text after cursor\n this.textarea.setSelectionRange(cursorPos, context.lineEnd);\n document.execCommand('delete');\n \n // Insert new list item with remaining text\n const newItem = MarkdownParser.createNewListItem(context);\n document.execCommand('insertText', false, '\\n' + newItem + textAfterCursor);\n \n // Position cursor after new list marker\n const newCursorPos = this.textarea.selectionStart - textAfterCursor.length;\n this.textarea.setSelectionRange(newCursorPos, newCursorPos);\n \n // Trigger input event\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n \n /**\n * Schedule numbered list renumbering\n * @private\n */\n scheduleNumberedListUpdate() {\n // Clear any pending update\n if (this.numberUpdateTimeout) {\n clearTimeout(this.numberUpdateTimeout);\n }\n \n // Schedule update after current input cycle\n this.numberUpdateTimeout = setTimeout(() => {\n this.updateNumberedLists();\n }, 10);\n }\n \n /**\n * Update/renumber all numbered lists\n * @private\n */\n updateNumberedLists() {\n const value = this.textarea.value;\n const cursorPos = this.textarea.selectionStart;\n \n const newValue = MarkdownParser.renumberLists(value);\n \n if (newValue !== value) {\n // Calculate cursor offset\n let offset = 0;\n const oldLines = value.split('\\n');\n const newLines = newValue.split('\\n');\n let charCount = 0;\n \n for (let i = 0; i < oldLines.length && charCount < cursorPos; i++) {\n if (oldLines[i] !== newLines[i]) {\n const diff = newLines[i].length - oldLines[i].length;\n if (charCount + oldLines[i].length < cursorPos) {\n offset += diff;\n }\n }\n charCount += oldLines[i].length + 1; // +1 for newline\n }\n \n // Update textarea\n this.textarea.value = newValue;\n const newCursorPos = cursorPos + offset;\n this.textarea.setSelectionRange(newCursorPos, newCursorPos);\n \n // Trigger update\n this.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n\n /**\n * Handle scroll events\n * @private\n */\n handleScroll(event) {\n // Sync preview scroll with textarea\n this.preview.scrollTop = this.textarea.scrollTop;\n this.preview.scrollLeft = this.textarea.scrollLeft;\n }\n\n /**\n * Get editor content\n * @returns {string} Current markdown content\n */\n getValue() {\n return this.textarea.value;\n }\n\n /**\n * Set editor content\n * @param {string} value - Markdown content to set\n */\n setValue(value) {\n this.textarea.value = value;\n this.updatePreview();\n\n // Update height if auto-resize is enabled\n if (this.options.autoResize) {\n this._updateAutoHeight();\n }\n }\n\n /**\n * Execute an action by ID\n * Central dispatcher used by toolbar clicks, keyboard shortcuts, and programmatic calls\n * @param {string} actionId - The action identifier (e.g., 'toggleBold', 'insertLink')\n * @param {Event|null} event - Optional event that triggered the action\n * @returns {Promise<boolean>} Whether the action was executed successfully\n */\n async performAction(actionId, event = null) {\n const textarea = this.textarea;\n if (!textarea) return false;\n\n const action = this.actionsById?.[actionId];\n if (!action) {\n console.warn(`OverType: Unknown action \"${actionId}\"`);\n return false;\n }\n\n textarea.focus();\n\n try {\n await action({\n editor: this,\n getValue: () => this.getValue(),\n setValue: (value) => this.setValue(value),\n event\n });\n // Note: actions are responsible for dispatching input event\n // This preserves behavior for direct consumers of toolbarButtons.*.action\n return true;\n } catch (error) {\n console.error(`OverType: Action \"${actionId}\" error:`, error);\n this.wrapper.dispatchEvent(new CustomEvent('button-error', {\n detail: { actionId, error }\n }));\n return false;\n }\n }\n\n /**\n * Get the rendered HTML of the current content\n * @param {Object} options - Rendering options\n * @param {boolean} options.cleanHTML - If true, removes syntax markers and OverType-specific classes\n * @returns {string} Rendered HTML\n */\n getRenderedHTML(options = {}) {\n const markdown = this.getValue();\n let html = MarkdownParser.parse(markdown, -1, false, this.options.codeHighlighter);\n\n if (options.cleanHTML) {\n // Remove all syntax marker spans for clean HTML export\n html = html.replace(/<span class=\"syntax-marker[^\"]*\">.*?<\\/span>/g, '');\n // Remove OverType-specific classes\n html = html.replace(/\\sclass=\"(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)\"/g, '');\n // Clean up empty class attributes\n html = html.replace(/\\sclass=\"\"/g, '');\n }\n \n return html;\n }\n\n /**\n * Get the current preview element's HTML\n * This includes all syntax markers and OverType styling\n * @returns {string} Current preview HTML (as displayed)\n */\n getPreviewHTML() {\n return this.preview.innerHTML;\n }\n \n /**\n * Get clean HTML without any OverType-specific markup\n * Useful for exporting to other formats or storage\n * @returns {string} Clean HTML suitable for export\n */\n getCleanHTML() {\n return this.getRenderedHTML({ cleanHTML: true });\n }\n\n /**\n * Focus the editor\n */\n focus() {\n this.textarea.focus();\n }\n\n /**\n * Blur the editor\n */\n blur() {\n this.textarea.blur();\n }\n\n /**\n * Check if editor is initialized\n * @returns {boolean}\n */\n isInitialized() {\n return this.initialized;\n }\n\n /**\n * Re-initialize with new options\n * @param {Object} options - New options to apply\n */\n reinit(options = {}) {\n const prevToolbarButtons = this.options?.toolbarButtons;\n this.options = this._mergeOptions({ ...this.options, ...options });\n const toolbarNeedsRebuild = this.toolbar &&\n this.options.toolbar &&\n toolbarButtonsChanged(prevToolbarButtons, this.options.toolbarButtons);\n\n // Rebuild action map in case toolbarButtons changed\n this._rebuildActionsMap();\n\n if (toolbarNeedsRebuild) {\n this._cleanupToolbarListeners();\n this.toolbar.destroy();\n this.toolbar = null;\n this._createToolbar();\n }\n\n if (this.fileUploadInitialized) {\n this._destroyFileUpload();\n }\n if (this.options.fileUpload) {\n this._initFileUpload();\n }\n\n this._applyOptions();\n this.updatePreview();\n }\n\n showToolbar() {\n if (this.toolbar) {\n this.toolbar.show();\n } else {\n this._createToolbar();\n }\n }\n\n hideToolbar() {\n if (this.toolbar) {\n this.toolbar.hide();\n }\n }\n\n /**\n * Set theme for this instance\n * @param {string|Object} theme - Theme name or custom theme object\n * @returns {this} Returns this for chaining\n */\n setTheme(theme) {\n OverType._autoInstances.delete(this);\n this.instanceTheme = theme;\n\n if (theme === 'auto') {\n OverType._autoInstances.add(this);\n OverType._startAutoListener();\n this._applyResolvedTheme(resolveAutoTheme('auto'));\n } else {\n const themeObj = typeof theme === 'string' ? getTheme(theme) : theme;\n const themeName = typeof themeObj === 'string' ? themeObj : themeObj.name;\n\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n\n if (themeObj && themeObj.colors) {\n const cssVars = themeToCSSVars(themeObj.colors, themeObj.previewColors);\n this.container.style.cssText += cssVars;\n }\n\n this.updatePreview();\n }\n\n OverType._stopAutoListener();\n return this;\n }\n\n _applyResolvedTheme(themeName) {\n const themeObj = getTheme(themeName);\n this.container.setAttribute('data-theme', themeName);\n\n if (themeObj && themeObj.colors) {\n this.container.style.cssText = themeToCSSVars(themeObj.colors, themeObj.previewColors);\n }\n\n this.updatePreview();\n }\n\n /**\n * Set instance-specific code highlighter\n * @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML\n */\n setCodeHighlighter(highlighter) {\n this.options.codeHighlighter = highlighter;\n this.updatePreview();\n }\n\n /**\n * Update stats bar\n * @private\n */\n _updateStats() {\n if (!this.statsBar) return;\n \n const value = this.textarea.value;\n const lines = value.split('\\n');\n const chars = value.length;\n const words = value.split(/\\s+/).filter(w => w.length > 0).length;\n \n // Calculate line and column\n const selectionStart = this.textarea.selectionStart;\n const beforeCursor = value.substring(0, selectionStart);\n const linesBeforeCursor = beforeCursor.split('\\n');\n const currentLine = linesBeforeCursor.length;\n const currentColumn = linesBeforeCursor[linesBeforeCursor.length - 1].length + 1;\n \n // Use custom formatter if provided\n if (this.options.statsFormatter) {\n this.statsBar.innerHTML = this.options.statsFormatter({\n chars,\n words,\n lines: lines.length,\n line: currentLine,\n column: currentColumn\n });\n } else {\n // Default format with live dot\n this.statsBar.innerHTML = `\n <div class=\"overtype-stat\">\n <span class=\"live-dot\"></span>\n <span>${chars} chars, ${words} words, ${lines.length} lines</span>\n </div>\n <div class=\"overtype-stat\">Line ${currentLine}, Col ${currentColumn}</div>\n `;\n }\n }\n \n /**\n * Setup auto-resize functionality\n * @private\n */\n _setupAutoResize() {\n // Add auto-resize class for styling\n this.container.classList.add('overtype-auto-resize');\n \n // Store previous height for comparison\n this.previousHeight = null;\n \n // Initial height update\n this._updateAutoHeight();\n \n // Listen for input events\n this.textarea.addEventListener('input', () => this._updateAutoHeight());\n \n // Listen for window resize\n window.addEventListener('resize', () => this._updateAutoHeight());\n }\n \n /**\n * Update height based on scrollHeight\n * @private\n */\n _updateAutoHeight() {\n if (!this.options.autoResize) return;\n \n const textarea = this.textarea;\n const preview = this.preview;\n const wrapper = this.wrapper;\n \n // Get computed styles\n const computed = window.getComputedStyle(textarea);\n const paddingTop = parseFloat(computed.paddingTop);\n const paddingBottom = parseFloat(computed.paddingBottom);\n \n // Store scroll positions\n const scrollTop = textarea.scrollTop;\n \n // Reset height to get accurate scrollHeight\n textarea.style.setProperty('height', 'auto', 'important');\n \n // Calculate new height based on scrollHeight\n let newHeight = textarea.scrollHeight;\n \n // Apply min height constraint\n if (this.options.minHeight) {\n const minHeight = parseInt(this.options.minHeight);\n newHeight = Math.max(newHeight, minHeight);\n }\n \n // Apply max height constraint\n let overflow = 'hidden';\n if (this.options.maxHeight) {\n const maxHeight = parseInt(this.options.maxHeight);\n if (newHeight > maxHeight) {\n newHeight = maxHeight;\n overflow = 'auto';\n }\n }\n \n // Apply the new height to all elements with !important to override base styles\n const heightPx = newHeight + 'px';\n textarea.style.setProperty('height', heightPx, 'important');\n textarea.style.setProperty('overflow-y', overflow, 'important');\n \n preview.style.setProperty('height', heightPx, 'important');\n preview.style.setProperty('overflow-y', overflow, 'important');\n \n wrapper.style.setProperty('height', heightPx, 'important');\n \n // Restore scroll position\n textarea.scrollTop = scrollTop;\n preview.scrollTop = scrollTop;\n \n // Track if height changed\n if (this.previousHeight !== newHeight) {\n this.previousHeight = newHeight;\n // Could dispatch a custom event here if needed\n }\n }\n \n /**\n * Show or hide stats bar\n * @param {boolean} show - Whether to show stats\n */\n showStats(show) {\n this.options.showStats = show;\n\n if (show && !this.statsBar) {\n // Create stats bar (add to container, not wrapper)\n this.statsBar = document.createElement('div');\n this.statsBar.className = 'overtype-stats';\n this.container.appendChild(this.statsBar);\n this._updateStats();\n } else if (show && this.statsBar) {\n // Already visible - refresh stats (useful after changing statsFormatter)\n this._updateStats();\n } else if (!show && this.statsBar) {\n // Remove stats bar\n this.statsBar.remove();\n this.statsBar = null;\n }\n }\n \n /**\n * Show normal edit mode (overlay with markdown preview)\n * @returns {this} Returns this for chaining\n */\n showNormalEditMode() {\n this.container.dataset.mode = 'normal';\n this.updatePreview(); // Re-render with normal mode (e.g., show syntax markers)\n\n // Always sync scroll from preview to textarea\n requestAnimationFrame(() => {\n this.textarea.scrollTop = this.preview.scrollTop;\n this.textarea.scrollLeft = this.preview.scrollLeft;\n });\n\n return this;\n }\n\n /**\n * Show plain textarea mode (no overlay)\n * @returns {this} Returns this for chaining\n */\n showPlainTextarea() {\n this.container.dataset.mode = 'plain';\n\n // Update toolbar button if exists\n if (this.toolbar) {\n const toggleBtn = this.container.querySelector('[data-action=\"toggle-plain\"]');\n if (toggleBtn) {\n toggleBtn.classList.remove('active');\n toggleBtn.title = 'Show markdown preview';\n }\n }\n\n return this;\n }\n\n /**\n * Show preview mode (read-only view)\n * @returns {this} Returns this for chaining\n */\n showPreviewMode() {\n this.container.dataset.mode = 'preview';\n this.updatePreview(); // Re-render with preview mode (e.g., checkboxes)\n return this;\n }\n\n /**\n * Destroy the editor instance\n */\n destroy() {\n OverType._autoInstances.delete(this);\n OverType._stopAutoListener();\n\n if (this.fileUploadInitialized) {\n this._destroyFileUpload();\n }\n\n // Remove instance reference\n this.element.overTypeInstance = null;\n OverType.instances.delete(this.element);\n\n // Cleanup shortcuts\n if (this.shortcuts) {\n this.shortcuts.destroy();\n }\n\n // Remove DOM if created by us\n if (this.wrapper) {\n const content = this.getValue();\n this.wrapper.remove();\n \n // Restore original content\n this.element.textContent = content;\n }\n\n this.initialized = false;\n }\n\n // ===== Static Methods =====\n\n /**\n * Initialize multiple editors (static convenience method)\n * @param {string|Element|NodeList|Array} target - Target element(s)\n * @param {Object} options - Configuration options\n * @returns {Array} Array of OverType instances\n */\n static init(target, options = {}) {\n return new OverType(target, options);\n }\n\n /**\n * Initialize editors with options from data-ot-* attributes\n * @param {string} selector - CSS selector for target elements\n * @param {Object} defaults - Default options (data attrs override these)\n * @returns {Array<OverType>} Array of OverType instances\n * @example\n * // HTML: <div class=\"editor\" data-ot-toolbar=\"true\" data-ot-theme=\"cave\"></div>\n * OverType.initFromData('.editor', { fontSize: '14px' });\n */\n static initFromData(selector, defaults = {}) {\n const elements = document.querySelectorAll(selector);\n return Array.from(elements).map(el => {\n const options = { ...defaults };\n\n // Parse data-ot-* attributes (kebab-case to camelCase)\n for (const attr of el.attributes) {\n if (attr.name.startsWith('data-ot-')) {\n const kebab = attr.name.slice(8); // Remove 'data-ot-'\n const key = kebab.replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n options[key] = OverType._parseDataValue(attr.value);\n }\n }\n\n return new OverType(el, options)[0];\n });\n }\n\n /**\n * Parse a data attribute value to the appropriate type\n * @private\n */\n static _parseDataValue(value) {\n if (value === 'true') return true;\n if (value === 'false') return false;\n if (value === 'null') return null;\n if (value !== '' && !isNaN(Number(value))) return Number(value);\n return value;\n }\n\n /**\n * Get instance from element\n * @param {Element} element - DOM element\n * @returns {OverType|null} OverType instance or null\n */\n static getInstance(element) {\n return element.overTypeInstance || OverType.instances.get(element) || null;\n }\n\n /**\n * Destroy all instances\n */\n static destroyAll() {\n const elements = document.querySelectorAll('[data-overtype-instance]');\n elements.forEach(element => {\n const instance = OverType.getInstance(element);\n if (instance) {\n instance.destroy();\n }\n });\n }\n\n /**\n * Inject styles into the document\n * @param {boolean} force - Force re-injection\n */\n static injectStyles(force = false) {\n if (OverType.stylesInjected && !force) return;\n\n // Remove any existing OverType styles\n const existing = document.querySelector('style.overtype-styles');\n if (existing) {\n existing.remove();\n }\n\n // Generate and inject new styles with current theme\n const theme = OverType.currentTheme || solar;\n const styles = generateStyles({ theme });\n const styleEl = document.createElement('style');\n styleEl.className = 'overtype-styles';\n styleEl.textContent = styles;\n document.head.appendChild(styleEl);\n\n OverType.stylesInjected = true;\n }\n \n /**\n * Set global theme for all OverType instances\n * @param {string|Object} theme - Theme name or custom theme object\n * @param {Object} customColors - Optional color overrides\n */\n static setTheme(theme, customColors = null) {\n OverType._globalAutoTheme = false;\n OverType._globalAutoCustomColors = null;\n\n if (theme === 'auto') {\n OverType._globalAutoTheme = true;\n OverType._globalAutoCustomColors = customColors;\n OverType._startAutoListener();\n OverType._applyGlobalTheme(resolveAutoTheme('auto'), customColors);\n return;\n }\n\n OverType._stopAutoListener();\n OverType._applyGlobalTheme(theme, customColors);\n }\n\n static _applyGlobalTheme(theme, customColors = null) {\n let themeObj = typeof theme === 'string' ? getTheme(theme) : theme;\n\n if (customColors) {\n themeObj = mergeTheme(themeObj, customColors);\n }\n\n OverType.currentTheme = themeObj;\n OverType.injectStyles(true);\n\n const themeName = typeof themeObj === 'string' ? themeObj : themeObj.name;\n\n document.querySelectorAll('.overtype-container').forEach(container => {\n if (themeName) {\n container.setAttribute('data-theme', themeName);\n }\n });\n\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n if (!wrapper.closest('.overtype-container')) {\n if (themeName) {\n wrapper.setAttribute('data-theme', themeName);\n }\n }\n\n const instance = wrapper._instance;\n if (instance) {\n instance.updatePreview();\n }\n });\n\n document.querySelectorAll('overtype-editor').forEach(webComponent => {\n if (themeName && typeof webComponent.setAttribute === 'function') {\n webComponent.setAttribute('theme', themeName);\n }\n if (typeof webComponent.refreshTheme === 'function') {\n webComponent.refreshTheme();\n }\n });\n }\n\n static _startAutoListener() {\n if (OverType._autoMediaQuery) return;\n if (!window.matchMedia) return;\n\n OverType._autoMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n OverType._autoMediaListener = (e) => {\n const resolved = e.matches ? 'cave' : 'solar';\n\n if (OverType._globalAutoTheme) {\n OverType._applyGlobalTheme(resolved, OverType._globalAutoCustomColors);\n }\n\n OverType._autoInstances.forEach(inst => inst._applyResolvedTheme(resolved));\n };\n\n OverType._autoMediaQuery.addEventListener('change', OverType._autoMediaListener);\n }\n\n static _stopAutoListener() {\n if (OverType._autoInstances.size > 0 || OverType._globalAutoTheme) return;\n if (!OverType._autoMediaQuery) return;\n\n OverType._autoMediaQuery.removeEventListener('change', OverType._autoMediaListener);\n OverType._autoMediaQuery = null;\n OverType._autoMediaListener = null;\n }\n\n /**\n * Set global code highlighter for all OverType instances\n * @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML\n */\n static setCodeHighlighter(highlighter) {\n MarkdownParser.setCodeHighlighter(highlighter);\n\n // Update all existing instances in light DOM\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n const instance = wrapper._instance;\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n });\n\n // Update web components (shadow DOM instances)\n document.querySelectorAll('overtype-editor').forEach(webComponent => {\n if (typeof webComponent.getEditor === 'function') {\n const instance = webComponent.getEditor();\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n }\n });\n }\n\n /**\n * Set custom syntax processor for extending markdown parsing\n * @param {Function|null} processor - Function that takes (html) and returns modified HTML\n * @example\n * OverType.setCustomSyntax((html) => {\n * // Highlight footnote references [^1]\n * return html.replace(/\\[\\^(\\w+)\\]/g, '<span class=\"footnote-ref\">$&</span>');\n * });\n */\n static setCustomSyntax(processor) {\n MarkdownParser.setCustomSyntax(processor);\n\n // Update all existing instances\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n const instance = wrapper._instance;\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n });\n\n document.querySelectorAll('overtype-editor').forEach(webComponent => {\n if (typeof webComponent.getEditor === 'function') {\n const instance = webComponent.getEditor();\n if (instance && instance.updatePreview) {\n instance.updatePreview();\n }\n }\n });\n }\n\n /**\n * Initialize global event listeners\n */\n static initGlobalListeners() {\n if (OverType.globalListenersInitialized) return;\n\n // Input event\n document.addEventListener('input', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleInput(e);\n }\n });\n\n // Keydown event\n document.addEventListener('keydown', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleKeydown(e);\n }\n });\n\n // Scroll event\n document.addEventListener('scroll', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleScroll(e);\n }\n }, true);\n\n // Selection change event\n document.addEventListener('selectionchange', (e) => {\n const activeElement = document.activeElement;\n if (activeElement && activeElement.classList.contains('overtype-input')) {\n const wrapper = activeElement.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) {\n // Update stats bar for cursor position\n if (instance.options.showStats && instance.statsBar) {\n instance._updateStats();\n }\n // Debounce updates\n clearTimeout(instance._selectionTimeout);\n instance._selectionTimeout = setTimeout(() => {\n instance.updatePreview();\n }, 50);\n }\n }\n });\n\n OverType.globalListenersInitialized = true;\n }\n}\n\n// Export classes for advanced usage\nOverType.MarkdownParser = MarkdownParser;\nOverType.ShortcutsManager = ShortcutsManager;\n\n// Export theme utilities\nOverType.themes = { solar, cave: getTheme('cave') };\nOverType.getTheme = getTheme;\n\n// Set default theme\nOverType.currentTheme = solar;\n\n// Export for module systems\nexport default OverType;\nexport { OverType };\n\n// Export toolbar buttons for custom toolbar configurations\nexport { toolbarButtons, defaultToolbarButtons } from './toolbar-buttons.js';\n", "/**\n * MarkdownParser - Parses markdown into HTML while preserving character alignment\n *\n * Key principles:\n * - Every character must occupy the exact same position as in the textarea\n * - No font-size changes, no padding/margin on inline elements\n * - Markdown tokens remain visible but styled\n */\nexport class MarkdownParser {\n // Track link index for anchor naming\n static linkIndex = 0;\n\n // Global code highlighter function\n static codeHighlighter = null;\n\n // Custom syntax processor function\n static customSyntax = null;\n\n /**\n * Reset link index (call before parsing a new document)\n */\n static resetLinkIndex() {\n this.linkIndex = 0;\n }\n\n /**\n * Set global code highlighter function\n * @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML\n */\n static setCodeHighlighter(highlighter) {\n this.codeHighlighter = highlighter;\n }\n\n /**\n * Set custom syntax processor function\n * @param {Function|null} processor - Function that takes (html) and returns modified HTML\n */\n static setCustomSyntax(processor) {\n this.customSyntax = processor;\n }\n\n /**\n * Apply custom syntax processor to parsed HTML\n * @param {string} html - Parsed HTML line\n * @returns {string} HTML with custom syntax applied\n */\n static applyCustomSyntax(html) {\n if (this.customSyntax) {\n return this.customSyntax(html);\n }\n return html;\n }\n\n /**\n * Escape HTML special characters\n * @param {string} text - Raw text to escape\n * @returns {string} Escaped HTML-safe text\n */\n static escapeHtml(text) {\n const map = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;'\n };\n return text.replace(/[&<>\"']/g, m => map[m]);\n }\n\n /**\n * Preserve leading spaces as non-breaking spaces\n * @param {string} html - HTML string\n * @param {string} originalLine - Original line with spaces\n * @returns {string} HTML with preserved indentation\n */\n static preserveIndentation(html, originalLine) {\n const leadingSpaces = originalLine.match(/^(\\s*)/)[1];\n const indentation = leadingSpaces.replace(/ /g, '&nbsp;');\n return html.replace(/^\\s*/, indentation);\n }\n\n /**\n * Parse headers (h1-h3 only)\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed HTML with header styling\n */\n static parseHeader(html) {\n return html.replace(/^(#{1,3})\\s(.+)$/, (match, hashes, content) => {\n const level = hashes.length;\n content = this.parseInlineElements(content);\n return `<h${level}><span class=\"syntax-marker\">${hashes} </span>${content}</h${level}>`;\n });\n }\n\n /**\n * Parse horizontal rules\n * @param {string} html - HTML line to parse\n * @returns {string|null} Parsed horizontal rule or null\n */\n static parseHorizontalRule(html) {\n if (html.match(/^(-{3,}|\\*{3,}|_{3,})$/)) {\n return `<div><span class=\"hr-marker\">${html}</span></div>`;\n }\n return null;\n }\n\n /**\n * Parse blockquotes\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed blockquote\n */\n static parseBlockquote(html) {\n return html.replace(/^&gt; (.+)$/, (match, content) => {\n return `<span class=\"blockquote\"><span class=\"syntax-marker\">&gt;</span> ${content}</span>`;\n });\n }\n\n /**\n * Parse bullet lists\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed bullet list item\n */\n static parseBulletList(html) {\n return html.replace(/^((?:&nbsp;)*)([-*+])\\s(.+)$/, (match, indent, marker, content) => {\n content = this.parseInlineElements(content);\n return `${indent}<li class=\"bullet-list\"><span class=\"syntax-marker\">${marker} </span>${content}</li>`;\n });\n }\n\n /**\n * Parse task lists (GitHub Flavored Markdown checkboxes)\n * @param {string} html - HTML line to parse\n * @param {boolean} isPreviewMode - Whether to render actual checkboxes (preview) or keep syntax visible (normal)\n * @returns {string} Parsed task list item\n */\n static parseTaskList(html, isPreviewMode = false) {\n return html.replace(/^((?:&nbsp;)*)-\\s+\\[([ xX])\\]\\s+(.+)$/, (match, indent, checked, content) => {\n content = this.parseInlineElements(content);\n if (isPreviewMode) {\n // Preview mode: render actual checkbox\n const isChecked = checked.toLowerCase() === 'x';\n return `${indent}<li class=\"task-list\"><input type=\"checkbox\" ${isChecked ? 'checked' : ''}> ${content}</li>`;\n } else {\n // Normal mode: keep syntax visible for alignment\n return `${indent}<li class=\"task-list\"><span class=\"syntax-marker\">- [${checked}] </span>${content}</li>`;\n }\n });\n }\n\n /**\n * Parse numbered lists\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed numbered list item\n */\n static parseNumberedList(html) {\n return html.replace(/^((?:&nbsp;)*)(\\d+\\.)\\s(.+)$/, (match, indent, marker, content) => {\n content = this.parseInlineElements(content);\n return `${indent}<li class=\"ordered-list\"><span class=\"syntax-marker\">${marker} </span>${content}</li>`;\n });\n }\n\n /**\n * Parse code blocks (markers only)\n * @param {string} html - HTML line to parse\n * @returns {string|null} Parsed code fence or null\n */\n static parseCodeBlock(html) {\n // The line must start with three backticks and have no backticks after subsequent text\n const codeFenceRegex = /^`{3}[^`]*$/;\n if (codeFenceRegex.test(html)) {\n return `<div><span class=\"code-fence\">${html}</span></div>`;\n }\n return null;\n }\n\n /**\n * Parse bold text\n * @param {string} html - HTML with potential bold markdown\n * @returns {string} HTML with bold styling\n */\n static parseBold(html) {\n html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong><span class=\"syntax-marker\">**</span>$1<span class=\"syntax-marker\">**</span></strong>');\n html = html.replace(/__(.+?)__/g, '<strong><span class=\"syntax-marker\">__</span>$1<span class=\"syntax-marker\">__</span></strong>');\n return html;\n }\n\n /**\n * Parse italic text\n * Note: Uses lookbehind assertions - requires modern browsers\n * @param {string} html - HTML with potential italic markdown\n * @returns {string} HTML with italic styling\n */\n static parseItalic(html) {\n // Single asterisk - must not be adjacent to other asterisks\n // Must not be inside a syntax-marker span (avoid matching bullet list markers like \">* \")\n html = html.replace(/(?<![\\*>])\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)/g, '<em><span class=\"syntax-marker\">*</span>$1<span class=\"syntax-marker\">*</span></em>');\n\n // Single underscore - must be at word boundaries to avoid matching inside words\n // This prevents matching underscores in the middle of words like \"bold_with_underscore\"\n html = html.replace(/(?<=^|\\s)_(?!_)(.+?)(?<!_)_(?!_)(?=\\s|$)/g, '<em><span class=\"syntax-marker\">_</span>$1<span class=\"syntax-marker\">_</span></em>');\n\n return html;\n }\n\n /**\n * Parse strikethrough text\n * Supports both single (~) and double (~~) tildes, but rejects 3+ tildes\n * @param {string} html - HTML with potential strikethrough markdown\n * @returns {string} HTML with strikethrough styling\n */\n static parseStrikethrough(html) {\n // Double tilde strikethrough: ~~text~~ (but not if part of 3+ tildes)\n html = html.replace(/(?<!~)~~(?!~)(.+?)(?<!~)~~(?!~)/g, '<del><span class=\"syntax-marker\">~~</span>$1<span class=\"syntax-marker\">~~</span></del>');\n // Single tilde strikethrough: ~text~ (but not if part of 2+ tildes on either side)\n html = html.replace(/(?<!~)~(?!~)(.+?)(?<!~)~(?!~)/g, '<del><span class=\"syntax-marker\">~</span>$1<span class=\"syntax-marker\">~</span></del>');\n return html;\n }\n\n /**\n * Parse inline code\n * @param {string} html - HTML with potential code markdown\n * @returns {string} HTML with code styling\n */\n static parseInlineCode(html) {\n // Must have equal number of backticks before and after inline code\n //\n // Regex explainer:\n // (?<!`): A negative lookbehind ensuring the opening backticks are not preceded by another backtick.\n // (`+): A capturing group that matches and remembers the opening sequence of one or more backticks. This is Group 1.\n // ((?:(?!\\1).)+?): A capturing group that greedily matches any character that is not the exact sequence of backticks captured in Group 1. This is Group 2.\n // (\\1): A backreference to Group 1, ensuring the closing sequence has the exact same number of backticks as the opening sequence. This is Group 3.\n // (?!`): A negative lookahead ensuring the closing backticks are not followed by another backtick.\n return html.replace(/(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)/g, '<code><span class=\"syntax-marker\">$1</span>$2<span class=\"syntax-marker\">$3</span></code>');\n }\n\n /**\n * Sanitize URL to prevent XSS attacks\n * @param {string} url - URL to sanitize\n * @returns {string} Safe URL or '#' if dangerous\n */\n static sanitizeUrl(url) {\n // Trim whitespace and convert to lowercase for protocol check\n const trimmed = url.trim();\n const lower = trimmed.toLowerCase();\n\n // Allow safe protocols\n const safeProtocols = [\n 'http://',\n 'https://',\n 'mailto:',\n 'ftp://',\n 'ftps://'\n ];\n\n // Check if URL starts with a safe protocol\n const hasSafeProtocol = safeProtocols.some(protocol => lower.startsWith(protocol));\n\n // Allow relative URLs (starting with / or # or no protocol)\n const isRelative = trimmed.startsWith('/') ||\n trimmed.startsWith('#') ||\n trimmed.startsWith('?') ||\n trimmed.startsWith('.') ||\n (!trimmed.includes(':') && !trimmed.includes('//'));\n\n // If safe protocol or relative URL, return as-is\n if (hasSafeProtocol || isRelative) {\n return url;\n }\n\n // Block dangerous protocols (javascript:, data:, vbscript:, etc.)\n return '#';\n }\n\n /**\n * Parse links\n * @param {string} html - HTML with potential link markdown\n * @returns {string} HTML with link styling\n */\n static parseLinks(html) {\n return html.replace(/\\[(.+?)\\]\\((.+?)\\)/g, (match, text, url) => {\n const anchorName = `--link-${this.linkIndex++}`;\n // Sanitize URL to prevent XSS attacks\n const safeUrl = this.sanitizeUrl(url);\n // Use real href - pointer-events handles click prevention in normal mode\n return `<a href=\"${safeUrl}\" style=\"anchor-name: ${anchorName}\"><span class=\"syntax-marker\">[</span>${text}<span class=\"syntax-marker url-part\">](${url})</span></a>`;\n });\n }\n\n /**\n * Identify and protect sanctuaries (code and links) before parsing\n * @param {string} text - Text with potential markdown\n * @returns {Object} Object with protected text and sanctuary map\n */\n static identifyAndProtectSanctuaries(text) {\n const sanctuaries = new Map();\n let sanctuaryCounter = 0;\n let protectedText = text;\n \n // Create a map to track protected regions (URLs should not be processed)\n const protectedRegions = [];\n \n // First, find all links and mark their URL regions as protected\n const linkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n let linkMatch;\n while ((linkMatch = linkRegex.exec(text)) !== null) {\n // Calculate the exact position of the URL part\n // linkMatch.index is the start of the match\n // We need to find where \"](\" starts, then add 2 to get URL start\n const bracketPos = linkMatch.index + linkMatch[0].indexOf('](');\n const urlStart = bracketPos + 2;\n const urlEnd = urlStart + linkMatch[2].length;\n protectedRegions.push({ start: urlStart, end: urlEnd });\n }\n \n // Now protect inline code, but skip if it's inside a protected region (URL)\n const codeRegex = /(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)/g;\n let codeMatch;\n const codeMatches = [];\n \n while ((codeMatch = codeRegex.exec(text)) !== null) {\n const codeStart = codeMatch.index;\n const codeEnd = codeMatch.index + codeMatch[0].length;\n \n // Check if this code is inside a protected URL region\n const inProtectedRegion = protectedRegions.some(region => \n codeStart >= region.start && codeEnd <= region.end\n );\n \n if (!inProtectedRegion) {\n codeMatches.push({\n match: codeMatch[0],\n index: codeMatch.index,\n openTicks: codeMatch[1],\n content: codeMatch[2],\n closeTicks: codeMatch[3]\n });\n }\n }\n \n // Replace code matches from end to start to preserve indices\n codeMatches.sort((a, b) => b.index - a.index);\n codeMatches.forEach(codeInfo => {\n const placeholder = `\\uE000${sanctuaryCounter++}\\uE001`;\n sanctuaries.set(placeholder, {\n type: 'code',\n original: codeInfo.match,\n openTicks: codeInfo.openTicks,\n content: codeInfo.content,\n closeTicks: codeInfo.closeTicks\n });\n protectedText = protectedText.substring(0, codeInfo.index) + \n placeholder + \n protectedText.substring(codeInfo.index + codeInfo.match.length);\n });\n \n // Then protect links - they can contain sanctuary placeholders for code but not raw code\n protectedText = protectedText.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/g, (match, linkText, url) => {\n const placeholder = `\\uE000${sanctuaryCounter++}\\uE001`;\n sanctuaries.set(placeholder, {\n type: 'link',\n original: match,\n linkText,\n url\n });\n return placeholder;\n });\n \n return { protectedText, sanctuaries };\n }\n \n /**\n * Restore and transform sanctuaries back to HTML\n * @param {string} html - HTML with sanctuary placeholders\n * @param {Map} sanctuaries - Map of sanctuaries to restore\n * @returns {string} HTML with sanctuaries restored and transformed\n */\n static restoreAndTransformSanctuaries(html, sanctuaries) {\n // Sort sanctuary placeholders by position to restore in order\n const placeholders = Array.from(sanctuaries.keys()).sort((a, b) => {\n const indexA = html.indexOf(a);\n const indexB = html.indexOf(b);\n return indexA - indexB;\n });\n \n placeholders.forEach(placeholder => {\n const sanctuary = sanctuaries.get(placeholder);\n let replacement;\n \n if (sanctuary.type === 'code') {\n // Transform code sanctuary to HTML\n replacement = `<code><span class=\"syntax-marker\">${sanctuary.openTicks}</span>${sanctuary.content}<span class=\"syntax-marker\">${sanctuary.closeTicks}</span></code>`;\n } else if (sanctuary.type === 'link') {\n // For links, we need to process the link text for markdown\n let processedLinkText = sanctuary.linkText;\n \n // First restore any sanctuary placeholders that were already in the link text\n // (e.g., inline code that was protected before the link)\n sanctuaries.forEach((innerSanctuary, innerPlaceholder) => {\n if (processedLinkText.includes(innerPlaceholder)) {\n if (innerSanctuary.type === 'code') {\n const codeHtml = `<code><span class=\"syntax-marker\">${innerSanctuary.openTicks}</span>${innerSanctuary.content}<span class=\"syntax-marker\">${innerSanctuary.closeTicks}</span></code>`;\n processedLinkText = processedLinkText.replace(innerPlaceholder, codeHtml);\n }\n }\n });\n \n // Now parse other markdown in the link text (bold, italic, etc)\n processedLinkText = this.parseStrikethrough(processedLinkText);\n processedLinkText = this.parseBold(processedLinkText);\n processedLinkText = this.parseItalic(processedLinkText);\n \n // Transform link sanctuary to HTML\n // URL should NOT be processed for markdown - use it as-is\n const anchorName = `--link-${this.linkIndex++}`;\n const safeUrl = this.sanitizeUrl(sanctuary.url);\n replacement = `<a href=\"${safeUrl}\" style=\"anchor-name: ${anchorName}\"><span class=\"syntax-marker\">[</span>${processedLinkText}<span class=\"syntax-marker url-part\">](${sanctuary.url})</span></a>`;\n }\n \n html = html.replace(placeholder, replacement);\n });\n \n return html;\n }\n \n /**\n * Parse all inline elements in correct order\n * @param {string} text - Text with potential inline markdown\n * @returns {string} HTML with all inline styling\n */\n static parseInlineElements(text) {\n // Step 1: Identify and protect sanctuaries (code and links)\n const { protectedText, sanctuaries } = this.identifyAndProtectSanctuaries(text);\n \n // Step 2: Parse other inline elements on protected text\n let html = protectedText;\n html = this.parseStrikethrough(html);\n html = this.parseBold(html);\n html = this.parseItalic(html);\n \n // Step 3: Restore and transform sanctuaries\n html = this.restoreAndTransformSanctuaries(html, sanctuaries);\n \n return html;\n }\n\n /**\n * Parse a single line of markdown\n * @param {string} line - Raw markdown line\n * @returns {string} Parsed HTML line\n */\n static parseLine(line, isPreviewMode = false) {\n let html = this.escapeHtml(line);\n\n // Preserve indentation\n html = this.preserveIndentation(html, line);\n\n // Check for block elements first\n const horizontalRule = this.parseHorizontalRule(html);\n if (horizontalRule) return horizontalRule;\n\n const codeBlock = this.parseCodeBlock(html);\n if (codeBlock) return codeBlock;\n\n // Parse block elements\n html = this.parseHeader(html);\n html = this.parseBlockquote(html);\n html = this.parseTaskList(html, isPreviewMode); // Check task lists before regular bullet lists\n html = this.parseBulletList(html);\n html = this.parseNumberedList(html);\n\n // Parse inline elements (skip for headers and list items \u2014 already parsed inside those functions)\n if (!html.includes('<li') && !html.includes('<h')) {\n html = this.parseInlineElements(html);\n }\n\n // Wrap in div to maintain line structure\n if (html.trim() === '') {\n // Intentionally use &nbsp; for empty lines to maintain vertical spacing\n // This causes a 0->1 character count difference but preserves visual alignment\n return '<div>&nbsp;</div>';\n }\n\n return `<div>${html}</div>`;\n }\n\n /**\n * Parse full markdown text\n * @param {string} text - Full markdown text\n * @param {number} activeLine - Currently active line index (optional)\n * @param {boolean} showActiveLineRaw - Show raw markdown on active line\n * @param {Function} instanceHighlighter - Instance-specific code highlighter (optional, overrides global if provided)\n * @returns {string} Parsed HTML\n */\n static parse(text, activeLine = -1, showActiveLineRaw = false, instanceHighlighter, isPreviewMode = false) {\n // Reset link counter for each parse\n this.resetLinkIndex();\n\n const lines = text.split('\\n');\n let inCodeBlock = false;\n\n const parsedLines = lines.map((line, index) => {\n // Show raw markdown on active line if requested\n if (showActiveLineRaw && index === activeLine) {\n const content = this.escapeHtml(line) || '&nbsp;';\n return `<div class=\"raw-line\">${content}</div>`;\n }\n\n // Check if this line is a code fence\n const codeFenceRegex = /^```[^`]*$/;\n if (codeFenceRegex.test(line)) {\n inCodeBlock = !inCodeBlock;\n // Parse fence markers normally to get styled output\n return this.applyCustomSyntax(this.parseLine(line, isPreviewMode));\n }\n\n // If we're inside a code block, don't parse as markdown\n if (inCodeBlock) {\n const escaped = this.escapeHtml(line);\n const indented = this.preserveIndentation(escaped, line);\n return `<div>${indented || '&nbsp;'}</div>`;\n }\n\n // Otherwise, parse the markdown normally\n return this.applyCustomSyntax(this.parseLine(line, isPreviewMode));\n });\n\n // Join without newlines to prevent extra spacing\n const html = parsedLines.join('');\n\n // Apply post-processing for list consolidation\n return this.postProcessHTML(html, instanceHighlighter);\n }\n\n /**\n * Post-process HTML to consolidate lists and code blocks\n * @param {string} html - HTML to post-process\n * @param {Function} instanceHighlighter - Instance-specific code highlighter (optional, overrides global if provided)\n * @returns {string} Post-processed HTML with consolidated lists and code blocks\n */\n static postProcessHTML(html, instanceHighlighter) {\n // Check if we're in a browser environment\n if (typeof document === 'undefined' || !document) {\n // In Node.js environment - do manual post-processing\n return this.postProcessHTMLManual(html, instanceHighlighter);\n }\n\n // Parse HTML string into DOM\n const container = document.createElement('div');\n container.innerHTML = html;\n\n let currentList = null;\n let listType = null;\n let currentCodeBlock = null;\n let inCodeBlock = false;\n\n // Process all direct children - need to be careful with live NodeList\n const children = Array.from(container.children);\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n\n // Skip if child was already processed/removed\n if (!child.parentNode) continue;\n\n // Check for code fence start/end\n const codeFence = child.querySelector('.code-fence');\n if (codeFence) {\n const fenceText = codeFence.textContent;\n if (fenceText.startsWith('```')) {\n if (!inCodeBlock) {\n // Start of code block - keep fence visible, then add pre/code\n inCodeBlock = true;\n\n // Create the code block that will follow the fence\n currentCodeBlock = document.createElement('pre');\n const codeElement = document.createElement('code');\n currentCodeBlock.appendChild(codeElement);\n currentCodeBlock.className = 'code-block';\n\n // Extract language if present\n const lang = fenceText.slice(3).trim();\n if (lang) {\n codeElement.className = `language-${lang}`;\n }\n\n // Insert code block after the fence div (don't remove the fence)\n container.insertBefore(currentCodeBlock, child.nextSibling);\n\n // Store reference to the code element for adding content\n currentCodeBlock._codeElement = codeElement;\n currentCodeBlock._language = lang;\n currentCodeBlock._codeContent = '';\n continue;\n } else {\n // End of code block - apply highlighting if needed\n // Use instance highlighter if provided, otherwise fall back to global highlighter\n const highlighter = instanceHighlighter || this.codeHighlighter;\n if (currentCodeBlock && highlighter && currentCodeBlock._codeContent) {\n try {\n const result = highlighter(\n currentCodeBlock._codeContent,\n currentCodeBlock._language || ''\n );\n\n // Check if result is a Promise (async highlighter)\n if (result && typeof result.then === 'function') {\n console.warn('Async highlighters are not supported in parse() because it returns an HTML string. The caller creates new DOM elements from that string, breaking references to the elements we would update. Use synchronous highlighters only.');\n // Keep the plain text fallback that was already set\n } else {\n // Synchronous highlighter\n // Verify highlighter returned non-empty string\n if (result && typeof result === 'string' && result.trim()) {\n currentCodeBlock._codeElement.innerHTML = result;\n }\n // else: keep the plain text fallback that was already set\n }\n } catch (error) {\n console.warn('Code highlighting failed:', error);\n // Keep the plain text content as fallback\n }\n }\n\n inCodeBlock = false;\n currentCodeBlock = null;\n continue;\n }\n }\n }\n\n // Check if we're in a code block - any div that's not a code fence\n if (inCodeBlock && currentCodeBlock && child.tagName === 'DIV' && !child.querySelector('.code-fence')) {\n const codeElement = currentCodeBlock._codeElement || currentCodeBlock.querySelector('code');\n // Add the line content to the code block content (for highlighting)\n if (currentCodeBlock._codeContent.length > 0) {\n currentCodeBlock._codeContent += '\\n';\n }\n // Get the actual text content, preserving spaces\n const lineText = child.textContent.replace(/\\u00A0/g, ' '); // \\u00A0 is nbsp\n currentCodeBlock._codeContent += lineText;\n\n // Also add to the code element (fallback if no highlighter)\n if (codeElement.textContent.length > 0) {\n codeElement.textContent += '\\n';\n }\n codeElement.textContent += lineText;\n child.remove();\n continue;\n }\n\n // Check if this div contains a list item\n let listItem = null;\n if (child.tagName === 'DIV') {\n // Look for li inside the div\n listItem = child.querySelector('li');\n }\n\n if (listItem) {\n const isBullet = listItem.classList.contains('bullet-list');\n const isOrdered = listItem.classList.contains('ordered-list');\n\n if (!isBullet && !isOrdered) {\n currentList = null;\n listType = null;\n continue;\n }\n\n const newType = isBullet ? 'ul' : 'ol';\n\n // Start new list or continue current\n if (!currentList || listType !== newType) {\n currentList = document.createElement(newType);\n container.insertBefore(currentList, child);\n listType = newType;\n }\n\n // Extract and preserve indentation from the div before moving the list item\n const indentationNodes = [];\n for (const node of child.childNodes) {\n if (node.nodeType === 3 && node.textContent.match(/^\\u00A0+$/)) {\n // This is a text node containing only non-breaking spaces (indentation)\n indentationNodes.push(node.cloneNode(true));\n } else if (node === listItem) {\n break; // Stop when we reach the list item\n }\n }\n\n // Add indentation to the list item\n indentationNodes.forEach(node => {\n listItem.insertBefore(node, listItem.firstChild);\n });\n\n // Move the list item to the current list\n currentList.appendChild(listItem);\n\n // Remove the now-empty div wrapper\n child.remove();\n } else {\n // Non-list element ends current list\n currentList = null;\n listType = null;\n }\n }\n\n return container.innerHTML;\n }\n\n /**\n * Manual post-processing for Node.js environments (without DOM)\n * @param {string} html - HTML to post-process\n * @param {Function} instanceHighlighter - Instance-specific code highlighter (optional, overrides global if provided)\n * @returns {string} Post-processed HTML\n */\n static postProcessHTMLManual(html, instanceHighlighter) {\n let processed = html;\n\n // Process unordered lists\n processed = processed.replace(/((?:<div>(?:&nbsp;)*<li class=\"bullet-list\">.*?<\\/li><\\/div>\\s*)+)/gs, (match) => {\n const divs = match.match(/<div>(?:&nbsp;)*<li class=\"bullet-list\">.*?<\\/li><\\/div>/gs) || [];\n if (divs.length > 0) {\n const items = divs.map(div => {\n // Extract indentation and list item\n const indentMatch = div.match(/<div>((?:&nbsp;)*)<li/);\n const listItemMatch = div.match(/<li class=\"bullet-list\">.*?<\\/li>/);\n\n if (indentMatch && listItemMatch) {\n const indentation = indentMatch[1];\n const listItem = listItemMatch[0];\n // Insert indentation at the start of the list item content\n return listItem.replace(/<li class=\"bullet-list\">/, `<li class=\"bullet-list\">${indentation}`);\n }\n return listItemMatch ? listItemMatch[0] : '';\n }).filter(Boolean);\n\n return '<ul>' + items.join('') + '</ul>';\n }\n return match;\n });\n\n // Process ordered lists\n processed = processed.replace(/((?:<div>(?:&nbsp;)*<li class=\"ordered-list\">.*?<\\/li><\\/div>\\s*)+)/gs, (match) => {\n const divs = match.match(/<div>(?:&nbsp;)*<li class=\"ordered-list\">.*?<\\/li><\\/div>/gs) || [];\n if (divs.length > 0) {\n const items = divs.map(div => {\n // Extract indentation and list item\n const indentMatch = div.match(/<div>((?:&nbsp;)*)<li/);\n const listItemMatch = div.match(/<li class=\"ordered-list\">.*?<\\/li>/);\n\n if (indentMatch && listItemMatch) {\n const indentation = indentMatch[1];\n const listItem = listItemMatch[0];\n // Insert indentation at the start of the list item content\n return listItem.replace(/<li class=\"ordered-list\">/, `<li class=\"ordered-list\">${indentation}`);\n }\n return listItemMatch ? listItemMatch[0] : '';\n }).filter(Boolean);\n\n return '<ol>' + items.join('') + '</ol>';\n }\n return match;\n });\n\n // Process code blocks - KEEP the fence markers for alignment AND use semantic pre/code\n const codeBlockRegex = /<div><span class=\"code-fence\">(```[^<]*)<\\/span><\\/div>(.*?)<div><span class=\"code-fence\">(```)<\\/span><\\/div>/gs;\n processed = processed.replace(codeBlockRegex, (match, openFence, content, closeFence) => {\n // Extract the content between fences\n const lines = content.match(/<div>(.*?)<\\/div>/gs) || [];\n const codeContent = lines.map(line => {\n // Extract text from each div - content is already escaped\n const text = line.replace(/<div>(.*?)<\\/div>/s, '$1')\n .replace(/&nbsp;/g, ' ');\n return text;\n }).join('\\n');\n\n // Extract language from the opening fence\n const lang = openFence.slice(3).trim();\n const langClass = lang ? ` class=\"language-${lang}\"` : '';\n\n // Apply code highlighting if available\n let highlightedContent = codeContent;\n // Use instance highlighter if provided, otherwise fall back to global highlighter\n const highlighter = instanceHighlighter || this.codeHighlighter;\n if (highlighter) {\n try {\n // CRITICAL: Decode HTML entities before passing to highlighter\n // In the DOM path, textContent automatically decodes entities.\n // In the manual path, we need to decode explicitly to avoid double-escaping.\n const decodedCode = codeContent\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&amp;/g, '&'); // Must be last to avoid double-decoding\n\n const result = highlighter(decodedCode, lang);\n\n // Check if result is a Promise (async highlighter)\n // Note: In Node.js context, we can't easily defer rendering, so we warn\n if (result && typeof result.then === 'function') {\n console.warn('Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering.');\n // Fall back to escaped content\n } else {\n // Synchronous highlighter - verify returned non-empty string\n if (result && typeof result === 'string' && result.trim()) {\n highlightedContent = result;\n }\n // else: keep the escaped codeContent as fallback\n }\n } catch (error) {\n console.warn('Code highlighting failed:', error);\n // Fall back to original content\n }\n }\n\n // Keep fence markers visible as separate divs, with pre/code block between them\n let result = `<div><span class=\"code-fence\">${openFence}</span></div>`;\n // Use highlighted content if available, otherwise use escaped content\n result += `<pre class=\"code-block\"><code${langClass}>${highlightedContent}</code></pre>`;\n result += `<div><span class=\"code-fence\">${closeFence}</span></div>`;\n\n return result;\n });\n\n return processed;\n }\n\n /**\n * List pattern definitions\n */\n static LIST_PATTERNS = {\n bullet: /^(\\s*)([-*+])\\s+(.*)$/,\n numbered: /^(\\s*)(\\d+)\\.\\s+(.*)$/,\n checkbox: /^(\\s*)-\\s+\\[([ x])\\]\\s+(.*)$/\n };\n\n /**\n * Get list context at cursor position\n * @param {string} text - Full text content\n * @param {number} cursorPosition - Current cursor position\n * @returns {Object} List context information\n */\n static getListContext(text, cursorPosition) {\n // Find the line containing the cursor\n const lines = text.split('\\n');\n let currentPos = 0;\n let lineIndex = 0;\n let lineStart = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const lineLength = lines[i].length;\n if (currentPos + lineLength >= cursorPosition) {\n lineIndex = i;\n lineStart = currentPos;\n break;\n }\n currentPos += lineLength + 1; // +1 for newline\n }\n\n const currentLine = lines[lineIndex];\n const lineEnd = lineStart + currentLine.length;\n\n // Check for checkbox first (most specific)\n const checkboxMatch = currentLine.match(this.LIST_PATTERNS.checkbox);\n if (checkboxMatch) {\n return {\n inList: true,\n listType: 'checkbox',\n indent: checkboxMatch[1],\n marker: '-',\n checked: checkboxMatch[2] === 'x',\n content: checkboxMatch[3],\n lineStart,\n lineEnd,\n markerEndPos: lineStart + checkboxMatch[1].length + checkboxMatch[2].length + 5 // indent + \"- [ ] \"\n };\n }\n\n // Check for bullet list\n const bulletMatch = currentLine.match(this.LIST_PATTERNS.bullet);\n if (bulletMatch) {\n return {\n inList: true,\n listType: 'bullet',\n indent: bulletMatch[1],\n marker: bulletMatch[2],\n content: bulletMatch[3],\n lineStart,\n lineEnd,\n markerEndPos: lineStart + bulletMatch[1].length + bulletMatch[2].length + 1 // indent + marker + space\n };\n }\n\n // Check for numbered list\n const numberedMatch = currentLine.match(this.LIST_PATTERNS.numbered);\n if (numberedMatch) {\n return {\n inList: true,\n listType: 'numbered',\n indent: numberedMatch[1],\n marker: parseInt(numberedMatch[2]),\n content: numberedMatch[3],\n lineStart,\n lineEnd,\n markerEndPos: lineStart + numberedMatch[1].length + numberedMatch[2].length + 2 // indent + number + \". \"\n };\n }\n\n // Not in a list\n return {\n inList: false,\n listType: null,\n indent: '',\n marker: null,\n content: currentLine,\n lineStart,\n lineEnd,\n markerEndPos: lineStart\n };\n }\n\n /**\n * Create a new list item based on context\n * @param {Object} context - List context from getListContext\n * @returns {string} New list item text\n */\n static createNewListItem(context) {\n switch (context.listType) {\n case 'bullet':\n return `${context.indent}${context.marker} `;\n case 'numbered':\n return `${context.indent}${context.marker + 1}. `;\n case 'checkbox':\n return `${context.indent}- [ ] `;\n default:\n return '';\n }\n }\n\n /**\n * Renumber all numbered lists in text\n * @param {string} text - Text containing numbered lists\n * @returns {string} Text with renumbered lists\n */\n static renumberLists(text) {\n const lines = text.split('\\n');\n const numbersByIndent = new Map();\n let inList = false;\n\n const result = lines.map(line => {\n const match = line.match(this.LIST_PATTERNS.numbered);\n\n if (match) {\n const indent = match[1];\n const indentLevel = indent.length;\n const content = match[3];\n\n // If we weren't in a list or indent changed, reset lower levels\n if (!inList) {\n numbersByIndent.clear();\n }\n\n // Get the next number for this indent level\n const currentNumber = (numbersByIndent.get(indentLevel) || 0) + 1;\n numbersByIndent.set(indentLevel, currentNumber);\n\n // Clear deeper indent levels\n for (const [level] of numbersByIndent) {\n if (level > indentLevel) {\n numbersByIndent.delete(level);\n }\n }\n\n inList = true;\n return `${indent}${currentNumber}. ${content}`;\n } else {\n // Not a numbered list item\n if (line.trim() === '' || !line.match(/^\\s/)) {\n // Empty line or non-indented line breaks the list\n inList = false;\n numbersByIndent.clear();\n }\n return line;\n }\n });\n\n return result.join('\\n');\n }\n}\n", "/**\n * Keyboard shortcuts handler for OverType editor\n * Delegates to editor.performAction for consistent behavior\n */\n\n/**\n * ShortcutsManager - Handles keyboard shortcuts for the editor\n */\nexport class ShortcutsManager {\n constructor(editor) {\n this.editor = editor;\n }\n\n /**\n * Handle keydown events - called by OverType\n * @param {KeyboardEvent} event - The keyboard event\n * @returns {boolean} Whether the event was handled\n */\n handleKeydown(event) {\n const isMac = navigator.platform.toLowerCase().includes('mac');\n const modKey = isMac ? event.metaKey : event.ctrlKey;\n\n if (!modKey) return false;\n\n let actionId = null;\n\n switch (event.key.toLowerCase()) {\n case 'b':\n if (!event.shiftKey) actionId = 'toggleBold';\n break;\n case 'i':\n if (!event.shiftKey) actionId = 'toggleItalic';\n break;\n case 'k':\n if (!event.shiftKey) actionId = 'insertLink';\n break;\n case '7':\n if (event.shiftKey) actionId = 'toggleNumberedList';\n break;\n case '8':\n if (event.shiftKey) actionId = 'toggleBulletList';\n break;\n }\n\n if (actionId) {\n event.preventDefault();\n this.editor.performAction(actionId, event);\n return true;\n }\n\n return false;\n }\n\n /**\n * Cleanup\n */\n destroy() {\n // Nothing to clean up since we don't add our own listener\n }\n}\n", "/**\n * Built-in themes for OverType editor\n * Each theme provides a complete color palette for the editor\n */\n\n/**\n * Solar theme - Light, warm and bright\n */\nexport const solar = {\n name: 'solar',\n colors: {\n bgPrimary: '#faf0ca', // Lemon Chiffon - main background\n bgSecondary: '#ffffff', // White - editor background\n text: '#0d3b66', // Yale Blue - main text\n textPrimary: '#0d3b66', // Yale Blue - primary text (same as text)\n textSecondary: '#5a7a9b', // Muted blue - secondary text\n h1: '#f95738', // Tomato - h1 headers\n h2: '#ee964b', // Sandy Brown - h2 headers\n h3: '#3d8a51', // Forest green - h3 headers\n strong: '#ee964b', // Sandy Brown - bold text\n em: '#f95738', // Tomato - italic text\n del: '#ee964b', // Sandy Brown - deleted text (same as strong)\n link: '#0d3b66', // Yale Blue - links\n code: '#0d3b66', // Yale Blue - inline code\n codeBg: 'rgba(244, 211, 94, 0.4)', // Naples Yellow with transparency\n blockquote: '#5a7a9b', // Muted blue - blockquotes\n hr: '#5a7a9b', // Muted blue - horizontal rules\n syntaxMarker: 'rgba(13, 59, 102, 0.52)', // Yale Blue with transparency\n syntax: '#999999', // Gray - syntax highlighting fallback\n cursor: '#f95738', // Tomato - cursor\n selection: 'rgba(244, 211, 94, 0.4)', // Naples Yellow with transparency\n listMarker: '#ee964b', // Sandy Brown - list markers\n rawLine: '#5a7a9b', // Muted blue - raw line indicators\n border: '#e0e0e0', // Light gray - borders\n hoverBg: '#f0f0f0', // Very light gray - hover backgrounds\n primary: '#0d3b66', // Yale Blue - primary accent\n // Toolbar colors\n toolbarBg: '#ffffff', // White - toolbar background\n toolbarIcon: '#0d3b66', // Yale Blue - icon color\n toolbarHover: '#f5f5f5', // Light gray - hover background\n toolbarActive: '#faf0ca', // Lemon Chiffon - active button background\n placeholder: '#999999', // Gray - placeholder text\n },\n previewColors: {\n text: '#1a1a1a',\n h1: '#1a1a1a',\n h2: '#2a2a2a',\n h3: '#3a3a3a',\n strong: 'inherit',\n em: 'inherit',\n link: '#0066cc',\n code: '#1a1a1a',\n codeBg: 'rgba(135, 131, 120, 0.15)',\n blockquote: '#555',\n hr: '#ddd',\n bg: 'transparent',\n }\n};\n\n/**\n * Cave theme - Dark ocean depths\n */\nexport const cave = {\n name: 'cave',\n colors: {\n bgPrimary: '#141E26', // Deep ocean - main background\n bgSecondary: '#1D2D3E', // Darker charcoal - editor background\n text: '#c5dde8', // Light blue-gray - main text\n textPrimary: '#c5dde8', // Light blue-gray - primary text (same as text)\n textSecondary: '#9fcfec', // Brighter blue - secondary text\n h1: '#d4a5ff', // Rich lavender - h1 headers\n h2: '#f6ae2d', // Hunyadi Yellow - h2 headers\n h3: '#9fcfec', // Brighter blue - h3 headers\n strong: '#f6ae2d', // Hunyadi Yellow - bold text\n em: '#9fcfec', // Brighter blue - italic text\n del: '#f6ae2d', // Hunyadi Yellow - deleted text (same as strong)\n link: '#9fcfec', // Brighter blue - links\n code: '#c5dde8', // Light blue-gray - inline code\n codeBg: '#1a232b', // Very dark blue - code background\n blockquote: '#9fcfec', // Brighter blue - same as italic\n hr: '#c5dde8', // Light blue-gray - horizontal rules\n syntaxMarker: 'rgba(159, 207, 236, 0.73)', // Brighter blue semi-transparent\n syntax: '#7a8c98', // Muted gray-blue - syntax highlighting fallback\n cursor: '#f26419', // Orange Pantone - cursor\n selection: 'rgba(51, 101, 138, 0.4)', // Lapis Lazuli with transparency\n listMarker: '#f6ae2d', // Hunyadi Yellow - list markers\n rawLine: '#9fcfec', // Brighter blue - raw line indicators\n border: '#2a3f52', // Dark blue-gray - borders\n hoverBg: '#243546', // Slightly lighter charcoal - hover backgrounds\n primary: '#9fcfec', // Brighter blue - primary accent\n // Toolbar colors for dark theme\n toolbarBg: '#1D2D3E', // Darker charcoal - toolbar background\n toolbarIcon: '#c5dde8', // Light blue-gray - icon color\n toolbarHover: '#243546', // Slightly lighter charcoal - hover background\n toolbarActive: '#2a3f52', // Even lighter - active button background\n placeholder: '#6a7a88', // Muted blue-gray - placeholder text\n },\n previewColors: {\n text: '#c5dde8',\n h1: '#e0e0e0',\n h2: '#d0d0d0',\n h3: '#c0c0c0',\n strong: 'inherit',\n em: 'inherit',\n link: '#6cb6e0',\n code: '#c5dde8',\n codeBg: 'rgba(255, 255, 255, 0.08)',\n blockquote: '#9aa8b4',\n hr: 'rgba(255, 255, 255, 0.15)',\n bg: 'transparent',\n }\n};\n\n/**\n * Default themes registry\n */\nexport const themes = {\n solar,\n cave,\n auto: solar,\n // Aliases for backward compatibility\n light: solar,\n dark: cave\n};\n\n/**\n * Get theme by name or return custom theme object\n * @param {string|Object} theme - Theme name or custom theme object\n * @returns {Object} Theme configuration\n */\nexport function getTheme(theme) {\n if (typeof theme === 'string') {\n const themeObj = themes[theme] || themes.solar;\n // Preserve the requested theme name (important for 'light' and 'dark' aliases)\n return { ...themeObj, name: theme };\n }\n return theme;\n}\n\n/**\n * Resolve auto theme to actual theme based on system color scheme\n * @param {string} themeName - Theme name to resolve\n * @returns {string} Resolved theme name ('solar' or 'cave' if auto, otherwise unchanged)\n */\nexport function resolveAutoTheme(themeName) {\n if (themeName !== 'auto') return themeName;\n const mq = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');\n return mq?.matches ? 'cave' : 'solar';\n}\n\n/**\n * Apply theme colors to CSS variables\n * @param {Object} colors - Theme colors object\n * @returns {string} CSS custom properties string\n */\nexport function themeToCSSVars(colors, previewColors) {\n const vars = [];\n for (const [key, value] of Object.entries(colors)) {\n const varName = key.replace(/([A-Z])/g, '-$1').toLowerCase();\n vars.push(`--${varName}: ${value};`);\n }\n if (previewColors) {\n for (const [key, value] of Object.entries(previewColors)) {\n const varName = key.replace(/([A-Z])/g, '-$1').toLowerCase();\n vars.push(`--preview-${varName}: ${value};`);\n }\n }\n return vars.join('\\n');\n}\n\n/**\n * Merge custom colors with base theme\n * @param {Object} baseTheme - Base theme object\n * @param {Object} customColors - Custom color overrides\n * @returns {Object} Merged theme object\n */\nexport function mergeTheme(baseTheme, customColors = {}, customPreviewColors = {}) {\n return {\n ...baseTheme,\n colors: {\n ...baseTheme.colors,\n ...customColors\n },\n previewColors: {\n ...baseTheme.previewColors,\n ...customPreviewColors\n }\n };\n}", "/**\n * CSS styles for OverType editor\n * Embedded in JavaScript to ensure single-file distribution\n */\n\nimport { themeToCSSVars } from './themes.js';\n\n/**\n * Generate the complete CSS for the editor\n * @param {Object} options - Configuration options\n * @returns {string} Complete CSS string\n */\nexport function generateStyles(options = {}) {\n const {\n fontSize = '14px',\n lineHeight = 1.6,\n /* System-first, guaranteed monospaced; avoids Android 'ui-monospace' pitfalls */\n fontFamily = '\"SF Mono\", SFMono-Regular, Menlo, Monaco, \"Cascadia Code\", Consolas, \"Roboto Mono\", \"Noto Sans Mono\", \"Droid Sans Mono\", \"Ubuntu Mono\", \"DejaVu Sans Mono\", \"Liberation Mono\", \"Courier New\", Courier, monospace',\n padding = '20px',\n theme = null,\n mobile = {}\n } = options;\n\n // Generate mobile overrides\n const mobileStyles = Object.keys(mobile).length > 0 ? `\n @media (max-width: 640px) {\n .overtype-wrapper .overtype-input,\n .overtype-wrapper .overtype-preview {\n ${Object.entries(mobile)\n .map(([prop, val]) => {\n const cssProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();\n return `${cssProp}: ${val} !important;`;\n })\n .join('\\n ')}\n }\n }\n ` : '';\n\n // Generate theme variables if provided\n const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors, theme.previewColors) : '';\n\n return `\n /* OverType Editor Styles */\n \n /* Middle-ground CSS Reset - Prevent parent styles from leaking in */\n .overtype-container * {\n /* Box model - these commonly leak */\n margin: 0 !important;\n padding: 0 !important;\n border: 0 !important;\n \n /* Layout - these can break our layout */\n /* Don't reset position - it breaks dropdowns */\n float: none !important;\n clear: none !important;\n \n /* Typography - only reset decorative aspects */\n text-decoration: none !important;\n text-transform: none !important;\n letter-spacing: normal !important;\n \n /* Visual effects that can interfere */\n box-shadow: none !important;\n text-shadow: none !important;\n \n /* Ensure box-sizing is consistent */\n box-sizing: border-box !important;\n \n /* Keep inheritance for these */\n /* font-family, color, line-height, font-size - inherit */\n }\n \n /* Container base styles after reset */\n .overtype-container {\n display: flex !important;\n flex-direction: column !important;\n width: 100% !important;\n height: 100% !important;\n position: relative !important; /* Override reset - needed for absolute children */\n overflow: visible !important; /* Allow dropdown to overflow container */\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif !important;\n text-align: left !important;\n ${themeVars ? `\n /* Theme Variables */\n ${themeVars}` : ''}\n }\n \n /* Force left alignment for all elements in the editor */\n .overtype-container .overtype-wrapper * {\n text-align: left !important;\n }\n \n /* Auto-resize mode styles */\n .overtype-container.overtype-auto-resize {\n height: auto !important;\n }\n\n .overtype-container.overtype-auto-resize .overtype-wrapper {\n flex: 0 0 auto !important; /* Don't grow/shrink, use explicit height */\n height: auto !important;\n min-height: 60px !important;\n overflow: visible !important;\n }\n \n .overtype-wrapper {\n position: relative !important; /* Override reset - needed for absolute children */\n width: 100% !important;\n flex: 1 1 0 !important; /* Grow to fill remaining space, with flex-basis: 0 */\n min-height: 60px !important; /* Minimum usable height */\n overflow: hidden !important;\n background: var(--bg-secondary, #ffffff) !important;\n z-index: 1; /* Below toolbar and dropdown */\n }\n\n /* Critical alignment styles - must be identical for both layers */\n .overtype-wrapper .overtype-input,\n .overtype-wrapper .overtype-preview {\n /* Positioning - must be identical */\n position: absolute !important; /* Override reset - required for overlay */\n top: 0 !important;\n left: 0 !important;\n width: 100% !important;\n height: 100% !important;\n \n /* Font properties - any difference breaks alignment */\n font-family: ${fontFamily} !important;\n font-variant-ligatures: none !important; /* keep metrics stable for code */\n font-size: var(--instance-font-size, ${fontSize}) !important;\n line-height: var(--instance-line-height, ${lineHeight}) !important;\n font-weight: normal !important;\n font-style: normal !important;\n font-variant: normal !important;\n font-stretch: normal !important;\n font-kerning: none !important;\n font-feature-settings: normal !important;\n \n /* Box model - must match exactly */\n padding: var(--instance-padding, ${padding}) !important;\n margin: 0 !important;\n border: none !important;\n outline: none !important;\n box-sizing: border-box !important;\n \n /* Text layout - critical for character positioning */\n white-space: pre-wrap !important;\n word-wrap: break-word !important;\n word-break: normal !important;\n overflow-wrap: break-word !important;\n tab-size: 2 !important;\n -moz-tab-size: 2 !important;\n text-align: left !important;\n text-indent: 0 !important;\n letter-spacing: normal !important;\n word-spacing: normal !important;\n \n /* Text rendering */\n text-transform: none !important;\n text-rendering: auto !important;\n -webkit-font-smoothing: auto !important;\n -webkit-text-size-adjust: 100% !important;\n \n /* Direction and writing */\n direction: ltr !important;\n writing-mode: horizontal-tb !important;\n unicode-bidi: normal !important;\n text-orientation: mixed !important;\n \n /* Visual effects that could shift perception */\n text-shadow: none !important;\n filter: none !important;\n transform: none !important;\n zoom: 1 !important;\n \n /* Vertical alignment */\n vertical-align: baseline !important;\n \n /* Size constraints */\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: none !important;\n max-height: none !important;\n \n /* Overflow */\n overflow-y: auto !important;\n overflow-x: auto !important;\n /* overscroll-behavior removed to allow scroll-through to parent */\n scrollbar-width: auto !important;\n scrollbar-gutter: auto !important;\n \n /* Animation/transition - disabled to prevent movement */\n animation: none !important;\n transition: none !important;\n }\n\n /* Input layer styles */\n .overtype-wrapper .overtype-input {\n /* Layer positioning */\n z-index: 1 !important;\n \n /* Text visibility */\n color: transparent !important;\n caret-color: var(--cursor, #f95738) !important;\n background-color: transparent !important;\n \n /* Textarea-specific */\n resize: none !important;\n appearance: none !important;\n -webkit-appearance: none !important;\n -moz-appearance: none !important;\n \n /* Prevent mobile zoom on focus */\n touch-action: manipulation !important;\n \n /* Disable autofill */\n autocomplete: off !important;\n autocorrect: off !important;\n autocapitalize: off !important;\n }\n\n .overtype-wrapper .overtype-input::selection {\n background-color: var(--selection, rgba(244, 211, 94, 0.4));\n }\n\n /* Placeholder shim - visible when textarea is empty */\n .overtype-wrapper .overtype-placeholder {\n position: absolute !important;\n top: 0 !important;\n left: 0 !important;\n width: 100% !important;\n z-index: 0 !important;\n pointer-events: none !important;\n user-select: none !important;\n font-family: ${fontFamily} !important;\n font-size: var(--instance-font-size, ${fontSize}) !important;\n line-height: var(--instance-line-height, ${lineHeight}) !important;\n padding: var(--instance-padding, ${padding}) !important;\n box-sizing: border-box !important;\n color: var(--placeholder, #999) !important;\n overflow: hidden !important;\n white-space: nowrap !important;\n text-overflow: ellipsis !important;\n }\n\n /* Preview layer styles */\n .overtype-wrapper .overtype-preview {\n /* Layer positioning */\n z-index: 0 !important;\n pointer-events: none !important;\n color: var(--text, #0d3b66) !important;\n background-color: transparent !important;\n \n /* Prevent text selection */\n user-select: none !important;\n -webkit-user-select: none !important;\n -moz-user-select: none !important;\n -ms-user-select: none !important;\n }\n\n /* Defensive styles for preview child divs */\n .overtype-wrapper .overtype-preview div {\n /* Reset any inherited styles */\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n text-align: left !important;\n text-indent: 0 !important;\n display: block !important;\n position: static !important;\n transform: none !important;\n min-height: 0 !important;\n max-height: none !important;\n line-height: inherit !important;\n font-size: inherit !important;\n font-family: inherit !important;\n }\n\n /* Markdown element styling - NO SIZE CHANGES */\n .overtype-wrapper .overtype-preview .header {\n font-weight: bold !important;\n }\n\n /* Header colors */\n .overtype-wrapper .overtype-preview .h1 { \n color: var(--h1, #f95738) !important; \n }\n .overtype-wrapper .overtype-preview .h2 { \n color: var(--h2, #ee964b) !important; \n }\n .overtype-wrapper .overtype-preview .h3 { \n color: var(--h3, #3d8a51) !important; \n }\n\n /* Semantic headers - flatten in edit mode */\n .overtype-wrapper .overtype-preview h1,\n .overtype-wrapper .overtype-preview h2,\n .overtype-wrapper .overtype-preview h3 {\n font-size: inherit !important;\n font-weight: bold !important;\n margin: 0 !important;\n padding: 0 !important;\n display: inline !important;\n line-height: inherit !important;\n }\n\n /* Header colors for semantic headers */\n .overtype-wrapper .overtype-preview h1 { \n color: var(--h1, #f95738) !important; \n }\n .overtype-wrapper .overtype-preview h2 { \n color: var(--h2, #ee964b) !important; \n }\n .overtype-wrapper .overtype-preview h3 { \n color: var(--h3, #3d8a51) !important; \n }\n\n /* Lists - remove styling in edit mode */\n .overtype-wrapper .overtype-preview ul,\n .overtype-wrapper .overtype-preview ol {\n list-style: none !important;\n margin: 0 !important;\n padding: 0 !important;\n display: block !important; /* Lists need to be block for line breaks */\n }\n\n .overtype-wrapper .overtype-preview li {\n display: block !important; /* Each item on its own line */\n margin: 0 !important;\n padding: 0 !important;\n /* Don't set list-style here - let ul/ol control it */\n }\n\n /* Bold text */\n .overtype-wrapper .overtype-preview strong {\n color: var(--strong, #ee964b) !important;\n font-weight: bold !important;\n }\n\n /* Italic text */\n .overtype-wrapper .overtype-preview em {\n color: var(--em, #f95738) !important;\n text-decoration-color: var(--em, #f95738) !important;\n text-decoration-thickness: 1px !important;\n font-style: italic !important;\n }\n\n /* Strikethrough text */\n .overtype-wrapper .overtype-preview del {\n color: var(--del, #ee964b) !important;\n text-decoration: line-through !important;\n text-decoration-color: var(--del, #ee964b) !important;\n text-decoration-thickness: 1px !important;\n }\n\n /* Inline code */\n .overtype-wrapper .overtype-preview code {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n color: var(--code, #0d3b66) !important;\n padding: 0 !important;\n border-radius: 2px !important;\n font-family: inherit !important;\n font-size: inherit !important;\n line-height: inherit !important;\n font-weight: normal !important;\n }\n\n /* Code blocks - consolidated pre blocks */\n .overtype-wrapper .overtype-preview pre {\n padding: 0 !important;\n margin: 0 !important;\n border-radius: 4px !important;\n overflow-x: auto !important;\n }\n \n /* Code block styling in normal mode - yellow background */\n .overtype-wrapper .overtype-preview pre.code-block {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n white-space: break-spaces !important; /* Prevent horizontal scrollbar that breaks alignment */\n }\n\n /* Code inside pre blocks - remove background */\n .overtype-wrapper .overtype-preview pre code {\n background: transparent !important;\n color: var(--code, #0d3b66) !important;\n font-family: ${fontFamily} !important; /* Match textarea font exactly for alignment */\n }\n\n /* Blockquotes */\n .overtype-wrapper .overtype-preview .blockquote {\n color: var(--blockquote, #5a7a9b) !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n }\n\n /* Links */\n .overtype-wrapper .overtype-preview a {\n color: var(--link, #0d3b66) !important;\n text-decoration: underline !important;\n font-weight: normal !important;\n }\n\n .overtype-wrapper .overtype-preview a:hover {\n text-decoration: underline !important;\n color: var(--link, #0d3b66) !important;\n }\n\n /* Lists - no list styling */\n .overtype-wrapper .overtype-preview ul,\n .overtype-wrapper .overtype-preview ol {\n list-style: none !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n\n /* Horizontal rules */\n .overtype-wrapper .overtype-preview hr {\n border: none !important;\n color: var(--hr, #5a7a9b) !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n .overtype-wrapper .overtype-preview .hr-marker {\n color: var(--hr, #5a7a9b) !important;\n opacity: 0.6 !important;\n }\n\n /* Code fence markers - with background when not in code block */\n .overtype-wrapper .overtype-preview .code-fence {\n color: var(--code, #0d3b66) !important;\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n }\n \n /* Code block lines - background for entire code block */\n .overtype-wrapper .overtype-preview .code-block-line {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n }\n \n /* Remove background from code fence when inside code block line */\n .overtype-wrapper .overtype-preview .code-block-line .code-fence {\n background: transparent !important;\n }\n\n /* Raw markdown line */\n .overtype-wrapper .overtype-preview .raw-line {\n color: var(--raw-line, #5a7a9b) !important;\n font-style: normal !important;\n font-weight: normal !important;\n }\n\n /* Syntax markers */\n .overtype-wrapper .overtype-preview .syntax-marker {\n color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important;\n opacity: 0.7 !important;\n }\n\n /* List markers */\n .overtype-wrapper .overtype-preview .list-marker {\n color: var(--list-marker, #ee964b) !important;\n }\n\n /* Stats bar */\n \n /* Stats bar - positioned by flexbox */\n .overtype-stats {\n height: 40px !important;\n padding: 0 20px !important;\n background: #f8f9fa !important;\n border-top: 1px solid #e0e0e0 !important;\n display: flex !important;\n justify-content: space-between !important;\n align-items: center !important;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;\n font-size: 0.85rem !important;\n color: #666 !important;\n flex-shrink: 0 !important; /* Don't shrink */\n z-index: 10001 !important; /* Above link tooltip */\n position: relative !important; /* Enable z-index */\n }\n \n /* Dark theme stats bar */\n .overtype-container[data-theme=\"cave\"] .overtype-stats {\n background: var(--bg-secondary, #1D2D3E) !important;\n border-top: 1px solid rgba(197, 221, 232, 0.1) !important;\n color: var(--text, #c5dde8) !important;\n }\n \n .overtype-stats .overtype-stat {\n display: flex !important;\n align-items: center !important;\n gap: 5px !important;\n white-space: nowrap !important;\n }\n \n .overtype-stats .live-dot {\n width: 8px !important;\n height: 8px !important;\n background: #4caf50 !important;\n border-radius: 50% !important;\n animation: overtype-pulse 2s infinite !important;\n }\n \n @keyframes overtype-pulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.6; transform: scale(1.2); }\n }\n \n\n /* Toolbar Styles */\n .overtype-toolbar.overtype-toolbar-hidden {\n display: none !important;\n }\n\n .overtype-toolbar {\n display: flex !important;\n align-items: center !important;\n gap: 4px !important;\n padding: 8px !important; /* Override reset */\n background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */\n border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */\n overflow-x: auto !important; /* Allow horizontal scrolling */\n overflow-y: hidden !important; /* Hide vertical overflow */\n -webkit-overflow-scrolling: touch !important;\n flex-shrink: 0 !important;\n height: auto !important;\n position: relative !important; /* Override reset */\n z-index: 100 !important; /* Ensure toolbar is above wrapper */\n scrollbar-width: thin; /* Thin scrollbar on Firefox */\n }\n \n /* Thin scrollbar styling */\n .overtype-toolbar::-webkit-scrollbar {\n height: 4px;\n }\n \n .overtype-toolbar::-webkit-scrollbar-track {\n background: transparent;\n }\n \n .overtype-toolbar::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.2);\n border-radius: 2px;\n }\n\n .overtype-toolbar-button {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: var(--toolbar-icon, var(--text-secondary, #666));\n cursor: pointer;\n transition: all 0.2s ease;\n flex-shrink: 0;\n }\n\n .overtype-toolbar-button svg {\n width: 20px;\n height: 20px;\n fill: currentColor;\n }\n\n .overtype-toolbar-button:hover {\n background: var(--toolbar-hover, var(--bg-secondary, #e9ecef));\n color: var(--toolbar-icon, var(--text-primary, #333));\n }\n\n .overtype-toolbar-button:active {\n transform: scale(0.95);\n }\n\n .overtype-toolbar-button.active {\n background: var(--toolbar-active, var(--primary, #007bff));\n color: var(--toolbar-icon, var(--text-primary, #333));\n }\n\n .overtype-toolbar-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .overtype-toolbar-separator {\n width: 1px;\n height: 24px;\n background: var(--border, #e0e0e0);\n margin: 0 4px;\n flex-shrink: 0;\n }\n\n /* Adjust wrapper when toolbar is present */\n /* Mobile toolbar adjustments */\n @media (max-width: 640px) {\n .overtype-toolbar {\n padding: 6px;\n gap: 2px;\n }\n\n .overtype-toolbar-button {\n width: 36px;\n height: 36px;\n }\n\n .overtype-toolbar-separator {\n margin: 0 2px;\n }\n }\n \n /* Plain mode - hide preview and show textarea text */\n .overtype-container[data-mode=\"plain\"] .overtype-preview {\n display: none !important;\n }\n \n .overtype-container[data-mode=\"plain\"] .overtype-input {\n color: var(--text, #0d3b66) !important;\n /* Use system font stack for better plain text readability */\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \n \"Helvetica Neue\", Arial, sans-serif !important;\n }\n \n /* Ensure textarea remains transparent in overlay mode */\n .overtype-container:not([data-mode=\"plain\"]) .overtype-input {\n color: transparent !important;\n }\n\n /* Dropdown menu styles */\n .overtype-toolbar-button {\n position: relative !important; /* Override reset - needed for dropdown */\n }\n\n .overtype-toolbar-button.dropdown-active {\n background: var(--toolbar-active, var(--hover-bg, #f0f0f0));\n }\n\n .overtype-dropdown-menu {\n position: fixed !important; /* Fixed positioning relative to viewport */\n background: var(--bg-secondary, white) !important; /* Override reset */\n border: 1px solid var(--border, #e0e0e0) !important; /* Override reset */\n border-radius: 6px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* Override reset */\n z-index: 10000; /* Very high z-index to ensure visibility */\n min-width: 150px;\n padding: 4px 0 !important; /* Override reset */\n /* Position will be set via JavaScript based on button position */\n }\n\n .overtype-dropdown-item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: 8px 12px;\n border: none;\n background: none;\n text-align: left;\n cursor: pointer;\n font-size: 14px;\n color: var(--text, #333);\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n }\n\n .overtype-dropdown-item:hover {\n background: var(--hover-bg, #f0f0f0);\n }\n\n .overtype-dropdown-item.active {\n font-weight: 600;\n }\n\n .overtype-dropdown-check {\n width: 16px;\n margin-right: 8px;\n color: var(--h1, #007bff);\n }\n\n .overtype-dropdown-icon {\n width: 20px;\n margin-right: 8px;\n text-align: center;\n }\n\n /* Preview mode styles */\n .overtype-container[data-mode=\"preview\"] .overtype-input {\n display: none !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-preview {\n pointer-events: auto !important;\n user-select: text !important;\n cursor: text !important;\n }\n\n /* Hide syntax markers in preview mode */\n .overtype-container[data-mode=\"preview\"] .syntax-marker {\n display: none !important;\n }\n \n /* Hide URL part of links in preview mode - extra specificity */\n .overtype-container[data-mode=\"preview\"] .syntax-marker.url-part,\n .overtype-container[data-mode=\"preview\"] .url-part {\n display: none !important;\n }\n \n /* Hide all syntax markers inside links too */\n .overtype-container[data-mode=\"preview\"] a .syntax-marker {\n display: none !important;\n }\n\n /* Headers - restore proper sizing in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h1,\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h2,\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h3 {\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif !important;\n font-weight: 600 !important;\n margin: 0 !important;\n display: block !important;\n line-height: 1 !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h1 {\n font-size: 2em !important;\n color: var(--preview-h1, #222) !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h2 {\n font-size: 1.5em !important;\n color: var(--preview-h2, #333) !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview h3 {\n font-size: 1.17em !important;\n color: var(--preview-h3, #444) !important;\n }\n\n /* Lists - restore list styling in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview ul {\n display: block !important;\n list-style: disc !important;\n padding-left: 2em !important;\n margin: 1em 0 !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview ol {\n display: block !important;\n list-style: decimal !important;\n padding-left: 2em !important;\n margin: 1em 0 !important;\n }\n \n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview li {\n display: list-item !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n /* Task list checkboxes - only in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview li.task-list {\n list-style: none !important;\n position: relative !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview li.task-list input[type=\"checkbox\"] {\n margin-right: 0.5em !important;\n cursor: default !important;\n vertical-align: middle !important;\n }\n\n /* Task list in normal mode - keep syntax visible */\n .overtype-container:not([data-mode=\"preview\"]) .overtype-wrapper .overtype-preview li.task-list {\n list-style: none !important;\n }\n\n .overtype-container:not([data-mode=\"preview\"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker {\n color: var(--syntax, #999999) !important;\n font-weight: normal !important;\n }\n\n /* Links - make clickable in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview a {\n pointer-events: auto !important;\n cursor: pointer !important;\n color: var(--preview-link, #0066cc) !important;\n text-decoration: underline !important;\n }\n\n /* Code blocks - proper pre/code styling in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview pre.code-block {\n background: var(--preview-code-bg, rgba(135, 131, 120, 0.15)) !important;\n color: var(--preview-code, #333) !important;\n padding: 1.2em !important;\n border-radius: 3px !important;\n overflow-x: auto !important;\n margin: 0 !important;\n display: block !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview pre.code-block code {\n background: transparent !important;\n color: inherit !important;\n padding: 0 !important;\n font-family: ${fontFamily} !important;\n font-size: 0.9em !important;\n line-height: 1.4 !important;\n }\n\n /* Hide old code block lines and fences in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .code-block-line {\n display: none !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .code-fence {\n display: none !important;\n }\n\n /* Blockquotes - enhanced styling in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .blockquote {\n display: block !important;\n border-left: 4px solid var(--preview-blockquote, #666) !important;\n color: var(--preview-blockquote, #666) !important;\n padding-left: 1em !important;\n margin: 1em 0 !important;\n font-style: italic !important;\n }\n\n /* Typography improvements in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview {\n font-family: Georgia, 'Times New Roman', serif !important;\n font-size: 16px !important;\n line-height: 1.8 !important;\n color: var(--preview-text, #333) !important;\n background: var(--preview-bg, transparent) !important;\n }\n\n /* Inline code in preview mode - keep monospace */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview code {\n font-family: ${fontFamily} !important;\n font-size: 0.9em !important;\n background: var(--preview-code-bg, rgba(135, 131, 120, 0.15)) !important;\n color: var(--preview-code, #333) !important;\n padding: 0.2em 0.4em !important;\n border-radius: 3px !important;\n }\n\n /* Strong and em elements in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview strong {\n font-weight: 700 !important;\n color: var(--preview-strong, inherit) !important;\n }\n\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview em {\n font-style: italic !important;\n color: var(--preview-em, inherit) !important;\n }\n\n /* HR in preview mode */\n .overtype-container[data-mode=\"preview\"] .overtype-wrapper .overtype-preview .hr-marker {\n display: block !important;\n border-top: 2px solid var(--preview-hr, #ddd) !important;\n text-indent: -9999px !important;\n height: 2px !important;\n }\n\n /* Link Tooltip */\n .overtype-link-tooltip {\n background: #333 !important;\n color: white !important;\n padding: 6px 10px !important;\n border-radius: 16px !important;\n font-size: 12px !important;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;\n display: flex !important;\n visibility: hidden !important;\n pointer-events: none !important;\n z-index: 10000 !important;\n cursor: pointer !important;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;\n max-width: 300px !important;\n white-space: nowrap !important;\n overflow: hidden !important;\n text-overflow: ellipsis !important;\n position: fixed;\n top: 0;\n left: 0;\n }\n\n .overtype-link-tooltip.visible {\n visibility: visible !important;\n pointer-events: auto !important;\n }\n\n ${mobileStyles}\n `;\n}", "/**\n * Format definitions for markdown syntax\n */\n\nexport const FORMATS = {\n bold: {\n prefix: '**',\n suffix: '**',\n trimFirst: true\n },\n italic: {\n prefix: '_',\n suffix: '_',\n trimFirst: true\n },\n code: {\n prefix: '`',\n suffix: '`',\n blockPrefix: '```',\n blockSuffix: '```'\n },\n link: {\n prefix: '[',\n suffix: '](url)',\n replaceNext: 'url',\n scanFor: 'https?://'\n },\n bulletList: {\n prefix: '- ',\n multiline: true,\n unorderedList: true\n },\n numberedList: {\n prefix: '1. ',\n multiline: true,\n orderedList: true\n },\n quote: {\n prefix: '> ',\n multiline: true,\n surroundWithNewlines: true\n },\n taskList: {\n prefix: '- [ ] ',\n multiline: true,\n surroundWithNewlines: true\n },\n header1: { prefix: '# ' },\n header2: { prefix: '## ' },\n header3: { prefix: '### ' },\n header4: { prefix: '#### ' },\n header5: { prefix: '##### ' },\n header6: { prefix: '###### ' }\n}\n\n/**\n * Default style configuration\n */\nexport function getDefaultStyle() {\n return {\n prefix: '',\n suffix: '',\n blockPrefix: '',\n blockSuffix: '',\n multiline: false,\n replaceNext: '',\n prefixSpace: false,\n scanFor: '',\n surroundWithNewlines: false,\n orderedList: false,\n unorderedList: false,\n trimFirst: false\n }\n}\n\n/**\n * Merge format with defaults\n */\nexport function mergeWithDefaults(format) {\n return { ...getDefaultStyle(), ...format }\n}", "/**\n * Debug utilities for markdown-actions\n * Add console logging to track what's happening\n */\n\n// Debug mode flag - disabled by default\nlet debugMode = false;\n\n/**\n * Enable or disable debug mode\n * @param {boolean} enabled - Whether to enable debug mode\n */\nexport function setDebugMode(enabled) {\n debugMode = enabled;\n}\n\n/**\n * Get current debug mode status\n * @returns {boolean} Whether debug mode is enabled\n */\nexport function getDebugMode() {\n return debugMode;\n}\n\nexport function debugLog(funcName, message, data) {\n // These will be completely removed by esbuild's drop: ['console'] in production\n if (!debugMode) return;\n \n console.group(`\uD83D\uDD0D ${funcName}`);\n console.log(message);\n if (data) {\n console.log('Data:', data);\n }\n console.groupEnd();\n}\n\nexport function debugSelection(textarea, label) {\n // These will be completely removed by esbuild's drop: ['console'] in production\n if (!debugMode) return;\n \n const selected = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n console.group(`\uD83D\uDCCD Selection: ${label}`);\n console.log('Position:', `${textarea.selectionStart}-${textarea.selectionEnd}`);\n console.log('Selected text:', JSON.stringify(selected));\n console.log('Length:', selected.length);\n \n // Show context around selection\n const before = textarea.value.slice(Math.max(0, textarea.selectionStart - 10), textarea.selectionStart);\n const after = textarea.value.slice(textarea.selectionEnd, Math.min(textarea.value.length, textarea.selectionEnd + 10));\n console.log('Context:', JSON.stringify(before) + '[SELECTION]' + JSON.stringify(after));\n console.groupEnd();\n}\n\nexport function debugResult(result) {\n // These will be completely removed by esbuild's drop: ['console'] in production\n if (!debugMode) return;\n \n console.group('\uD83D\uDCDD Result');\n console.log('Text to insert:', JSON.stringify(result.text));\n console.log('New selection:', `${result.selectionStart}-${result.selectionEnd}`);\n console.groupEnd();\n}", "/**\n * Text insertion system with undo/redo support\n * Extracted and adapted from GitHub's markdown-toolbar-element\n */\n\nimport { getDebugMode } from '../debug.js'\n\nlet canInsertText = null\n\n/**\n * Insert text at current position with undo/redo support\n * @param {HTMLTextAreaElement} textarea - Target textarea\n * @param {Object} options - Text and selection options\n * @param {string} options.text - Text to insert\n * @param {number} [options.selectionStart] - New selection start\n * @param {number} [options.selectionEnd] - New selection end\n */\nexport function insertText(textarea, { text, selectionStart, selectionEnd }) {\n const debugMode = getDebugMode();\n \n if (debugMode) {\n console.group('\uD83D\uDD27 insertText');\n console.log('Current selection:', `${textarea.selectionStart}-${textarea.selectionEnd}`);\n console.log('Text to insert:', JSON.stringify(text));\n console.log('New selection to set:', selectionStart, '-', selectionEnd);\n }\n \n // Make sure the textarea is focused\n textarea.focus();\n \n const originalSelectionStart = textarea.selectionStart\n const originalSelectionEnd = textarea.selectionEnd\n const before = textarea.value.slice(0, originalSelectionStart)\n const after = textarea.value.slice(originalSelectionEnd)\n \n if (debugMode) {\n console.log('Before text (last 20):', JSON.stringify(before.slice(-20)));\n console.log('After text (first 20):', JSON.stringify(after.slice(0, 20)));\n console.log('Selected text being replaced:', JSON.stringify(textarea.value.slice(originalSelectionStart, originalSelectionEnd)));\n }\n \n // Store the original value to check if execCommand actually changed it\n const originalValue = textarea.value\n\n // Try execCommand for both insertions and replacements to preserve undo history\n // execCommand('insertText') can handle replacing selected text\n const hasSelection = originalSelectionStart !== originalSelectionEnd\n \n if (canInsertText === null || canInsertText === true) {\n textarea.contentEditable = 'true'\n try {\n canInsertText = document.execCommand('insertText', false, text)\n if (debugMode) console.log('execCommand returned:', canInsertText, 'for text with', text.split('\\n').length, 'lines');\n } catch (error) {\n canInsertText = false\n if (debugMode) console.log('execCommand threw error:', error);\n }\n textarea.contentEditable = 'false'\n }\n\n if (debugMode) {\n console.log('canInsertText before:', canInsertText);\n console.log('execCommand result:', canInsertText);\n }\n \n // Check if execCommand actually worked by comparing the value\n if (canInsertText) {\n const expectedValue = before + text + after\n const actualValue = textarea.value\n \n if (debugMode) {\n console.log('Expected length:', expectedValue.length);\n console.log('Actual length:', actualValue.length);\n }\n \n if (actualValue !== expectedValue) {\n if (debugMode) {\n console.log('execCommand changed the value but not as expected');\n console.log('Expected:', JSON.stringify(expectedValue.slice(0, 100)));\n console.log('Actual:', JSON.stringify(actualValue.slice(0, 100)));\n }\n // Don't set canInsertText to false here - execCommand did work\n // We just need to not double-insert\n }\n }\n\n if (!canInsertText) {\n if (debugMode) console.log('Using manual insertion');\n // Only do manual insertion if execCommand didn't change the value\n if (textarea.value === originalValue) {\n if (debugMode) console.log('Value unchanged, doing manual replacement');\n try {\n document.execCommand('ms-beginUndoUnit')\n } catch (e) {\n // Do nothing.\n }\n textarea.value = before + text + after\n try {\n document.execCommand('ms-endUndoUnit')\n } catch (e) {\n // Do nothing.\n }\n textarea.dispatchEvent(new CustomEvent('input', { bubbles: true, cancelable: true }))\n } else {\n if (debugMode) console.log('Value was changed by execCommand, skipping manual insertion');\n }\n }\n\n if (debugMode) console.log('Setting selection range:', selectionStart, selectionEnd);\n if (selectionStart != null && selectionEnd != null) {\n textarea.setSelectionRange(selectionStart, selectionEnd)\n } else {\n textarea.setSelectionRange(originalSelectionStart, textarea.selectionEnd)\n }\n \n if (debugMode) {\n console.log('Final value length:', textarea.value.length);\n console.groupEnd();\n }\n}\n\n/**\n * Configure undo method\n * @param {'native' | 'manual' | 'auto'} method - Undo method to use\n */\nexport function setUndoMethod(method) {\n switch (method) {\n case 'native':\n canInsertText = true\n break\n case 'manual':\n canInsertText = false\n break\n case 'auto':\n canInsertText = null\n break\n }\n}", "/**\n * Core selection utilities extracted and adapted from GitHub's markdown-toolbar-element\n */\n\n/**\n * Check if string contains multiple lines\n */\nexport function isMultipleLines(string) {\n return string.trim().split('\\n').length > 1\n}\n\n/**\n * Find the start of the word at position i\n */\nexport function wordSelectionStart(text, i) {\n let index = i\n while (text[index] && text[index - 1] != null && !text[index - 1].match(/\\s/)) {\n index--\n }\n return index\n}\n\n/**\n * Find the end of the word at position i\n */\nexport function wordSelectionEnd(text, i, multiline) {\n let index = i\n const breakpoint = multiline ? /\\n/ : /\\s/\n while (text[index] && !text[index].match(breakpoint)) {\n index++\n }\n return index\n}\n\n/**\n * Expand selection to line boundaries\n */\nexport function expandSelectionToLine(textarea) {\n const lines = textarea.value.split('\\n')\n let counter = 0\n for (let index = 0; index < lines.length; index++) {\n const lineLength = lines[index].length + 1\n if (textarea.selectionStart >= counter && textarea.selectionStart < counter + lineLength) {\n textarea.selectionStart = counter\n }\n if (textarea.selectionEnd >= counter && textarea.selectionEnd < counter + lineLength) {\n // For the last line, don't go past the actual text length\n if (index === lines.length - 1) {\n textarea.selectionEnd = Math.min(counter + lines[index].length, textarea.value.length)\n } else {\n textarea.selectionEnd = counter + lineLength - 1\n }\n }\n counter += lineLength\n }\n}\n\n/**\n * Expand selected text with smart boundary detection\n */\nexport function expandSelectedText(textarea, prefixToUse, suffixToUse, multiline = false) {\n if (textarea.selectionStart === textarea.selectionEnd) {\n textarea.selectionStart = wordSelectionStart(textarea.value, textarea.selectionStart)\n textarea.selectionEnd = wordSelectionEnd(textarea.value, textarea.selectionEnd, multiline)\n } else {\n const expandedSelectionStart = textarea.selectionStart - prefixToUse.length\n const expandedSelectionEnd = textarea.selectionEnd + suffixToUse.length\n const beginsWithPrefix = textarea.value.slice(expandedSelectionStart, textarea.selectionStart) === prefixToUse\n const endsWithSuffix = textarea.value.slice(textarea.selectionEnd, expandedSelectionEnd) === suffixToUse\n if (beginsWithPrefix && endsWithSuffix) {\n textarea.selectionStart = expandedSelectionStart\n textarea.selectionEnd = expandedSelectionEnd\n }\n }\n return textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n}\n\n/**\n * Calculate newlines needed to surround selected text\n */\nexport function newlinesToSurroundSelectedText(textarea) {\n const beforeSelection = textarea.value.slice(0, textarea.selectionStart)\n const afterSelection = textarea.value.slice(textarea.selectionEnd)\n\n const breaksBefore = beforeSelection.match(/\\n*$/)\n const breaksAfter = afterSelection.match(/^\\n*/)\n const newlinesBeforeSelection = breaksBefore ? breaksBefore[0].length : 0\n const newlinesAfterSelection = breaksAfter ? breaksAfter[0].length : 0\n\n let newlinesToAppend = ''\n let newlinesToPrepend = ''\n\n if (beforeSelection.match(/\\S/) && newlinesBeforeSelection < 2) {\n newlinesToAppend = '\\n'.repeat(2 - newlinesBeforeSelection)\n }\n\n if (afterSelection.match(/\\S/) && newlinesAfterSelection < 2) {\n newlinesToPrepend = '\\n'.repeat(2 - newlinesAfterSelection)\n }\n\n return { newlinesToAppend, newlinesToPrepend }\n}\n\n/**\n * Utility to preserve selection during operations\n */\nexport function preserveSelection(textarea, callback) {\n const start = textarea.selectionStart\n const end = textarea.selectionEnd\n const scrollTop = textarea.scrollTop\n \n callback()\n \n textarea.selectionStart = start\n textarea.selectionEnd = end\n textarea.scrollTop = scrollTop\n}\n\n/**\n * Apply a line-based operation with cursor preservation\n * This function handles expanding to line boundaries and preserving cursor position\n * @param {HTMLTextAreaElement} textarea - The textarea element\n * @param {Function} operation - The operation to perform (receives textarea and returns result)\n * @param {Object} options - Options for the operation\n * @param {string} options.prefix - The prefix being added/removed (for cursor adjustment)\n * @param {Function} options.adjustSelection - Custom selection adjustment function\n * @returns {Object} The result from the operation with adjusted cursor position\n */\nexport function applyLineOperation(textarea, operation, options = {}) {\n // Save original cursor position AND selection before any expansion\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n const noInitialSelection = originalStart === originalEnd\n \n // Store the line start position to calculate offset later\n const value = textarea.value\n let lineStart = originalStart\n \n // Find start of the line containing the selection start\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n \n // Expand selection to line boundaries for the operation\n if (noInitialSelection) {\n // Expand to current line when no selection\n let lineEnd = originalStart\n \n // Find end of current line\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n } else {\n // For selections, expand to full lines\n expandSelectionToLine(textarea)\n }\n \n // Apply the operation\n const result = operation(textarea)\n \n // Restore original selection/cursor with prefix adjustment\n if (options.adjustSelection) {\n // Use custom selection adjustment logic\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const isRemoving = selectedText.startsWith(options.prefix)\n const adjusted = options.adjustSelection(isRemoving, originalStart, originalEnd, lineStart)\n result.selectionStart = adjusted.start\n result.selectionEnd = adjusted.end\n } else if (options.prefix) {\n // Use default prefix-based adjustment\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const isRemoving = selectedText.startsWith(options.prefix)\n \n if (noInitialSelection) {\n // No selection - just restore cursor position\n if (isRemoving) {\n // When removing prefix, adjust cursor position\n result.selectionStart = Math.max(originalStart - options.prefix.length, lineStart)\n result.selectionEnd = result.selectionStart\n } else {\n // When adding prefix, adjust cursor position\n result.selectionStart = originalStart + options.prefix.length\n result.selectionEnd = result.selectionStart\n }\n } else {\n // Had a selection - restore it with adjustment\n if (isRemoving) {\n // When removing prefix, shift selection back\n result.selectionStart = Math.max(originalStart - options.prefix.length, lineStart)\n result.selectionEnd = Math.max(originalEnd - options.prefix.length, lineStart)\n } else {\n // When adding prefix, shift selection forward\n result.selectionStart = originalStart + options.prefix.length\n result.selectionEnd = originalEnd + options.prefix.length\n }\n }\n }\n \n return result\n}", "/**\n * Block-level text formatting operations\n * Handles inline formats like bold, italic, code, and links\n */\n\nimport { expandSelectedText, newlinesToSurroundSelectedText, isMultipleLines } from '../core/selection.js'\nimport { insertText } from '../core/insertion.js'\n\n/**\n * Apply block-level styling to selected text\n */\nexport function blockStyle(textarea, style) {\n let newlinesToAppend\n let newlinesToPrepend\n\n const { prefix, suffix, blockPrefix, blockSuffix, replaceNext, prefixSpace, scanFor, surroundWithNewlines, trimFirst } = style\n const originalSelectionStart = textarea.selectionStart\n const originalSelectionEnd = textarea.selectionEnd\n\n let selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let prefixToUse = isMultipleLines(selectedText) && blockPrefix && blockPrefix.length > 0 ? `${blockPrefix}\\n` : prefix\n let suffixToUse = isMultipleLines(selectedText) && blockSuffix && blockSuffix.length > 0 ? `\\n${blockSuffix}` : suffix\n\n if (prefixSpace) {\n const beforeSelection = textarea.value[textarea.selectionStart - 1]\n if (textarea.selectionStart !== 0 && beforeSelection != null && !beforeSelection.match(/\\s/)) {\n prefixToUse = ` ${prefixToUse}`\n }\n }\n \n selectedText = expandSelectedText(textarea, prefixToUse, suffixToUse, style.multiline)\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n const hasReplaceNext = replaceNext && replaceNext.length > 0 && suffixToUse.indexOf(replaceNext) > -1 && selectedText.length > 0\n \n if (surroundWithNewlines) {\n const ref = newlinesToSurroundSelectedText(textarea)\n newlinesToAppend = ref.newlinesToAppend\n newlinesToPrepend = ref.newlinesToPrepend\n prefixToUse = newlinesToAppend + prefix\n suffixToUse += newlinesToPrepend\n }\n\n // Check if we should remove formatting (toggle off)\n if (selectedText.startsWith(prefixToUse) && selectedText.endsWith(suffixToUse)) {\n const replacementText = selectedText.slice(prefixToUse.length, selectedText.length - suffixToUse.length)\n if (originalSelectionStart === originalSelectionEnd) {\n let position = originalSelectionStart - prefixToUse.length\n position = Math.max(position, selectionStart)\n position = Math.min(position, selectionStart + replacementText.length)\n selectionStart = selectionEnd = position\n } else {\n selectionEnd = selectionStart + replacementText.length\n }\n return { text: replacementText, selectionStart, selectionEnd }\n } else if (!hasReplaceNext) {\n // Add formatting\n let replacementText = prefixToUse + selectedText + suffixToUse\n selectionStart = originalSelectionStart + prefixToUse.length\n selectionEnd = originalSelectionEnd + prefixToUse.length\n const whitespaceEdges = selectedText.match(/^\\s*|\\s*$/g)\n if (trimFirst && whitespaceEdges) {\n const leadingWhitespace = whitespaceEdges[0] || ''\n const trailingWhitespace = whitespaceEdges[1] || ''\n replacementText = leadingWhitespace + prefixToUse + selectedText.trim() + suffixToUse + trailingWhitespace\n selectionStart += leadingWhitespace.length\n selectionEnd -= trailingWhitespace.length\n }\n return { text: replacementText, selectionStart, selectionEnd }\n } else if (scanFor && scanFor.length > 0 && selectedText.match(scanFor)) {\n // Handle link/image with URL detection\n suffixToUse = suffixToUse.replace(replaceNext, selectedText)\n const replacementText = prefixToUse + suffixToUse\n selectionStart = selectionEnd = selectionStart + prefixToUse.length\n return { text: replacementText, selectionStart, selectionEnd }\n } else {\n // Handle link/image with placeholder\n const replacementText = prefixToUse + selectedText + suffixToUse\n selectionStart = selectionStart + prefixToUse.length + selectedText.length + suffixToUse.indexOf(replaceNext)\n selectionEnd = selectionStart + replaceNext.length\n return { text: replacementText, selectionStart, selectionEnd }\n }\n}\n\n/**\n * Apply style to selected text in textarea\n */\nexport function styleSelectedText(textarea, style) {\n const text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n \n let result\n if (style.orderedList || style.unorderedList) {\n // Will be handled by list operations\n return\n } else if (style.multiline && isMultipleLines(text)) {\n result = multilineStyle(textarea, style)\n } else {\n result = blockStyle(textarea, style)\n }\n\n insertText(textarea, result)\n}\n\n/**\n * Apply multiline styling (quotes, task lists, etc)\n * Note: This does NOT expand selection to line - that should be done by the caller if needed\n */\nexport function multilineStyle(textarea, style) {\n const { prefix, suffix, surroundWithNewlines } = style\n let text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n const lines = text.split('\\n')\n \n // Check if we need to undo (all lines have the format)\n const undoStyle = lines.every(line => line.startsWith(prefix) && (!suffix || line.endsWith(suffix)))\n\n if (undoStyle) {\n // Remove the formatting\n text = lines.map(line => {\n let result = line.slice(prefix.length)\n if (suffix) {\n result = result.slice(0, result.length - suffix.length)\n }\n return result\n }).join('\\n')\n selectionEnd = selectionStart + text.length\n } else {\n // Apply the formatting\n text = lines.map(line => prefix + line + (suffix || '')).join('\\n')\n if (surroundWithNewlines) {\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea)\n selectionStart += newlinesToAppend.length\n selectionEnd = selectionStart + text.length\n text = newlinesToAppend + text + newlinesToPrepend\n }\n }\n\n return { text, selectionStart, selectionEnd }\n}", "/**\n * List operations for bullet and numbered lists\n */\n\nimport { expandSelectionToLine, newlinesToSurroundSelectedText, applyLineOperation } from '../core/selection.js'\nimport { insertText } from '../core/insertion.js'\n\n/**\n * Undo ordered list formatting\n */\nfunction undoOrderedListStyle(text) {\n const lines = text.split('\\n')\n const orderedListRegex = /^\\d+\\.\\s+/\n const shouldUndoOrderedList = lines.every(line => orderedListRegex.test(line))\n let result = lines\n if (shouldUndoOrderedList) {\n result = lines.map(line => line.replace(orderedListRegex, ''))\n }\n\n return {\n text: result.join('\\n'),\n processed: shouldUndoOrderedList\n }\n}\n\n/**\n * Undo unordered list formatting\n */\nfunction undoUnorderedListStyle(text) {\n const lines = text.split('\\n')\n const unorderedListPrefix = '- '\n const shouldUndoUnorderedList = lines.every(line => line.startsWith(unorderedListPrefix))\n let result = lines\n if (shouldUndoUnorderedList) {\n result = lines.map(line => line.slice(unorderedListPrefix.length))\n }\n\n return {\n text: result.join('\\n'),\n processed: shouldUndoUnorderedList\n }\n}\n\n/**\n * Make prefix for list item\n */\nfunction makePrefix(index, unorderedList) {\n if (unorderedList) {\n return '- '\n } else {\n return `${index + 1}. `\n }\n}\n\n/**\n * Clear existing list style\n */\nfunction clearExistingListStyle(style, selectedText) {\n let undoResult\n let undoResultOppositeList\n let pristineText\n \n if (style.orderedList) {\n undoResult = undoOrderedListStyle(selectedText)\n undoResultOppositeList = undoUnorderedListStyle(undoResult.text)\n pristineText = undoResultOppositeList.text\n } else {\n undoResult = undoUnorderedListStyle(selectedText)\n undoResultOppositeList = undoOrderedListStyle(undoResult.text)\n pristineText = undoResultOppositeList.text\n }\n \n return [undoResult, undoResultOppositeList, pristineText]\n}\n\n/**\n * Apply list styling to selected text\n */\nexport function listStyle(textarea, style) {\n const noInitialSelection = textarea.selectionStart === textarea.selectionEnd\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n\n // Select whole line\n expandSelectionToLine(textarea)\n\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n\n // Clear any existing list formatting\n const [undoResult, undoResultOppositeList, pristineText] = clearExistingListStyle(style, selectedText)\n\n const prefixedLines = pristineText.split('\\n').map((value, index) => {\n return `${makePrefix(index, style.unorderedList)}${value}`\n })\n\n const totalPrefixLength = prefixedLines.reduce((previousValue, _currentValue, currentIndex) => {\n return previousValue + makePrefix(currentIndex, style.unorderedList).length\n }, 0)\n\n const totalPrefixLengthOppositeList = prefixedLines.reduce((previousValue, _currentValue, currentIndex) => {\n return previousValue + makePrefix(currentIndex, !style.unorderedList).length\n }, 0)\n\n // If we're undoing the same list type, just return the pristine text\n if (undoResult.processed) {\n if (noInitialSelection) {\n selectionStart = Math.max(selectionStart - makePrefix(0, style.unorderedList).length, 0)\n selectionEnd = selectionStart\n } else {\n selectionStart = textarea.selectionStart\n selectionEnd = textarea.selectionEnd - totalPrefixLength\n }\n return { text: pristineText, selectionStart, selectionEnd }\n }\n\n // Apply new list formatting\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea)\n const text = newlinesToAppend + prefixedLines.join('\\n') + newlinesToPrepend\n\n if (noInitialSelection) {\n selectionStart = Math.max(selectionStart + makePrefix(0, style.unorderedList).length + newlinesToAppend.length, 0)\n selectionEnd = selectionStart\n } else {\n if (undoResultOppositeList.processed) {\n // Converting from one list type to another\n selectionStart = Math.max(textarea.selectionStart + newlinesToAppend.length, 0)\n selectionEnd = textarea.selectionEnd + newlinesToAppend.length + totalPrefixLength - totalPrefixLengthOppositeList\n } else {\n // Adding list formatting to plain text\n selectionStart = Math.max(textarea.selectionStart + newlinesToAppend.length, 0)\n selectionEnd = textarea.selectionEnd + newlinesToAppend.length + totalPrefixLength\n }\n }\n\n return { text, selectionStart, selectionEnd }\n}\n\n/**\n * Apply list style to textarea\n */\nexport function applyListStyle(textarea, style) {\n // Use applyLineOperation for consistent selection preservation\n const result = applyLineOperation(\n textarea,\n (ta) => listStyle(ta, style),\n {\n // Custom selection adjustment for lists\n adjustSelection: (isRemoving, selStart, selEnd, lineStart) => {\n // Get the current line to check if we're removing\n const currentLine = textarea.value.slice(lineStart, textarea.selectionEnd)\n const orderedListRegex = /^\\d+\\.\\s+/\n const unorderedListRegex = /^- /\n \n // Check if we're removing a list\n const hasOrderedList = orderedListRegex.test(currentLine)\n const hasUnorderedList = unorderedListRegex.test(currentLine)\n const isRemovingCurrent = (style.orderedList && hasOrderedList) || (style.unorderedList && hasUnorderedList)\n \n if (selStart === selEnd) {\n // No selection - cursor position\n if (isRemovingCurrent) {\n // Removing list - adjust cursor back\n const prefixMatch = currentLine.match(style.orderedList ? orderedListRegex : unorderedListRegex)\n const prefixLength = prefixMatch ? prefixMatch[0].length : 0\n return {\n start: Math.max(selStart - prefixLength, lineStart),\n end: Math.max(selStart - prefixLength, lineStart)\n }\n } else if (hasOrderedList || hasUnorderedList) {\n // Converting from one list type to another\n const oldPrefixMatch = currentLine.match(hasOrderedList ? orderedListRegex : unorderedListRegex)\n const oldPrefixLength = oldPrefixMatch ? oldPrefixMatch[0].length : 0\n const newPrefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n const adjustment = newPrefixLength - oldPrefixLength\n return {\n start: selStart + adjustment,\n end: selStart + adjustment\n }\n } else {\n // Adding new list\n const prefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n return {\n start: selStart + prefixLength,\n end: selStart + prefixLength\n }\n }\n } else {\n // Has selection - preserve it\n if (isRemovingCurrent) {\n // Removing current list type\n const prefixMatch = currentLine.match(style.orderedList ? orderedListRegex : unorderedListRegex)\n const prefixLength = prefixMatch ? prefixMatch[0].length : 0\n return {\n start: Math.max(selStart - prefixLength, lineStart),\n end: Math.max(selEnd - prefixLength, lineStart)\n }\n } else if (hasOrderedList || hasUnorderedList) {\n // Converting from one list type to another\n const oldPrefixMatch = currentLine.match(hasOrderedList ? orderedListRegex : unorderedListRegex)\n const oldPrefixLength = oldPrefixMatch ? oldPrefixMatch[0].length : 0\n const newPrefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n const adjustment = newPrefixLength - oldPrefixLength\n return {\n start: selStart + adjustment,\n end: selEnd + adjustment\n }\n } else {\n // Adding new list\n const prefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n return {\n start: selStart + prefixLength,\n end: selEnd + prefixLength\n }\n }\n }\n }\n }\n )\n \n insertText(textarea, result)\n}", "/**\n * Format detection utilities\n */\n\nimport { FORMATS } from './formats.js'\n\n/**\n * Check if text has a specific format applied\n */\nfunction hasFormatApplied(text, format) {\n if (!format.prefix) return false\n \n if (format.suffix) {\n return text.startsWith(format.prefix) && text.endsWith(format.suffix)\n } else {\n return text.startsWith(format.prefix)\n }\n}\n\n/**\n * Get active formats at cursor position\n */\nexport function getActiveFormats(textarea) {\n if (!textarea) return []\n \n const formats = []\n const { selectionStart, selectionEnd, value } = textarea\n \n // Get current line for line-based formats\n const lines = value.split('\\n')\n let lineStart = 0\n let currentLine = ''\n \n for (const line of lines) {\n if (selectionStart >= lineStart && selectionStart <= lineStart + line.length) {\n currentLine = line\n break\n }\n lineStart += line.length + 1\n }\n \n // Check line-based formats\n if (currentLine.startsWith('- ')) {\n if (currentLine.startsWith('- [ ] ') || currentLine.startsWith('- [x] ')) {\n formats.push('task-list')\n } else {\n formats.push('bullet-list')\n }\n }\n \n if (/^\\d+\\.\\s/.test(currentLine)) {\n formats.push('numbered-list')\n }\n \n if (currentLine.startsWith('> ')) {\n formats.push('quote')\n }\n \n if (currentLine.startsWith('# ')) formats.push('header')\n if (currentLine.startsWith('## ')) formats.push('header-2')\n if (currentLine.startsWith('### ')) formats.push('header-3')\n \n // Check inline formats by looking around cursor\n const lookBehind = Math.max(0, selectionStart - 10)\n const lookAhead = Math.min(value.length, selectionEnd + 10)\n const surrounding = value.slice(lookBehind, lookAhead)\n \n // Check for bold\n if (surrounding.includes('**')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenBold = beforeCursor.lastIndexOf('**')\n const nextCloseBold = afterCursor.indexOf('**')\n if (lastOpenBold !== -1 && nextCloseBold !== -1) {\n formats.push('bold')\n }\n }\n \n // Check for italic\n if (surrounding.includes('_')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenItalic = beforeCursor.lastIndexOf('_')\n const nextCloseItalic = afterCursor.indexOf('_')\n if (lastOpenItalic !== -1 && nextCloseItalic !== -1) {\n formats.push('italic')\n }\n }\n \n // Check for code\n if (surrounding.includes('`')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n if (beforeCursor.includes('`') && afterCursor.includes('`')) {\n formats.push('code')\n }\n }\n \n // Check for link\n if (surrounding.includes('[') && surrounding.includes(']')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenBracket = beforeCursor.lastIndexOf('[')\n const nextCloseBracket = afterCursor.indexOf(']')\n if (lastOpenBracket !== -1 && nextCloseBracket !== -1) {\n const afterBracket = value.slice(selectionEnd + nextCloseBracket + 1, selectionEnd + nextCloseBracket + 10)\n if (afterBracket.startsWith('(')) {\n formats.push('link')\n }\n }\n }\n \n return formats\n}\n\n/**\n * Check if specific format is active at cursor\n */\nexport function hasFormat(textarea, format) {\n const activeFormats = getActiveFormats(textarea)\n return activeFormats.includes(format)\n}\n\n/**\n * Expand selection based on options\n */\nexport function expandSelection(textarea, options = {}) {\n if (!textarea) return\n \n const { toWord, toLine, toFormat } = options\n const { selectionStart, selectionEnd, value } = textarea\n \n if (toLine) {\n // Find line boundaries\n const lines = value.split('\\n')\n let lineStart = 0\n let lineEnd = 0\n let currentPos = 0\n \n for (const line of lines) {\n if (selectionStart >= currentPos && selectionStart <= currentPos + line.length) {\n lineStart = currentPos\n lineEnd = currentPos + line.length\n break\n }\n currentPos += line.length + 1\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n } else if (toWord && selectionStart === selectionEnd) {\n // Find word boundaries\n let start = selectionStart\n let end = selectionEnd\n \n // Move start back to word boundary\n while (start > 0 && !/\\s/.test(value[start - 1])) {\n start--\n }\n \n // Move end forward to word boundary\n while (end < value.length && !/\\s/.test(value[end])) {\n end++\n }\n \n textarea.selectionStart = start\n textarea.selectionEnd = end\n }\n}", "/**\n * markdown-actions - Lightweight markdown toolbar functionality\n * Based on GitHub's markdown-toolbar-element\n */\n\nimport { FORMATS, mergeWithDefaults } from './core/formats.js'\nimport { insertText, setUndoMethod } from './core/insertion.js'\nimport { preserveSelection, isMultipleLines, expandSelectionToLine, applyLineOperation } from './core/selection.js'\nimport { blockStyle, multilineStyle } from './operations/block.js'\nimport { applyListStyle } from './operations/list.js'\nimport { getActiveFormats as getActive, hasFormat as has, expandSelection as expand } from './core/detection.js'\nimport { debugLog, debugSelection, debugResult, setDebugMode, getDebugMode } from './debug.js'\n\n/**\n * Toggle bold formatting\n */\nexport function toggleBold(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n debugLog('toggleBold', 'Starting');\n debugSelection(textarea, 'Before');\n \n const style = mergeWithDefaults(FORMATS.bold)\n const result = blockStyle(textarea, style)\n \n debugResult(result);\n \n insertText(textarea, result)\n \n debugSelection(textarea, 'After');\n}\n\n/**\n * Toggle italic formatting\n */\nexport function toggleItalic(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.italic)\n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Toggle code formatting\n */\nexport function toggleCode(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n // blockStyle already handles both inline and block code correctly\n const style = mergeWithDefaults(FORMATS.code)\n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Insert or toggle link formatting\n */\nexport function insertLink(textarea, options = {}) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let style = mergeWithDefaults(FORMATS.link)\n \n // Check if selected text is a URL\n const isURL = selectedText && selectedText.match(/^https?:\\/\\//)\n \n if (isURL && !options.url) {\n // If selected text is a URL, use it as both link text and URL\n style.suffix = `](${selectedText})`\n style.replaceNext = ''\n // Don't change the selected text, it becomes the link text\n } else if (options.url) {\n // Override with custom URL if provided\n style.suffix = `](${options.url})`\n style.replaceNext = ''\n }\n \n // Override with custom text if provided\n if (options.text && !selectedText) {\n // Insert the text and select it\n const pos = textarea.selectionStart\n textarea.value = textarea.value.slice(0, pos) + options.text + textarea.value.slice(pos)\n textarea.selectionStart = pos\n textarea.selectionEnd = pos + options.text.length\n }\n \n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Toggle bullet list formatting\n */\nexport function toggleBulletList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.bulletList)\n applyListStyle(textarea, style)\n}\n\n/**\n * Toggle numbered list formatting\n */\nexport function toggleNumberedList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.numberedList)\n applyListStyle(textarea, style)\n}\n\n/**\n * Toggle quote formatting\n * Matches GitHub's implementation for quotes\n */\nexport function toggleQuote(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n debugLog('toggleQuote', 'Starting');\n debugSelection(textarea, 'Initial');\n \n const style = mergeWithDefaults(FORMATS.quote)\n \n // Use the reusable line operation helper\n const result = applyLineOperation(\n textarea,\n (ta) => multilineStyle(ta, style),\n { prefix: style.prefix }\n )\n \n debugResult(result);\n insertText(textarea, result)\n debugSelection(textarea, 'Final');\n}\n\n/**\n * Toggle task list formatting\n * Matches GitHub's implementation for task lists\n */\nexport function toggleTaskList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const style = mergeWithDefaults(FORMATS.taskList)\n \n // Use the reusable line operation helper\n const result = applyLineOperation(\n textarea,\n (ta) => multilineStyle(ta, style),\n { prefix: style.prefix }\n )\n \n insertText(textarea, result)\n}\n\n/**\n * Insert or toggle header with specific level\n */\nexport function insertHeader(textarea, level = 1, toggle = false) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n if (level < 1 || level > 6) level = 1\n \n debugLog('insertHeader', `============ START ============`);\n debugLog('insertHeader', `Level: ${level}, Toggle: ${toggle}`);\n debugLog('insertHeader', `Initial cursor: ${textarea.selectionStart}-${textarea.selectionEnd}`);\n \n const headerKey = `header${level === 1 ? '1' : level}`\n const style = mergeWithDefaults(FORMATS[headerKey] || FORMATS.header1)\n debugLog('insertHeader', `Style prefix: \"${style.prefix}\"`);\n \n // Save original positions and get line info BEFORE applyLineOperation\n const value = textarea.value\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n \n // Find the current line boundaries to check existing header\n let lineStart = originalStart\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n let lineEnd = originalEnd\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n // Get current line and check for existing header\n const currentLineContent = value.slice(lineStart, lineEnd)\n debugLog('insertHeader', `Current line (before): \"${currentLineContent}\"`);\n \n const existingHeaderMatch = currentLineContent.match(/^(#{1,6})\\s*/)\n const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0\n const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0\n \n debugLog('insertHeader', `Existing header check:`);\n debugLog('insertHeader', ` - Match: ${existingHeaderMatch ? `\"${existingHeaderMatch[0]}\"` : 'none'}`);\n debugLog('insertHeader', ` - Existing level: ${existingLevel}`);\n debugLog('insertHeader', ` - Existing prefix length: ${existingPrefixLength}`);\n debugLog('insertHeader', ` - Target level: ${level}`);\n \n // Determine if we're toggling off\n const shouldToggleOff = toggle && existingLevel === level\n debugLog('insertHeader', `Should toggle OFF: ${shouldToggleOff} (toggle=${toggle}, existingLevel=${existingLevel}, level=${level})`);\n \n // Use applyLineOperation for consistent behavior\n const result = applyLineOperation(\n textarea,\n (ta) => {\n const currentLine = ta.value.slice(ta.selectionStart, ta.selectionEnd)\n debugLog('insertHeader', `Line in operation: \"${currentLine}\"`);\n \n // Remove any existing header formatting\n const cleanedLine = currentLine.replace(/^#{1,6}\\s*/, '')\n debugLog('insertHeader', `Cleaned line: \"${cleanedLine}\"`);\n \n let newLine\n \n if (shouldToggleOff) {\n // Toggle off - just use the cleaned line\n debugLog('insertHeader', 'ACTION: Toggling OFF - removing header');\n newLine = cleanedLine\n } else if (existingLevel > 0) {\n // Replace existing header with new one\n debugLog('insertHeader', `ACTION: Replacing H${existingLevel} with H${level}`);\n newLine = style.prefix + cleanedLine\n } else {\n // Add new header\n debugLog('insertHeader', 'ACTION: Adding new header');\n newLine = style.prefix + cleanedLine\n }\n \n debugLog('insertHeader', `New line: \"${newLine}\"`);\n \n return {\n text: newLine,\n selectionStart: ta.selectionStart,\n selectionEnd: ta.selectionEnd\n }\n },\n {\n prefix: style.prefix,\n // Custom selection adjustment for headers\n adjustSelection: (isRemoving, selStart, selEnd, lineStartPos) => {\n debugLog('insertHeader', `Adjusting selection:`);\n debugLog('insertHeader', ` - isRemoving param: ${isRemoving}`);\n debugLog('insertHeader', ` - shouldToggleOff: ${shouldToggleOff}`);\n debugLog('insertHeader', ` - selStart: ${selStart}, selEnd: ${selEnd}`);\n debugLog('insertHeader', ` - lineStartPos: ${lineStartPos}`);\n \n if (shouldToggleOff) {\n // Removing the header entirely\n const adjustment = Math.max(selStart - existingPrefixLength, lineStartPos)\n debugLog('insertHeader', ` - Removing header, adjusting by -${existingPrefixLength}`);\n return {\n start: adjustment,\n end: selStart === selEnd ? adjustment : Math.max(selEnd - existingPrefixLength, lineStartPos)\n }\n } else if (existingPrefixLength > 0) {\n // Replacing existing header with new one\n const prefixDiff = style.prefix.length - existingPrefixLength\n debugLog('insertHeader', ` - Replacing header, adjusting by ${prefixDiff}`);\n return {\n start: selStart + prefixDiff,\n end: selEnd + prefixDiff\n }\n } else {\n // Adding new header\n debugLog('insertHeader', ` - Adding header, adjusting by +${style.prefix.length}`);\n return {\n start: selStart + style.prefix.length,\n end: selEnd + style.prefix.length\n }\n }\n }\n }\n )\n \n debugLog('insertHeader', `Final result: text=\"${result.text}\", cursor=${result.selectionStart}-${result.selectionEnd}`);\n debugLog('insertHeader', `============ END ============`);\n \n insertText(textarea, result)\n}\n\n/**\n * Toggle H1 header\n */\nexport function toggleH1(textarea) {\n insertHeader(textarea, 1, true)\n}\n\n/**\n * Toggle H2 header\n */\nexport function toggleH2(textarea) {\n insertHeader(textarea, 2, true)\n}\n\n/**\n * Toggle H3 header\n */\nexport function toggleH3(textarea) {\n insertHeader(textarea, 3, true)\n}\n\n/**\n * Get active formats at cursor position\n */\nexport function getActiveFormats(textarea) {\n return getActive(textarea)\n}\n\n/**\n * Check if format is active at cursor\n */\nexport function hasFormat(textarea, format) {\n return has(textarea, format)\n}\n\n/**\n * Expand selection based on options\n */\nexport function expandSelection(textarea, options = {}) {\n expand(textarea, options)\n}\n\n/**\n * Apply custom format\n */\nexport function applyCustomFormat(textarea, format) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const style = mergeWithDefaults(format)\n let result\n \n if (style.multiline) {\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n if (isMultipleLines(selectedText)) {\n result = multilineStyle(textarea, style)\n } else {\n result = blockStyle(textarea, style)\n }\n } else {\n result = blockStyle(textarea, style)\n }\n \n insertText(textarea, result)\n}\n\n/**\n * Preserve selection during callback\n */\nexport { preserveSelection }\n\n/**\n * Configure undo method\n */\nexport { setUndoMethod }\n\n/**\n * Debug mode control\n */\nexport { setDebugMode, getDebugMode }\n\n/**\n * Default export with all functions\n */\nexport default {\n toggleBold,\n toggleItalic,\n toggleCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n toggleTaskList,\n insertHeader,\n toggleH1,\n toggleH2,\n toggleH3,\n getActiveFormats,\n hasFormat,\n expandSelection,\n applyCustomFormat,\n preserveSelection,\n setUndoMethod,\n setDebugMode,\n getDebugMode\n}", "/**\n * Toolbar component for OverType editor\n * Provides markdown formatting buttons with support for custom buttons\n */\n\nimport * as markdownActions from 'markdown-actions';\n\nexport class Toolbar {\n constructor(editor, options = {}) {\n this.editor = editor;\n this.container = null;\n this.buttons = {};\n\n // Get toolbar buttons array\n this.toolbarButtons = options.toolbarButtons || [];\n }\n\n /**\n * Create and render toolbar\n */\n create() {\n this.container = document.createElement('div');\n this.container.className = 'overtype-toolbar';\n this.container.setAttribute('role', 'toolbar');\n this.container.setAttribute('aria-label', 'Formatting toolbar');\n\n // Create buttons from toolbarButtons array\n this.toolbarButtons.forEach(buttonConfig => {\n if (buttonConfig.name === 'separator') {\n const separator = this.createSeparator();\n this.container.appendChild(separator);\n } else {\n const button = this.createButton(buttonConfig);\n this.buttons[buttonConfig.name] = button;\n this.container.appendChild(button);\n }\n });\n\n // Insert toolbar before the wrapper (as sibling, not child)\n this.editor.container.insertBefore(this.container, this.editor.wrapper);\n }\n\n /**\n * Create a toolbar separator\n */\n createSeparator() {\n const separator = document.createElement('div');\n separator.className = 'overtype-toolbar-separator';\n separator.setAttribute('role', 'separator');\n return separator;\n }\n\n /**\n * Create a toolbar button\n */\n createButton(buttonConfig) {\n const button = document.createElement('button');\n button.className = 'overtype-toolbar-button';\n button.type = 'button';\n button.setAttribute('data-button', buttonConfig.name);\n button.title = buttonConfig.title || '';\n button.setAttribute('aria-label', buttonConfig.title || buttonConfig.name);\n button.innerHTML = this.sanitizeSVG(buttonConfig.icon || '');\n\n // Special handling for viewMode dropdown\n if (buttonConfig.name === 'viewMode') {\n button.classList.add('has-dropdown');\n button.dataset.dropdown = 'true';\n button.addEventListener('click', (e) => {\n e.preventDefault();\n this.toggleViewModeDropdown(button);\n });\n return button;\n }\n\n // Standard button click handler - delegate to performAction\n button._clickHandler = (e) => {\n e.preventDefault();\n const actionId = buttonConfig.actionId || buttonConfig.name;\n this.editor.performAction(actionId, e);\n };\n\n button.addEventListener('click', button._clickHandler);\n return button;\n }\n\n /**\n * Handle button action programmatically\n * Accepts either an actionId string or a buttonConfig object (backwards compatible)\n * @param {string|Object} actionIdOrConfig - Action identifier string or button config object\n * @returns {Promise<boolean>} Whether the action was executed\n */\n async handleAction(actionIdOrConfig) {\n // Old style: buttonConfig object with .action function - execute directly\n if (actionIdOrConfig && typeof actionIdOrConfig === 'object' && typeof actionIdOrConfig.action === 'function') {\n this.editor.textarea.focus();\n try {\n await actionIdOrConfig.action({\n editor: this.editor,\n getValue: () => this.editor.getValue(),\n setValue: (value) => this.editor.setValue(value),\n event: null\n });\n return true;\n } catch (error) {\n console.error(`Action \"${actionIdOrConfig.name}\" error:`, error);\n this.editor.wrapper.dispatchEvent(new CustomEvent('button-error', {\n detail: { buttonName: actionIdOrConfig.name, error }\n }));\n return false;\n }\n }\n\n // New style: string actionId - delegate to performAction\n if (typeof actionIdOrConfig === 'string') {\n return this.editor.performAction(actionIdOrConfig, null);\n }\n\n return false;\n }\n\n /**\n * Sanitize SVG to prevent XSS\n */\n sanitizeSVG(svg) {\n if (typeof svg !== 'string') return '';\n\n // Remove script tags and on* event handlers\n const cleaned = svg\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '')\n .replace(/\\son\\w+\\s*=\\s*[\"'][^\"']*[\"']/gi, '')\n .replace(/\\son\\w+\\s*=\\s*[^\\s>]*/gi, '');\n\n return cleaned;\n }\n\n /**\n * Toggle view mode dropdown (internal implementation)\n * Not exposed to users - viewMode button behavior is fixed\n */\n toggleViewModeDropdown(button) {\n // Close any existing dropdown\n const existingDropdown = document.querySelector('.overtype-dropdown-menu');\n if (existingDropdown) {\n existingDropdown.remove();\n button.classList.remove('dropdown-active');\n return;\n }\n\n button.classList.add('dropdown-active');\n\n const dropdown = this.createViewModeDropdown(button);\n\n // Position dropdown relative to button\n const rect = button.getBoundingClientRect();\n dropdown.style.position = 'absolute';\n dropdown.style.top = `${rect.bottom + 5}px`;\n dropdown.style.left = `${rect.left}px`;\n\n document.body.appendChild(dropdown);\n\n // Click outside to close\n this.handleDocumentClick = (e) => {\n if (!dropdown.contains(e.target) && !button.contains(e.target)) {\n dropdown.remove();\n button.classList.remove('dropdown-active');\n document.removeEventListener('click', this.handleDocumentClick);\n }\n };\n\n setTimeout(() => {\n document.addEventListener('click', this.handleDocumentClick);\n }, 0);\n }\n\n /**\n * Create view mode dropdown menu (internal implementation)\n */\n createViewModeDropdown(button) {\n const dropdown = document.createElement('div');\n dropdown.className = 'overtype-dropdown-menu';\n\n const items = [\n { id: 'normal', label: 'Normal Edit', icon: '\u2713' },\n { id: 'plain', label: 'Plain Textarea', icon: '\u2713' },\n { id: 'preview', label: 'Preview Mode', icon: '\u2713' }\n ];\n\n const currentMode = this.editor.container.dataset.mode || 'normal';\n\n items.forEach(item => {\n const menuItem = document.createElement('button');\n menuItem.className = 'overtype-dropdown-item';\n menuItem.type = 'button';\n menuItem.textContent = item.label;\n\n if (item.id === currentMode) {\n menuItem.classList.add('active');\n menuItem.setAttribute('aria-current', 'true');\n const checkmark = document.createElement('span');\n checkmark.className = 'overtype-dropdown-icon';\n checkmark.textContent = item.icon;\n menuItem.prepend(checkmark);\n }\n\n menuItem.addEventListener('click', (e) => {\n e.preventDefault();\n\n // Handle view mode changes\n switch(item.id) {\n case 'plain':\n this.editor.showPlainTextarea();\n break;\n case 'preview':\n this.editor.showPreviewMode();\n break;\n case 'normal':\n default:\n this.editor.showNormalEditMode();\n break;\n }\n\n dropdown.remove();\n button.classList.remove('dropdown-active');\n document.removeEventListener('click', this.handleDocumentClick);\n });\n\n dropdown.appendChild(menuItem);\n });\n\n return dropdown;\n }\n\n /**\n * Update active states of toolbar buttons\n */\n updateButtonStates() {\n try {\n const activeFormats = markdownActions.getActiveFormats?.(\n this.editor.textarea,\n this.editor.textarea.selectionStart\n ) || [];\n\n Object.entries(this.buttons).forEach(([name, button]) => {\n if (name === 'viewMode') return; // Skip dropdown button\n\n let isActive = false;\n\n switch(name) {\n case 'bold':\n isActive = activeFormats.includes('bold');\n break;\n case 'italic':\n isActive = activeFormats.includes('italic');\n break;\n case 'code':\n isActive = false; // Disabled: unreliable in code blocks\n break;\n case 'bulletList':\n isActive = activeFormats.includes('bullet-list');\n break;\n case 'orderedList':\n isActive = activeFormats.includes('numbered-list');\n break;\n case 'taskList':\n isActive = activeFormats.includes('task-list');\n break;\n case 'quote':\n isActive = activeFormats.includes('quote');\n break;\n case 'h1':\n isActive = activeFormats.includes('header');\n break;\n case 'h2':\n isActive = activeFormats.includes('header-2');\n break;\n case 'h3':\n isActive = activeFormats.includes('header-3');\n break;\n }\n\n button.classList.toggle('active', isActive);\n button.setAttribute('aria-pressed', isActive.toString());\n });\n } catch (error) {\n // Silently fail if markdown-actions not available\n }\n }\n\n show() {\n if (this.container) {\n this.container.classList.remove('overtype-toolbar-hidden');\n }\n }\n\n hide() {\n if (this.container) {\n this.container.classList.add('overtype-toolbar-hidden');\n }\n }\n\n /**\n * Destroy toolbar and cleanup\n */\n destroy() {\n if (this.container) {\n // Clean up event listeners\n if (this.handleDocumentClick) {\n document.removeEventListener('click', this.handleDocumentClick);\n }\n\n // Clean up button listeners\n Object.values(this.buttons).forEach(button => {\n if (button._clickHandler) {\n button.removeEventListener('click', button._clickHandler);\n delete button._clickHandler;\n }\n });\n\n // Remove container\n this.container.remove();\n this.container = null;\n this.buttons = {};\n }\n }\n}\n", "/**\n * Custom positioning reference element.\n * @see https://floating-ui.com/docs/virtual-elements\n */\n\nconst sides = ['top', 'right', 'bottom', 'left'];\nconst alignments = ['start', 'end'];\nconst placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + \"-\" + alignments[0], side + \"-\" + alignments[1]), []);\nconst min = Math.min;\nconst max = Math.max;\nconst round = Math.round;\nconst floor = Math.floor;\nconst createCoords = v => ({\n x: v,\n y: v\n});\nconst oppositeSideMap = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nconst oppositeAlignmentMap = {\n start: 'end',\n end: 'start'\n};\nfunction clamp(start, value, end) {\n return max(start, min(value, end));\n}\nfunction evaluate(value, param) {\n return typeof value === 'function' ? value(param) : value;\n}\nfunction getSide(placement) {\n return placement.split('-')[0];\n}\nfunction getAlignment(placement) {\n return placement.split('-')[1];\n}\nfunction getOppositeAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}\nfunction getAxisLength(axis) {\n return axis === 'y' ? 'height' : 'width';\n}\nconst yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);\nfunction getSideAxis(placement) {\n return yAxisSides.has(getSide(placement)) ? 'y' : 'x';\n}\nfunction getAlignmentAxis(placement) {\n return getOppositeAxis(getSideAxis(placement));\n}\nfunction getAlignmentSides(placement, rects, rtl) {\n if (rtl === void 0) {\n rtl = false;\n }\n const alignment = getAlignment(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const length = getAxisLength(alignmentAxis);\n let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';\n if (rects.reference[length] > rects.floating[length]) {\n mainAlignmentSide = getOppositePlacement(mainAlignmentSide);\n }\n return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];\n}\nfunction getExpandedPlacements(placement) {\n const oppositePlacement = getOppositePlacement(placement);\n return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];\n}\nfunction getOppositeAlignmentPlacement(placement) {\n return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);\n}\nconst lrPlacement = ['left', 'right'];\nconst rlPlacement = ['right', 'left'];\nconst tbPlacement = ['top', 'bottom'];\nconst btPlacement = ['bottom', 'top'];\nfunction getSideList(side, isStart, rtl) {\n switch (side) {\n case 'top':\n case 'bottom':\n if (rtl) return isStart ? rlPlacement : lrPlacement;\n return isStart ? lrPlacement : rlPlacement;\n case 'left':\n case 'right':\n return isStart ? tbPlacement : btPlacement;\n default:\n return [];\n }\n}\nfunction getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {\n const alignment = getAlignment(placement);\n let list = getSideList(getSide(placement), direction === 'start', rtl);\n if (alignment) {\n list = list.map(side => side + \"-\" + alignment);\n if (flipAlignment) {\n list = list.concat(list.map(getOppositeAlignmentPlacement));\n }\n }\n return list;\n}\nfunction getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);\n}\nfunction expandPaddingObject(padding) {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n ...padding\n };\n}\nfunction getPaddingObject(padding) {\n return typeof padding !== 'number' ? expandPaddingObject(padding) : {\n top: padding,\n right: padding,\n bottom: padding,\n left: padding\n };\n}\nfunction rectToClientRect(rect) {\n const {\n x,\n y,\n width,\n height\n } = rect;\n return {\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n x,\n y\n };\n}\n\nexport { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };\n", "import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';\nexport { rectToClientRect } from '@floating-ui/utils';\n\nfunction computeCoordsFromPlacement(_ref, placement, rtl) {\n let {\n reference,\n floating\n } = _ref;\n const sideAxis = getSideAxis(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const alignLength = getAxisLength(alignmentAxis);\n const side = getSide(placement);\n const isVertical = sideAxis === 'y';\n const commonX = reference.x + reference.width / 2 - floating.width / 2;\n const commonY = reference.y + reference.height / 2 - floating.height / 2;\n const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;\n let coords;\n switch (side) {\n case 'top':\n coords = {\n x: commonX,\n y: reference.y - floating.height\n };\n break;\n case 'bottom':\n coords = {\n x: commonX,\n y: reference.y + reference.height\n };\n break;\n case 'right':\n coords = {\n x: reference.x + reference.width,\n y: commonY\n };\n break;\n case 'left':\n coords = {\n x: reference.x - floating.width,\n y: commonY\n };\n break;\n default:\n coords = {\n x: reference.x,\n y: reference.y\n };\n }\n switch (getAlignment(placement)) {\n case 'start':\n coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);\n break;\n case 'end':\n coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);\n break;\n }\n return coords;\n}\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nasync function detectOverflow(state, options) {\n var _await$platform$isEle;\n if (options === void 0) {\n options = {};\n }\n const {\n x,\n y,\n platform,\n rects,\n elements,\n strategy\n } = state;\n const {\n boundary = 'clippingAncestors',\n rootBoundary = 'viewport',\n elementContext = 'floating',\n altBoundary = false,\n padding = 0\n } = evaluate(options, state);\n const paddingObject = getPaddingObject(padding);\n const altContext = elementContext === 'floating' ? 'reference' : 'floating';\n const element = elements[altBoundary ? altContext : elementContext];\n const clippingClientRect = rectToClientRect(await platform.getClippingRect({\n element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),\n boundary,\n rootBoundary,\n strategy\n }));\n const rect = elementContext === 'floating' ? {\n x,\n y,\n width: rects.floating.width,\n height: rects.floating.height\n } : rects.reference;\n const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));\n const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {\n x: 1,\n y: 1\n } : {\n x: 1,\n y: 1\n };\n const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n elements,\n rect,\n offsetParent,\n strategy\n }) : rect);\n return {\n top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,\n bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,\n left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,\n right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x\n };\n}\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n *\n * This export does not have any `platform` interface logic. You will need to\n * write one for the platform you are using Floating UI with.\n */\nconst computePosition = async (reference, floating, config) => {\n const {\n placement = 'bottom',\n strategy = 'absolute',\n middleware = [],\n platform\n } = config;\n const validMiddleware = middleware.filter(Boolean);\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));\n let rects = await platform.getElementRects({\n reference,\n floating,\n strategy\n });\n let {\n x,\n y\n } = computeCoordsFromPlacement(rects, placement, rtl);\n let statefulPlacement = placement;\n let middlewareData = {};\n let resetCount = 0;\n for (let i = 0; i < validMiddleware.length; i++) {\n var _platform$detectOverf;\n const {\n name,\n fn\n } = validMiddleware[i];\n const {\n x: nextX,\n y: nextY,\n data,\n reset\n } = await fn({\n x,\n y,\n initialPlacement: placement,\n placement: statefulPlacement,\n strategy,\n middlewareData,\n rects,\n platform: {\n ...platform,\n detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow\n },\n elements: {\n reference,\n floating\n }\n });\n x = nextX != null ? nextX : x;\n y = nextY != null ? nextY : y;\n middlewareData = {\n ...middlewareData,\n [name]: {\n ...middlewareData[name],\n ...data\n }\n };\n if (reset && resetCount <= 50) {\n resetCount++;\n if (typeof reset === 'object') {\n if (reset.placement) {\n statefulPlacement = reset.placement;\n }\n if (reset.rects) {\n rects = reset.rects === true ? await platform.getElementRects({\n reference,\n floating,\n strategy\n }) : reset.rects;\n }\n ({\n x,\n y\n } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));\n }\n i = -1;\n }\n }\n return {\n x,\n y,\n placement: statefulPlacement,\n strategy,\n middlewareData\n };\n};\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = options => ({\n name: 'arrow',\n options,\n async fn(state) {\n const {\n x,\n y,\n placement,\n rects,\n platform,\n elements,\n middlewareData\n } = state;\n // Since `element` is required, we don't Partial<> the type.\n const {\n element,\n padding = 0\n } = evaluate(options, state) || {};\n if (element == null) {\n return {};\n }\n const paddingObject = getPaddingObject(padding);\n const coords = {\n x,\n y\n };\n const axis = getAlignmentAxis(placement);\n const length = getAxisLength(axis);\n const arrowDimensions = await platform.getDimensions(element);\n const isYAxis = axis === 'y';\n const minProp = isYAxis ? 'top' : 'left';\n const maxProp = isYAxis ? 'bottom' : 'right';\n const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';\n const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];\n const startDiff = coords[axis] - rects.reference[axis];\n const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));\n let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;\n\n // DOM platform can return `window` as the `offsetParent`.\n if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {\n clientSize = elements.floating[clientProp] || rects.floating[length];\n }\n const centerToReference = endDiff / 2 - startDiff / 2;\n\n // If the padding is large enough that it causes the arrow to no longer be\n // centered, modify the padding so that it is centered.\n const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;\n const minPadding = min(paddingObject[minProp], largestPossiblePadding);\n const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);\n\n // Make sure the arrow doesn't overflow the floating element if the center\n // point is outside the floating element's bounds.\n const min$1 = minPadding;\n const max = clientSize - arrowDimensions[length] - maxPadding;\n const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;\n const offset = clamp(min$1, center, max);\n\n // If the reference is small enough that the arrow's padding causes it to\n // to point to nothing for an aligned placement, adjust the offset of the\n // floating element itself. To ensure `shift()` continues to take action,\n // a single reset is performed when this is true.\n const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;\n const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;\n return {\n [axis]: coords[axis] + alignmentOffset,\n data: {\n [axis]: offset,\n centerOffset: center - offset - alignmentOffset,\n ...(shouldAddOffset && {\n alignmentOffset\n })\n },\n reset: shouldAddOffset\n };\n }\n});\n\nfunction getPlacementList(alignment, autoAlignment, allowedPlacements) {\n const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);\n return allowedPlacementsSortedByAlignment.filter(placement => {\n if (alignment) {\n return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);\n }\n return true;\n });\n}\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'autoPlacement',\n options,\n async fn(state) {\n var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;\n const {\n rects,\n middlewareData,\n placement,\n platform,\n elements\n } = state;\n const {\n crossAxis = false,\n alignment,\n allowedPlacements = placements,\n autoAlignment = true,\n ...detectOverflowOptions\n } = evaluate(options, state);\n const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;\n const currentPlacement = placements$1[currentIndex];\n if (currentPlacement == null) {\n return {};\n }\n const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));\n\n // Make `computeCoords` start from the right place.\n if (placement !== currentPlacement) {\n return {\n reset: {\n placement: placements$1[0]\n }\n };\n }\n const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];\n const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {\n placement: currentPlacement,\n overflows: currentOverflows\n }];\n const nextPlacement = placements$1[currentIndex + 1];\n\n // There are more placements to check.\n if (nextPlacement) {\n return {\n data: {\n index: currentIndex + 1,\n overflows: allOverflows\n },\n reset: {\n placement: nextPlacement\n }\n };\n }\n const placementsSortedByMostSpace = allOverflows.map(d => {\n const alignment = getAlignment(d.placement);\n return [d.placement, alignment && crossAxis ?\n // Check along the mainAxis and main crossAxis side.\n d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :\n // Check only the mainAxis.\n d.overflows[0], d.overflows];\n }).sort((a, b) => a[1] - b[1]);\n const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,\n // Aligned placements should not check their opposite crossAxis\n // side.\n getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));\n const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];\n if (resetPlacement !== placement) {\n return {\n data: {\n index: currentIndex + 1,\n overflows: allOverflows\n },\n reset: {\n placement: resetPlacement\n }\n };\n }\n return {};\n }\n };\n};\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'flip',\n options,\n async fn(state) {\n var _middlewareData$arrow, _middlewareData$flip;\n const {\n placement,\n middlewareData,\n rects,\n initialPlacement,\n platform,\n elements\n } = state;\n const {\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = true,\n fallbackPlacements: specifiedFallbackPlacements,\n fallbackStrategy = 'bestFit',\n fallbackAxisSideDirection = 'none',\n flipAlignment = true,\n ...detectOverflowOptions\n } = evaluate(options, state);\n\n // If a reset by the arrow was caused due to an alignment offset being\n // added, we should skip any logic now since `flip()` has already done its\n // work.\n // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643\n if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n return {};\n }\n const side = getSide(placement);\n const initialSideAxis = getSideAxis(initialPlacement);\n const isBasePlacement = getSide(initialPlacement) === initialPlacement;\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));\n const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';\n if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {\n fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));\n }\n const placements = [initialPlacement, ...fallbackPlacements];\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const overflows = [];\n let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];\n if (checkMainAxis) {\n overflows.push(overflow[side]);\n }\n if (checkCrossAxis) {\n const sides = getAlignmentSides(placement, rects, rtl);\n overflows.push(overflow[sides[0]], overflow[sides[1]]);\n }\n overflowsData = [...overflowsData, {\n placement,\n overflows\n }];\n\n // One or more sides is overflowing.\n if (!overflows.every(side => side <= 0)) {\n var _middlewareData$flip2, _overflowsData$filter;\n const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;\n const nextPlacement = placements[nextIndex];\n if (nextPlacement) {\n const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;\n if (!ignoreCrossAxisOverflow ||\n // We leave the current main axis only if every placement on that axis\n // overflows the main axis.\n overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {\n // Try next placement and re-run the lifecycle.\n return {\n data: {\n index: nextIndex,\n overflows: overflowsData\n },\n reset: {\n placement: nextPlacement\n }\n };\n }\n }\n\n // First, find the candidates that fit on the mainAxis side of overflow,\n // then find the placement that fits the best on the main crossAxis side.\n let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;\n\n // Otherwise fallback.\n if (!resetPlacement) {\n switch (fallbackStrategy) {\n case 'bestFit':\n {\n var _overflowsData$filter2;\n const placement = (_overflowsData$filter2 = overflowsData.filter(d => {\n if (hasFallbackAxisSideDirection) {\n const currentSideAxis = getSideAxis(d.placement);\n return currentSideAxis === initialSideAxis ||\n // Create a bias to the `y` side axis due to horizontal\n // reading directions favoring greater width.\n currentSideAxis === 'y';\n }\n return true;\n }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];\n if (placement) {\n resetPlacement = placement;\n }\n break;\n }\n case 'initialPlacement':\n resetPlacement = initialPlacement;\n break;\n }\n }\n if (placement !== resetPlacement) {\n return {\n reset: {\n placement: resetPlacement\n }\n };\n }\n }\n return {};\n }\n };\n};\n\nfunction getSideOffsets(overflow, rect) {\n return {\n top: overflow.top - rect.height,\n right: overflow.right - rect.width,\n bottom: overflow.bottom - rect.height,\n left: overflow.left - rect.width\n };\n}\nfunction isAnySideFullyClipped(overflow) {\n return sides.some(side => overflow[side] >= 0);\n}\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'hide',\n options,\n async fn(state) {\n const {\n rects,\n platform\n } = state;\n const {\n strategy = 'referenceHidden',\n ...detectOverflowOptions\n } = evaluate(options, state);\n switch (strategy) {\n case 'referenceHidden':\n {\n const overflow = await platform.detectOverflow(state, {\n ...detectOverflowOptions,\n elementContext: 'reference'\n });\n const offsets = getSideOffsets(overflow, rects.reference);\n return {\n data: {\n referenceHiddenOffsets: offsets,\n referenceHidden: isAnySideFullyClipped(offsets)\n }\n };\n }\n case 'escaped':\n {\n const overflow = await platform.detectOverflow(state, {\n ...detectOverflowOptions,\n altBoundary: true\n });\n const offsets = getSideOffsets(overflow, rects.floating);\n return {\n data: {\n escapedOffsets: offsets,\n escaped: isAnySideFullyClipped(offsets)\n }\n };\n }\n default:\n {\n return {};\n }\n }\n }\n };\n};\n\nfunction getBoundingRect(rects) {\n const minX = min(...rects.map(rect => rect.left));\n const minY = min(...rects.map(rect => rect.top));\n const maxX = max(...rects.map(rect => rect.right));\n const maxY = max(...rects.map(rect => rect.bottom));\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY\n };\n}\nfunction getRectsByLine(rects) {\n const sortedRects = rects.slice().sort((a, b) => a.y - b.y);\n const groups = [];\n let prevRect = null;\n for (let i = 0; i < sortedRects.length; i++) {\n const rect = sortedRects[i];\n if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {\n groups.push([rect]);\n } else {\n groups[groups.length - 1].push(rect);\n }\n prevRect = rect;\n }\n return groups.map(rect => rectToClientRect(getBoundingRect(rect)));\n}\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'inline',\n options,\n async fn(state) {\n const {\n placement,\n elements,\n rects,\n platform,\n strategy\n } = state;\n // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a\n // ClientRect's bounds, despite the event listener being triggered. A\n // padding of 2 seems to handle this issue.\n const {\n padding = 2,\n x,\n y\n } = evaluate(options, state);\n const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);\n const clientRects = getRectsByLine(nativeClientRects);\n const fallback = rectToClientRect(getBoundingRect(nativeClientRects));\n const paddingObject = getPaddingObject(padding);\n function getBoundingClientRect() {\n // There are two rects and they are disjoined.\n if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {\n // Find the first rect in which the point is fully inside.\n return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;\n }\n\n // There are 2 or more connected rects.\n if (clientRects.length >= 2) {\n if (getSideAxis(placement) === 'y') {\n const firstRect = clientRects[0];\n const lastRect = clientRects[clientRects.length - 1];\n const isTop = getSide(placement) === 'top';\n const top = firstRect.top;\n const bottom = lastRect.bottom;\n const left = isTop ? firstRect.left : lastRect.left;\n const right = isTop ? firstRect.right : lastRect.right;\n const width = right - left;\n const height = bottom - top;\n return {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x: left,\n y: top\n };\n }\n const isLeftSide = getSide(placement) === 'left';\n const maxRight = max(...clientRects.map(rect => rect.right));\n const minLeft = min(...clientRects.map(rect => rect.left));\n const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);\n const top = measureRects[0].top;\n const bottom = measureRects[measureRects.length - 1].bottom;\n const left = minLeft;\n const right = maxRight;\n const width = right - left;\n const height = bottom - top;\n return {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x: left,\n y: top\n };\n }\n return fallback;\n }\n const resetRects = await platform.getElementRects({\n reference: {\n getBoundingClientRect\n },\n floating: elements.floating,\n strategy\n });\n if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {\n return {\n reset: {\n rects: resetRects\n }\n };\n }\n return {};\n }\n };\n};\n\nconst originSides = /*#__PURE__*/new Set(['left', 'top']);\n\n// For type backwards-compatibility, the `OffsetOptions` type was also\n// Derivable.\n\nasync function convertValueToCoords(state, options) {\n const {\n placement,\n platform,\n elements\n } = state;\n const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n const side = getSide(placement);\n const alignment = getAlignment(placement);\n const isVertical = getSideAxis(placement) === 'y';\n const mainAxisMulti = originSides.has(side) ? -1 : 1;\n const crossAxisMulti = rtl && isVertical ? -1 : 1;\n const rawValue = evaluate(options, state);\n\n // eslint-disable-next-line prefer-const\n let {\n mainAxis,\n crossAxis,\n alignmentAxis\n } = typeof rawValue === 'number' ? {\n mainAxis: rawValue,\n crossAxis: 0,\n alignmentAxis: null\n } : {\n mainAxis: rawValue.mainAxis || 0,\n crossAxis: rawValue.crossAxis || 0,\n alignmentAxis: rawValue.alignmentAxis\n };\n if (alignment && typeof alignmentAxis === 'number') {\n crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;\n }\n return isVertical ? {\n x: crossAxis * crossAxisMulti,\n y: mainAxis * mainAxisMulti\n } : {\n x: mainAxis * mainAxisMulti,\n y: crossAxis * crossAxisMulti\n };\n}\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = function (options) {\n if (options === void 0) {\n options = 0;\n }\n return {\n name: 'offset',\n options,\n async fn(state) {\n var _middlewareData$offse, _middlewareData$arrow;\n const {\n x,\n y,\n placement,\n middlewareData\n } = state;\n const diffCoords = await convertValueToCoords(state, options);\n\n // If the placement is the same and the arrow caused an alignment offset\n // then we don't need to change the positioning coordinates.\n if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n return {};\n }\n return {\n x: x + diffCoords.x,\n y: y + diffCoords.y,\n data: {\n ...diffCoords,\n placement\n }\n };\n }\n };\n};\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'shift',\n options,\n async fn(state) {\n const {\n x,\n y,\n placement,\n platform\n } = state;\n const {\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = false,\n limiter = {\n fn: _ref => {\n let {\n x,\n y\n } = _ref;\n return {\n x,\n y\n };\n }\n },\n ...detectOverflowOptions\n } = evaluate(options, state);\n const coords = {\n x,\n y\n };\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const crossAxis = getSideAxis(getSide(placement));\n const mainAxis = getOppositeAxis(crossAxis);\n let mainAxisCoord = coords[mainAxis];\n let crossAxisCoord = coords[crossAxis];\n if (checkMainAxis) {\n const minSide = mainAxis === 'y' ? 'top' : 'left';\n const maxSide = mainAxis === 'y' ? 'bottom' : 'right';\n const min = mainAxisCoord + overflow[minSide];\n const max = mainAxisCoord - overflow[maxSide];\n mainAxisCoord = clamp(min, mainAxisCoord, max);\n }\n if (checkCrossAxis) {\n const minSide = crossAxis === 'y' ? 'top' : 'left';\n const maxSide = crossAxis === 'y' ? 'bottom' : 'right';\n const min = crossAxisCoord + overflow[minSide];\n const max = crossAxisCoord - overflow[maxSide];\n crossAxisCoord = clamp(min, crossAxisCoord, max);\n }\n const limitedCoords = limiter.fn({\n ...state,\n [mainAxis]: mainAxisCoord,\n [crossAxis]: crossAxisCoord\n });\n return {\n ...limitedCoords,\n data: {\n x: limitedCoords.x - x,\n y: limitedCoords.y - y,\n enabled: {\n [mainAxis]: checkMainAxis,\n [crossAxis]: checkCrossAxis\n }\n }\n };\n }\n };\n};\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n options,\n fn(state) {\n const {\n x,\n y,\n placement,\n rects,\n middlewareData\n } = state;\n const {\n offset = 0,\n mainAxis: checkMainAxis = true,\n crossAxis: checkCrossAxis = true\n } = evaluate(options, state);\n const coords = {\n x,\n y\n };\n const crossAxis = getSideAxis(placement);\n const mainAxis = getOppositeAxis(crossAxis);\n let mainAxisCoord = coords[mainAxis];\n let crossAxisCoord = coords[crossAxis];\n const rawOffset = evaluate(offset, state);\n const computedOffset = typeof rawOffset === 'number' ? {\n mainAxis: rawOffset,\n crossAxis: 0\n } : {\n mainAxis: 0,\n crossAxis: 0,\n ...rawOffset\n };\n if (checkMainAxis) {\n const len = mainAxis === 'y' ? 'height' : 'width';\n const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;\n const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;\n if (mainAxisCoord < limitMin) {\n mainAxisCoord = limitMin;\n } else if (mainAxisCoord > limitMax) {\n mainAxisCoord = limitMax;\n }\n }\n if (checkCrossAxis) {\n var _middlewareData$offse, _middlewareData$offse2;\n const len = mainAxis === 'y' ? 'width' : 'height';\n const isOriginSide = originSides.has(getSide(placement));\n const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);\n const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);\n if (crossAxisCoord < limitMin) {\n crossAxisCoord = limitMin;\n } else if (crossAxisCoord > limitMax) {\n crossAxisCoord = limitMax;\n }\n }\n return {\n [mainAxis]: mainAxisCoord,\n [crossAxis]: crossAxisCoord\n };\n }\n };\n};\n\n/**\n * Provides data that allows you to change the size of the floating element \u2014\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = function (options) {\n if (options === void 0) {\n options = {};\n }\n return {\n name: 'size',\n options,\n async fn(state) {\n var _state$middlewareData, _state$middlewareData2;\n const {\n placement,\n rects,\n platform,\n elements\n } = state;\n const {\n apply = () => {},\n ...detectOverflowOptions\n } = evaluate(options, state);\n const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n const side = getSide(placement);\n const alignment = getAlignment(placement);\n const isYAxis = getSideAxis(placement) === 'y';\n const {\n width,\n height\n } = rects.floating;\n let heightSide;\n let widthSide;\n if (side === 'top' || side === 'bottom') {\n heightSide = side;\n widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';\n } else {\n widthSide = side;\n heightSide = alignment === 'end' ? 'top' : 'bottom';\n }\n const maximumClippingHeight = height - overflow.top - overflow.bottom;\n const maximumClippingWidth = width - overflow.left - overflow.right;\n const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);\n const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);\n const noShift = !state.middlewareData.shift;\n let availableHeight = overflowAvailableHeight;\n let availableWidth = overflowAvailableWidth;\n if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {\n availableWidth = maximumClippingWidth;\n }\n if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {\n availableHeight = maximumClippingHeight;\n }\n if (noShift && !alignment) {\n const xMin = max(overflow.left, 0);\n const xMax = max(overflow.right, 0);\n const yMin = max(overflow.top, 0);\n const yMax = max(overflow.bottom, 0);\n if (isYAxis) {\n availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));\n } else {\n availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));\n }\n }\n await apply({\n ...state,\n availableWidth,\n availableHeight\n });\n const nextDimensions = await platform.getDimensions(elements.floating);\n if (width !== nextDimensions.width || height !== nextDimensions.height) {\n return {\n reset: {\n rects: true\n }\n };\n }\n return {};\n }\n };\n};\n\nexport { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size };\n", "function hasWindow() {\n return typeof window !== 'undefined';\n}\nfunction getNodeName(node) {\n if (isNode(node)) {\n return (node.nodeName || '').toLowerCase();\n }\n // Mocked nodes in testing environments may not be instances of Node. By\n // returning `#document` an infinite loop won't occur.\n // https://github.com/floating-ui/floating-ui/issues/2317\n return '#document';\n}\nfunction getWindow(node) {\n var _node$ownerDocument;\n return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;\n}\nfunction getDocumentElement(node) {\n var _ref;\n return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;\n}\nfunction isNode(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Node || value instanceof getWindow(value).Node;\n}\nfunction isElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Element || value instanceof getWindow(value).Element;\n}\nfunction isHTMLElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n}\nfunction isShadowRoot(value) {\n if (!hasWindow() || typeof ShadowRoot === 'undefined') {\n return false;\n }\n return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;\n}\nconst invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);\nfunction isOverflowElement(element) {\n const {\n overflow,\n overflowX,\n overflowY,\n display\n } = getComputedStyle(element);\n return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);\n}\nconst tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);\nfunction isTableElement(element) {\n return tableElements.has(getNodeName(element));\n}\nconst topLayerSelectors = [':popover-open', ':modal'];\nfunction isTopLayer(element) {\n return topLayerSelectors.some(selector => {\n try {\n return element.matches(selector);\n } catch (_e) {\n return false;\n }\n });\n}\nconst transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];\nconst willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];\nconst containValues = ['paint', 'layout', 'strict', 'content'];\nfunction isContainingBlock(elementOrCss) {\n const webkit = isWebKit();\n const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n // https://drafts.csswg.org/css-transforms-2/#individual-transforms\n return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));\n}\nfunction getContainingBlock(element) {\n let currentNode = getParentNode(element);\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else if (isTopLayer(currentNode)) {\n return null;\n }\n currentNode = getParentNode(currentNode);\n }\n return null;\n}\nfunction isWebKit() {\n if (typeof CSS === 'undefined' || !CSS.supports) return false;\n return CSS.supports('-webkit-backdrop-filter', 'none');\n}\nconst lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);\nfunction isLastTraversableNode(node) {\n return lastTraversableNodeNames.has(getNodeName(node));\n}\nfunction getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}\nfunction getNodeScroll(element) {\n if (isElement(element)) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n }\n return {\n scrollLeft: element.scrollX,\n scrollTop: element.scrollY\n };\n}\nfunction getParentNode(node) {\n if (getNodeName(node) === 'html') {\n return node;\n }\n const result =\n // Step into the shadow DOM of the parent of a slotted node.\n node.assignedSlot ||\n // DOM Element detected.\n node.parentNode ||\n // ShadowRoot detected.\n isShadowRoot(node) && node.host ||\n // Fallback.\n getDocumentElement(node);\n return isShadowRoot(result) ? result.host : result;\n}\nfunction getNearestOverflowAncestor(node) {\n const parentNode = getParentNode(node);\n if (isLastTraversableNode(parentNode)) {\n return node.ownerDocument ? node.ownerDocument.body : node.body;\n }\n if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {\n return parentNode;\n }\n return getNearestOverflowAncestor(parentNode);\n}\nfunction getOverflowAncestors(node, list, traverseIframes) {\n var _node$ownerDocument2;\n if (list === void 0) {\n list = [];\n }\n if (traverseIframes === void 0) {\n traverseIframes = true;\n }\n const scrollableAncestor = getNearestOverflowAncestor(node);\n const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);\n const win = getWindow(scrollableAncestor);\n if (isBody) {\n const frameElement = getFrameElement(win);\n return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);\n }\n return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));\n}\nfunction getFrameElement(win) {\n return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;\n}\n\nexport { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };\n", "import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@floating-ui/core';\nimport { round, createCoords, max, min, floor } from '@floating-ui/utils';\nimport { getComputedStyle as getComputedStyle$1, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom';\nexport { getOverflowAncestors } from '@floating-ui/utils/dom';\n\nfunction getCssDimensions(element) {\n const css = getComputedStyle$1(element);\n // In testing environments, the `width` and `height` properties are empty\n // strings for SVG elements, returning NaN. Fallback to `0` in this case.\n let width = parseFloat(css.width) || 0;\n let height = parseFloat(css.height) || 0;\n const hasOffset = isHTMLElement(element);\n const offsetWidth = hasOffset ? element.offsetWidth : width;\n const offsetHeight = hasOffset ? element.offsetHeight : height;\n const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;\n if (shouldFallback) {\n width = offsetWidth;\n height = offsetHeight;\n }\n return {\n width,\n height,\n $: shouldFallback\n };\n}\n\nfunction unwrapElement(element) {\n return !isElement(element) ? element.contextElement : element;\n}\n\nfunction getScale(element) {\n const domElement = unwrapElement(element);\n if (!isHTMLElement(domElement)) {\n return createCoords(1);\n }\n const rect = domElement.getBoundingClientRect();\n const {\n width,\n height,\n $\n } = getCssDimensions(domElement);\n let x = ($ ? round(rect.width) : rect.width) / width;\n let y = ($ ? round(rect.height) : rect.height) / height;\n\n // 0, NaN, or Infinity should always fallback to 1.\n\n if (!x || !Number.isFinite(x)) {\n x = 1;\n }\n if (!y || !Number.isFinite(y)) {\n y = 1;\n }\n return {\n x,\n y\n };\n}\n\nconst noOffsets = /*#__PURE__*/createCoords(0);\nfunction getVisualOffsets(element) {\n const win = getWindow(element);\n if (!isWebKit() || !win.visualViewport) {\n return noOffsets;\n }\n return {\n x: win.visualViewport.offsetLeft,\n y: win.visualViewport.offsetTop\n };\n}\nfunction shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {\n if (isFixed === void 0) {\n isFixed = false;\n }\n if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {\n return false;\n }\n return isFixed;\n}\n\nfunction getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {\n if (includeScale === void 0) {\n includeScale = false;\n }\n if (isFixedStrategy === void 0) {\n isFixedStrategy = false;\n }\n const clientRect = element.getBoundingClientRect();\n const domElement = unwrapElement(element);\n let scale = createCoords(1);\n if (includeScale) {\n if (offsetParent) {\n if (isElement(offsetParent)) {\n scale = getScale(offsetParent);\n }\n } else {\n scale = getScale(element);\n }\n }\n const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);\n let x = (clientRect.left + visualOffsets.x) / scale.x;\n let y = (clientRect.top + visualOffsets.y) / scale.y;\n let width = clientRect.width / scale.x;\n let height = clientRect.height / scale.y;\n if (domElement) {\n const win = getWindow(domElement);\n const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;\n let currentWin = win;\n let currentIFrame = getFrameElement(currentWin);\n while (currentIFrame && offsetParent && offsetWin !== currentWin) {\n const iframeScale = getScale(currentIFrame);\n const iframeRect = currentIFrame.getBoundingClientRect();\n const css = getComputedStyle$1(currentIFrame);\n const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;\n const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;\n x *= iframeScale.x;\n y *= iframeScale.y;\n width *= iframeScale.x;\n height *= iframeScale.y;\n x += left;\n y += top;\n currentWin = getWindow(currentIFrame);\n currentIFrame = getFrameElement(currentWin);\n }\n }\n return rectToClientRect({\n width,\n height,\n x,\n y\n });\n}\n\n// If <html> has a CSS width greater than the viewport, then this will be\n// incorrect for RTL.\nfunction getWindowScrollBarX(element, rect) {\n const leftScroll = getNodeScroll(element).scrollLeft;\n if (!rect) {\n return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;\n }\n return rect.left + leftScroll;\n}\n\nfunction getHTMLOffset(documentElement, scroll) {\n const htmlRect = documentElement.getBoundingClientRect();\n const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);\n const y = htmlRect.top + scroll.scrollTop;\n return {\n x,\n y\n };\n}\n\nfunction convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {\n let {\n elements,\n rect,\n offsetParent,\n strategy\n } = _ref;\n const isFixed = strategy === 'fixed';\n const documentElement = getDocumentElement(offsetParent);\n const topLayer = elements ? isTopLayer(elements.floating) : false;\n if (offsetParent === documentElement || topLayer && isFixed) {\n return rect;\n }\n let scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n let scale = createCoords(1);\n const offsets = createCoords(0);\n const isOffsetParentAnElement = isHTMLElement(offsetParent);\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n if (isHTMLElement(offsetParent)) {\n const offsetRect = getBoundingClientRect(offsetParent);\n scale = getScale(offsetParent);\n offsets.x = offsetRect.x + offsetParent.clientLeft;\n offsets.y = offsetRect.y + offsetParent.clientTop;\n }\n }\n const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);\n return {\n width: rect.width * scale.x,\n height: rect.height * scale.y,\n x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,\n y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y\n };\n}\n\nfunction getClientRects(element) {\n return Array.from(element.getClientRects());\n}\n\n// Gets the entire size of the scrollable document area, even extending outside\n// of the `<html>` and `<body>` rect bounds if horizontally scrollable.\nfunction getDocumentRect(element) {\n const html = getDocumentElement(element);\n const scroll = getNodeScroll(element);\n const body = element.ownerDocument.body;\n const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);\n const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);\n let x = -scroll.scrollLeft + getWindowScrollBarX(element);\n const y = -scroll.scrollTop;\n if (getComputedStyle$1(body).direction === 'rtl') {\n x += max(html.clientWidth, body.clientWidth) - width;\n }\n return {\n width,\n height,\n x,\n y\n };\n}\n\n// Safety check: ensure the scrollbar space is reasonable in case this\n// calculation is affected by unusual styles.\n// Most scrollbars leave 15-18px of space.\nconst SCROLLBAR_MAX = 25;\nfunction getViewportRect(element, strategy) {\n const win = getWindow(element);\n const html = getDocumentElement(element);\n const visualViewport = win.visualViewport;\n let width = html.clientWidth;\n let height = html.clientHeight;\n let x = 0;\n let y = 0;\n if (visualViewport) {\n width = visualViewport.width;\n height = visualViewport.height;\n const visualViewportBased = isWebKit();\n if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {\n x = visualViewport.offsetLeft;\n y = visualViewport.offsetTop;\n }\n }\n const windowScrollbarX = getWindowScrollBarX(html);\n // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the\n // visual width of the <html> but this is not considered in the size\n // of `html.clientWidth`.\n if (windowScrollbarX <= 0) {\n const doc = html.ownerDocument;\n const body = doc.body;\n const bodyStyles = getComputedStyle(body);\n const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;\n const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);\n if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {\n width -= clippingStableScrollbarWidth;\n }\n } else if (windowScrollbarX <= SCROLLBAR_MAX) {\n // If the <body> scrollbar is on the left, the width needs to be extended\n // by the scrollbar amount so there isn't extra space on the right.\n width += windowScrollbarX;\n }\n return {\n width,\n height,\n x,\n y\n };\n}\n\nconst absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);\n// Returns the inner client rect, subtracting scrollbars if present.\nfunction getInnerBoundingClientRect(element, strategy) {\n const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');\n const top = clientRect.top + element.clientTop;\n const left = clientRect.left + element.clientLeft;\n const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);\n const width = element.clientWidth * scale.x;\n const height = element.clientHeight * scale.y;\n const x = left * scale.x;\n const y = top * scale.y;\n return {\n width,\n height,\n x,\n y\n };\n}\nfunction getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {\n let rect;\n if (clippingAncestor === 'viewport') {\n rect = getViewportRect(element, strategy);\n } else if (clippingAncestor === 'document') {\n rect = getDocumentRect(getDocumentElement(element));\n } else if (isElement(clippingAncestor)) {\n rect = getInnerBoundingClientRect(clippingAncestor, strategy);\n } else {\n const visualOffsets = getVisualOffsets(element);\n rect = {\n x: clippingAncestor.x - visualOffsets.x,\n y: clippingAncestor.y - visualOffsets.y,\n width: clippingAncestor.width,\n height: clippingAncestor.height\n };\n }\n return rectToClientRect(rect);\n}\nfunction hasFixedPositionAncestor(element, stopNode) {\n const parentNode = getParentNode(element);\n if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {\n return false;\n }\n return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);\n}\n\n// A \"clipping ancestor\" is an `overflow` element with the characteristic of\n// clipping (or hiding) child elements. This returns all clipping ancestors\n// of the given element up the tree.\nfunction getClippingElementAncestors(element, cache) {\n const cachedResult = cache.get(element);\n if (cachedResult) {\n return cachedResult;\n }\n let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');\n let currentContainingBlockComputedStyle = null;\n const elementIsFixed = getComputedStyle$1(element).position === 'fixed';\n let currentNode = elementIsFixed ? getParentNode(element) : element;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {\n const computedStyle = getComputedStyle$1(currentNode);\n const currentNodeIsContaining = isContainingBlock(currentNode);\n if (!currentNodeIsContaining && computedStyle.position === 'fixed') {\n currentContainingBlockComputedStyle = null;\n }\n const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);\n if (shouldDropCurrentNode) {\n // Drop non-containing blocks.\n result = result.filter(ancestor => ancestor !== currentNode);\n } else {\n // Record last containing block for next iteration.\n currentContainingBlockComputedStyle = computedStyle;\n }\n currentNode = getParentNode(currentNode);\n }\n cache.set(element, result);\n return result;\n}\n\n// Gets the maximum area that the element is visible in due to any number of\n// clipping ancestors.\nfunction getClippingRect(_ref) {\n let {\n element,\n boundary,\n rootBoundary,\n strategy\n } = _ref;\n const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);\n const clippingAncestors = [...elementClippingAncestors, rootBoundary];\n const firstClippingAncestor = clippingAncestors[0];\n const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {\n const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);\n accRect.top = max(rect.top, accRect.top);\n accRect.right = min(rect.right, accRect.right);\n accRect.bottom = min(rect.bottom, accRect.bottom);\n accRect.left = max(rect.left, accRect.left);\n return accRect;\n }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));\n return {\n width: clippingRect.right - clippingRect.left,\n height: clippingRect.bottom - clippingRect.top,\n x: clippingRect.left,\n y: clippingRect.top\n };\n}\n\nfunction getDimensions(element) {\n const {\n width,\n height\n } = getCssDimensions(element);\n return {\n width,\n height\n };\n}\n\nfunction getRectRelativeToOffsetParent(element, offsetParent, strategy) {\n const isOffsetParentAnElement = isHTMLElement(offsetParent);\n const documentElement = getDocumentElement(offsetParent);\n const isFixed = strategy === 'fixed';\n const rect = getBoundingClientRect(element, true, isFixed, offsetParent);\n let scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n const offsets = createCoords(0);\n\n // If the <body> scrollbar appears on the left (e.g. RTL systems). Use\n // Firefox with layout.scrollbar.side = 3 in about:config to test this.\n function setLeftRTLScrollbarOffset() {\n offsets.x = getWindowScrollBarX(documentElement);\n }\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n if (isOffsetParentAnElement) {\n const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);\n offsets.x = offsetRect.x + offsetParent.clientLeft;\n offsets.y = offsetRect.y + offsetParent.clientTop;\n } else if (documentElement) {\n setLeftRTLScrollbarOffset();\n }\n }\n if (isFixed && !isOffsetParentAnElement && documentElement) {\n setLeftRTLScrollbarOffset();\n }\n const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);\n const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;\n const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;\n return {\n x,\n y,\n width: rect.width,\n height: rect.height\n };\n}\n\nfunction isStaticPositioned(element) {\n return getComputedStyle$1(element).position === 'static';\n}\n\nfunction getTrueOffsetParent(element, polyfill) {\n if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {\n return null;\n }\n if (polyfill) {\n return polyfill(element);\n }\n let rawOffsetParent = element.offsetParent;\n\n // Firefox returns the <html> element as the offsetParent if it's non-static,\n // while Chrome and Safari return the <body> element. The <body> element must\n // be used to perform the correct calculations even if the <html> element is\n // non-static.\n if (getDocumentElement(element) === rawOffsetParent) {\n rawOffsetParent = rawOffsetParent.ownerDocument.body;\n }\n return rawOffsetParent;\n}\n\n// Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\nfunction getOffsetParent(element, polyfill) {\n const win = getWindow(element);\n if (isTopLayer(element)) {\n return win;\n }\n if (!isHTMLElement(element)) {\n let svgOffsetParent = getParentNode(element);\n while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {\n if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {\n return svgOffsetParent;\n }\n svgOffsetParent = getParentNode(svgOffsetParent);\n }\n return win;\n }\n let offsetParent = getTrueOffsetParent(element, polyfill);\n while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {\n offsetParent = getTrueOffsetParent(offsetParent, polyfill);\n }\n if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {\n return win;\n }\n return offsetParent || getContainingBlock(element) || win;\n}\n\nconst getElementRects = async function (data) {\n const getOffsetParentFn = this.getOffsetParent || getOffsetParent;\n const getDimensionsFn = this.getDimensions;\n const floatingDimensions = await getDimensionsFn(data.floating);\n return {\n reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),\n floating: {\n x: 0,\n y: 0,\n width: floatingDimensions.width,\n height: floatingDimensions.height\n }\n };\n};\n\nfunction isRTL(element) {\n return getComputedStyle$1(element).direction === 'rtl';\n}\n\nconst platform = {\n convertOffsetParentRelativeRectToViewportRelativeRect,\n getDocumentElement,\n getClippingRect,\n getOffsetParent,\n getElementRects,\n getClientRects,\n getDimensions,\n getScale,\n isElement,\n isRTL\n};\n\nfunction rectsAreEqual(a, b) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\n// https://samthor.au/2021/observing-dom/\nfunction observeMove(element, onMove) {\n let io = null;\n let timeoutId;\n const root = getDocumentElement(element);\n function cleanup() {\n var _io;\n clearTimeout(timeoutId);\n (_io = io) == null || _io.disconnect();\n io = null;\n }\n function refresh(skip, threshold) {\n if (skip === void 0) {\n skip = false;\n }\n if (threshold === void 0) {\n threshold = 1;\n }\n cleanup();\n const elementRectForRootMargin = element.getBoundingClientRect();\n const {\n left,\n top,\n width,\n height\n } = elementRectForRootMargin;\n if (!skip) {\n onMove();\n }\n if (!width || !height) {\n return;\n }\n const insetTop = floor(top);\n const insetRight = floor(root.clientWidth - (left + width));\n const insetBottom = floor(root.clientHeight - (top + height));\n const insetLeft = floor(left);\n const rootMargin = -insetTop + \"px \" + -insetRight + \"px \" + -insetBottom + \"px \" + -insetLeft + \"px\";\n const options = {\n rootMargin,\n threshold: max(0, min(1, threshold)) || 1\n };\n let isFirstUpdate = true;\n function handleObserve(entries) {\n const ratio = entries[0].intersectionRatio;\n if (ratio !== threshold) {\n if (!isFirstUpdate) {\n return refresh();\n }\n if (!ratio) {\n // If the reference is clipped, the ratio is 0. Throttle the refresh\n // to prevent an infinite loop of updates.\n timeoutId = setTimeout(() => {\n refresh(false, 1e-7);\n }, 1000);\n } else {\n refresh(false, ratio);\n }\n }\n if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {\n // It's possible that even though the ratio is reported as 1, the\n // element is not actually fully within the IntersectionObserver's root\n // area anymore. This can happen under performance constraints. This may\n // be a bug in the browser's IntersectionObserver implementation. To\n // work around this, we compare the element's bounding rect now with\n // what it was at the time we created the IntersectionObserver. If they\n // are not equal then the element moved, so we refresh.\n refresh();\n }\n isFirstUpdate = false;\n }\n\n // Older browsers don't support a `document` as the root and will throw an\n // error.\n try {\n io = new IntersectionObserver(handleObserve, {\n ...options,\n // Handle <iframe>s\n root: root.ownerDocument\n });\n } catch (_e) {\n io = new IntersectionObserver(handleObserve, options);\n }\n io.observe(element);\n }\n refresh(true);\n return cleanup;\n}\n\n/**\n * Automatically updates the position of the floating element when necessary.\n * Should only be called when the floating element is mounted on the DOM or\n * visible on the screen.\n * @returns cleanup function that should be invoked when the floating element is\n * removed from the DOM or hidden from the screen.\n * @see https://floating-ui.com/docs/autoUpdate\n */\nfunction autoUpdate(reference, floating, update, options) {\n if (options === void 0) {\n options = {};\n }\n const {\n ancestorScroll = true,\n ancestorResize = true,\n elementResize = typeof ResizeObserver === 'function',\n layoutShift = typeof IntersectionObserver === 'function',\n animationFrame = false\n } = options;\n const referenceEl = unwrapElement(reference);\n const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];\n ancestors.forEach(ancestor => {\n ancestorScroll && ancestor.addEventListener('scroll', update, {\n passive: true\n });\n ancestorResize && ancestor.addEventListener('resize', update);\n });\n const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;\n let reobserveFrame = -1;\n let resizeObserver = null;\n if (elementResize) {\n resizeObserver = new ResizeObserver(_ref => {\n let [firstEntry] = _ref;\n if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {\n // Prevent update loops when using the `size` middleware.\n // https://github.com/floating-ui/floating-ui/issues/1740\n resizeObserver.unobserve(floating);\n cancelAnimationFrame(reobserveFrame);\n reobserveFrame = requestAnimationFrame(() => {\n var _resizeObserver;\n (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);\n });\n }\n update();\n });\n if (referenceEl && !animationFrame) {\n resizeObserver.observe(referenceEl);\n }\n resizeObserver.observe(floating);\n }\n let frameId;\n let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;\n if (animationFrame) {\n frameLoop();\n }\n function frameLoop() {\n const nextRefRect = getBoundingClientRect(reference);\n if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {\n update();\n }\n prevRefRect = nextRefRect;\n frameId = requestAnimationFrame(frameLoop);\n }\n update();\n return () => {\n var _resizeObserver2;\n ancestors.forEach(ancestor => {\n ancestorScroll && ancestor.removeEventListener('scroll', update);\n ancestorResize && ancestor.removeEventListener('resize', update);\n });\n cleanupIo == null || cleanupIo();\n (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();\n resizeObserver = null;\n if (animationFrame) {\n cancelAnimationFrame(frameId);\n }\n };\n}\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nconst detectOverflow = detectOverflow$1;\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = offset$1;\n\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = autoPlacement$1;\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = shift$1;\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = flip$1;\n\n/**\n * Provides data that allows you to change the size of the floating element \u2014\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = size$1;\n\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = hide$1;\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = arrow$1;\n\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = inline$1;\n\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = limitShift$1;\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n */\nconst computePosition = (reference, floating, options) => {\n // This caches the expensive `getClippingElementAncestors` function so that\n // multiple lifecycle resets re-use the same result. It only lives for a\n // single call. If other functions become expensive, we can add them as well.\n const cache = new Map();\n const mergedOptions = {\n platform,\n ...options\n };\n const platformWithCache = {\n ...mergedOptions.platform,\n _c: cache\n };\n return computePosition$1(reference, floating, {\n ...mergedOptions,\n platform: platformWithCache\n });\n};\n\nexport { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, platform, shift, size };\n", "/**\n * Link Tooltip - Shows a clickable tooltip when cursor is within a link\n * Uses Floating UI for positioning across all browsers\n */\n\nimport { computePosition, offset, shift, flip } from '@floating-ui/dom';\n\nexport class LinkTooltip {\n constructor(editor) {\n this.editor = editor;\n this.tooltip = null;\n this.currentLink = null;\n this.hideTimeout = null;\n this.visibilityChangeHandler = null;\n this.isTooltipHovered = false;\n\n this.init();\n }\n\n init() {\n // Create tooltip element\n this.createTooltip();\n\n // Listen for cursor position changes\n this.editor.textarea.addEventListener('selectionchange', () => this.checkCursorPosition());\n this.editor.textarea.addEventListener('keyup', e => {\n if (e.key.includes('Arrow') || e.key === 'Home' || e.key === 'End') {\n this.checkCursorPosition();\n }\n });\n\n // Hide tooltip when typing\n this.editor.textarea.addEventListener('input', () => this.hide());\n\n // Reposition tooltip when scrolling\n this.editor.textarea.addEventListener('scroll', () => {\n if (this.currentLink) {\n this.positionTooltip(this.currentLink);\n }\n });\n\n // Hide tooltip when textarea loses focus (unless hovering tooltip)\n this.editor.textarea.addEventListener('blur', () => {\n if (!this.isTooltipHovered) {\n this.hide();\n }\n });\n\n // Hide tooltip when page loses visibility (tab switch, minimize, etc.)\n this.visibilityChangeHandler = () => {\n if (document.hidden) {\n this.hide();\n }\n };\n document.addEventListener('visibilitychange', this.visibilityChangeHandler);\n\n // Track hover state to prevent hiding when clicking tooltip\n this.tooltip.addEventListener('mouseenter', () => {\n this.isTooltipHovered = true;\n this.cancelHide();\n });\n this.tooltip.addEventListener('mouseleave', () => {\n this.isTooltipHovered = false;\n this.scheduleHide();\n });\n }\n\n createTooltip() {\n this.tooltip = document.createElement('div');\n this.tooltip.className = 'overtype-link-tooltip';\n\n // Add link icon and text container\n this.tooltip.innerHTML = `\n <span style=\"display: flex; align-items: center; gap: 6px;\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"flex-shrink: 0;\">\n <path d=\"M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z\"></path>\n <path d=\"M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z\"></path>\n </svg>\n <span class=\"overtype-link-tooltip-url\"></span>\n </span>\n `;\n\n // Click handler to open link\n this.tooltip.addEventListener('click', e => {\n e.preventDefault();\n e.stopPropagation();\n if (this.currentLink) {\n window.open(this.currentLink.url, '_blank');\n this.hide();\n }\n });\n\n // Append tooltip to editor container\n this.editor.container.appendChild(this.tooltip);\n }\n\n checkCursorPosition() {\n const cursorPos = this.editor.textarea.selectionStart;\n const text = this.editor.textarea.value;\n\n // Find if cursor is within a markdown link\n const linkInfo = this.findLinkAtPosition(text, cursorPos);\n\n if (linkInfo) {\n if (!this.currentLink || this.currentLink.url !== linkInfo.url || this.currentLink.index !== linkInfo.index) {\n this.show(linkInfo);\n }\n } else {\n this.scheduleHide();\n }\n }\n\n findLinkAtPosition(text, position) {\n // Regex to find markdown links: [text](url)\n const linkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n let match;\n let linkIndex = 0;\n\n while ((match = linkRegex.exec(text)) !== null) {\n const start = match.index;\n const end = match.index + match[0].length;\n\n if (position >= start && position <= end) {\n return {\n text: match[1],\n url: match[2],\n index: linkIndex,\n start: start,\n end: end\n };\n }\n linkIndex++;\n }\n\n return null;\n }\n\n async show(linkInfo) {\n this.currentLink = linkInfo;\n this.cancelHide();\n\n // Update tooltip content\n const urlSpan = this.tooltip.querySelector('.overtype-link-tooltip-url');\n urlSpan.textContent = linkInfo.url;\n\n // Position first (tooltip is always rendered but invisible, so Floating UI can measure it)\n await this.positionTooltip(linkInfo);\n\n // Only reveal if we're still showing this link\n if (this.currentLink === linkInfo) {\n this.tooltip.classList.add('visible');\n }\n }\n\n async positionTooltip(linkInfo) {\n const anchorElement = this.findAnchorElement(linkInfo.index);\n\n if (!anchorElement) {\n return;\n }\n\n const rect = anchorElement.getBoundingClientRect();\n if (rect.width === 0 || rect.height === 0) {\n return;\n }\n\n try {\n const { x, y } = await computePosition(\n anchorElement,\n this.tooltip,\n {\n strategy: 'fixed',\n placement: 'bottom',\n middleware: [\n offset(8),\n shift({ padding: 8 }),\n flip()\n ]\n }\n );\n\n Object.assign(this.tooltip.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed'\n });\n } catch (error) {\n console.warn('Floating UI positioning failed:', error);\n }\n }\n\n findAnchorElement(linkIndex) {\n const preview = this.editor.preview;\n return preview.querySelector(`a[style*=\"--link-${linkIndex}\"]`);\n }\n\n hide() {\n this.tooltip.classList.remove('visible');\n this.currentLink = null;\n this.isTooltipHovered = false;\n }\n\n scheduleHide() {\n this.cancelHide();\n this.hideTimeout = setTimeout(() => this.hide(), 300);\n }\n\n cancelHide() {\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n }\n\n destroy() {\n this.cancelHide();\n\n if (this.visibilityChangeHandler) {\n document.removeEventListener('visibilitychange', this.visibilityChangeHandler);\n this.visibilityChangeHandler = null;\n }\n\n if (this.tooltip && this.tooltip.parentNode) {\n this.tooltip.parentNode.removeChild(this.tooltip);\n }\n this.tooltip = null;\n this.currentLink = null;\n this.isTooltipHovered = false;\n }\n}\n", "/**\n * SVG icons for OverType toolbar\n * Quill-style icons with inline styles\n */\n\nexport const boldIcon = `<svg viewBox=\"0 0 18 18\">\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z\"></path>\n</svg>`;\n\nexport const italicIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"13\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"5\" x2=\"11\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"10\" y1=\"14\" y2=\"4\"></line>\n</svg>`;\n\nexport const h1Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z\"></path>\n</svg>`;\n\nexport const h2Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z\"></path>\n</svg>`;\n\nexport const h3Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M16.65186,12.30664a2.6742,2.6742,0,0,1-2.915,2.68457,3.96592,3.96592,0,0,1-2.25537-.6709.56007.56007,0,0,1-.13232-.83594L11.64648,13c.209-.34082.48389-.36328.82471-.1543a2.32654,2.32654,0,0,0,1.12256.33008c.71484,0,1.12207-.35156,1.12207-.78125,0-.61523-.61621-.86816-1.46338-.86816H13.2085a.65159.65159,0,0,1-.68213-.41895l-.05518-.10937a.67114.67114,0,0,1,.14307-.78125l.71533-.86914a8.55289,8.55289,0,0,1,.68213-.7373V8.58887a3.93913,3.93913,0,0,1-.748.05469H11.9873a.54085.54085,0,0,1-.605-.60547V7.59863a.54085.54085,0,0,1,.605-.60547h3.75146a.53773.53773,0,0,1,.60547.59375v.17676a1.03723,1.03723,0,0,1-.27539.748L14.74854,10.0293A2.31132,2.31132,0,0,1,16.65186,12.30664ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z\"></path>\n</svg>`;\n\nexport const linkIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"11\" y1=\"7\" y2=\"11\"></line>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z\"></path>\n</svg>`;\n\nexport const codeIcon = `<svg viewBox=\"0 0 18 18\">\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" points=\"5 7 3 9 5 11\"></polyline>\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" points=\"13 7 15 9 13 11\"></polyline>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"10\" x2=\"8\" y1=\"5\" y2=\"13\"></line>\n</svg>`;\n\n\nexport const bulletListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"14\" y2=\"14\"></line>\n</svg>`;\n\nexport const orderedListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" x1=\"2.5\" x2=\"4.5\" y1=\"5.5\" y2=\"5.5\"></line>\n <path fill=\"currentColor\" d=\"M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" d=\"M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" d=\"M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109\"></path>\n</svg>`;\n\nexport const quoteIcon = `<svg viewBox=\"2 2 20 20\">\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14\"></path>\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14\"></path>\n</svg>`;\n\nexport const taskListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"14\" y2=\"14\"></line>\n <rect stroke=\"currentColor\" fill=\"none\" stroke-width=\"1.5\" x=\"2\" y=\"3\" width=\"3\" height=\"3\" rx=\"0.5\"></rect>\n <rect stroke=\"currentColor\" fill=\"none\" stroke-width=\"1.5\" x=\"2\" y=\"13\" width=\"3\" height=\"3\" rx=\"0.5\"></rect>\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" points=\"2.65 9.5 3.5 10.5 5 8.5\"></polyline>\n</svg>`;\n\nexport const uploadIcon = `<svg viewBox=\"0 0 18 18\">\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M2.25 12.375v1.688A1.688 1.688 0 0 0 3.938 15.75h10.124a1.688 1.688 0 0 0 1.688-1.688V12.375\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5.063 6.188L9 2.25l3.938 3.938\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M9 2.25v10.125\"></path>\n</svg>`;\n\nexport const eyeIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\" fill=\"none\"></path>\n <circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"none\"></circle>\n</svg>`;", "/**\n * Toolbar button definitions for OverType editor\n * Export built-in buttons that can be used in custom toolbar configurations\n */\n\nimport * as icons from './icons.js';\nimport * as markdownActions from 'markdown-actions';\n\n/**\n * Built-in toolbar button definitions\n * Each button has: name, actionId, icon, title, action\n * - name: DOM identifier for the button element\n * - actionId: Canonical action identifier used by performAction\n * Action signature: ({ editor, getValue, setValue, event }) => void\n */\nexport const toolbarButtons = {\n bold: {\n name: 'bold',\n actionId: 'toggleBold',\n icon: icons.boldIcon,\n title: 'Bold (Ctrl+B)',\n action: ({ editor }) => {\n markdownActions.toggleBold(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n italic: {\n name: 'italic',\n actionId: 'toggleItalic',\n icon: icons.italicIcon,\n title: 'Italic (Ctrl+I)',\n action: ({ editor }) => {\n markdownActions.toggleItalic(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n code: {\n name: 'code',\n actionId: 'toggleCode',\n icon: icons.codeIcon,\n title: 'Inline Code',\n action: ({ editor }) => {\n markdownActions.toggleCode(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n separator: {\n name: 'separator'\n // No icon, title, or action - special separator element\n },\n\n link: {\n name: 'link',\n actionId: 'insertLink',\n icon: icons.linkIcon,\n title: 'Insert Link',\n action: ({ editor }) => {\n markdownActions.insertLink(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n h1: {\n name: 'h1',\n actionId: 'toggleH1',\n icon: icons.h1Icon,\n title: 'Heading 1',\n action: ({ editor }) => {\n markdownActions.toggleH1(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n h2: {\n name: 'h2',\n actionId: 'toggleH2',\n icon: icons.h2Icon,\n title: 'Heading 2',\n action: ({ editor }) => {\n markdownActions.toggleH2(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n h3: {\n name: 'h3',\n actionId: 'toggleH3',\n icon: icons.h3Icon,\n title: 'Heading 3',\n action: ({ editor }) => {\n markdownActions.toggleH3(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n bulletList: {\n name: 'bulletList',\n actionId: 'toggleBulletList',\n icon: icons.bulletListIcon,\n title: 'Bullet List',\n action: ({ editor }) => {\n markdownActions.toggleBulletList(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n orderedList: {\n name: 'orderedList',\n actionId: 'toggleNumberedList',\n icon: icons.orderedListIcon,\n title: 'Numbered List',\n action: ({ editor }) => {\n markdownActions.toggleNumberedList(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n taskList: {\n name: 'taskList',\n actionId: 'toggleTaskList',\n icon: icons.taskListIcon,\n title: 'Task List',\n action: ({ editor }) => {\n if (markdownActions.toggleTaskList) {\n markdownActions.toggleTaskList(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n },\n\n quote: {\n name: 'quote',\n actionId: 'toggleQuote',\n icon: icons.quoteIcon,\n title: 'Quote',\n action: ({ editor }) => {\n markdownActions.toggleQuote(editor.textarea);\n editor.textarea.dispatchEvent(new Event('input', { bubbles: true }));\n }\n },\n\n upload: {\n name: 'upload',\n actionId: 'uploadFile',\n icon: icons.uploadIcon,\n title: 'Upload File',\n action: ({ editor }) => {\n if (!editor.options.fileUpload?.enabled) return;\n const input = document.createElement('input');\n input.type = 'file';\n input.multiple = true;\n if (editor.options.fileUpload.mimeTypes?.length > 0) {\n input.accept = editor.options.fileUpload.mimeTypes.join(',');\n }\n input.onchange = () => {\n if (!input.files?.length) return;\n const dt = new DataTransfer();\n for (const f of input.files) dt.items.add(f);\n editor._handleDataTransfer(dt);\n };\n input.click();\n }\n },\n\n viewMode: {\n name: 'viewMode',\n icon: icons.eyeIcon,\n title: 'View mode'\n // Special: handled internally by Toolbar class as dropdown\n // No action property - dropdown behavior is internal\n }\n};\n\n/**\n * Default toolbar button layout with separators\n * This is used when toolbar: true but no toolbarButtons provided\n */\nexport const defaultToolbarButtons = [\n toolbarButtons.bold,\n toolbarButtons.italic,\n toolbarButtons.code,\n toolbarButtons.separator,\n toolbarButtons.link,\n toolbarButtons.separator,\n toolbarButtons.h1,\n toolbarButtons.h2,\n toolbarButtons.h3,\n toolbarButtons.separator,\n toolbarButtons.bulletList,\n toolbarButtons.orderedList,\n toolbarButtons.taskList,\n toolbarButtons.separator,\n toolbarButtons.quote,\n toolbarButtons.separator,\n toolbarButtons.viewMode\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAa1B,OAAO,iBAAiB;AACtB,SAAK,YAAY;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,mBAAmB,aAAa;AACrC,SAAK,kBAAkB;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,gBAAgB,WAAW;AAChC,SAAK,eAAe;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,kBAAkB,MAAM;AAC7B,QAAI,KAAK,cAAc;AACrB,aAAO,KAAK,aAAa,IAAI;AAAA,IAC/B;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,MAAM;AACtB,UAAM,MAAM;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AACA,WAAO,KAAK,QAAQ,YAAY,OAAK,IAAI,CAAC,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,oBAAoB,MAAM,cAAc;AAC7C,UAAM,gBAAgB,aAAa,MAAM,QAAQ,EAAE,CAAC;AACpD,UAAM,cAAc,cAAc,QAAQ,MAAM,QAAQ;AACxD,WAAO,KAAK,QAAQ,QAAQ,WAAW;AAAA,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BAA6B;AAAA,EACxC;AACJ;AAAA;AAnqDI,cAFE,WAEK,aAAY,oBAAI,QAAQ;AAC/B,cAHE,WAGK,kBAAiB;AACxB,cAJE,WAIK,8BAA6B;AACpC,cALE,WAKK,iBAAgB;AACvB,cANE,WAMK,mBAAkB;AACzB,cAPE,WAOK,sBAAqB;AAC5B,cARE,WAQK,kBAAiB,oBAAI,IAAI;AAChC,cATE,WASK,oBAAmB;AAC1B,cAVE,WAUK,2BAA0B;AAVrC,IAAM,WAAN;AAwqDA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAG5B,SAAS,SAAS,EAAE,OAAO,MAAM,SAAS,MAAM,EAAE;AAClD,SAAS,WAAW;AAGpB,SAAS,eAAe;AAGxB,IAAO,mBAAQ;",
6
6
  "names": ["result", "debugMode", "getActiveFormats", "platform", "platform", "placements", "sides", "side", "placement", "overflow", "platform", "x", "y", "min", "max", "getComputedStyle", "getComputedStyle", "offset", "shift", "flip", "computePosition", "computePosition", "offset", "shift", "flip", "_a", "toolbarButtons", "offset"]
7
7
  }